Skip to content
This repository has been archived by the owner on Sep 30, 2020. It is now read-only.

Commit

Permalink
Merge pull request #960 from joakim-hove/version-1.10
Browse files Browse the repository at this point in the history
Version 1.10
  • Loading branch information
jepebe committed Dec 11, 2015
2 parents d93cf7b + bee5716 commit 0fb14cc
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 37 deletions.
2 changes: 1 addition & 1 deletion devel/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ endif()

set( ERT_VERSION_MAJOR 1 )
set( ERT_VERSION_MINOR 10 )
set( ERT_VERSION_MICRO 7 )
set( ERT_VERSION_MICRO 8 )

# If the micro version is not integer, that should be interpreted as a
# development version leading towards version MAJOR.MINOR.0
Expand Down
1 change: 1 addition & 0 deletions devel/libenkf/include/ert/enkf/block_fs_driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ extern "C" {
int num_fs ,
const char * ens_path_fmt,
const char * filename );
void * block_fs_driver_alloc_new( fs_driver_enum driver_type , bool read_only , int num_fs , const char * mountfile_fmt, bool block_level_lock );

#ifdef __cplusplus
}
Expand Down
6 changes: 3 additions & 3 deletions devel/libenkf/include/ert/enkf/fs_driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -199,12 +199,12 @@ struct fs_driver_struct {
void fs_driver_init(fs_driver_type * );
void fs_driver_assert_cast(const fs_driver_type * );
fs_driver_type * fs_driver_safe_cast(void * );

void fs_driver_init_fstab( FILE * stream, fs_driver_impl driver_id );
FILE * fs_driver_open_fstab( const char * path , bool create);
fs_driver_impl fs_driver_fread_type( FILE * stream );
fs_driver_impl fs_driver_fread_type( FILE * stream );
void fs_driver_assert_magic( FILE * stream );
void fs_driver_assert_version( FILE * stream , const char * mount_point);
int fs_driver_assert_version( FILE * stream , const char * mount_point);


#ifdef __cplusplus
Expand Down
18 changes: 10 additions & 8 deletions devel/libenkf/src/block_fs_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ static block_fs_driver_type * block_fs_driver_alloc(int num_fs) {



static void * block_fs_driver_alloc_new( fs_driver_enum driver_type , bool read_only , int num_fs , const char * mountfile_fmt, bool block_level_lock ) {
void * block_fs_driver_alloc_new( fs_driver_enum driver_type , bool read_only , int num_fs , const char * mountfile_fmt, bool block_level_lock ) {
block_fs_driver_type * driver = block_fs_driver_alloc( num_fs);
driver->config = bfs_config_alloc( driver_type , read_only, block_level_lock );
{
Expand Down Expand Up @@ -466,13 +466,15 @@ void block_fs_driver_create_fs( FILE * stream ,
int num_fs ,
const char * ens_path_fmt,
const char * filename ) {

util_fwrite_int(driver_type , stream );
util_fwrite_int(num_fs , stream );
{
char * mountfile_fmt = util_alloc_sprintf("%s%c%s.mnt" , ens_path_fmt , UTIL_PATH_SEP_CHAR , filename );
util_fwrite_string( mountfile_fmt , stream );
free( mountfile_fmt );

if (stream) {
util_fwrite_int(driver_type , stream );
util_fwrite_int(num_fs , stream );
{
char * mountfile_fmt = util_alloc_sprintf("%s%c%s.mnt" , ens_path_fmt , UTIL_PATH_SEP_CHAR , filename );
util_fwrite_string( mountfile_fmt , stream );
free( mountfile_fmt );
}
}

for (int ifs = 0; ifs < num_fs; ifs++) {
Expand Down
61 changes: 44 additions & 17 deletions devel/libenkf/src/enkf_fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -439,33 +439,58 @@ static void enkf_fs_assign_driver( enkf_fs_type * fs , fs_driver_type * driver ,
}


static enkf_fs_type * enkf_fs_mount_block_fs( FILE * fstab_stream , const char * mount_point ) {
static enkf_fs_type * enkf_fs_mount_block_fs( FILE * fstab_stream , const char * mount_point , int file_fs_version) {
enkf_fs_type * fs = enkf_fs_alloc_empty( mount_point );

{
int driver_nr;
for (driver_nr = 0; driver_nr < 5; driver_nr++) {
fs_driver_enum driver_type = util_fread_int( fstab_stream );

fs_driver_type * driver = block_fs_driver_open( fstab_stream , mount_point , driver_type , fs->read_only);
while (true) {
fs_driver_enum driver_type;
if (fread( &driver_type , sizeof driver_type , 1 , fstab_stream) == 1) {
fs_driver_type * driver = block_fs_driver_open( fstab_stream , mount_point , driver_type , fs->read_only);
enkf_fs_assign_driver( fs , driver , driver_type );
} else
break;
}

enkf_fs_assign_driver( fs , driver , driver_type );
/*
The current mount map is of version 106 - which does not have
any information for the STATIC driver; we add a default STATIC driver.
*/
if ((CURRENT_FS_VERSION == 105) && (file_fs_version == 6)) {
int num_fs = 32;
const char * mountfile_fmt = "Ensemble/mod_%d/STATIC.mnt";
fs_driver_type * driver;
bool block_level_lock = false;

fprintf(stderr, "Warning: the current filesystem is created with a newer version of ERT - missing STATIC storage; creating default\n");
block_fs_driver_create_fs( NULL , mount_point , DRIVER_STATIC , num_fs , "Ensemble/mod_%d" , "STATIC");
driver = block_fs_driver_alloc_new( DRIVER_STATIC , fs->read_only , num_fs , mountfile_fmt , block_level_lock );
enkf_fs_assign_driver( fs , driver , DRIVER_STATIC );
}
}
return fs;
}


static enkf_fs_type * enkf_fs_mount_plain( FILE * fstab_stream , const char * mount_point ) {
static enkf_fs_type * enkf_fs_mount_plain( FILE * fstab_stream , const char * mount_point , int file_fs_version) {
enkf_fs_type * fs = enkf_fs_alloc_empty( mount_point );
{
int driver_nr;
for (driver_nr = 0; driver_nr < 5; driver_nr++) {
fs_driver_enum driver_type = util_fread_int( fstab_stream );
fs_driver_type * driver = plain_driver_open( fstab_stream , mount_point );

enkf_fs_assign_driver( fs , driver , driver_type );
while (true) {
fs_driver_enum driver_type;
if (fread( &driver_type , sizeof driver_type , 1 , fstab_stream) == 1) {
fs_driver_type * driver = plain_driver_open( fstab_stream , mount_point );
enkf_fs_assign_driver( fs , driver , driver_type );
} else
break;
}

/*
The current mount map is of version 106 - which does not have
any information for the STATIC driver; we add a default STATIC driver.
*/
if ((CURRENT_FS_VERSION == 105) && (file_fs_version == 106))
util_exit("Warning: the current filesystem is created with a newer version of ERT - please use a newer version of ERT\n");

}
return fs;
}
Expand Down Expand Up @@ -625,17 +650,19 @@ enkf_fs_type * enkf_fs_mount( const char * mount_point ) {

if (stream != NULL) {
enkf_fs_type * fs = NULL;
int file_fs_version;

fs_driver_assert_magic( stream );
fs_driver_assert_version( stream , mount_point );
file_fs_version = fs_driver_assert_version( stream , mount_point );
{
fs_driver_impl driver_id = util_fread_int( stream );

switch( driver_id ) {
case( BLOCK_FS_DRIVER_ID ):
fs = enkf_fs_mount_block_fs( stream , mount_point);
fs = enkf_fs_mount_block_fs( stream , mount_point , file_fs_version);
break;
case( PLAIN_DRIVER_ID ):
fs = enkf_fs_mount_plain( stream , mount_point );
fs = enkf_fs_mount_plain( stream , mount_point , file_fs_version);
break;
default:
util_abort("%s: unrecognized driver_id:%d \n",__func__ , driver_id );
Expand Down
15 changes: 7 additions & 8 deletions devel/libenkf/src/fs_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,17 +192,16 @@ static void upgrade104B(FILE * stream , const char * mount_point) {



void fs_driver_assert_version( FILE * stream , const char * mount_point) {
int fs_driver_assert_version( FILE * stream , const char * mount_point) {
int file_version = util_fread_int( stream );

if (file_version > CURRENT_FS_VERSION)
if (file_version <= 104)
util_exit("%s: The file system you are trying to access is created with a old version of ert - upgrade it?\n",__func__);

if (file_version > 106)
util_exit("%s: The file system you are trying to access is created with a newer version of ert - sorry.\n",__func__);
else if (file_version < CURRENT_FS_VERSION) {
if ((file_version == 104) && (CURRENT_FS_VERSION == 105))
upgrade104B( stream , mount_point );
else
util_exit("%s: The file system you are trying to access is created with a old version of ert - upgrade it?\n",__func__);
}

return file_version;
}


Expand Down

0 comments on commit 0fb14cc

Please sign in to comment.