コード例 #1
0
ファイル: enkf_main_manage_fs.c プロジェクト: eoia/ert
void enkf_main_user_select_fs(enkf_main_type * enkf_main , const char * input_case ) {
    const char * ens_path = model_config_get_enspath( enkf_main->model_config);
    int root_version = enkf_fs_get_version104( ens_path );
    if (root_version == -1 || root_version == 105) {
        if (input_case == NULL) {
            char * current_mount_point = util_alloc_filename( ens_path , CURRENT_CASE , NULL);

            if (enkf_main_current_case_file_exists(enkf_main)) {
                char * current_case = enkf_main_read_alloc_current_case_name(enkf_main);
                enkf_main_select_fs(enkf_main, current_case);
                free (current_case);
            } else if (enkf_fs_exists( current_mount_point ) && util_is_link( current_mount_point )) {
                /*If the current_case file does not exists, but the 'current' symlink does we use readlink to
                  get hold of the actual target before calling the  enkf_main_select_fs() function. We then
                  write the current_case file and delete the symlink.*/
                char * target_case = util_alloc_atlink_target( ens_path , CURRENT_CASE );
                enkf_main_select_fs( enkf_main , target_case );
                unlink(current_mount_point);
                enkf_main_write_current_case_file(enkf_main, target_case);
                free( target_case );
            } else
                enkf_main_select_fs( enkf_main , DEFAULT_CASE );  // Selecting (a new) default case

            free( current_mount_point );
        } else
            enkf_main_select_fs( enkf_main , input_case );
    } else {
        fprintf(stderr,"Sorry: the filesystem located in %s must be upgraded before the current ERT version can read it.\n" , ens_path);
        exit(1);
    }
}
コード例 #2
0
ファイル: gen_kw.c プロジェクト: blattms/ert
void gen_kw_filter_file(const gen_kw_type * gen_kw , const char * target_file) {
  const char * template_file = gen_kw_config_get_template_file(gen_kw->config);
  if (template_file != NULL) {
    const int size = gen_kw_config_get_data_size(gen_kw->config );
    int ikw;
    
    for (ikw = 0; ikw < size; ikw++) {
      const char * key = gen_kw_config_get_tagged_name(gen_kw->config , ikw);  
      subst_list_append_owned_ref(gen_kw->subst_list , key , util_alloc_sprintf("%g" , gen_kw_config_transform( gen_kw->config , ikw , gen_kw->data[ikw] )) , NULL);
    }
      
    /*
      If the target_file already exists as a symbolic link the
      symbolic link is removed before creating the target file. The is
      to ensure against existing symlinks pointing to a common file
      outside the realization root.
    */
    if (util_is_link( target_file ))
      remove( target_file );
    
    subst_list_filter_file( gen_kw->subst_list  , template_file  , target_file);
  } else 
    util_abort("%s: internal error - tried to filter gen_kw instance without template file.\n",__func__);
}