void test_active_index_list() {
  int default_value = -1;
  bool_vector_type * mask = bool_vector_alloc(0 , false);

  bool_vector_iset(mask , 10, true);
  bool_vector_iset(mask , 15, true);
  bool_vector_iset(mask , 20, true);

  {
    int_vector_type * active_index_list = bool_vector_alloc_active_index_list(mask , default_value);

    test_assert_int_equal( default_value , int_vector_get_default(active_index_list));
    test_assert_int_equal( 21 , int_vector_size( active_index_list ));

    test_assert_int_equal( default_value , int_vector_iget( active_index_list , 0));
    test_assert_int_equal( default_value , int_vector_iget( active_index_list , 1));
    test_assert_int_equal( default_value , int_vector_iget( active_index_list , 12));
    test_assert_int_equal( default_value , int_vector_iget( active_index_list , 19));

    test_assert_int_equal( 0 , int_vector_iget( active_index_list , 10));
    test_assert_int_equal( 1 , int_vector_iget( active_index_list , 15));
    test_assert_int_equal( 2 , int_vector_iget( active_index_list , 20));


    int_vector_free( active_index_list);
  }
  bool_vector_free(mask);
}
Esempio n. 2
0
void obs_vector_measure(const obs_vector_type * obs_vector ,
                        enkf_fs_type * fs ,
                        state_enum state ,
                        int report_step ,
                        const int_vector_type * ens_active_list ,
                        meas_data_type * meas_data ,
                        const active_list_type * active_list) {

  void * obs_node = vector_iget( obs_vector->nodes , report_step );
  if ( obs_node != NULL ) {
    enkf_node_type * enkf_node = enkf_node_deep_alloc( obs_vector->config_node );

    node_id_type node_id = { .report_step = report_step ,
                             .state       = state ,
                             .iens        = 0 };

    for (int active_iens_index =0; active_iens_index < int_vector_size( ens_active_list ); active_iens_index++) {
      node_id.iens = int_vector_iget( ens_active_list , active_iens_index );

      enkf_node_load(enkf_node , fs , node_id);
      obs_vector->measure(obs_node , enkf_node_value_ptr(enkf_node) , node_id , meas_data , active_list);
    }

    enkf_node_free( enkf_node );
  }
}
Esempio n. 3
0
static bool_vector_type * alloc_mask( const int_vector_type * active_list ) {
  bool_vector_type * mask = bool_vector_alloc( 0 , false );
  int i;
  for (i=0; i < int_vector_size( active_list ); i++) 
    bool_vector_iset( mask , int_vector_iget( active_list , i) , true );

  return mask;
}
Esempio n. 4
0
int state_map_get_size( state_map_type * map) {
  int size;
  pthread_rwlock_rdlock( &map->rw_lock );
  {
    size = int_vector_size( map->state );
  }
  pthread_rwlock_unlock( &map->rw_lock );
  return size;
}
Esempio n. 5
0
File: nnc_info.c Progetto: moiw/ert
const int_vector_type * nnc_info_get_index_list(const nnc_info_type * nnc_info, int lgr_nr) { 
  int_vector_type * ret = NULL;
  if (int_vector_size(nnc_info->lgr_index_map) > lgr_nr) {
    int lgr_index = int_vector_iget(nnc_info->lgr_index_map, lgr_nr); 
    if (-1 != lgr_index) {
      ret = vector_iget(nnc_info->lgr_list, lgr_index); 
    }
  }
  return ret;
}
void test_div() {
  int_vector_type * int_vector = int_vector_alloc( 0 , 100);
  int_vector_iset( int_vector , 10 , 100 );
  int_vector_div( int_vector , 10 );
  {
    int i;
    for (i=0; i < int_vector_size( int_vector ); i++) 
      test_assert_int_equal( 10 , int_vector_iget( int_vector , i ));
  }
}
Esempio n. 7
0
bool string_util_update_active_mask( const char * range_string , bool_vector_type * active_mask) {
  int i;
  int_vector_type * sscanf_active = string_util_sscanf_alloc_active_list( range_string );
  if (sscanf_active) {
    for (i=0; i < int_vector_size( sscanf_active ); i++)
      bool_vector_iset( active_mask , int_vector_iget(sscanf_active , i) , true );
    
    int_vector_free( sscanf_active );
    return true;
  } else
    return false;
}
void test_alloc() {
  const int size = 100;
  const int default_value = 77;
  int_vector_type * v = int_vector_alloc(size , default_value);

  test_assert_int_equal(size , int_vector_size(v));
  for (int i=0; i < size; i++)
    test_assert_int_equal( default_value , int_vector_iget( v , i));


  int_vector_free( v);
}
Esempio n. 9
0
bool nnc_info_equal( const nnc_info_type * nnc_info1 , const nnc_info_type * nnc_info2 ) {
  if (nnc_info1 == nnc_info2)
    return true;
  
  if ((nnc_info1 == NULL) || (nnc_info2 == NULL))
    return false;

  {
    if (nnc_info1->lgr_nr != nnc_info2->lgr_nr)
      return false;
    
    if ((int_vector_size( nnc_info1->lgr_index_map ) > 0) && (int_vector_size( nnc_info2->lgr_index_map ) > 0)) {
      int max_lgr_nr = util_int_max( int_vector_size( nnc_info1->lgr_index_map ), 
                                     int_vector_size( nnc_info2->lgr_index_map ) );
      int lgr_nr = 0;
      
      while (true) {
        nnc_vector_type * vector1 = nnc_info_get_vector( nnc_info1 , lgr_nr );
        nnc_vector_type * vector2 = nnc_info_get_vector( nnc_info2 , lgr_nr );
        
        if (!nnc_vector_equal(vector1 , vector2))
          return false;
        
        lgr_nr++;
        if (lgr_nr > max_lgr_nr)
          return true;
      } 
    } else {
      if (int_vector_size( nnc_info1->lgr_index_map ) == int_vector_size( nnc_info2->lgr_index_map ))
        return true;
      else
        return false;
    }
  }
}
Esempio n. 10
0
void test_neighbours( const ecl_grid_type * grid) {
  const int k = 0;
  fault_block_layer_type * layer = fault_block_layer_alloc( grid , k );
  geo_polygon_collection_type * polylines = geo_polygon_collection_alloc();
  ecl_kw_type * ecl_kw = ecl_kw_alloc("FAULTBLK" , ecl_grid_get_global_size( grid )     , ECL_INT_TYPE );

  ecl_kw_iset_int( ecl_kw , 0 , 1);
  ecl_kw_iset_int( ecl_kw , ecl_grid_get_global_index3( grid , 3,3,k) , 2);
  ecl_kw_iset_int( ecl_kw , ecl_grid_get_global_index3( grid , 4,3,k) , 3);
  ecl_kw_iset_int( ecl_kw , ecl_grid_get_global_index3( grid , 5,3,k) , 4);
  ecl_kw_iset_int( ecl_kw , ecl_grid_get_global_index3( grid , 4,2,k) , 5);
  fault_block_layer_load_kw( layer , ecl_kw);
  
  {
    int_vector_type * neighbours = int_vector_alloc( 0,0);
    {
      fault_block_type * block = fault_block_layer_get_block( layer , 1 );

      test_assert_int_equal( 0 , int_vector_size( neighbours ));
      fault_block_list_neighbours( block , false , polylines , neighbours );
      test_assert_int_equal( 0 , int_vector_size( neighbours ));
    }

    {
      fault_block_type * block = fault_block_layer_get_block( layer , 2 );

      fault_block_list_neighbours( block , false , polylines , neighbours );
      test_assert_int_equal( 1 , int_vector_size( neighbours ));
      test_assert_true( int_vector_contains( neighbours , 3 ));
    }
    int_vector_free( neighbours );
    

  }
  
  geo_polygon_collection_free( polylines );
  fault_block_layer_free( layer );  
  ecl_kw_free( ecl_kw );
}
Esempio n. 11
0
void test_create(enkf_config_node_type * config_node ) {
  obs_vector_type * obs_vector = obs_vector_alloc( SUMMARY_OBS , "OBS" , config_node , 100 );
  test_assert_true( obs_vector_is_instance( obs_vector ));
  {
    const int_vector_type * step_list = obs_vector_get_step_list( obs_vector );

    {
      summary_obs_type * obs_node = summary_obs_alloc( "FOPT" , "FOPT" , 10 , 1 , NULL , 0);
      obs_vector_install_node( obs_vector , 10 , obs_node );
      test_assert_int_equal( 1 , int_vector_size( step_list ));
      test_assert_int_equal( 10 , int_vector_iget( step_list , 0));
    }

    {
      summary_obs_type * obs_node = summary_obs_alloc( "FOPT" , "FOPT" , 10 , 1 , NULL , 0);
      obs_vector_install_node( obs_vector , 10 , obs_node );
      test_assert_int_equal( 1 , int_vector_size( step_list ));
      test_assert_int_equal( 10 , int_vector_iget( step_list , 0));
    }

    {
      summary_obs_type * obs_node = summary_obs_alloc( "FOPT" , "FOPT" , 10 , 1 , NULL , 0);
      obs_vector_install_node( obs_vector , 5 , obs_node );
      test_assert_int_equal( 2 , int_vector_size( step_list ));
      test_assert_int_equal( 5 , int_vector_iget( step_list , 0));
      test_assert_int_equal( 10 , int_vector_iget( step_list , 1));
    }

    {
      summary_obs_type * obs_node = summary_obs_alloc( "FOPT" , "FOPT" , 10 , 1 , NULL , 0);
      obs_vector_install_node( obs_vector , 15 , obs_node );
      test_assert_int_equal( 3 , int_vector_size( step_list ));
      test_assert_int_equal( 5 , int_vector_iget( step_list , 0));
      test_assert_int_equal( 10 , int_vector_iget( step_list , 1));
      test_assert_int_equal( 15 , int_vector_iget( step_list , 2));
    }
  }
  obs_vector_free( obs_vector );
}
Esempio n. 12
0
static void enkf_main_export_runpath_file(enkf_main_type * enkf_main,
                                          const int_vector_type * realizations,
                                          const int_vector_type * iterations) {

  ecl_config_type * ecl_config            = enkf_main_get_ecl_config(enkf_main);
  const model_config_type * model_config  = enkf_main_get_model_config(enkf_main);
  const char * basename_fmt               = ecl_config_get_eclbase(ecl_config);
  const char * runpath_fmt                = model_config_get_runpath_as_char(model_config);
  const qc_module_type * qc_module        = enkf_main_get_qc_module( enkf_main );

  runpath_list_type * runpath_list = runpath_list_alloc( qc_module_get_runpath_list_file( qc_module ));

  for (int iter = 0; iter < int_vector_size(iterations); ++iter) {
    for (int iens = 0; iens < int_vector_size(realizations); ++iens) {
      int iter_value = int_vector_iget(iterations, iter);
      int iens_value = int_vector_iget(realizations, iens);
      char * basename;
      char * runpath;

      if (basename_fmt)
        basename = util_alloc_sprintf(basename_fmt, iens_value);
      else
        basename = util_alloc_sprintf("--%d", iens_value);

      if (model_config_runpath_requires_iter(model_config))
        runpath = util_alloc_sprintf(runpath_fmt, iens_value, iter_value);
      else
        runpath = util_alloc_sprintf(runpath_fmt, iens_value);

      runpath_list_add(runpath_list, iens_value, iter_value, runpath, basename);

      free(basename);
      free(runpath);
    }
  }
  runpath_list_fprintf(runpath_list);
  runpath_list_free(runpath_list);
}
Esempio n. 13
0
int state_map_count_matching( state_map_type * state_map , int mask) {
   int count = 0;
   pthread_rwlock_rdlock( &state_map->rw_lock );
   {
     const int * map_ptr = int_vector_get_ptr(state_map->state);
     for (int i=0; i < int_vector_size( state_map->state ); i++) {
       int state_value = map_ptr[i];
       if (state_value & mask)
         count++;
     }
   }
   pthread_rwlock_unlock(&state_map->rw_lock);
   return count;
 }
