예제 #1
0
파일: migrate_bfs.c 프로젝트: Ensembles/ert
int main(int argc, char ** argv) {
  int num_src_drivers    = 10;
  int num_target_drivers = 32;
  if (argc != 4) 
    usage();
  
  {
    char * src_path        = argv[1] ;
    char * target_path     = argv[2] ;
    char * dir             = argv[3] ;
   
    util_make_path( target_path );
    if (util_same_file( src_path , target_path)) {
      fprintf(stderr,"The two directories:%s and %s point to the same location \n" , src_path , target_path );
      exit(1);
    }
    
    {
      char * src_case    = util_alloc_sprintf("%s/%s" , src_path , dir );
      char * target_case = util_alloc_sprintf("%s/%s" , target_path , dir );

      msg_type * msg = msg_alloc("Copying from: " , false);
      msg_show( msg );
      migrate_file(src_case , num_src_drivers , target_case , num_target_drivers , "ANALYZED" , 32 , msg);
      migrate_file(src_case , num_src_drivers , target_case , num_target_drivers , "FORECAST" , 32 , msg);
      migrate_file(src_case , num_src_drivers , target_case , num_target_drivers , "PARAMETER" , 32 , msg);
      migrate_file(src_case , num_src_drivers , target_case , num_target_drivers , "STATIC" , 32 , msg);
      copy_index( src_case , target_case );
      free( src_case);
      free( target_case );
      msg_free( msg , true );
    }
  }
}
예제 #2
0
job_type * alloc_job( rng_type * rng , const char * cmd) {
  const int second = 1000000;
  const int submit_min = 0;
  const int submit_max = 10 * second;

  const int callback_min = 0.5 * second;
  const int callback_max = 2 * second;

  const int run_min = 2 * second;
  const int run_max = 10 * second;

  job_type * job = util_malloc( sizeof * job );
  UTIL_TYPE_ID_INIT( job , JOB_TYPE_ID )
  job->callback_run = false;
  job->queue_index = -1;
  job->submit_usleep    = submit_min  + rng_get_int( rng , (submit_max - submit_min ));
  job->callback_usleep = callback_min + rng_get_int( rng , (callback_max - callback_min ));
  job->run_usleep      = run_min      + rng_get_int( rng , (run_max - run_min ));
  job->run_path        = util_alloc_sprintf("%08d", rng_get_int(rng , 100000000));
  job->cmd = cmd;
  job->argc = 4;

  job->argv = util_malloc( 4 * sizeof * job->argv );
  job->argv[0] = job->run_path;
  job->argv[1] = "RUNNING";
  job->argv[2] = "OK";
  job->argv[3] = util_alloc_sprintf("%d", job->run_usleep);

  util_make_path( job->run_path );
  return job;
}
예제 #3
0
int main( int argc , char ** argv) {
  util_install_signals();
  {
    const char * file = argv[1];

    test_fortio_is_instance( file );
    test_fortio_safe_cast( file );
    test_assert_util_abort("fortio_safe_cast", test_fortio_unsafe_cast, NULL);
    test_existing_read( file );
    test_not_existing_read( );
    test_open_close_read( file );
    test_wrapper( file );
    test_fread_truncated_head();
    test_fread_truncated_data();
    test_fread_truncated_tail();
    test_fread_invalid_tail();
    test_fseek();
    test_at_eof();

    test_write( "/tmp/path/does/not/exist" , false );
    {
      test_work_area_type * work_area = test_work_area_alloc("ecl_fortio.write" );
      util_make_path("path");
      test_write( "path/file.x" , true );
      test_work_area_free( work_area );
    }

    exit(0);
  }
}
예제 #4
0
char * util_alloc_tmp_file(const char * path, const char * prefix , bool include_pid ) {
  // Should be reimplemented to use mkstemp() 
  const int pid_digits    = 6;
  const int random_digits = 6;
  const int random_max    = 1000000;

#ifdef HAVE_PID_T  
  const int pid_max     = 1000000;
  pid_t  pid            = getpid() % pid_max;
#else
  int    pid            = 0;
#endif

  char * file           = util_calloc(strlen(path) + 1 + strlen(prefix) + 1 + pid_digits + 1 + random_digits + 1 , sizeof * file );
  char * tmp_prefix     = util_alloc_string_copy( prefix );
  
  if (!util_is_directory(path))
    util_make_path(path);
  util_string_tr( tmp_prefix ,  UTIL_PATH_SEP_CHAR , '_');  /* removing path seps. */
  
  do {
    long int rand_int = rand() % random_max;
    if (include_pid)
      sprintf(file , "%s%c%s-%d-%ld" , path , UTIL_PATH_SEP_CHAR , tmp_prefix , pid , rand_int);
    else
      sprintf(file , "%s%c%s-%ld" , path , UTIL_PATH_SEP_CHAR , tmp_prefix , rand_int);
  } while (util_file_exists(file));   

  free( tmp_prefix );
  return file;
}
예제 #5
0
void enkf_tui_export_fieldP(void * arg) {
  enkf_main_type * enkf_main                   = enkf_main_safe_cast( arg );
  const ensemble_config_type * ensemble_config = enkf_main_get_ensemble_config(enkf_main);
  const enkf_config_node_type * config_node    = enkf_tui_util_scanf_key(ensemble_config , PROMPT_LEN ,  FIELD  , INVALID_VAR );
  int iens1                                    = 0;
  int iens2                                    = enkf_main_get_ensemble_size( enkf_main );
  const int last_report                        = enkf_main_get_history_length( enkf_main );
  int report_step                              = util_scanf_int_with_limits("Report step: ", PROMPT_LEN , 0 , last_report);
  double lower_limit                           = util_scanf_double("Lower limit", PROMPT_LEN);
  double upper_limit                           = util_scanf_double("Upper limit", PROMPT_LEN);
  char * export_file;
  util_printf_prompt("Filename to store file: " , PROMPT_LEN , '=' , "=> ");
  export_file = util_alloc_stdin_line();
  {
    enkf_fs_type   * fs        = enkf_main_tui_get_fs(enkf_main);
    enkf_node_type ** ensemble = enkf_node_load_alloc_ensemble( config_node , fs , report_step , iens1 , iens2 );
    enkf_node_type *  sum      = enkf_node_alloc( config_node );
    int active_ens_size        = 0;
    int iens;

    enkf_node_clear( sum );
    {
      /* OK going low level */
      field_type * sum_field = (field_type *) enkf_node_value_ptr( sum );

      for (iens = iens1; iens < iens2; iens++) {
        if (ensemble[iens - iens1] != NULL) {
          field_type * field     = (field_type *) enkf_node_value_ptr( ensemble[iens - iens1] );
          field_update_sum( sum_field , field , lower_limit , upper_limit);
          active_ens_size++;
        }
      }
      if (active_ens_size > 0) {
        field_scale( sum_field , 1.0 / active_ens_size );
        {
          char * path;
          util_alloc_file_components( export_file , &path , NULL , NULL);
          if (path != NULL) {
            util_make_path( path );
            free( path );
          }
        }
        field_export(sum_field , export_file , NULL , RMS_ROFF_FILE , false, NULL);
      } else fprintf(stderr,"Warning: no data found \n");
    }

    for (iens = iens1; iens < iens2; iens++) {
      if (ensemble[iens - iens1] != NULL)
        enkf_node_free( ensemble[iens - iens1] );
    }

    free( ensemble );
    enkf_node_free( sum );
  }
  free( export_file );
}
예제 #6
0
static text_state_type * text_state_alloc( const void * init_arg ) {
  text_state_type * state = util_malloc( sizeof * state );
  {
    const arg_pack_type * arg_pack = arg_pack_safe_cast_const( init_arg );
    state->plot_path               = util_alloc_string_copy( arg_pack_iget_const_ptr( arg_pack , 0) );
    util_make_path( state->plot_path );
  }
  
  return state;
}
예제 #7
0
void enkf_tui_export_gen_data(void * arg) {
  enkf_main_type * enkf_main = enkf_main_safe_cast( arg );
  const ensemble_config_type * ensemble_config = enkf_main_get_ensemble_config(enkf_main);
  {
    int report_step;
    int iens1 , iens2;
    const int last_report = enkf_main_get_history_length( enkf_main );

    const enkf_config_node_type * config_node;
    path_fmt_type * file_fmt;

    config_node    = enkf_tui_util_scanf_key(ensemble_config , PROMPT_LEN ,  GEN_DATA , INVALID_VAR);


    report_step = util_scanf_int_with_limits("Report step: ", PROMPT_LEN , 0 , last_report);
    enkf_tui_util_scanf_iens_range("Realizations members to export(0 - %d)" , enkf_main_get_ensemble_size( enkf_main ) , PROMPT_LEN , &iens1 , &iens2);
    {
      char path_fmt[512];
      util_printf_prompt("Filename to store files in (with %d) in: " , PROMPT_LEN , '=' , "=> ");
      scanf("%s" , path_fmt);
      file_fmt = path_fmt_alloc_path_fmt( path_fmt );
    }

    {
      enkf_fs_type   * fs   = enkf_main_tui_get_fs(enkf_main);
      enkf_node_type * node = enkf_node_alloc(config_node);
      gen_data_file_format_type export_type = gen_data_guess_export_type( (const gen_data_type *) enkf_node_value_ptr(node) );
      int iens;

      for (iens = iens1; iens <= iens2; iens++) {
        node_id_type node_id = {.report_step = report_step , .iens = iens};
        if (enkf_node_try_load(node , fs, node_id)) {
          char * full_path = path_fmt_alloc_path( file_fmt , false , iens);
          char * path;
          util_alloc_file_components(full_path , &path , NULL , NULL);
          if (path != NULL) util_make_path( path );

          {
            const gen_data_type * gen_data = (const gen_data_type *) enkf_node_value_ptr(node);
            gen_data_export(gen_data , full_path , export_type);
          }

          free(full_path);
          free(path);
        }
      }
      enkf_node_free(node);
    }
  }
}
예제 #8
0
void enkf_tui_export_field(const enkf_main_type * enkf_main , field_file_format_type file_type) {
  const ensemble_config_type * ensemble_config = enkf_main_get_ensemble_config(enkf_main);
  const bool output_transform = true;
  const enkf_config_node_type * config_node;
  const int last_report = enkf_main_get_history_length( enkf_main );
  int        iens1 , iens2 , iens , report_step;
  path_fmt_type * export_path;

  config_node    = enkf_tui_util_scanf_key(ensemble_config , PROMPT_LEN ,  FIELD  , INVALID_VAR );

  report_step = util_scanf_int_with_limits("Report step: ", PROMPT_LEN , 0 , last_report);
  enkf_tui_util_scanf_iens_range("Realizations members to export(0 - %d)" , enkf_main_get_ensemble_size( enkf_main ) , PROMPT_LEN , &iens1 , &iens2);

  {
    char * path_fmt;
    util_printf_prompt("Filename to store files in (with %d) in: " , PROMPT_LEN , '=' , "=> ");
    path_fmt = util_alloc_stdin_line();
    export_path = path_fmt_alloc_path_fmt( path_fmt );
    free( path_fmt );
  }

  {
    enkf_fs_type   * fs   = enkf_main_tui_get_fs(enkf_main);
    enkf_node_type * node = enkf_node_alloc(config_node);

    for (iens = iens1; iens <= iens2; iens++) {
      node_id_type node_id = {.report_step = report_step , .iens = iens };
      if (enkf_node_try_load(node , fs , node_id)) {
        char * filename = path_fmt_alloc_path( export_path , false , iens);
        {
          char * path;
          util_alloc_file_components(filename , &path , NULL , NULL);
          if (path != NULL) {
            util_make_path( path );
            free( path );
          }
        }

        {
          const field_type * field = (const field_type *) enkf_node_value_ptr(node);
          field_export(field , filename , NULL , file_type , output_transform, NULL);
        }
        free(filename);
      } else
        printf("Warning: could not load realization:%d \n", iens);
    }
    enkf_node_free(node);
  }
}
예제 #9
0
void test_with_prefix() {
  test_work_area_type * work_area = test_work_area_alloc( "with-prefix" );

  util_make_path( "PREFIX" );
  {
    test_work_area_type * sub_area = test_work_area_alloc_relative("PREFIX" , "sub-work" );
    test_assert_true( test_work_area_is_instance( sub_area ));
    test_work_area_free( sub_area );
    test_assert_true( util_entry_exists("PREFIX/sub-work"));
  }
  {
    test_work_area_type * sub_area = test_work_area_alloc_relative("DoesNotExist" , "sub-work" );
    test_assert_NULL( sub_area );
  }
  test_work_area_free( work_area );
}
예제 #10
0
void enkf_tui_help_menu_misc(void * arg) {
  
  enkf_main_type  * enkf_main  = enkf_main_safe_cast( arg );  
  plot_config_type * plot_config = enkf_main_get_plot_config( enkf_main );
  {
    const char * plot_path  =  plot_config_get_path( plot_config );
    util_make_path( plot_path );
  }
  
  {
    menu_type * menu = menu_alloc("Help: Miscellanous" , "Back" , "bB");
    menu_add_helptext(menu , "This option contains miscellaneous options.");
    menu_add_item(menu , "Open manual (firefox)"    , "mM"  , enkf_tui_help_manual_misc , enkf_main , NULL);
    menu_run(menu);
    menu_free(menu);
  }
}
예제 #11
0
void enkf_tui_help_menu_table(void * arg) {
  
  enkf_main_type  * enkf_main  = enkf_main_safe_cast( arg );  
  plot_config_type * plot_config = enkf_main_get_plot_config( enkf_main );
  {
    const char * plot_path  =  plot_config_get_path( plot_config );
    util_make_path( plot_path );
  }
  
  {
    menu_type * menu = menu_alloc("Help: Table of results" , "Back" , "bB");
    menu_add_helptext(menu , "This option can generate a table of results after the case has been run.");
    menu_add_item(menu , "Open manual (firefox)"    , "mM"  , enkf_tui_help_manual_table , enkf_main , NULL);
    menu_run(menu);
    menu_free(menu);
  }
}
예제 #12
0
void enkf_tui_help_menu_run(void * arg) {
  
  enkf_main_type  * enkf_main  = enkf_main_safe_cast( arg );  
  plot_config_type * plot_config = enkf_main_get_plot_config( enkf_main );
  {
    const char * plot_path  =  plot_config_get_path( plot_config );
    util_make_path( plot_path );
  }
  
  {
    menu_type * menu = menu_alloc("Help: Run menu" , "Back" , "bB");
    menu_add_helptext(menu , "This menu is used to do the main work in ERT. The first option, x: Ensemble run: history, will just run the case without any data conditioning. Options r and s will initiate classical enkf runs. The two options i and t invokes the ensemble kalman smoother.");
    menu_add_item(menu , "Open manual (firefox)"    , "mM"  , enkf_tui_help_manual_run , enkf_main , NULL);
    menu_run(menu);
    menu_free(menu);
  }
}
예제 #13
0
void enkf_tui_help_menu_main(void * arg) {
  
  enkf_main_type  * enkf_main  = enkf_main_safe_cast( arg );  
  plot_config_type * plot_config = enkf_main_get_plot_config( enkf_main );
  {
    const char * plot_path  =  plot_config_get_path( plot_config );
    util_make_path( plot_path );
  }
  
  {
    menu_type * menu = menu_alloc("Help: Main menu" , "Back" , "bB");
    menu_add_helptext(menu , "Choose the different options from the main menu to read more about the different options.");
    menu_add_item(menu , "Open manual (firefox)"    , "mM"  , enkf_tui_help_manual_main , enkf_main , NULL);
    menu_run(menu);
    menu_free(menu);
  }
}
예제 #14
0
파일: migrate_bfs.c 프로젝트: Ensembles/ert
static void migrate_file( const char * src_case, int num_src_drivers , const char * target_case, int num_target_drivers, const char * file, int block_size , msg_type * msg) {
  block_fs_type ** target_fs = util_calloc( num_target_drivers , sizeof * target_fs  ); 
  int itarget;
  for (itarget = 0; itarget < num_target_drivers; itarget++) {
    char * path       = util_alloc_sprintf("%s/mod_%d" , target_case , itarget );
    char * mount_file = util_alloc_sprintf("%s/mod_%d/%s.mnt" , target_case , itarget , file );
    util_make_path( path );
    
    target_fs[itarget] =  block_fs_mount( mount_file , 16 , 0 , 1.0, 0 , false , false );
    free( mount_file );
    free( path );
  } 

  {
    int isrc;
    buffer_type * buffer = buffer_alloc(1024);
    for (isrc = 0; isrc < num_src_drivers; isrc++) {
      char * mount_file = util_alloc_sprintf("%s/mod_%d/%s.mnt" , src_case , isrc , file );
      block_fs_type   * src_fs    = block_fs_mount( mount_file , 16 , 1024 , 1.0 , 0 , true , true );
      vector_type     * file_list = block_fs_alloc_filelist( src_fs , NULL , NO_SORT , false );
      int ifile;
      msg_update( msg , mount_file );
      for (ifile = 0; ifile < vector_get_size( file_list ); ifile++) {
        const file_node_type * node = vector_iget_const( file_list , ifile );
        const char * filename       = file_node_get_filename( node );
        int   report_step , iens;
        char * key;
        if (block_fs_sscanf_key( filename , &key , &report_step , &iens )) {
          block_fs_fread_realloc_buffer( src_fs , filename , buffer);
          block_fs_fwrite_buffer( target_fs[(iens % num_target_drivers)] , filename , buffer );
          free( key );
        } else
          util_abort("%s: All hell is loose - failed to parse:%s \n",__func__ , filename);
      }

      vector_free( file_list );
      block_fs_close(src_fs , false);
    }
    buffer_free( buffer );
  }

  
  for (itarget = 0; itarget < num_target_drivers; itarget++) 
    block_fs_close( target_fs[itarget] , false);
  free( target_fs );
}
예제 #15
0
void enkf_tui_help_menu_cases(void * arg) {
  
  enkf_main_type  * enkf_main  = enkf_main_safe_cast( arg );  
  plot_config_type * plot_config = enkf_main_get_plot_config( enkf_main );
  {
    const char * plot_path  =  plot_config_get_path( plot_config );
    util_make_path( plot_path );
  }
  
  {
    menu_type * menu = menu_alloc("Help: Manage cases" , "Back" , "bB");
    menu_add_helptext(menu , "Use this menu to navgate between cases and to initialize cases. A case has to be initialized before it can be used.");
    menu_add_item(menu , "Open manual (firefox)"    , "mM"  , enkf_tui_help_manual_cases , enkf_main , NULL);
    menu_run(menu);
    menu_free(menu);
  }
}
예제 #16
0
int main( int argc , char ** argv) {
  const char * file = argv[1];
  
  test_existing_read( file );
  test_not_existing_read( );
  test_open_close_read( file );
  test_wrapper( file );
  test_write( "/tmp/path/does/not/exist" , false );  
  {
    test_work_area_type * work_area = test_work_area_alloc("ecl_fortio.write" );
    util_make_path("path");
    test_write( "path/file.x" , true );
    test_work_area_free( work_area );
  }
  
  exit(0);
}
예제 #17
0
void enkf_tui_help_menu_simple(void * arg) {
  
  enkf_main_type  * enkf_main  = enkf_main_safe_cast( arg );  
  plot_config_type * plot_config = enkf_main_get_plot_config( enkf_main );
  {
    const char * plot_path  =  plot_config_get_path( plot_config );
    util_make_path( plot_path );
  }
  
  {
    menu_type * menu = menu_alloc("Help: Simple menu" , "Back" , "bB");
    menu_add_helptext(menu , "The top four options in the simple menu will run eclipse simulations. Option s: Sensitivity run: No data conditioning, will initialize all parameters and run one eclipse simulation for each set of different parameters. e: Assimilation run: EnKF updates, will initialize all parameters and run one eclipse simulation for each set of different parameters. The eclipse simulations will run until the first data time step is encountered and condition on data before continuing. a: Assimilation run: Smoother update, will do one pass of the sensitivity run, then condition the parameters to all the data and rerun all experiments. i: Assimilation run: Iterated smoother [RML-EnKF] will iterate the smoother run several times.");
    menu_add_item(menu , "Open manual (firefox)"    , "mM"  , enkf_tui_help_manual_main , enkf_main , NULL);
    menu_run(menu);
    menu_free(menu);
  }
}
예제 #18
0
void submit_jobs_to_queue(job_queue_type * queue, test_work_area_type * work_area, char * executable_to_run, int number_of_jobs, int number_of_slowjobs, char* sleep_short, char* sleep_long, bool multithreaded) {
  int submitted_slowjobs = 0;
  for (int i = 0; i < number_of_jobs; i++) {
    char * runpath = util_alloc_sprintf("%s/%s_%d", test_work_area_get_cwd(work_area), "job", i);
    util_make_path(runpath);

    char * sleeptime = sleep_short;
    if (submitted_slowjobs < number_of_slowjobs) {
      sleeptime = sleep_long;
      submitted_slowjobs++;
    }

    if (multithreaded) {

      job_queue_add_job_mt(queue, executable_to_run, NULL, NULL, NULL, NULL, 1, runpath, "Testjob", 2, (const char *[2]) {
        runpath, sleeptime
      });
    } else {
예제 #19
0
void site_config_set_license_root_path( site_config_type * site_config , const char * license_root_path) {
  util_make_path( license_root_path );
  {
    char * full_license_root_path = util_alloc_realpath( license_root_path );
    {
      /**
         Appending /user/pid to the license root path. Everything
         including the pid is removed when exiting (gracefully ...).
         
         Dangling license directories after a crash can just be removed.
      */
      site_config->license_root_path   = util_realloc_string_copy( site_config->license_root_path , full_license_root_path );
      site_config->__license_root_path = util_realloc_sprintf(site_config->__license_root_path , "%s%c%s%c%d" , full_license_root_path , UTIL_PATH_SEP_CHAR , getenv("USER") , UTIL_PATH_SEP_CHAR , getpid());
      
      if (!site_config->user_mode)
        site_config->license_root_path_site = util_realloc_string_copy( site_config->license_root_path_site , full_license_root_path );
    }
    free( full_license_root_path );
  }
}
예제 #20
0
void test_latex_link( latex_type * latex ) {
  const char * path = "/tmp/linkFarm";
  const char * file1 = util_alloc_filename( path , "File1" , NULL );
  const char * file2 = util_alloc_filename( path , "File2" , NULL );
  const char * file3 = util_alloc_filename( path , "File3" , NULL );
  

  util_make_path( path );
  make_file( file1 );
  make_file( file2 );
  make_file( file3 );
  
  latex_link_path( latex , path );
  latex_link_directory_content( latex , path );
  
  test_link( latex , "File1" , file1);
  test_link( latex , "File2" , file2);
  test_link( latex , "File3" , file3);
  test_link( latex , "linkFarm" , path);
  
  util_clear_directory( path , true , true );
}
예제 #21
0
EclipseIO::EclipseIO( const EclipseState& es,
                      EclipseGrid grid,
                      const Schedule& schedule,
                      const SummaryConfig& summary_config)
    : impl( new Impl( es, std::move( grid ), schedule , summary_config) )
{
    if( !this->impl->output_enabled )
        return;
    {
        const auto& outputDir = this->impl->outputDir;

        // make sure that the output directory exists, if not try to create it
        if ( !util_entry_exists( outputDir.c_str() ) ) {
            util_make_path( outputDir.c_str() );
        }

        if( !util_is_directory( outputDir.c_str() ) ) {
            throw std::runtime_error( "The path specified as output directory '"
                                      + outputDir + "' is not a directory");
        }
    }
}
예제 #22
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 );
}
예제 #23
0
void enkf_tui_export_scalar2csv(void * arg) {
  enkf_main_type * enkf_main = enkf_main_safe_cast( arg );
  const ensemble_config_type * ensemble_config = enkf_main_get_ensemble_config(enkf_main);
  const enkf_config_node_type * config_node;
  char * user_key, *key_index;

  util_printf_prompt("Scalar to export (KEY:INDEX)" , PROMPT_LEN , '=' , "=> "); user_key = util_alloc_stdin_line();
  config_node = ensemble_config_user_get_node( ensemble_config , user_key , &key_index);
  if (config_node != NULL) {
    int    report_step , first_report, last_report;
    int    iens1 , iens2, iens;
    char * csv_file;

    iens2        = enkf_main_get_ensemble_size( enkf_main ) - 1;
    iens1        = 0;
    first_report = 0;
    last_report  = enkf_main_get_history_length( enkf_main );
    {
      char * path;
      char * prompt = util_alloc_sprintf("File to store \'%s\'", user_key);
      util_printf_prompt(prompt , PROMPT_LEN , '=' , "=> ");
      csv_file = util_alloc_stdin_line();

      util_alloc_file_components( csv_file , &path , NULL , NULL);
      if (path != NULL) {
        if (util_entry_exists( path )) {
          if (!util_is_directory( path )) {
            /* The path component already exists in the filesystem - and it is not a directory - we leave the building. */
            fprintf(stderr,"Sorry: %s already exists - and is not a directory.\n",path);
            free(path);
            free(csv_file);
            free(user_key);
            return ;
          }
        } else {
          /* The path does not exist - we make it. */
          enkf_tui_util_msg("Creating new directory: %s\n" , path);
          util_make_path( path );
        }
      }
      free(prompt);
    }
    {
      /* Seriously manual creation of csv file. */
      enkf_fs_type * fs     = enkf_main_tui_get_fs(enkf_main);
      enkf_node_type * node = enkf_node_alloc( config_node );
      FILE * stream         = util_fopen( csv_file , "w");
      node_id_type node_id;


      /* Header line */
      fprintf(stream , "\"Report step\"");
      for (iens = iens1; iens <= iens2; iens++)
        fprintf(stream , "%s\"%s(%d)\"" , CSV_SEP , user_key , iens);
      fprintf(stream , CSV_NEWLINE);

      for (report_step = first_report; report_step <= last_report; report_step++) {
        fprintf(stream , "%6d" , report_step);
        node_id.report_step = report_step;
        for (iens = iens1; iens <= iens2; iens++) {
          double value;
          char label[32];
          /*
             Have not implemented a choice on forecast/analyzed. Tries
             analyzed first, then forecast.
          */
          node_id.iens = iens;
          sprintf(label , "%03d/%03d" , report_step , iens);

          if (enkf_node_user_get( node , fs , key_index , node_id ,  &value))
            fprintf(stream , "%s%g" , CSV_SEP , value);
          else
            fprintf(stream , "%s%s" , CSV_SEP , CSV_MISSING_VALUE);

        }
        fprintf(stream , CSV_NEWLINE);
      }

      enkf_node_free( node );
      fclose(stream);
    }
  } else
    fprintf(stderr,"Sorry - could not find any nodes with key:%s\n",user_key);

  free(user_key);
}