예제 #1
0
파일: hook_manager.c 프로젝트: Thif/ert-1
void hook_manager_init_hook( hook_manager_type * hook_manager , const config_content_type * config) {
  if (config_content_has_item( config , HOOK_WORKFLOW_KEY)) {
    const char * file_name = config_content_iget( config , HOOK_WORKFLOW_KEY, 0, 0 );
    char * workflow_name;
    util_alloc_file_components( file_name , NULL , &workflow_name , NULL );
    {
      workflow_type * workflow = ert_workflow_list_add_workflow( hook_manager->workflow_list , file_name , workflow_name);
      if (workflow != NULL) {
        ert_workflow_list_add_alias( hook_manager->workflow_list , workflow_name , HOOK_WORKFLOW_KEY );
        hook_workflow_set_workflow( hook_manager->hook_workflow , workflow);
      }
      hook_workflow_set_run_mode( hook_manager->hook_workflow , config_content_iget( config , HOOK_WORKFLOW_KEY, 0, 1 ));
    }
  }
}
예제 #2
0
파일: ensemble_config.c 프로젝트: chflo/ert
void ensemble_config_init(ensemble_config_type * ensemble_config , const config_content_type * config , ecl_grid_type * grid, const ecl_sum_type * refcase) {
  int i;
  ensemble_config_set_refcase( ensemble_config , refcase );

  if (config_content_has_item( config , GEN_KW_TAG_FORMAT_KEY)) {
    ensemble_config_set_gen_kw_format( ensemble_config , config_content_iget( config , GEN_KW_TAG_FORMAT_KEY , 0 , 0 ));
  }

  ensemble_config_init_GEN_PARAM( ensemble_config , config );
  ensemble_config_init_GEN_DATA( ensemble_config , config );
  ensemble_config_init_CUSTOM_KW(ensemble_config, config);
  ensemble_config_init_GEN_KW(ensemble_config , config );
  ensemble_config_init_SURFACE( ensemble_config , config );

  ensemble_config_init_SUMMARY( ensemble_config , config , refcase );

  ensemble_config_init_FIELD( ensemble_config , config , grid );


  /* Containers - this must come last, to ensure that the other nodes have been added. */
  {
    for (i=0; i < config_content_get_occurences(config , CONTAINER_KEY ); i++) {
      const stringlist_type * container_kw_list = config_content_iget_stringlist_ref(config , CONTAINER_KEY , i);
      const char * container_key = stringlist_iget( container_kw_list , 0 );
      enkf_config_node_type * container_node = ensemble_config_add_container( ensemble_config , container_key );

      for (int j= 1; j < stringlist_get_size( container_kw_list ); j++) {
        const char * child_key = stringlist_iget( container_kw_list , j);
        enkf_config_node_update_container( container_node , ensemble_config_get_node( ensemble_config , child_key ));
      }
    }
  }

  /*****************************************************************/
}
예제 #3
0
파일: ecl_config.c 프로젝트: Ensembles/ert
void ecl_config_init(ecl_config_type * ecl_config, const config_content_type * config)
{
  if (config_content_has_item(config, ECLBASE_KEY)) {
    ui_return_type * ui_return = ecl_config_validate_eclbase(ecl_config, config_content_iget(config, ECLBASE_KEY, 0, 0));
    if (ui_return_get_status(ui_return) == UI_RETURN_OK)
      ecl_config_set_eclbase(ecl_config, config_content_iget(config, ECLBASE_KEY, 0, 0));
    else
      util_abort("%s: failed to set eclbase format. Error:%s\n", __func__ , ui_return_get_last_error(ui_return));
    ui_return_free(ui_return);
  }

  if (config_content_has_item(config, DATA_FILE_KEY))
  {
    ui_return_type * ui_return = ecl_config_validate_data_file(ecl_config, config_content_iget(config, DATA_FILE_KEY, 0, 0));
    if (ui_return_get_status( ui_return ) == UI_RETURN_OK)
      ecl_config_set_data_file( ecl_config, config_content_iget(config, DATA_FILE_KEY, 0, 0) );
    else
      util_abort("%s: problem setting ECLIPSE data file\n",__func__ , ui_return_get_last_error(ui_return));

    ui_return_free(ui_return);
  }

  if (config_content_has_item(config, SCHEDULE_FILE_KEY)) {
    const char * schedule_target_file = config_content_safe_iget(config, SCHEDULE_FILE_KEY, 0, 1);
    if (schedule_target_file) {
      ui_return_type * ui_return_sched_target_file = ecl_config_validate_schedule_file(ecl_config, schedule_target_file);
      if (!ui_return_get_status(ui_return_sched_target_file) == UI_RETURN_OK) {
         util_abort("%s: failed to set target schedule file. Error:%s\n",__func__ , ui_return_get_last_error(ui_return_sched_target_file));
      }
      ui_return_free(ui_return_sched_target_file);
    }

    ui_return_type * ui_return = ecl_config_validate_schedule_file(ecl_config, config_content_iget(config, SCHEDULE_FILE_KEY, 0, 0));
    if (ui_return_get_status(ui_return) == UI_RETURN_OK)
      ecl_config_set_schedule_file(ecl_config, config_content_iget(config, SCHEDULE_FILE_KEY, 0, 0), schedule_target_file);
    else
      util_abort("%s: failed to set schedule file. Error:%s\n",__func__ , ui_return_get_last_error(ui_return));

    ui_return_free(ui_return);
  }

  if (config_content_has_item(config, GRID_KEY)) {
    const char * grid_file = config_content_iget(config, GRID_KEY, 0, 0);
    ui_return_type * ui_return = ecl_config_validate_grid( ecl_config , grid_file);
    if (ui_return_get_status(ui_return) == UI_RETURN_OK)
      ecl_config_set_grid(ecl_config, grid_file );
    else
      util_abort("%s: failed to set grid file:%s  Error:%s \n",__func__ , grid_file , ui_return_get_last_error(ui_return));

    ui_return_free( ui_return );
  }


  if (config_content_has_item(config, ADD_FIXED_LENGTH_SCHEDULE_KW_KEY))
  {
    int iocc;
    for (iocc = 0; iocc < config_content_get_occurences(config, ADD_FIXED_LENGTH_SCHEDULE_KW_KEY); iocc++)
      ecl_config_add_fixed_length_schedule_kw(ecl_config,
                                              config_content_iget(config, ADD_FIXED_LENGTH_SCHEDULE_KW_KEY, iocc, 0),
                                              config_content_iget_as_int(config, ADD_FIXED_LENGTH_SCHEDULE_KW_KEY, iocc, 1));
  }

  if (config_content_has_item(config, REFCASE_KEY))
  {
    const char * refcase_path = config_content_get_value_as_path(config, REFCASE_KEY);
    if (!ecl_config_load_refcase(ecl_config, refcase_path))
      fprintf(stderr, "** Warning: loading refcase:%s failed \n", refcase_path);
  }

  if (config_content_has_item(config, REFCASE_LIST_KEY))
  {
    config_content_item_type * item = config_content_get_item(config, REFCASE_LIST_KEY);
    int i;
    for (i = 0; i < config_content_item_get_size(item); i++)
    {
      config_content_node_type * node = config_content_item_iget_node(item, i);
      int j;
      for (j = 0; j < config_content_node_get_size(node); j++)
      {
        const char * case_glob = config_content_node_iget_as_path(node, j);
        ecl_refcase_list_add_matching(ecl_config->refcase_list, case_glob);
      }
    }
  }

  if (config_content_has_item(config, INIT_SECTION_KEY))
    ecl_config_set_init_section(ecl_config, config_content_get_value(config, INIT_SECTION_KEY));
  else if (ecl_config->can_restart)
    /**
     This is a hard error - the datafile contains <INIT>, however
     the config file does NOT contain INIT_SECTION, i.e. we have
     no information to fill in for the <INIT> section. This case
     will not be able to initialize an ECLIPSE model, and that is
     broken behaviour.
     */
    util_exit("Sorry: when the datafile contains <INIT> the config file MUST have the INIT_SECTION keyword. \n");

  /*
   The user has not supplied a INIT_SECTION keyword whatsoever,
   this essentially means that we can not restart - because:

   1. The EQUIL section must be inlined in the DATAFILE without any
   special markup.

   2. ECLIPSE will fail hard if the datafile contains both an EQUIL
   section and a restart statement, and when we have not marked
   the EQUIL section specially with the INIT_SECTION keyword it
   is impossible for ERT to dynamically change between a
   datafile with initialisation and a datafile for restart.

   IFF the user has no intentitions of any form of restart, this is
   perfectly legitemate.
   */
  if (config_content_has_item(config, END_DATE_KEY))
  {
    const char * date_string = config_content_get_value(config, END_DATE_KEY);
    time_t end_date;
    if (util_sscanf_date_utc(date_string, &end_date))
      ecl_config_set_end_date(ecl_config, end_date);
    else
      fprintf(stderr, "** WARNING **: Failed to parse %s as a date - should be in format dd/mm/yyyy \n", date_string);
  }
}