Ejemplo n.º 1
0
void sched_file_update_blocks(sched_file_type * sched_file, 
                              int restart1 , 
                              int restart2 , 
                              sched_kw_type_enum kw_type,
                              sched_file_callback_ftype * callback,
                              void * callback_arg) {

  int restart_nr;
  if (restart2 > sched_file_get_num_restart_files(sched_file))
    restart2 = sched_file_get_num_restart_files(sched_file) - 1;
  
  for (restart_nr = restart1; restart_nr <= restart2; restart_nr++) {
    sched_block_type * sched_block = sched_file_iget_block( sched_file , restart_nr );
    sched_file_update_block( sched_block , restart_nr , kw_type , callback , callback_arg);
  }
}
Ejemplo n.º 2
0
void ecl_config_set_schedule_file( ecl_config_type * ecl_config , const char * schedule_file ) {
  if (ecl_config->start_date == -1)
    util_abort("%s: must set ecl_data_file first \n",__func__);
  {
    char * base;  /* The schedule target file will be without any path component */
    char * ext;
    util_alloc_file_components(schedule_file , NULL , &base , &ext);
    ecl_config->schedule_target_file = util_alloc_filename(NULL , base , ext);
    free(ext);
    free(base);
  }
  ecl_config->sched_file = sched_file_alloc( ecl_config->start_date );
  
  
  sched_file_parse(ecl_config->sched_file , schedule_file );
  ecl_config->last_history_restart = sched_file_get_num_restart_files( ecl_config->sched_file ) - 1;   /* We keep track of this - so we can stop assimilation at the end of history */
  {
    hash_iter_type * iter = hash_iter_alloc( ecl_config->fixed_length_kw );
    while (!hash_iter_is_complete( iter )) {
      const char * key = hash_iter_get_next_key( iter );
      int length       = hash_get_int( ecl_config->fixed_length_kw , key );
      
      sched_file_add_fixed_length_kw( ecl_config->sched_file , key , length);
    }
    hash_iter_free( iter );
  }
}
Ejemplo n.º 3
0
static void sched_file_build_block_dates(sched_file_type * sched_file)
{
  int num_restart_files = sched_file_get_num_restart_files(sched_file);
  time_t curr_time, new_time;

  if(num_restart_files < 1)
    util_abort("%s: Error - empty sched_file - aborting.\n", __func__);

  /* Special case for block 0. */
  sched_block_type * sched_block = sched_file_iget_block(sched_file, 0);
  sched_block->block_start_time  = sched_file->start_time ;
  sched_block->block_end_time    = sched_file->start_time ;

  curr_time = sched_file->start_time;
  for(int i=1; i<num_restart_files; i++)
  {
    sched_block = sched_file_iget_block(sched_file, i);
    sched_block->block_start_time = curr_time;
    
    sched_kw_type * timing_kw = sched_block_get_last_kw_ref(sched_block);
    new_time = sched_kw_get_new_time(timing_kw, curr_time);
    
    if(curr_time > new_time)
      util_abort("%s: Schedule file contains negative timesteps - aborting.\n",__func__);
    
    curr_time = new_time;
    sched_block->block_end_time = curr_time;
  }
}
Ejemplo n.º 4
0
void sched_file_update(sched_file_type * sched_file, 
                       sched_kw_type_enum kw_type,
                       sched_file_callback_ftype * callback,
                       void * callback_arg) {

  sched_file_update_blocks(sched_file , 1 , sched_file_get_num_restart_files(sched_file) - 1 , kw_type , callback , callback_arg);

}
Ejemplo n.º 5
0
void sched_file_summarize(const sched_file_type * sched_file , FILE * stream) {
  int len            = sched_file_get_num_restart_files(sched_file);
  time_t  start_time = sched_file_iget_block_start_time(sched_file , 0);
  for(int i=1; i<len; i++) {
    time_t t = sched_file_iget_block_start_time(sched_file , i);
    __sched_file_summarize_line(i - 1 , start_time , t , stream);
  }
  {
    time_t t = sched_file_iget_block_end_time(sched_file , len - 1);
    __sched_file_summarize_line(len - 1 , start_time , t , stream);
  }
}
Ejemplo n.º 6
0
int sched_file_get_restart_nr_from_time_t(const sched_file_type * sched_file, time_t time)
{
  int num_restart_files = sched_file_get_num_restart_files(sched_file);
  for( int i=0; i<num_restart_files; i++ ) {
    time_t block_end_time = sched_file_iget_block_end_time(sched_file, i);

    if (block_end_time > time) {
      int mday,year,month;
      util_set_date_values( time , &mday , &month , &year);
      util_abort("%s: Date: %02d/%02d/%04d  does not cooincide with any report time. Aborting.\n", __func__ , mday , month , year);
    } else if (block_end_time == time)
      return i; 
  }
  
  // If we are here, time did'nt correspond a restart file. Abort.
  {
    int mday,year,month;
    util_set_date_values( time , &mday , &month , &year);
    util_abort("%s: Date: %02d/%02d/%04d  does not cooincide with any report time. Aborting.\n", __func__ , mday , month , year);
  }
  return 0;
}
Ejemplo n.º 7
0
static void sched_file_fprintf_i__(const sched_file_type * sched_file, int last_restart_file, const char * file , bool addEND)
{
  FILE * stream = util_fopen(file, "w");
  int num_restart_files = sched_file_get_num_restart_files(sched_file);
  

  last_restart_file = util_int_min( last_restart_file , num_restart_files - 1);
  
  if (last_restart_file > num_restart_files) {
    util_abort("%s: you asked for restart nr:%d - the last available restart nr is: %d \n",__func__ , last_restart_file , num_restart_files);
    /* Must abort here because the calling scope is expecting to find last_restart_file.  */
  }
  
  for(int i=0; i<= last_restart_file; i++)
  {
    const sched_block_type * sched_block = vector_iget_const( sched_file->blocks , i);
    sched_block_fprintf(sched_block, stream);
  }

  if (addEND)
    fprintf(stream, "END\n");
  
  fclose(stream);
}
Ejemplo n.º 8
0
int ecl_config_get_num_restart_files(const ecl_config_type * ecl_config) {
  return sched_file_get_num_restart_files(ecl_config->sched_file);
}
Ejemplo n.º 9
0
void sched_history_update( sched_history_type * sched_history, const sched_file_type * sched_file ) {
  
  sched_history_realloc( sched_history );
  sched_history_add_FIELD_group( sched_history );
  {
    int block_nr;
    stringlist_type * well_list  = stringlist_alloc_new();    
    stringlist_type * group_list = stringlist_alloc_new();

    for (block_nr = 0; block_nr < sched_file_get_num_restart_files( sched_file ); block_nr++) {
      sched_block_type * block = sched_file_iget_block( sched_file , block_nr );
      int kw_nr;
      int report_step = block_nr;

      time_t_vector_iset( sched_history->time , block_nr , sched_file_iget_block_end_time( sched_file , block_nr));
      for (kw_nr = 0; kw_nr < sched_block_get_size( block ); kw_nr++) {
        sched_kw_type * kw         = sched_block_iget_kw( block , kw_nr );
        sched_kw_type_enum kw_type = sched_kw_get_type( kw );

        switch( kw_type ) {
        case(WCONHIST):
          {
            const sched_kw_wconhist_type * wconhist = sched_kw_get_data( kw );
            sched_kw_wconhist_init_well_list( wconhist , well_list );
            int iw;
            for (iw = 0; iw < stringlist_get_size( well_list ); iw++) {
              const char * well_name           = stringlist_iget( well_list , iw );
              well_history_type * well_history = sched_history_get_well( sched_history , well_name );
              well_history_add_keyword( well_history , kw , report_step );
            }
          }
          sched_history_set_historical( sched_history , block_nr );
          break; 
        case(WCONPROD):    /* This is only added to turn the well OFF from WCONHIST behaviour.  It is currently not
                              possible to query the well for anything when it is in WCONPROD state. */

          { 
            const sched_kw_wconprod_type * wconprod = sched_kw_get_data( kw ); 
            sched_kw_wconprod_init_well_list( wconprod , well_list );
            int iw;
            for (iw = 0; iw < stringlist_get_size( well_list ); iw++) {
              const char * well_name           = stringlist_iget( well_list , iw );
              well_history_type * well_history = sched_history_get_well( sched_history , well_name );
              well_history_add_keyword( well_history , kw , report_step);
            }
          }
          bool_vector_iset_default( sched_history->historical , block_nr , false );
          break;
        case(WCONINJE):
          {
            const sched_kw_wconinje_type * wconinje = sched_kw_get_data( kw );
            sched_kw_wconinje_init_well_list( wconinje , well_list );
            int iw;
            for (iw = 0; iw < stringlist_get_size( well_list ); iw++) {
              const char * well_name           = stringlist_iget( well_list , iw );
              well_history_type * well_history = sched_history_get_well( sched_history , well_name );
              well_history_add_keyword( well_history , kw , report_step);
            }
            if (sched_kw_wconinje_historical( wconinje ))
              sched_history_set_historical( sched_history , block_nr );
          }
          break;
        case(WCONINJH):
          /* ... */
          sched_history_set_historical( sched_history , block_nr );
          break;
        case(WELSPECS):
          {
            const sched_kw_welspecs_type * welspecs = sched_kw_get_data( kw );
            sched_kw_welspecs_init_child_parent_list( welspecs , well_list , group_list );
            sched_history_add_wells( sched_history , welspecs , well_list );
            sched_history_add_groups_welspecs( sched_history , welspecs , report_step , well_list , group_list );
            for (int iw = 0; iw < stringlist_get_size( well_list ); iw++) {
              const char * well_name           = stringlist_iget( well_list , iw );
              well_history_type * well_history = sched_history_get_well( sched_history , well_name );
              well_history_add_keyword( well_history , kw , report_step);
            }
          }
          break;
        case(GRUPTREE):
          {
            const sched_kw_gruptree_type * gruptree = sched_kw_get_data( kw );
            stringlist_type * parent_group_list = group_list;
            stringlist_type * child_group_list  = well_list;

            sched_kw_gruptree_init_child_parent_list( gruptree , child_group_list , parent_group_list );
            sched_history_add_groups_gruptree( sched_history , gruptree , report_step , well_list , group_list );
          }
          break;
        default:
          /*   */
          break;
        }
      }
    }
    stringlist_free( well_list );
    stringlist_free( group_list );
  }
  sched_history_install_index( sched_history );
}
Ejemplo n.º 10
0
/* Writes the complete schedule file. */
void sched_file_fprintf(const sched_file_type * sched_file, const char * file)
{
  int num_restart_files = sched_file_get_num_restart_files(sched_file);
  sched_file_fprintf_i__( sched_file , num_restart_files - 1 , file , sched_file->hasEND);
}