Skip to content

Commit

Permalink
Merge branch 'main' into remove-IO-dev-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hkershaw-brown authored Dec 6, 2024
2 parents 5e16477 + 08e0326 commit a7dfbe2
Show file tree
Hide file tree
Showing 13 changed files with 241 additions and 5 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
13 changes: 13 additions & 0 deletions assimilation_code/modules/assimilation/beta_distribution_mod.f90
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

!-----------------------------------------------------------------------
Expand Down
13 changes: 13 additions & 0 deletions assimilation_code/modules/assimilation/gamma_distribution_mod.f90
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

!-----------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
16 changes: 16 additions & 0 deletions developer_tests/beta_dist/test_beta_dist.f90
Original file line number Diff line number Diff line change
@@ -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
13 changes: 13 additions & 0 deletions developer_tests/beta_dist/work/input.nml
Original file line number Diff line number Diff line change
@@ -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'
/

40 changes: 40 additions & 0 deletions developer_tests/beta_dist/work/quickbuild.sh
Original file line number Diff line number Diff line change
@@ -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 "$@"
16 changes: 16 additions & 0 deletions developer_tests/gamma_dist/test_gamma_dist.f90
Original file line number Diff line number Diff line change
@@ -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
13 changes: 13 additions & 0 deletions developer_tests/gamma_dist/work/input.nml
Original file line number Diff line number Diff line change
@@ -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'
/

40 changes: 40 additions & 0 deletions developer_tests/gamma_dist/work/quickbuild.sh
Original file line number Diff line number Diff line change
@@ -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 "$@"
16 changes: 16 additions & 0 deletions developer_tests/normal_dist/test_normal_dist.f90
Original file line number Diff line number Diff line change
@@ -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
13 changes: 13 additions & 0 deletions developer_tests/normal_dist/work/input.nml
Original file line number Diff line number Diff line change
@@ -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'
/

40 changes: 40 additions & 0 deletions developer_tests/normal_dist/work/quickbuild.sh
Original file line number Diff line number Diff line change
@@ -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 "$@"

0 comments on commit a7dfbe2

Please sign in to comment.