Beispiel #1
0
static enkf_fs_type * enkf_fs_alloc_empty( const char * mount_point , bool read_only) {
  enkf_fs_type * fs          = util_malloc(sizeof * fs );
  UTIL_TYPE_ID_INIT( fs , ENKF_FS_TYPE_ID );
  fs->time_map               = time_map_alloc();
  fs->cases_config           = cases_config_alloc();
  fs->state_map              = state_map_alloc();
  fs->misfit_ensemble        = misfit_ensemble_alloc();
  fs->index                  = NULL;
  fs->eclipse_static         = NULL;
  fs->parameter              = NULL;
  fs->dynamic_forecast       = NULL;
  fs->dynamic_analyzed       = NULL;
  fs->read_only              = read_only;
  fs->mount_point            = util_alloc_string_copy( mount_point );
  fs->refcount               = 0;
  fs->lock_fd                = 0;
  
  if (mount_point == NULL)
    util_abort("%s: fatal internal error: mount_point == NULL \n",__func__);
  {
    char ** path_tmp;
    int     path_len;

    util_path_split( fs->mount_point , &path_len , &path_tmp);
    fs->case_name = util_alloc_string_copy( path_tmp[path_len - 1]);
    fs->root_path = util_alloc_joined_string( (const char **) path_tmp , path_len , UTIL_PATH_SEP_STRING);
    fs->lock_file = util_alloc_filename( fs->mount_point , fs->case_name , "lock");

    util_free_stringlist( path_tmp , path_len );
  }
  return fs;
}
Beispiel #2
0
const enkf_config_node_type * ensemble_config_user_get_node(const ensemble_config_type * config , const char  * full_key, char ** index_key ) {
  const enkf_config_node_type * node = NULL;
  char ** key_list;
  int     keys;
  int     key_length = 1;
  int offset;
  
  *index_key = NULL;
  util_split_string(full_key , USER_KEY_JOIN_STRING , &keys , &key_list);
  while (node == NULL && key_length <= keys) {
    char * current_key = util_alloc_joined_string( (const char **) key_list , key_length , USER_KEY_JOIN_STRING );
    if (ensemble_config_has_key(config , current_key))
      node = ensemble_config_get_node(config , current_key);
    else
      key_length++;
    offset = strlen( current_key );
    free( current_key );
  }
  if (node != NULL) {
    if (offset < strlen( full_key ))
      *index_key = util_alloc_string_copy(&full_key[offset+1]);
  }
  
  util_free_stringlist(key_list , keys);
  return node;
}
Beispiel #3
0
static void output_add_key( const ecl_sum_type * refcase , output_type * output , const char * qkey) {
  int tokens;
  double  quantile;
  char ** tmp;
  char  * sum_key;

  util_split_string( qkey , SUMMARY_JOIN , &tokens , &tmp);
  if (tokens == 1)
    util_exit("Hmmm - the key:%s is malformed - must be of the form SUMMARY_KEY:QUANTILE.\n",qkey);

  if (!util_sscanf_double( tmp[tokens - 1] , &quantile))
    util_exit("Hmmmm - failed to interpret:%s as a quantile - must be a number (0,1).\n",tmp[tokens-1]);

  if (quantile <= 0 || quantile >= 1.0)
    util_exit("Invalid quantile value:%g - must be in interval (0,1)\n", quantile);

  sum_key = util_alloc_joined_string( (const char **) tmp , tokens - 1 , SUMMARY_JOIN);
  {
    stringlist_type * matching_keys = stringlist_alloc_new();
    int i;
    ecl_sum_select_matching_general_var_list( refcase , sum_key , matching_keys );
    for (i=0; i < stringlist_get_size( matching_keys ); i++)
      vector_append_owned_ref( output->keys , quant_key_alloc( stringlist_iget( matching_keys , i ) , quantile) , quant_key_free__ );

    if (stringlist_get_size( matching_keys ) == 0)
      fprintf(stderr,"** Warning: No summary vectors matching:\'%s\' found?? \n", sum_key);
    stringlist_free( matching_keys );
  }

  util_free_stringlist( tmp, tokens );
}