コード例 #1
0
ファイル: gen_data_config.c プロジェクト: danielfmva/ert
void gen_data_config_add_report_step( gen_data_config_type * config , int report_step) {
  if (config->dynamic) {
    if (!gen_data_config_has_report_step( config , report_step)) {
      int_vector_append( config->active_report_steps , report_step );
      int_vector_sort( config->active_report_steps );
    }
  }
}
コード例 #2
0
ファイル: obs_vector.c プロジェクト: Ensembles/ert
obs_vector_type * obs_vector_alloc_from_GENERAL_OBSERVATION(const conf_instance_type * conf_instance , time_map_type * obs_time , const ensemble_config_type * ensemble_config) {
  if(!conf_instance_is_of_class(conf_instance, "GENERAL_OBSERVATION"))
    util_abort("%s: internal error. expected \"GENERAL_OBSERVATION\" instance, got \"%s\".\n",
               __func__, conf_instance_get_class_name_ref(conf_instance) );
  const char * obs_key         = conf_instance_get_name_ref(conf_instance);
  const char * state_kw        = conf_instance_get_item_value_ref(   conf_instance, "DATA" );
  if (ensemble_config_has_key( ensemble_config , state_kw )) {
    const char * obs_key         = conf_instance_get_name_ref(conf_instance);
    int          obs_restart_nr   = __conf_instance_get_restart_nr(conf_instance , obs_key , obs_time , true);
    const char * index_file       = NULL;
    const char * index_list       = NULL;
    const char * obs_file         = NULL;
    const char * error_covar_file = NULL;

    if (conf_instance_has_item(conf_instance , "INDEX_FILE"))
      index_file = conf_instance_get_item_value_ref(   conf_instance, "INDEX_FILE" );

    if (conf_instance_has_item(conf_instance , "INDEX_LIST"))
      index_list = conf_instance_get_item_value_ref(   conf_instance, "INDEX_LIST" );

    if (conf_instance_has_item(conf_instance , "OBS_FILE"))
      obs_file = conf_instance_get_item_value_ref(   conf_instance, "OBS_FILE" );

    if (conf_instance_has_item(conf_instance , "ERROR_COVAR"))
      error_covar_file = conf_instance_get_item_value_ref(   conf_instance, "ERROR_COVAR" );

    {
      obs_vector_type * obs_vector = NULL;
      const enkf_config_node_type * config_node  = ensemble_config_get_node( ensemble_config , state_kw);

      if (enkf_config_node_get_impl_type(config_node) == GEN_DATA) {
        double scalar_error = -1;
        double scalar_value = -1;
        gen_obs_type * gen_obs ;
        const gen_data_config_type * config = enkf_config_node_get_ref( config_node );

        if (gen_data_config_has_report_step( config , obs_restart_nr)) {
          obs_vector = obs_vector_alloc( GEN_OBS , obs_key , ensemble_config_get_node(ensemble_config , state_kw ), time_map_get_last_step( obs_time ));
          if (conf_instance_has_item(conf_instance , "VALUE")) {
            scalar_value = conf_instance_get_item_value_double(conf_instance , "VALUE");
            scalar_error = conf_instance_get_item_value_double(conf_instance , "ERROR");
          }

          /** The config system has ensured that we have either OBS_FILE or (VALUE and ERROR). */
          gen_obs = gen_obs_alloc( enkf_config_node_get_ref( config_node ) , obs_key , obs_file , scalar_value , scalar_error , index_file , index_list , error_covar_file);
          obs_vector_install_node( obs_vector , obs_restart_nr , gen_obs );
        } else
          fprintf(stderr,"** ERROR: The GEN_DATA node:%s is not configured to load from report step:%d - the observation:%s will be ignored\n", state_kw , obs_restart_nr , obs_key);
      } else {
        ert_impl_type impl_type = enkf_config_node_get_impl_type(config_node);
        fprintf(stderr,"** ERROR: %s: %s has implementation type:\'%s\' - expected:\'%s\' - observation:%s ignored.\n",
                __func__ , state_kw , enkf_types_get_impl_name(impl_type) , enkf_types_get_impl_name(GEN_DATA) , obs_key);
      }
      return obs_vector;

    }
  } else {
    fprintf(stderr,"** Warning the ensemble key:%s does not exist - observation:%s not added \n", state_kw , obs_key);
    return NULL;
  }
}