void enkf_tui_export_gen_data(void * arg) { enkf_main_type * enkf_main = enkf_main_safe_cast( arg ); const ensemble_config_type * ensemble_config = enkf_main_get_ensemble_config(enkf_main); { int report_step; int iens1 , iens2; const int last_report = enkf_main_get_history_length( enkf_main ); const enkf_config_node_type * config_node; path_fmt_type * file_fmt; config_node = enkf_tui_util_scanf_key(ensemble_config , PROMPT_LEN , GEN_DATA , INVALID_VAR); report_step = util_scanf_int_with_limits("Report step: ", PROMPT_LEN , 0 , last_report); enkf_tui_util_scanf_iens_range("Realizations members to export(0 - %d)" , enkf_main_get_ensemble_size( enkf_main ) , PROMPT_LEN , &iens1 , &iens2); { char path_fmt[512]; util_printf_prompt("Filename to store files in (with %d) in: " , PROMPT_LEN , '=' , "=> "); scanf("%s" , path_fmt); file_fmt = path_fmt_alloc_path_fmt( path_fmt ); } { enkf_fs_type * fs = enkf_main_tui_get_fs(enkf_main); enkf_node_type * node = enkf_node_alloc(config_node); gen_data_file_format_type export_type = gen_data_guess_export_type( (const gen_data_type *) enkf_node_value_ptr(node) ); int iens; for (iens = iens1; iens <= iens2; iens++) { node_id_type node_id = {.report_step = report_step , .iens = iens}; if (enkf_node_try_load(node , fs, node_id)) { char * full_path = path_fmt_alloc_path( file_fmt , false , iens); char * path; util_alloc_file_components(full_path , &path , NULL , NULL); if (path != NULL) util_make_path( path ); { const gen_data_type * gen_data = (const gen_data_type *) enkf_node_value_ptr(node); gen_data_export(gen_data , full_path , export_type); } free(full_path); free(path); } } enkf_node_free(node); } } }
void enkf_tui_export_field(const enkf_main_type * enkf_main , field_file_format_type file_type) { const ensemble_config_type * ensemble_config = enkf_main_get_ensemble_config(enkf_main); const bool output_transform = true; const enkf_config_node_type * config_node; const int last_report = enkf_main_get_history_length( enkf_main ); int iens1 , iens2 , iens , report_step; path_fmt_type * export_path; config_node = enkf_tui_util_scanf_key(ensemble_config , PROMPT_LEN , FIELD , INVALID_VAR ); report_step = util_scanf_int_with_limits("Report step: ", PROMPT_LEN , 0 , last_report); enkf_tui_util_scanf_iens_range("Realizations members to export(0 - %d)" , enkf_main_get_ensemble_size( enkf_main ) , PROMPT_LEN , &iens1 , &iens2); { char * path_fmt; util_printf_prompt("Filename to store files in (with %d) in: " , PROMPT_LEN , '=' , "=> "); path_fmt = util_alloc_stdin_line(); export_path = path_fmt_alloc_path_fmt( path_fmt ); free( path_fmt ); } { enkf_fs_type * fs = enkf_main_tui_get_fs(enkf_main); enkf_node_type * node = enkf_node_alloc(config_node); for (iens = iens1; iens <= iens2; iens++) { node_id_type node_id = {.report_step = report_step , .iens = iens }; if (enkf_node_try_load(node , fs , node_id)) { char * filename = path_fmt_alloc_path( export_path , false , iens); { char * path; util_alloc_file_components(filename , &path , NULL , NULL); if (path != NULL) { util_make_path( path ); free( path ); } } { const field_type * field = (const field_type *) enkf_node_value_ptr(node); field_export(field , filename , NULL , file_type , output_transform, NULL); } free(filename); } else printf("Warning: could not load realization:%d \n", iens); } enkf_node_free(node); } }
void ecl_config_set_eclbase( ecl_config_type * ecl_config , const char * eclbase_fmt ) { if (ecl_config->eclbase != NULL) path_fmt_free( ecl_config->eclbase ); ecl_config->eclbase = path_fmt_alloc_path_fmt( eclbase_fmt ); }