From 6152237b3d8de176480793b44e7588972ddc8ece Mon Sep 17 00:00:00 2001 From: Michael Levy Date: Tue, 17 Sep 2024 15:54:26 -0600 Subject: [PATCH 1/2] Introduce new bury_coeff test Sets lgcm_has_global_ops = .true. during init, and runs with ladjust_bury_coeff = .true.; it then prints out requested forcings (because we add three new surface flux forcings) and also prints out short names of all the running means that MARBL wants the GCM to track --- tests/driver_src/marbl.F90 | 61 ++++++++++++++++++- tests/driver_src/marbl_init_drv.F90 | 14 ++++- .../marbl_with_ladjust_bury_coeff.settings | 1 + .../regression_tests/bury_coeff/bury_coeff.py | 17 ++++++ tests/regression_tests/bury_coeff/test.nml | 3 + 5 files changed, 92 insertions(+), 4 deletions(-) create mode 100644 tests/input_files/settings/marbl_with_ladjust_bury_coeff.settings create mode 100755 tests/regression_tests/bury_coeff/bury_coeff.py create mode 100644 tests/regression_tests/bury_coeff/test.nml diff --git a/tests/driver_src/marbl.F90 b/tests/driver_src/marbl.F90 index 4e4dcdfe..969e2d22 100644 --- a/tests/driver_src/marbl.F90 +++ b/tests/driver_src/marbl.F90 @@ -410,7 +410,6 @@ Program marbl ' (units: ', trim(marbl_instances(1)%interior_tendency_forcings(n)%metadata%field_units),')' call driver_status_log%log_noerror(log_message, subname) end do - call marbl_instances(1)%shutdown() end if @@ -439,6 +438,66 @@ Program marbl call marbl_instances(1)%shutdown() end if + ! -- bury_coeff test -- ! + case ('bury_coeff') + call verify_single_instance(num_inst, trim(testname)) + lprint_marbl_log = .false. + call marbl_init_test(marbl_instances(1), unit_system_opt, lshutdown = .false., lhas_global_ops=.true.) + if (.not. marbl_instances(1)%StatusLog%labort_marbl) then + ! Log requested surface forcing fields + call driver_status_log%log_header('Requested surface forcing fields', subname) + do n=1,size(marbl_instances(1)%surface_flux_forcings) + write(log_message, "(I0, 5A)") n, '. ', & + trim(marbl_instances(1)%surface_flux_forcings(n)%metadata%varname), & + ' (units: ', trim(marbl_instances(1)%surface_flux_forcings(n)%metadata%field_units),')' + call driver_status_log%log_noerror(log_message, subname) + end do + + ! Log requested interior forcing fields + call driver_status_log%log_header('Requested interior forcing fields', subname) + ! Provide message if no itnerior tendency forcings are requested + if (size(marbl_instances(1)%interior_tendency_forcings) == 0) & + call driver_status_log%log_noerror('No forcing fields requested for interior_tendency_compute()!', subname) + do n=1,size(marbl_instances(1)%interior_tendency_forcings) + write(log_message, "(I0, 5A)") n, '. ', & + trim(marbl_instances(1)%interior_tendency_forcings(n)%metadata%varname), & + ' (units: ', trim(marbl_instances(1)%interior_tendency_forcings(n)%metadata%field_units),')' + call driver_status_log%log_noerror(log_message, subname) + end do + + ! Print info about burial coefficient vars as well + call driver_status_log%log_header('Size of arrays for running means', subname) + write(log_message, "(A, I0)") "size(glo_avg_rmean_interior_tendency): ", & + size(marbl_instances(1)%glo_avg_rmean_interior_tendency) + call driver_status_log%log_noerror(log_message, subname) + do n=1,size(marbl_instances(1)%glo_avg_rmean_interior_tendency) + write(log_message, "(2A)") " -- ", trim(marbl_instances(1)%glo_avg_rmean_interior_tendency(n)%sname) + call driver_status_log%log_noerror(log_message, subname) + end do + write(log_message, "(A, I0)") "size(glo_avg_rmean_surface_flux): ", & + size(marbl_instances(1)%glo_avg_rmean_surface_flux) + call driver_status_log%log_noerror(log_message, subname) + do n=1,size(marbl_instances(1)%glo_avg_rmean_surface_flux) + write(log_message, "(2A)") " -- ", trim(marbl_instances(1)%glo_avg_rmean_surface_flux(n)%sname) + call driver_status_log%log_noerror(log_message, subname) + end do + write(log_message, "(A, I0)") "size(glo_scalar_rmean_interior_tendency): ", & + size(marbl_instances(1)%glo_scalar_rmean_interior_tendency) + call driver_status_log%log_noerror(log_message, subname) + do n=1,size(marbl_instances(1)%glo_scalar_rmean_interior_tendency) + write(log_message, "(2A)") " -- ", trim(marbl_instances(1)%glo_scalar_rmean_interior_tendency(n)%sname) + call driver_status_log%log_noerror(log_message, subname) + end do + write(log_message, "(A, I0)") "size(glo_scalar_rmean_surface_flux): ", & + size(marbl_instances(1)%glo_scalar_rmean_surface_flux) + call driver_status_log%log_noerror(log_message, subname) + do n=1,size(marbl_instances(1)%glo_scalar_rmean_surface_flux) + write(log_message, "(2A)") " -- ", trim(marbl_instances(1)%glo_scalar_rmean_surface_flux(n)%sname) + call driver_status_log%log_noerror(log_message, subname) + end do + call marbl_instances(1)%shutdown() + end if + ! -- available_output test -- ! case ('available_output') call verify_single_instance(num_inst, trim(testname)) diff --git a/tests/driver_src/marbl_init_drv.F90 b/tests/driver_src/marbl_init_drv.F90 index e30d6972..109700c5 100644 --- a/tests/driver_src/marbl_init_drv.F90 +++ b/tests/driver_src/marbl_init_drv.F90 @@ -14,17 +14,18 @@ module marbl_init_drv Contains - subroutine test(marbl_instance, unit_system_opt, lshutdown, num_PAR_subcols) + subroutine test(marbl_instance, unit_system_opt, lshutdown, num_PAR_subcols, lhas_global_ops) type(marbl_interface_class), intent(inout) :: marbl_instance character(len=*), intent(in) :: unit_system_opt logical, optional, intent(in) :: lshutdown integer, optional, intent(in) :: num_PAR_subcols + logical, optional, intent(in) :: lhas_global_ops character(*), parameter :: subname = 'marbl_init_drv:test' real(kind=r8), dimension(km) :: delta_z, zw, zt integer :: k, num_PAR_subcols_loc - logical :: lshutdown_loc + logical :: lshutdown_loc, lhas_global_ops_loc ! Run marbl_instance%shutdown? (Skip when running get_setting() from driver) if (present(lshutdown)) then @@ -39,6 +40,12 @@ subroutine test(marbl_instance, unit_system_opt, lshutdown, num_PAR_subcols) num_PAR_subcols_loc = 1 end if + if (present(lhas_global_ops)) then + lhas_global_ops_loc = lhas_global_ops + else + lhas_global_ops_loc = .false. + end if + ! Initialize levels delta_z = c1 zw(1) = delta_z(1) @@ -57,7 +64,8 @@ subroutine test(marbl_instance, unit_system_opt, lshutdown, num_PAR_subcols) gcm_delta_z = delta_z, & gcm_zw = zw, & gcm_zt = zt, & - unit_system_opt = unit_system_opt) + unit_system_opt = unit_system_opt, & + lgcm_has_global_ops=lhas_global_ops_loc) if (marbl_instance%StatusLog%labort_marbl) then call marbl_instance%StatusLog%log_error_trace('marbl%init', subname) return diff --git a/tests/input_files/settings/marbl_with_ladjust_bury_coeff.settings b/tests/input_files/settings/marbl_with_ladjust_bury_coeff.settings new file mode 100644 index 00000000..735ac867 --- /dev/null +++ b/tests/input_files/settings/marbl_with_ladjust_bury_coeff.settings @@ -0,0 +1 @@ +ladjust_bury_coeff = .true. diff --git a/tests/regression_tests/bury_coeff/bury_coeff.py b/tests/regression_tests/bury_coeff/bury_coeff.py new file mode 100755 index 00000000..faea4b78 --- /dev/null +++ b/tests/regression_tests/bury_coeff/bury_coeff.py @@ -0,0 +1,17 @@ +#!/usr/bin/env python + +from sys import path +import os + +path.insert(0, os.path.join('..', '..', 'python_for_tests')) +from marbl_testing_class import MARBL_testcase + +mt = MARBL_testcase() + +mt.parse_args(desc='Run full MARBL setup (config, init, and complete) and print ' + 'output relating to burial coefficients', + DefaultSettingsFile='../../input_files/settings/marbl_with_ladjust_bury_coeff.settings') + +mt.build_exe() + +mt.run_exe() diff --git a/tests/regression_tests/bury_coeff/test.nml b/tests/regression_tests/bury_coeff/test.nml new file mode 100644 index 00000000..15b89169 --- /dev/null +++ b/tests/regression_tests/bury_coeff/test.nml @@ -0,0 +1,3 @@ +&marbl_driver_nml +testname="bury_coeff" +/ From 0b27bcae0f30f3bb56c0e3360cd05e813b4de31c Mon Sep 17 00:00:00 2001 From: Michael Levy Date: Tue, 17 Sep 2024 17:03:37 -0600 Subject: [PATCH 2/2] Update run_test_suite.sh script 1. Skip marbl_with_ladjust_bury_coeff.settings when running init (since it should fail due to lgcm_has_global_ops = .false.) 2. Run new bury_coeff test --- MARBL_tools/run_test_suite.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/MARBL_tools/run_test_suite.sh b/MARBL_tools/run_test_suite.sh index 9673ce6b..1e4d4d51 100755 --- a/MARBL_tools/run_test_suite.sh +++ b/MARBL_tools/run_test_suite.sh @@ -136,6 +136,9 @@ if [ "${STATUS}" == "PASS" ]; then print_status "init.py" >> ${RESULTS_CACHE} # Initialize MARBL with settings from tests/input_files/settings/ for settingsfile in `find ../../input_files/settings -type f`; do + if [ "`basename $settingsfile`" == "marbl_with_ladjust_bury_coeff.settings" ]; then + continue + fi (set -x ; ./init.py -s $settingsfile) STATUS=$(check_return $?) print_status "init.py ($(basename ${settingsfile}))" >> ${RESULTS_CACHE} @@ -362,6 +365,12 @@ if [ "${STATUS}" == "PASS" ]; then STATUS=$(check_return $?) print_status "requested_tracers.py" >> ${RESULTS_CACHE} + # Print all fields MARBL needs running means of + cd ${MARBL_ROOT}/tests/regression_tests/bury_coeff + (set -x ; ./bury_coeff.py) + STATUS=$(check_return $?) + print_status "bury_coeff.py" >> ${RESULTS_CACHE} + # Print all output_for_GCM variables cd ${MARBL_ROOT}/tests/regression_tests/available_output (set -x ; ./available_output.py)