Пример #1
0
void misfit_ensemble_initialize( misfit_ensemble_type * misfit_ensemble ,
                                 const ensemble_config_type * ensemble_config ,
                                 const enkf_obs_type * enkf_obs ,
                                 enkf_fs_type * fs ,
                                 int ens_size ,
                                 int history_length,
                                 bool force_init) {

    if (force_init || !misfit_ensemble->initialized) {
        misfit_ensemble_clear( misfit_ensemble );

        msg_type * msg                 = msg_alloc("Evaluating misfit for observation: " , false);
        double ** chi2_work            = __2d_malloc( history_length + 1 , ens_size );
        bool_vector_type * iens_valid  = bool_vector_alloc( ens_size , true );

        hash_iter_type * obs_iter = enkf_obs_alloc_iter( enkf_obs );
        const char * obs_key      = hash_iter_get_next_key( obs_iter );

        misfit_ensemble->history_length = history_length;
        misfit_ensemble_set_ens_size( misfit_ensemble , ens_size );

        msg_show( msg );
        while (obs_key != NULL) {
            obs_vector_type * obs_vector = enkf_obs_get_vector( enkf_obs , obs_key );
            msg_update( msg , obs_key );

            bool_vector_reset( iens_valid );
            bool_vector_iset( iens_valid , ens_size - 1 , true );
            obs_vector_ensemble_chi2( obs_vector ,
                                      fs ,
                                      iens_valid ,
                                      0 ,
                                      misfit_ensemble->history_length,
                                      0 ,
                                      ens_size ,
                                      chi2_work);

            /**
                Internalizing the results from the chi2_work table into the misfit structure.
            */
            for (int iens = 0; iens < ens_size; iens++) {
                misfit_member_type * node = misfit_ensemble_iget_member( misfit_ensemble , iens );
                if (bool_vector_iget( iens_valid , iens))
                    misfit_member_update( node , obs_key , misfit_ensemble->history_length , iens , (const double **) chi2_work);
            }
            obs_key = hash_iter_get_next_key( obs_iter );
        }

        bool_vector_free( iens_valid );
        msg_free(msg , true );
        hash_iter_free( obs_iter );

        __2d_free( chi2_work , misfit_ensemble->history_length + 1);
        misfit_ensemble->initialized = true;
    }
}
Пример #2
0
static sched_kw_gruptree_type * sched_kw_gruptree_copyc(const sched_kw_gruptree_type * src) {
  sched_kw_gruptree_type * target = sched_kw_gruptree_alloc_empty();
  hash_iter_type * iter = hash_iter_alloc(src->gruptree_hash);
  const char * kw = hash_iter_get_next_key(iter);
  while (kw != NULL) {
    char * parent_name = hash_get_string(src->gruptree_hash , kw);
    hash_insert_string( target->gruptree_hash , kw , parent_name);
    kw = hash_iter_get_next_key(iter);
  }
  hash_iter_free(iter);
  return target;
}
Пример #3
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 );
  }
}
Пример #4
0
void * hash_iter_get_next_value(hash_iter_type * iter) {
  const char * key = hash_iter_get_next_key(iter);

  if(key != NULL)
    return hash_get(iter->hash, key);
  else
    return NULL;
}
Пример #5
0
void output_table_run( hash_type * output_table , ensemble_type * ensemble ) {
  hash_iter_type * iter = hash_iter_alloc( output_table);

  while (!hash_iter_is_complete( iter )) {
    const char * output_file     = hash_iter_get_next_key( iter );
    const output_type * output   = hash_get( output_table , output_file );
    output_run_line( output, ensemble );
  }
}
Пример #6
0
void hash_apply( hash_type * hash , hash_apply_ftype * func) {
  hash_iter_type * iter = hash_iter_alloc( hash );
  while (!hash_iter_is_complete( iter )) {
    const char * key = hash_iter_get_next_key( iter );
    void * value     = hash_get( hash , key );

    func( value );
  }
  hash_iter_free( iter );
}
Пример #7
0
void sched_history_fprintf_index_keys( const sched_history_type * sched_history , FILE * stream ) {
  hash_iter_type * iter = hash_iter_alloc( sched_history->index );
  int c = 0;
  while (!hash_iter_is_complete( iter )) {
    fprintf(stream , "%18s" , hash_iter_get_next_key( iter ));
    c += 1;
    if ((c % 6) == 0)
      fprintf(stream , "\n");
  }
  hash_iter_free( iter );
}
Пример #8
0
void local_dataset_fprintf( const local_dataset_type * dataset , FILE * stream) {
  hash_iter_type * data_iter = hash_iter_alloc( dataset->nodes );
  while (!hash_iter_is_complete( data_iter )) {
    const char * data_key          = hash_iter_get_next_key( data_iter );
    active_list_type * active_list = hash_get( dataset->nodes , data_key );
    
    fprintf(stream , "%s %s %s\n", local_config_get_cmd_string( ADD_DATA ) , dataset->name , data_key );
    active_list_fprintf( active_list , false , data_key , stream );
  }
  hash_iter_free( data_iter );
}
Пример #9
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;
}
Пример #10
0
bool ensemble_config_has_impl_type(const  ensemble_config_type * config, const ert_impl_type impl_type) {
  bool ret = false; 
  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) {
      ret = true; 
      break; 
    }
  }
  hash_iter_free(iter);
  return ret; 
}
Пример #11
0
void local_dataset_summary_fprintf( const local_dataset_type * dataset , FILE * stream) {
{
  hash_iter_type * data_iter = hash_iter_alloc( dataset->nodes );
  while (!hash_iter_is_complete( data_iter )) {
    const char * data_key          = hash_iter_get_next_key( data_iter );
    fprintf(stream , "NAME OF DATA:%s,", data_key );

    active_list_type * active_list = hash_get( dataset->nodes , data_key );
    active_list_summary_fprintf( active_list , local_dataset_get_name(dataset) , data_key , stream);
  }
  hash_iter_free( data_iter );
 }
}
Пример #12
0
local_dataset_type * local_dataset_alloc_copy( local_dataset_type * src_dataset , const char * copy_name ) {
  local_dataset_type * copy_dataset = local_dataset_alloc( copy_name );
  hash_iter_type * node_iter = hash_iter_alloc( src_dataset->nodes );

  while (!hash_iter_is_complete( node_iter )) {
    const char * key = hash_iter_get_next_key( node_iter );
    active_list_type * active_list = active_list_alloc_copy( hash_get( src_dataset->nodes , key ) );
    hash_insert_hash_owned_ref( copy_dataset->nodes , key , active_list , active_list_free__);
  }

  hash_iter_free( node_iter );
  return copy_dataset;
}
Пример #13
0
bool well_state_add_MSW( well_state_type * well_state ,
                         const ecl_file_type * rst_file ,
                         int well_nr,
                         bool load_segment_information) {

  if (ecl_file_has_kw( rst_file , ISEG_KW)) {
    ecl_rsthead_type  * rst_head  = ecl_rsthead_alloc( rst_file );
    const ecl_kw_type * iwel_kw = ecl_file_iget_named_kw( rst_file , IWEL_KW , 0);
    const ecl_kw_type * iseg_kw = ecl_file_iget_named_kw( rst_file , ISEG_KW , 0);
    well_rseg_loader_type * rseg_loader = NULL;
    
    int segment_count;

    if (ecl_file_has_kw( rst_file , RSEG_KW )) {
      if (load_segment_information)
        rseg_loader = well_rseg_loader_alloc(rst_file);
        
      segment_count = well_segment_collection_load_from_kw( well_state->segments ,
                                                            well_nr ,
                                                            iwel_kw ,
                                                            iseg_kw ,
                                                            rseg_loader ,
                                                            rst_head,
                                                            load_segment_information , 
                                                            &well_state->is_MSW_well);
      
      
      if (segment_count > 0) {
        hash_iter_type * grid_iter = hash_iter_alloc( well_state->connections );
        while (!hash_iter_is_complete( grid_iter )) {
          const char * grid_name = hash_iter_get_next_key( grid_iter );
          const well_conn_collection_type * connections = hash_get( well_state->connections , grid_name );
          well_segment_collection_add_connections( well_state->segments , grid_name , connections );
        }
        hash_iter_free( grid_iter );

        well_segment_collection_link( well_state->segments );
        well_segment_collection_add_branches( well_state->segments , well_state->branches );
      }
      ecl_rsthead_free( rst_head );
      
      if (rseg_loader != NULL) {
        well_rseg_loader_free(rseg_loader);
      }
      
      return true;
    }
  } else
    return false;
}
Пример #14
0
void sched_kw_gruptree_init_child_parent_list( const sched_kw_gruptree_type * kw , stringlist_type * child , stringlist_type * parent) {
  stringlist_clear( child );
  stringlist_clear( parent );
  {
    hash_iter_type * iter = hash_iter_alloc( kw->gruptree_hash );
    while (!hash_iter_is_complete( iter )) {
      const char * child_group  = hash_iter_get_next_key( iter );
      const char * parent_group = hash_get_string( kw->gruptree_hash , child_group );
      
      stringlist_append_copy( child , child_group );       /* <- The iterator keys go out of scope when hash_iter_free() is called. */
      stringlist_append_ref( parent , parent_group );
    }
    hash_iter_free( iter );
  }
}
Пример #15
0
void site_config_clear_env( site_config_type * site_config ) {
  /* 1: Clearing the user_set variables. */
  {
    hash_iter_type * hash_iter = hash_iter_alloc( site_config->env_variables_user );
    while (!hash_iter_is_complete( hash_iter )) {
      const char * var       = hash_iter_get_next_key( hash_iter );
      util_unsetenv( var );
    }
    hash_iter_free( hash_iter );
    hash_clear( site_config->env_variables_user );
  }
  

  /* 2: Recovering the site_set variables. */
  {
    hash_iter_type * hash_iter = hash_iter_alloc( site_config->env_variables_site );
    while (!hash_iter_is_complete( hash_iter )) {
      const char * var       = hash_iter_get_next_key( hash_iter );
      const char * value     = hash_get( site_config->env_variables_site , var );
      util_interp_setenv( var , value );    /* Will call unsetenv if value == NULL */
    }
    hash_iter_free( hash_iter );
  }  
}
Пример #16
0
stringlist_type * ensemble_config_alloc_keylist_from_var_type(const ensemble_config_type * config , int var_mask) {
  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);
    enkf_var_type var_type = enkf_config_node_get_var_type( hash_get(config->config_nodes , key));
    
    if (var_type & var_mask)
      stringlist_append_copy( key_list , key );
  }
  hash_iter_free(iter);

  return key_list;
}
Пример #17
0
void site_config_clear_pathvar( site_config_type * site_config ) {
  stringlist_clear( site_config->path_variables_user );
  stringlist_clear( site_config->path_values_user );
  {
    /* Recover the original values. */
    hash_iter_type * hash_iter = hash_iter_alloc( site_config->path_variables_site );
    while (!hash_iter_is_complete( hash_iter )) {
      const char * var       = hash_iter_get_next_key( hash_iter );
      const char * site_value = hash_get( site_config->path_variables_site , var );
      
      if (site_value == NULL)
        util_unsetenv( var );
      else
        util_setenv( var , site_value );
    }
  }
}
Пример #18
0
static ecl_grav_survey_type * ecl_grav_get_survey( const ecl_grav_type * grav , const char * name) {
  if (name == NULL)
    return NULL;  // Calling scope must determine if this is OK?
  else {
    if (hash_has_key( grav->surveys , name))
      return hash_get( grav->surveys , name );
    else {
      hash_iter_type * survey_iter = hash_iter_alloc( grav->surveys );
      fprintf(stderr,"Survey name:%s not registered. Available surveys are: \n\n     " , name);
      while (!hash_iter_is_complete( survey_iter )) {
        const char * survey = hash_iter_get_next_key( survey_iter );
        fprintf(stderr,"%s ",survey);
      }
      fprintf(stderr,"\n\n");
      hash_iter_free( survey_iter );
      exit(1);
    }
  }
}
Пример #19
0
void print_status() {
  int total_running = 0;
  int total_pending = 0;
  for (int i=0; i < vector_get_size( job_pool ); i++) {
    block_job_type * job = vector_iget( job_pool , i );
    if (job->running)
      total_running += 1;
    else
      total_pending += 1;
  }
  printf("Running:%3d  Pending: %3d   Blocks active: ",total_running , total_pending);
  {
    hash_iter_type * iter = hash_iter_alloc( nodes );
    while (!hash_iter_is_complete( iter )) {
      const char * hostname = hash_iter_get_next_key( iter );
      const count_pair_type * count = hash_get( nodes , hostname );
      printf("%s %d/%d   ",hostname , count->current , count->target);
    }
    printf("\n");
    hash_iter_free( iter );
  }
}
Пример #20
0
void update_pool_status( bool *all_blocked , int * pending) {
  int i;
  int pend_count   = 0;
  *all_blocked = true;

  for (i=0; i < vector_get_size( job_pool ); i++) {
    block_job_type * job = vector_iget( job_pool , i );
    update_job_status( job );

    if (!job->running)
      pend_count++;
  }

  {
    hash_iter_type * iter = hash_iter_alloc( nodes );
    while (!hash_iter_is_complete( iter )) {
      const char * hostname = hash_iter_get_next_key( iter );
      const count_pair_type * count = hash_get( nodes , hostname );
      if (count->current < count->target)
        *all_blocked = false;
    }
  }
  *pending = pend_count;
}
Пример #21
0
const char * set_iter_get_next_key(set_iter_type * set_iter)
{
  return hash_iter_get_next_key(set_iter->hash_iter);
}
Пример #22
0
void site_config_fprintf_config( const site_config_type * site_config , FILE * stream ) {
  fprintf( stream , CONFIG_COMMENTLINE_FORMAT );
  fprintf( stream , CONFIG_COMMENT_FORMAT , "Here comes system related information - which typically");
  fprintf( stream , CONFIG_COMMENT_FORMAT , "overrides information from the site-wide configuration file.");
  /* Starting with the user defined jobs. */
  {
    stringlist_type * joblist = ext_joblist_alloc_list( site_config->joblist );
    char * fmt_key     = util_alloc_sprintf(CONFIG_KEY_FORMAT , INSTALL_JOB_KEY);
    char * install_fmt = util_alloc_sprintf("%s%s%s" , fmt_key , CONFIG_VALUE_FORMAT , CONFIG_ENDVALUE_FORMAT);
    
    for (int i=0; i < stringlist_get_size( joblist ); i++) {
      ext_job_type * ext_job = ext_joblist_get_job( site_config->joblist ,stringlist_iget( joblist , i ));
      if (ext_job_is_private( ext_job ))
        ext_job_fprintf_config( ext_job , install_fmt , stream );
      
    }
    
    free( install_fmt );
    free( fmt_key );
  }

  
  /* Storing the env variables set with SETENV */
  {
    hash_iter_type * iter = hash_iter_alloc( site_config->env_variables_user );
    while (!hash_iter_is_complete( iter )) {
      const char * var        = hash_iter_get_next_key( iter );
      const char * user_value = hash_get( site_config->env_variables_user , var );
      const char * site_value = hash_safe_get( site_config->env_variables_site , var );
      
      if (!util_string_equal( user_value , site_value)) {
        fprintf(stream , CONFIG_KEY_FORMAT      , SETENV_KEY );
        fprintf(stream , CONFIG_VALUE_FORMAT    , var );
        fprintf(stream , CONFIG_ENDVALUE_FORMAT , user_value );
      }
    }
  }

  /* Storing the driver type setting: */
  if ( site_config->driver_type != site_config->driver_type_site) {
    fprintf(stream , CONFIG_KEY_FORMAT , QUEUE_SYSTEM_KEY );
    fprintf(stream , CONFIG_ENDVALUE_FORMAT , site_config_get_queue_name( site_config ));
  }
  
  /* Storing UMASK setting */
  if ( site_config->umask != site_config->umask_site) {
    fprintf(stream , CONFIG_KEY_FORMAT , UMASK_KEY );
    fprintf(stream , "%o\n" , site_config->umask );
  }

  /* Storing MAX_SUBMIT setting */
  if ( site_config->max_submit != site_config->max_submit_site) {
    fprintf(stream , CONFIG_KEY_FORMAT , MAX_SUBMIT_KEY );
    fprintf(stream , "%d\n" , site_config->max_submit );
  }
  
  /* Storing LICENSE_ROOT_PATH */
  if (!util_string_equal( site_config->license_root_path , site_config->license_root_path_site)) {
    fprintf(stream , CONFIG_KEY_FORMAT      , LICENSE_PATH_KEY );
    fprintf(stream , CONFIG_ENDVALUE_FORMAT , site_config->license_root_path);
  }

  /* Storing jobscript */
  if (!util_string_equal( site_config->job_script , site_config->job_script_site)) {
    fprintf(stream , CONFIG_KEY_FORMAT      , LICENSE_PATH_KEY );
    fprintf(stream , CONFIG_ENDVALUE_FORMAT , site_config->job_script);
  }

  /* Storing local settings. */
  if (site_config_get_max_running_local(site_config) != site_config->max_running_local_site) {
    fprintf(stream , CONFIG_KEY_FORMAT , MAX_RUNNING_LOCAL_KEY );
    fprintf(stream , CONFIG_INT_FORMAT , site_config_get_max_running_local( site_config ));
    fprintf( stream , "\n");
  }

  /* Storing LSF settings. */
  {
    if (site_config_get_max_running_lsf( site_config ) != site_config->max_running_lsf_site) {
      fprintf(stream , CONFIG_KEY_FORMAT , MAX_RUNNING_LSF_KEY );
      fprintf(stream , CONFIG_INT_FORMAT , site_config_get_max_running_lsf( site_config ));
      fprintf( stream , "\n");
    } 
    
    if (!util_string_equal( site_config_get_lsf_queue(site_config) , site_config->lsf_queue_name_site)) {
      fprintf(stream , CONFIG_KEY_FORMAT      , LSF_QUEUE_KEY );
      fprintf(stream , CONFIG_ENDVALUE_FORMAT , site_config_get_lsf_queue( site_config ));
    }

    if (!util_string_equal( site_config_get_lsf_request( site_config ) , site_config->lsf_request_site)) {
      fprintf(stream , CONFIG_KEY_FORMAT      , LSF_RESOURCES_KEY );
      fprintf(stream , CONFIG_ENDVALUE_FORMAT , site_config_get_lsf_request( site_config ));
    }
  }

  
  /* Storing RSH settings. */
  {
    if (site_config_get_max_running_rsh(site_config) != site_config->max_running_rsh_site) {
      fprintf(stream , CONFIG_KEY_FORMAT , MAX_RUNNING_RSH_KEY );
      fprintf(stream , CONFIG_INT_FORMAT , site_config_get_max_running_rsh( site_config ));
      fprintf( stream , "\n");
    }
    
    if (!util_string_equal( site_config_get_rsh_command( site_config ) , site_config->rsh_command_site)) {
      fprintf(stream , CONFIG_KEY_FORMAT      , LICENSE_PATH_KEY );
      fprintf(stream , CONFIG_ENDVALUE_FORMAT , site_config_get_rsh_command( site_config ));
    }

    {
      queue_driver_type * rsh_driver = site_config_get_queue_driver( site_config , RSH_DRIVER_NAME );
      const hash_type * host_list = queue_driver_get_option( rsh_driver , RSH_HOSTLIST );
      hash_iter_type * iter = hash_iter_alloc( host_list );
      while (!hash_iter_is_complete( iter )) {
        const char * host_name = hash_iter_get_next_key( iter );
        fprintf(stream , CONFIG_KEY_FORMAT      , RSH_HOST_KEY );
        fprintf(stream , "%s:%d\n"  , host_name , hash_get_int( host_list , host_name));
      }
      hash_iter_free( iter );
    }
  }
  
  fprintf(stream , "\n\n");
}
Пример #23
0
void ecl_config_fprintf_config( const ecl_config_type * ecl_config , FILE * stream ) {
  fprintf( stream , CONFIG_COMMENTLINE_FORMAT );
  fprintf( stream , CONFIG_COMMENT_FORMAT , "Here comes configuration information related to the ECLIPSE model.");

  fprintf( stream , CONFIG_KEY_FORMAT      , DATA_FILE_KEY );
  fprintf( stream , CONFIG_ENDVALUE_FORMAT , ecl_config->data_file );
  
  fprintf( stream , CONFIG_KEY_FORMAT      , SCHEDULE_FILE_KEY );
  fprintf( stream , CONFIG_ENDVALUE_FORMAT , sched_file_iget_filename( ecl_config->sched_file , 0));

  fprintf( stream , CONFIG_KEY_FORMAT      , ECLBASE_KEY );
  fprintf( stream , CONFIG_ENDVALUE_FORMAT , path_fmt_get_fmt( ecl_config->eclbase ));

  if (ecl_config->include_all_static_kw) {
    fprintf( stream , CONFIG_KEY_FORMAT      , STATIC_KW_KEY );
    fprintf( stream , CONFIG_ENDVALUE_FORMAT , DEFAULT_ALL_STATIC_KW );
  }
  {
    int size = stringlist_get_size( ecl_config->user_static_kw );
    if (size > 0) {
      int i;
      fprintf( stream , CONFIG_KEY_FORMAT      , STATIC_KW_KEY );
      for (i=0; i < size; i++)
        if (i < (size -1 ))
          fprintf( stream , CONFIG_VALUE_FORMAT      , stringlist_iget( ecl_config->user_static_kw , i));
        else
          fprintf( stream , CONFIG_ENDVALUE_FORMAT      , stringlist_iget( ecl_config->user_static_kw , i));
    }
  }

  /*
    if (ecl_config->refcase != NULL) {
    fprintf( stream , CONFIG_KEY_FORMAT      , REFCASE_KEY );
    fprintf( stream , CONFIG_ENDVALUE_FORMAT , ecl_config_get_refcase_name( ecl_config ));
    }
  */

  if (ecl_config->grid != NULL) {
    fprintf( stream , CONFIG_KEY_FORMAT      , GRID_KEY );
    fprintf( stream , CONFIG_ENDVALUE_FORMAT , ecl_config_get_gridfile( ecl_config ));
  }

  if (ecl_config->schedule_prediction_file != NULL) {
    fprintf( stream , CONFIG_KEY_FORMAT      , SCHEDULE_PREDICTION_FILE_KEY );
    fprintf( stream , CONFIG_ENDVALUE_FORMAT , ecl_config_get_schedule_prediction_file( ecl_config ));
  }
  
  if (ecl_config->init_section != NULL) {
    fprintf( stream , CONFIG_KEY_FORMAT      , INIT_SECTION_KEY );
    fprintf( stream , CONFIG_ENDVALUE_FORMAT , ecl_config_get_init_section( ecl_config ));
  }

  
  {
    hash_iter_type * iter = hash_iter_alloc( ecl_config->fixed_length_kw );
    while (!hash_iter_is_complete( iter )) {
      const char  * kw  = hash_iter_get_next_key( iter );
      int   length      = hash_get_int( ecl_config->fixed_length_kw , kw); 

      fprintf( stream , CONFIG_KEY_FORMAT    , ADD_FIXED_LENGTH_SCHEDULE_KW_KEY );
      fprintf( stream , CONFIG_VALUE_FORMAT  , kw );
      fprintf( stream , CONFIG_INT_FORMAT    , length );
      fprintf( stream , "\n");
      
    }
    hash_iter_free( iter );
  }

  
  
  fprintf(stream , "\n\n");
}
Пример #24
0
void sched_history_install_index( sched_history_type * sched_history ) {
  /*1: Installing well based keys like WOPRH. */
  {
    hash_iter_type * well_iter = hash_iter_alloc( sched_history->well_history );
    while (!hash_iter_is_complete( well_iter )) {
      const char * well_name         = hash_iter_get_next_key( well_iter );
      const well_history_type * well = hash_get( sched_history->well_history , well_name );
      
      /* WOPR */
      {
        well_index_type * well_index = well_index_alloc( well_name , "WOPRH" , well , WCONHIST , wconhist_state_iget_WOPRH );
        sched_history_install_well_index( sched_history , well_index , VAR_LIST("WOPR" , "WOPRH") , well_name);
      }
      
      
      /* WGPR */
      {
        well_index_type * well_index = well_index_alloc( well_name , "WGPRH" , well , WCONHIST , wconhist_state_iget_WGPRH );
        sched_history_install_well_index( sched_history , well_index , VAR_LIST("WGPR" , "WGPRH") , well_name);
      }
      
      
      /* WWPR */
      {
        well_index_type * well_index = well_index_alloc( well_name , "WWPRH" , well , WCONHIST , wconhist_state_iget_WWPRH );
        sched_history_install_well_index( sched_history , well_index , VAR_LIST("WWPR" , "WWPRH") , well_name);
      }
      
      
      /* WWCT */
      {
        well_index_type * well_index = well_index_alloc( well_name , "WWCTH" , well , WCONHIST , wconhist_state_iget_WWCTH );
        sched_history_install_well_index( sched_history , well_index , VAR_LIST("WWCT" , "WWCTH") , well_name);
      }

      /* WGOR */
      {
        well_index_type * well_index = well_index_alloc( well_name , "WGORH" , well , WCONHIST , wconhist_state_iget_WGORH );
        sched_history_install_well_index( sched_history , well_index , VAR_LIST("WGOR" , "WGORH") , well_name);
      }

      /* WGPT */
      {
        well_index_type * well_index = well_index_alloc( well_name , "WGPTH" , well , WCONHIST , wconhist_state_iget_WGPTH );
        sched_history_install_well_index( sched_history , well_index , VAR_LIST("WGPT" , "WGPTH") , well_name);
      }

      /* WOPT */
      {
        well_index_type * well_index = well_index_alloc( well_name , "WOPTH" , well , WCONHIST , wconhist_state_iget_WOPTH );
        sched_history_install_well_index( sched_history , well_index , VAR_LIST("WOPT" , "WOPTH") , well_name);
      }
      
      /* WWPT */
      {
        well_index_type * well_index = well_index_alloc( well_name , "WWPTH" , well , WCONHIST , wconhist_state_iget_WWPTH );
        sched_history_install_well_index( sched_history , well_index , VAR_LIST("WWPT" , "WWPTH") , well_name);
      }

      /* STAT */
      {
        well_index_type * well_index = well_index_alloc( well_name , "STAT" , well , WCONHIST , wconhist_state_iget_STAT );
        sched_history_install_well_index( sched_history , well_index , VAR_LIST("STAT" ) , well_name);
      }

      
      /* WWIRH - this can be got from _either_ the WCONINJH keyowrord
         or the WCONINJE keyword (provided the latter is in rate
         controlled mode. ) */
      {
        well_index_type * well_index = well_index_alloc( well_name , "WWIRH" , well , WCONINJH , wconinjh_state_iget_WWIRH );   /* The first type */
        well_index_add_type( well_index , WCONINJE , wconinje_state_iget_WWIRH );                         /* The second type */
        sched_history_install_well_index( sched_history , well_index , VAR_LIST("WWIRH" , "WWIR") , well_name);
      }
      
      /* WGIRH - this can be got from _either_ the WCONINJH keyowrord
         or the WCONINJE keyword (provided the latter is in rate
         controlled mode. ) */
      {
        well_index_type * well_index = well_index_alloc( well_name , "WGIRH" , well , WCONINJH , wconinjh_state_iget_WGIRH );   /* The first type */
        well_index_add_type( well_index , WCONINJE , wconinje_state_iget_WGIRH );                         /* The second type */
        sched_history_install_well_index( sched_history , well_index , VAR_LIST("WGIRH" , "WGIR") , well_name);
      }
    }
    hash_iter_free( well_iter );
  }



  /*2: Installing group based indices */
  {
    hash_iter_type * group_iter = hash_iter_alloc( sched_history->group_history );
    while (!hash_iter_is_complete( group_iter )) {
      const char * group_name          = hash_iter_get_next_key( group_iter );
      const group_history_type * group = hash_get( sched_history->group_history , group_name );
      
      /* GOPR */
      {
        group_index_type * group_index = group_index_alloc( group_name , "GOPRH" , group , group_history_iget_GOPRH );
        sched_history_install_group_index( sched_history , group_index , VAR_LIST("GOPR" , "GOPRH") , group_name);
      }

      /* GGPR */
      {
        group_index_type * group_index = group_index_alloc( group_name , "GGPRH" , group , group_history_iget_GGPRH );
        sched_history_install_group_index( sched_history , group_index , VAR_LIST("GGPR" , "GGPRH") , group_name);
      }

      /* GWPR */
      {
        group_index_type * group_index = group_index_alloc( group_name , "GWPRH" , group , group_history_iget_GWPRH );
        sched_history_install_group_index( sched_history , group_index , VAR_LIST("GWPR" , "GWPRH") , group_name);
      }

      /* GWCT */
      {
        group_index_type * group_index = group_index_alloc( group_name , "GWCTH" , group , group_history_iget_GWCTH );
        sched_history_install_group_index( sched_history , group_index , VAR_LIST("GWCT" , "GWCTH") , group_name);
      }

      /* GGOR */
      {
        group_index_type * group_index = group_index_alloc( group_name , "GGORH" , group , group_history_iget_GGORH );
        sched_history_install_group_index( sched_history , group_index , VAR_LIST("GGOR" , "GGORH") , group_name);
      }

      /* GOPT */
      {
        group_index_type * group_index = group_index_alloc( group_name , "GOPTH" , group , group_history_iget_GOPTH );
        sched_history_install_group_index( sched_history , group_index , VAR_LIST("GOPT" , "GOPTH") , group_name);
      }

      /* GGPT */
      {
        group_index_type * group_index = group_index_alloc( group_name , "GGPTH" , group , group_history_iget_GGPTH );
        sched_history_install_group_index( sched_history , group_index , VAR_LIST("GGPT" , "GGPTH") , group_name);
      }
      
      /* GWPT */
      {
        group_index_type * group_index = group_index_alloc( group_name , "GWPTH" , group , group_history_iget_GWPTH );
        sched_history_install_group_index( sched_history , group_index , VAR_LIST("GWPT" , "GWPTH") , group_name);
      }
    }
    hash_iter_free( group_iter );
  }


  /*3: Installing field based indices (which is just an alias to the FIELD group); */
  {
    const group_history_type * group = hash_get( sched_history->group_history , FIELD_GROUP );
    const char * group_name          = FIELD_GROUP;
    
    /* FWPRH */
    {
      group_index_type * group_index   = group_index_alloc( group_name , "GWPRH" , group , group_history_iget_GWPRH );
      hash_insert_hash_owned_ref( sched_history->index , "FWPRH" , group_index , group_index_free__ );
      hash_insert_ref( sched_history->index , "FWPR" , group_index);
    }

    /* FOPRH */
    {
      group_index_type * group_index   = group_index_alloc( group_name , "GOPRH" , group , group_history_iget_GOPRH );
      hash_insert_hash_owned_ref( sched_history->index , "FOPRH" , group_index , group_index_free__ );
      hash_insert_ref( sched_history->index , "FOPR" , group_index);
    }

    /* FGPRH */
    {
      group_index_type * group_index   = group_index_alloc( group_name , "GGPRH" , group , group_history_iget_GGPRH );
      hash_insert_hash_owned_ref( sched_history->index , "FGPRH" , group_index , group_index_free__ );
      hash_insert_ref( sched_history->index , "FGPR" , group_index);
    }

    /* FWPTH */
    {
      group_index_type * group_index   = group_index_alloc( group_name , "GWPTH" , group , group_history_iget_GWPTH );
      hash_insert_hash_owned_ref( sched_history->index , "FWPTH" , group_index , group_index_free__ );
      hash_insert_ref( sched_history->index , "FWPT" , group_index);
    }

    /* FOPTH */
    {
      group_index_type * group_index   = group_index_alloc( group_name , "GOPTH" , group , group_history_iget_GOPTH );
      hash_insert_hash_owned_ref( sched_history->index , "FOPTH" , group_index , group_index_free__ );
      hash_insert_ref( sched_history->index , "FOPT" , group_index);
    }

    /* FGPTH */
    {
      group_index_type * group_index   = group_index_alloc( group_name , "GGPTH" , group , group_history_iget_GGPTH );
      hash_insert_hash_owned_ref( sched_history->index , "FGPTH" , group_index , group_index_free__ );
      hash_insert_ref( sched_history->index , "FGPT" , group_index);
    }

    /* FGORH */
    {
      group_index_type * group_index   = group_index_alloc( group_name , "GGORH" , group , group_history_iget_GGORH );
      hash_insert_hash_owned_ref( sched_history->index , "FGORH" , group_index , group_index_free__ );
      hash_insert_ref( sched_history->index , "FGOR" , group_index);
    }

    /* FWCTH */
    {
      group_index_type * group_index   = group_index_alloc( group_name , "GWCTH" , group , group_history_iget_GWCTH );
      hash_insert_hash_owned_ref( sched_history->index , "FWCTH" , group_index , group_index_free__ );
      hash_insert_ref( sched_history->index , "FWCT" , group_index);
    }
  }
}