Beispiel #1
0
void site_config_init_env(site_config_type * site_config, const config_type * config) {
  {
    config_content_item_type * setenv_item = config_get_content_item(config, SETENV_KEY);
    if (setenv_item != NULL) {
      int i;
      for (i = 0; i < config_content_item_get_size(setenv_item); i++) {
        const config_content_node_type * setenv_node = config_content_item_iget_node(setenv_item, i);
        const char * var = config_content_node_iget(setenv_node, 0);
        const char * value = config_content_node_iget(setenv_node, 1);

        site_config_setenv(site_config, var, value);
      }
    }
  }

  {
    config_content_item_type * path_item = config_get_content_item(config, UPDATE_PATH_KEY);
    if (path_item != NULL) {
      int i;
      for (i = 0; i < config_content_item_get_size(path_item); i++) {
        const config_content_node_type * path_node = config_content_item_iget_node(path_item, i);
        const char * path = config_content_node_iget(path_node, 0);
        const char * value = config_content_node_iget(path_node, 1);

        site_config_update_pathvar(site_config, path, value);
      }
    }
  }
}
Beispiel #2
0
void ensemble_config_init_SUMMARY( ensemble_config_type * ensemble_config , const config_type * config , const ecl_sum_type * refcase) {
  const config_content_item_type * item = config_get_content_item( config , SUMMARY_KEY );

  if (item != NULL) {
    int i;
    for (i=0; i < config_content_item_get_size( item ); i++) {
      const 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 * key = config_content_node_iget( node , j );
        
        if (util_string_has_wildcard( key )) {
          if (ensemble_config->refcase != NULL) {
            int k;
            stringlist_type * keys = stringlist_alloc_new ( );

            ecl_sum_select_matching_general_var_list( ensemble_config->refcase , key , keys );   /* expanding the wildcard notatition with help of the refcase. */
            for (k=0; k < stringlist_get_size( keys ); k++) 
              ensemble_config_add_summary(ensemble_config , stringlist_iget(keys , k) , LOAD_FAIL_SILENT );

            stringlist_free( keys );
          } else
            util_exit("error: when using summary wildcards like: \"%s\" you must supply a valid refcase.\n",key);
        } else 
          ensemble_config_add_summary(ensemble_config , key , LOAD_FAIL_SILENT);
      }
    }
  }
}
Beispiel #3
0
void ecl_config_static_kw_init( ecl_config_type * ecl_config , const config_type * config ) {
  const config_content_item_type * content_item = config_get_content_item( config , STATIC_KW_KEY );
  if (content_item != NULL) {
    int j;
    for (j=0; j < config_content_item_get_size( content_item ); j++) {
      const config_content_node_type * content_node = config_content_item_iget_node( content_item , j);
      int k;
      for (k = 0; k < config_content_node_get_size( content_node ); k++)
        ecl_config_add_static_kw(ecl_config , config_content_node_iget( content_node , k ));
    }
  }
}
Beispiel #4
0
void ensemble_config_init_GEN_PARAM( ensemble_config_type * ensemble_config , const config_type * config) {
  /* gen_param  - should be unified with the gen_data*/
  const config_content_item_type * item = config_get_content_item( config , GEN_PARAM_KEY );
  if (item != NULL) {
    for (int i=0; i < config_content_item_get_size(item); i++) {
      const config_content_node_type * node = config_content_item_iget_node( item , i );
      enkf_config_node_type * config_node = enkf_config_node_alloc_GEN_PARAM_from_config( node );
      if (config_node)
        ensemble_config_add_node( ensemble_config , config_node );
      
    }
  }
}
Beispiel #5
0
void ensemble_config_init_GEN_DATA( ensemble_config_type * ensemble_config , const config_type * config) {
  const config_content_item_type * item = config_get_content_item( config , GEN_DATA_KEY );
  if (item != NULL) {
    int i;
    for (i=0; i < config_content_item_get_size(item); i++) {
      const config_content_node_type * node = config_content_item_iget_node( item , i );
      enkf_config_node_type * config_node = enkf_config_node_alloc_GEN_DATA_from_config( node );
      if (config_node)
        ensemble_config_add_node( ensemble_config , config_node );
      
    }
  }
}
Beispiel #6
0
static void site_config_add_jobs(site_config_type * site_config, const config_type * config) {
  if (config_item_set(config, INSTALL_JOB_KEY)) {
    const config_content_item_type * content_item = config_get_content_item(config, INSTALL_JOB_KEY);
    int num_jobs = config_content_item_get_size(content_item);
    for (int job_nr = 0; job_nr < num_jobs; job_nr++) {
      config_content_node_type * node = config_content_item_iget_node(content_item, job_nr);
      const char * job_key = config_content_node_iget(node, 0);
      const char * description_file = config_content_node_iget_as_abspath(node, 1);

      site_config_install_job(site_config, job_key, description_file);
    }
  }
}
Beispiel #7
0
void ensemble_config_init_SURFACE( ensemble_config_type * ensemble_config , const config_type * config ) {
  const config_content_item_type * item = config_get_content_item( config , SURFACE_KEY );
  if (item != NULL) {
    int i;
    for (i=0; i < config_content_item_get_size( item ); i++) {
      const config_content_node_type * node = config_content_item_iget_node( item , i );
      const char * key           = config_content_node_iget( node , 0 );
      {
        hash_type * options = hash_alloc();  /* INIT_FILE:<init_files>  OUTPUT_FILE:<outfile>  BASE_SURFACE:<base_file> */
        
        config_content_node_init_opt_hash( node , options , 1 );
        {
          const char * init_file_fmt   = hash_safe_get( options , INIT_FILES_KEY );
          const char * output_file     = hash_safe_get( options , OUTPUT_FILE_KEY);
          const char * base_surface    = hash_safe_get( options , BASE_SURFACE_KEY);
          const char * min_std_file    = hash_safe_get( options , MIN_STD_KEY);
          const char *  forward_string = hash_safe_get( options , FORWARD_INIT_KEY );
          bool forward_init = false;
          
          if (forward_string) {
            if (!util_sscanf_bool( forward_string , &forward_init))
              fprintf(stderr,"** Warning: parsing %s as bool failed - using FALSE \n",forward_string);
          }
          
          if ((init_file_fmt == NULL) || (output_file == NULL) || (base_surface == NULL)) {
            fprintf(stderr,"** error: when entering a surface you must provide arguments:\n");
            fprintf(stderr,"**   %s:/path/to/input/files%%d  \n",INIT_FILES_KEY);
            fprintf(stderr,"**   %s:name_of_output_file\n", OUTPUT_FILE_KEY);
            fprintf(stderr,"**   %s:base_surface_file\n",BASE_SURFACE_KEY);
            exit(1);
          }
        
          {
            enkf_config_node_type * config_node = ensemble_config_add_surface( ensemble_config , key , forward_init);
            enkf_config_node_update_surface( config_node , base_surface , init_file_fmt , output_file , min_std_file );
          }
        }
        hash_free( options );
      }
    }
  }
}
Beispiel #8
0
void ensemble_config_init_GEN_KW( ensemble_config_type * ensemble_config , const config_type * config ) {
  const config_content_item_type * gen_kw_item = config_get_content_item( config , GEN_KW_KEY );
  if (gen_kw_item != NULL) {
    int i;
    for (i=0; i < config_content_item_get_size( gen_kw_item ); i++) {
      config_content_node_type * node = config_content_item_iget_node( gen_kw_item , i );

      const char * key             = config_content_node_iget( node , 0 );
      const char * template_file   = config_content_node_iget_as_path( node , 1 );
      const char * enkf_outfile    = config_content_node_iget( node , 2 );
      const char * parameter_file  = config_content_node_iget_as_path( node , 3 );
      hash_type * opt_hash         = hash_alloc();

      config_content_node_init_opt_hash( node , opt_hash , 4 );
      {
        const char *  forward_string = hash_safe_get( opt_hash , FORWARD_INIT_KEY );
        enkf_config_node_type * config_node;
        bool forward_init = false;
        
        if (forward_string) {
          if (!util_sscanf_bool( forward_string , &forward_init))
            fprintf(stderr,"** Warning: parsing %s as bool failed - using FALSE \n",forward_string);
        }
        
        config_node = ensemble_config_add_gen_kw( ensemble_config , key , forward_init);
        enkf_config_node_update_gen_kw( config_node , 
                                        enkf_outfile , 
                                        template_file , 
                                        parameter_file , 
                                        hash_safe_get( opt_hash , MIN_STD_KEY ) , 
                                        hash_safe_get( opt_hash , INIT_FILES_KEY));
      }
      hash_free( opt_hash );
    }
  }
}
Beispiel #9
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 #10
0
void ensemble_config_init_FIELD( ensemble_config_type * ensemble_config , const config_type * config , ecl_grid_type * grid) {
  const config_content_item_type * item = config_get_content_item( config , FIELD_KEY );
  if (item != NULL) {
    int i;
    for (i=0; i < config_content_item_get_size( item ); i++) {
      const config_content_node_type * node = config_content_item_iget_node( item , i );
      const char *  key                     = config_content_node_iget( node , 0 );
      const char *  var_type_string         = config_content_node_iget( node , 1 );
      enkf_config_node_type * config_node;
      
      {
        hash_type * options = hash_alloc();
        
        int    truncation = TRUNCATE_NONE;
        double value_min  = -1;
        double value_max  = -1;
        
        config_content_node_init_opt_hash( node , options , 2 );
        if (hash_has_key( options , MIN_KEY)) {
          truncation |= TRUNCATE_MIN;
          value_min   = atof(hash_get( options , MIN_KEY));
        }

        if (hash_has_key( options , MAX_KEY)) {
          truncation |= TRUNCATE_MAX;
          value_max   = atof(hash_get( options , MAX_KEY));
        }
        
        
        if (strcmp(var_type_string , DYNAMIC_KEY) == 0) {
          config_node = ensemble_config_add_field( ensemble_config , key , grid , false);
          enkf_config_node_update_state_field( config_node , truncation , value_min , value_max );
        } else if (strcmp(var_type_string , PARAMETER_KEY) == 0) {
          const char *  ecl_file          = config_content_node_iget( node , 2 );
          const char *  init_file_fmt     = hash_safe_get( options , INIT_FILES_KEY );
          const char *  init_transform    = hash_safe_get( options , INIT_TRANSFORM_KEY );
          const char *  output_transform  = hash_safe_get( options , OUTPUT_TRANSFORM_KEY );
          const char *  min_std_file      = hash_safe_get( options , MIN_STD_KEY );
          const char *  forward_string    = hash_safe_get( options , FORWARD_INIT_KEY );
          bool forward_init = false;

          if (forward_string) {
            if (!util_sscanf_bool( forward_string , &forward_init))
              fprintf(stderr,"** Warning: parsing %s as bool failed - using FALSE \n",forward_string);
          }
          config_node = ensemble_config_add_field( ensemble_config , key , grid , forward_init);
          enkf_config_node_update_parameter_field( config_node, 
                                                   ecl_file          , 
                                                   init_file_fmt     , 
                                                   min_std_file      , 
                                                   truncation        , 
                                                   value_min         , 
                                                   value_max         ,    
                                                   init_transform    , 
                                                   output_transform   );
        } else if (strcmp(var_type_string , GENERAL_KEY) == 0) {
          /* General - not really interesting .. */
          const char *  ecl_file          = config_content_node_iget( node , 2 );
          const char *  enkf_infile       = config_content_node_iget( node , 3 );
          const char *  init_file_fmt     = hash_safe_get( options , INIT_FILES_KEY );
          const char *  init_transform    = hash_safe_get( options , INIT_TRANSFORM_KEY );
          const char *  output_transform  = hash_safe_get( options , OUTPUT_TRANSFORM_KEY );
          const char *  input_transform   = hash_safe_get( options , INPUT_TRANSFORM_KEY );
          const char *  min_std_file      = hash_safe_get( options , MIN_STD_KEY );
          const char *  forward_string    = hash_safe_get( options , FORWARD_INIT_KEY );
          bool forward_init = false;

          if (forward_string) {
            if (!util_sscanf_bool( forward_string , &forward_init))
              fprintf(stderr,"** Warning: parsing %s as bool failed - using FALSE \n",forward_string);
          }
          
          config_node = ensemble_config_add_field( ensemble_config , key , grid , forward_init);
          enkf_config_node_update_general_field( config_node,
                                                 ecl_file , 
                                                 enkf_infile , 
                                                 init_file_fmt , 
                                                 min_std_file , 
                                                 truncation , value_min , value_max , 
                                                 init_transform , 
                                                 input_transform , 
                                                 output_transform);

          
        } else 
          util_abort("%s: field type: %s is not recognized\n",__func__ , var_type_string);
        
        hash_free( options );
      }
    }
  }
}
Beispiel #11
0
bool site_config_init(site_config_type * site_config, const config_type * config) {
  site_config_add_jobs(site_config, config);
  site_config_init_env(site_config, config);

  /* 
     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_get_value(config, UMASK_KEY);
    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_get_value(config, LSF_QUEUE_KEY));

    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_get_value_as_int(config, MAX_RUNNING_LSF_KEY));

    if (config_item_set(config, LSF_SERVER_KEY))
      site_config_set_lsf_server(site_config, config_get_value(config, LSF_SERVER_KEY));
  }


  /* RSH options */
  {
    if (config_item_set(config, RSH_COMMAND_KEY))
      site_config_set_rsh_command(site_config, config_get_value(config, RSH_COMMAND_KEY));

    if (config_item_set(config, MAX_RUNNING_RSH_KEY))
      site_config_set_max_running_rsh(site_config, config_get_value_as_int(config, MAX_RUNNING_RSH_KEY));

    /* Parsing the "host1:4" strings. */
    {
      const config_content_item_type * rsh_host_item = config_get_content_item(config, RSH_HOST_KEY);
      if (rsh_host_item != NULL) {
        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_get_value(config, QUEUE_SYSTEM_KEY);
      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 if (strcmp(queue_system, TORQUE_DRIVER_NAME) == 0)
        driver_type = TORQUE_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_get_value_as_abspath(config, JOB_SCRIPT_KEY));

  if (config_item_set(config, LICENSE_PATH_KEY))
    site_config_set_license_root_path(site_config, config_get_value_as_abspath(config, LICENSE_PATH_KEY));

  site_config_install_job_queue(site_config);

  /* Setting QUEUE_OPTIONS */
  {
    int i;
    for (i = 0; i < config_get_occurences(config, QUEUE_OPTION_KEY); i++) {
      const 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);
    }
  }
  return true;
}