Esempio n. 14
0
void test_del() {
  int_vector_type * vec = int_vector_alloc(0,0);
  
  test_assert_int_equal( int_vector_del_value( vec , 77) , 0 );

  int_vector_append(vec , 1);
  int_vector_append(vec , 2);
  int_vector_append(vec , 3);
  int_vector_append(vec , 1);
  int_vector_append(vec , 2);
  int_vector_append(vec , 3);
  int_vector_append(vec , 1);
  int_vector_append(vec , 1);

  int_vector_fprintf( vec , stdout , "int_vector" , "%3d");

  test_assert_int_equal( int_vector_del_value( vec , 77) ,  0);
  test_assert_int_equal( int_vector_del_value( vec , 2) , 2 );
  test_assert_int_equal( 6 , int_vector_size( vec ));

  int_vector_fprintf( vec , stdout , "int_vector" , "%3d");

  test_assert_int_equal( 1 , int_vector_iget(vec , 0));
  test_assert_int_equal( 3 , int_vector_iget(vec , 1));
  test_assert_int_equal( 1 , int_vector_iget(vec , 2));
  test_assert_int_equal( 3 , int_vector_iget(vec , 3));
  test_assert_int_equal( 1 , int_vector_iget(vec , 4));
  test_assert_int_equal( 1 , int_vector_iget(vec , 5));
  
  test_assert_int_equal( 4 , int_vector_del_value( vec , 1 ));
  test_assert_int_equal( 2 , int_vector_size( vec ));

  test_assert_int_equal( 3 , int_vector_iget(vec , 0));
  test_assert_int_equal( 3 , int_vector_iget(vec , 1));
  int_vector_free( vec );
}
Esempio n. 15
0
static void state_map_select_matching__( state_map_type * map , bool_vector_type * select_target , int select_mask , bool select) {
  pthread_rwlock_rdlock( &map->rw_lock );
  {
    {
      const int * map_ptr = int_vector_get_ptr( map->state );

      for (int i=0; i < int_vector_size( map->state ); i++) {
        int state_value = map_ptr[i];
        if (state_value & select_mask) 
          bool_vector_iset( select_target , i , select);
      }
    }
    pthread_rwlock_unlock( &map->rw_lock );
  }
}
Esempio n. 16
0
static int file_map_find_kw_value( const file_map_type * file_map , const char * kw , const void * value) {
  int global_index = -1;
  if ( file_map_has_kw( file_map , kw)) {
    const int_vector_type * index_list = hash_get( file_map->kw_index , kw );
    int index = 0;
    while (index < int_vector_size( index_list )) {
      const ecl_kw_type * ecl_kw = file_map_iget_kw( file_map , int_vector_iget( index_list , index ));
      if (ecl_kw_data_equal( ecl_kw , value )) {
        global_index = int_vector_iget( index_list , index );
        break;
      }
      index++;
    }
  }
  return global_index;
}
Esempio n. 17
0
static int file_map_find_sim_time(const file_map_type * file_map , time_t sim_time) {
  int seqnum_index = -1;
  if ( file_map_has_kw( file_map , INTEHEAD_KW)) {
    const int_vector_type * intehead_index_list = hash_get( file_map->kw_index , INTEHEAD_KW );
    int index = 0;
    while (index < int_vector_size( intehead_index_list )) {
      const ecl_kw_type * intehead_kw = file_map_iget_kw( file_map , int_vector_iget( intehead_index_list , index ));
      if (ecl_rsthead_date( intehead_kw ) == sim_time) {
        seqnum_index = index;
        break;
      }
      index++;
    }
  }
  return seqnum_index;
}
Esempio n. 18
0
void fault_block_layer_del_block( fault_block_layer_type * layer , int block_id) {
  int storage_index = int_vector_safe_iget( layer->block_map , block_id);
  if (storage_index >= 0) {

    int_vector_iset( layer->block_map , block_id , -1 );
    vector_idel( layer->blocks , storage_index );
    {
      int index;

      for (index = 0; index < int_vector_size( layer->block_map ); index++) {
        int current_storage_index = int_vector_iget( layer->block_map , index );
        if (current_storage_index > storage_index)
          int_vector_iset( layer->block_map ,index , current_storage_index - 1);
      }
    }
  }
}
Esempio n. 19
0
void nnc_info_fprintf(const nnc_info_type * nnc_info , FILE * stream) {
  fprintf(stream,"LGR_NR:%d \n",nnc_info->lgr_nr);
  {
    int lgr_nr;
    for (lgr_nr=0; lgr_nr < int_vector_size( nnc_info->lgr_index_map ); lgr_nr++) {
      int lgr_index = int_vector_iget( nnc_info->lgr_index_map , lgr_nr );
      if (lgr_index >= 0) {
        printf("   %02d -> %02d  => ",lgr_nr , lgr_index);
        {
          const int_vector_type * index_list = nnc_info_iget_grid_index_list( nnc_info , lgr_index );
          int_vector_fprintf( index_list , stream , " " , "%d");
          printf("\n");
        }
      }
    }
  }
  fprintf(stream , "\n");
}
Esempio n. 20
0
int main(int argc , char ** argv) {
  int lgr_nr = 77;
  nnc_info_type * nnc_info = nnc_info_alloc(lgr_nr);   

  test_assert_int_equal( 0 , nnc_info_get_total_size( nnc_info ));
  test_assert_int_equal( lgr_nr , nnc_info_get_lgr_nr(  nnc_info ));
  test_assert_true(nnc_info_is_instance(nnc_info));
  test_assert_not_NULL(nnc_info); 
  
  nnc_info_add_nnc(nnc_info, lgr_nr, 110 , 0);
  test_assert_int_equal( 1, nnc_info_get_total_size( nnc_info ));
  
  nnc_info_add_nnc(nnc_info, 1, 110 , 1);
  nnc_info_add_nnc(nnc_info, 1, 111 , 2);
  test_assert_int_equal( 3, nnc_info_get_total_size( nnc_info ));
  

  nnc_vector_type * nnc_vector = nnc_info_get_vector( nnc_info , 1);
  const int_vector_type * nnc_cells = nnc_info_get_grid_index_list(nnc_info, 1); 
  test_assert_int_equal(int_vector_size(nnc_cells), 2); 
  test_assert_ptr_equal( nnc_cells , nnc_vector_get_grid_index_list( nnc_vector ));


  nnc_vector_type * nnc_vector_null  = nnc_info_get_vector( nnc_info , 2);
  const int_vector_type * nnc_cells_null = nnc_info_get_grid_index_list(nnc_info, 2); 
  test_assert_NULL(nnc_cells_null); 
  test_assert_NULL(nnc_vector_null); 
  
  nnc_vector_type * nnc_vector_self  = nnc_info_get_self_vector( nnc_info );
  const nnc_vector_type * nnc_vector_77  = nnc_info_get_vector( nnc_info , lgr_nr );
  test_assert_ptr_equal( nnc_vector_77 , nnc_vector_self );

  const int_vector_type * nnc_cells_77 = nnc_info_get_grid_index_list(nnc_info, lgr_nr); 
  const int_vector_type * nnc_cells_self = nnc_info_get_self_grid_index_list(nnc_info); 
  test_assert_ptr_equal( nnc_cells_77 , nnc_cells_self );


  test_assert_int_equal( 2 , nnc_info_get_size( nnc_info ));
  test_assert_ptr_equal( nnc_info_get_vector( nnc_info , 1 ) , nnc_info_iget_vector( nnc_info , 1 ));
  nnc_info_free(nnc_info);
  

  exit(0);
}
void test_mask() {
  bool_vector_type * mask = bool_vector_alloc(0 , false);

  bool_vector_iset(mask , 10, true);
  bool_vector_iset(mask , 15, true);
  bool_vector_iset(mask , 20, true);

  {
    int_vector_type * index_list = bool_vector_alloc_active_list( mask );

    test_assert_int_equal( 3 , int_vector_size( index_list ));
    test_assert_int_equal( 10 , int_vector_iget( index_list , 0 ));
    test_assert_int_equal( 15 , int_vector_iget( index_list , 1 ));
    test_assert_int_equal( 20 , int_vector_iget( index_list , 2 ));

    int_vector_free( index_list );
  }
  bool_vector_free( mask );
}
Esempio n. 22
0
static int file_map_iget_occurence( const file_map_type * file_map , int global_index) {
  const ecl_file_kw_type * file_kw = vector_iget_const( file_map->kw_list , global_index);
  const char * header              = ecl_file_kw_get_header( file_kw );
  const int_vector_type * index_vector = hash_get( file_map->kw_index , header );
  const int * index_data = int_vector_get_const_ptr( index_vector );
  
  int occurence = -1;
  {
    /* Manual reverse lookup. */
    int i;
    for (i=0; i < int_vector_size( index_vector ); i++)
      if (index_data[i] == global_index)
        occurence = i;
  }
  if (occurence < 0)
    util_abort("%s: internal error ... \n" , __func__);

  return occurence;
}
Esempio n. 23
0
File: nnc_info.c Progetto: moiw/ert
void nnc_info_add_nnc(nnc_info_type * nnc_info, int lgr_nr, int global_cell_number) {
   
  bool index_list_initialized = false; 
  
  if (int_vector_size(nnc_info->lgr_index_map) > lgr_nr) {
    int lgr_index = int_vector_iget(nnc_info->lgr_index_map, lgr_nr); 
    if (-1 != lgr_index) {
      int_vector_append(vector_iget(nnc_info->lgr_list, lgr_index), global_cell_number);
      index_list_initialized = true; 
    }
  }
  
  if (!index_list_initialized) {
    int_vector_type * nnc_for_lgr_vec = int_vector_alloc(0,0); 
    int_vector_append(nnc_for_lgr_vec, global_cell_number); 
    vector_append_owned_ref(nnc_info->lgr_list, nnc_for_lgr_vec, int_vector_free__); 
    int_vector_iset(nnc_info->lgr_index_map , lgr_nr, vector_get_size(nnc_info->lgr_list) -1 ); 
  }
 }
