Exemple #1
0
/**
   This site_config object is not really ready for prime time.
 */
site_config_type * site_config_alloc_empty() {
  site_config_type * site_config = util_malloc(sizeof * site_config);

  site_config->joblist = ext_joblist_alloc();
  site_config->queue_drivers = hash_alloc();

  site_config->lsf_queue_name_site = NULL;
  site_config->lsf_request_site = NULL;
  site_config->rsh_command_site = NULL;
  site_config->license_root_path = NULL;
  site_config->license_root_path_site = NULL;
  site_config->__license_root_path = NULL;
  site_config->job_script = NULL;
  site_config->job_script_site = NULL;
  site_config->manual_url = NULL;
  site_config->default_browser = NULL;
  site_config->user_mode = false;
  site_config->driver_type = NULL_DRIVER;

  site_config->job_queue = job_queue_alloc(DEFAULT_MAX_SUBMIT, "OK", "ERROR");
  site_config->env_variables_user = hash_alloc();
  site_config->env_variables_site = hash_alloc();

  site_config->path_variables_user = stringlist_alloc_new();
  site_config->path_values_user = stringlist_alloc_new();
  site_config->path_variables_site = hash_alloc();

  /* Some hooops to get the current umask. */
  site_config->umask = umask(0);
  site_config_set_umask(site_config, site_config->umask);
  site_config_set_manual_url(site_config, DEFAULT_MANUAL_URL);
  site_config_set_default_browser(site_config, DEFAULT_BROWSER);
  site_config_set_max_submit(site_config, DEFAULT_MAX_SUBMIT);
  return site_config;
}
Exemple #2
0
void stringlist_insert_stringlist_copy(stringlist_type * stringlist, const stringlist_type * src, int pos) {
  int size_old  = stringlist_get_size(stringlist);

  /** Cannot use assert_index here. */
  if(pos < 0 || pos > size_old)
    util_abort("%s: Position %d is out of bounds. Min: 0 Max: %d\n", pos, size_old);
  {
  stringlist_type * start = stringlist_alloc_new();
  stringlist_type * end   = stringlist_alloc_new();
  stringlist_type * newList   = stringlist_alloc_new();
  int i;

  for( i=0; i<pos; i++)
    stringlist_append_ref(start, stringlist_iget(stringlist, i));

  for( i=pos; i<size_old; i++)
    stringlist_append_ref(end  , stringlist_iget(stringlist, i));

  stringlist_append_stringlist_copy(newList, start);
  stringlist_append_stringlist_copy(newList, src  );
  stringlist_append_stringlist_copy(newList, end  );

  stringlist_clear(stringlist);
  stringlist_append_stringlist_copy(stringlist, newList);

  stringlist_free(newList);
  stringlist_free(start);
  stringlist_free(end);
  }
}
Exemple #3
0
SummaryComparator::SummaryComparator(const std::string& basename1,
                                     const std::string& basename2,
                                     double absoluteTol, double relativeTol){
    ecl_sum1 = ecl_sum_fread_alloc_case(basename1.c_str(), ":");
    ecl_sum2 = ecl_sum_fread_alloc_case(basename2.c_str(), ":");
    if (ecl_sum1 == nullptr || ecl_sum2 == nullptr) {
        OPM_THROW(std::runtime_error, "Not able to open files");
    }
    absoluteTolerance = absoluteTol;
    relativeTolerance = relativeTol;
    keys1 = stringlist_alloc_new();
    keys2 = stringlist_alloc_new();
    ecl_sum_select_matching_general_var_list( ecl_sum1 , "*" , this->keys1);
    stringlist_sort(this->keys1 , nullptr );
    ecl_sum_select_matching_general_var_list( ecl_sum2 , "*" , this->keys2);
    stringlist_sort(this->keys2 , nullptr );

    if(stringlist_get_size(keys1) <= stringlist_get_size(keys2)){
        this->keysShort = this->keys1;
        this->keysLong = this->keys2;
    }else{
        this->keysShort = this->keys2;
        this->keysLong = this->keys1;
    }
}
void test_join() {
  const char * elt0 = "AAA";
  const char * elt1 = "BBB";
  const char * elt2 = "CCC";
  const char * elt3 = "DDD";
  const char * elt4 = "EEE";
  const char * elt5 = "FFF";

  stringlist_type * s = stringlist_alloc_new();

  {
    // empty join
    const char* empty_join = stringlist_alloc_joined_string(s, "!!!");
    test_assert_not_NULL(empty_join);
    test_assert_string_equal("", empty_join);
  }

  stringlist_append_copy( s , elt0 );
  stringlist_append_copy( s , elt1 );
  stringlist_append_copy( s , elt2 );

  const char * sep0 = "";
  const char * sep1 = "!!!";
  const char * sep2 = " abc ";

  const char * j0 = stringlist_alloc_joined_string( s, sep0);
  const char * j1 = stringlist_alloc_joined_string( s, sep1);
  const char * j2 = stringlist_alloc_joined_string( s, sep2);

  test_assert_string_equal( j0, "AAABBBCCC");
  test_assert_string_equal( j1, "AAA!!!BBB!!!CCC");
  test_assert_string_equal( j2, "AAA abc BBB abc CCC");

  stringlist_type * s1 = stringlist_alloc_new();
  stringlist_append_copy( s1 , elt0 );
  test_assert_string_equal( "AAA", stringlist_alloc_joined_string( s1, sep0));
  test_assert_string_equal( "AAA", stringlist_alloc_joined_string( s1, sep1));
  test_assert_string_equal( "AAA", stringlist_alloc_joined_string( s1, sep2));

  stringlist_type * sub = stringlist_alloc_new();
  stringlist_append_copy( sub , elt0 );
  stringlist_append_copy( sub , elt1 );
  stringlist_append_copy( sub , elt2 );
  stringlist_append_copy( sub , elt3 );
  stringlist_append_copy( sub , elt4 );
  stringlist_append_copy( sub , elt5 );
  test_assert_string_equal( "CCC:DDD:EEE", stringlist_alloc_joined_substring( sub, 2, 5, ":"));
}
Exemple #5
0
stringlist_type * enkf_main_alloc_caselist( const enkf_main_type * enkf_main ) {
    stringlist_type * case_list = stringlist_alloc_new( );
    {
        const char * ens_path = model_config_get_enspath( enkf_main->model_config );
        DIR * ens_dir = opendir( ens_path );
        if (ens_dir != NULL) {
            int ens_fd = dirfd( ens_dir );
            if (ens_fd != -1) {
                struct dirent * dp;
                do {
                    dp = readdir( ens_dir );
                    if (dp != NULL) {
                        if (!(util_string_equal( dp->d_name , ".") || util_string_equal(dp->d_name , ".."))) {
                            if (!util_string_equal( dp->d_name , CURRENT_CASE_FILE)) {
                                char * full_path = util_alloc_filename( ens_path , dp->d_name , NULL);
                                if (util_is_directory( full_path ))
                                    stringlist_append_copy( case_list , dp->d_name );
                                free( full_path);
                            }
                        }
                    }
                } while (dp != NULL);
            }
        }
        closedir( ens_dir );
    }
    return case_list;
}
static enkf_config_node_type * enkf_config_node_alloc__( enkf_var_type   var_type, 
                                                         ert_impl_type  impl_type, 
                                                         const char * key,
                                                         bool forward_init) {

  enkf_config_node_type * node = util_malloc( sizeof *node );
  UTIL_TYPE_ID_INIT( node , ENKF_CONFIG_NODE_TYPE_ID );
  node->forward_init    = forward_init;
  node->var_type        = var_type;
  node->impl_type       = impl_type;
  node->key             = util_alloc_string_copy( key );
  node->container_nodes = vector_alloc_new();
  node->vector_storage  = false;

  node->init_file_fmt    = NULL; 
  node->enkf_infile_fmt  = NULL;
  node->enkf_outfile_fmt = NULL;
  node->internalize      = NULL;
  node->data             = NULL;
  node->obs_keys         = stringlist_alloc_new(); 
  node->min_std          = NULL;
  node->min_std_file     = NULL;
  
  node->get_data_size = NULL;
  node->freef         = NULL; 
  {  
    switch(impl_type) {
    case(FIELD):
      node->freef             = field_config_free__;
      node->get_data_size     = field_config_get_data_size__;  
      break;
    case(STATIC):
      break;
    case(GEN_KW):
      node->freef             = gen_kw_config_free__;
      node->get_data_size     = gen_kw_config_get_data_size__;
      break;
    case(SUMMARY):
      node->vector_storage    = true;
      node->freef             = summary_config_free__;
      node->get_data_size     = summary_config_get_data_size__;
      break;
    case(GEN_DATA):
      node->freef             = gen_data_config_free__;
      node->get_data_size     = NULL;
      break;
    case(SURFACE):
      node->freef             = surface_config_free__;
      node->get_data_size     = surface_config_get_data_size__;
      break;
    case(CONTAINER):
      node->freef             = container_config_free__;
      node->get_data_size     = container_config_get_data_size__;
      break;
    default:
      util_abort("%s : invalid implementation type: %d - aborting \n",__func__ , impl_type);
    }
  }
  return node;
}
Exemple #7
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
QStringList RifEclipseSummaryTools::findSummaryDataFiles(const QString& caseFile)
{
    QStringList fileNames;

    QString path;
    QString base;

    findSummaryHeaderFileInfo(caseFile, nullptr, &path, &base, nullptr);
    if (path.isEmpty() || base.isEmpty()) return fileNames;

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

    ecl_util_alloc_summary_files(RiaStringEncodingTools::toNativeEncoded(path).data(), RiaStringEncodingTools::toNativeEncoded(base).data(), nullptr, &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(RiaStringEncodingTools::fromNativeEncoded(stringlist_iget(summary_file_list, i)));
        }
    }

    util_safe_free(header_file);
    stringlist_free(summary_file_list);

    return fileNames;
}
Exemple #8
0
void ensemble_config_init_SUMMARY( ensemble_config_type * ensemble_config , const config_content_type * config , const ecl_sum_type * refcase) {
  if (config_content_has_item(config , SUMMARY_KEY)) {
    const config_content_item_type * item = config_content_get_item( config , SUMMARY_KEY );
    int i;
    for (i=0; i < config_content_item_get_size( item ); i++) {
      const config_content_node_type * node = config_content_item_iget_node( item , i );
      int j;
      for (j= 0; j < config_content_node_get_size( node ); j++) {
        const char * key = config_content_node_iget( node , j );
        summary_key_matcher_add_summary_key(ensemble_config->summary_key_matcher, key);

        if (util_string_has_wildcard( key )) {
            //todo: DEPRECATED. In the Future the matcher should take care of this.
          if (ensemble_config->refcase != NULL) {
            int k;
            stringlist_type * keys = stringlist_alloc_new ( );

            ecl_sum_select_matching_general_var_list( ensemble_config->refcase , key , keys );   /* expanding the wildcard notation with help of the refcase. */
            for (k=0; k < stringlist_get_size( keys ); k++)
              ensemble_config_add_summary(ensemble_config , stringlist_iget(keys , k) , LOAD_FAIL_SILENT );

            stringlist_free( keys );
          }
        } else
          ensemble_config_add_summary(ensemble_config , key , LOAD_FAIL_SILENT);
      }
    }
  }
}
Exemple #9
0
void test_run_workflow_job( const char * config_file , const char * job_file ) {
  ert_test_context_type * test_context = ert_test_context_alloc("CREATE_CONTEXT_JOB" , config_file , NULL );
  stringlist_type * args0 = stringlist_alloc_new( );
  stringlist_type * args1 = stringlist_alloc_new( );

  stringlist_append_ref( args1 , "NewCase");
  test_assert_false( ert_test_context_run_worklow_job( test_context , "NO-this-does-not-exist" , args1));
  ert_test_context_install_workflow_job( test_context , "JOB" , job_file );
  
  test_assert_false( ert_test_context_run_worklow_job( test_context , "JOB" , args0));
  test_assert_true( ert_test_context_run_worklow_job( test_context , "JOB" , args1));
  
  stringlist_free( args0 );
  stringlist_free( args1 );
  ert_test_context_free( test_context );
}
Exemple #10
0
void test_run_workflow(const char * config_file , const char * job_file) {
  ert_test_context_type * test_context = ert_test_context_alloc("INSTALL_WORKFLOW" , config_file , NULL );
  test_assert_false( ert_test_context_run_worklow( test_context , "No-does.not.exist"));
  
  ert_test_context_install_workflow_job( test_context , "JOB" , job_file );
  {
    FILE * stream1 = util_fopen( "WFLOW1", "w");
    FILE * stream2 = util_fopen( "WFLOW2", "w");
    stringlist_type * args = stringlist_alloc_new( );
    ert_test_context_fwrite_workflow_job( stream1 , "JOB" , args);
    stringlist_append_ref( args , "NewCase");
    ert_test_context_fwrite_workflow_job( stream2 , "JOB" , args);
        
    stringlist_free( args );
    fclose( stream1 );
    fclose( stream2 );
  }
  test_assert_true( ert_test_context_install_workflow( test_context , "WFLOW1" , "WFLOW1"));
  test_assert_true( ert_test_context_install_workflow( test_context , "WFLOW2" , "WFLOW2"));
  
  test_assert_true( ert_test_context_run_worklow( test_context , "WFLOW2"));
  test_assert_false( ert_test_context_run_worklow( test_context , "WFLOW1"));

  ert_test_context_free( test_context );
}
Exemple #11
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);

  }
}
Exemple #12
0
sched_file_type * sched_file_alloc(time_t start_time)
{
  sched_file_type * sched_file = util_malloc(sizeof * sched_file);
  UTIL_TYPE_ID_INIT( sched_file , SCHED_FILE_TYPE_ID);
  sched_file->kw_list            = vector_alloc_new();
  sched_file->kw_list_by_type    = NULL;
  sched_file->blocks             = vector_alloc_new();
  sched_file->files              = stringlist_alloc_new();
  sched_file->start_time         = start_time;
  sched_file->fixed_length_table = hash_alloc();
  sched_file->hasEND             = false;
  sched_file_init_fixed_length( sched_file );
  {
    char * fixed_length_file = getenv("SCHEDULE_FIXED_LENGTH");
    if ((fixed_length_file != NULL) && (util_entry_readable( fixed_length_file ))) {
      FILE * stream = util_fopen(fixed_length_file , "r");
      char kw[32];
      int  len;
      bool OK = true;

      do {
        if (fscanf(stream , "%s %d" , kw , &len) == 2)
          sched_file_add_fixed_length_kw( sched_file , kw , len);
        else
          OK = false;
      } while (OK);
      fclose( stream);
    }
  }
  return sched_file;
}
int test_load_manually_to_new_case(enkf_main_type * enkf_main) {
  int result = 0;
  int iens = 0;
  int iter = 0;
  const char * casename = "new_case";
  enkf_main_select_fs( enkf_main , casename );
  
  
  enkf_fs_type * fs = enkf_main_get_fs( enkf_main );
  run_arg_type * run_arg = run_arg_alloc_ENSEMBLE_EXPERIMENT(fs , iens , iter , "simulations/run0");
  {
    arg_pack_type * arg_pack = arg_pack_alloc();
    arg_pack_append_ptr( arg_pack , enkf_main_iget_state(enkf_main, 0));                
    arg_pack_append_ptr( arg_pack , run_arg );
    arg_pack_append_bool( arg_pack , true );                                            
    arg_pack_append_owned_ptr( arg_pack , stringlist_alloc_new() , stringlist_free__);  
    arg_pack_append_bool( arg_pack, true );                                             
    arg_pack_append_ptr( arg_pack, &result );                                           
    
    enkf_state_load_from_forward_model_mt(arg_pack);
    arg_pack_free(arg_pack);
  }
  
  return result;
}
Exemple #14
0
ecl_config_type * ecl_config_alloc_empty( ) {
  ecl_config_type * ecl_config         = util_malloc(sizeof * ecl_config );

  ecl_config->io_config                = ecl_io_config_alloc( DEFAULT_FORMATTED , DEFAULT_UNIFIED , DEFAULT_UNIFIED );
  ecl_config->fixed_length_kw          = hash_alloc();
  ecl_config->eclbase                  = NULL;
  ecl_config->include_all_static_kw    = false;
  ecl_config->static_kw_set            = set_alloc_empty();
  ecl_config->user_static_kw           = stringlist_alloc_new();
  ecl_config->num_cpu                  = 1;                     /* This must get a valid default in case no ECLIPSE datafile is provided. */
  ecl_config->data_file                = NULL;
  ecl_config->input_init_section       = NULL; 
  ecl_config->init_section             = NULL;
  ecl_config->grid                     = NULL;
  ecl_config->can_restart              = false;
  ecl_config->start_date               = -1;
  ecl_config->end_date                 = -1;
  ecl_config->sched_file               = NULL;
  ecl_config->schedule_prediction_file = NULL;
  ecl_config->schedule_target_file     = NULL;
  ecl_config->refcase_list             = ecl_refcase_list_alloc();
  
  ecl_config_init_static_kw( ecl_config );

  return ecl_config;
}
Exemple #15
0
static void output_add_key( const ecl_sum_type * refcase , output_type * output , const char * qkey) {
  int tokens;
  double  quantile;
  char ** tmp;
  char  * sum_key;

  util_split_string( qkey , SUMMARY_JOIN , &tokens , &tmp);
  if (tokens == 1)
    util_exit("Hmmm - the key:%s is malformed - must be of the form SUMMARY_KEY:QUANTILE.\n",qkey);

  if (!util_sscanf_double( tmp[tokens - 1] , &quantile))
    util_exit("Hmmmm - failed to interpret:%s as a quantile - must be a number (0,1).\n",tmp[tokens-1]);

  if (quantile <= 0 || quantile >= 1.0)
    util_exit("Invalid quantile value:%g - must be in interval (0,1)\n", quantile);

  sum_key = util_alloc_joined_string( (const char **) tmp , tokens - 1 , SUMMARY_JOIN);
  {
    stringlist_type * matching_keys = stringlist_alloc_new();
    int i;
    ecl_sum_select_matching_general_var_list( refcase , sum_key , matching_keys );
    for (i=0; i < stringlist_get_size( matching_keys ); i++)
      vector_append_owned_ref( output->keys , quant_key_alloc( stringlist_iget( matching_keys , i ) , quantile) , quant_key_free__ );

    if (stringlist_get_size( matching_keys ) == 0)
      fprintf(stderr,"** Warning: No summary vectors matching:\'%s\' found?? \n", sum_key);
    stringlist_free( matching_keys );
  }

  util_free_stringlist( tmp, tokens );
}
Exemple #16
0
void ensemble_config_init_SUMMARY( ensemble_config_type * ensemble_config , const config_type * config , const ecl_sum_type * refcase) {
  const config_content_item_type * item = config_get_content_item( config , SUMMARY_KEY );

  if (item != NULL) {
    int i;
    for (i=0; i < config_content_item_get_size( item ); i++) {
      const config_content_node_type * node = config_content_item_iget_node( item , i );
      int j;
      for (j= 0; j < config_content_node_get_size( node ); j++) {
        const char * key = config_content_node_iget( node , j );
        
        if (util_string_has_wildcard( key )) {
          if (ensemble_config->refcase != NULL) {
            int k;
            stringlist_type * keys = stringlist_alloc_new ( );

            ecl_sum_select_matching_general_var_list( ensemble_config->refcase , key , keys );   /* expanding the wildcard notatition with help of the refcase. */
            for (k=0; k < stringlist_get_size( keys ); k++) 
              ensemble_config_add_summary(ensemble_config , stringlist_iget(keys , k) , LOAD_FAIL_SILENT );

            stringlist_free( keys );
          } else
            util_exit("error: when using summary wildcards like: \"%s\" you must supply a valid refcase.\n",key);
        } else 
          ensemble_config_add_summary(ensemble_config , key , LOAD_FAIL_SILENT);
      }
    }
  }
}
Exemple #17
0
int main(int argc , char ** argv) {
  const char * data_file = argv[1];
  
  ecl_sum_type * ecl_sum = ecl_sum_fread_alloc_case( data_file , ":");
  if (ecl_sum != NULL) {
    stringlist_type * keys = stringlist_alloc_new();

    if (argc == 2)
      ecl_sum_select_matching_general_var_list( ecl_sum , "*" , keys);
    else {
      for (int iarg = 2; iarg < argc; iarg++) {
        printf("Matchging:%s \n",argv[iarg]);
        ecl_sum_select_matching_general_var_list( ecl_sum , argv[iarg] , keys);
      }
    }
    
    stringlist_sort( keys , NULL );
    {
      int i;
      for (i=0; i < stringlist_get_size( keys );  i++)
        printf("%s \n",stringlist_iget( keys , i ));
    }
    
    stringlist_free( keys );
    ecl_sum_free(ecl_sum);
  } else 
    fprintf(stderr,"key_list.x: No summary data found for case:%s\n", data_file );
}
Exemple #18
0
well_info_type * well_info_alloc( const ecl_grid_type * grid) {
  well_info_type * well_info = util_malloc( sizeof * well_info );
  well_info->wells      = hash_alloc();
  well_info->well_names = stringlist_alloc_new();
  well_info->grid       = grid;
  return well_info;
}
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
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;
}
void test_load_results_job(ert_test_context_type * test_context , const char * job_name , const char * job_file) {
  stringlist_type * args = stringlist_alloc_new();
  ert_test_context_install_workflow_job( test_context , job_name , job_file );
  stringlist_append_copy( args , "0");
  stringlist_append_copy( args , ",");
  stringlist_append_copy( args , "1");
  test_assert_true( ert_test_context_run_worklow_job( test_context , job_name , args) );
  stringlist_free( args );
}
void test_matching() {
  stringlist_type * s1 = stringlist_alloc_new();
  stringlist_type * s2 = stringlist_alloc_new();

  stringlist_append_copy(s1 , "AAA");
  stringlist_append_copy(s1 , "ABC" );
  stringlist_append_copy(s1 , "123");
  stringlist_append_copy(s1 , "ABC:123");

  stringlist_select_matching_elements( s2 , s1 , "*");
  test_assert_int_equal( 4 , stringlist_get_size( s2 ));
  test_assert_string_equal( "AAA" , stringlist_iget( s2 , 0 ));
  test_assert_string_equal( "ABC" , stringlist_iget( s2 , 1 ));
  test_assert_string_equal( "123" , stringlist_iget( s2 , 2 ));
  test_assert_string_equal( "ABC:123" , stringlist_iget( s2 , 3 ));

  stringlist_select_matching_elements( s2 , s1 , "*");
  test_assert_int_equal( 4 , stringlist_get_size( s2 ));
  test_assert_string_equal( "AAA" , stringlist_iget( s2 , 0 ));
  test_assert_string_equal( "ABC" , stringlist_iget( s2 , 1 ));
  test_assert_string_equal( "123" , stringlist_iget( s2 , 2 ));
  test_assert_string_equal( "ABC:123" , stringlist_iget( s2 , 3 ));


  stringlist_append_matching_elements( s2 , s1 , "*");
  test_assert_int_equal( 8 , stringlist_get_size( s2 ));
  test_assert_string_equal( "AAA" , stringlist_iget( s2 , 0 ));
  test_assert_string_equal( "ABC" , stringlist_iget( s2 , 1 ));
  test_assert_string_equal( "123" , stringlist_iget( s2 , 2 ));
  test_assert_string_equal( "ABC:123" , stringlist_iget( s2 , 3 ));

  test_assert_string_equal( "AAA" , stringlist_iget( s2 , 4 ));
  test_assert_string_equal( "ABC" , stringlist_iget( s2 , 5 ));
  test_assert_string_equal( "123" , stringlist_iget( s2 , 6 ));
  test_assert_string_equal( "ABC:123" , stringlist_iget( s2 , 7 ));

  stringlist_select_matching_elements( s2 , s1 , "*B*");
  test_assert_int_equal( 2 , stringlist_get_size( s2 ));
  test_assert_string_equal( "ABC" , stringlist_iget( s2 , 0 ));
  test_assert_string_equal( "ABC:123" , stringlist_iget( s2 , 1 ));

  stringlist_free( s2 );
  stringlist_free( s1 );
}
Exemple #22
0
static file_map_type * file_map_alloc( fortio_type * fortio , inv_map_type * inv_map , bool owner ) {
  file_map_type * file_map     = util_malloc( sizeof * file_map );
  file_map->kw_list            = vector_alloc_new();
  file_map->kw_index           = hash_alloc();
  file_map->distinct_kw        = stringlist_alloc_new();
  file_map->owner              = owner;
  file_map->fortio             = fortio;
  file_map->inv_map            = inv_map;
  return file_map;
}
Exemple #23
0
block_job_type * block_job_alloc() {
  block_job_type * job = util_malloc( sizeof * job );

  job->lsf_job   = NULL;
  job->running   = false;
  job->block_job = false;
  job->hostlist  = stringlist_alloc_new();

  return job;
}
void test_update_default(const char * config_file , const char * job_file) {
  ert_test_context_type * test_context = ert_test_context_alloc("AnalysisJob0" , config_file);

  stringlist_type * args = stringlist_alloc_new();
  test_assert_true( ert_test_context_install_workflow_job( test_context , "JOB" , job_file ));
  test_assert_true( ert_test_context_run_worklow_job( test_context , "JOB" , args) );
  stringlist_free( args );

  ert_test_context_free( test_context );
}
Exemple #25
0
stringlist_type * hash_alloc_stringlist(hash_type * hash) {
  stringlist_type * stringlist = stringlist_alloc_new();
  char ** keylist = hash_alloc_keylist__(hash , true);
  int i;
  for (i = 0; i < hash_get_size( hash ); i++)
    stringlist_append_owned_ref( stringlist , keylist[i] );

  free( keylist );
  return stringlist;
}
Exemple #26
0
void enkf_tui_init(enkf_main_type * enkf_main, bool all_members , bool all_parameters , bool interval ) {
  const int prompt_len                         = 35;
  const ensemble_config_type * ensemble_config = enkf_main_get_ensemble_config(enkf_main);
  int   ens_size                               = enkf_main_get_ensemble_size( enkf_main );
  int iens1, iens2;
  init_mode_enum init_mode = INIT_FORCE;
  bool iens_valid = false;
  
  /* iens2 should be interpreted as __inclusive__ */
  if ( all_members ) {
    iens1 = 0;
    iens2 = ens_size - 1;
    iens_valid = true;
  } else {
    if( interval ) {
      char * iens1char = util_scanf_int_with_limits_return_char("First ensemble member in interval"  , prompt_len , 0 , ens_size - 1);
      if (strlen(iens1char)) {
        util_sscanf_int(iens1char , &iens1);
        char * iens2char = util_scanf_int_with_limits_return_char("Second ensemble member in interval" , prompt_len , iens1 , ens_size - 1);
        if (strlen(iens2char)) {
          util_sscanf_int(iens2char , &iens2);
          iens_valid = true;
        }
        free(iens2char);
      }
      free(iens1char);
    } else {
      char * iens1char = util_scanf_int_with_limits_return_char("Initialize ensemble member" , prompt_len , 0 , ens_size - 1);
      if (strlen(iens1char)) {
        util_sscanf_int(iens1char , &iens1);
        iens2 = iens1;
        iens_valid = true;
      }
      free(iens1char);
    }
  }
  
  if (iens_valid) {
    stringlist_type * param_list = NULL;
    if (all_parameters) 
      param_list = ensemble_config_alloc_keylist_from_var_type( ensemble_config , PARAMETER );
    else {
      const enkf_config_node_type * config_node = NULL;
      param_list = stringlist_alloc_new();
      config_node = enkf_tui_util_scanf_key(ensemble_config , prompt_len , INVALID , INVALID_VAR);
      if( config_node != NULL )
        stringlist_append_copy( param_list , enkf_config_node_get_key(config_node));
    }

    if (param_list != NULL) {
      enkf_main_initialize_from_scratch(enkf_main , param_list , iens1 , iens2 , init_mode);
      stringlist_free( param_list );
    }
  }
}
Exemple #27
0
stringlist_type * gen_kw_config_alloc_name_list( const gen_kw_config_type * config ) {
  
  stringlist_type * name_list = stringlist_alloc_new();
  int i;
  for (i=0; i < vector_get_size( config->parameters ); i++) {
    const gen_kw_parameter_type * parameter = vector_iget_const( config->parameters , i );
    stringlist_append_ref( name_list , parameter->name );    /* If the underlying parameter goes out scope - whom bang .. */
  }

  return name_list;
}
void test_update_new_case(const char * config_file , const char * job_file) {
  ert_test_context_type * test_context = ert_test_context_alloc("AnalysisJob1" , config_file);

  stringlist_type * args = stringlist_alloc_new();
  stringlist_append_copy( args , "NewCase" );
  ert_test_context_install_workflow_job( test_context , "JOB" , job_file );
  test_assert_true( ert_test_context_run_worklow_job( test_context , "JOB" , args) );
  stringlist_free( args );
  
  ert_test_context_free( test_context );
}
Exemple #29
0
stringlist_type * config_content_item_alloc_stringlist(const config_content_item_type * item, bool copy) {
  const config_content_node_type * node = config_content_item_get_last_node( item );
  stringlist_type * stringlist = stringlist_alloc_new();
  const stringlist_type * src_list = config_content_node_get_stringlist( node );
  
  if (copy)
    stringlist_append_stringlist_copy( stringlist , src_list );
  else
    stringlist_append_stringlist_ref( stringlist , src_list );  
  
  return stringlist;
}
Exemple #30
0
stringlist_type * ensemble_config_alloc_keylist_from_impl_type(const ensemble_config_type * config , ert_impl_type impl_type) {
  stringlist_type * key_list = stringlist_alloc_new();
  hash_iter_type * iter = hash_iter_alloc(config->config_nodes);
  while (!hash_iter_is_complete( iter )) {
    const char * key = hash_iter_get_next_key(iter);
    if (enkf_config_node_get_impl_type( hash_get(config->config_nodes , key)) == impl_type)
      stringlist_append_copy( key_list , key );

  }
  hash_iter_free(iter);
  return key_list;
}