Пример #1
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;
}
Пример #2
0
void test_reverse() {
  const char * val1 = "value1";
  const char * val2 = "value2";
  const char * val3 = "value3";
  const char * val4 = "value4";
  
  vector_type * vector1 = vector_alloc_new(  );
  vector_type * vector2 = vector_alloc_new(  );

  vector_append_ref( vector1 , val1 );
  vector_append_ref( vector1 , val2 );
  vector_append_ref( vector1 , val3 );
  vector_append_ref( vector1 , val4 );

  vector_append_ref( vector2 , val1 );
  vector_append_ref( vector2 , val2 );
  vector_append_ref( vector2 , val3 );
  vector_append_ref( vector2 , val4 );

  vector_inplace_reverse( vector1 );

  {
    int i;
    int size = vector_get_size( vector1 );
    for (i=0; i < vector_get_size( vector1 ); i++)
      test_assert_ptr_equal( vector_iget_const( vector2 , i ) , vector_iget_const( vector1 , size - 1 - i ));
  }
  vector_free( vector1 );
  vector_free( vector2 );
}
Пример #3
0
ecl_file_type * ecl_file_alloc_empty( int flags ) {
  ecl_file_type * ecl_file = util_malloc( sizeof * ecl_file );
  UTIL_TYPE_ID_INIT(ecl_file , ECL_FILE_ID);
  ecl_file->map_list  = vector_alloc_new();
  ecl_file->map_stack = vector_alloc_new();
  ecl_file->inv_map   = inv_map_alloc( );
  ecl_file->flags     = flags;
  return ecl_file;
}
Пример #4
0
ecl_file_type * ecl_file_alloc_empty( bool read_only ) {
  ecl_file_type * ecl_file = util_malloc( sizeof * ecl_file );
  UTIL_TYPE_ID_INIT(ecl_file , ECL_FILE_ID);
  ecl_file->map_list  = vector_alloc_new();
  ecl_file->map_stack = vector_alloc_new();
  ecl_file->read_only = read_only;
  ecl_file->inv_map   = inv_map_alloc( );
  return ecl_file;
}
Пример #5
0
workflow_type * workflow_alloc( const char * src_file , workflow_joblist_type * joblist) {
  workflow_type * script = util_malloc( sizeof * script );
  UTIL_TYPE_ID_INIT( script , WORKFLOW_TYPE_ID );

  script->src_file        = util_alloc_string_copy( src_file );
  script->joblist         = joblist;
  script->cmd_list        = vector_alloc_new();
  script->compiled        = false;
  script->last_error      = NULL;
  script->stack           = vector_alloc_new();

  workflow_try_compile( script , NULL );
  return script;
}
vector_type * load_expected( const ecl_grid_type * grid, const char * filename ) {
  FILE * stream = util_fopen( filename , "r");
  vector_type * expected = vector_alloc_new();

  while (true) {
    double x,y,z;
    int i,j,k,skip;

    if (fscanf( stream , "%lg %lg %lg %d %d %d %d" , &x,&y,&z,&i,&j,&k,&skip) == 7) {
      point_type * p = util_malloc( sizeof * p );
      p->x = x;
      p->y = y;
      p->z = z;

      p->i = i-1;
      p->j = j-1;
      p->k = k-1;
      p->skip = skip;
      p->g = ecl_grid_get_global_index3(grid,    p->i, p->j, p->k);
      vector_append_owned_ref( expected, p , free );
    } else
      break;
  }

  fclose( stream );
  test_assert_int_equal( 10 , vector_get_size( expected ));
  return expected;
}
Пример #7
0
static sched_block_type * sched_block_alloc_empty()
{
  sched_block_type * block = util_malloc(sizeof * block);
  block->kw_list = vector_alloc_new();
  block->kw_hash = hash_alloc();
  return block;
}
Пример #8
0
nnc_info_type * nnc_info_alloc() {
  nnc_info_type * nnc_info = util_malloc( sizeof * nnc_info );
  UTIL_TYPE_ID_INIT(nnc_info , NNC_INFO_TYPE_ID);
  nnc_info->lgr_list = vector_alloc_new(); 
  nnc_info->lgr_index_map = int_vector_alloc(0, -1); 
  return nnc_info; 
}
Пример #9
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);
}
Пример #10
0
container_type * container_alloc( container_config_type * config ) {
  container_type * container = util_malloc( sizeof * container );
  UTIL_TYPE_ID_INIT( container , CONTAINER );
  container->config = config;
  container->nodes  = vector_alloc_new();
  return container;
}
Пример #11
0
well_segment_collection_type * well_segment_collection_alloc() {
  well_segment_collection_type * segment_collection = util_malloc( sizeof * segment_collection );

  segment_collection->__segment_storage = vector_alloc_new();
  segment_collection->segment_index_map = int_vector_alloc( 0 , -1 );
  return segment_collection;
}
Пример #12
0
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;
}
Пример #13
0
static ecl_rft_node_type * ecl_rft_node_alloc_empty(const char * data_type_string) {
  ecl_rft_enum data_type = SEGMENT;
  
  /* According to the ECLIPSE documentaton. */
  if (strchr(data_type_string , 'P') != NULL)
    data_type = PLT;
  else if (strchr(data_type_string, 'R') != NULL)
    data_type = RFT;
  else if (strchr(data_type_string , 'S') != NULL)
    data_type = SEGMENT;                    
  else 
    util_abort("%s: Could not determine type of RFT/PLT/SEGMENT data - aborting\n",__func__);
  

  /* Can return NULL */
  if (data_type == SEGMENT) {
    fprintf(stderr,"%s: sorry SEGMENT PLT/RFT is not supported - file a complaint. \n",__func__);
    return NULL;
  }

  {
    ecl_rft_node_type * rft_node = util_malloc(sizeof * rft_node );
    UTIL_TYPE_ID_INIT( rft_node , ECL_RFT_NODE_ID );
    
    rft_node->cells = vector_alloc_new();
    rft_node->data_type = data_type;
    rft_node->sort_perm = NULL;
    rft_node->sort_perm_in_sync = false;
    
    return rft_node;
  }
}
Пример #14
0
static well_ts_type * well_ts_alloc_empty( ) {
  well_ts_type * well_ts = util_malloc( sizeof * well_ts );
  UTIL_TYPE_ID_INIT( well_ts , WELL_TS_TYPE_ID );

  well_ts->ts         = vector_alloc_new();
  return well_ts;
}
Пример #15
0
runpath_list_type * runpath_list_alloc(const char * export_file) {
  runpath_list_type * list = util_malloc( sizeof * list );
  list->list     = vector_alloc_new();
  list->line_fmt = NULL;
  list->export_file = util_alloc_string_copy( export_file );
  pthread_rwlock_init( &list->lock , NULL );
  return list;
}
Пример #16
0
static misfit_ensemble_type * misfit_ensemble_alloc_empty() {
  misfit_ensemble_type * table    = util_malloc( sizeof * table );

  table->initialized     = false;
  table->ensemble        = vector_alloc_new();
  
  return table;
}
Пример #17
0
static ecl_rft_file_type * ecl_rft_file_alloc_empty(const char * filename) {
  ecl_rft_file_type * rft_vector = util_malloc(sizeof * rft_vector );
  UTIL_TYPE_ID_INIT( rft_vector , ECL_RFT_FILE_ID );
  rft_vector->data       = vector_alloc_new();
  rft_vector->filename   = util_alloc_string_copy(filename);
  rft_vector->well_index = hash_alloc();
  return rft_vector;
}
Пример #18
0
local_obsdata_type * local_obsdata_alloc( const char * name) {
  local_obsdata_type * data = util_malloc( sizeof * data );
  UTIL_TYPE_ID_INIT( data , LOCAL_OBSDATA_TYPE_ID );
  data->nodes_list = vector_alloc_new();
  data->nodes_map = hash_alloc();
  data->name = util_alloc_string_copy( name );
  return data;
}
Пример #19
0
config_content_item_type * config_content_item_alloc( const config_schema_item_type * schema , const config_path_elm_type * path_elm) {
  config_content_item_type * content_item = util_malloc( sizeof * content_item );
  UTIL_TYPE_ID_INIT( content_item , CONFIG_CONTENT_ITEM_ID );
  content_item->schema = schema;
  content_item->nodes = vector_alloc_new();
  content_item->path_elm = path_elm;
  return content_item;
}
Пример #20
0
static misfit_ranking_type * misfit_ranking_alloc_empty( int ens_size ) {
  misfit_ranking_type * misfit_ranking = util_malloc( sizeof * misfit_ranking );
  UTIL_TYPE_ID_INIT( misfit_ranking , MISFIT_RANKING_TYPE_ID );
  misfit_ranking->sort_permutation = NULL;
  misfit_ranking->ensemble = vector_alloc_new();
  misfit_ranking->total    = double_vector_alloc( 0 , INVALID_RANKING_VALUE );
  misfit_ranking->ens_size = ens_size;
  return misfit_ranking;
}
Пример #21
0
config_content_type * config_content_alloc() {
  config_content_type * content = util_malloc( sizeof * content );
  UTIL_TYPE_ID_INIT( content , CONFIG_CONTENT_TYPE_ID );
  content->valid = false;
  content->items = hash_alloc();
  content->nodes = vector_alloc_new();
  content->parse_errors = config_error_alloc();
  content->define_list = subst_list_alloc( NULL );
  content->parsed_files = set_alloc_empty();

  content->path_elm_storage  = vector_alloc_new();
  content->path_elm_stack    = vector_alloc_new();

  content->invoke_path = NULL;
  content->config_file = NULL;
  content->abs_path = NULL;
  return content;
}
Пример #22
0
local_updatestep_type * local_updatestep_alloc( const char * name ) {
  local_updatestep_type * updatestep = util_malloc( sizeof * updatestep );
  
  UTIL_TYPE_ID_INIT( updatestep , LOCAL_UPDATESTEP_TYPE_ID );
  updatestep->name      = util_alloc_string_copy( name );
  updatestep->ministep  = vector_alloc_new();
  
  return updatestep;
}
Пример #23
0
vector_type * vector_alloc_copy(const vector_type * src , bool deep_copy) {
  vector_type * copy = vector_alloc_new();
  int i;
  for (i=0; i < src->size; i++) {
    node_data_type * node_copy = node_data_alloc_copy( src->data[i] , deep_copy);
    vector_append_node( copy , node_copy );
  }
  return copy;
}
Пример #24
0
subst_list_type * subst_list_alloc(const void * input_arg) {
  subst_list_type * subst_list = util_malloc(sizeof * subst_list );
  UTIL_TYPE_ID_INIT( subst_list , SUBST_LIST_TYPE_ID);
  subst_list->parent           = NULL;
  subst_list->func_pool        = NULL;
  subst_list->string_data      = vector_alloc_new();
  subst_list->func_data        = vector_alloc_new();

  if (input_arg != NULL) {
    if (subst_list_is_instance( input_arg )) 
      subst_list_set_parent( subst_list , input_arg );
    else if (subst_func_pool_is_instance( input_arg ))
      subst_list->func_pool = input_arg;
    else
      util_abort("%s: run_time cast failed - invalid type on input argument.\n",__func__);
  }
  
  return subst_list;
}
Пример #25
0
rms_tag_type * rms_tag_alloc(const char * name) {
    rms_tag_type *tag = malloc(sizeof *tag);
    UTIL_TYPE_ID_INIT( tag , RMS_TAG_TYPE_ID )
    tag->name = NULL;
    tag->key_hash = hash_alloc();
    tag->key_list = vector_alloc_new();
    if (name != NULL)
        tag->name = util_alloc_string_copy(name);
    return tag;
}
Пример #26
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;
}
Пример #27
0
menu_type * menu_alloc(const char * title , const char * quit_label , const char * quit_keys) {
    menu_type * menu = util_malloc(sizeof * menu );

    menu->title     = util_alloc_string_copy( title );
    menu->quit_keys = util_alloc_string_copy( quit_keys );
    menu->items     = vector_alloc_new();
    menu->complete_key_set = util_alloc_string_copy( quit_keys );
    menu->quit_label = util_alloc_string_copy( quit_label );

    return menu;
}
Пример #28
0
static void sched_block_add_kw(sched_block_type * block, const sched_kw_type * kw)
{
  vector_append_ref(block->kw_list , kw );
  if (!hash_has_key( block->kw_hash , sched_kw_get_name( kw ))) 
    hash_insert_hash_owned_ref( block->kw_hash , sched_kw_get_name( kw ) , vector_alloc_new() , vector_free__);
  
  {
    vector_type * kw_vector = hash_get( block->kw_hash , sched_kw_get_name( kw ));
    vector_append_ref( kw_vector , kw );
  }
}
Пример #29
0
static stringlist_type * stringlist_alloc_empty( bool alloc_vector ) {
  stringlist_type * stringlist = util_malloc(sizeof * stringlist );
  UTIL_TYPE_ID_INIT( stringlist , STRINGLIST_TYPE_ID);

  if (alloc_vector)
    stringlist->strings = vector_alloc_new();
  else
    stringlist->strings = NULL;

  return stringlist;
}
Пример #30
0
ensemble_type * ensemble_alloc( ) {
  ensemble_type * ensemble = util_malloc( sizeof * ensemble );

  ensemble->num_interp  = DEFAULT_NUM_INTERP;
  ensemble->start_time  = -1;
  ensemble->end_time    = -1;
  ensemble->data        = vector_alloc_new();
  ensemble->interp_time = time_t_vector_alloc( 0 , -1 );
  pthread_rwlock_init( &ensemble->rwlock , NULL );
  return ensemble;
}