static void * enkf_main_smoother_JOB__( void * self , int iter , const stringlist_type * args ) { enkf_main_type * enkf_main = enkf_main_safe_cast( self ); int ens_size = enkf_main_get_ensemble_size( enkf_main ); bool_vector_type * iactive = bool_vector_alloc( ens_size , true ); bool valid = true; const char * target_case; enkf_fs_type * target_fs = enkf_main_get_fs( enkf_main ); // Argument 0: Which case to write to. Default current case. if (stringlist_get_size(args)) { target_case = stringlist_iget( args , 0 ); if (strcmp( target_case , CURRENT_CASE_STRING) == 0) target_case = enkf_fs_get_case_name(target_fs); } else target_case = enkf_fs_get_case_name(target_fs); //Argument 1: Rerun. Default false. bool rerun = (stringlist_get_size(args) >= 2) ? stringlist_iget_as_bool(args, 1, &valid) : false; if (!valid) { fprintf(stderr, "** Warning: Function %s : Second argument must be a bool value. Exiting job\n", __func__); return NULL; } enkf_main_run_smoother( enkf_main , target_case , iactive , iter , rerun); bool_vector_free( iactive ); return NULL; }
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 ); }
static void enkf_main_update_current_case( enkf_main_type * enkf_main , const char * case_path /* Can be NULL */) { if (!case_path) case_path = enkf_fs_get_case_name( enkf_main_get_fs(enkf_main) ); enkf_main_write_current_case_file(enkf_main, case_path); update_case_log(enkf_main , case_path); enkf_main_gen_data_special( enkf_main ); enkf_main_add_subst_kw( enkf_main , "ERT-CASE" , enkf_main_get_current_fs( enkf_main ) , "Current case" , true ); enkf_main_add_subst_kw( enkf_main , "ERTCASE" , enkf_main_get_current_fs( enkf_main ) , "Current case" , true ); }
void test_magic_strings( ert_test_context_type * test_context ) { enkf_main_type * enkf_main = ert_test_context_get_main( test_context ); test_assert_true( ert_test_context_run_worklow( test_context , "MAGIC_PRINT") ); test_assert_true( util_file_exists( "magic-list.txt") ); { FILE * stream = util_fopen("magic-list.txt" , "r"); char string[128]; fscanf( stream , "%s" , string); test_assert_string_equal( string , enkf_fs_get_case_name( enkf_main_get_fs( enkf_main ))); fscanf( stream , "%s" , string); test_assert_string_equal( string , "MagicAllTheWayToWorkFlow"); fclose( stream ); } }
const char * enkf_main_get_current_fs( const enkf_main_type * enkf_main ) { return enkf_fs_get_case_name( enkf_main->dbase ); }