Exemple #1
0
void gen_data_ecl_write(const gen_data_type * gen_data , const char * run_path , const char * eclfile , void * filestream) {
  if (eclfile != NULL) {
    char * full_path = util_alloc_filename( run_path , eclfile  , NULL);

    gen_data_file_format_type export_type = gen_data_config_get_output_format( gen_data->config );
    gen_data_export( gen_data , full_path , export_type , filestream );
    free( full_path );
  }
}
Exemple #2
0
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);
    }
  }
}