static void plplot_set_axis(plot_driver_type * driver , const plot_range_type * range , const char * timefmt , plot_color_type box_color , double tick_font_size) { plplot_state_type * state = driver->state; { double xmin , xmax , ymin , ymax; plot_range_get_limits( range , &xmin , &xmax , &ymin , &ymax); if (state->logx) { xmin = log( xmin ); xmax = log( xmax ); } if (state->logy) { ymin = log( ymin ); ymax = log( ymax ); } plwind( xmin , xmax , ymin , ymax ); } plcol0(box_color); plschr(0, tick_font_size * PLOT_DEFAULT_LABEL_FONTSIZE); if (timefmt != NULL) { pltimefmt(timefmt); state->plbox_xopt = util_realloc_sprintf( state->plbox_xopt , "%s%c" , state->plbox_xopt , 'd'); } plbox(state->plbox_xopt, 0.0, 0, state->plbox_yopt , 0.0, 0); }
void site_config_set_license_root_path( site_config_type * site_config , const char * license_root_path) { util_make_path( license_root_path ); { char * full_license_root_path = util_alloc_realpath( license_root_path ); { /** Appending /user/pid to the license root path. Everything including the pid is removed when exiting (gracefully ...). Dangling license directories after a crash can just be removed. */ site_config->license_root_path = util_realloc_string_copy( site_config->license_root_path , full_license_root_path ); site_config->__license_root_path = util_realloc_sprintf(site_config->__license_root_path , "%s%c%s%c%d" , full_license_root_path , UTIL_PATH_SEP_CHAR , getenv("USER") , UTIL_PATH_SEP_CHAR , getpid()); if (!site_config->user_mode) site_config->license_root_path_site = util_realloc_string_copy( site_config->license_root_path_site , full_license_root_path ); } free( full_license_root_path ); } }
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 ); }
double obs_vector_total_chi2(const obs_vector_type * obs_vector , enkf_fs_type * fs , int iens, state_enum load_state) { int report_step; double sum_chi2 = 0; enkf_node_type * enkf_node = enkf_node_alloc( obs_vector->config_node ); node_id_type node_id = {.report_step = 0, .iens = iens , .state = load_state }; for (report_step = 0; report_step < vector_get_size( obs_vector->nodes ); report_step++) { if (vector_iget(obs_vector->nodes , report_step) != NULL) { node_id.report_step = report_step; if (enkf_node_try_load( enkf_node , fs , node_id)) sum_chi2 += obs_vector_chi2__(obs_vector , report_step , enkf_node, node_id); } } enkf_node_free( enkf_node ); return sum_chi2; } /** This function will sum up all timesteps of the obs_vector, for all ensemble members. */ void obs_vector_ensemble_total_chi2(const obs_vector_type * obs_vector , enkf_fs_type * fs , int ens_size , state_enum load_state , double * sum_chi2) { const bool verbose = true; msg_type * msg; int report_step; int iens; char * msg_text = NULL; for (iens = 0; iens < ens_size; iens++) sum_chi2[iens] = 0; if (verbose) { msg = msg_alloc("Observation: " , false); msg_show(msg); } { node_id_type node_id = {.report_step = 0, .iens = iens , .state = load_state }; enkf_node_type * enkf_node = enkf_node_alloc( obs_vector->config_node ); for (report_step = 0; report_step < vector_get_size( obs_vector->nodes); report_step++) { if (verbose) { msg_text = util_realloc_sprintf( msg_text , "%s[%03d]" , obs_vector->obs_key , report_step); msg_update(msg , msg_text); } if (vector_iget(obs_vector->nodes , report_step) != NULL) { node_id.report_step = report_step; for (iens = 0; iens < ens_size; iens++) { node_id.iens = iens; if (enkf_node_try_load( enkf_node , fs , node_id)) sum_chi2[iens] += obs_vector_chi2__(obs_vector , report_step , enkf_node, node_id); } } } enkf_node_free( enkf_node ); } if (verbose) { msg_free(msg , true); util_safe_free( msg_text ); } } const char * obs_vector_get_obs_key( const obs_vector_type * obs_vector) { return obs_vector->obs_key; } /*****************************************************************/ VOID_FREE(obs_vector)
static void gen_kw_parameter_update_tagged_name( gen_kw_parameter_type * parameter , const char * tag_fmt) { if (tag_fmt != NULL) parameter->tagged_name = util_realloc_sprintf( parameter->tagged_name , tag_fmt , parameter->name ); }
void queue_driver_set_max_running(queue_driver_type * driver, int max_running) { driver->max_running_string = util_realloc_sprintf(driver->max_running_string,"%d", max_running); driver->max_running = max_running; }