Exemplo n.º 1
0
void enkf_tui_run_one_more_iteration(void * arg){
  enkf_main_type * enkf_main  = enkf_main_safe_cast( arg );
  const ecl_config_type * ecl_config = enkf_main_get_ecl_config( enkf_main );
  const int last_report = enkf_main_get_history_length( enkf_main );
  int step2;
  if (ecl_config_has_schedule( ecl_config ))
    step2 = util_scanf_int_with_limits("Last report",PROMPT_LEN , 0 , last_report);  
  else
    step2 = last_report;
  enkf_main_run_one_more_iteration(enkf_main, step2);
}
Exemplo n.º 2
0
static void enkf_main_export_runpath_file(enkf_main_type * enkf_main,
                                          const int_vector_type * realizations,
                                          const int_vector_type * iterations) {

  ecl_config_type * ecl_config            = enkf_main_get_ecl_config(enkf_main);
  const model_config_type * model_config  = enkf_main_get_model_config(enkf_main);
  const char * basename_fmt               = ecl_config_get_eclbase(ecl_config);
  const char * runpath_fmt                = model_config_get_runpath_as_char(model_config);
  const qc_module_type * qc_module        = enkf_main_get_qc_module( enkf_main );

  runpath_list_type * runpath_list = runpath_list_alloc( qc_module_get_runpath_list_file( qc_module ));

  for (int iter = 0; iter < int_vector_size(iterations); ++iter) {
    for (int iens = 0; iens < int_vector_size(realizations); ++iens) {
      int iter_value = int_vector_iget(iterations, iter);
      int iens_value = int_vector_iget(realizations, iens);
      char * basename;
      char * runpath;

      if (basename_fmt)
        basename = util_alloc_sprintf(basename_fmt, iens_value);
      else
        basename = util_alloc_sprintf("--%d", iens_value);

      if (model_config_runpath_requires_iter(model_config))
        runpath = util_alloc_sprintf(runpath_fmt, iens_value, iter_value);
      else
        runpath = util_alloc_sprintf(runpath_fmt, iens_value);

      runpath_list_add(runpath_list, iens_value, iter_value, runpath, basename);

      free(basename);
      free(runpath);
    }
  }
  runpath_list_fprintf(runpath_list);
  runpath_list_free(runpath_list);
}
Exemplo n.º 3
0
void enkf_tui_run_menu(void * arg) {
  enkf_main_type  * enkf_main  = enkf_main_safe_cast( arg );
  model_config_type * model_config = enkf_main_get_model_config( enkf_main );
  path_fmt_type     * runpath_fmt  = model_config_get_runpath_fmt( model_config );
  menu_type       * menu;

  {
    char   * title = util_alloc_sprintf("Run menu [case:%s  Runpath:%s]" , enkf_main_get_current_fs( enkf_main ) , path_fmt_get_fmt ( runpath_fmt ));
    menu = menu_alloc(title , "Back" , "bB");
    free(title);
  }
  menu_add_item(menu , "Ensemble run: history"                , "xX" , enkf_tui_run_exp         , enkf_main , NULL);
  menu_add_separator( menu );
  {
    const ecl_config_type * ecl_config = enkf_main_get_ecl_config( enkf_main );
    const model_config_type * model_config = enkf_main_get_model_config( enkf_main );
    const analysis_config_type * analysis_config = enkf_main_get_analysis_config(enkf_main);
    
    menu_item_type * enkf_item         = menu_add_item(menu , "Start EnKF run from beginning"          , "sS" , enkf_tui_run_start         , enkf_main , NULL);
    menu_item_type * restart_enkf_item = menu_add_item(menu , "Restart EnKF run from arbitrary state"  , "rR" , enkf_tui_run_restart__       , enkf_main , NULL);
    menu_item_type * ES_item           = menu_add_item(menu , "Integrated smoother update"             , "iI" , enkf_tui_run_smoother      , enkf_main , NULL);
    menu_item_type * it_ES_item        = menu_add_item(menu , "Iterated smoother [RML-EnKF]"           , "tT" , enkf_tui_run_iterated_ES   , enkf_main , NULL);
    menu_item_type * one_more_item     = menu_add_item(menu , "One more iteration (disabled)"          , "mM" , enkf_tui_run_one_more_iteration , enkf_main , NULL);
              
    if (!ecl_config_has_schedule( ecl_config )) {
      menu_item_disable( enkf_item );
      menu_item_disable( restart_enkf_item );
    }
    
    if (!ecl_config_has_init_section( ecl_config )) 
      menu_item_disable( enkf_item );

    menu_item_disable( one_more_item );
    if (!analysis_config_get_module_option(analysis_config , ANALYSIS_ITERABLE)) {
      menu_item_disable( it_ES_item );
      menu_item_disable( one_more_item );
    } else {
      menu_item_disable( enkf_item );
      menu_item_disable( restart_enkf_item );
      menu_item_disable( ES_item );
    }
      
    if (!model_config_has_history( model_config )) {
      menu_item_disable( it_ES_item );
      menu_item_disable( ES_item );
      menu_item_disable( one_more_item );
    }
  }
  menu_add_separator(menu);
  menu_add_item(menu , "Create runpath directories - NO simulation" , "cC" , enkf_tui_run_create_runpath__ , enkf_main , NULL );
  menu_add_item(menu , "Load results manually"                               , "lL"  , enkf_tui_run_manual_load__ , enkf_main , NULL);
  menu_add_separator(menu);
  {
    menu_item_type * analysis_item = menu_add_item(menu , "Analysis menu"             , "aA" , enkf_tui_analysis_menu , enkf_main , NULL);
    
    if (!enkf_main_have_obs( enkf_main )) 
      menu_item_disable( analysis_item );
  }
  /*
    Option to set runpath runtime - currently dismantled.
    
    menu_add_separator(menu);
    {
    model_config_type * model_config = enkf_main_get_model_config( enkf_main );
    path_fmt_type     * runpath_fmt  = model_config_get_runpath_fmt( model_config );
    arg_pack_type * arg_pack = arg_pack_alloc();  
    char * runpath_label = util_alloc_sprintf("Set new value for RUNPATH:%s" , path_fmt_get_fmt ( runpath_fmt ));
    
    arg_pack_append_ptr(arg_pack , model_config);
    arg_pack_append_ptr(arg_pack , menu_add_item(menu , runpath_label , "dD" , enkf_tui_run_set_runpath , arg_pack , arg_pack_free__));
    
    free(runpath_label);
    }
  */
  menu_add_item(menu , "Help"                                  , "hH" , enkf_tui_help_menu_run   , enkf_main , NULL); 
  menu_run(menu);
  menu_free(menu);
}
Exemplo n.º 4
0
static void test_export_runpath_file(ert_test_context_type * test_context,
                                    const char * job_name,
                                    const char * job_file,
                                    stringlist_type * args,
                                    int_vector_type * iens_values,
                                    int_vector_type * iter_values) {

  ert_test_context_install_workflow_job( test_context , job_name , job_file );
  test_assert_true( ert_test_context_run_worklow_job( test_context , job_name , args) );

  {
    const enkf_main_type * enkf_main = ert_test_context_get_main(test_context);
    qc_module_type * qc_module       = enkf_main_get_qc_module( enkf_main );
    const char * runpath_file_name   = qc_module_get_runpath_list_file(qc_module);

    ecl_config_type * ecl_config            = enkf_main_get_ecl_config(enkf_main);
    const model_config_type * model_config  = enkf_main_get_model_config(enkf_main);
    const char * base_fmt                   = ecl_config_get_eclbase(ecl_config);
    const char * runpath_fmt                = model_config_get_runpath_as_char(model_config);

    test_assert_true(util_file_exists(runpath_file_name));
    FILE * file = util_fopen(runpath_file_name, "r");

    int file_iens = 0;
    char file_path[256];
    char file_base[256];
    int file_iter = 0;
    char * cwd = util_alloc_cwd();
    int counter = 0;
    int iens_index = 0;
    int iter_index = 0;

    while (4 == fscanf( file , "%d %s %s %d" , &file_iens , file_path , file_base, &file_iter)) {
      ++ counter;

      test_assert_true(int_vector_size(iens_values) >= iens_index+1);
      test_assert_true(int_vector_size(iter_values) >= iter_index+1);

      int iens = int_vector_iget(iens_values, iens_index);
      int iter = int_vector_iget(iter_values, iter_index);

      test_assert_int_equal(file_iens, iens);
      test_assert_int_equal(file_iter, iter);

      char * base = util_alloc_sprintf("--%d", iens);
      if (base_fmt && (util_int_format_count(base_fmt) == 1))
        base = util_alloc_sprintf(base_fmt, iens);

      test_assert_string_equal(base, file_base);

      char * runpath = "";
      if (util_int_format_count(runpath_fmt) == 1)
        runpath = util_alloc_sprintf(runpath_fmt, iens);
      else if (util_int_format_count(runpath_fmt) == 2)
        runpath = util_alloc_sprintf(runpath_fmt, iens,iter);

      test_assert_string_equal(runpath, file_path);

      if (iens_index+1 < int_vector_size(iens_values))
        ++iens_index;
      else if ((iens_index+1 == int_vector_size(iens_values))) {
        ++iter_index;
        iens_index = 0;
      }

      free(base);
      free(runpath);
    }

    int linecount = int_vector_size(iens_values) * int_vector_size(iter_values);
    test_assert_int_equal(linecount, counter);
    free(cwd);
    fclose(file);
  }
}