void ensemble_config_init_SURFACE( ensemble_config_type * ensemble_config , const config_type * config ) { const config_content_item_type * item = config_get_content_item( config , SURFACE_KEY ); if (item != NULL) { int i; for (i=0; i < config_content_item_get_size( item ); i++) { const config_content_node_type * node = config_content_item_iget_node( item , i ); const char * key = config_content_node_iget( node , 0 ); { hash_type * options = hash_alloc(); /* INIT_FILE:<init_files> OUTPUT_FILE:<outfile> BASE_SURFACE:<base_file> */ config_content_node_init_opt_hash( node , options , 1 ); { const char * init_file_fmt = hash_safe_get( options , INIT_FILES_KEY ); const char * output_file = hash_safe_get( options , OUTPUT_FILE_KEY); const char * base_surface = hash_safe_get( options , BASE_SURFACE_KEY); const char * min_std_file = hash_safe_get( options , MIN_STD_KEY); const char * forward_string = hash_safe_get( options , FORWARD_INIT_KEY ); 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); } if ((init_file_fmt == NULL) || (output_file == NULL) || (base_surface == NULL)) { fprintf(stderr,"** error: when entering a surface you must provide arguments:\n"); fprintf(stderr,"** %s:/path/to/input/files%%d \n",INIT_FILES_KEY); fprintf(stderr,"** %s:name_of_output_file\n", OUTPUT_FILE_KEY); fprintf(stderr,"** %s:base_surface_file\n",BASE_SURFACE_KEY); exit(1); } { enkf_config_node_type * config_node = ensemble_config_add_surface( ensemble_config , key , forward_init); enkf_config_node_update_surface( config_node , base_surface , init_file_fmt , output_file , min_std_file ); } } hash_free( options ); } } } }
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 site_config_fprintf_config( const site_config_type * site_config , FILE * stream ) { fprintf( stream , CONFIG_COMMENTLINE_FORMAT ); fprintf( stream , CONFIG_COMMENT_FORMAT , "Here comes system related information - which typically"); fprintf( stream , CONFIG_COMMENT_FORMAT , "overrides information from the site-wide configuration file."); /* Starting with the user defined jobs. */ { stringlist_type * joblist = ext_joblist_alloc_list( site_config->joblist ); char * fmt_key = util_alloc_sprintf(CONFIG_KEY_FORMAT , INSTALL_JOB_KEY); char * install_fmt = util_alloc_sprintf("%s%s%s" , fmt_key , CONFIG_VALUE_FORMAT , CONFIG_ENDVALUE_FORMAT); for (int i=0; i < stringlist_get_size( joblist ); i++) { ext_job_type * ext_job = ext_joblist_get_job( site_config->joblist ,stringlist_iget( joblist , i )); if (ext_job_is_private( ext_job )) ext_job_fprintf_config( ext_job , install_fmt , stream ); } free( install_fmt ); free( fmt_key ); } /* Storing the env variables set with SETENV */ { hash_iter_type * iter = hash_iter_alloc( site_config->env_variables_user ); while (!hash_iter_is_complete( iter )) { const char * var = hash_iter_get_next_key( iter ); const char * user_value = hash_get( site_config->env_variables_user , var ); const char * site_value = hash_safe_get( site_config->env_variables_site , var ); if (!util_string_equal( user_value , site_value)) { fprintf(stream , CONFIG_KEY_FORMAT , SETENV_KEY ); fprintf(stream , CONFIG_VALUE_FORMAT , var ); fprintf(stream , CONFIG_ENDVALUE_FORMAT , user_value ); } } } /* Storing the driver type setting: */ if ( site_config->driver_type != site_config->driver_type_site) { fprintf(stream , CONFIG_KEY_FORMAT , QUEUE_SYSTEM_KEY ); fprintf(stream , CONFIG_ENDVALUE_FORMAT , site_config_get_queue_name( site_config )); } /* Storing UMASK setting */ if ( site_config->umask != site_config->umask_site) { fprintf(stream , CONFIG_KEY_FORMAT , UMASK_KEY ); fprintf(stream , "%o\n" , site_config->umask ); } /* Storing MAX_SUBMIT setting */ if ( site_config->max_submit != site_config->max_submit_site) { fprintf(stream , CONFIG_KEY_FORMAT , MAX_SUBMIT_KEY ); fprintf(stream , "%d\n" , site_config->max_submit ); } /* Storing LICENSE_ROOT_PATH */ if (!util_string_equal( site_config->license_root_path , site_config->license_root_path_site)) { fprintf(stream , CONFIG_KEY_FORMAT , LICENSE_PATH_KEY ); fprintf(stream , CONFIG_ENDVALUE_FORMAT , site_config->license_root_path); } /* Storing jobscript */ if (!util_string_equal( site_config->job_script , site_config->job_script_site)) { fprintf(stream , CONFIG_KEY_FORMAT , LICENSE_PATH_KEY ); fprintf(stream , CONFIG_ENDVALUE_FORMAT , site_config->job_script); } /* Storing local settings. */ if (site_config_get_max_running_local(site_config) != site_config->max_running_local_site) { fprintf(stream , CONFIG_KEY_FORMAT , MAX_RUNNING_LOCAL_KEY ); fprintf(stream , CONFIG_INT_FORMAT , site_config_get_max_running_local( site_config )); fprintf( stream , "\n"); } /* Storing LSF settings. */ { if (site_config_get_max_running_lsf( site_config ) != site_config->max_running_lsf_site) { fprintf(stream , CONFIG_KEY_FORMAT , MAX_RUNNING_LSF_KEY ); fprintf(stream , CONFIG_INT_FORMAT , site_config_get_max_running_lsf( site_config )); fprintf( stream , "\n"); } if (!util_string_equal( site_config_get_lsf_queue(site_config) , site_config->lsf_queue_name_site)) { fprintf(stream , CONFIG_KEY_FORMAT , LSF_QUEUE_KEY ); fprintf(stream , CONFIG_ENDVALUE_FORMAT , site_config_get_lsf_queue( site_config )); } if (!util_string_equal( site_config_get_lsf_request( site_config ) , site_config->lsf_request_site)) { fprintf(stream , CONFIG_KEY_FORMAT , LSF_RESOURCES_KEY ); fprintf(stream , CONFIG_ENDVALUE_FORMAT , site_config_get_lsf_request( site_config )); } } /* Storing RSH settings. */ { if (site_config_get_max_running_rsh(site_config) != site_config->max_running_rsh_site) { fprintf(stream , CONFIG_KEY_FORMAT , MAX_RUNNING_RSH_KEY ); fprintf(stream , CONFIG_INT_FORMAT , site_config_get_max_running_rsh( site_config )); fprintf( stream , "\n"); } if (!util_string_equal( site_config_get_rsh_command( site_config ) , site_config->rsh_command_site)) { fprintf(stream , CONFIG_KEY_FORMAT , LICENSE_PATH_KEY ); fprintf(stream , CONFIG_ENDVALUE_FORMAT , site_config_get_rsh_command( site_config )); } { queue_driver_type * rsh_driver = site_config_get_queue_driver( site_config , RSH_DRIVER_NAME ); const hash_type * host_list = queue_driver_get_option( rsh_driver , RSH_HOSTLIST ); hash_iter_type * iter = hash_iter_alloc( host_list ); while (!hash_iter_is_complete( iter )) { const char * host_name = hash_iter_get_next_key( iter ); fprintf(stream , CONFIG_KEY_FORMAT , RSH_HOST_KEY ); fprintf(stream , "%s:%d\n" , host_name , hash_get_int( host_list , host_name)); } hash_iter_free( iter ); } } fprintf(stream , "\n\n"); }
stringlist_type * config_schema_item_get_required_children_value(const config_schema_item_type * item , const char * value) { return hash_safe_get( item->required_children_value , value ); }
void ensemble_config_init_FIELD( ensemble_config_type * ensemble_config , const config_type * config , ecl_grid_type * grid) { const config_content_item_type * item = config_get_content_item( config , FIELD_KEY ); if (item != NULL) { int i; for (i=0; i < config_content_item_get_size( item ); i++) { const config_content_node_type * node = config_content_item_iget_node( item , i ); const char * key = config_content_node_iget( node , 0 ); const char * var_type_string = config_content_node_iget( node , 1 ); enkf_config_node_type * config_node; { hash_type * options = hash_alloc(); int truncation = TRUNCATE_NONE; double value_min = -1; double value_max = -1; config_content_node_init_opt_hash( node , options , 2 ); if (hash_has_key( options , MIN_KEY)) { truncation |= TRUNCATE_MIN; value_min = atof(hash_get( options , MIN_KEY)); } if (hash_has_key( options , MAX_KEY)) { truncation |= TRUNCATE_MAX; value_max = atof(hash_get( options , MAX_KEY)); } if (strcmp(var_type_string , DYNAMIC_KEY) == 0) { config_node = ensemble_config_add_field( ensemble_config , key , grid , false); enkf_config_node_update_state_field( config_node , truncation , value_min , value_max ); } else if (strcmp(var_type_string , PARAMETER_KEY) == 0) { const char * ecl_file = config_content_node_iget( node , 2 ); const char * init_file_fmt = hash_safe_get( options , INIT_FILES_KEY ); const char * init_transform = hash_safe_get( options , INIT_TRANSFORM_KEY ); const char * output_transform = hash_safe_get( options , OUTPUT_TRANSFORM_KEY ); const char * min_std_file = hash_safe_get( options , MIN_STD_KEY ); const char * forward_string = hash_safe_get( options , FORWARD_INIT_KEY ); 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_field( ensemble_config , key , grid , forward_init); enkf_config_node_update_parameter_field( config_node, ecl_file , init_file_fmt , min_std_file , truncation , value_min , value_max , init_transform , output_transform ); } else if (strcmp(var_type_string , GENERAL_KEY) == 0) { /* General - not really interesting .. */ const char * ecl_file = config_content_node_iget( node , 2 ); const char * enkf_infile = config_content_node_iget( node , 3 ); const char * init_file_fmt = hash_safe_get( options , INIT_FILES_KEY ); const char * init_transform = hash_safe_get( options , INIT_TRANSFORM_KEY ); const char * output_transform = hash_safe_get( options , OUTPUT_TRANSFORM_KEY ); const char * input_transform = hash_safe_get( options , INPUT_TRANSFORM_KEY ); const char * min_std_file = hash_safe_get( options , MIN_STD_KEY ); const char * forward_string = hash_safe_get( options , FORWARD_INIT_KEY ); 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_field( ensemble_config , key , grid , forward_init); enkf_config_node_update_general_field( config_node, ecl_file , enkf_infile , init_file_fmt , min_std_file , truncation , value_min , value_max , init_transform , input_transform , output_transform); } else util_abort("%s: field type: %s is not recognized\n",__func__ , var_type_string); hash_free( options ); } } } }