Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates to the variable conversion tests #87

Open
wants to merge 3 commits into
base: testing_routines
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 25 additions & 13 deletions tests/test_CAM_interface/test_cam_interface.F90
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,7 @@ subroutine test_rev_var_conv_moist(test_name)
real(dp), dimension(num_cols, sam_sounding) :: t, q, tabs, qv, qc, qi
real(dp), dimension(num_cols, sam_sounding) :: r, p_sat, q_sat
real(dp), dimension(num_cols, sam_sounding) :: tabs_exp, qv_exp, qc_exp, qi_exp
real(dp), dimension(num_cols, sam_sounding) :: tabs_int, qv_int, qc_int, qi_int
integer :: i
real(dp), dimension(sam_sounding) :: pres_sam, presi_sam, gamaz_sam, rho_sam, z_sam

Expand Down Expand Up @@ -514,25 +515,36 @@ subroutine test_rev_var_conv_moist(test_name)
qc = 0.0
qi = 0.0

tabs_exp = -100.0
qv_exp = -100.0
qc_exp = -100.0
qi_exp = -100.0
tabs_exp = tabs
! Store existing qv, qc, qi values before CAM->SAM conversion
qv_exp = qv
qc_exp = qc
qi_exp = qi

call CAM_var_conversion(qv, qc, qi, q, tabs, t)
call SAM_var_conversion(t, q, tabs_exp, qv_exp, qc_exp, qi_exp)

! Add 1.0 to q values (they should be 0.0) to avoid division by 0.0 errors in check
qc = qc + 1.0
qi = qi + 1.0
! Store intermediates after CAM conversion
qv_int = qv
qc_int = qc
qi_int = qi
tabs_int = tabs
call SAM_var_conversion(t, q, tabs, qv, qc, qi)

qc_exp = 1.0
qi_exp = 1.0
! Note: in the assertions,
! add 1.0 to the q values (that should be 0.0) to avoid division by 0.0 errors in check

! Compare pre-conversion with post-conversion values
call assert_array_equal(tabs, tabs_exp, test_name//": tabs")
call assert_array_equal(qv, qv_exp, test_name//": qv")
call assert_array_equal(qc, qc_exp, test_name//": qc")
call assert_array_equal(qi, qi_exp, test_name//": qi")
call assert_array_equal(qc+1.0, qc_exp+1.0, test_name//": qc")
call assert_array_equal(qi+1.0, qi_exp+1.0, test_name//": qi")

! Convert SAM->CAM one last time, i.e., is the conversion invertible
call CAM_var_conversion(qv, qc, qi, q, tabs, t)

call assert_array_equal(tabs, tabs_int, test_name//": tabs")
call assert_array_equal(qv, qv_int, test_name//": qv")
call assert_array_equal(qc+1.0, qc_int+1.0, test_name//": qc")
call assert_array_equal(qi+1.0, qi_int+1.0, test_name//": qi")

end subroutine test_rev_var_conv_moist

Expand Down
Loading