job_type * alloc_job( rng_type * rng , const char * cmd) {
  const int second = 1000000;
  const int submit_min = 0;
  const int submit_max = 10 * second;

  const int callback_min = 0.5 * second;
  const int callback_max = 2 * second;

  const int run_min = 2 * second;
  const int run_max = 10 * second;

  job_type * job = util_malloc( sizeof * job );
  UTIL_TYPE_ID_INIT( job , JOB_TYPE_ID )
  job->callback_run = false;
  job->queue_index = -1;
  job->submit_usleep    = submit_min  + rng_get_int( rng , (submit_max - submit_min ));
  job->callback_usleep = callback_min + rng_get_int( rng , (callback_max - callback_min ));
  job->run_usleep      = run_min      + rng_get_int( rng , (run_max - run_min ));
  job->run_path        = util_alloc_sprintf("%08d", rng_get_int(rng , 100000000));
  job->cmd = cmd;
  job->argc = 4;

  job->argv = util_malloc( 4 * sizeof * job->argv );
  job->argv[0] = job->run_path;
  job->argv[1] = "RUNNING";
  job->argv[2] = "OK";
  job->argv[3] = util_alloc_sprintf("%d", job->run_usleep);

  util_make_path( job->run_path );
  return job;
}
Example #2
0
int main(int argc, char ** argv) {
  int num_src_drivers    = 10;
  int num_target_drivers = 32;
  if (argc != 4) 
    usage();
  
  {
    char * src_path        = argv[1] ;
    char * target_path     = argv[2] ;
    char * dir             = argv[3] ;
   
    util_make_path( target_path );
    if (util_same_file( src_path , target_path)) {
      fprintf(stderr,"The two directories:%s and %s point to the same location \n" , src_path , target_path );
      exit(1);
    }
    
    {
      char * src_case    = util_alloc_sprintf("%s/%s" , src_path , dir );
      char * target_case = util_alloc_sprintf("%s/%s" , target_path , dir );

      msg_type * msg = msg_alloc("Copying from: " , false);
      msg_show( msg );
      migrate_file(src_case , num_src_drivers , target_case , num_target_drivers , "ANALYZED" , 32 , msg);
      migrate_file(src_case , num_src_drivers , target_case , num_target_drivers , "FORECAST" , 32 , msg);
      migrate_file(src_case , num_src_drivers , target_case , num_target_drivers , "PARAMETER" , 32 , msg);
      migrate_file(src_case , num_src_drivers , target_case , num_target_drivers , "STATIC" , 32 , msg);
      copy_index( src_case , target_case );
      free( src_case);
      free( target_case );
      msg_free( msg , true );
    }
  }
}
Example #3
0
void test_read_erroneous_gen_kw_file() {
  const char * parameter_filename = "MULTFLT_with_errors.txt";
  const char * tmpl_filename = "MULTFLT.tmpl";

  {
    FILE * stream = util_fopen(parameter_filename, "w");
    const char * data = util_alloc_sprintf("MULTFLT1 NORMAL 0\nMULTFLT2 RAW\nMULTFLT3 NORMAL 0");
    util_fprintf_string(data, 30, true, stream);
    util_fclose(stream);

    FILE * tmpl_stream = util_fopen(tmpl_filename, "w");
    const char * tmpl_data = util_alloc_sprintf("<MULTFLT1> <MULTFLT2> <MULTFLT3>\n");
    util_fprintf_string(tmpl_data, 30, true, tmpl_stream);
    util_fclose(tmpl_stream);
  }

  gen_kw_config_type * gen_kw_config = gen_kw_config_alloc_empty("MULTFLT", "<%s>");
  vector_type * arg = vector_alloc_new();
  vector_append_ref( arg , gen_kw_config );
  vector_append_ref(arg, parameter_filename);

  test_assert_util_abort("arg_pack_fscanf", read_erroneous_gen_kw_file,  arg);

  vector_free(arg);
  gen_kw_config_free(gen_kw_config);
}
Example #4
0
static bool util_addr2line_lookup__(const void * bt_addr , char ** func_name , char ** file_name , int * line_nr, bool subtract_base_adress) {
  *func_name = NULL;    // If dladdr() succeeds, but addr2line fails the func_name pointer will be set, but the function will return false anyway.
  *file_name = NULL;
  *line_nr   = 0;
  {
    bool  address_found = false;
    Dl_info dl_info;
#if defined(__APPLE__)
    return false;
#else
    if (dladdr(bt_addr , &dl_info)) {
      const char * executable = dl_info.dli_fname;
      *func_name = util_alloc_string_copy( dl_info.dli_sname );
      if (util_file_exists( executable )) {
        char *stdout_file = util_alloc_tmp_file("/tmp" , "addr2line" , true);
        /* 1: Run addr2line application */
        {
          char ** argv = util_calloc(3 , sizeof * argv );
          argv[0] = util_alloc_string_copy("--functions");
          argv[1] = util_alloc_sprintf("--exe=%s" , executable );
          {
            char * rel_address = (char *) bt_addr;
            if (subtract_base_adress)
              rel_address -= (size_t) dl_info.dli_fbase;
            argv[2] = util_alloc_sprintf("%p" , (void *) rel_address);
          }
          util_spawn_blocking("addr2line", 3, (const char **) argv, stdout_file, NULL);
          util_free_stringlist(argv , 3);
        }

        /* 2: Parse stdout output */
        {
          bool at_eof;
          FILE * stream = util_fopen(stdout_file , "r");
          char * tmp_fname = util_fscanf_alloc_line(stream , &at_eof);

          if (strcmp(tmp_fname , UNDEFINED_FUNCTION) != 0) {
            char * stdout_file_name = util_fscanf_alloc_line(stream , &at_eof);
            char * line_string = NULL;
            util_binary_split_string( stdout_file_name , ":" , false , file_name , &line_string);
            if (line_string && util_sscanf_int( line_string , line_nr))
              address_found = true;

            free( stdout_file_name );
            util_safe_free( line_string );
          }
          free( tmp_fname );
          fclose(stream);
        }
        util_unlink_existing(stdout_file);
        free( stdout_file );
      }
    }
    return address_found;
#endif
  }
}
Example #5
0
File: main.c Project: pgdr/ert
static void init_debug(const char * argv0) {
  char * git_commit       = util_alloc_sprintf("git commit...........: %s \n",GIT_COMMIT);
  char * compile_time     = util_alloc_sprintf("Compile time.........: %s \n",COMPILE_TIME_STAMP);

  /* This will be printed if/when util_abort() is called on a later stage. */
  util_abort_append_version_info(git_commit);
  util_abort_append_version_info(compile_time);

  free(git_commit);
  free(compile_time);

  util_abort_set_executable(argv0);
}
Example #6
0
void model_config_set_case_table( model_config_type * model_config , int ens_size , const char * case_table_file ) {
  if (model_config->case_table_file != NULL) { /* Clear the current selection */
    free( model_config->case_table_file );
    stringlist_free( model_config->case_names );
    
    model_config->case_table_file = NULL;
    model_config->case_names      = NULL;
  }

  if (case_table_file != NULL) {
    bool atEOF = false;
    char casename[128];
    int  case_size = 0;
    FILE * stream = util_fopen( case_table_file , "r");
    model_config->case_names = stringlist_alloc_new();
    while (!atEOF) {
      if (fscanf( stream , "%s" , casename) == 1) {
        stringlist_append_copy( model_config->case_names , casename );
        case_size++;
      } else
        atEOF = true;
    }
    fclose( stream );

    if (case_size < ens_size) {
      for (int i = case_size; i < ens_size; i++)
        stringlist_append_owned_ref( model_config->case_names , util_alloc_sprintf("case_%04d" , i));
      fprintf(stderr, "** Warning: mismatch between NUM_REALIZATIONS:%d and size of CASE_TABLE:%d - using \'case_nnnn\' for the last cases %d.\n", ens_size , case_size , ens_size - case_size);
    } else if (case_size > ens_size) 
      fprintf(stderr, "** Warning: mismatch between NUM_REALIZATIONS:%d and CASE_TABLE:%d - only the %d realizations will be used.\n", ens_size , case_size , ens_size);

  }
}
Example #7
0
static void enkf_tui_analysis_update_title( enkf_main_type * enkf_main , menu_type * menu ) {
  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 * title = util_alloc_sprintf("Analysis menu [Current module:%s]" , analysis_module_get_name( analysis_module ));
  menu_set_title( menu , title );
  free( title );
}
Example #8
0
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);
    
  }
}
Example #9
0
void enkf_tui_util_scanf_report_steps(int last_report , int prompt_len , int * __step1 , int * __step2) {
  char * prompt = util_alloc_sprintf("Report steps (0 - %d)" , last_report);
  bool OK = false;

  util_printf_prompt(prompt , prompt_len , '=' , "=> ");
  
  while (!OK) {
    char * input = util_alloc_stdin_line();
    const char * current_ptr = input;
    int step1 , step2;
    OK = true;
    if(input == NULL){
      step1=0;
      step2=last_report;
    }
    else{
      current_ptr = util_parse_int(current_ptr , &step1 , &OK);
      current_ptr = util_skip_sep(current_ptr , " ,-:" , &OK);
      current_ptr = util_parse_int(current_ptr , &step2 , &OK);
    }
    if (!OK) 
      printf("Failed to parse two integers from: \"%s\". Example: \"0 - 19\" to get the 20 first report steps.\n",input);
    free(input);

    step1 = util_int_min(step1 , last_report);
    step2 = util_int_min(step2 , last_report);
    if (step1 > step2) 
      util_exit("%s: ohh come on - must have a finite interval forward in time - no plots for you.\n",__func__);
    *__step1 = step1;
    *__step2 = step2;
    
  }
  free(prompt);
}
Example #10
0
void enkf_tui_util_scanf_iens_range(const char * prompt_fmt , int ens_size , int prompt_len , int * iens1 , int * iens2) {
  char * prompt = util_alloc_sprintf(prompt_fmt , ens_size - 1);
  bool OK = false;

  util_printf_prompt(prompt , prompt_len , '=' , "=> ");
  
  while (!OK) {
    char * input = util_alloc_stdin_line();
    const char * current_ptr = input;
    OK = true;

    if (input != NULL) {
      current_ptr = util_parse_int(current_ptr , iens1 , &OK);
      current_ptr = util_skip_sep(current_ptr , " ,-:" , &OK);
      current_ptr = util_parse_int(current_ptr , iens2 , &OK);
      
      if (!OK) 
        printf("Failed to parse two integers from: \"%s\". Example: \"0 - 19\" to get the 20 first members.\n",input);
      free(input);
    } else {
      *iens1 = 0;
      *iens2 = ens_size - 1;
    }
  }
  free(prompt);
}
Example #11
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);
}
Example #12
0
bool ecl_util_valid_basename_fmt(const char * basename_fmt)
{
  bool valid;

  char * eclbasename_fmt = util_split_alloc_filename(basename_fmt);

  const char * percent_ptr = strchr(eclbasename_fmt, '%');
  if (percent_ptr) {
    percent_ptr++;
    while (true)
    {
      if (*percent_ptr == 'd')
      {
        char * basename_instance = util_alloc_sprintf(eclbasename_fmt, 0);
        valid = ecl_util_valid_basename(basename_instance);
        free(basename_instance);
        break;
      } else if (!isdigit(*percent_ptr)) {
        valid = false;
        break;
      } else
        percent_ptr++;
    }
  } else
    valid = ecl_util_valid_basename(eclbasename_fmt);

  free(eclbasename_fmt);

  return valid;
}
Example #13
0
/**
   This function will load an active map from the enkf_fs filesystem.
*/
void gen_data_config_load_active( gen_data_config_type * config , int report_step , bool force_load) {
  if (config->fs == NULL)
    return;                /* This is used as a GEN_PARAM instance - and the loading of mask is not an option. */
  
  
  pthread_mutex_lock( &config->update_lock );
  {
    if ( force_load || (int_vector_iget( config->data_size_vector , report_step ) > 0)) {
      if (config->active_report_step != report_step) {
        char * filename = util_alloc_sprintf("%s_active" , config->key );
        FILE * stream   = enkf_fs_open_excase_tstep_file( config->fs , filename , report_step);

        if (stream != NULL) {
          bool_vector_fread( config->active_mask , stream );
          fclose( stream );
        } else 
          fprintf(stderr,"** Warning: could not find file:%s \n",filename);

        free( filename );
      }
    }
    config->active_report_step = report_step;
  }
  pthread_mutex_unlock( &config->update_lock );
}
Example #14
0
plot_dataset_type * plot_alloc_new_dataset(plot_type * plot , const char * __label , plot_data_type data_type) {
  if (data_type == PLOT_HIST) {
    if (vector_get_size( plot->dataset) > 0)
      util_abort("%s: sorry - when using histograms you can *only* have one dataset\n",__func__);
    plot->is_histogram = true;
  } else if (plot->is_histogram)
    util_abort("%s: sorry - when using histograms you can *only* have one dataset\n",__func__);
  
  {
    char * label;
    if (__label == NULL)
      label = util_alloc_sprintf("data_%d" , vector_get_size( plot->dataset ));
    else
      label = (char *) __label;
    
    if (hash_has_key( plot->dataset_hash , label))
      util_abort("%s: sorry - the label %s is already in use - must be unique \n",__func__ , label);
    {
      plot_dataset_type * dataset = plot_dataset_alloc(data_type, label , plot->logx , plot->logy);
      vector_append_owned_ref(plot->dataset , dataset , plot_dataset_free__);
      hash_insert_ref( plot->dataset_hash , label , dataset);
      if (__label == NULL)
        free(label);
      return dataset;
    }
  }
}  
Example #15
0
void group_rate_add_well_rate( group_rate_type * group_rate , well_rate_type * well_rate) {
  if (well_rate_get_phase( well_rate ) == group_rate->phase) {
    char * key = util_alloc_sprintf("%s:%s" , well_rate_get_name( well_rate ) , sched_phase_type_string( group_rate->phase ));
    vector_append_owned_ref( group_rate->well_rates , well_rate , well_rate_free__ );
    free( key );
  }
}
Example #16
0
void field_config_scanf_ijk(const field_config_type * config , bool active_only , const char * _prompt , int prompt_len , int *_i , int *_j , int *_k , int * _global_index) {
    const char * sep_set = " ,.:";
    char * prompt = util_alloc_sprintf("%s (%d,%d,%d)" , _prompt , config->nx , config->ny , config->nz);
    bool OK;
    int i,j,k,global_index;
    global_index = -1; /* Keep the compiler happy. */

    do {
        char         *input;
        const  char  *current_ptr;
        util_printf_prompt(prompt , prompt_len , '=' , "=> ");
        input = util_alloc_stdin_line();


        i = -1;
        j = -1;
        k = -1;

        OK = true;
        current_ptr = input;
        current_ptr = util_parse_int(current_ptr , &i , &OK);
        current_ptr = util_skip_sep(current_ptr , sep_set , &OK);
        current_ptr = util_parse_int(current_ptr , &j , &OK);
        current_ptr = util_skip_sep(current_ptr , sep_set , &OK);
        current_ptr = util_parse_int(current_ptr , &k , &OK);
        if (OK)
            if (current_ptr[0] != '\0') OK = false; /* There was something more at the end */

        /* Now we have three valid integers. */

        if (OK) {
            if (i <= 0 || i > config->nx) OK = false;
            if (j <= 0 || j > config->ny) OK = false;
            if (k <= 0 || k > config->nz) OK = false;
            i--;
            j--;
            k--;
        }
        /* Now we have three integers in the right interval. */


        if (OK) {
            global_index = field_config_active_index(config , i,j,k);
            if (active_only) {
                if (global_index < 0) {
                    OK = false;
                    printf("Sorry the point: (%d,%d,%d) corresponds to an inactive cell\n" , i + 1 , j+ 1 , k + 1);
                }
            }
        }
        free(input);
    } while (!OK);

    if (_i != NULL) *_i = i;
    if (_j != NULL) *_j = j;
    if (_k != NULL) *_k = k;
    if (_global_index != NULL) *_global_index = global_index;

    free(prompt);
}
Example #17
0
void ert_workflow_list_add_jobs_in_directory( ert_workflow_list_type * workflow_list , const char * path ) {
  DIR * dirH = opendir( path );
  if (dirH) {
    while (true) {
      struct dirent * entry = readdir( dirH );
      if (entry != NULL) {
        if ((strcmp(entry->d_name , ".") != 0) && (strcmp(entry->d_name , "..") != 0)) {
          char * full_path = util_alloc_filename( path , entry->d_name , NULL );

          if (util_is_file( full_path )) {
           if (ert_log_is_open())
              ert_log_add_message( 1 , NULL , util_alloc_sprintf("Adding workflow job:%s " , full_path ), true);

            ert_workflow_list_add_job( workflow_list , entry->d_name , full_path );
          }

          free( full_path );
        }
      } else
        break;
    }
    closedir( dirH );
  } else
    fprintf(stderr, "** Warning: failed to open workflow/jobs directory: %s\n", path);
}
Example #18
0
char * smspec_alloc_region_2_region_r1r2_key( const char * join_string , const char * keyword , int r1, int r2) {
  return util_alloc_sprintf(ECL_SUM_KEYFMT_REGION_2_REGION_R1R2,
                            keyword,
                            join_string,
                            r1,
                            r2);
}
Example #19
0
static void migrate_file( const char * src_case, int num_src_drivers , const char * target_case, int num_target_drivers, const char * file, int block_size , msg_type * msg) {
  block_fs_type ** target_fs = util_calloc( num_target_drivers , sizeof * target_fs  ); 
  int itarget;
  for (itarget = 0; itarget < num_target_drivers; itarget++) {
    char * path       = util_alloc_sprintf("%s/mod_%d" , target_case , itarget );
    char * mount_file = util_alloc_sprintf("%s/mod_%d/%s.mnt" , target_case , itarget , file );
    util_make_path( path );
    
    target_fs[itarget] =  block_fs_mount( mount_file , 16 , 0 , 1.0, 0 , false , false );
    free( mount_file );
    free( path );
  } 

  {
    int isrc;
    buffer_type * buffer = buffer_alloc(1024);
    for (isrc = 0; isrc < num_src_drivers; isrc++) {
      char * mount_file = util_alloc_sprintf("%s/mod_%d/%s.mnt" , src_case , isrc , file );
      block_fs_type   * src_fs    = block_fs_mount( mount_file , 16 , 1024 , 1.0 , 0 , true , true );
      vector_type     * file_list = block_fs_alloc_filelist( src_fs , NULL , NO_SORT , false );
      int ifile;
      msg_update( msg , mount_file );
      for (ifile = 0; ifile < vector_get_size( file_list ); ifile++) {
        const file_node_type * node = vector_iget_const( file_list , ifile );
        const char * filename       = file_node_get_filename( node );
        int   report_step , iens;
        char * key;
        if (block_fs_sscanf_key( filename , &key , &report_step , &iens )) {
          block_fs_fread_realloc_buffer( src_fs , filename , buffer);
          block_fs_fwrite_buffer( target_fs[(iens % num_target_drivers)] , filename , buffer );
          free( key );
        } else
          util_abort("%s: All hell is loose - failed to parse:%s \n",__func__ , filename);
      }

      vector_free( file_list );
      block_fs_close(src_fs , false);
    }
    buffer_free( buffer );
  }

  
  for (itarget = 0; itarget < num_target_drivers; itarget++) 
    block_fs_close( target_fs[itarget] , false);
  free( target_fs );
}
Example #20
0
char * smspec_alloc_local_block_key( const char * join_string , const char * keyword , const char * lgr_name , int i , int j , int k) {
  return util_alloc_sprintf(ECL_SUM_KEYFMT_LOCAL_BLOCK ,
                            keyword ,
                            join_string ,
                            lgr_name ,
                            join_string ,
                            i,j,k);
}
Example #21
0
char * util_alloc_dump_filename() {
  time_t timestamp = time(NULL);
  char day[32];
  strftime(day, 32, "%Y%m%d-%H%M%S", localtime(&timestamp));
  {
    uid_t uid = getuid();
    struct passwd *pwd = getpwuid(uid);
    char * filename;

    if (pwd)
      filename = util_alloc_sprintf("/tmp/ert_abort_dump.%s.%s.log", pwd->pw_name, day);
    else
      filename = util_alloc_sprintf("/tmp/ert_abort_dump.%d.%s.log", uid , day);

    return filename;
  }
}
Example #22
0
void * lsb_dlopen( lsb_type * lsb , const char * lib_name) {
    void * lib_handle = dlopen( lib_name , RTLD_NOW | RTLD_GLOBAL);
    if (!lib_handle) {
        lsb->ready = false;
        stringlist_append_owned_ref( lsb->error_list , util_alloc_sprintf("dlopen(%s) - failed:%s \n" , lib_name , dlerror()));
    }
    return lib_handle;
}
Example #23
0
void * enkf_main_rank_on_observations_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);

  bool step_arguments = false;
  bool obs_arguments  = false;
  int  delimiter      = 0;
  {
    delimiter = stringlist_find_first(args, "|");
    if (delimiter > -1) {
      step_arguments = (delimiter > 1) ? true : false;
      obs_arguments  = (stringlist_get_size(args) > delimiter + 1) ? true : false;
    } else if (stringlist_get_size(args) > 1) {
        step_arguments = true;
        delimiter     = stringlist_get_size(args);
    }
  }

  int_vector_type * steps_vector = NULL;
  {
    char * report_steps = NULL;

    if (step_arguments)
      report_steps = stringlist_alloc_joined_substring(args, 1, delimiter, ",");
    else
      report_steps = util_alloc_sprintf("0-%d", enkf_main_get_history_length(enkf_main));

    steps_vector = string_util_alloc_value_list(report_steps);

    free(report_steps);
  }


  stringlist_type * obs_ranking_keys = NULL;
  {
    char * obs_key_char = NULL;
    if (obs_arguments)
      obs_key_char = stringlist_alloc_joined_substring( args , delimiter+1 , stringlist_get_size(args) , " ");

    enkf_obs_type * enkf_obs = enkf_main_get_obs(enkf_main);
    obs_ranking_keys = enkf_obs_alloc_matching_keylist( enkf_obs , obs_key_char );

    if ((obs_arguments) && (stringlist_get_size(obs_ranking_keys) == 0)) {
      fprintf(stderr,"The input string : \"%s\" did not resolve to any valid observation keys. Job not started\n", obs_key_char);
      return NULL;
    }

    if (obs_arguments)
      free(obs_key_char);
  }


  enkf_main_rank_on_observations(enkf_main, ranking_name, obs_ranking_keys, steps_vector);

  stringlist_free(obs_ranking_keys);
  int_vector_free(steps_vector);
  return NULL;
}
Example #24
0
static void * lsb_dlsym( lsb_type * lsb , const char * function_name ) {
    void * function = dlsym( lsb->lib_handle , function_name );
    if (!function) {
        lsb->ready = false;
        stringlist_append_owned_ref( lsb->error_list , util_alloc_sprintf( "Failed to locate symbol:%s  dlerror:%s" , function_name , dlerror()));
    }

    return function;
}
Example #25
0
static char * smspec_alloc_wgname_key( const char * join_string , const char * keyword , const char * wgname) {
  if (wgname != NULL)
    return util_alloc_sprintf(ECL_SUM_KEYFMT_WELL,
                              keyword ,
                              join_string ,
                              wgname );
  else
    return NULL;
}
Example #26
0
void ecl_config_add_config_items(config_type * config)
{
  config_schema_item_type * item;

  item = config_add_schema_item(config, SCHEDULE_FILE_KEY, false);
  config_schema_item_set_argc_minmax(item, 1, 2);
  config_schema_item_iset_type(item, 0, CONFIG_EXISTING_PATH);
  /*
   Observe that SCHEDULE_PREDICTION_FILE - which is implemented as a
   GEN_KW is added in ensemble_config.c
   */

  item = config_add_schema_item(config, IGNORE_SCHEDULE_KEY, false);
  config_schema_item_set_argc_minmax(item, 1, 1);
  config_schema_item_iset_type(item, 0, CONFIG_BOOL);

  item = config_add_schema_item(config, ECLBASE_KEY, false);
  config_schema_item_set_argc_minmax(item, 1, 1);

  item = config_add_schema_item(config, DATA_FILE_KEY, false);
  config_schema_item_set_argc_minmax(item, 1, 1);
  config_schema_item_iset_type(item, 0, CONFIG_EXISTING_PATH);

  item = config_add_schema_item(config, STATIC_KW_KEY, false);
  config_schema_item_set_argc_minmax(item, 1, CONFIG_DEFAULT_ARG_MAX);

  item = config_add_schema_item(config, ADD_FIXED_LENGTH_SCHEDULE_KW_KEY, false);
  config_schema_item_set_argc_minmax(item, 2, 2);
  config_schema_item_iset_type(item, 1, CONFIG_INT);

  item = config_add_schema_item(config, REFCASE_KEY, false);
  config_schema_item_set_argc_minmax(item, 1, 1);
  config_schema_item_iset_type(item, 0, CONFIG_PATH);

  item = config_add_schema_item(config, REFCASE_LIST_KEY, false);
  config_schema_item_set_default_type(item, CONFIG_PATH);

  item = config_add_key_value(config, PLOT_REFCASE_LIST_KEY, false, CONFIG_STRING);
  {
    char * message = util_alloc_sprintf("Warning: the key:%s is depreceated - use %s instead", PLOT_REFCASE_LIST_KEY,
        REFCASE_LIST_KEY);
    config_install_message(config, PLOT_REFCASE_LIST_KEY, message);
    free(message);
  }

  item = config_add_schema_item(config, GRID_KEY, false);
  config_schema_item_set_argc_minmax(item, 1, 1);
  config_schema_item_iset_type(item, 0, CONFIG_EXISTING_PATH);

  item = config_add_schema_item(config, INIT_SECTION_KEY, false);
  config_schema_item_set_argc_minmax(item, 1, 1);
  config_schema_item_iset_type(item, 0, CONFIG_PATH);
  config_add_alias(config, INIT_SECTION_KEY, "EQUIL_INIT_FILE");

  item = config_add_schema_item(config, END_DATE_KEY, false);
  config_schema_item_set_argc_minmax(item, 1, 1);
}
Example #27
0
File: ecl_sum.c Project: flikka/ert
void ecl_sum_export_csv(const ecl_sum_type * ecl_sum , const char * filename  , const stringlist_type * var_list , const char * date_format , const char * sep) {
  FILE * stream = util_mkdir_fopen(filename , "w");
  char * date_header = util_alloc_sprintf("DAYS%sDATE" , sep);
  bool report_only = false;
  ecl_sum_fmt_type fmt;
  ecl_sum_fmt_init_csv( &fmt , date_format , date_header , sep );
  ecl_sum_fprintf( ecl_sum , stream , var_list , report_only , &fmt );
  fclose( stream );
  free( date_header );
}
Example #28
0
const char * member_config_update_jobname(member_config_type * member_config , const char * jobname_fmt , const subst_list_type * subst_list) {
  if (jobname_fmt != NULL) {
    util_safe_free( member_config->jobname );
    {
      char * tmp = util_alloc_sprintf( jobname_fmt , member_config->iens);
      member_config->jobname = subst_list_alloc_filtered_string( subst_list , tmp );
      free( tmp );
    }
  }
  return member_config->jobname;
}
Example #29
0
char * smspec_alloc_local_well_key( const char * join_string , const char * keyword , const char * lgr_name , const char * wgname) {
  if (wgname != NULL)
    return util_alloc_sprintf( ECL_SUM_KEYFMT_LOCAL_WELL ,
                               keyword ,
                               join_string ,
                               lgr_name ,
                               join_string ,
                               wgname);
  else
    return NULL;
}
Example #30
0
char * smspec_alloc_segment_key( const char * join_string , const char * keyword , const char * wgname , int num) {
  if (wgname != NULL)
    return util_alloc_sprintf(ECL_SUM_KEYFMT_SEGMENT ,
                              keyword ,
                              join_string ,
                              wgname ,
                              join_string ,
                              num );
  else
    return NULL;
}