本文整理汇总了C++中enkf_main_safe_cast函数的典型用法代码示例。如果您正苦于以下问题:C++ enkf_main_safe_cast函数的具体用法?C++ enkf_main_safe_cast怎么用?C++ enkf_main_safe_cast使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了enkf_main_safe_cast函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: enkf_tui_analysis_menu
void enkf_tui_analysis_menu(void * arg) {
enkf_main_type * enkf_main = enkf_main_safe_cast( arg );
menu_type * menu = menu_alloc( "Analysis menu" , "Back" , "bB");
arg_pack_type * arg_pack = arg_pack_alloc();
arg_pack_append_ptr( arg_pack , enkf_main );
arg_pack_append_ptr( arg_pack , menu );
{
enkf_tui_analysis_update_title(enkf_main, menu);
if (enkf_main_have_obs(enkf_main)) {
menu_add_item(menu, "Global scaling of uncertainty", "gG", enkf_tui_analysis_scale_observation_std__, enkf_main, NULL);
menu_add_separator(menu);
}
menu_add_item(menu, "Select analysis module", "sS", enkf_tui_analysis_select_module__, arg_pack, NULL);
menu_add_item(menu, "List available modules", "lL", enkf_tui_analysis_list_modules__, enkf_main, NULL);
menu_add_item(menu, "Modify analysis module parameters", "mM", enkf_tui_analysis_update_module__, enkf_main, NULL);
menu_add_item(menu, "Reload current module (external only)", "rR", enkf_tui_analysis_reload_module__, enkf_main, NULL);
}
menu_run(menu);
menu_free(menu);
arg_pack_free(arg_pack);
}
示例2: enkf_main_rank_on_data_JOB
void * enkf_main_rank_on_data_JOB(void * self, const stringlist_type * args) {
enkf_main_type * enkf_main = enkf_main_safe_cast( self );
const char * ranking_name = stringlist_iget(args, 0);
const char * data_key = stringlist_iget(args, 1);
bool valid = true;
bool sort_increasing = stringlist_iget_as_bool(args, 2, &valid);
if (!valid) {
fprintf(stderr,"** Third argument \"sort increasing\" not recognized as bool value, job not started\n");
return NULL;
}
int report_step = (stringlist_get_size(args) > 3) ? stringlist_iget_as_int(args, 3, &valid) : enkf_main_get_history_length(enkf_main) ;
if (!valid) {
fprintf(stderr,"** Fourth argument \"step\" not recognized as integer value, job not started\n");
return NULL;
}
if (report_step < 0) {
fprintf(stderr,"** Negative report step, job not started\n");
return NULL;
}
enkf_main_rank_on_data(enkf_main, ranking_name, data_key, sort_increasing, report_step);
return NULL;
}
示例3: enkf_tui_fs_initialize_case_from_copy
void enkf_tui_fs_initialize_case_from_copy(void * arg)
{
int prompt_len =50;
char * source_case;
int ens_size;
int last_report;
int src_step;
state_enum src_state;
enkf_main_type * enkf_main = enkf_main_safe_cast( arg );
ens_size = enkf_main_get_ensemble_size( enkf_main );
last_report = enkf_main_get_history_length( enkf_main );
source_case = enkf_tui_fs_alloc_existing_case( enkf_main , "Initialize from case" , prompt_len);
if (source_case != NULL) {
src_step = util_scanf_int_with_limits("Source report step",prompt_len , 0 , last_report);
src_state = enkf_tui_util_scanf_state("Source analyzed/forecast [A|F]" , prompt_len , false);
enkf_fs_type * source_fs = enkf_main_mount_alt_fs( enkf_main , source_case , false );
enkf_main_init_current_case_from_existing(enkf_main, source_fs , src_step , src_state);
enkf_fs_decref(source_fs);
}
util_safe_free( source_case );
}
示例4: enkf_tui_ranking_menu
void enkf_tui_ranking_menu(void * arg) {
enkf_main_type * enkf_main = enkf_main_safe_cast( arg );
{
menu_type * menu = menu_alloc("Ranking of results" , "Back" , "bB");
menu_item_type * obs_item;
{
arg_pack_type * arg_pack = arg_pack_alloc();
arg_pack_append_ptr( arg_pack , enkf_main );
menu_add_item(menu , "Create/update misfit table" , "cC" , enkf_tui_ranking_make_misfit_ensemble , arg_pack , arg_pack_free__);
menu_add_separator( menu );
obs_item = menu_add_item(menu , "New observation based ranking" , "nN" , enkf_tui_ranking_create_obs , enkf_main , NULL);
arg_pack_append_ptr( arg_pack , obs_item );
}
menu_add_item(menu , "New data based ranking (Sort: increasing)" , "iI" , enkf_tui_ranking_create_data_increasing , enkf_main , NULL);
menu_add_item(menu , "New data based ranking (Sort: decreasing)" , "dD" , enkf_tui_ranking_create_data_decreasing , enkf_main , NULL);
menu_add_item(menu , "Show ranking" , "sS" , enkf_tui_ranking_display , enkf_main , NULL);
{
enkf_fs_type * fs = enkf_main_get_fs( enkf_main );
misfit_ensemble_type * misfit_ensemble = enkf_fs_get_misfit_ensemble( fs );
if (!misfit_ensemble_initialized( misfit_ensemble ))
menu_item_disable( obs_item );
}
menu_add_item(menu , "Help" , "hH" , enkf_tui_help_menu_rank , enkf_main , NULL);
menu_run(menu);
menu_free(menu);
}
}
示例5: enkf_main_std_scale_correlated_obs_JOB
void * enkf_main_std_scale_correlated_obs_JOB(void * self, const stringlist_type * args) {
if (stringlist_get_size(args) > 0) {
enkf_main_type * enkf_main = enkf_main_safe_cast( self );
int ensemble_size = enkf_main_get_ensemble_size(enkf_main);
enkf_fs_type * fs = enkf_main_get_fs( enkf_main );
enkf_obs_type * obs = enkf_main_get_obs( enkf_main );
int_vector_type * realizations = int_vector_alloc(1, 0);
local_obsdata_type * obsdata = local_obsdata_alloc( "OBS-JOB" );
int_vector_init_range(realizations, 0, ensemble_size, 1);
for (int iarg = 0; iarg < stringlist_get_size(args); iarg++) {
const char * arg_key = stringlist_iget( args , iarg );
stringlist_type * key_list = enkf_obs_alloc_matching_keylist(obs, arg_key);
for (int iobs=0; iobs < stringlist_get_size( key_list ); iobs++) {
const char * obs_key = stringlist_iget( key_list , iobs);
const obs_vector_type * obs_vector = enkf_obs_get_vector(obs, obs_key);
local_obsdata_add_node( obsdata , obs_vector_alloc_local_node(obs_vector) );
}
stringlist_free( key_list );
}
if (local_obsdata_get_size(obsdata) > 0)
enkf_obs_scale_correlated_std(obs, fs, realizations, obsdata );
local_obsdata_free( obsdata );
}
return NULL;
}
示例6: enkf_main_smoother_JOB__
static void * enkf_main_smoother_JOB__( void * self , int iter , const stringlist_type * args ) {
enkf_main_type * enkf_main = enkf_main_safe_cast( self );
int ens_size = enkf_main_get_ensemble_size( enkf_main );
bool_vector_type * iactive = bool_vector_alloc( ens_size , true );
bool valid = true;
const char * target_case;
enkf_fs_type * target_fs = enkf_main_get_fs( enkf_main );
// Argument 0: Which case to write to. Default current case.
if (stringlist_get_size(args)) {
target_case = stringlist_iget( args , 0 );
if (strcmp( target_case , CURRENT_CASE_STRING) == 0)
target_case = enkf_fs_get_case_name(target_fs);
} else
target_case = enkf_fs_get_case_name(target_fs);
//Argument 1: Rerun. Default false.
bool rerun = (stringlist_get_size(args) >= 2) ? stringlist_iget_as_bool(args, 1, &valid) : false;
if (!valid) {
fprintf(stderr, "** Warning: Function %s : Second argument must be a bool value. Exiting job\n", __func__);
return NULL;
}
enkf_main_run_smoother( enkf_main , target_case , iactive , iter , rerun);
bool_vector_free( iactive );
return NULL;
}
示例7: enkf_main_create_case_JOB
void * enkf_main_create_case_JOB( void * self , const stringlist_type * args) {
enkf_main_type * enkf_main = enkf_main_safe_cast( self );
const char * new_case = stringlist_iget( args , 0 );
enkf_fs_type * fs = enkf_main_mount_alt_fs( enkf_main , new_case , true );
enkf_fs_decref( fs );
return NULL;
}
示例8: enkf_main_init_case_from_existing_JOB
void * enkf_main_init_case_from_existing_JOB( void * self , const stringlist_type * args) {
enkf_main_type * enkf_main = enkf_main_safe_cast( self );
const char * source_case = stringlist_iget( args , 0 );
enkf_fs_type * source_fs = enkf_main_mount_alt_fs( enkf_main , source_case , true );
{
enkf_fs_type * target_fs;
if (stringlist_get_size(args) > 1) {
const char * current_case = enkf_main_get_current_fs(enkf_main);
const char * target_case = stringlist_iget( args , 1 );
if (0 != strcmp(current_case, target_case)) {
target_fs = enkf_main_mount_alt_fs( enkf_main , target_case , true );
} else
target_fs = enkf_fs_get_ref( enkf_main_get_fs(enkf_main) ); // Using get_ref so that we can unconditionally call decref() further down.
} else
target_fs = enkf_fs_get_ref( enkf_main_get_fs(enkf_main) ); // Using get_ref so that we can unconditionally call decref() further down.
enkf_main_init_case_from_existing(enkf_main, source_fs, 0, ANALYZED, target_fs);
enkf_fs_decref(target_fs);
}
enkf_fs_decref(source_fs);
return NULL;
}
示例9: enkf_main_create_reports_JOB
void * enkf_main_create_reports_JOB(void * self , const stringlist_type * args ) {
enkf_main_type * enkf_main = enkf_main_safe_cast( self );
ert_report_list_type * report_list = enkf_main_get_report_list( enkf_main );
ert_report_list_create( report_list , enkf_main_get_current_fs( enkf_main ) , true );
return NULL;
}
示例10: enkf_main_analysis_enkf_update_JOB
void * enkf_main_analysis_enkf_update_JOB( void * self , const stringlist_type * args) {
enkf_main_type * enkf_main = enkf_main_safe_cast( self );
enkf_fs_type * target_fs = enkf_main_get_fs( enkf_main );
int target_step;
int_vector_type * step_list;
// Argument 0: The number of the step to write to
if (stringlist_get_size(args) > 1)
util_sscanf_int(stringlist_iget( args , 1) , &target_step);
else
target_step = 0;
// Argument 1 - ??: The timesteps to use in the update
if (stringlist_get_size( args ) > 2) {
char * step_args = stringlist_alloc_joined_substring(args , 2 , stringlist_get_size(args) , " ");
step_list = string_util_alloc_active_list( step_args );
free( step_args );
} else
step_list = int_vector_alloc(1,target_step);
enkf_main_UPDATE( enkf_main , step_list , target_fs , target_step , SMOOTHER_UPDATE);
int_vector_free( step_list );
return NULL;
}
示例11: enkf_tui_analysis_update_module__
void enkf_tui_analysis_update_module__(void * arg) {
enkf_main_type * enkf_main = enkf_main_safe_cast( arg );
int prompt_len = 50;
{
const analysis_config_type * analysis_config = enkf_main_get_analysis_config( enkf_main );
analysis_module_type * analysis_module = analysis_config_get_active_module( analysis_config );
char var_name[256];
char value[256];
util_printf_prompt("Variable to modify" , prompt_len , '=' , "=> ");
scanf("%s", var_name);
{
char * value_prompt = util_alloc_sprintf("New value for %s" , var_name);
util_printf_prompt(value_prompt , prompt_len , '=' , "=> ");
free( value_prompt );
}
scanf("%s", value);
if (analysis_module_set_var( analysis_module , var_name , value))
printf("\'%s\' successfully set to \'%s\' \n",var_name , value);
else
printf("** Variable/type combination: %s/%s not recognized \n", var_name , value);
}
}
示例12: enkf_tui_run_iterated_ES
void enkf_tui_run_iterated_ES(void * arg) {
enkf_main_type * enkf_main = enkf_main_safe_cast( arg );
const analysis_config_type * analysis_config = enkf_main_get_analysis_config(enkf_main);
analysis_iter_config_type * iter_config = analysis_config_get_iter_config(analysis_config);
int num_iter = analysis_iter_config_get_num_iterations(iter_config);
enkf_main_run_iterated_ES(enkf_main , 0 , num_iter );
}
示例13: enkf_tui_run_smoother
void enkf_tui_run_smoother(void * arg) {
enkf_main_type * enkf_main = enkf_main_safe_cast( arg );
int ens_size = enkf_main_get_ensemble_size( enkf_main );
bool_vector_type * iactive = bool_vector_alloc( ens_size , true );
enkf_main_run_smoother(enkf_main , "AUTO-SMOOTHER" , iactive , 0 , true );
bool_vector_free( iactive );
}
示例14: enkf_tui_fs_initialize_case_for_predictions
void enkf_tui_fs_initialize_case_for_predictions(void * arg)
{
int prompt_len = 35;
char source_case[256];
int report_step_from;
int report_step_to;
state_enum state_from;
state_enum state_to;
enkf_main_type * enkf_main = enkf_main_safe_cast( arg );
state_from = ANALYZED;
state_to = ANALYZED;
report_step_from = enkf_main_get_history_length( enkf_main );
report_step_to = enkf_main_get_history_length( enkf_main );
{
char * target_case = util_alloc_string_copy( NULL );
util_printf_prompt("Source case" , prompt_len , '=' , "=> ");
fgets(source_case, prompt_len, stdin);
char *newline = strchr(source_case,'\n');
if(newline)
*newline = 0;
if(strlen(source_case) !=0)
enkf_tui_fs_copy_ensemble__(enkf_main, source_case, target_case, report_step_from, state_from, report_step_to, state_to, false);
free(target_case);
}
}
示例15: enkf_tui_fs_initialize_case_from_copy
void enkf_tui_fs_initialize_case_from_copy(void * arg)
{
int prompt_len =50;
char * source_case;
int ens_size;
int last_report;
int src_step;
state_enum src_state;
enkf_main_type * enkf_main = enkf_main_safe_cast( arg );
ens_size = enkf_main_get_ensemble_size( enkf_main );
last_report = enkf_main_get_history_length( enkf_main );
source_case = enkf_tui_fs_alloc_existing_case( enkf_main , "Initialize from case" , prompt_len);
if (source_case != NULL) {
char * ranking_key = NULL;
bool_vector_type * iens_mask = bool_vector_alloc( 0 , true );
src_step = util_scanf_int_with_limits("Source report step",prompt_len , 0 , last_report);
src_state = enkf_tui_util_scanf_state("Source analyzed/forecast [A|F]" , prompt_len , false);
enkf_main_initialize_from_existing( enkf_main , source_case , src_step , src_state , iens_mask , ranking_key );
bool_vector_free( iens_mask );
}
util_safe_free( source_case );
}