diff --git a/.gitignore b/.gitignore index 2db1c24b3..c0823ccc7 100644 --- a/.gitignore +++ b/.gitignore @@ -202,6 +202,9 @@ test_quad_irreg_interp test_quad_reg_interp test_table_read test_ran_unif +test_gamma_dist +test_normal_dist +test_beta_dist test_kde_dist test_window diff --git a/assimilation_code/modules/assimilation/beta_distribution_mod.f90 b/assimilation_code/modules/assimilation/beta_distribution_mod.f90 index eec0a327c..f5c3c5fc3 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(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' +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..5ffb66d2d 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(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' +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 b3a7c3329..b6b84a4ba 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 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 "$@" 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 "$@" 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 "$@"