Esempio n. 1
0
char * ert_run_context_alloc_runpath( int iens , path_fmt_type * runpath_fmt , subst_list_type * subst_list , int iter) {
  char * runpath;
  {
    char * first_pass = path_fmt_alloc_path(runpath_fmt , false , iens, iter);    /* 1: Replace first %d with iens, if a second %d replace with iter */

    if (subst_list)
      runpath = subst_list_alloc_filtered_string( subst_list , first_pass );         /* 2: Filter out various magic strings like <CASE> and <CWD>. */
    else
      runpath = util_alloc_string_copy( first_pass );

    free( first_pass );
  }
  return runpath;
}
Esempio n. 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);
    }
  }
}
Esempio n. 3
0
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);
  }
}
Esempio n. 4
0
const char * member_config_update_eclbase(member_config_type * member_config , const ecl_config_type * ecl_config , const subst_list_type * subst_list) {
  util_safe_free( member_config->eclbase );
  {
    const path_fmt_type * eclbase_fmt = ecl_config_get_eclbase_fmt(ecl_config);
    if (eclbase_fmt != NULL) {
      {
        char * tmp = path_fmt_alloc_path(eclbase_fmt , false , member_config->iens);
        member_config->eclbase = subst_list_alloc_filtered_string( subst_list , tmp );
        free( tmp );
      }

      if (!ecl_util_valid_basename( member_config->eclbase )) 
        util_exit("Sorry - the basename:%s is invalid. ECLIPSE does not handle mIxeD cAsE :-( \n" , member_config->eclbase);
    }
  }
  
  return member_config->eclbase;
}
Esempio n. 5
0
static stringlist_type * ert_run_context_alloc_runpath_list(const bool_vector_type * iactive , path_fmt_type * runpath_fmt , subst_list_type * subst_list , int iter) {
  stringlist_type * runpath_list = stringlist_alloc_new();
  for (int iens = 0; iens < bool_vector_size( iactive ); iens++) {
    if (bool_vector_iget( iactive , iens )) {
      char * tmp1 = path_fmt_alloc_path(runpath_fmt , false , iens, iter);    /* 1: Replace first %d with iens, if a second %d replace with iter */
      char * tmp2 = tmp1;

      if (subst_list)
        tmp2 = subst_list_alloc_filtered_string( subst_list , tmp1 );         /* 2: Filter out various magic strings like <CASE> and <CWD>. */

      stringlist_append_copy( runpath_list , tmp2 );

      if (subst_list)
        free( tmp2 );
      free( tmp1 );
    } else
      stringlist_append_ref( runpath_list , NULL );
  }
  return runpath_list;
}
Esempio n. 6
0
char * enkf_config_node_alloc_outfile(const enkf_config_node_type * node , int report_step) {
  if (node->enkf_outfile_fmt != NULL)
    return path_fmt_alloc_path(node->enkf_outfile_fmt , false , report_step);
  else
    return NULL;
}