Beispiel #1
0
void rng_config_init( rng_config_type * rng_config , config_type * config ) {
    if (config_item_set( config , STORE_SEED_KEY ))
        rng_config_set_seed_store_file( rng_config , config_iget(config , STORE_SEED_KEY ,0,0));

    if (config_item_set( config , LOAD_SEED_KEY ))
        rng_config_set_seed_load_file( rng_config , config_iget(config , LOAD_SEED_KEY ,0,0));
}
Beispiel #2
0
void ensemble_config_init(ensemble_config_type * ensemble_config , const config_type * config , ecl_grid_type * grid, const ecl_sum_type * refcase) {
  int i;
  ensemble_config_set_refcase( ensemble_config , refcase );

  if (config_item_set( config , GEN_KW_TAG_FORMAT_KEY))
    ensemble_config_set_gen_kw_format( ensemble_config , config_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_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_get_occurences(config , CONTAINER_KEY ); i++) {
      const stringlist_type * container_kw_list = config_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 ));
      }
    }
  }

  /*****************************************************************/
}
Beispiel #3
0
void site_config_init(site_config_type * site_config , const config_type * config, bool user_config) {
  site_config_add_jobs(site_config , config);
  {
    int i;
    for (i = 0; i < config_get_occurences( config , SETENV_KEY); i++) {
      const stringlist_type * tokens = config_iget_stringlist_ref(config , SETENV_KEY , i);
      const char * var               = stringlist_iget( tokens , 0);
      const char * value             = stringlist_iget( tokens , 1);

      site_config_setenv( site_config , var , value );
    }
    
    for (i=0; i < config_get_occurences( config, UPDATE_PATH_KEY); i++) {
      const stringlist_type * tokens = config_iget_stringlist_ref(config , UPDATE_PATH_KEY , i);
      const char * path              = stringlist_iget( tokens , 0);
      const char * value             = stringlist_iget( tokens , 1);
      
      site_config_update_pathvar( site_config , path , value );
    }
  }
  /* 
     When LSF is used several enviroment variables must be set (by the
     site wide file) - i.e.  the calls to SETENV must come first.
  */
  if (!site_config->user_mode) 
    site_config_create_queue_drivers( site_config );   

  /* 
     Set the umask for all file creation. A value of '0' will ensure
     that all files and directories are created with 'equal rights'
     for everyone - might be handy if you are helping someone... The
     default statoil value is 0022, i.e. write access is removed from
     group and others.  

     The string is supposed to be in OCTAL representation (without any
     prefix characters).
  */
  if (config_item_set(config , UMASK_KEY)) {
    const char * string_mask = config_iget( config , UMASK_KEY , 0 , 0);
    mode_t umask_value;
    if (util_sscanf_octal_int( string_mask , &umask_value))
      site_config_set_umask( site_config , umask_value);
    else
      util_abort("%s: failed to parse:\"%s\" as a valid octal literal \n",__func__ , string_mask);
  }

  if (config_item_set(config , MAX_SUBMIT_KEY)) 
    site_config_set_max_submit( site_config , config_get_value_as_int( config , MAX_SUBMIT_KEY ));
  

  /* LSF options */
  {
    if (config_item_set(config , LSF_QUEUE_KEY))
      site_config_set_lsf_queue( site_config , config_iget( config , LSF_QUEUE_KEY , 0 , 0));
    
    if (config_item_set(config , LSF_RESOURCES_KEY)) {
      char * lsf_resource_request = config_alloc_joined_string(config , LSF_RESOURCES_KEY , " ");
      site_config_set_lsf_request( site_config , lsf_resource_request );
      free( lsf_resource_request );
    }
    
    if (config_item_set(config , MAX_RUNNING_LSF_KEY))
      site_config_set_max_running_lsf( site_config , config_iget_as_int( config , MAX_RUNNING_LSF_KEY , 0 , 0));

    if (config_item_set(config , LSF_SERVER_KEY))
      site_config_set_lsf_server( site_config , config_iget( config , LSF_SERVER_KEY , 0 , 0));
  }


  /* RSH options */
  {
    if (config_item_set( config , RSH_COMMAND_KEY ))
      site_config_set_rsh_command( site_config , config_iget(config , RSH_COMMAND_KEY , 0,0));
    
    if (config_item_set( config , MAX_RUNNING_RSH_KEY))
      site_config_set_max_running_rsh( site_config , config_iget_as_int( config , MAX_RUNNING_RSH_KEY , 0,0));

    /* Parsing the "host1:4" strings. */
    if (user_config) {
      if (config_item_set( config , RSH_HOST_KEY)) {
        stringlist_type * rsh_host_list = config_alloc_complete_stringlist(config , RSH_HOST_KEY);
        int i;
        for (i=0; i < stringlist_get_size( rsh_host_list ); i++) 
          site_config_add_rsh_host_from_string( site_config , stringlist_iget( rsh_host_list , i ) );
        
        stringlist_free( rsh_host_list );
      }
    }
  }

  if (config_item_set( config , QUEUE_SYSTEM_KEY)) {
    job_driver_type driver_type;
    {
      const char * queue_system = config_iget(config , QUEUE_SYSTEM_KEY , 0,0);
      if (strcmp(queue_system , LSF_DRIVER_NAME) == 0) {
        driver_type = LSF_DRIVER;
      } else if (strcmp(queue_system , RSH_DRIVER_NAME) == 0) 
        driver_type = RSH_DRIVER;
      else if (strcmp(queue_system , LOCAL_DRIVER_NAME) == 0) 
        driver_type = LOCAL_DRIVER;
      else {
        util_abort("%s: queue system :%s not recognized \n",__func__ , queue_system);
        driver_type = NULL_DRIVER;
      }
    }
    site_config_set_job_queue__( site_config , driver_type );
  }
  
  /* Parsing local options */
  if (config_item_set( config , MAX_RUNNING_LOCAL_KEY))
    site_config_set_max_running_local( site_config , config_iget_as_int( config , MAX_RUNNING_LOCAL_KEY , 0,0));

  if (config_item_set(config , JOB_SCRIPT_KEY))
    site_config_set_job_script( site_config , config_iget( config , JOB_SCRIPT_KEY , 0 , 0));
  
  if (config_item_set(config , LICENSE_PATH_KEY))
    site_config_set_license_root_path( site_config , config_iget( config , LICENSE_PATH_KEY , 0 , 0));
  
  if (user_config) 
    site_config_install_job_queue( site_config );
  
  /* Setting QUEUE_OPTIONS */
  { 
    int i;
    for (i=0; i < config_get_occurences(config , QUEUE_OPTION_KEY); i++) {
      stringlist_type * tokens   = config_iget_stringlist_ref(config , QUEUE_OPTION_KEY , i);
      const char * driver_name   = stringlist_iget( tokens , 0 );
      const char * option_key    = stringlist_iget( tokens , 1 );
      const char * option_value  = stringlist_alloc_joined_substring( tokens , 2 , stringlist_get_size( tokens ), " ");
      /* 
         If it is desirable to keep the exact number of spaces in the
         option_value it should be quoted with "" in the configuration
         file.
      */
      site_config_set_queue_option( site_config , driver_name , option_key , option_value );
    }
  }
}
Beispiel #4
0
void ecl_config_init( ecl_config_type * ecl_config , const config_type * config ) {
  if (config_item_set( config , ECLBASE_KEY ))
    ecl_config_set_eclbase( ecl_config , config_iget(config , ECLBASE_KEY ,0,0) );
  
  if (config_item_set( config , DATA_FILE_KEY ))
    ecl_config_set_data_file( ecl_config , config_iget( config , DATA_FILE_KEY ,0,0));
  
  if (config_item_set( config , SCHEDULE_FILE_KEY ))
    ecl_config_set_schedule_file( ecl_config , config_iget( config , SCHEDULE_FILE_KEY ,0,0));

  
  if (config_item_set(config , GRID_KEY))
    ecl_config_set_grid( ecl_config , config_iget(config , GRID_KEY , 0,0) );
  
  if (config_item_set( config , ADD_FIXED_LENGTH_SCHEDULE_KW_KEY)) {
    int iocc;
    for (iocc = 0; iocc < config_get_occurences(config , ADD_FIXED_LENGTH_SCHEDULE_KW_KEY); iocc++) 
      ecl_config_add_fixed_length_schedule_kw( ecl_config , 
                                               config_iget(config , ADD_FIXED_LENGTH_SCHEDULE_KW_KEY , iocc , 0) , 
                                               config_iget_as_int(config , ADD_FIXED_LENGTH_SCHEDULE_KW_KEY , iocc , 1));
  }
  
  
  if (config_item_set( config , REFCASE_KEY)) {
    const char * refcase_path = config_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_item_set( config , REFCASE_LIST_KEY)) {
    config_content_item_type * item = config_get_content_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 );
      }
    }
  }
  
  /* Deprecated */
  if (config_item_set( config , PLOT_REFCASE_LIST_KEY)) {
    const char * case_list_file = config_get_value( config , PLOT_REFCASE_LIST_KEY);
    FILE * stream = util_fopen(case_list_file , "r");
    bool at_eof;
    do {
      char * case_name = util_fscanf_alloc_line(stream , &at_eof);
      if (case_name) {
        ecl_refcase_list_add_case( ecl_config->refcase_list , case_name);
        free( case_name );
      }
    } while (!at_eof);
    
    fclose( stream );
  }
  
  if (config_item_set(config , INIT_SECTION_KEY)) 
    ecl_config_set_init_section( ecl_config , config_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_item_set( config , END_DATE_KEY )) {
    const char * date_string = config_get_value( config , END_DATE_KEY );
    time_t end_date;
    if (util_sscanf_date( 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);
  }
}
Beispiel #5
0
void model_config_init(model_config_type * model_config , 
                       const config_type * config , 
                       int ens_size , 
                       const ext_joblist_type * joblist , 
                       int last_history_restart , 
                       const sched_file_type * sched_file , 
                       const ecl_sum_type * refcase) {
  
  model_config->forward_model = forward_model_alloc(  joblist );
  model_config_set_refcase( model_config , refcase );
  

  if (config_item_set( config , FORWARD_MODEL_KEY )) {
    char * config_string = config_alloc_joined_string( config , FORWARD_MODEL_KEY , " ");
    forward_model_parse_init( model_config->forward_model , config_string );
    free(config_string);
  }

  if (config_item_set( config , ENKF_SCHED_FILE_KEY))
    model_config_set_enkf_sched_file(model_config , config_get_value(config , ENKF_SCHED_FILE_KEY ));
  
  if (config_item_set( config, RUNPATH_KEY)) {
    model_config_add_runpath( model_config , DEFAULT_RUNPATH_KEY , config_get_value(config , RUNPATH_KEY) );
    model_config_select_runpath( model_config , DEFAULT_RUNPATH_KEY );
  }

  {
    history_source_type source_type = DEFAULT_HISTORY_SOURCE;

    if (config_item_set( config , HISTORY_SOURCE_KEY)) {
      const char * history_source = config_iget(config , HISTORY_SOURCE_KEY, 0,0);
      source_type = history_get_source_type( history_source );
    }

    if (!model_config_select_history( model_config , source_type , sched_file , refcase ))
      if (!model_config_select_history( model_config , DEFAULT_HISTORY_SOURCE , sched_file , refcase ))
        if (!model_config_select_any_history( model_config , sched_file , refcase))
          fprintf(stderr,"** Warning:: Do not have enough information to select a history source \n");
    
  }
      


  if (model_config->history != NULL) {
    int num_restart = history_get_last_restart( model_config->history );
    bool_vector_iset( model_config->internalize_state , num_restart - 1 , false );
    bool_vector_iset( model_config->__load_state      , num_restart - 1 , false );
  }

  /*
    The full treatment of the SCHEDULE_PREDICTION_FILE keyword is in
    the ensemble_config file, because the functionality is implemented
    as (quite) plain GEN_KW instance. Here we just check if it is
    present or not.
  */
  
  if (config_item_set(config ,  SCHEDULE_PREDICTION_FILE_KEY)) 
    model_config->has_prediction = true;
  else
    model_config->has_prediction = false;


  if (config_item_set(config ,  CASE_TABLE_KEY)) 
    model_config_set_case_table( model_config , ens_size , config_iget( config , CASE_TABLE_KEY , 0,0));
  
  if (config_item_set( config , ENSPATH_KEY))
    model_config_set_enspath( model_config , config_get_value(config , ENSPATH_KEY));

  if (config_item_set( config , JOBNAME_KEY))
    model_config_set_jobname_fmt( model_config , config_get_value(config , JOBNAME_KEY));

  if (config_item_set( config , RFTPATH_KEY))
    model_config_set_rftpath( model_config , config_get_value(config , RFTPATH_KEY));
  
  if (config_item_set( config , DBASE_TYPE_KEY))
    model_config_set_dbase_type( model_config , config_get_value(config , DBASE_TYPE_KEY));
  
  if (config_item_set( config , MAX_RESAMPLE_KEY))
    model_config_set_max_internal_submit( model_config , config_get_value_as_int( config , MAX_RESAMPLE_KEY ));


  {
    const char * export_file_name;
    if (config_item_set( config , GEN_KW_EXPORT_FILE_KEY))
      export_file_name = config_get_value(config, GEN_KW_EXPORT_FILE_KEY);
    else
      export_file_name = DEFAULT_GEN_KW_EXPORT_FILE;

    model_config_set_gen_kw_export_file(model_config, export_file_name);
   }
  
}