void site_config_setenv( site_config_type * site_config , const char * variable, const char * __value) { const char * value = util_interp_setenv( variable , __value ); if (site_config->user_mode) { /* In the table meant for user-export we store the literal $var strings. */ hash_insert_hash_owned_ref( site_config->env_variables_user , variable , util_alloc_string_copy( __value ) , free); if (!hash_has_key( site_config->env_variables_site , variable)) hash_insert_ref( site_config->env_variables_site , variable , NULL); /* We insert a NULL so we can recover a unsetenv() in _clear_env(). */ } else hash_insert_hash_owned_ref( site_config->env_variables_site , variable , util_alloc_string_copy( value ) , free); }
ecl_rft_file_type * ecl_rft_file_alloc(const char * filename) { ecl_rft_file_type * rft_vector = ecl_rft_file_alloc_empty( filename ); ecl_file_type * ecl_file = ecl_file_open( filename , 0); int global_index = 0; int block_nr = 0; while (true) { if (ecl_file_select_block( ecl_file , TIME_KW , block_nr)) { ecl_rft_node_type * rft_node = ecl_rft_node_alloc( ecl_file ); if (rft_node != NULL) { const char * well_name = ecl_rft_node_get_well_name( rft_node ); ecl_rft_file_add_node(rft_vector , rft_node); if (!hash_has_key( rft_vector->well_index , well_name)) hash_insert_hash_owned_ref( rft_vector->well_index , well_name , int_vector_alloc( 0 , 0 ) , int_vector_free__); { int_vector_type * index_list = hash_get( rft_vector->well_index , well_name ); int_vector_append(index_list , global_index); } global_index++; } } else break; block_nr++; } ecl_file_close( ecl_file ); return rft_vector; }
void config_content_add_item( config_content_type * content , const config_schema_item_type * schema_item , const config_path_elm_type * path_elm) { const char * kw = config_schema_item_get_kw( schema_item ); config_content_item_type * content_item = config_content_item_alloc( schema_item , path_elm ); hash_insert_hash_owned_ref( content->items , kw , content_item , config_content_item_free__ ); }
static void well_state_add_connections__( well_state_type * well_state , const ecl_file_type * rst_file , const char * grid_name , int grid_nr, int well_nr ) { ecl_rsthead_type * header = ecl_rsthead_alloc( rst_file ); const ecl_kw_type * icon_kw = ecl_file_iget_named_kw( rst_file , ICON_KW , 0); const ecl_kw_type * iwel_kw = ecl_file_iget_named_kw( rst_file , IWEL_KW , 0); well_state_add_wellhead( well_state , header , iwel_kw , well_nr , grid_name , grid_nr ); if (!well_state_has_grid_connections( well_state , grid_name )) hash_insert_hash_owned_ref( well_state->connections , grid_name, well_conn_collection_alloc( ) , well_conn_collection_free__ ); { ecl_kw_type * scon_kw = NULL; well_conn_collection_type * wellcc = hash_get( well_state->connections , grid_name ); if (ecl_file_has_kw( rst_file , SCON_KW)) scon_kw = ecl_file_iget_named_kw( rst_file , SCON_KW , 0); well_conn_collection_load_from_kw( wellcc , iwel_kw , icon_kw , scon_kw , well_nr , header ); } ecl_rsthead_free( header ); }
static void sched_history_add_group( sched_history_type * sched_history , group_history_type * new_group, group_history_type * parent_group , int report_step ) { hash_insert_hash_owned_ref( sched_history->group_history , group_history_get_name( new_group ) , new_group , group_history_free__ ); if (parent_group == NULL) parent_group = sched_history_get_group( sched_history , FIELD_GROUP ); group_history_add_child( parent_group , new_group , group_history_get_name( new_group ) , report_step ); }
static void sched_block_add_kw(sched_block_type * block, const sched_kw_type * kw) { vector_append_ref(block->kw_list , kw ); if (!hash_has_key( block->kw_hash , sched_kw_get_name( kw ))) hash_insert_hash_owned_ref( block->kw_hash , sched_kw_get_name( kw ) , vector_alloc_new() , vector_free__); { vector_type * kw_vector = hash_get( block->kw_hash , sched_kw_get_name( kw )); vector_append_ref( kw_vector , kw ); } }
void ensemble_config_add_node( ensemble_config_type * ensemble_config , enkf_config_node_type * node) { if (node) { const char * key = enkf_config_node_get_key( node ); if (ensemble_config_has_key(ensemble_config , key)) util_abort("%s: a configuration object:%s has already been added - aborting \n",__func__ , key); hash_insert_hash_owned_ref(ensemble_config->config_nodes , key , node , enkf_config_node_free__); ensemble_config->have_forward_init |= enkf_config_node_use_forward_init( node ); } else util_abort("%s: internal error - tried to add NULL node to ensemble configuration \n",__func__); }
enkf_config_node_type * ensemble_config_add_STATIC_node(ensemble_config_type * ensemble_config , const char * key) { if (ensemble_config_has_key(ensemble_config , key)) util_abort("%s: a configuration object:%s has already been added - aborting \n",__func__ , key); { enkf_config_node_type * node = enkf_config_node_alloc(STATIC_STATE , STATIC , false , key , NULL , NULL , NULL , NULL); hash_insert_hash_owned_ref(ensemble_config->config_nodes , key , node , enkf_config_node_free__); return node; } }
static void sched_history_add_wells( sched_history_type * sched_history , const sched_kw_welspecs_type * welspecs , const stringlist_type * wells) { for (int iw = 0; iw < stringlist_get_size( wells ); iw++) { const char * well = stringlist_iget( wells , iw ); if (!hash_has_key( sched_history->well_history , well)) hash_insert_hash_owned_ref( sched_history->well_history , well , well_history_alloc( well , sched_history->time ), well_history_free__ ); /* Could possibly extract more information from the welspecs keyword and update well_history object here, but it does not seem to contain any more interesting info??? */ } }
local_dataset_type * local_dataset_alloc_copy( local_dataset_type * src_dataset , const char * copy_name ) { local_dataset_type * copy_dataset = local_dataset_alloc( copy_name ); hash_iter_type * node_iter = hash_iter_alloc( src_dataset->nodes ); while (!hash_iter_is_complete( node_iter )) { const char * key = hash_iter_get_next_key( node_iter ); active_list_type * active_list = active_list_alloc_copy( hash_get( src_dataset->nodes , key ) ); hash_insert_hash_owned_ref( copy_dataset->nodes , key , active_list , active_list_free__); } hash_iter_free( node_iter ); return copy_dataset; }
void output_table_init( const ecl_sum_type * refcase, hash_type * output_table , const config_type * config ) { int i,j; for (i=0; i < config_get_occurences( config , "OUTPUT" ); i++) { const stringlist_type * tokens = config_iget_stringlist_ref( config , "OUTPUT" , i); const char * file = stringlist_iget( tokens , 0 ); const char * format_string = stringlist_iget( tokens , 1 ); output_type * output = output_alloc( file , format_string ); /* All the keys are just added - without any check. */ for (j = 2; j < stringlist_get_size( tokens ); j++) output_add_key( refcase , output , stringlist_iget( tokens , j)); hash_insert_hash_owned_ref( output_table , file , output , output_free__ ); } }
bool hash_add_option( hash_type * hash, const char * key_value) { bool addOK = false; { char * value; char * key; util_binary_split_string( key_value , ":" , true , &key , &value); if (value != NULL) { hash_insert_hash_owned_ref( hash , key , value , free ); addOK = true; } util_safe_free( key ); } return addOK; }
void output_table_init( const ecl_sum_type * refcase, hash_type * output_table , const config_content_type * config ) { int i,j; if (config_content_has_item( config , "OUTPUT")) { const config_content_item_type * output_item = config_content_get_item( config , "OUTPUT"); for (i = 0; i < config_content_item_get_size( output_item ); i++) { const config_content_node_type * output_node = config_content_item_iget_node( output_item , i ); const char * file = config_content_node_iget( output_node , 0 ); const char * format_string = config_content_node_iget( output_node , 1 ); output_type * output = output_alloc( file , format_string ); /* All the keys are just added - without any check. */ for (j = 2; j < config_content_node_get_size( output_node ); j++) output_add_key( refcase , output , config_content_node_iget( output_node , j)); hash_insert_hash_owned_ref( output_table , file , output , output_free__ ); } } }
static void file_map_make_index( file_map_type * file_map ) { stringlist_clear( file_map->distinct_kw ); hash_clear( file_map->kw_index ); { int i; for (i=0; i < vector_get_size( file_map->kw_list ); i++) { const ecl_file_kw_type * file_kw = vector_iget_const( file_map->kw_list , i); const char * header = ecl_file_kw_get_header( file_kw ); if ( !hash_has_key( file_map->kw_index , header )) { int_vector_type * index_vector = int_vector_alloc( 0 , -1 ); hash_insert_hash_owned_ref( file_map->kw_index , header , index_vector , int_vector_free__); stringlist_append_copy( file_map->distinct_kw , header); } { int_vector_type * index_vector = hash_get( file_map->kw_index , header); int_vector_append( index_vector , i); } } } }
hash_type * hash_alloc_from_options(const stringlist_type * options) { int num_options = stringlist_get_size( options ); hash_type * opt_hash = hash_alloc(); int iopt; for (iopt = 0; iopt < num_options; iopt++) { char * option; char * value; util_binary_split_string( stringlist_iget(options , iopt) , ":" , true , &option , &value); if ((option != NULL) && (value != NULL)) hash_insert_hash_owned_ref( opt_hash , option , util_alloc_string_copy(value) , free); // Warning: could not interpret string as KEY:VALUE - ignored util_safe_free(option); util_safe_free(value); } return opt_hash; }
workflow_type * ert_workflow_list_add_workflow( ert_workflow_list_type * workflow_list , const char * workflow_file , const char * workflow_name) { if (util_file_exists( workflow_file )) { workflow_type * workflow = workflow_alloc( workflow_file , workflow_list->joblist ); char * name; if (workflow_name == NULL) util_alloc_file_components( workflow_file , NULL , &name , NULL ); else name = (char *) workflow_name; hash_insert_hash_owned_ref( workflow_list->workflows , name , workflow , workflow_free__); if (hash_has_key( workflow_list->alias_map , name)) hash_del( workflow_list->alias_map , name); if (workflow_name == NULL) free( name ); return workflow; } else return NULL; }
hash_type * config_content_item_alloc_hash(const config_content_item_type * item , bool copy) { hash_type * hash = hash_alloc(); if (item != NULL) { int inode; for (inode = 0; inode < vector_get_size( item->nodes ); inode++) { const config_content_node_type * node = config_content_item_iget_node(item , inode); const stringlist_type * src_list = config_content_node_get_stringlist( node ); const char * key = stringlist_iget(src_list , 0); const char * value = stringlist_iget(src_list , 1); if (copy) { hash_insert_hash_owned_ref(hash , key , util_alloc_string_copy(value) , free); } else hash_insert_ref(hash , key , value ); } } return hash; }
static void sched_history_install_group_index( sched_history_type * sched_history , group_index_type * group_index , const char ** var_list , const char * group_name) { int index = 0; char * gen_key = NULL; const char * var = var_list[ index ]; bool first = true; while ( var != NULL ) { gen_key = util_realloc_sprintf( gen_key , "%s%s%s" , var , sched_history->sep_string , group_name ); if (first) { first = false; hash_insert_hash_owned_ref( sched_history->index , gen_key , group_index , group_index_free__); } else hash_insert_ref( sched_history->index , gen_key , group_index ); index++; var = var_list[ index ]; } if (first) util_abort("%s: internal error - empty var_list \n",__func__); free( gen_key ); }
void ranking_table_add_data_ranking( ranking_table_type * ranking_table , bool sort_increasing , const char * ranking_key , const char * user_key , const char * key_index , enkf_fs_type * fs , const enkf_config_node_type * config_node , int step) { data_ranking_type * ranking = data_ranking_alloc( sort_increasing , ranking_table->ens_size , user_key , key_index , fs , config_node , step ); hash_insert_hash_owned_ref( ranking_table->ranking_table , ranking_key , ranking, data_ranking_free__ ); }
void local_dataset_add_node(local_dataset_type * dataset, const char *node_key) { if (hash_has_key( dataset->nodes , node_key )) util_abort("%s: tried to add existing node key:%s \n",__func__ , node_key); hash_insert_hash_owned_ref( dataset->nodes , node_key , active_list_alloc( ALL_ACTIVE ) , active_list_free__); }
static void site_config_add_queue_driver( site_config_type * site_config , const char * driver_name , queue_driver_type * driver ) { hash_insert_hash_owned_ref( site_config->queue_drivers , driver_name , driver , queue_driver_free__ ); }
void config_schema_item_set_required_children_on_value(config_schema_item_type * item , const char * value , stringlist_type * child_list) { if (item->required_children_value == NULL) item->required_children_value = hash_alloc(); hash_insert_hash_owned_ref( item->required_children_value , value , stringlist_alloc_deep_copy(child_list) , stringlist_free__); }
void ranking_table_add_misfit_ranking( ranking_table_type * ranking_table , const misfit_ensemble_type * misfit_ensemble , const stringlist_type * obs_keys , const int_vector_type * steps , const char * ranking_key) { misfit_ranking_type * ranking = misfit_ranking_alloc( misfit_ensemble , obs_keys , steps , ranking_key ); hash_insert_hash_owned_ref( ranking_table->ranking_table , ranking_key , ranking , misfit_ranking_free__ ); }
void output_run_line( const output_type * output , ensemble_type * ensemble) { const int data_columns = vector_get_size( output->keys ); const int data_rows = time_t_vector_size( ensemble->interp_time ); double ** data; int row_nr, column_nr; data = util_calloc( data_rows , sizeof * data ); /* time-direction, i.e. the row index is the first index and the column number (i.e. the different keys) is the second index. */ for (row_nr=0; row_nr < data_rows; row_nr++) data[row_nr] = util_calloc( data_columns , sizeof * data[row_nr] ); printf("Creating output file: %s \n",output->file ); /* Go through all the cases and check that they have this key; exit if missing. Could also ignore the missing keys and just continue; and even defer the checking to the inner loop. */ for (column_nr = 0; column_nr < vector_get_size( output->keys ); column_nr++) { const quant_key_type * qkey = vector_iget( output->keys , column_nr ); { bool OK = true; for (int iens = 0; iens < vector_get_size( ensemble->data ); iens++) { const sum_case_type * sum_case = vector_iget_const( ensemble->data , iens ); if (!ecl_sum_has_general_var(sum_case->ecl_sum , qkey->sum_key)) { OK = false; fprintf(stderr,"** Sorry: the case:%s does not have the summary key:%s \n", ecl_sum_get_case( sum_case->ecl_sum ), qkey->sum_key); } } if (!OK) util_exit("Exiting due to missing summary vector(s).\n"); } } /* The main loop - outer loop is running over time. */ { /** In the quite typical case that we are asking for several quantiles of the quantity, i.e. WWCT:OP_1:0.10 WWCT:OP_1:0.50 WWCT:OP_1:0.90 the interp_data_cache construction will ensure that the underlying ecl_sum object is only queried once; and also the sorting will be performed once. */ hash_type * interp_data_cache = hash_alloc(); for (row_nr = 0; row_nr < data_rows; row_nr++) { time_t interp_time = time_t_vector_iget( ensemble->interp_time , row_nr); for (column_nr = 0; column_nr < vector_get_size( output->keys ); column_nr++) { const quant_key_type * qkey = vector_iget( output->keys , column_nr ); double_vector_type * interp_data; /* Check if we have the vector in the cache table - if not create it. */ if (!hash_has_key( interp_data_cache , qkey->sum_key)) { interp_data = double_vector_alloc(0 , 0); hash_insert_hash_owned_ref( interp_data_cache , qkey->sum_key , interp_data , double_vector_free__); } interp_data = hash_get( interp_data_cache , qkey->sum_key ); /* Check if the vector has data - if not initialize it. */ if (double_vector_size( interp_data ) == 0) { for (int iens = 0; iens < vector_get_size( ensemble->data ); iens++) { const sum_case_type * sum_case = vector_iget_const( ensemble->data , iens ); if ((interp_time >= sum_case->start_time) && (interp_time <= sum_case->end_time)) /* We allow the different simulations to have differing length */ double_vector_append( interp_data , ecl_sum_get_general_var_from_sim_time( sum_case->ecl_sum , interp_time , qkey->sum_key)) ; double_vector_sort( interp_data ); } } data[row_nr][column_nr] = statistics_empirical_quantile__( interp_data , qkey->quantile ); } hash_apply( interp_data_cache , double_vector_reset__ ); } hash_free( interp_data_cache ); } output_save( output , ensemble , (const double **) data); for (row_nr=0; row_nr < data_rows; row_nr++) free( data[row_nr] ); free( data ); }
void ext_joblist_add_job(ext_joblist_type * joblist , const char * name , ext_job_type * new_job) { hash_insert_hash_owned_ref(joblist->jobs , name , new_job , ext_job_free__); }
void sched_history_install_index( sched_history_type * sched_history ) { /*1: Installing well based keys like WOPRH. */ { hash_iter_type * well_iter = hash_iter_alloc( sched_history->well_history ); while (!hash_iter_is_complete( well_iter )) { const char * well_name = hash_iter_get_next_key( well_iter ); const well_history_type * well = hash_get( sched_history->well_history , well_name ); /* WOPR */ { well_index_type * well_index = well_index_alloc( well_name , "WOPRH" , well , WCONHIST , wconhist_state_iget_WOPRH ); sched_history_install_well_index( sched_history , well_index , VAR_LIST("WOPR" , "WOPRH") , well_name); } /* WGPR */ { well_index_type * well_index = well_index_alloc( well_name , "WGPRH" , well , WCONHIST , wconhist_state_iget_WGPRH ); sched_history_install_well_index( sched_history , well_index , VAR_LIST("WGPR" , "WGPRH") , well_name); } /* WWPR */ { well_index_type * well_index = well_index_alloc( well_name , "WWPRH" , well , WCONHIST , wconhist_state_iget_WWPRH ); sched_history_install_well_index( sched_history , well_index , VAR_LIST("WWPR" , "WWPRH") , well_name); } /* WWCT */ { well_index_type * well_index = well_index_alloc( well_name , "WWCTH" , well , WCONHIST , wconhist_state_iget_WWCTH ); sched_history_install_well_index( sched_history , well_index , VAR_LIST("WWCT" , "WWCTH") , well_name); } /* WGOR */ { well_index_type * well_index = well_index_alloc( well_name , "WGORH" , well , WCONHIST , wconhist_state_iget_WGORH ); sched_history_install_well_index( sched_history , well_index , VAR_LIST("WGOR" , "WGORH") , well_name); } /* WGPT */ { well_index_type * well_index = well_index_alloc( well_name , "WGPTH" , well , WCONHIST , wconhist_state_iget_WGPTH ); sched_history_install_well_index( sched_history , well_index , VAR_LIST("WGPT" , "WGPTH") , well_name); } /* WOPT */ { well_index_type * well_index = well_index_alloc( well_name , "WOPTH" , well , WCONHIST , wconhist_state_iget_WOPTH ); sched_history_install_well_index( sched_history , well_index , VAR_LIST("WOPT" , "WOPTH") , well_name); } /* WWPT */ { well_index_type * well_index = well_index_alloc( well_name , "WWPTH" , well , WCONHIST , wconhist_state_iget_WWPTH ); sched_history_install_well_index( sched_history , well_index , VAR_LIST("WWPT" , "WWPTH") , well_name); } /* STAT */ { well_index_type * well_index = well_index_alloc( well_name , "STAT" , well , WCONHIST , wconhist_state_iget_STAT ); sched_history_install_well_index( sched_history , well_index , VAR_LIST("STAT" ) , well_name); } /* WWIRH - this can be got from _either_ the WCONINJH keyowrord or the WCONINJE keyword (provided the latter is in rate controlled mode. ) */ { well_index_type * well_index = well_index_alloc( well_name , "WWIRH" , well , WCONINJH , wconinjh_state_iget_WWIRH ); /* The first type */ well_index_add_type( well_index , WCONINJE , wconinje_state_iget_WWIRH ); /* The second type */ sched_history_install_well_index( sched_history , well_index , VAR_LIST("WWIRH" , "WWIR") , well_name); } /* WGIRH - this can be got from _either_ the WCONINJH keyowrord or the WCONINJE keyword (provided the latter is in rate controlled mode. ) */ { well_index_type * well_index = well_index_alloc( well_name , "WGIRH" , well , WCONINJH , wconinjh_state_iget_WGIRH ); /* The first type */ well_index_add_type( well_index , WCONINJE , wconinje_state_iget_WGIRH ); /* The second type */ sched_history_install_well_index( sched_history , well_index , VAR_LIST("WGIRH" , "WGIR") , well_name); } } hash_iter_free( well_iter ); } /*2: Installing group based indices */ { hash_iter_type * group_iter = hash_iter_alloc( sched_history->group_history ); while (!hash_iter_is_complete( group_iter )) { const char * group_name = hash_iter_get_next_key( group_iter ); const group_history_type * group = hash_get( sched_history->group_history , group_name ); /* GOPR */ { group_index_type * group_index = group_index_alloc( group_name , "GOPRH" , group , group_history_iget_GOPRH ); sched_history_install_group_index( sched_history , group_index , VAR_LIST("GOPR" , "GOPRH") , group_name); } /* GGPR */ { group_index_type * group_index = group_index_alloc( group_name , "GGPRH" , group , group_history_iget_GGPRH ); sched_history_install_group_index( sched_history , group_index , VAR_LIST("GGPR" , "GGPRH") , group_name); } /* GWPR */ { group_index_type * group_index = group_index_alloc( group_name , "GWPRH" , group , group_history_iget_GWPRH ); sched_history_install_group_index( sched_history , group_index , VAR_LIST("GWPR" , "GWPRH") , group_name); } /* GWCT */ { group_index_type * group_index = group_index_alloc( group_name , "GWCTH" , group , group_history_iget_GWCTH ); sched_history_install_group_index( sched_history , group_index , VAR_LIST("GWCT" , "GWCTH") , group_name); } /* GGOR */ { group_index_type * group_index = group_index_alloc( group_name , "GGORH" , group , group_history_iget_GGORH ); sched_history_install_group_index( sched_history , group_index , VAR_LIST("GGOR" , "GGORH") , group_name); } /* GOPT */ { group_index_type * group_index = group_index_alloc( group_name , "GOPTH" , group , group_history_iget_GOPTH ); sched_history_install_group_index( sched_history , group_index , VAR_LIST("GOPT" , "GOPTH") , group_name); } /* GGPT */ { group_index_type * group_index = group_index_alloc( group_name , "GGPTH" , group , group_history_iget_GGPTH ); sched_history_install_group_index( sched_history , group_index , VAR_LIST("GGPT" , "GGPTH") , group_name); } /* GWPT */ { group_index_type * group_index = group_index_alloc( group_name , "GWPTH" , group , group_history_iget_GWPTH ); sched_history_install_group_index( sched_history , group_index , VAR_LIST("GWPT" , "GWPTH") , group_name); } } hash_iter_free( group_iter ); } /*3: Installing field based indices (which is just an alias to the FIELD group); */ { const group_history_type * group = hash_get( sched_history->group_history , FIELD_GROUP ); const char * group_name = FIELD_GROUP; /* FWPRH */ { group_index_type * group_index = group_index_alloc( group_name , "GWPRH" , group , group_history_iget_GWPRH ); hash_insert_hash_owned_ref( sched_history->index , "FWPRH" , group_index , group_index_free__ ); hash_insert_ref( sched_history->index , "FWPR" , group_index); } /* FOPRH */ { group_index_type * group_index = group_index_alloc( group_name , "GOPRH" , group , group_history_iget_GOPRH ); hash_insert_hash_owned_ref( sched_history->index , "FOPRH" , group_index , group_index_free__ ); hash_insert_ref( sched_history->index , "FOPR" , group_index); } /* FGPRH */ { group_index_type * group_index = group_index_alloc( group_name , "GGPRH" , group , group_history_iget_GGPRH ); hash_insert_hash_owned_ref( sched_history->index , "FGPRH" , group_index , group_index_free__ ); hash_insert_ref( sched_history->index , "FGPR" , group_index); } /* FWPTH */ { group_index_type * group_index = group_index_alloc( group_name , "GWPTH" , group , group_history_iget_GWPTH ); hash_insert_hash_owned_ref( sched_history->index , "FWPTH" , group_index , group_index_free__ ); hash_insert_ref( sched_history->index , "FWPT" , group_index); } /* FOPTH */ { group_index_type * group_index = group_index_alloc( group_name , "GOPTH" , group , group_history_iget_GOPTH ); hash_insert_hash_owned_ref( sched_history->index , "FOPTH" , group_index , group_index_free__ ); hash_insert_ref( sched_history->index , "FOPT" , group_index); } /* FGPTH */ { group_index_type * group_index = group_index_alloc( group_name , "GGPTH" , group , group_history_iget_GGPTH ); hash_insert_hash_owned_ref( sched_history->index , "FGPTH" , group_index , group_index_free__ ); hash_insert_ref( sched_history->index , "FGPT" , group_index); } /* FGORH */ { group_index_type * group_index = group_index_alloc( group_name , "GGORH" , group , group_history_iget_GGORH ); hash_insert_hash_owned_ref( sched_history->index , "FGORH" , group_index , group_index_free__ ); hash_insert_ref( sched_history->index , "FGOR" , group_index); } /* FWCTH */ { group_index_type * group_index = group_index_alloc( group_name , "GWCTH" , group , group_history_iget_GWCTH ); hash_insert_hash_owned_ref( sched_history->index , "FWCTH" , group_index , group_index_free__ ); hash_insert_ref( sched_history->index , "FWCT" , group_index); } } }
void model_config_add_runpath( model_config_type * model_config , const char * path_key , const char * fmt) { path_fmt_type * path_fmt = path_fmt_alloc_directory_fmt( fmt ); hash_insert_hash_owned_ref( model_config->runpath_map , path_key , path_fmt , path_fmt_free__ ); }
static void sched_history_add_FIELD_group( sched_history_type * sched_history ) { group_history_type * field_group = group_history_alloc( FIELD_GROUP , sched_history->time , 0 ); hash_insert_hash_owned_ref( sched_history->group_history , FIELD_GROUP , field_group , group_history_free__ ); }
int main( int argc, char ** argv) { if (argc == 1) util_exit("block_node node1 node2 node3:2 \n"); /* Initialize lsf environment */ util_setenv( "LSF_BINDIR" , "/prog/LSF/9.1/linux2.6-glibc2.3-x86_64/bin" ); util_setenv( "LSF_LINDIR" , "/prog/LSF/9.1/linux2.6-glibc2.3-x86_64/lib" ); util_setenv( "XLSF_UIDDIR" , "/prog/LSF/9.1/linux2.6-glibc2.3-x86_64/lib/uid" ); util_setenv( "LSF_SERVERDIR" , "/prog/LSF/9.1/linux2.6-glibc2.3-x86_64/etc"); util_setenv( "LSF_ENVDIR" , "/prog/LSF/conf"); util_update_path_var( "PATH" , "/prog/LSF/9.1/linux2.6-glibc2.3-x86_64/bin" , false); util_update_path_var( "LD_LIBRARY_PATH" , "/prog/LSF/9.1/linux2.6-glibc2.3-x86_64/lib" , false); lsf_driver = lsf_driver_alloc(); if (lsf_driver_get_submit_method( lsf_driver ) != LSF_SUBMIT_INTERNAL) util_exit("Sorry - the block_node program must be invoked on a proper LSF node \n"); { int iarg; int total_blocked_target = 0; nodes = hash_alloc(); for (iarg = 1; iarg < argc; iarg++) { char *node_name; int num_slots; { char * num_slots_string; util_binary_split_string( argv[iarg] , ":" , true , &node_name , &num_slots_string); if (num_slots_string) util_sscanf_int( num_slots_string , &num_slots); else num_slots = 1; } if (!hash_has_key( nodes , node_name)) hash_insert_hash_owned_ref( nodes , node_name , count_pair_alloc() , free); { count_pair_type * pair = hash_get( nodes , node_name); pair->target += num_slots; } total_blocked_target += num_slots; } signal(SIGINT , block_node_exit ); { const int sleep_time = 5; const int chunk_size = 10; /* We submit this many at a time. */ const int max_pool_size = 1000; /* The absolute total maximum of jobs we will submit. */ bool cont = true; int pending = 0; bool all_blocked; job_pool = vector_alloc_new(); while (cont) { printf("[Ctrl-C to give up] "); fflush( stdout ); if (cont) sleep( sleep_time ); if (pending == 0) { if (vector_get_size( job_pool ) < max_pool_size) add_jobs( chunk_size ); } update_pool_status( &all_blocked , &pending); print_status(); if (all_blocked) cont = false; } if (!all_blocked) printf("Sorry - failed to block all the nodes \n"); block_node_exit( 0 ); hash_free( nodes ); } } }
static void ecl_subsidence_add_survey__( ecl_subsidence_type * subsidence , const char * name , ecl_subsidence_survey_type * survey) { hash_insert_hash_owned_ref( subsidence->surveys , name , survey , ecl_subsidence_survey_free__ ); }