Esempio n. 24
0
bool field_config_parse_user_key__( const char * index_key , int *i , int *j , int *k) {
    int      length;
    {
        int_vector_type * indices = string_util_alloc_value_list( index_key );
        length = int_vector_size( indices );

        if (length == 3) {
            *i = int_vector_iget( indices , 0) - 1;
            *j = int_vector_iget( indices , 1) - 1;
            *k = int_vector_iget( indices , 2) - 1;
        }

        int_vector_free( indices );
    }
    if (length == 3)
        return true;
    else
        return false;
}
Esempio n. 25
0
void test_iset_block() {
  int_vector_type * vec = int_vector_alloc(0,0);

  int_vector_iset_block( vec , 10 , 10 , 77 );
  test_assert_int_equal( int_vector_size( vec ) , 20 );
  {
    int i; 
    for (i=10; i < 20; i++)
      test_assert_int_equal( int_vector_iget( vec , i ) , 77 );
  }
  int_vector_iset_block( vec , 10 , 0 , 177 );
  test_assert_int_equal( int_vector_iget( vec , 10 ) , 77 );

  int_vector_iset_block( vec , 10 , -11 , 66 );
  {
    int i; 
    for (i=0; i <= 10; i++)
      test_assert_int_equal( int_vector_iget( vec , i ) , 66 );
  }
  int_vector_free( vec );
}
static int ecl_rft_file_get_node_index_time_rft( const ecl_rft_file_type * rft_file , const char * well , time_t recording_time) {
  int global_index = -1;
  if (hash_has_key( rft_file->well_index , well)) {
    const int_vector_type * index_vector = hash_get(rft_file->well_index , well);
    int well_index = 0;
    while (true) {
      if (well_index == int_vector_size( index_vector ))
        break;

      {
        const ecl_rft_node_type * node = ecl_rft_file_iget_node( rft_file , int_vector_iget( index_vector , well_index ));
        if (ecl_rft_node_get_date( node ) == recording_time) {
          global_index = int_vector_iget( index_vector , well_index );
          break;
        }
      }

      well_index++;
    }
  }
  return global_index;
}
Esempio n. 27
0
void ecl_sum_tstep_fwrite( const ecl_sum_tstep_type * ministep , const int_vector_type * index_map , fortio_type * fortio) {
  {
    ecl_kw_type * ministep_kw = ecl_kw_alloc( MINISTEP_KW , 1 , ECL_INT_TYPE );
    ecl_kw_iset_int( ministep_kw , 0 , ministep->ministep );
    ecl_kw_fwrite( ministep_kw , fortio );
    ecl_kw_free( ministep_kw );
  }

  {
    int compact_size = int_vector_size( index_map );
    ecl_kw_type * params_kw = ecl_kw_alloc( PARAMS_KW , compact_size , ECL_FLOAT_TYPE );

    const int * index = int_vector_get_ptr( index_map );
    float * data      = ecl_kw_get_ptr( params_kw );

    {
      int i;
      for (i=0; i < compact_size; i++)
        data[i] = ministep->data[ index[i] ];
    }
    ecl_kw_fwrite( params_kw , fortio );
    ecl_kw_free( params_kw );
  }
}
Esempio n. 28
0
File: ecl_sum.c Progetto: flikka/ert
static void __ecl_sum_fprintf_line( const ecl_sum_type * ecl_sum , FILE * stream , int internal_index , const bool_vector_type * has_var , const int_vector_type * var_index , char * date_string , const ecl_sum_fmt_type * fmt) {
  fprintf(stream , fmt->days_fmt , ecl_sum_iget_sim_days(ecl_sum , internal_index));
  fprintf(stream , "%s", fmt->sep );

  {
    struct tm ts;
    time_t sim_time = ecl_sum_iget_sim_time(ecl_sum , internal_index );
    util_localtime( &sim_time , &ts);
    strftime( date_string , DATE_STRING_LENGTH - 1 , fmt->date_fmt , &ts);
    fprintf(stream , "%s", date_string );
  }

  {
    int ivar;
    for (ivar = 0; ivar < int_vector_size( var_index ); ivar++) {
      if (bool_vector_iget( has_var , ivar )) {
        fprintf(stream , "%s", fmt->sep);
        fprintf(stream , fmt->value_fmt , ecl_sum_iget(ecl_sum , internal_index, int_vector_iget( var_index , ivar )));
      }
    }
  }

  fprintf(stream , "%s", fmt->newline);
}
int main(int argc , char ** argv) {
  
  int_vector_type * int_vector = int_vector_alloc( 0 , 99);
  
  int_vector_iset( int_vector , 2 , 0);       
  int_vector_insert( int_vector , 2 , 77 );   
  int_vector_iset( int_vector , 5 , -10);     
  
  int_vector_fprintf( int_vector , stdout , "int_vector" , "%3d");
  assert_equal( int_vector_iget(int_vector , 0 ) == 99 );
  assert_equal( int_vector_iget(int_vector , 1 ) == 99 );
  assert_equal( int_vector_iget(int_vector , 2 ) == 77 );
  assert_equal( int_vector_iget(int_vector , 3 ) == 00 );
  assert_equal( int_vector_iget(int_vector , 4 ) == 99 );
  assert_equal( int_vector_iget(int_vector , 5 ) == -10 );
  
  {
    int N1 = 100000;
    int N2 = 10*N1;
    int_vector_type * v1 = int_vector_alloc( N1 , 0 );
    int_vector_type * v2;
    int * data1 = int_vector_get_ptr( v1 );
    int_vector_iset( v1 , N1 - 1, 99);

    int_vector_free_container( v1 );
    v2 = int_vector_alloc( N2 , 0 );
    int_vector_iset(v2 , N2 - 1, 77 );
    
    test_assert_int_equal(  data1[N1-1] , 99);
    int_vector_free( v2 );
    free( data1 );
  }                 
  
  
  test_assert_true( int_vector_init_range( int_vector , 100 , 1000 , 115 ) );
  test_assert_int_equal( int_vector_iget( int_vector , 0 ) , 100);
  test_assert_int_equal( int_vector_iget( int_vector , 1 ) , 215);
  test_assert_int_equal( int_vector_iget( int_vector , 2 ) , 330);
  test_assert_int_equal( int_vector_iget( int_vector , 3 ) , 445);
  test_assert_int_equal( int_vector_get_last( int_vector ) , 1000);
  
  test_assert_false( int_vector_init_range( int_vector , 100 , -1000 , 115 ) );
  test_assert_int_equal( int_vector_iget( int_vector , 0 ) , 100);
  test_assert_int_equal( int_vector_iget( int_vector , 1 ) , 215);
  test_assert_int_equal( int_vector_iget( int_vector , 2 ) , 330);
  test_assert_int_equal( int_vector_iget( int_vector , 3 ) , 445);
  test_assert_int_equal( int_vector_get_last( int_vector ) , 1000);

  {
    int_vector_type * v1 = int_vector_alloc(0,0);
    int_vector_type * v2 = int_vector_alloc(0,0);
    int_vector_append(v1 , 10);
    int_vector_append(v1 , 15);
    int_vector_append(v1 , 20);

    int_vector_append(v2 , 1);
    int_vector_append(v2 , 2);
    int_vector_append(v2 , 3);

    int_vector_append_vector( v1 , v2 );
    test_assert_int_equal( int_vector_size( v1 ) , 6 );
    test_assert_int_equal( int_vector_iget (v1 ,  0 ), 10 );
    test_assert_int_equal( int_vector_iget (v1 ,  1 ), 15 );
    test_assert_int_equal( int_vector_iget (v1 ,  2 ), 20 );
                                                               
    test_assert_int_equal( int_vector_iget (v1 ,  3 ), 1 );
    test_assert_int_equal( int_vector_iget (v1 ,  4 ), 2 );
    test_assert_int_equal( int_vector_iget (v1 ,  5 ), 3 );

    int_vector_free( v1 );
    int_vector_free( v2 );
  }
  
  exit(0);
}
int ecl_rft_file_get_well_occurences( const ecl_rft_file_type * rft_file , const char * well) {
  const int_vector_type * index_vector = hash_get(rft_file->well_index , well);
  return int_vector_size( index_vector );
}