Ejemplo n.º 1
0
static void field_config_set_init_transform( field_config_type * config , const char * __init_transform_name ) {
    const char * init_transform_name = NULL;
    if (field_trans_table_has_key( config->trans_table , __init_transform_name))
        init_transform_name = __init_transform_name;


    config->init_transform_name = util_realloc_string_copy( config->init_transform_name , init_transform_name );
    if (init_transform_name != NULL)
        config->init_transform = field_trans_table_lookup( config->trans_table , init_transform_name);
    else
        config->init_transform = NULL;
}
Ejemplo n.º 2
0
void ensemble_config_set_gen_kw_format( ensemble_config_type * ensemble_config , const char * gen_kw_format_string) {
  if (!util_string_equal( gen_kw_format_string , ensemble_config->gen_kw_format_string)) {
    stringlist_type * gen_kw_keys = ensemble_config_alloc_keylist_from_impl_type( ensemble_config , GEN_KW );
    int i;
    ensemble_config->gen_kw_format_string = util_realloc_string_copy( ensemble_config->gen_kw_format_string , gen_kw_format_string );
    for (i=0; i < stringlist_get_size( gen_kw_keys ); i++) {
      enkf_config_node_type * config_node = ensemble_config_get_node( ensemble_config , stringlist_iget( gen_kw_keys , i ));
      gen_kw_config_update_tag_format( enkf_config_node_get_ref( config_node ) , gen_kw_format_string );
    }
    stringlist_free( gen_kw_keys );
  }
}
Ejemplo n.º 3
0
bool model_config_select_runpath( model_config_type * model_config , const char * path_key) {
  if (hash_has_key( model_config->runpath_map , path_key )) {
    model_config->current_runpath = hash_get( model_config->runpath_map , path_key );
    model_config->current_path_key = util_realloc_string_copy( model_config->current_path_key , path_key);
    return true;
  } else {
    if (model_config->current_runpath != NULL)  // OK - we already have a valid selection - stick to that and return False.
      return false;
    else {
      util_abort("%s: path_key:%s does not exist - and currently no valid runpath selected \n",__func__ , path_key);
      return false;
    }
  }
}
Ejemplo n.º 4
0
static void field_config_set_output_transform( field_config_type * config , const char * __output_transform_name ) {
    const char * output_transform_name = NULL;
    if (field_trans_table_has_key( config->trans_table , __output_transform_name))
        output_transform_name = __output_transform_name;
    else if (__output_transform_name) {
        fprintf(stderr , "Sorry: the field transformation function:%s is not recognized \n\n",__output_transform_name);
        field_trans_table_fprintf(config->trans_table , stderr);
        util_exit("Exiting ... \n");
    }

    config->output_transform_name = util_realloc_string_copy( config->output_transform_name , output_transform_name );
    if (output_transform_name != NULL)
        config->output_transform = field_trans_table_lookup( config->trans_table , output_transform_name);
    else
        config->output_transform = NULL;
}
Ejemplo n.º 5
0
void enkf_config_node_update_min_std( enkf_config_node_type * config_node , const char * min_std_file ) {
  if (!util_string_equal( config_node->min_std_file , min_std_file )) {
    /* The current min_std_file and the new input are different, and
       the min_std node must be cleared. */
    if (config_node->min_std != NULL) {
      enkf_node_free( config_node->min_std );
      config_node->min_std = NULL;
      free( config_node->min_std_file );
    }
  }
  config_node->min_std_file = util_realloc_string_copy( config_node->min_std_file , min_std_file );
  if (config_node->min_std_file != NULL) {
    config_node->min_std = enkf_node_alloc( config_node );
    enkf_node_fload( config_node->min_std , min_std_file );
  }
}
Ejemplo n.º 6
0
void ecl_config_set_data_file( ecl_config_type * ecl_config , const char * data_file) {
  ecl_config->data_file = util_realloc_string_copy( ecl_config->data_file , data_file );
  {
    FILE * stream        = util_fopen( ecl_config->data_file , "r");
    parser_type * parser = parser_alloc(NULL , NULL , NULL , NULL , "--" , "\n" );
    char * init_tag      = enkf_util_alloc_tagged_string( "INIT" );
    
    ecl_config->can_restart = parser_fseek_string( parser , stream , init_tag , false , true ); 
    
    free( init_tag );
    parser_free( parser );
    fclose( stream );
  }
  ecl_config->start_date = ecl_util_get_start_date( ecl_config->data_file );
  ecl_config->num_cpu    = ecl_util_get_num_cpu( ecl_config->data_file );
}
Ejemplo n.º 7
0
/**
   input_value can be NULL. 
*/
static void subst_list_string_set_value(subst_list_string_type * node, const char * input_value , const char * doc_string , subst_insert_type insert_mode) {
  subst_list_string_free_content( node );
  {
    char * value;
    if (insert_mode == SUBST_DEEP_COPY)
      value = util_alloc_string_copy(input_value);
    else
      value = (char *) input_value;
    
    if (insert_mode == SUBST_SHARED_REF)
      node->value_owner = false;
    else
      node->value_owner = true;
    
    node->value = value;
  }
  
  if (doc_string != NULL)
    node->doc_string = util_realloc_string_copy( node->doc_string , doc_string );
}
Ejemplo n.º 8
0
void gen_kw_config_set_parameter_file( gen_kw_config_type * config , const char * parameter_file ) {
  config->parameter_file = util_realloc_string_copy( config->parameter_file , parameter_file );
  vector_clear( config->parameters );
  if (parameter_file != NULL) {
    FILE * stream = util_fopen(parameter_file , "r");
    
    while (true) {
      char parameter_name[256];
      int  fscanf_return;
      
      fscanf_return = fscanf(stream , "%s" , parameter_name);
      if (fscanf_return == 1) {
        gen_kw_parameter_type * parameter  = gen_kw_parameter_alloc( parameter_name , config->tag_fmt);
        trans_func_type       * trans_func = trans_func_fscanf_alloc( stream );
        gen_kw_parameter_set_trans_func( parameter , trans_func );

        vector_append_owned_ref( config->parameters , parameter , gen_kw_parameter_free__ );
      } else 
        break; /* OK - we are ate EOF. */
    } 
    
    fclose( stream );
  }
}
Ejemplo n.º 9
0
static void __print_helptext(char * label, int l) {
    bool end_reached = false;
    char * label_copy = util_alloc_string_copy( label );
    char * first_part = "Dummy3";
    char * second_part = "Dummy4";
    while(!end_reached) {
        int i;
        if(strlen(label_copy) > l) {
            util_binary_split_string_from_max_length(label_copy , " ", l , &first_part , &second_part);
            printf("|    %s",first_part);
            for (i=strlen(first_part); i < l; i++)
                fputc(' ' , stdout);
            printf("    |\n");
            label_copy = util_realloc_string_copy(label_copy, second_part);
        }
        else {
            printf("|    %s",label_copy);
            for (i=strlen(label_copy); i < l; i++)
                fputc(' ' , stdout);
            printf("    |\n");
            end_reached = true;
        }
    }
}
Ejemplo n.º 10
0
void rml_enkf_log_set_log_file( rml_enkf_log_type * data , const char * log_file ) {
  data->log_file = util_realloc_string_copy( data->log_file , log_file );
}
Ejemplo n.º 11
0
void runpath_list_set_line_fmt( runpath_list_type * list , const char * line_fmt ) {
  list->line_fmt = util_realloc_string_copy( list->line_fmt , line_fmt );
}
Ejemplo n.º 12
0
void parser_set_comment_end( parser_type * parser , const char * comment_end ) {
  __verify_string_length( comment_end );
  parser->comment_end = util_realloc_string_copy( parser->comment_end , comment_end );
}
Ejemplo n.º 13
0
void hook_manager_set_path( hook_manager_type * hook_manager , const char * path) {
  hook_manager->path = util_realloc_string_copy( hook_manager->path , path );
}
Ejemplo n.º 14
0
void plot_config_set_image_type(plot_config_type * plot_config , const char * image_type) {
  plot_config->image_type = util_realloc_string_copy(plot_config->image_type , image_type);
}
Ejemplo n.º 15
0
void matrix_set_name( matrix_type * matrix , const char * name) {
  matrix->name = util_realloc_string_copy( matrix->name , name );
}
Ejemplo n.º 16
0
void util_abort_test_set_intercept_function(const char * function) {
  intercept_function = util_realloc_string_copy( intercept_function , function );
}
Ejemplo n.º 17
0
void site_config_set_default_browser( site_config_type * site_config , const char * default_browser ) {
  site_config->default_browser = util_realloc_string_copy( site_config->default_browser , default_browser );
}
Ejemplo n.º 18
0
void site_config_set_lsf_request( site_config_type * site_config , const char * lsf_request) {
  queue_driver_type * lsf_driver = site_config_get_queue_driver( site_config , LSF_DRIVER_NAME);
  queue_driver_set_option( lsf_driver, LSF_RESOURCE , lsf_request );
  if (!site_config->user_mode) 
    site_config->lsf_request_site = util_realloc_string_copy( site_config->lsf_request_site , lsf_request);
}
Ejemplo n.º 19
0
void ecl_config_set_schedule_prediction_file( ecl_config_type * ecl_config , const char * schedule_prediction_file ) {
  ecl_config->schedule_prediction_file = util_realloc_string_copy( ecl_config->schedule_prediction_file , schedule_prediction_file );
}
Ejemplo n.º 20
0
static void smspec_node_set_lgr_name( smspec_node_type * index , const char * lgr_name ) {
  index->lgr_name = util_realloc_string_copy(index->lgr_name , lgr_name);
}
Ejemplo n.º 21
0
void ecl_config_set_init_section( ecl_config_type * ecl_config , const char * input_init_section ) {
  /* The semantic regarding INIT_SECTION is as follows:
  
       1. If the INIT_SECTION points to an existing file - the
          ecl_config->input_init_section is set to the absolute path of
          this file.

       2. If the INIT_SECTION points to a not existing file:

          a. We assert that INIT_SECTION points to a pure filename,
             i.e. /some/path/which/does/not/exist is NOT accepted. In
             the case the input argument contain a path a error message
             will be printed on stderr and the ->init_section will not
             be set.
          b. The ecl_config->input_init_section is set to point to this
             file.
          c. WE TRUST THE USER TO SUPPLY CONTENT (THROUGH SOME FUNKY
             FORWARD MODEL) IN THE RUNPATH. This can unfortunately not
             be checked/verified before the ECLIPSE simulation fails.


     The INIT_SECTION keyword and <INIT> in the datafile (checked with
     ecl_config->can_restart) interplay as follows: 


     CASE   |   INIT_SECTION  |  <INIT>    | OK ?
     ---------------------------------------------
     0      |   Present       | Present    |  Yes 
     1      |   Not Present   | Present    |  No    
     2      |   Present       | Not present|  No
     3      |   Not Present   | Not present|  Yes
     ---------------------------------------------


     Case 0: This is the most flexible case, which can do arbitrary
        restart.

     Case 1: In this case the datafile will contain a <INIT> tag, we
        we do not have the info to replace that tag with for
        initialisation, and ECLIPSE will fail. Strictly speaking this
        case can actually restart, but that is not enough - we let
        this case fail hard.

     Case 2: We have some INIT_SECTION infor, but no tag in he
        datafile to update. If the datafile has embedded
        initialisation info this case will work for init; but it is
        logically flawed, and not accepted. Currently only a warning.

     Case 3: This case has just the right amount of information for
        initialisation, but it is 'consistently unable' to restart.
     
  */
  if (ecl_config->can_restart) {  /* The <INIT> tag is set. */
    ecl_config->input_init_section = util_realloc_string_copy( ecl_config->input_init_section , input_init_section );   /* input_init_section = path/to/init_section         */
    if (util_file_exists( ecl_config->input_init_section )) {                                                           /* init_section       = $CWD/path/to/init_section */ 
      util_safe_free( ecl_config->init_section );
      ecl_config->init_section = util_alloc_realpath(input_init_section);
    } else {
      char * path;
      
      util_alloc_file_components( ecl_config->input_init_section , &path , NULL , NULL );
      if (path != NULL) 
        fprintf(stderr,"** Warning: %s: When INIT_SECTION:%s points to a non-existing file - you can not have any path components.\n",__func__ , input_init_section);
      else 
        ecl_config->init_section = util_alloc_string_copy(input_init_section);
      
      util_safe_free( path );
    }
  } else
    /* 
       The <INIT> tag is not set - we can not utilize the
       input_init_section info, and we just ignore it.
    */
    fprintf(stderr,"** Warning: <INIT> tag was not found in datafile - can not utilize INIT_SECTION keyword - ignored.\n");
}
Ejemplo n.º 22
0
void runpath_list_set_export_file( runpath_list_type * list , const char * export_file ) {
  list->export_file = util_realloc_string_copy( list->export_file , export_file );
}
Ejemplo n.º 23
0
void site_config_set_manual_url( site_config_type * site_config , const char * manual_url ) {
  site_config->manual_url = util_realloc_string_copy( site_config->manual_url , manual_url );
}
Ejemplo n.º 24
0
void parser_set_quoters( parser_type * parser , const char * quoters ) {
  __verify_string_length( quoters );
  parser->quoters = util_realloc_string_copy( parser->quoters , quoters );
}
Ejemplo n.º 25
0
void field_config_set_ecl_kw_name(field_config_type * config , const char * ecl_kw_name) {
    config->ecl_kw_name = util_realloc_string_copy(config->ecl_kw_name , ecl_kw_name);
}
Ejemplo n.º 26
0
void parser_set_specials( parser_type * parser , const char * specials ) {
  __verify_string_length( specials );
  parser->specials = util_realloc_string_copy( parser->specials , specials );
}
Ejemplo n.º 27
0
void plot_config_set_path(plot_config_type * plot_config , const char * plot_path) {
  plot_config->plot_path = util_realloc_string_copy(plot_config->plot_path , plot_path);
  util_make_path( plot_path );
}
Ejemplo n.º 28
0
void parser_set_delete_set( parser_type * parser , const char * delete_set ) {
  __verify_string_length( delete_set );
  parser->delete_set = util_realloc_string_copy( parser->delete_set , delete_set );
}
Ejemplo n.º 29
0
void plot_config_set_driver(plot_config_type * plot_config , const char * plot_driver) {
  plot_config->driver = util_realloc_string_copy(plot_config->driver , plot_driver);
}
Ejemplo n.º 30
0
void parser_set_comment_start( parser_type * parser , const char * comment_start ) {
  __verify_string_length( comment_start );
  parser->comment_start = util_realloc_string_copy( parser->comment_start , comment_start );
}