From a2920f91d7da1b1436d5519a241c81d051f78037 Mon Sep 17 00:00:00 2001 From: Helen Kershaw Date: Fri, 9 Aug 2024 08:20:53 -0400 Subject: [PATCH 1/8] feat: gamma distribution test program --- .../gamma_dist/test_gamma_dist.f90 | 16 ++++++++ developer_tests/gamma_dist/work/input.nml | 13 ++++++ developer_tests/gamma_dist/work/quickbuild.sh | 40 +++++++++++++++++++ 3 files changed, 69 insertions(+) create mode 100644 developer_tests/gamma_dist/test_gamma_dist.f90 create mode 100644 developer_tests/gamma_dist/work/input.nml create mode 100755 developer_tests/gamma_dist/work/quickbuild.sh diff --git a/developer_tests/gamma_dist/test_gamma_dist.f90 b/developer_tests/gamma_dist/test_gamma_dist.f90 new file mode 100644 index 000000000..5a6b701ff --- /dev/null +++ b/developer_tests/gamma_dist/test_gamma_dist.f90 @@ -0,0 +1,16 @@ +! DART software - Copyright UCAR. This open source software is provided +! by UCAR, "as is", without charge, subject to all terms of use at +! http://www.image.ucar.edu/DAReS/DART/DART_download + +program test_gamma_distribution + +use utilities_mod, only : initialize_utilities, finalize_utilities +use gamma_distribution_mod, only : test_gamma + +implicit none + +call initialize_utilities() +call test_gamma() +call finalize_utilities() + +end program test_gamma_distribution diff --git a/developer_tests/gamma_dist/work/input.nml b/developer_tests/gamma_dist/work/input.nml new file mode 100644 index 000000000..83525855e --- /dev/null +++ b/developer_tests/gamma_dist/work/input.nml @@ -0,0 +1,13 @@ +&utilities_nml + module_details = .false. + / + +&preprocess_nml + input_obs_qty_mod_file = '../../../assimilation_code/modules/observations/DEFAULT_obs_kind_mod.F90' + output_obs_qty_mod_file = '../../../assimilation_code/modules/observations/obs_kind_mod.f90' + input_obs_def_mod_file = '../../../observations/forward_operators/DEFAULT_obs_def_mod.F90' + output_obs_def_mod_file = '../../../observations/forward_operators/obs_def_mod.f90' + obs_type_files = '../../../observations/forward_operators/obs_def_gps_mod.f90' + quantity_files = '../../../assimilation_code/modules/observations/default_quantities_mod.f90' + / + diff --git a/developer_tests/gamma_dist/work/quickbuild.sh b/developer_tests/gamma_dist/work/quickbuild.sh new file mode 100755 index 000000000..2d773835a --- /dev/null +++ b/developer_tests/gamma_dist/work/quickbuild.sh @@ -0,0 +1,40 @@ +#!/usr/bin/env bash + +# DART software - Copyright UCAR. This open source software is provided +# by UCAR, "as is", without charge, subject to all terms of use at +# http://www.image.ucar.edu/DAReS/DART/DART_download + +main() { + + +export DART=$(git rev-parse --show-toplevel) +source "$DART"/build_templates/buildfunctions.sh + +MODEL="none" +EXTRA="$DART"/models/template/threed_model_mod.f90 +dev_test=1 +LOCATION="threed_sphere" +TEST="gamma_dist" + +serial_programs=( +test_gamma_dist +) + +# quickbuild arguments +arguments "$@" + +# clean the directory +\rm -f -- *.o *.mod Makefile .cppdefs + +# build and run preprocess before making any other DART executables +buildpreprocess + +# build DART +buildit + +# clean up +\rm -f -- *.o *.mod + +} + +main "$@" From c84461f5162ef8493a800f909a3c6dab8ea41b68 Mon Sep 17 00:00:00 2001 From: Helen Kershaw Date: Fri, 9 Aug 2024 08:57:26 -0400 Subject: [PATCH 2/8] feat: normal_dist test harness --- .gitignore | 2 + .../normal_dist/test_normal_dist.f90 | 16 ++++++++ developer_tests/normal_dist/work/input.nml | 13 ++++++ .../normal_dist/work/quickbuild.sh | 40 +++++++++++++++++++ 4 files changed, 71 insertions(+) create mode 100644 developer_tests/normal_dist/test_normal_dist.f90 create mode 100644 developer_tests/normal_dist/work/input.nml create mode 100755 developer_tests/normal_dist/work/quickbuild.sh diff --git a/.gitignore b/.gitignore index 7d4937541..e5b66c4c5 100644 --- a/.gitignore +++ b/.gitignore @@ -199,6 +199,8 @@ test_quad_irreg_interp test_quad_reg_interp test_table_read test_ran_unif +test_gamma_dist +test_normal_dist # Directories to NOT IGNORE ... same as executable names # as far as I know, these must be listed after the executables diff --git a/developer_tests/normal_dist/test_normal_dist.f90 b/developer_tests/normal_dist/test_normal_dist.f90 new file mode 100644 index 000000000..5d829e7a2 --- /dev/null +++ b/developer_tests/normal_dist/test_normal_dist.f90 @@ -0,0 +1,16 @@ +! DART software - Copyright UCAR. This open source software is provided +! by UCAR, "as is", without charge, subject to all terms of use at +! http://www.image.ucar.edu/DAReS/DART/DART_download + +program test_normal_distribution + +use utilities_mod, only : initialize_utilities, finalize_utilities +use normal_distribution_mod, only : test_normal + +implicit none + +call initialize_utilities() +call test_normal() +call finalize_utilities() + +end program test_normal_distribution diff --git a/developer_tests/normal_dist/work/input.nml b/developer_tests/normal_dist/work/input.nml new file mode 100644 index 000000000..83525855e --- /dev/null +++ b/developer_tests/normal_dist/work/input.nml @@ -0,0 +1,13 @@ +&utilities_nml + module_details = .false. + / + +&preprocess_nml + input_obs_qty_mod_file = '../../../assimilation_code/modules/observations/DEFAULT_obs_kind_mod.F90' + output_obs_qty_mod_file = '../../../assimilation_code/modules/observations/obs_kind_mod.f90' + input_obs_def_mod_file = '../../../observations/forward_operators/DEFAULT_obs_def_mod.F90' + output_obs_def_mod_file = '../../../observations/forward_operators/obs_def_mod.f90' + obs_type_files = '../../../observations/forward_operators/obs_def_gps_mod.f90' + quantity_files = '../../../assimilation_code/modules/observations/default_quantities_mod.f90' + / + diff --git a/developer_tests/normal_dist/work/quickbuild.sh b/developer_tests/normal_dist/work/quickbuild.sh new file mode 100755 index 000000000..2570f489c --- /dev/null +++ b/developer_tests/normal_dist/work/quickbuild.sh @@ -0,0 +1,40 @@ +#!/usr/bin/env bash + +# DART software - Copyright UCAR. This open source software is provided +# by UCAR, "as is", without charge, subject to all terms of use at +# http://www.image.ucar.edu/DAReS/DART/DART_download + +main() { + + +export DART=$(git rev-parse --show-toplevel) +source "$DART"/build_templates/buildfunctions.sh + +MODEL="none" +EXTRA="$DART"/models/template/threed_model_mod.f90 +dev_test=1 +LOCATION="threed_sphere" +TEST="normal_dist" + +serial_programs=( +test_normal_dist +) + +# quickbuild arguments +arguments "$@" + +# clean the directory +\rm -f -- *.o *.mod Makefile .cppdefs + +# build and run preprocess before making any other DART executables +buildpreprocess + +# build DART +buildit + +# clean up +\rm -f -- *.o *.mod + +} + +main "$@" From c532129f3e917b4bfbf9234862a55bdeb753c16a Mon Sep 17 00:00:00 2001 From: Helen Kershaw Date: Fri, 9 Aug 2024 09:01:32 -0400 Subject: [PATCH 3/8] feat: beta distribution test harness This is failing GNU Fortran (MacPorts gcc13 13.2.0_4+stdlib_flag) 13.2.0 inv_cdf Failed to converge for quantile 0.0000000000000000 ---------------------------- max difference in inversion is 7.8846335608728112E-006 max difference should be less than 1e-14 --- .gitignore | 1 + developer_tests/beta_dist/test_beta_dist.f90 | 16 ++++++++ developer_tests/beta_dist/work/input.nml | 13 +++++++ developer_tests/beta_dist/work/quickbuild.sh | 40 ++++++++++++++++++++ 4 files changed, 70 insertions(+) create mode 100644 developer_tests/beta_dist/test_beta_dist.f90 create mode 100644 developer_tests/beta_dist/work/input.nml create mode 100755 developer_tests/beta_dist/work/quickbuild.sh diff --git a/.gitignore b/.gitignore index e5b66c4c5..a15a8cf8f 100644 --- a/.gitignore +++ b/.gitignore @@ -201,6 +201,7 @@ test_table_read test_ran_unif test_gamma_dist test_normal_dist +test_beta_dist # Directories to NOT IGNORE ... same as executable names # as far as I know, these must be listed after the executables diff --git a/developer_tests/beta_dist/test_beta_dist.f90 b/developer_tests/beta_dist/test_beta_dist.f90 new file mode 100644 index 000000000..2432d9817 --- /dev/null +++ b/developer_tests/beta_dist/test_beta_dist.f90 @@ -0,0 +1,16 @@ +! DART software - Copyright UCAR. This open source software is provided +! by UCAR, "as is", without charge, subject to all terms of use at +! http://www.image.ucar.edu/DAReS/DART/DART_download + +program test_beta_distribution + +use utilities_mod, only : initialize_utilities, finalize_utilities +use beta_distribution_mod, only : test_beta + +implicit none + +call initialize_utilities() +call test_beta() +call finalize_utilities() + +end program test_beta_distribution diff --git a/developer_tests/beta_dist/work/input.nml b/developer_tests/beta_dist/work/input.nml new file mode 100644 index 000000000..83525855e --- /dev/null +++ b/developer_tests/beta_dist/work/input.nml @@ -0,0 +1,13 @@ +&utilities_nml + module_details = .false. + / + +&preprocess_nml + input_obs_qty_mod_file = '../../../assimilation_code/modules/observations/DEFAULT_obs_kind_mod.F90' + output_obs_qty_mod_file = '../../../assimilation_code/modules/observations/obs_kind_mod.f90' + input_obs_def_mod_file = '../../../observations/forward_operators/DEFAULT_obs_def_mod.F90' + output_obs_def_mod_file = '../../../observations/forward_operators/obs_def_mod.f90' + obs_type_files = '../../../observations/forward_operators/obs_def_gps_mod.f90' + quantity_files = '../../../assimilation_code/modules/observations/default_quantities_mod.f90' + / + diff --git a/developer_tests/beta_dist/work/quickbuild.sh b/developer_tests/beta_dist/work/quickbuild.sh new file mode 100755 index 000000000..bc7f67a31 --- /dev/null +++ b/developer_tests/beta_dist/work/quickbuild.sh @@ -0,0 +1,40 @@ +#!/usr/bin/env bash + +# DART software - Copyright UCAR. This open source software is provided +# by UCAR, "as is", without charge, subject to all terms of use at +# http://www.image.ucar.edu/DAReS/DART/DART_download + +main() { + + +export DART=$(git rev-parse --show-toplevel) +source "$DART"/build_templates/buildfunctions.sh + +MODEL="none" +EXTRA="$DART"/models/template/threed_model_mod.f90 +dev_test=1 +LOCATION="threed_sphere" +TEST="beta_dist" + +serial_programs=( +test_beta_dist +) + +# quickbuild arguments +arguments "$@" + +# clean the directory +\rm -f -- *.o *.mod Makefile .cppdefs + +# build and run preprocess before making any other DART executables +buildpreprocess + +# build DART +buildit + +# clean up +\rm -f -- *.o *.mod + +} + +main "$@" From 2feb8698306268d4ab3fdc1f3e42d19ff6f1b13c Mon Sep 17 00:00:00 2001 From: Helen Kershaw Date: Fri, 9 Aug 2024 09:05:50 -0400 Subject: [PATCH 4/8] feat: test harness for bnrh_dist Note no test_bnrh subroutine exists --- developer_tests/bnrh_dist/test_bnrh_dist.f90 | 16 ++++++++ developer_tests/bnrh_dist/work/input.nml | 13 +++++++ developer_tests/bnrh_dist/work/quickbuild.sh | 40 ++++++++++++++++++++ developer_tests/create_dist_test.sh | 23 +++++++++++ 4 files changed, 92 insertions(+) create mode 100644 developer_tests/bnrh_dist/test_bnrh_dist.f90 create mode 100644 developer_tests/bnrh_dist/work/input.nml create mode 100755 developer_tests/bnrh_dist/work/quickbuild.sh create mode 100755 developer_tests/create_dist_test.sh diff --git a/developer_tests/bnrh_dist/test_bnrh_dist.f90 b/developer_tests/bnrh_dist/test_bnrh_dist.f90 new file mode 100644 index 000000000..57fe820c9 --- /dev/null +++ b/developer_tests/bnrh_dist/test_bnrh_dist.f90 @@ -0,0 +1,16 @@ +! DART software - Copyright UCAR. This open source software is provided +! by UCAR, "as is", without charge, subject to all terms of use at +! http://www.image.ucar.edu/DAReS/DART/DART_download + +program test_bnrh_distribution + +use utilities_mod, only : initialize_utilities, finalize_utilities +use bnrh_distribution_mod, only : test_bnrh + +implicit none + +call initialize_utilities() +call test_bnrh() +call finalize_utilities() + +end program test_bnrh_distribution diff --git a/developer_tests/bnrh_dist/work/input.nml b/developer_tests/bnrh_dist/work/input.nml new file mode 100644 index 000000000..83525855e --- /dev/null +++ b/developer_tests/bnrh_dist/work/input.nml @@ -0,0 +1,13 @@ +&utilities_nml + module_details = .false. + / + +&preprocess_nml + input_obs_qty_mod_file = '../../../assimilation_code/modules/observations/DEFAULT_obs_kind_mod.F90' + output_obs_qty_mod_file = '../../../assimilation_code/modules/observations/obs_kind_mod.f90' + input_obs_def_mod_file = '../../../observations/forward_operators/DEFAULT_obs_def_mod.F90' + output_obs_def_mod_file = '../../../observations/forward_operators/obs_def_mod.f90' + obs_type_files = '../../../observations/forward_operators/obs_def_gps_mod.f90' + quantity_files = '../../../assimilation_code/modules/observations/default_quantities_mod.f90' + / + diff --git a/developer_tests/bnrh_dist/work/quickbuild.sh b/developer_tests/bnrh_dist/work/quickbuild.sh new file mode 100755 index 000000000..3fa860840 --- /dev/null +++ b/developer_tests/bnrh_dist/work/quickbuild.sh @@ -0,0 +1,40 @@ +#!/usr/bin/env bash + +# DART software - Copyright UCAR. This open source software is provided +# by UCAR, "as is", without charge, subject to all terms of use at +# http://www.image.ucar.edu/DAReS/DART/DART_download + +main() { + + +export DART=$(git rev-parse --show-toplevel) +source "$DART"/build_templates/buildfunctions.sh + +MODEL="none" +EXTRA="$DART"/models/template/threed_model_mod.f90 +dev_test=1 +LOCATION="threed_sphere" +TEST="bnrh_dist" + +serial_programs=( +test_bnrh_dist +) + +# quickbuild arguments +arguments "$@" + +# clean the directory +\rm -f -- *.o *.mod Makefile .cppdefs + +# build and run preprocess before making any other DART executables +buildpreprocess + +# build DART +buildit + +# clean up +\rm -f -- *.o *.mod + +} + +main "$@" diff --git a/developer_tests/create_dist_test.sh b/developer_tests/create_dist_test.sh new file mode 100755 index 000000000..c5cf0b506 --- /dev/null +++ b/developer_tests/create_dist_test.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash + +# Check if an argument is passed to the script +if [ -z "$1" ]; then + echo "Error: No distribution name provided." + echo "Usage: $0 " + exit 1 +fi + +DIST="$1" +distdir="$DIST"_dist + +# Step 1: Create the DIST directory +mkdir -p "$distdir"/work + +# Step 2: Copy contents from gamma_dist to DIST +cp -r gamma_dist/work/quickbuild.sh $distdir/work/ +cp -r gamma_dist/test_gamma_dist.f90 $distdir/test_${DIST}_dist.f90 +cp -r gamma_dist/work/input.nml $distdir/work/ + + +# Step 3: Replace references of gamma with DIST in the copied files +find "$distdir" -type f -exec sed -i '' "s/gamma/$DIST/g" {} + From d04c06a5f2f4695b7ecf50cb841df04a4c62621b Mon Sep 17 00:00:00 2001 From: Helen Kershaw Date: Tue, 3 Sep 2024 13:37:22 -0400 Subject: [PATCH 5/8] chore: remove helper script used to create test_X_dist directories --- developer_tests/create_dist_test.sh | 23 ----------------------- 1 file changed, 23 deletions(-) delete mode 100755 developer_tests/create_dist_test.sh diff --git a/developer_tests/create_dist_test.sh b/developer_tests/create_dist_test.sh deleted file mode 100755 index c5cf0b506..000000000 --- a/developer_tests/create_dist_test.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/env bash - -# Check if an argument is passed to the script -if [ -z "$1" ]; then - echo "Error: No distribution name provided." - echo "Usage: $0 " - exit 1 -fi - -DIST="$1" -distdir="$DIST"_dist - -# Step 1: Create the DIST directory -mkdir -p "$distdir"/work - -# Step 2: Copy contents from gamma_dist to DIST -cp -r gamma_dist/work/quickbuild.sh $distdir/work/ -cp -r gamma_dist/test_gamma_dist.f90 $distdir/test_${DIST}_dist.f90 -cp -r gamma_dist/work/input.nml $distdir/work/ - - -# Step 3: Replace references of gamma with DIST in the copied files -find "$distdir" -type f -exec sed -i '' "s/gamma/$DIST/g" {} + From c2df64e174202ecc7e71e86a07f506e37882a78c Mon Sep 17 00:00:00 2001 From: Helen Kershaw Date: Tue, 3 Sep 2024 13:41:43 -0400 Subject: [PATCH 6/8] not really a fix, there is no bnrh test routine so removing the harness --- developer_tests/bnrh_dist/test_bnrh_dist.f90 | 16 -------- developer_tests/bnrh_dist/work/input.nml | 13 ------- developer_tests/bnrh_dist/work/quickbuild.sh | 40 -------------------- 3 files changed, 69 deletions(-) delete mode 100644 developer_tests/bnrh_dist/test_bnrh_dist.f90 delete mode 100644 developer_tests/bnrh_dist/work/input.nml delete mode 100755 developer_tests/bnrh_dist/work/quickbuild.sh diff --git a/developer_tests/bnrh_dist/test_bnrh_dist.f90 b/developer_tests/bnrh_dist/test_bnrh_dist.f90 deleted file mode 100644 index 57fe820c9..000000000 --- a/developer_tests/bnrh_dist/test_bnrh_dist.f90 +++ /dev/null @@ -1,16 +0,0 @@ -! DART software - Copyright UCAR. This open source software is provided -! by UCAR, "as is", without charge, subject to all terms of use at -! http://www.image.ucar.edu/DAReS/DART/DART_download - -program test_bnrh_distribution - -use utilities_mod, only : initialize_utilities, finalize_utilities -use bnrh_distribution_mod, only : test_bnrh - -implicit none - -call initialize_utilities() -call test_bnrh() -call finalize_utilities() - -end program test_bnrh_distribution diff --git a/developer_tests/bnrh_dist/work/input.nml b/developer_tests/bnrh_dist/work/input.nml deleted file mode 100644 index 83525855e..000000000 --- a/developer_tests/bnrh_dist/work/input.nml +++ /dev/null @@ -1,13 +0,0 @@ -&utilities_nml - module_details = .false. - / - -&preprocess_nml - input_obs_qty_mod_file = '../../../assimilation_code/modules/observations/DEFAULT_obs_kind_mod.F90' - output_obs_qty_mod_file = '../../../assimilation_code/modules/observations/obs_kind_mod.f90' - input_obs_def_mod_file = '../../../observations/forward_operators/DEFAULT_obs_def_mod.F90' - output_obs_def_mod_file = '../../../observations/forward_operators/obs_def_mod.f90' - obs_type_files = '../../../observations/forward_operators/obs_def_gps_mod.f90' - quantity_files = '../../../assimilation_code/modules/observations/default_quantities_mod.f90' - / - diff --git a/developer_tests/bnrh_dist/work/quickbuild.sh b/developer_tests/bnrh_dist/work/quickbuild.sh deleted file mode 100755 index 3fa860840..000000000 --- a/developer_tests/bnrh_dist/work/quickbuild.sh +++ /dev/null @@ -1,40 +0,0 @@ -#!/usr/bin/env bash - -# DART software - Copyright UCAR. This open source software is provided -# by UCAR, "as is", without charge, subject to all terms of use at -# http://www.image.ucar.edu/DAReS/DART/DART_download - -main() { - - -export DART=$(git rev-parse --show-toplevel) -source "$DART"/build_templates/buildfunctions.sh - -MODEL="none" -EXTRA="$DART"/models/template/threed_model_mod.f90 -dev_test=1 -LOCATION="threed_sphere" -TEST="bnrh_dist" - -serial_programs=( -test_bnrh_dist -) - -# quickbuild arguments -arguments "$@" - -# clean the directory -\rm -f -- *.o *.mod Makefile .cppdefs - -# build and run preprocess before making any other DART executables -buildpreprocess - -# build DART -buildit - -# clean up -\rm -f -- *.o *.mod - -} - -main "$@" From 100ae03a48b7cc1277e33627a6af3b7fdec83a79 Mon Sep 17 00:00:00 2001 From: Helen Kershaw Date: Tue, 3 Sep 2024 12:08:00 -0600 Subject: [PATCH 7/8] pass/fail conditions from Jeff's mega commit 5b3850fb1a08fff0ebce3f95283fef29de431bdc note the pass/fail conditions for the matlab tests do no match the comments for gamma and beta. The comment says absolute value, the test is not on the absolute value. --- .../modules/assimilation/beta_distribution_mod.f90 | 13 +++++++++++++ .../modules/assimilation/gamma_distribution_mod.f90 | 13 +++++++++++++ .../assimilation/normal_distribution_mod.f90 | 10 +++++----- 3 files changed, 31 insertions(+), 5 deletions(-) diff --git a/assimilation_code/modules/assimilation/beta_distribution_mod.f90 b/assimilation_code/modules/assimilation/beta_distribution_mod.f90 index eec0a327c..3e970eea9 100644 --- a/assimilation_code/modules/assimilation/beta_distribution_mod.f90 +++ b/assimilation_code/modules/assimilation/beta_distribution_mod.f90 @@ -65,6 +65,12 @@ subroutine test_beta cdf_diff(i) = beta_cdf(mx(i), malpha(i), mbeta(i), 0.0_r8, 1.0_r8) - mcdf(i) write(*, *) i, pdf_diff(i), cdf_diff(i) end do +if(maxval(pdf_diff) < 1e-15_r8 .and. maxval(cdf_diff) < 1e-15_r8) then + write(*, *) 'Matlab Comparison Tests: PASS' +else + write(*, *) 'Matlab Comparison Tests: FAIL' +endif + ! Test many x values for cdf and inverse cdf for a single set of alpha and beta alpha = 5.0_r8 @@ -83,6 +89,13 @@ subroutine test_beta write(*, *) 'max difference in inversion is ', max_diff write(*, *) 'max difference should be less than 1e-14' +if(max_diff < 1e-14_r8) then + write(*, *) 'Inversion Tests: PASS' +else + write(*, *) 'Inversion Tests: FAIL' +endif + + end subroutine test_beta !----------------------------------------------------------------------- diff --git a/assimilation_code/modules/assimilation/gamma_distribution_mod.f90 b/assimilation_code/modules/assimilation/gamma_distribution_mod.f90 index 953c90fe1..712bfa34f 100644 --- a/assimilation_code/modules/assimilation/gamma_distribution_mod.f90 +++ b/assimilation_code/modules/assimilation/gamma_distribution_mod.f90 @@ -65,6 +65,12 @@ subroutine test_gamma write(*, *) i, pdf_diff(i), cdf_diff(i) end do +if(maxval(pdf_diff) < 1e-15_r8 .and. maxval(cdf_diff) < 1e-15_r8) then + write(*, *) 'Matlab Comparison Tests: PASS' +else + write(*, *) 'Matlab Compariosn Tests: FAIL' +endif + ! Input a mean and variance mean = 10.0_r8 sd = 1.0_r8 @@ -87,6 +93,13 @@ subroutine test_gamma write(*, *) 'max difference in inversion is ', max_diff write(*, *) 'max difference should be less than 1e-11' +if(max_diff < 1e-11_r8) then + write(*, *) 'Inversion Tests: PASS' +else + write(*, *) 'Inversion Tests: FAIL' +endif + + end subroutine test_gamma !----------------------------------------------------------------------- diff --git a/assimilation_code/modules/assimilation/normal_distribution_mod.f90 b/assimilation_code/modules/assimilation/normal_distribution_mod.f90 index 6b0656c62..297f4d599 100644 --- a/assimilation_code/modules/assimilation/normal_distribution_mod.f90 +++ b/assimilation_code/modules/assimilation/normal_distribution_mod.f90 @@ -66,10 +66,10 @@ subroutine test_normal cdf_diff(i) = normal_cdf(mx(i), mmean(i), msd(i)) - mcdf(i) end do max_matlab_diff = maxval(abs(cdf_diff)) -if(max_matlab_diff > 1.0e-15_r8) then - write(*, *) 'WARNING: Difference from Matlab baseline is too large ', max_matlab_diff +if(max_matlab_diff < 1.0e-15_r8) then + write(*, *) 'Matlab Comparison Tests: PASS ', max_matlab_diff else - write(*, *) 'Agreement with Matlab baseline is okay: max diff is < 1e-15 ', max_matlab_diff + write(*, *) 'Matlab Comparison Tests: FAIL ', max_matlab_diff endif ! Keep track of differences as function of quantile @@ -92,10 +92,10 @@ subroutine test_normal do j = 1, 16 if(max_diff(j) > inv_diff_bound(j)) then - write(*, *) 'WARNING: Max inversion diff ', max_diff(j), ' > bound ', inv_diff_bound(j), & + write(*, *) 'FAIL: Max inversion diff ', max_diff(j), ' > bound ', inv_diff_bound(j), & 'for quantiles < ', max_q(j) else - write(*, *) 'Max inversion diff ', max_diff(j), ' OK, bound ', inv_diff_bound(j), & + write(*, *) 'PASS: Max inversion diff ', max_diff(j), ' < bound ', inv_diff_bound(j), & 'for quantiles < ', max_q(j) endif end do From 680b19a0b7d8d8dd3fe119607302262226ad8f2a Mon Sep 17 00:00:00 2001 From: Helen Kershaw Date: Thu, 12 Sep 2024 14:03:32 -0400 Subject: [PATCH 8/8] absolute value for comparison beta and gamma distribution --- .../modules/assimilation/beta_distribution_mod.f90 | 2 +- .../modules/assimilation/gamma_distribution_mod.f90 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/assimilation_code/modules/assimilation/beta_distribution_mod.f90 b/assimilation_code/modules/assimilation/beta_distribution_mod.f90 index 3e970eea9..f5c3c5fc3 100644 --- a/assimilation_code/modules/assimilation/beta_distribution_mod.f90 +++ b/assimilation_code/modules/assimilation/beta_distribution_mod.f90 @@ -65,7 +65,7 @@ subroutine test_beta cdf_diff(i) = beta_cdf(mx(i), malpha(i), mbeta(i), 0.0_r8, 1.0_r8) - mcdf(i) write(*, *) i, pdf_diff(i), cdf_diff(i) end do -if(maxval(pdf_diff) < 1e-15_r8 .and. maxval(cdf_diff) < 1e-15_r8) then +if(abs(maxval(pdf_diff)) < 1e-15_r8 .and. abs(maxval(cdf_diff)) < 1e-15_r8) then write(*, *) 'Matlab Comparison Tests: PASS' else write(*, *) 'Matlab Comparison Tests: FAIL' diff --git a/assimilation_code/modules/assimilation/gamma_distribution_mod.f90 b/assimilation_code/modules/assimilation/gamma_distribution_mod.f90 index 712bfa34f..5ffb66d2d 100644 --- a/assimilation_code/modules/assimilation/gamma_distribution_mod.f90 +++ b/assimilation_code/modules/assimilation/gamma_distribution_mod.f90 @@ -65,7 +65,7 @@ subroutine test_gamma write(*, *) i, pdf_diff(i), cdf_diff(i) end do -if(maxval(pdf_diff) < 1e-15_r8 .and. maxval(cdf_diff) < 1e-15_r8) then +if(abs(maxval(pdf_diff)) < 1e-15_r8 .and. abs(maxval(cdf_diff)) < 1e-15_r8) then write(*, *) 'Matlab Comparison Tests: PASS' else write(*, *) 'Matlab Compariosn Tests: FAIL'