void ert_workflow_list_init( ert_workflow_list_type * workflow_list , config_content_type * config ) { /* Adding jobs */ { if (config_content_has_item( config , WORKFLOW_JOB_DIRECTORY_KEY)) { const config_content_item_type * jobpath_item = config_content_get_item( config , WORKFLOW_JOB_DIRECTORY_KEY); for (int i=0; i < config_content_item_get_size( jobpath_item ); i++) { config_content_node_type * path_node = config_content_item_iget_node( jobpath_item , i ); for (int j=0; j < config_content_node_get_size( path_node ); j++) ert_workflow_list_add_jobs_in_directory( workflow_list , config_content_node_iget_as_abspath( path_node , j ) ); } } } { if (config_content_has_item( config , LOAD_WORKFLOW_JOB_KEY)) { const config_content_item_type * job_item = config_content_get_item( config , LOAD_WORKFLOW_JOB_KEY); for (int i=0; i < config_content_item_get_size( job_item ); i++) { config_content_node_type * job_node = config_content_item_iget_node( job_item , i ); const char * config_file = config_content_node_iget_as_path( job_node , 0 ); const char * job_name = config_content_node_safe_iget( job_node , 1 ); ert_workflow_list_add_job( workflow_list , job_name , config_file); } } } /* Adding workflows */ { if (config_content_has_item( config , LOAD_WORKFLOW_KEY)) { const config_content_item_type * workflow_item = config_content_get_item( config , LOAD_WORKFLOW_KEY); for (int i=0; i < config_content_item_get_size( workflow_item ); i++) { config_content_node_type * workflow_node = config_content_item_iget_node( workflow_item , i ); const char * workflow_file = config_content_node_iget_as_path( workflow_node , 0 ); const char * workflow_name = config_content_node_safe_iget( workflow_node , 1 ); ert_workflow_list_add_workflow( workflow_list , workflow_file , workflow_name ); } } } }
void ensemble_config_init_CUSTOM_KW(ensemble_config_type * ensemble_config, const config_content_type * config) { if (config_content_has_item(config, CUSTOM_KW_KEY)) { const config_content_item_type * custom_kw_item = config_content_get_item(config, CUSTOM_KW_KEY); for (int i = 0; i < config_content_item_get_size(custom_kw_item); i++) { config_content_node_type * node = config_content_item_iget_node(custom_kw_item, i); const char * key = config_content_node_iget(node, 0); const char * result_file = config_content_node_iget_as_path(node, 1); const char * output_file = NULL; if(config_content_node_get_size(node) > 2) { output_file = config_content_node_iget_as_path(node, 2); } enkf_config_node_type * config_node = ensemble_config_add_custom_kw(ensemble_config, key, result_file, output_file); enkf_config_node_update_custom_kw(config_node, result_file, output_file); enkf_config_node_set_internalize(config_node, 0); } } }
void ensemble_config_init_GEN_KW( ensemble_config_type * ensemble_config , const config_type * config ) { const config_content_item_type * gen_kw_item = config_get_content_item( config , GEN_KW_KEY ); if (gen_kw_item != NULL) { int i; for (i=0; i < config_content_item_get_size( gen_kw_item ); i++) { config_content_node_type * node = config_content_item_iget_node( gen_kw_item , i ); const char * key = config_content_node_iget( node , 0 ); const char * template_file = config_content_node_iget_as_path( node , 1 ); const char * enkf_outfile = config_content_node_iget( node , 2 ); const char * parameter_file = config_content_node_iget_as_path( node , 3 ); hash_type * opt_hash = hash_alloc(); config_content_node_init_opt_hash( node , opt_hash , 4 ); { const char * forward_string = hash_safe_get( opt_hash , FORWARD_INIT_KEY ); enkf_config_node_type * config_node; bool forward_init = false; if (forward_string) { if (!util_sscanf_bool( forward_string , &forward_init)) fprintf(stderr,"** Warning: parsing %s as bool failed - using FALSE \n",forward_string); } config_node = ensemble_config_add_gen_kw( ensemble_config , key , forward_init); enkf_config_node_update_gen_kw( config_node , enkf_outfile , template_file , parameter_file , hash_safe_get( opt_hash , MIN_STD_KEY ) , hash_safe_get( opt_hash , INIT_FILES_KEY)); } hash_free( opt_hash ); } } }
void ecl_config_init( ecl_config_type * ecl_config , const config_type * config ) { if (config_item_set( config , ECLBASE_KEY )) ecl_config_set_eclbase( ecl_config , config_iget(config , ECLBASE_KEY ,0,0) ); if (config_item_set( config , DATA_FILE_KEY )) ecl_config_set_data_file( ecl_config , config_iget( config , DATA_FILE_KEY ,0,0)); if (config_item_set( config , SCHEDULE_FILE_KEY )) ecl_config_set_schedule_file( ecl_config , config_iget( config , SCHEDULE_FILE_KEY ,0,0)); if (config_item_set(config , GRID_KEY)) ecl_config_set_grid( ecl_config , config_iget(config , GRID_KEY , 0,0) ); if (config_item_set( config , ADD_FIXED_LENGTH_SCHEDULE_KW_KEY)) { int iocc; for (iocc = 0; iocc < config_get_occurences(config , ADD_FIXED_LENGTH_SCHEDULE_KW_KEY); iocc++) ecl_config_add_fixed_length_schedule_kw( ecl_config , config_iget(config , ADD_FIXED_LENGTH_SCHEDULE_KW_KEY , iocc , 0) , config_iget_as_int(config , ADD_FIXED_LENGTH_SCHEDULE_KW_KEY , iocc , 1)); } if (config_item_set( config , REFCASE_KEY)) { const char * refcase_path = config_get_value_as_path( config , REFCASE_KEY ); if (!ecl_config_load_refcase( ecl_config , refcase_path)) fprintf(stderr,"** Warning: loading refcase:%s failed \n", refcase_path); } if (config_item_set( config , REFCASE_LIST_KEY)) { config_content_item_type * item = config_get_content_item( config , REFCASE_LIST_KEY); int i; for (i=0; i < config_content_item_get_size( item ); i++) { config_content_node_type * node = config_content_item_iget_node( item , i ); int j; for (j=0; j < config_content_node_get_size( node ); j++) { const char * case_glob = config_content_node_iget_as_path( node , j ); ecl_refcase_list_add_matching( ecl_config->refcase_list , case_glob ); } } } /* Deprecated */ if (config_item_set( config , PLOT_REFCASE_LIST_KEY)) { const char * case_list_file = config_get_value( config , PLOT_REFCASE_LIST_KEY); FILE * stream = util_fopen(case_list_file , "r"); bool at_eof; do { char * case_name = util_fscanf_alloc_line(stream , &at_eof); if (case_name) { ecl_refcase_list_add_case( ecl_config->refcase_list , case_name); free( case_name ); } } while (!at_eof); fclose( stream ); } if (config_item_set(config , INIT_SECTION_KEY)) ecl_config_set_init_section( ecl_config , config_get_value( config , INIT_SECTION_KEY )); else if (ecl_config->can_restart) /** This is a hard error - the datafile contains <INIT>, however the config file does NOT contain INIT_SECTION, i.e. we have no information to fill in for the <INIT> section. This case will not be able to initialize an ECLIPSE model, and that is broken behaviour. */ util_exit("Sorry: when the datafile contains <INIT> the config file MUST have the INIT_SECTION keyword. \n"); /* The user has not supplied a INIT_SECTION keyword whatsoever, this essentially means that we can not restart - because: 1. The EQUIL section must be inlined in the DATAFILE without any special markup. 2. ECLIPSE will fail hard if the datafile contains both an EQUIL section and a restart statement, and when we have not marked the EQUIL section specially with the INIT_SECTION keyword it is impossible for ERT to dynamically change between a datafile with initialisation and a datafile for restart. IFF the user has no intentitions of any form of restart, this is perfectly legitemate. */ if (config_item_set( config , END_DATE_KEY )) { const char * date_string = config_get_value( config , END_DATE_KEY ); time_t end_date; if (util_sscanf_date( date_string , &end_date)) ecl_config_set_end_date( ecl_config , end_date ); else fprintf(stderr,"** WARNING **: Failed to parse %s as a date - should be in format dd/mm/yyyy \n",date_string); } }
void ecl_config_init(ecl_config_type * ecl_config, const config_content_type * config) { if (config_content_has_item(config, ECLBASE_KEY)) { ui_return_type * ui_return = ecl_config_validate_eclbase(ecl_config, config_content_iget(config, ECLBASE_KEY, 0, 0)); if (ui_return_get_status(ui_return) == UI_RETURN_OK) ecl_config_set_eclbase(ecl_config, config_content_iget(config, ECLBASE_KEY, 0, 0)); else util_abort("%s: failed to set eclbase format. Error:%s\n", __func__ , ui_return_get_last_error(ui_return)); ui_return_free(ui_return); } if (config_content_has_item(config, DATA_FILE_KEY)) { ui_return_type * ui_return = ecl_config_validate_data_file(ecl_config, config_content_iget(config, DATA_FILE_KEY, 0, 0)); if (ui_return_get_status( ui_return ) == UI_RETURN_OK) ecl_config_set_data_file( ecl_config, config_content_iget(config, DATA_FILE_KEY, 0, 0) ); else util_abort("%s: problem setting ECLIPSE data file\n",__func__ , ui_return_get_last_error(ui_return)); ui_return_free(ui_return); } if (config_content_has_item(config, SCHEDULE_FILE_KEY)) { const char * schedule_target_file = config_content_safe_iget(config, SCHEDULE_FILE_KEY, 0, 1); if (schedule_target_file) { ui_return_type * ui_return_sched_target_file = ecl_config_validate_schedule_file(ecl_config, schedule_target_file); if (!ui_return_get_status(ui_return_sched_target_file) == UI_RETURN_OK) { util_abort("%s: failed to set target schedule file. Error:%s\n",__func__ , ui_return_get_last_error(ui_return_sched_target_file)); } ui_return_free(ui_return_sched_target_file); } ui_return_type * ui_return = ecl_config_validate_schedule_file(ecl_config, config_content_iget(config, SCHEDULE_FILE_KEY, 0, 0)); if (ui_return_get_status(ui_return) == UI_RETURN_OK) ecl_config_set_schedule_file(ecl_config, config_content_iget(config, SCHEDULE_FILE_KEY, 0, 0), schedule_target_file); else util_abort("%s: failed to set schedule file. Error:%s\n",__func__ , ui_return_get_last_error(ui_return)); ui_return_free(ui_return); } if (config_content_has_item(config, GRID_KEY)) { const char * grid_file = config_content_iget(config, GRID_KEY, 0, 0); ui_return_type * ui_return = ecl_config_validate_grid( ecl_config , grid_file); if (ui_return_get_status(ui_return) == UI_RETURN_OK) ecl_config_set_grid(ecl_config, grid_file ); else util_abort("%s: failed to set grid file:%s Error:%s \n",__func__ , grid_file , ui_return_get_last_error(ui_return)); ui_return_free( ui_return ); } if (config_content_has_item(config, ADD_FIXED_LENGTH_SCHEDULE_KW_KEY)) { int iocc; for (iocc = 0; iocc < config_content_get_occurences(config, ADD_FIXED_LENGTH_SCHEDULE_KW_KEY); iocc++) ecl_config_add_fixed_length_schedule_kw(ecl_config, config_content_iget(config, ADD_FIXED_LENGTH_SCHEDULE_KW_KEY, iocc, 0), config_content_iget_as_int(config, ADD_FIXED_LENGTH_SCHEDULE_KW_KEY, iocc, 1)); } if (config_content_has_item(config, REFCASE_KEY)) { const char * refcase_path = config_content_get_value_as_path(config, REFCASE_KEY); if (!ecl_config_load_refcase(ecl_config, refcase_path)) fprintf(stderr, "** Warning: loading refcase:%s failed \n", refcase_path); } if (config_content_has_item(config, REFCASE_LIST_KEY)) { config_content_item_type * item = config_content_get_item(config, REFCASE_LIST_KEY); int i; for (i = 0; i < config_content_item_get_size(item); i++) { config_content_node_type * node = config_content_item_iget_node(item, i); int j; for (j = 0; j < config_content_node_get_size(node); j++) { const char * case_glob = config_content_node_iget_as_path(node, j); ecl_refcase_list_add_matching(ecl_config->refcase_list, case_glob); } } } if (config_content_has_item(config, INIT_SECTION_KEY)) ecl_config_set_init_section(ecl_config, config_content_get_value(config, INIT_SECTION_KEY)); else if (ecl_config->can_restart) /** This is a hard error - the datafile contains <INIT>, however the config file does NOT contain INIT_SECTION, i.e. we have no information to fill in for the <INIT> section. This case will not be able to initialize an ECLIPSE model, and that is broken behaviour. */ util_exit("Sorry: when the datafile contains <INIT> the config file MUST have the INIT_SECTION keyword. \n"); /* The user has not supplied a INIT_SECTION keyword whatsoever, this essentially means that we can not restart - because: 1. The EQUIL section must be inlined in the DATAFILE without any special markup. 2. ECLIPSE will fail hard if the datafile contains both an EQUIL section and a restart statement, and when we have not marked the EQUIL section specially with the INIT_SECTION keyword it is impossible for ERT to dynamically change between a datafile with initialisation and a datafile for restart. IFF the user has no intentitions of any form of restart, this is perfectly legitemate. */ if (config_content_has_item(config, END_DATE_KEY)) { const char * date_string = config_content_get_value(config, END_DATE_KEY); time_t end_date; if (util_sscanf_date_utc(date_string, &end_date)) ecl_config_set_end_date(ecl_config, end_date); else fprintf(stderr, "** WARNING **: Failed to parse %s as a date - should be in format dd/mm/yyyy \n", date_string); } }
const char * config_content_get_value_as_path( const config_content_type * config , const char * kw) { config_content_node_type * node = config_content_get_value_node__( config , kw ); return config_content_node_iget_as_path(node , 0); }
const char * config_content_iget_as_path( const config_content_type * content , const char * key , int occurence , int index) { config_content_item_type * item = config_content_get_item(content , key); config_content_node_type * node = config_content_item_iget_node( item , index ); return config_content_node_iget_as_path(node , index); }