示例#1
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);
}
示例#2
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 );
  }
}
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 );
}
示例#4
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;
  }
}
示例#5
0
static void obs_vector_resize(obs_vector_type * vector , int new_size) {
  int current_size = vector_get_size( vector->nodes );
  int i;
  
  for (i=current_size; i < new_size; i++) 
    vector_append_ref( vector->nodes , NULL);
  
}
示例#6
0
void add_jobs( int chunk_size) {
  int i;
  char * cwd = util_alloc_cwd();
  for (i=0; i < chunk_size; i++) {
    block_job_type * job = block_job_alloc();
    job->lsf_job = lsf_driver_submit_job(lsf_driver , BLOCK_COMMAND , 1 , cwd , "BLOCK" , 0 , NULL );
    vector_append_ref( job_pool , job );
  }
  free( cwd );
}
示例#7
0
文件: stringlist.c 项目: akva2/ert
/**
  Allocates a new stringlist where the strings are references to the
  num_strings found in stringlist from start.
*/
stringlist_type * stringlist_alloc_shallow_copy_with_limits(const stringlist_type * stringlist, int offset, int num_strings) {
  stringlist_type * copy = stringlist_alloc_empty( true );
  int i;
  for( i=0; i<num_strings; i++)
    {
    const char * str = stringlist_iget(stringlist, i + offset);
    vector_append_ref(copy->strings, str);
  }

  return copy;
}
示例#8
0
文件: rms_tag.c 项目: bramirex/ert
void rms_tag_add_tagkey(rms_tag_type *tag , const rms_tagkey_type *tagkey, int mem_mode) {
    rms_tagkey_type * tagkey_copy;

    switch (mem_mode) {
    case(COPY):
        tagkey_copy = rms_tagkey_copyc(tagkey);
        vector_append_owned_ref( tag->key_list , tagkey_copy , rms_tagkey_free_ );
        hash_insert_ref(tag->key_hash , rms_tagkey_get_name(tagkey_copy) , tagkey_copy);
        break;
    case(OWNED_REF):
        vector_append_owned_ref( tag->key_list , tagkey , rms_tagkey_free_ );
        hash_insert_ref(tag->key_hash , rms_tagkey_get_name(tagkey) , tagkey);
        break;
    case(SHARED):
        vector_append_ref( tag->key_list , tagkey );
        hash_insert_ref(tag->key_hash , rms_tagkey_get_name(tagkey) , tagkey);
        break;
    }
}
示例#9
0
void enkf_config_node_update_container( enkf_config_node_type * config_node , const enkf_config_node_type * child_node) {
  vector_append_ref( config_node->container_nodes , child_node );
}                                       
示例#10
0
void container_add_node(container_type * container , void * child_node ) {
  vector_append_ref( container->nodes , child_node );
}
示例#11
0
文件: vector.cpp 项目: OPM/ResInsight
void vector_grow_NULL( vector_type * vector , int new_size ) {
  int i;
  for (i = vector->size; i < new_size; i++)
    vector_append_ref( vector , NULL );
}
示例#12
0
文件: vector.cpp 项目: OPM/ResInsight
static void vector_assert_size( vector_type * vector , int min_size) {
  while (vector->size < min_size)
    vector_append_ref( vector , NULL );
}
示例#13
0
void config_content_add_node( config_content_type * content , config_content_node_type * content_node ) {
  vector_append_ref( content->nodes , content_node );
}
示例#14
0
static void file_map_add_kw( file_map_type * file_map , ecl_file_kw_type * file_kw) {
  if (file_map->owner)
    vector_append_owned_ref( file_map->kw_list , file_kw , ecl_file_kw_free__ ); 
  else
    vector_append_ref( file_map->kw_list , file_kw); 
}
示例#15
0
文件: stringlist.c 项目: akva2/ert
void stringlist_append_ref(stringlist_type * stringlist , const char * s) {
  vector_append_ref(stringlist->strings , s);
}
示例#16
0
static void sched_file_update_index( sched_file_type * sched_file ) {
  int ikw;
  

  /* By type index */
  {
    if (sched_file->kw_list_by_type != NULL) 
      vector_free( sched_file->kw_list_by_type );
    sched_file->kw_list_by_type = vector_alloc_NULL_initialized( NUM_SCHED_KW_TYPES );
    for (ikw = 0; ikw < vector_get_size( sched_file->kw_list ); ikw++) {
      const sched_kw_type * kw = vector_iget_const( sched_file->kw_list , ikw );
      sched_kw_type_enum type  = sched_kw_get_type( kw );
      {
        vector_type * tmp      = vector_iget( sched_file->kw_list_by_type , type );
        
        if (tmp == NULL) {
          tmp = vector_alloc_new();
          vector_iset_owned_ref( sched_file->kw_list_by_type , type , tmp , vector_free__ );
        }
        
        vector_append_ref( tmp , kw );
      }
    }
  }

  
  
  /* Block based on restart number. */
  {
    time_t current_time;
    sched_block_type * current_block;
    vector_clear( sched_file->blocks );

    /* 
       Adding a pseudo block at the start which runs from the start of
       time (i.e. EPOCH start 01/01/1970) to simulation start.
    */
    current_block = sched_block_alloc_empty( 0 );
    current_block->block_start_time  = sched_file->start_time;//-1;     /* Need this funny node - hhmmmmmm */
    current_block->block_end_time    = sched_file->start_time;
    sched_file_add_block( sched_file , current_block );
    
    current_block = sched_block_alloc_empty( 0 );
    current_block->block_start_time  = sched_file->start_time;
    current_time = sched_file->start_time;
    
    for (ikw = 0; ikw < vector_get_size( sched_file->kw_list ); ikw++) {
      const sched_kw_type * kw = vector_iget_const( sched_file->kw_list , ikw );
      sched_kw_type_enum type  = sched_kw_get_type( kw );
      {
        sched_block_add_kw( current_block , kw );
        if(type == DATES || type == TSTEP || type == TIME) {
          /**
             Observe that when we enocunter a time-based keyword we do the following:
             
               1. Finish the the current block by setting the end_time
                  field and add this block to the sched_file
                  structure.

               2. Create a new block starting at current time.

              ------- 

              Blocks are not actually added to the sched_file instance
              before they are terminated with a DATES/TSTEP
              keyword. This implies that keywords which come after the
              last DATES/TSTEP keyword are lost.
          */
               
          current_time = sched_kw_get_new_time( kw , current_time );

          /* Finishing off the current block, and adding it to the sched_file. */
          current_block->block_end_time = current_time;
          sched_file_add_block( sched_file , current_block );
          
          /* Creating a new block - not yet added to the sched_file. */
          current_block = sched_block_alloc_empty( vector_get_size( sched_file->blocks ));
          current_block->block_start_time = current_time;
        }
      }
    }
    /*
      Free the last block, which has not been added to the sched_file
      object.
    */
    sched_block_free( current_block );
  }
}