From d064cc086c988b22ab05850e47dd81baef659829 Mon Sep 17 00:00:00 2001 From: Uriel Ramirez Date: Thu, 26 Sep 2024 09:58:40 -0400 Subject: [PATCH] attempt #2 --- .../data_override/test_data_override2_mono.sh | 20 ++++- .../test_data_override2_ongrid.sh | 13 +-- .../test_data_override2_scalar.sh | 13 ++- .../test_data_override_ensembles.sh | 7 +- .../test_data_override_ongrid.F90 | 88 ++++++++++--------- .../test_data_override_weights.sh | 9 +- 6 files changed, 94 insertions(+), 56 deletions(-) diff --git a/test_fms/data_override/test_data_override2_mono.sh b/test_fms/data_override/test_data_override2_mono.sh index e3179988a..05c833389 100755 --- a/test_fms/data_override/test_data_override2_mono.sh +++ b/test_fms/data_override/test_data_override2_mono.sh @@ -27,9 +27,10 @@ output_dir [ ! -d "INPUT" ] && mkdir -p "INPUT" -cat <<_EOF > input.nml +cat <<_EOF > input_base.nml &test_data_override_ongrid_nml test_case = 2 + write_only = .False. / _EOF @@ -41,17 +42,23 @@ _EOF for KIND in r4 r8 do rm -rf INPUT/* + sed 's/write_only = .False./write_only = .True./g' input_base.nml > input.nml + test_expect_success "Creating input files (${KIND})" ' + mpirun -n 6 ../test_data_override_ongrid_${KIND} + ' + + cp input_base.nml input.nml test_expect_success "test_data_override with monotonically increasing and decreasing data sets (${KIND})" ' mpirun -n 6 ../test_data_override_ongrid_${KIND} ' - sync done rm -rf data_table -cat <<_EOF > input.nml +cat <<_EOF > input_base.nml &test_data_override_ongrid_nml test_case = 2 + write_only = .False. / &data_override_nml use_data_table_yaml = .True. @@ -81,10 +88,15 @@ if [ -z $parser_skip ]; then for KIND in r4 r8 do rm -rf INPUT/* + sed 's/write_only = .False./write_only = .True./g' input_base.nml > input.nml + test_expect_success "Creating input files (${KIND})" ' + mpirun -n 6 ../test_data_override_ongrid_${KIND} + ' + + cp input_base.nml input.nml test_expect_success "test_data_override with monotonically increasing and decreasing data sets -yaml (${KIND})" ' mpirun -n 6 ../test_data_override_ongrid_${KIND} ' - sync done fi diff --git a/test_fms/data_override/test_data_override2_ongrid.sh b/test_fms/data_override/test_data_override2_ongrid.sh index d76cdddd4..4f4bc7db8 100755 --- a/test_fms/data_override/test_data_override2_ongrid.sh +++ b/test_fms/data_override/test_data_override2_ongrid.sh @@ -36,6 +36,7 @@ use_data_table_yaml=.False. &test_data_override_ongrid_nml nhalox=halo_size nhaloy=halo_size + write_only = .False. / _EOF printf '"OCN", "runoff", "runoff", "./INPUT/runoff.daitren.clim.1440x1080.v20180328.nc", "none" , 1.0' | cat > data_table @@ -48,6 +49,7 @@ use_data_table_yaml=.True. &test_data_override_ongrid_nml nhalox=halo_size nhaloy=halo_size + write_only = .False. / _EOF cat <<_EOF > data_table.yaml @@ -66,21 +68,22 @@ fi for KIND in r4 r8 do rm -rf INPUT/* -sync +sed -e 's/halo_size/2/g ; s/write_only = .False./write_only = .True./g' input_base.nml > input.nml + +test_expect_success "Creating input files (${KIND})" ' + mpirun -n 6 ../test_data_override_ongrid_${KIND} +' + sed 's/halo_size/2/g' input_base.nml > input.nml test_expect_success "data_override on grid with 2 halos in x and y (${KIND})" ' mpirun -n 6 ../test_data_override_ongrid_${KIND} ' -rm -rf INPUT/* -sync sed 's/halo_size/0/g' input_base.nml > input.nml test_expect_success "data_override on grid with 0 halos in x and y (${KIND})" ' mpirun -n 6 ../test_data_override_ongrid_${KIND} ' -rm -rf INPUT/* -sync test_expect_success "data_override get_grid_v1 (${KIND})" ' mpirun -n 1 ../test_get_grid_v1_${KIND} ' diff --git a/test_fms/data_override/test_data_override2_scalar.sh b/test_fms/data_override/test_data_override2_scalar.sh index 82637bcfa..319684d12 100755 --- a/test_fms/data_override/test_data_override2_scalar.sh +++ b/test_fms/data_override/test_data_override2_scalar.sh @@ -28,22 +28,24 @@ output_dir rm -rf data_table data_table.yaml input.nml input_base.nml if [ ! -z $parser_skip ]; then - cat <<_EOF > input.nml + cat <<_EOF > input_base.nml &data_override_nml use_data_table_yaml=.False. / &test_data_override_ongrid_nml test_case = 3 + write_only = .False. / _EOF printf '"OCN", "co2", "co2", "./INPUT/scalar.nc", "none" , 1.0' | cat > data_table else -cat <<_EOF > input.nml +cat <<_EOF > input_base.nml &data_override_nml use_data_table_yaml=.True. / &test_data_override_ongrid_nml test_case = 3 + write_only = .False. / _EOF cat <<_EOF > data_table.yaml @@ -62,10 +64,15 @@ fi for KIND in r4 r8 do rm -rf INPUT/* +sed 's/write_only = .False./write_only = .True./g' input_base.nml > input.nml +test_expect_success "Creating input files (${KIND})" ' + mpirun -n 6 ../test_data_override_ongrid_${KIND} +' + +cp input_base.nml input.nml test_expect_success "data_override scalar field (${KIND})" ' mpirun -n 6 ../test_data_override_ongrid_${KIND} ' -sync done rm -rf INPUT *.nc # remove any leftover files to reduce size diff --git a/test_fms/data_override/test_data_override_ensembles.sh b/test_fms/data_override/test_data_override_ensembles.sh index 5be478215..2c541390e 100755 --- a/test_fms/data_override/test_data_override_ensembles.sh +++ b/test_fms/data_override/test_data_override_ensembles.sh @@ -68,10 +68,15 @@ if [ -z $parser_skip ]; then for KIND in r4 r8 do rm -rf INPUT/. + sed 's/write_only = .False./write_only = .True./g' input_base.nml > input.nml + test_expect_success "Creating input files (${KIND})" ' + mpirun -n 6 ../test_data_override_ongrid_${KIND} + ' + + cp input_base.nml input.nml test_expect_success "test_data_override with two ensembles -yaml (${KIND})" ' mpirun -n 12 ../test_data_override_ongrid_${KIND} ' - sync done cat <<_EOF > data_table.yaml diff --git a/test_fms/data_override/test_data_override_ongrid.F90 b/test_fms/data_override/test_data_override_ongrid.F90 index 5ed2354de..55115cbee 100644 --- a/test_fms/data_override/test_data_override_ongrid.F90 +++ b/test_fms/data_override/test_data_override_ongrid.F90 @@ -36,7 +36,7 @@ program test_data_override_ongrid nf90_double, nf90_unlimited use ensemble_manager_mod, only: get_ensemble_size, ensemble_manager_init -use fms_mod, only: string +use fms_mod, only: string, fms_init, fms_end implicit none @@ -61,10 +61,12 @@ program test_data_override_ongrid integer, allocatable :: pelist(:) integer, allocatable :: pelist_ens(:) integer :: ensemble_id +logical :: write_only=.false. !< True if creating the input files only + !! False if running the tests only -namelist / test_data_override_ongrid_nml / nhalox, nhaloy, test_case, nlon, nlat, layout +namelist / test_data_override_ongrid_nml / nhalox, nhaloy, test_case, nlon, nlat, layout, write_only -call mpp_init +call fms_init call fms2_io_init read (input_nml_file, test_data_override_ongrid_nml, iostat=io_status) @@ -98,46 +100,50 @@ program test_data_override_ongrid call mpp_set_current_pelist(pelist) end select -select case (test_case) -case (ongrid) - call generate_ongrid_input_file () -case (bilinear) - call generate_bilinear_input_file () -case (scalar) - call generate_scalar_input_file () -case (weight_file) - call generate_weight_input_file () -case (ensemble_case) - call generate_ensemble_input_file() -end select - -call mpp_sync() -call mpp_error(NOTE, "Finished creating INPUT Files") - -select case (test_case) -case (ensemble_case) - !< Go back to the ensemble pelist - call mpp_set_current_pelist(pelist_ens) -end select - -!< Initiliaze data_override -call data_override_init(Ocean_domain_in=Domain, mode=lkind) +if (write_only) then + select case (test_case) + case (ongrid) + call generate_ongrid_input_file () + case (bilinear) + call generate_bilinear_input_file () + case (scalar) + call generate_scalar_input_file () + case (weight_file) + call generate_weight_input_file () + case (ensemble_case) + call generate_ensemble_input_file() + end select -select case (test_case) -case (ongrid) - call ongrid_test() -case (bilinear) - call bilinear_test() -case (scalar) - call scalar_test() -case (weight_file) - call weight_file_test() -case (ensemble_case) - call ensemble_test() - call mpp_set_current_pelist(pelist) -end select + call mpp_sync() + call mpp_error(NOTE, "Finished creating INPUT Files") -call mpp_exit +else + call mpp_error(FATAL, "WUT") + select case (test_case) + case (ensemble_case) + !< Go back to the ensemble pelist + call mpp_set_current_pelist(pelist_ens) + end select + + !< Initiliaze data_override + call data_override_init(Ocean_domain_in=Domain, mode=lkind) + + select case (test_case) + case (ongrid) + call ongrid_test() + case (bilinear) + call bilinear_test() + case (scalar) + call scalar_test() + case (weight_file) + call weight_file_test() + case (ensemble_case) + call ensemble_test() + call mpp_set_current_pelist(pelist) + end select +endif + +call fms_end contains diff --git a/test_fms/data_override/test_data_override_weights.sh b/test_fms/data_override/test_data_override_weights.sh index 2c558e51b..aae82e5bd 100755 --- a/test_fms/data_override/test_data_override_weights.sh +++ b/test_fms/data_override/test_data_override_weights.sh @@ -48,7 +48,7 @@ data_table: factor: 1.0 _EOF -cat <<_EOF > input.nml +cat <<_EOF > input_base.nml &data_override_nml use_data_table_yaml = .True. / @@ -66,10 +66,15 @@ if [ -z $parser_skip ]; then for KIND in r4 r8 do rm -rf INPUT/. + sed 's/write_only = .False./write_only = .True./g' input_base.nml > input.nml + test_expect_success "Creating input files (${KIND})" ' + mpirun -n 6 ../test_data_override_ongrid_${KIND} + ' + + cp input_base.nml input.nml test_expect_success "test_data_override with and without weight files -yaml (${KIND})" ' mpirun -n 2 ../test_data_override_ongrid_${KIND} ' - sync done fi