Ejemplo n.º 1
0
void test_run_workflow(const char * config_file , const char * job_file) {
  ert_test_context_type * test_context = ert_test_context_alloc("INSTALL_WORKFLOW" , config_file , NULL );
  test_assert_false( ert_test_context_run_worklow( test_context , "No-does.not.exist"));
  
  ert_test_context_install_workflow_job( test_context , "JOB" , job_file );
  {
    FILE * stream1 = util_fopen( "WFLOW1", "w");
    FILE * stream2 = util_fopen( "WFLOW2", "w");
    stringlist_type * args = stringlist_alloc_new( );
    ert_test_context_fwrite_workflow_job( stream1 , "JOB" , args);
    stringlist_append_ref( args , "NewCase");
    ert_test_context_fwrite_workflow_job( stream2 , "JOB" , args);
        
    stringlist_free( args );
    fclose( stream1 );
    fclose( stream2 );
  }
  test_assert_true( ert_test_context_install_workflow( test_context , "WFLOW1" , "WFLOW1"));
  test_assert_true( ert_test_context_install_workflow( test_context , "WFLOW2" , "WFLOW2"));
  
  test_assert_true( ert_test_context_run_worklow( test_context , "WFLOW2"));
  test_assert_false( ert_test_context_run_worklow( test_context , "WFLOW1"));

  ert_test_context_free( test_context );
}
Ejemplo n.º 2
0
int main(int argc , char ** argv) {
    enkf_main_install_SIGNALS();

    const char * config_file             = argv[1];
    ert_test_context_type * test_context = ert_test_context_alloc("VerifyJobsFileTest" , config_file);
    enkf_main_type * enkf_main           = ert_test_context_get_main(test_context);

    {
        const int ens_size         = enkf_main_get_ensemble_size( enkf_main );
        bool_vector_type * iactive = bool_vector_alloc(0, false);
        bool_vector_iset( iactive , ens_size - 1 , true );

        enkf_main_create_run_path(enkf_main , iactive , 0);
        bool_vector_free(iactive);
    }

    const char * filename = util_alloc_filename(ert_test_context_get_cwd(test_context),
                            "simulations/run0/jobs.py", NULL);
    const char * jobs_file_content = util_fread_alloc_file_content(filename, NULL);

    test_assert_true  (strstr(jobs_file_content, "umask = 0022") != NULL);
    test_assert_false (strstr(jobs_file_content, "umask = 0023") != NULL);
    test_assert_false (strstr(jobs_file_content, "umask = 0032") != NULL);
    test_assert_false (strstr(jobs_file_content, "umask = 0122") != NULL);
    test_assert_false (strstr(jobs_file_content, "umask = 1022") != NULL);

    ert_test_context_free(test_context);
    exit(0);
}
Ejemplo n.º 3
0
int main(int argc , const char ** argv) {
  enkf_main_install_SIGNALS();

  const char * config_file                  = argv[1];
  const char * config_file_iterations       = argv[2];
  const char * job_file_create_case         = argv[3];
  const char * job_file_init_case_job       = argv[4];
  const char * job_file_load_results        = argv[5];
  const char * job_file_load_results_iter   = argv[6];
  const char * job_file_observation_ranking = argv[7];
  const char * job_file_data_ranking        = argv[8];
  const char * job_file_ranking_export      = argv[9];
  const char * job_file_init_misfit_table   = argv[10];
  const char * job_file_export_runpath      = argv[11];


  ert_test_context_type * test_context = create_context( config_file, "enkf_workflow_job_test" );
  {
    test_create_case_job(test_context, "JOB1" , job_file_create_case);
    test_init_case_job(test_context, "JOB2", job_file_init_case_job);
    test_load_results_job(test_context, "JOB3" , job_file_load_results);
    test_load_results_iter_job( test_context, "JOB4" , job_file_load_results_iter );
    test_init_misfit_table(test_context, "JOB5" , job_file_init_misfit_table);
    test_rank_realizations_on_observations_job(test_context, "JOB6" , job_file_observation_ranking);
    test_rank_realizations_on_data_job(test_context , "JOB7" , job_file_data_ranking);
    test_export_ranking(test_context, "JOB8" , job_file_ranking_export);
  }
  ert_test_context_free( test_context );

  test_export_runpath_files(config_file, config_file_iterations, job_file_export_runpath);

  exit(0);
}
Ejemplo n.º 4
0
void test_install_job( const char * config_file, const char * job_file_OK , const char * job_file_ERROR) {
  ert_test_context_type * test_context = ert_test_context_alloc("CREATE_CONTEXT_JOB" , config_file , NULL );

  test_assert_false( ert_test_context_install_workflow_job( test_context , "JOB" , "File/does/not/exist"));
  test_assert_false( ert_test_context_install_workflow_job( test_context , "ERROR" , job_file_ERROR));
  test_assert_true( ert_test_context_install_workflow_job( test_context , "OK" , job_file_OK));
  
  ert_test_context_free( test_context );
}
Ejemplo n.º 5
0
void test_update_default(const char * config_file , const char * job_file) {
  ert_test_context_type * test_context = ert_test_context_alloc("AnalysisJob0" , config_file);

  stringlist_type * args = stringlist_alloc_new();
  test_assert_true( ert_test_context_install_workflow_job( test_context , "JOB" , job_file ));
  test_assert_true( ert_test_context_run_worklow_job( test_context , "JOB" , args) );
  stringlist_free( args );

  ert_test_context_free( test_context );
}
Ejemplo n.º 6
0
void test_update_new_case(const char * config_file , const char * job_file) {
  ert_test_context_type * test_context = ert_test_context_alloc("AnalysisJob1" , config_file);

  stringlist_type * args = stringlist_alloc_new();
  stringlist_append_copy( args , "NewCase" );
  ert_test_context_install_workflow_job( test_context , "JOB" , job_file );
  test_assert_true( ert_test_context_run_worklow_job( test_context , "JOB" , args) );
  stringlist_free( args );
  
  ert_test_context_free( test_context );
}
Ejemplo n.º 7
0
int main( int argc , char ** argv) {
    const char * config_file = argv[1];
    util_install_signals();
    ert_test_context_type * test_context = ert_test_context_alloc("GENDATA" , config_file , NULL );
    enkf_main_type * enkf_main = ert_test_context_get_main( test_context );

    test_gendata( enkf_main , "GEN_TIMESHIFT" , 60);

    ert_test_context_free( test_context );
    exit(0);
}
Ejemplo n.º 8
0
int main(int argc , char ** argv) {
  const char * config_file             =  argv[1];
  ert_test_context_type * test_context = ert_test_context_alloc("gen_kw_test" , config_file , NULL);
  enkf_main_type * enkf_main           = ert_test_context_get_main(test_context);
  test_assert_not_NULL(enkf_main);

  test_write_gen_kw_export_file(enkf_main);
  test_assert_util_abort("gen_kw_ecl_write", test_send_fortio_to_gen_kw_ecl_write, enkf_main);

  ert_test_context_free( test_context );
  exit(0);
}
Ejemplo n.º 9
0
int main(int argc , char ** argv) {
  const char * config_file = argv[1];
  ert_test_context_type * context = ert_test_context_alloc( "OBS_VECTOR_FS" , config_file);
  enkf_main_type * enkf_main = ert_test_context_get_main( context );

  {
    test_valid_obs_vector( enkf_main , "WWCT:OP_3");
    test_container( context );
    test_measure( context );
    test_invalid_obs_vector( enkf_main , "GOPT:OP");
  }
  ert_test_context_free( context );
}
Ejemplo n.º 10
0
void test_create_valid( const char * config_file ) {
  char * cwd0 = util_alloc_cwd();
  ert_test_context_type * test_context = ert_test_context_alloc("CREATE_CONTEXT" , config_file , NULL );
  test_assert_true( ert_test_context_is_instance( test_context ));
  test_assert_true( enkf_main_is_instance( ert_test_context_get_main( test_context )));
  {
    char * cwd1 = util_alloc_cwd();
    test_assert_string_not_equal(cwd1 , cwd0);
    free( cwd1 );
  }
  free( cwd0 );
  ert_test_context_free( test_context );
}
void test_update_selected_step(const char * config_file , const char * job_file) {
  ert_test_context_type * test_context = ert_test_context_alloc("AnalysisJob2" , config_file);

  stringlist_type * args = stringlist_alloc_new();
  stringlist_append_copy( args , "50" );
  stringlist_append_copy( args , "10" );
  stringlist_append_copy( args , ",20" );
  stringlist_append_copy( args , ",30-50" );
  ert_test_context_install_workflow_job( test_context , "JOB" , job_file );
  test_assert_true( ert_test_context_run_worklow_job( test_context , "JOB" , args) );
  stringlist_free( args );
  
  ert_test_context_free( test_context );
}
Ejemplo n.º 12
0
int main(int argc , char ** argv) {
  util_install_signals();
  {
    const char * config_file = argv[1];
    ert_test_context_type * test_context = ert_test_context_alloc( "ENKF_OBS_FS" , config_file );
    {
      testS( test_context );
      test_iget( test_context );
      test_container( test_context );
    }
    ert_test_context_free( test_context );
    exit(0);
  }
}
Ejemplo n.º 13
0
void test_config( const char * config_file ) {
  ert_test_context_type * test_context = ert_test_context_alloc( "RUNPATH_FILE" , config_file , NULL );
  enkf_main_type * enkf_main = ert_test_context_get_main( test_context );
  qc_module_type * qc_module = enkf_main_get_qc_module( enkf_main );

  ert_test_context_run_worklow( test_context , "ARGECHO_WF");
  {
    FILE * stream = util_fopen("runpath_list.txt" , "r");
    char runpath_file[256];
    fscanf(stream , "%s" , runpath_file );
    fclose( stream );
    test_assert_string_equal( runpath_file , qc_module_get_runpath_list_file( qc_module ));
  }
  
  ert_test_context_free( test_context );
}
Ejemplo n.º 14
0
void test_run_workflow_job( const char * config_file , const char * job_file ) {
  ert_test_context_type * test_context = ert_test_context_alloc("CREATE_CONTEXT_JOB" , config_file , NULL );
  stringlist_type * args0 = stringlist_alloc_new( );
  stringlist_type * args1 = stringlist_alloc_new( );

  stringlist_append_ref( args1 , "NewCase");
  test_assert_false( ert_test_context_run_worklow_job( test_context , "NO-this-does-not-exist" , args1));
  ert_test_context_install_workflow_job( test_context , "JOB" , job_file );
  
  test_assert_false( ert_test_context_run_worklow_job( test_context , "JOB" , args0));
  test_assert_true( ert_test_context_run_worklow_job( test_context , "JOB" , args1));
  
  stringlist_free( args0 );
  stringlist_free( args1 );
  ert_test_context_free( test_context );
}
Ejemplo n.º 15
0
void test_install_workflow( const char * config_file , const char * job_file ) {
  ert_test_context_type * test_context = ert_test_context_alloc("INSTALL_WORKFLOW" , config_file , NULL );
  const char * wf_file = "WFLOW";

  ert_test_context_install_workflow_job( test_context , "JOB" , job_file );
  {
    FILE * stream = util_fopen( wf_file , "w");
    stringlist_type * args = stringlist_alloc_new( );
    stringlist_append_ref( args , "NewCase");
    ert_test_context_fwrite_workflow_job( stream , "JOB" , args);
    stringlist_free( args );
    fclose( stream );
  }
  test_assert_true( ert_test_context_install_workflow( test_context , "WFLOW" , wf_file ));
  ert_test_context_free( test_context );
}
Ejemplo n.º 16
0
int main( int argc , char ** argv) {
  const char * model_config = argv[1];
  const char * site_config = NULL;
  ert_test_context_type * test_context = ert_test_context_alloc( "MAGIC-STRINGS" , model_config , site_config);
  enkf_main_type * enkf_main = ert_test_context_get_main( test_context );

  {
    test_has_job( test_context );

    enkf_main_select_fs(enkf_main , "default");
    test_assert_string_equal( "default" , enkf_fs_get_case_name( enkf_main_get_fs( enkf_main )));
    test_magic_strings( test_context );
    
    enkf_main_select_fs(enkf_main , "extraCase");
    test_assert_string_equal( "extraCase" , enkf_fs_get_case_name( enkf_main_get_fs( enkf_main )));
    test_magic_strings( test_context );
  }
  ert_test_context_free( test_context );
}
Ejemplo n.º 17
0
int main(int argc , char ** argv) {
  enkf_main_install_SIGNALS();

  const char * config_file = argv[1];
  const char * init_file   = argv[2];
  const char * key         = "PORO";
  int iens                 = 0;

  ert_test_context_type * test_context         = ert_test_context_alloc("ExportInactiveCellsTest" , config_file);
  enkf_main_type * enkf_main                   = ert_test_context_get_main(test_context);
  enkf_fs_type * fs                            = enkf_main_get_fs(enkf_main);
  const ensemble_config_type * ensemble_config = enkf_main_get_ensemble_config(enkf_main);
  const enkf_config_node_type * config_node    = ensemble_config_get_node(ensemble_config , key);
  const field_config_type * field_config       = enkf_config_node_get_ref( config_node );
  enkf_state_type * state                      = enkf_main_iget_state( enkf_main , iens );
  enkf_node_type * field_node                  = enkf_state_get_node( state , key );
  field_type * field                           = enkf_node_value_ptr(field_node);

  {
    forward_initialize_node(enkf_main, init_file, field_node);
    node_id_type node_id = {.report_step = 0 , .iens = iens , .state = BOTH };
    test_assert_true(enkf_node_try_load(field_node , fs , node_id));
    field_scale(field, 3.0);
  }

  int nx,ny,nz;
  field_config_get_dims(field_config , &nx , &ny , &nz);
  const char * export_file_grdecl = "my_test_dir/exported_field_test_file_grdecl";
  const char * export_file_roff   = "my_test_dir/exported_field_test_file_roff";
  field_file_format_type file_type;

  char * found_init_file = enkf_main_alloc_abs_path_to_init_file(enkf_main, config_node);
  {
    file_type = ECL_GRDECL_FILE;
    field_export(field, export_file_grdecl, NULL, file_type, false, found_init_file);
    check_exported_data(export_file_grdecl, init_file, file_type, field_config, field, nx, ny, nz);
  }
  {
    file_type = RMS_ROFF_FILE;
    field_export(field, export_file_roff, NULL, file_type, false, found_init_file);
    check_exported_data(export_file_roff, init_file, file_type, field_config, field, nx, ny, nz);
  }

  free(found_init_file);
  found_init_file = NULL;
  {
    file_type = ECL_GRDECL_FILE;
    field_export(field, export_file_grdecl, NULL, file_type, false, found_init_file);
    check_exported_data(export_file_grdecl, found_init_file, file_type, field_config, field, nx, ny, nz);
  }
  {
    file_type = RMS_ROFF_FILE;
    field_export(field, export_file_roff, NULL, file_type, false, found_init_file);
    check_exported_data(export_file_roff, found_init_file, file_type, field_config, field, nx, ny, nz);
  }



  ert_test_context_free(test_context);
  exit(0);
}
Ejemplo n.º 18
0
void test_export_runpath_files(const char * config_file,
                               const char * config_file_iterations,
                               const char * job_file_export_runpath) {

  stringlist_type * args = stringlist_alloc_new();
  const char * job_name  = "export_job";

  ert_test_context_type * test_context_iterations = create_context( config_file_iterations, "enkf_workflow_job_test_export_runpath_iter" );

  {
    int_vector_type * iens_values = int_vector_alloc(5,0);
    const int iens[5] = {0,1,2,3,4};
    int_vector_set_many(iens_values, 0, &iens[0], 5);
    int_vector_type * iter_values = int_vector_alloc(1,0);

    test_export_runpath_file(test_context_iterations, job_name, job_file_export_runpath, args, iens_values, iter_values);

    int_vector_free(iens_values);
    int_vector_free(iter_values);
  }
  {
    stringlist_append_copy( args, "0-2"); //realization range

    int_vector_type * iens_values = int_vector_alloc(3,0);
    const int iens[] = {0,1,2};
    int_vector_set_many(iens_values, 0, &iens[0], 3);
    int_vector_type * iter_values = int_vector_alloc(1,0);

    test_export_runpath_file(test_context_iterations, job_name, job_file_export_runpath, args, iens_values, iter_values);

    int_vector_free(iens_values);
    int_vector_free(iter_values);

    stringlist_clear(args);
  }
  {
    stringlist_append_copy( args, "0,3-5"); //realization range

    int_vector_type * iens_values = int_vector_alloc(4,0);
    const int iens[] = {0,3,4,5};
    int_vector_set_many(iens_values, 0, &iens[0], 4);
    int_vector_type * iter_values = int_vector_alloc(1,0);

    test_export_runpath_file(test_context_iterations, job_name, job_file_export_runpath, args, iens_values, iter_values);

    int_vector_free(iens_values);
    int_vector_free(iter_values);

    stringlist_clear(args);
  }
  {
    stringlist_append_copy( args, "1-2"); //realization range
    stringlist_append_copy( args, "|");   //delimiter
    stringlist_append_copy( args, "1-3"); //iteration range

    int_vector_type * iens_values = int_vector_alloc(2,0);
    int iens[] = {1,2};
    int_vector_set_many(iens_values, 0, &iens[0], 2);
    int_vector_type * iter_values = int_vector_alloc(3,0);
    int iter[] = {1,2,3};
    int_vector_set_many(iter_values, 0, &iter[0], 3);

    test_export_runpath_file(test_context_iterations, job_name, job_file_export_runpath, args, iens_values, iter_values);

    int_vector_free(iens_values);
    int_vector_free(iter_values);

    stringlist_clear(args);
  }
  {
    stringlist_append_copy( args, "*");   //realization range
    stringlist_append_copy( args, "|");   //delimiter
    stringlist_append_copy( args, "*");   //iteration range

    int_vector_type * iens_values = int_vector_alloc(5,0);
    int iens[] = {0,1,2,3,4};
    int_vector_set_many(iens_values, 0, &iens[0], 5);
    int_vector_type * iter_values = int_vector_alloc(4,0);
    int iter[] = {0,1,2,3};
    int_vector_set_many(iter_values, 0, &iter[0], 4);

    test_export_runpath_file(test_context_iterations, job_name, job_file_export_runpath, args, iens_values, iter_values);

    int_vector_free(iens_values);
    int_vector_free(iter_values);

    stringlist_clear(args);
  }

  ert_test_context_free(test_context_iterations);
  ert_test_context_type * test_context = create_context( config_file, "enkf_workflow_job_test_export_runpath" );

  {
    int_vector_type * iens_values = int_vector_alloc(1,0);
    int_vector_init_range(iens_values, 0, 25, 1);
    int_vector_type * iter_values = int_vector_alloc(1,0);

    test_export_runpath_file(test_context, job_name, job_file_export_runpath, args, iens_values, iter_values);

    int_vector_free(iens_values);
    int_vector_free(iter_values);

    stringlist_clear(args);
  }
  {
    stringlist_append_copy( args, "1-3"); //realization range

    int_vector_type * iens_values = int_vector_alloc(3,0);
    int iens[] = {1,2,3};
    int_vector_set_many(iens_values, 0, &iens[0], 3);
    int_vector_type * iter_values = int_vector_alloc(1,0);

    test_export_runpath_file(test_context, job_name, job_file_export_runpath, args, iens_values, iter_values);

    int_vector_free(iens_values);
    int_vector_free(iter_values);

    stringlist_clear(args);
  }
  {
    stringlist_append_copy( args, "1,2"); //realization range
    stringlist_append_copy( args, "|");   //delimiter
    stringlist_append_copy( args, "1-3"); //iteration range

    int_vector_type * iens_values = int_vector_alloc(2,0);
    int iens[] = {1,2};
    int_vector_set_many(iens_values, 0, &iens[0], 2);
    int_vector_type * iter_values = int_vector_alloc(1,0);

    test_export_runpath_file(test_context, job_name, job_file_export_runpath, args, iens_values, iter_values);

    int_vector_free(iens_values);
    int_vector_free(iter_values);

    stringlist_clear(args);
  }


  ert_test_context_free(test_context);


  stringlist_free( args );
}