Esempio n. 1
0
static void gen_kw_parameter_free( gen_kw_parameter_type * parameter ) {
  util_safe_free( parameter->name );
  util_safe_free( parameter->tagged_name );
  if (parameter->trans_func != NULL)
    trans_func_free( parameter->trans_func );
  free( parameter );
}
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
void RifEclipseSummaryTools::findSummaryHeaderFileInfo(const std::string& inputFile, std::string* headerFile, std::string* path, std::string* base, bool* isFormatted)
{
    char* myPath = NULL;
    char* myBase = NULL;
    bool formattedFile = true;

    util_alloc_file_components(inputFile.data(), &myPath, &myBase, NULL);

    char* myHeaderFile = ecl_util_alloc_exfilename(myPath, myBase, ECL_SUMMARY_HEADER_FILE, true, -1);
    if (!myHeaderFile)
    {
        myHeaderFile = ecl_util_alloc_exfilename(myPath, myBase, ECL_SUMMARY_HEADER_FILE, false, -1);
        if (myHeaderFile)
        {
            formattedFile = false;
        }
    }

    if (myHeaderFile && headerFile) *headerFile = myHeaderFile;
    if (myPath && path)             *path = myPath;
    if (myBase && base)             *base = myBase;
    if (isFormatted)                *isFormatted = formattedFile;

    util_safe_free(myHeaderFile);
    util_safe_free(myBase);
    util_safe_free(myPath);
}
Esempio n. 3
0
void site_config_free(site_config_type * site_config) {
  ext_joblist_free(site_config->joblist);
  job_queue_free(site_config->job_queue);

  hash_free(site_config->queue_drivers);

  stringlist_free(site_config->path_variables_user);
  stringlist_free(site_config->path_values_user);
  hash_free(site_config->path_variables_site);

  hash_free(site_config->env_variables_site);
  hash_free(site_config->env_variables_user);

  if (site_config->__license_root_path != NULL)
    util_clear_directory(site_config->__license_root_path, true, true);

  util_safe_free(site_config->manual_url);
  util_safe_free(site_config->default_browser);
  util_safe_free(site_config->license_root_path);
  util_safe_free(site_config->license_root_path_site);
  util_safe_free(site_config->__license_root_path);
  util_safe_free(site_config->job_script);
  util_safe_free(site_config->job_script_site);
  util_safe_free(site_config->rsh_command_site);
  util_safe_free(site_config->lsf_queue_name_site);
  util_safe_free(site_config->lsf_request_site);
  free(site_config);
}
Esempio n. 4
0
void data_ranking_free( data_ranking_type * ranking ) {
    double_vector_free( ranking->data_ensemble );
    bool_vector_free( ranking->valid );
    util_safe_free( ranking->sort_permutation );
    util_safe_free( ranking->user_key );
    free( ranking );
}
Esempio n. 5
0
void job_queue_free(job_queue_type * queue) {
  util_safe_free( queue->ok_file );
  util_safe_free( queue->exit_file );
  job_list_free( queue->job_list );
  job_queue_status_free( queue->status );
  free(queue);
}
Esempio n. 6
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
void RifEclipseSummaryTools::findSummaryHeaderFileInfo(const QString& inputFile, QString* headerFile, QString* path, QString* base, bool* isFormatted)
{
    char* myPath = nullptr;
    char* myBase = nullptr;
    bool formattedFile = true;

    util_alloc_file_components(RiaStringEncodingTools::toNativeEncoded(QDir::toNativeSeparators(inputFile)).data(), &myPath, &myBase, nullptr);

    char* myHeaderFile = ecl_util_alloc_exfilename(myPath, myBase, ECL_SUMMARY_HEADER_FILE, true, -1);
    if (!myHeaderFile)
    {
        myHeaderFile = ecl_util_alloc_exfilename(myPath, myBase, ECL_SUMMARY_HEADER_FILE, false, -1);
        if (myHeaderFile)
        {
            formattedFile = false;
        }
    }

    if (myHeaderFile && headerFile) *headerFile = RiaFilePathTools::toInternalSeparator(myHeaderFile);
    if (myPath && path)             *path = RiaFilePathTools::toInternalSeparator(myPath);
    if (myBase && base)             *base = RiaFilePathTools::toInternalSeparator(myBase);
    if (isFormatted)                *isFormatted = formattedFile;

    util_safe_free(myHeaderFile);
    util_safe_free(myBase);
    util_safe_free(myPath);
}
Esempio n. 7
0
void ecl_config_free(ecl_config_type * ecl_config) {
  ecl_io_config_free( ecl_config->io_config );
  if (ecl_config->eclbase != NULL) 
    path_fmt_free( ecl_config->eclbase );

  set_free( ecl_config->static_kw_set );
  stringlist_free( ecl_config->user_static_kw );
  util_safe_free(ecl_config->data_file);
  if (ecl_config->sched_file != NULL)
    sched_file_free(ecl_config->sched_file);


  util_safe_free(ecl_config->schedule_target_file);
  hash_free( ecl_config->fixed_length_kw );

  util_safe_free(ecl_config->input_init_section);
  util_safe_free(ecl_config->init_section);
  util_safe_free(ecl_config->schedule_prediction_file);

  if (ecl_config->grid != NULL)
    ecl_grid_free( ecl_config->grid );

  ecl_refcase_list_free( ecl_config->refcase_list );
  
  free(ecl_config);
}
Esempio n. 8
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
QString RifEclipseSummaryTools::findGridCaseFileFromSummaryHeaderFile(const QString& summaryHeaderFile)
{
    char* myPath = nullptr;
    char* myBase = nullptr;
    bool formattedFile = true;

    util_alloc_file_components(RiaStringEncodingTools::toNativeEncoded(QDir::toNativeSeparators(summaryHeaderFile)).data(), &myPath, &myBase, nullptr);

    char* caseFile = ecl_util_alloc_exfilename(myPath, myBase, ECL_EGRID_FILE, true, -1);
    if (!caseFile)
    {
        caseFile= ecl_util_alloc_exfilename(myPath, myBase, ECL_EGRID_FILE, false, -1);
        if (caseFile)
        {
            formattedFile = false;
        }
    }

    QString gridCaseFile;

    if (caseFile) gridCaseFile = caseFile;

    util_safe_free(caseFile);
    util_safe_free(myBase);
    util_safe_free(myPath);

    return RiaFilePathTools::toInternalSeparator(gridCaseFile);
}
Esempio n. 9
0
void ecl_config_set_init_section(ecl_config_type * ecl_config, const char * input_init_section) {
  if (ecl_config->can_restart)  { 
    /* The <INIT> tag is set. */
    ecl_config->input_init_section = util_realloc_string_copy(ecl_config->input_init_section, input_init_section); /* input_init_section = path/to/init_section         */
    if (util_file_exists(ecl_config->input_init_section))
    { /* init_section       = $CWD/path/to/init_section */
      util_safe_free(ecl_config->init_section);
      ecl_config->init_section = util_alloc_realpath(input_init_section);
    }
    else
    {
      char * path;

      util_alloc_file_components(ecl_config->input_init_section, &path, NULL, NULL );
      if (path != NULL )
        fprintf(stderr,
            "** Warning: %s: When INIT_SECTION:%s points to a non-existing file - you can not have any path components.\n",
            __func__, input_init_section);
      else
        ecl_config->init_section = util_alloc_string_copy(input_init_section);

      util_safe_free(path);
    }
  }
  else
    /* 
       The <INIT> tag is not set - we can not utilize the
       input_init_section info, and we just ignore it.
     */
    fprintf(stderr,
        "** Warning: <INIT> tag was not found in datafile - can not utilize INIT_SECTION keyword - ignored.\n");
}
Esempio n. 10
0
void gen_kw_config_free(gen_kw_config_type * gen_kw_config) {
  util_safe_free( gen_kw_config->key );
  util_safe_free( gen_kw_config->template_file );
  util_safe_free( gen_kw_config->parameter_file );

  vector_free( gen_kw_config->parameters );
  free(gen_kw_config);
}
Esempio n. 11
0
void field_config_free(field_config_type * config) {
    util_safe_free(config->ecl_kw_name);
    util_safe_free(config->input_transform_name);
    util_safe_free(config->output_transform_name);
    util_safe_free(config->init_transform_name);
    if ((config->private_grid) && (config->grid != NULL)) ecl_grid_free( config->grid );
    free(config);
}
Esempio n. 12
0
/**
   This function will close all pending/halfopen plot operations and
   free all resources used by the plot.
*/
void plot_free( plot_type * plot )
{
  plot_driver_free( plot->driver );
  plot_free_all_datasets(plot);
  plot_range_free(plot->range);
  util_safe_free(plot->timefmt);
  util_safe_free(plot);
}
Esempio n. 13
0
void job_queue_node_free_data(job_queue_node_type * node) {
  util_safe_free( node->job_name );
  util_safe_free( node->exit_file );
  util_safe_free( node->ok_file );
  util_safe_free( node->run_cmd );
  util_free_stringlist( node->argv , node->argc );

  if (node->job_data != NULL)
    util_abort("%s: internal error - driver spesific job data has not been freed - will leak.\n",__func__);
}
Esempio n. 14
0
void gen_data_config_free(gen_data_config_type * config) {
  int_vector_free( config->data_size_vector );
  
  util_safe_free( config->key );
  util_safe_free( config->template_buffer );
  util_safe_free( config->template_file );
  util_safe_free( config->template_key );
  bool_vector_free( config->active_mask );
  
  free(config);
}
Esempio n. 15
0
static void plplot_state_close( plplot_state_type * state ) {
  plsstrm(state->stream);
  plend1();
  plend();
  
  util_safe_free( state->filename );
  util_safe_free( state->device );
  free( state->plbox_xopt );
  free( state->plbox_yopt );
  free( state );
}
Esempio n. 16
0
static void gen_data_config_reset_template( gen_data_config_type * config ) {
  util_safe_free( config->template_buffer ); 
  util_safe_free( config->template_key ); 
  util_safe_free( config->template_file );

  config->template_file = NULL;
  config->template_buffer = NULL;
  config->template_key = NULL;
  config->template_data_offset = 0;
  config->template_data_skip = 0;
  config->template_buffer_size = 0;
}
Esempio n. 17
0
void custom_kw_config_free(custom_kw_config_type * config) {
    util_safe_free(config->name);
    util_safe_free(config->result_file);
    util_safe_free(config->output_file);
    util_safe_free(config->key_definition_file);

    hash_free(config->custom_keys);
    hash_free(config->custom_key_types);

    pthread_rwlock_destroy(& config->rw_lock);

    free(config);
}
Esempio n. 18
0
File: ecl_sum.c Progetto: flikka/ert
void ecl_sum_set_case( ecl_sum_type * ecl_sum , const char * ecl_case) {
  util_safe_free( ecl_sum->ecl_case );
  util_safe_free( ecl_sum->path );
  util_safe_free( ecl_sum->abs_path );
  util_safe_free( ecl_sum->base );
  util_safe_free( ecl_sum->ext );
  {
    char  *path , *base, *ext;

    util_alloc_file_components( ecl_case , &path , &base , &ext);

    ecl_sum->ecl_case = util_alloc_string_copy( ecl_case );
    ecl_sum->path     = util_alloc_string_copy( path );
    ecl_sum->base     = util_alloc_string_copy( base );
    ecl_sum->ext      = util_alloc_string_copy( ext );
    if (path != NULL)
      ecl_sum->abs_path = util_alloc_abs_path( path );
    else
      ecl_sum->abs_path = util_alloc_cwd();

    util_safe_free( base );
    util_safe_free( path );
    util_safe_free( ext );
  }
}
Esempio n. 19
0
void config_content_free( config_content_type * content ) {
  vector_free( content->nodes );
  vector_free( content->path_elm_stack );
  vector_free( content->path_elm_storage );
  hash_free( content->items );
  config_error_free( content->parse_errors );
  subst_list_free( content->define_list );
  util_safe_free( content->config_file );
  util_safe_free( content->abs_path );
  set_free( content->parsed_files );
  if (content->invoke_path != NULL)
    config_root_path_free( content->invoke_path );

  free( content );
}
Esempio n. 20
0
static void util_fprintf_backtrace(FILE * stream) {
  const char * with_linenr_format = " #%02d %s(..) %s in %s:%d\n";
  const char * func_format        = " #%02d %s(..) %s in ???\n";
  const char * unknown_format     = " #%02d ???? \n";

  const int max_bt = 100;
  const int max_func_length = 70;
  void *bt_addr[max_bt];
  int    size,i;

  size       = backtrace(bt_addr , max_bt);

  fprintf(stream , "--------------------------------------------------------------------------------\n");
  for (i=0; i < size; i++) {
    int line_nr;
    char * func_name;
    char * file_name;
    char * padding = NULL;

    if (util_addr2line_lookup(bt_addr[i], &func_name , &file_name , &line_nr)) {
      int pad_length;
      char * function;
      // Seems it can return true - but with func_name == NULL?! Static/inlinded functions?
      if (func_name)
        function = func_name;
      else
        function = "???";

      pad_length = util_int_max (2, 2 + max_func_length - strlen(function));
      padding = realloc_padding( padding , pad_length);
      fprintf(stream , with_linenr_format , i , function , padding , file_name , line_nr);
    } else {
      if (func_name != NULL) {
        int pad_length = util_int_max( 2 , 2 + max_func_length - strlen(func_name));
        padding = realloc_padding( padding , pad_length);
        fprintf(stream , func_format , i , func_name , padding);
      } else {
        padding = realloc_padding( padding , 2 + max_func_length );
        fprintf(stream , unknown_format , i , padding);
      }
    }

    util_safe_free( func_name );
    util_safe_free( file_name );
    util_safe_free( padding );
  }
  fprintf(stream , "--------------------------------------------------------------------------------\n");
}
Esempio n. 21
0
void plot_config_free( plot_config_type * plot_config) {
  free(plot_config->plot_path);
  util_safe_free(plot_config->viewer);
  free(plot_config->image_type);
  free(plot_config->driver );
  free(plot_config);
}
Esempio n. 22
0
void ecl_util_alloc_summary_data_files(const char * path , const char * base , bool fmt_file , stringlist_type * filelist) {
  char  * unif_data_file = ecl_util_alloc_exfilename(path , base , ECL_UNIFIED_SUMMARY_FILE , fmt_file , -1);
  int files = ecl_util_select_filelist( path , base , ECL_SUMMARY_FILE , fmt_file , filelist);

  if ((files > 0) && (unif_data_file != NULL)) {
    /* 
       We have both a unified file AND a list of files: BASE.S0000,
       BASE.S0001, BASE.S0002, ..., must check which is newest and
       load accordingly.
    */
    bool unified_newest = true;
    int file_nr = 0;
    while (unified_newest && (file_nr < files)) {
      if (util_file_difftime( stringlist_iget(filelist , file_nr) , unif_data_file ) > 0) 
        unified_newest = false;
      file_nr++;
    }
    
    if (unified_newest) {
      stringlist_clear( filelist ); /* Clear out all the BASE.Snnnn selections. */
      stringlist_append_copy( filelist , unif_data_file );
    } 
  } else if (unif_data_file != NULL) {
    /* Found a unified summary file :  Clear out all the BASE.Snnnn selections. */
    stringlist_clear( filelist );      /* Clear out all the BASE.Snnnn selections. */
    stringlist_append_copy( filelist , unif_data_file );
  } 
  util_safe_free( unif_data_file );
}
static ecl_kw_type * __ecl_kw_fscanf_alloc_grdecl__(FILE * stream , const char * header , bool strict , int size , ecl_type_enum ecl_type) {
  if (! (ecl_type == ECL_FLOAT_TYPE || ecl_type == ECL_INT_TYPE || ecl_type == ECL_DOUBLE_TYPE))
    util_abort("%s: sorry only types FLOAT, INT and DOUBLE supported\n",__func__);

  if (header != NULL)
    if (!ecl_kw_grdecl_fseek_kw( header , true , stream ))
      return NULL;  /* Could not find it. */

  {
    char file_header[9];
    if (fscanf(stream , "%s" , file_header) == 1) {
      int kw_size;
      char * data = fscanf_alloc_grdecl_data( file_header , strict , ecl_type , &kw_size , stream );
      
      // Verify size
      if (size > 0)
        if (size != kw_size) {
          util_safe_free( data );
          util_abort("%s: size mismatch when loading:%s. File:%d elements. Requested:%d elements \n",
                     __func__ , file_header , kw_size , size);
        }
      
      {
        ecl_kw_type * ecl_kw = ecl_kw_alloc_new( file_header , kw_size , ecl_type , NULL );
        ecl_kw_set_data_ptr( ecl_kw , data );
        return ecl_kw;
      }

    } else 
      /** No header read - probably at EOF */
      return NULL;
  }
}
Esempio n. 24
0
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 );
}
Esempio n. 25
0
void enkf_tui_run_exp(void * enkf_main) {
  const int ens_size          = enkf_main_get_ensemble_size( enkf_main );
  bool_vector_type * iactive  = bool_vector_alloc(0,false);

  state_enum init_state    = ANALYZED; 
  int start_report         = 0;
  int init_step_parameters = 0;
  
  {

    char * prompt = util_alloc_sprintf("Which realizations to simulate (Ex: 1,3-5) <Enter for all> [M to return to menu] : " , ens_size);
    char * select_string;
      
    util_printf_prompt(prompt , PROMPT_LEN , '=' , "=> ");
    select_string = util_alloc_stdin_line();
    enkf_tui_util_sscanf_active_list( iactive , select_string , ens_size);

    util_safe_free( select_string );
    free( prompt );
  }
  if (bool_vector_count_equal(iactive , true))
    enkf_main_run_exp(enkf_main , iactive , true , init_step_parameters , start_report , init_state, true);
  
  bool_vector_free(iactive);
}
Esempio n. 26
0
config_path_elm_type * config_content_add_path_elm( config_content_type * content , const char * path ) {
  const config_path_elm_type * current_path_elm;

  if (vector_get_size( content->path_elm_stack ) == 0)
    current_path_elm = NULL;
  else
    current_path_elm = vector_get_last_const(content->path_elm_stack);

  {
    config_path_elm_type * new_path_elm;

    {
      char * rel_path = NULL;
      config_root_path_type * invoke_path = config_content_get_invoke_path( content );
      if (path != NULL) {
        if (current_path_elm == NULL)
          rel_path = util_alloc_rel_path( config_root_path_get_abs_path(invoke_path) , path);
        else
          rel_path = config_path_elm_alloc_relpath( current_path_elm , path );
      }
      new_path_elm = config_path_elm_alloc( invoke_path , rel_path );
      util_safe_free( rel_path );
    }
    vector_append_owned_ref( content->path_elm_storage , new_path_elm , config_path_elm_free__);
    vector_append_ref( content->path_elm_stack , new_path_elm );
    return new_path_elm;
  }
}
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
std::vector<std::string> RifEclipseSummaryTools::findSummaryDataFiles(const std::string& caseFile)
{
    std::vector<std::string> fileNames;

    std::string path;
    std::string base;

    findSummaryHeaderFileInfo(caseFile, NULL, &path, &base, NULL);
    if (path.empty() || base.empty()) return fileNames;

    char* header_file = NULL;
    stringlist_type* summary_file_list = stringlist_alloc_new();

    ecl_util_alloc_summary_files(path.data(), base.data(), NULL, &header_file, summary_file_list);
    if (stringlist_get_size( summary_file_list ) > 0)
    {
        for (int i = 0; i < stringlist_get_size(summary_file_list); i++)
        {
            fileNames.push_back(stringlist_iget(summary_file_list, i));
        }
    }

    util_safe_free(header_file);
    stringlist_free(summary_file_list);

    return fileNames;
}
Esempio n. 28
0
static void ecl_grav_survey_free( ecl_grav_survey_type * grav_survey ) {
  free( grav_survey->name );
  util_safe_free( grav_survey->porv );
  vector_free( grav_survey->phase_list );
  hash_free( grav_survey->phase_map );
  free( grav_survey );
}
Esempio n. 29
0
static void custom_kw_config_reset__(custom_kw_config_type * config) {
    config->undefined = true;
    hash_clear(config->custom_keys);
    hash_clear(config->custom_key_types);
    util_safe_free(config->key_definition_file);
    config->key_definition_file = NULL;
}
Esempio n. 30
0
File: log.c Progetto: jokva/ert
void log_close( log_type * logh ) {
    if ((logh->stream != stdout) && (logh->stream != stderr) && (logh->stream != NULL))
        fclose( logh->stream );  /* This closes BOTH the FILE * stream and the integer file descriptor. */

    util_safe_free( logh->filename );
    free( logh );
}