plot_dataset_type * plot_alloc_new_dataset(plot_type * plot , const char * __label , plot_data_type data_type) { if (data_type == PLOT_HIST) { if (vector_get_size( plot->dataset) > 0) util_abort("%s: sorry - when using histograms you can *only* have one dataset\n",__func__); plot->is_histogram = true; } else if (plot->is_histogram) util_abort("%s: sorry - when using histograms you can *only* have one dataset\n",__func__); { char * label; if (__label == NULL) label = util_alloc_sprintf("data_%d" , vector_get_size( plot->dataset )); else label = (char *) __label; if (hash_has_key( plot->dataset_hash , label)) util_abort("%s: sorry - the label %s is already in use - must be unique \n",__func__ , label); { plot_dataset_type * dataset = plot_dataset_alloc(data_type, label , plot->logx , plot->logy); vector_append_owned_ref(plot->dataset , dataset , plot_dataset_free__); hash_insert_ref( plot->dataset_hash , label , dataset); if (__label == NULL) free(label); return dataset; } } }
void well_state_add_wellhead( well_state_type * well_state , const ecl_rsthead_type * header , const ecl_kw_type * iwel_kw , int well_nr , const char * grid_name , int grid_nr) { well_conn_type * wellhead = well_conn_alloc_wellhead( iwel_kw , header , well_nr ); if (wellhead != NULL) { vector_safe_iset_owned_ref( well_state->index_wellhead , grid_nr , wellhead , well_conn_free__ ); hash_insert_ref( well_state->name_wellhead , grid_name , wellhead ); } }
void rms_tag_add_tagkey(rms_tag_type *tag , const rms_tagkey_type *tagkey, int mem_mode) { rms_tagkey_type * tagkey_copy; switch (mem_mode) { case(COPY): tagkey_copy = rms_tagkey_copyc(tagkey); vector_append_owned_ref( tag->key_list , tagkey_copy , rms_tagkey_free_ ); hash_insert_ref(tag->key_hash , rms_tagkey_get_name(tagkey_copy) , tagkey_copy); break; case(OWNED_REF): vector_append_owned_ref( tag->key_list , tagkey , rms_tagkey_free_ ); hash_insert_ref(tag->key_hash , rms_tagkey_get_name(tagkey) , tagkey); break; case(SHARED): vector_append_ref( tag->key_list , tagkey ); hash_insert_ref(tag->key_hash , rms_tagkey_get_name(tagkey) , tagkey); break; } }
bool local_obsdata_add_node( local_obsdata_type * data , local_obsdata_node_type * node ) { const char * key = local_obsdata_node_get_key( node ); if (local_obsdata_has_node(data , key)) return false; else { vector_append_owned_ref( data->nodes_list , node , local_obsdata_node_free__ ); hash_insert_ref( data->nodes_map , key , node ); return true; } }
void site_config_update_pathvar( site_config_type * site_config , const char * pathvar , const char * value) { if (site_config->user_mode) { stringlist_append_copy( site_config->path_variables_user , pathvar ); stringlist_append_copy( site_config->path_values_user , value ); if (!hash_has_key( site_config->path_variables_site , pathvar )) hash_insert_ref( site_config->path_variables_site , pathvar , NULL); /* This path variable has not been touched in the site_config. We store a NULL, so can roll back (i.e. call unsetenv()). */ } util_update_path_var( pathvar , value , false ); }
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); }
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 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); } } }
static void ecl_grav_survey_add_phase( ecl_grav_survey_type * survey, ecl_phase_enum phase , ecl_grav_phase_type * grav_phase ) { vector_append_owned_ref( survey->phase_list , grav_phase , ecl_grav_phase_free__ ); hash_insert_ref( survey->phase_map , ecl_util_get_phase_name( phase ) , grav_phase ); }
void ert_workflow_list_add_alias( ert_workflow_list_type * workflow_list , const char * real_name , const char * alias) { if (!util_string_equal( real_name , alias)) hash_insert_ref( workflow_list->alias_map , alias , real_name ); }
void local_ministep_add_dataset( local_ministep_type * ministep , const local_dataset_type * dataset) { hash_insert_ref( ministep->datasets , local_dataset_get_name( dataset ) , dataset ); }