From 949afbc1f88a75d7f66a009a44ed7a4c8623c6e2 Mon Sep 17 00:00:00 2001 From: Steve Goldhaber Date: Mon, 6 Jan 2025 22:16:13 +0100 Subject: [PATCH] Implement constituent index lookup routines ccpp_constituent_index: Lookup index constituent by name ccpp_constituent_indices: Lookup indices of consitutents by name Add tests of this functionality into advection_test Minor code cleanup Update DDThost test for new CCPP source file --- scripts/ccpp_datafile.py | 2 + scripts/constituents.py | 3 + scripts/host_cap.py | 16 --- src/ccpp_constituent_prop_mod.F90 | 2 +- src/ccpp_scheme_utils.F90 | 101 ++++++++++++++++ test/advection_test/cld_suite.xml | 1 + test/advection_test/cld_suite_files.txt | 1 + test/advection_test/const_indices.F90 | 77 +++++++++++++ test/advection_test/const_indices.meta | 108 ++++++++++++++++++ test/advection_test/run_test | 15 ++- test/advection_test/test_host.F90 | 39 ++++++- test/advection_test/test_host_data.F90 | 57 ++++++++- test/advection_test/test_host_data.meta | 38 ++++++ test/advection_test/test_host_mod.F90 | 2 +- test/advection_test/test_reports.py | 14 ++- test/capgen_test/run_test | 1 + test/capgen_test/test_host_data.F90 | 6 +- test/capgen_test/test_reports.py | 1 + test/ddthost_test/run_test | 1 + test/ddthost_test/test_reports.py | 1 + test/var_compatibility_test/run_test | 1 + .../var_compatibility_test/test_host_data.F90 | 6 +- test/var_compatibility_test/test_reports.py | 1 + 23 files changed, 464 insertions(+), 30 deletions(-) create mode 100644 src/ccpp_scheme_utils.F90 create mode 100644 test/advection_test/const_indices.F90 create mode 100644 test/advection_test/const_indices.meta diff --git a/scripts/ccpp_datafile.py b/scripts/ccpp_datafile.py index 6bb5e537..782e203e 100755 --- a/scripts/ccpp_datafile.py +++ b/scripts/ccpp_datafile.py @@ -1067,6 +1067,8 @@ def _add_generated_files(parent, host_files, suite_files, ccpp_kinds, src_dir): entry = ET.SubElement(utilities, "file") entry.text = os.path.join(src_dir, "ccpp_constituent_prop_mod.F90") entry = ET.SubElement(utilities, "file") + entry.text = os.path.join(src_dir, "ccpp_scheme_utils.F90") + entry = ET.SubElement(utilities, "file") entry.text = os.path.join(src_dir, "ccpp_hashable.F90") entry = ET.SubElement(utilities, "file") entry.text = os.path.join(src_dir, "ccpp_hash_table.F90") diff --git a/scripts/constituents.py b/scripts/constituents.py index a8c11144..bb83c3c7 100644 --- a/scripts/constituents.py +++ b/scripts/constituents.py @@ -608,6 +608,8 @@ def write_host_routines(cap, host, reg_funcname, init_funcname, num_const_funcna cap.write(f"{substmt}(ncols, num_layers, {err_dummy_str})", 1) cap.comment("Initialize constituent data", 2) cap.blank_line() + cap.write("use ccpp_scheme_utils, only: ccpp_initialize_constituent_ptr", 2) + cap.blank_line() cap.comment("Dummy arguments", 2) cap.write("integer, intent(in) :: ncols", 2) cap.write("integer, intent(in) :: num_layers", 2) @@ -617,6 +619,7 @@ def write_host_routines(cap, host, reg_funcname, init_funcname, num_const_funcna cap.blank_line() call_str = f"call {const_obj_name}%lock_data(ncols, num_layers, {obj_err_callstr})" cap.write(call_str, 2) + cap.write(f"call ccpp_initialize_constituent_ptr({const_obj_name})", 2) cap.write(f"end {substmt}", 1) # Write num_consts routine substmt = f"subroutine {num_const_funcname}" diff --git a/scripts/host_cap.py b/scripts/host_cap.py index f1d2880b..b06906fe 100644 --- a/scripts/host_cap.py +++ b/scripts/host_cap.py @@ -101,14 +101,6 @@ def constituent_initialize_subname(host_model): Because this is a user interface API function, the name is fixed.""" return f"{host_model.name}_ccpp_initialize_constituents" -############################################################################### -def constituent_initialize_subname(host_model): -############################################################################### - """Return the name of the subroutine used to initialize the - constituents for this run. - Because this is a user interface API function, the name is fixed.""" - return f"{host_model.name}_ccpp_initialize_constituents" - ############################################################################### def constituent_num_consts_funcname(host_model): ############################################################################### @@ -125,14 +117,6 @@ def query_scheme_constituents_funcname(host_model): Because this is a user interface API function, the name is fixed.""" return f"{host_model.name}_ccpp_is_scheme_constituent" -############################################################################### -def query_scheme_constituents_funcname(host_model): -############################################################################### - """Return the name of the function to return True if the standard name - passed in matches an existing constituent - Because this is a user interface API function, the name is fixed.""" - return f"{host_model.name}_ccpp_is_scheme_constituent" - ############################################################################### def constituent_copyin_subname(host_model): ############################################################################### diff --git a/src/ccpp_constituent_prop_mod.F90 b/src/ccpp_constituent_prop_mod.F90 index 16019571..a08291b6 100644 --- a/src/ccpp_constituent_prop_mod.F90 +++ b/src/ccpp_constituent_prop_mod.F90 @@ -23,7 +23,7 @@ module ccpp_constituent_prop_mod integer, parameter :: mass_mixing_ratio = -5 integer, parameter :: volume_mixing_ratio = -6 integer, parameter :: number_concentration = -7 - integer, parameter :: int_unassigned = -HUGE(1) + integer, public, parameter :: int_unassigned = -HUGE(1) real(kind_phys), parameter :: kphys_unassigned = HUGE(1.0_kind_phys) !! \section arg_table_ccpp_constituent_properties_t diff --git a/src/ccpp_scheme_utils.F90 b/src/ccpp_scheme_utils.F90 new file mode 100644 index 00000000..c689d194 --- /dev/null +++ b/src/ccpp_scheme_utils.F90 @@ -0,0 +1,101 @@ +module ccpp_scheme_utils + + ! Module of utilities available to CCPP schemes + + use ccpp_constituent_prop_mod, only: ccpp_model_constituents_t, int_unassigned + + implicit none + private + + !! Public interfaces + public :: ccpp_initialize_constituent_ptr ! Used by framework to initialize + public :: ccpp_constituent_index ! Lookup index constituent by name + public :: ccpp_constituent_indices ! Lookup indices of consitutents by name + + !! Private module variables & interfaces + + ! initialized set to .true. once hash table pointer is initialized + logical :: initialized = .false. + type(ccpp_model_constituents_t), pointer :: constituent_obj => NULL() + + private :: uninitialized + +contains + + subroutine uninitialized(caller, errcode, errmsg) + ! Dummy arguments + character(len=*), intent(in) :: caller + integer, optional, intent(out) :: errcode + character(len=*), optional, intent(out) :: errmsg + + if (.not. initialized) then + if (present(errcode)) then + errcode = 1 + end if + if (present(errmsg)) then + errmsg = trim(caller)//' FAILED, module not initialized' + end if + end if + end subroutine uninitialized + + subroutine ccpp_initialize_constituent_ptr(const_obj) + ! Dummy arguments + type(ccpp_model_constituents_t), pointer, intent(in) :: const_obj + + if (.not. initialized) then + constituent_obj => const_obj + initialized = .true. + end if + end subroutine ccpp_initialize_constituent_ptr + + subroutine ccpp_constituent_index(standard_name, const_index, errcode, errmsg) + ! Dummy arguments + character(len=*), intent(in) :: standard_name + integer, intent(out) :: const_index + integer, optional, intent(out) :: errcode + character(len=*), optional, intent(out) :: errmsg + + ! Local variable + character(len=*), parameter :: subname = 'ccpp_constituent_index' + + if (initialized) then + call constituent_obj%const_index(const_index, standard_name, & + errcode, errmsg) + else + const_index = int_unassigned + call uninitialized(subname) + end if + end subroutine ccpp_constituent_index + + subroutine ccpp_constituent_indices(standard_names, const_inds, errcode, errmsg) + ! Dummy arguments + character(len=*), intent(in) :: standard_names(:) + integer, intent(out) :: const_inds(:) + integer, optional, intent(out) :: errcode + character(len=*), optional, intent(out) :: errmsg + + ! Local variables + integer :: indx + character(len=*), parameter :: subname = 'ccpp_constituent_indices' + + const_inds = int_unassigned + if (initialized) then + if (size(const_inds) < size(standard_names)) then + errcode = 1 + errmsg = subname//': const_inds too small' + else + do indx = 1, size(standard_names) + ! For each std name in , find the const. index + call constituent_obj%const_index(const_inds(indx), & + standard_names(indx), errcode, errmsg) + if (errcode /= 0) then + exit + end if + end do + end if + else + call uninitialized(subname) + end if + end subroutine ccpp_constituent_indices + +end module ccpp_scheme_utils diff --git a/test/advection_test/cld_suite.xml b/test/advection_test/cld_suite.xml index 361518d1..fac613e8 100644 --- a/test/advection_test/cld_suite.xml +++ b/test/advection_test/cld_suite.xml @@ -2,6 +2,7 @@ + const_indices cld_liq apply_constituent_tendencies cld_ice diff --git a/test/advection_test/cld_suite_files.txt b/test/advection_test/cld_suite_files.txt index 301bb4ee..4ce40a53 100644 --- a/test/advection_test/cld_suite_files.txt +++ b/test/advection_test/cld_suite_files.txt @@ -1,3 +1,4 @@ cld_liq.meta cld_ice.meta apply_constituent_tendencies.meta +const_indices.meta diff --git a/test/advection_test/const_indices.F90 b/test/advection_test/const_indices.F90 new file mode 100644 index 00000000..30b1c4ec --- /dev/null +++ b/test/advection_test/const_indices.F90 @@ -0,0 +1,77 @@ +! Test collection of constituent indices +! + +MODULE const_indices + + USE ccpp_kinds, ONLY: kind_phys + + IMPLICIT NONE + PRIVATE + + PUBLIC :: const_indices_init + PUBLIC :: const_indices_run + +CONTAINS + + !> \section arg_table_const_indices_run Argument Table + !! \htmlinclude arg_table_const_indices_run.html + !! + subroutine const_indices_run(const_std_name, num_consts, test_stdname_array, & + const_index, const_inds, errmsg, errflg) + use ccpp_scheme_utils, only: ccpp_constituent_index, ccpp_constituent_indices + + character(len=*), intent(in) :: const_std_name + integer, intent(in) :: num_consts + character(len=*), intent(in) :: test_stdname_array(:) + integer, intent(out) :: const_index + integer, intent(out) :: const_inds(:) + character(len=512), intent(out) :: errmsg + integer, intent(out) :: errflg + !---------------------------------------------------------------- + + integer :: indx + + errmsg = '' + errflg = 0 + + ! Find the constituent index for + call ccpp_constituent_index(const_std_name, const_index, errflg, errmsg) + if (errflg == 0) then + call ccpp_constituent_indices(test_stdname_array, const_inds, errflg, errmsg) + end if + + end subroutine const_indices_run + + !> \section arg_table_const_indices_init Argument Table + !! \htmlinclude arg_table_const_indices_init.html + !! + subroutine const_indices_init(const_std_name, num_consts, test_stdname_array, & + const_index, const_inds, errmsg, errflg) + use ccpp_scheme_utils, only: ccpp_constituent_index, ccpp_constituent_indices + + character(len=*), intent(in) :: const_std_name + integer, intent(in) :: num_consts + character(len=*), intent(in) :: test_stdname_array(:) + integer, intent(out) :: const_index + integer, intent(out) :: const_inds(:) + character(len=512), intent(out) :: errmsg + integer, intent(out) :: errflg + !---------------------------------------------------------------- + + integer :: indx + + errmsg = '' + errflg = 0 + + ! Find the constituent index for + call ccpp_constituent_index(const_std_name, const_index, errflg, errmsg) + if (errflg == 0) then + call ccpp_constituent_indices(test_stdname_array, const_inds, errflg, errmsg) + end if + + end subroutine const_indices_init + + !! @} + !! @} + +END MODULE const_indices diff --git a/test/advection_test/const_indices.meta b/test/advection_test/const_indices.meta new file mode 100644 index 00000000..a4cc98e2 --- /dev/null +++ b/test/advection_test/const_indices.meta @@ -0,0 +1,108 @@ +# const_indices just returns some constituent indices as a test +[ccpp-table-properties] + name = const_indices + type = scheme +[ccpp-arg-table] + name = const_indices_run + type = scheme +[ const_std_name ] + standard_name = test_banana_name + type = character | kind = len=* + units = 1 + dimensions = () + protected = true + intent = in +[ num_consts ] + standard_name = banana_array_dim + long_name = Size of test_banana_name_array + units = 1 + dimensions = () + type = integer + intent = in +[ test_stdname_array ] + standard_name = test_banana_name_array + type = character | kind = len=* + units = count + dimensions = (banana_array_dim) + intent = in +[ const_index ] + standard_name = test_banana_constituent_index + long_name = Constituent index + units = 1 + dimensions = () + type = integer + intent = out +[ const_inds ] + standard_name = test_banana_constituent_indices + long_name = Array of constituent indices + units = 1 + dimensions = (banana_array_dim) + type = integer + intent = out +[ errmsg ] + standard_name = ccpp_error_message + long_name = Error message for error handling in CCPP + units = none + dimensions = () + type = character + kind = len=512 + intent = out +[ errflg ] + standard_name = ccpp_error_code + long_name = Error flag for error handling in CCPP + units = 1 + dimensions = () + type = integer + intent = out +[ccpp-arg-table] + name = const_indices_init + type = scheme +[ const_std_name ] + standard_name = test_banana_name + type = character | kind = len=* + units = 1 + dimensions = () + protected = true + intent = in +[ num_consts ] + standard_name = banana_array_dim + long_name = Size of test_banana_name_array + units = 1 + dimensions = () + type = integer + intent = in +[ test_stdname_array ] + standard_name = test_banana_name_array + type = character | kind = len=* + units = count + dimensions = (banana_array_dim) + intent = in +[ const_index ] + standard_name = test_banana_constituent_index + long_name = Constituent index + units = 1 + dimensions = () + type = integer + intent = out +[ const_inds ] + standard_name = test_banana_constituent_indices + long_name = Array of constituent indices + units = 1 + dimensions = (banana_array_dim) + type = integer + intent = out +[ errmsg ] + standard_name = ccpp_error_message + long_name = Error message for error handling in CCPP + units = none + dimensions = () + type = character + kind = len=512 + intent = out +[ errflg ] + standard_name = ccpp_error_code + long_name = Error flag for error handling in CCPP + units = 1 + dimensions = () + type = integer + intent = out diff --git a/test/advection_test/run_test b/test/advection_test/run_test index 5f9f8a8b..2301a4fc 100755 --- a/test/advection_test/run_test +++ b/test/advection_test/run_test @@ -122,13 +122,15 @@ hash_files="${fsrc}/ccpp_hashable.F90,${fsrc}/ccpp_hash_table.F90" suite_files="${build_dir}/ccpp/ccpp_cld_suite_cap.F90" utility_files="${build_dir}/ccpp/ccpp_kinds.F90" utility_files="${utility_files},${fsrc}/ccpp_constituent_prop_mod.F90" +utility_files="${utility_files},${fsrc}/ccpp_scheme_utils.F90" utility_files="${utility_files},${hash_files}" ccpp_files="${utility_files},${host_files},${suite_files}" process_list="" -module_list="apply_constituent_tendencies,cld_ice,cld_liq" +module_list="apply_constituent_tendencies,cld_ice,cld_liq,const_indices" dependencies="" suite_list="cld_suite" -required_vars="ccpp_constituent_tendencies,ccpp_constituents" +required_vars="banana_array_dim" +required_vars="${required_vars},ccpp_constituent_tendencies,ccpp_constituents" required_vars="${required_vars},ccpp_error_code,ccpp_error_message" required_vars="${required_vars},cloud_ice_dry_mixing_ratio" required_vars="${required_vars},cloud_liquid_dry_mixing_ratio" @@ -141,11 +143,15 @@ required_vars="${required_vars},number_of_ccpp_constituents" required_vars="${required_vars},surface_air_pressure" required_vars="${required_vars},temperature" required_vars="${required_vars},tendency_of_cloud_liquid_dry_mixing_ratio" +required_vars="${required_vars},test_banana_constituent_index" +required_vars="${required_vars},test_banana_constituent_indices" +required_vars="${required_vars},test_banana_name,test_banana_name_array" required_vars="${required_vars},time_step_for_physics" required_vars="${required_vars},vertical_layer_dimension" required_vars="${required_vars},water_temperature_at_freezing" required_vars="${required_vars},water_vapor_specific_humidity" -input_vars="ccpp_constituent_tendencies,ccpp_constituents" +input_vars="banana_array_dim" +input_vars="${input_vars},ccpp_constituent_tendencies,ccpp_constituents" input_vars="${input_vars},cloud_ice_dry_mixing_ratio,cloud_liquid_dry_mixing_ratio" input_vars="${input_vars},horizontal_dimension" input_vars="${input_vars},horizontal_loop_begin" @@ -153,6 +159,7 @@ input_vars="${input_vars},horizontal_loop_end" input_vars="${input_vars},number_of_ccpp_constituents" input_vars="${input_vars},surface_air_pressure,temperature" input_vars="${input_vars},tendency_of_cloud_liquid_dry_mixing_ratio" +input_vars="${input_vars},test_banana_name,test_banana_name_array" input_vars="${input_vars},time_step_for_physics" input_vars="${input_vars},vertical_layer_dimension" input_vars="${input_vars},water_temperature_at_freezing" @@ -165,6 +172,8 @@ output_vars="${output_vars},dynamic_constituents_for_cld_ice" output_vars="${output_vars},dynamic_constituents_for_cld_liq" output_vars="${output_vars},temperature" output_vars="${output_vars},tendency_of_cloud_liquid_dry_mixing_ratio" +output_vars="${output_vars},test_banana_constituent_index" +output_vars="${output_vars},test_banana_constituent_indices" output_vars="${output_vars},water_vapor_specific_humidity" ## diff --git a/test/advection_test/test_host.F90 b/test/advection_test/test_host.F90 index c5a2121a..fa6c8e43 100644 --- a/test/advection_test/test_host.F90 +++ b/test/advection_test/test_host.F90 @@ -225,6 +225,8 @@ subroutine test_host(retval, test_suites) use test_host_mod, only: num_time_steps use test_host_mod, only: init_data, compare_data use test_host_mod, only: ncols, pver + use test_host_data, only: num_consts, std_name_array, const_std_name + use test_host_data, only: check_constituent_indices use test_host_ccpp_cap, only: test_host_ccpp_deallocate_dynamic_constituents use test_host_ccpp_cap, only: test_host_ccpp_register_constituents use test_host_ccpp_cap, only: test_host_ccpp_is_scheme_constituent @@ -255,6 +257,8 @@ subroutine test_host(retval, test_suites) logical :: const_log logical :: is_constituent logical :: has_default + integer :: test_scalar_const_index + integer :: test_const_indices(num_consts) character(len=128), allocatable :: suite_names(:) character(len=256) :: const_str character(len=512) :: errmsg @@ -359,7 +363,7 @@ subroutine test_host(retval, test_suites) call test_host_ccpp_register_constituents(host_constituents, & errmsg=errmsg, errflg=errflg) end if - ! Check the error + ! Check the error if (errflg == 0) then write(6, '(2a)') 'ERROR register_constituents: expected this error: ', & trim(expected_error) @@ -460,6 +464,16 @@ subroutine test_host(retval, test_suites) call check_errflg(subname//".index_dyn_const3", errflg, errmsg, & errflg_final) + ! Load up the test array indices + call test_host_const_get_index(const_std_name, test_scalar_const_index, errflg, errmsg) + call check_errflg(subname//"."//const_std_name, errflg, errmsg, & + errflg_final) + do sind = 1, num_consts + call test_host_const_get_index(std_name_array(sind), & + test_const_indices(sind), errflg, errmsg) + call check_errflg(subname//"."//std_name_array(sind), errflg, errmsg, & + errflg_final) + end do ! Stop tests here if the index checks failed, as all other tests will ! likely fail as well: @@ -1017,6 +1031,12 @@ subroutine test_host(retval, test_suites) end if end do + ! Check indices + call check_constituent_indices(test_scalar_const_index, test_const_indices, & + errmsg, errflg) + call check_errflg(subname//" check suite indices", errflg, errmsg, & + errflg_final) + ! Loop over time steps do time_step = 1, num_time_steps ! Initialize the timestep @@ -1054,6 +1074,11 @@ subroutine test_host(retval, test_suites) end do end do end do + ! Check indices + call check_constituent_indices(test_scalar_const_index, test_const_indices, & + errmsg, errflg) + call check_errflg(subname//" check suite indices", errflg, errmsg, & + errflg_final) do sind = 1, num_suites if (errflg == 0) then @@ -1116,15 +1141,16 @@ program test implicit none character(len=cs), target :: test_parts1(1) - character(len=cm), target :: test_invars1(11) - character(len=cm), target :: test_outvars1(11) - character(len=cm), target :: test_reqvars1(15) + character(len=cm), target :: test_invars1(12) + character(len=cm), target :: test_outvars1(13) + character(len=cm), target :: test_reqvars1(18) type(suite_info) :: test_suites(1) logical :: run_okay test_parts1 = (/ 'physics '/) test_invars1 = (/ & + 'banana_array_dim ', & 'cloud_ice_dry_mixing_ratio ', & 'cloud_liquid_dry_mixing_ratio ', & 'tendency_of_cloud_liquid_dry_mixing_ratio', & @@ -1147,8 +1173,11 @@ program test 'dynamic_constituents_for_cld_liq ', & 'dynamic_constituents_for_cld_ice ', & 'tendency_of_cloud_liquid_dry_mixing_ratio', & + 'test_banana_constituent_index ', & + 'test_banana_constituent_indices ', & 'cloud_ice_dry_mixing_ratio ' /) test_reqvars1 = (/ & + 'banana_array_dim ', & 'surface_air_pressure ', & 'temperature ', & 'time_step_for_physics ', & @@ -1161,6 +1190,8 @@ program test 'ccpp_constituent_tendencies ', & 'ccpp_constituents ', & 'number_of_ccpp_constituents ', & + 'test_banana_constituent_index ', & + 'test_banana_constituent_indices ', & 'water_vapor_specific_humidity ', & 'ccpp_error_message ', & 'ccpp_error_code ' /) diff --git a/test/advection_test/test_host_data.F90 b/test/advection_test/test_host_data.F90 index ee33b66a..bbf0efdc 100644 --- a/test/advection_test/test_host_data.F90 +++ b/test/advection_test/test_host_data.F90 @@ -2,6 +2,8 @@ module test_host_data use ccpp_kinds, only: kind_phys + implicit none + !> \section arg_table_physics_state Argument Table !! \htmlinclude arg_table_physics_state.html type physics_state @@ -10,10 +12,63 @@ module test_host_data real(kind_phys), dimension(:,:,:), pointer :: q => NULL() ! constituent array end type physics_state - public allocate_physics_state + !> \section arg_table_test_host_data Argument Table + !! \htmlinclude arg_table_test_host_data.html + integer, public, parameter :: num_consts = 3 + character(len=32), public, parameter :: std_name_array(num_consts) = (/ & + 'specific_humidity ', & + 'cloud_liquid_dry_mixing_ratio', & + 'cloud_ice_dry_mixing_ratio ' /) + character(len=32), public, parameter :: const_std_name = std_name_array(1) + + integer :: const_inds(num_consts) = -1 ! test array access from suite + integer :: const_index = -1 ! test scalar access from suite + + public :: allocate_physics_state + public :: check_constituent_indices contains + subroutine check_constituent_indices(test_index, test_indices, errmsg, errflg) + ! Check constituent indices against what was found by suite + ! indices are passed in rather than looked up to avoid a dependency loop + ! Dummy arguments + integer, intent(in) :: test_index ! scalar const index from host + integer, intent(in) :: test_indices(:) ! array_test_indices from host + character(len=*), intent(out) :: errmsg + integer, intent(out) :: errflg + + ! Local variable + integer :: indx + integer :: emstrt + + errflg = 0 + errmsg = '' + if (test_index /= const_index) then + emstrt = len_trim(errmsg) + 1 + write(errmsg(emstrt:), '(2a,i0,a,i0)') 'const_index_check for ', & + const_std_name, test_index, ' /= ', const_index + errflg = errflg + 1 + end if + do indx = 1, num_consts + if (test_indices(indx) /= const_inds(indx)) then + emstrt = len_trim(errmsg) + 1 + if (len_trim(errmsg) > 0) then + write(errmsg(emstrt:), '(", ")') + emstrt = emstrt + 2 + end if + write(errmsg(emstrt:), '(2a,i0,a,i0)') 'const_indices_check for ', & + std_name_array(indx), test_indices(indx), ' /= ', const_inds(indx) + errflg = errflg + 1 + end if + end do + + ! Reset for next test + const_index = -1 + const_inds = -1 + + end subroutine check_constituent_indices + subroutine allocate_physics_state(cols, levels, constituents, state) integer, intent(in) :: cols integer, intent(in) :: levels diff --git a/test/advection_test/test_host_data.meta b/test/advection_test/test_host_data.meta index d256d2ec..a676f141 100644 --- a/test/advection_test/test_host_data.meta +++ b/test/advection_test/test_host_data.meta @@ -30,3 +30,41 @@ kind = kind_phys units = kg kg-1 dimensions = (horizontal_dimension, vertical_layer_dimension) + +[ccpp-table-properties] + name = test_host_data + type = module +[ccpp-arg-table] + name = test_host_data + type = module +[ num_consts ] + standard_name = banana_array_dim + long_name = Size of test_banana_name_array + units = 1 + dimensions = () + type = integer +[ std_name_array ] + standard_name = test_banana_name_array + type = character | kind = len=32 + units = count + dimensions = (banana_array_dim) + protected = true +[ const_std_name ] + standard_name = test_banana_name + type = character | kind = len=32 + units = 1 + dimensions = () + protected = true +[ const_inds ] + standard_name = test_banana_constituent_indices + long_name = Array of constituent indices + units = 1 + dimensions = (banana_array_dim) + protected = true + type = integer +[ const_index ] + standard_name = test_banana_constituent_index + long_name = Constituent index + units = 1 + dimensions = () + type = integer diff --git a/test/advection_test/test_host_mod.F90 b/test/advection_test/test_host_mod.F90 index 0ae75b3d..50826f17 100644 --- a/test/advection_test/test_host_mod.F90 +++ b/test/advection_test/test_host_mod.F90 @@ -10,7 +10,7 @@ module test_host_mod real(kind_phys), parameter :: tolerance = 1.0e-13_kind_phys !> \section arg_table_test_host_mod Argument Table - !! \htmlinclude arg_table_test_host_host.html + !! \htmlinclude arg_table_test_host_mod.html !! integer, parameter :: ncols = 10 integer, parameter :: pver = 5 diff --git a/test/advection_test/test_reports.py b/test/advection_test/test_reports.py index 2a51a411..04294364 100644 --- a/test/advection_test/test_reports.py +++ b/test/advection_test/test_reports.py @@ -60,11 +60,13 @@ def usage(errmsg=None): _UTILITY_FILES = [os.path.join(_BUILD_DIR, "ccpp", "ccpp_kinds.F90"), os.path.join(_FRAMEWORK_DIR, "src", "ccpp_constituent_prop_mod.F90"), + os.path.join(_FRAMEWORK_DIR, "src", + "ccpp_scheme_utils.F90"), os.path.join(_FRAMEWORK_DIR, "src", "ccpp_hashable.F90"), os.path.join(_FRAMEWORK_DIR, "src", "ccpp_hash_table.F90")] _CCPP_FILES = _UTILITY_FILES + _HOST_FILES + _SUITE_FILES _PROCESS_LIST = list() -_MODULE_LIST = ["cld_ice", "cld_liq", "apply_constituent_tendencies"] +_MODULE_LIST = ["cld_ice", "cld_liq", "const_indices", "apply_constituent_tendencies"] _SUITE_LIST = ["cld_suite"] _DYN_CONST_ROUTINES = ["cld_ice_dynamic_constituents", "cld_liq_dynamic_constituents"] _REQUIRED_VARS_CLD = ["ccpp_error_code", "ccpp_error_message", @@ -80,6 +82,10 @@ def usage(errmsg=None): "number_of_ccpp_constituents", "dynamic_constituents_for_cld_ice", "dynamic_constituents_for_cld_liq", + "test_banana_constituent_indices", "test_banana_name", + "banana_array_dim", + "test_banana_name_array", + "test_banana_constituent_index", # Added by --debug option "horizontal_dimension", "vertical_layer_dimension"] @@ -93,6 +99,8 @@ def usage(errmsg=None): "ccpp_constituents", "ccpp_constituent_tendencies", "number_of_ccpp_constituents", + "banana_array_dim", + "test_banana_name_array", "test_banana_name", # Added by --debug option "horizontal_dimension", "vertical_layer_dimension"] @@ -104,7 +112,9 @@ def usage(errmsg=None): "ccpp_constituent_tendencies", "cloud_liquid_dry_mixing_ratio", "dynamic_constituents_for_cld_ice", - "dynamic_constituents_for_cld_liq"] + "dynamic_constituents_for_cld_liq", + "test_banana_constituent_indices", + "test_banana_constituent_index"] def fields_string(field_type, field_list, sep): """Create an error string for field(s), . diff --git a/test/capgen_test/run_test b/test/capgen_test/run_test index f0b71aa2..5b0f4fe8 100755 --- a/test/capgen_test/run_test +++ b/test/capgen_test/run_test @@ -122,6 +122,7 @@ suite_files="${build_dir}/ccpp/ccpp_ddt_suite_cap.F90" suite_files="${suite_files},${build_dir}/ccpp/ccpp_temp_suite_cap.F90" utility_files="${build_dir}/ccpp/ccpp_kinds.F90" utility_files="${utility_files},${frame_src}/ccpp_constituent_prop_mod.F90" +utility_files="${utility_files},${frame_src}/ccpp_scheme_utils.F90" utility_files="${utility_files},${frame_src}/ccpp_hashable.F90" utility_files="${utility_files},${frame_src}/ccpp_hash_table.F90" ccpp_files="${utility_files}" diff --git a/test/capgen_test/test_host_data.F90 b/test/capgen_test/test_host_data.F90 index 7a651fca..0c7cdea1 100644 --- a/test/capgen_test/test_host_data.F90 +++ b/test/capgen_test/test_host_data.F90 @@ -2,6 +2,9 @@ module test_host_data use ccpp_kinds, only: kind_phys + implicit none + private + !> \section arg_table_physics_state Argument Table !! \htmlinclude arg_table_physics_state.html type physics_state @@ -16,7 +19,8 @@ module test_host_data q ! constituent mixing ratio (kg/kg moist or dry air depending on type) end type physics_state - public allocate_physics_state + public :: physics_state + public :: allocate_physics_state contains diff --git a/test/capgen_test/test_reports.py b/test/capgen_test/test_reports.py index ed123013..499ab22d 100644 --- a/test/capgen_test/test_reports.py +++ b/test/capgen_test/test_reports.py @@ -61,6 +61,7 @@ def usage(errmsg=None): os.path.join(_BUILD_DIR, "ccpp", "ccpp_temp_suite_cap.F90")] _UTILITY_FILES = [os.path.join(_BUILD_DIR, "ccpp", "ccpp_kinds.F90"), os.path.join(_SRC_DIR, "ccpp_constituent_prop_mod.F90"), + os.path.join(_SRC_DIR, "ccpp_scheme_utils.F90"), os.path.join(_SRC_DIR, "ccpp_hashable.F90"), os.path.join(_SRC_DIR, "ccpp_hash_table.F90")] _CCPP_FILES = _UTILITY_FILES + \ diff --git a/test/ddthost_test/run_test b/test/ddthost_test/run_test index 65e73886..98b934b4 100755 --- a/test/ddthost_test/run_test +++ b/test/ddthost_test/run_test @@ -122,6 +122,7 @@ suite_files="${build_dir}/ccpp/ccpp_ddt_suite_cap.F90" suite_files="${suite_files},${build_dir}/ccpp/ccpp_temp_suite_cap.F90" utility_files="${build_dir}/ccpp/ccpp_kinds.F90" utility_files="${utility_files},${frame_src}/ccpp_constituent_prop_mod.F90" +utility_files="${utility_files},${frame_src}/ccpp_scheme_utils.F90" utility_files="${utility_files},${frame_src}/ccpp_hashable.F90" utility_files="${utility_files},${frame_src}/ccpp_hash_table.F90" ccpp_files="${utility_files}" diff --git a/test/ddthost_test/test_reports.py b/test/ddthost_test/test_reports.py index aae9098b..e2904a6e 100644 --- a/test/ddthost_test/test_reports.py +++ b/test/ddthost_test/test_reports.py @@ -51,6 +51,7 @@ os.path.join(_BUILD_DIR, "ccpp", "ccpp_temp_suite_cap.F90")] _UTILITY_FILES = [os.path.join(_BUILD_DIR, "ccpp", "ccpp_kinds.F90"), os.path.join(_SRC_DIR, "ccpp_constituent_prop_mod.F90"), + os.path.join(_SRC_DIR, "ccpp_scheme_utils.F90"), os.path.join(_SRC_DIR, "ccpp_hashable.F90"), os.path.join(_SRC_DIR, "ccpp_hash_table.F90")] _CCPP_FILES = _UTILITY_FILES + \ diff --git a/test/var_compatibility_test/run_test b/test/var_compatibility_test/run_test index 5a1d6b5c..adf2123b 100755 --- a/test/var_compatibility_test/run_test +++ b/test/var_compatibility_test/run_test @@ -121,6 +121,7 @@ host_files="${build_dir}/ccpp/test_host_ccpp_cap.F90" suite_files="${build_dir}/ccpp/ccpp_var_compatibility_suite_cap.F90" utility_files="${build_dir}/ccpp/ccpp_kinds.F90" utility_files="${utility_files},${frame_src}/ccpp_constituent_prop_mod.F90" +utility_files="${utility_files},${frame_src}/ccpp_scheme_utils.F90" utility_files="${utility_files},${frame_src}/ccpp_hashable.F90" utility_files="${utility_files},${frame_src}/ccpp_hash_table.F90" ccpp_files="${utility_files}" diff --git a/test/var_compatibility_test/test_host_data.F90 b/test/var_compatibility_test/test_host_data.F90 index 9d0ca306..04d7e77e 100644 --- a/test/var_compatibility_test/test_host_data.F90 +++ b/test/var_compatibility_test/test_host_data.F90 @@ -2,6 +2,9 @@ module test_host_data use ccpp_kinds, only: kind_phys + implicit none + private + !> \section arg_table_physics_state Argument Table !! \htmlinclude arg_table_physics_state.html type physics_state @@ -15,7 +18,8 @@ module test_host_data real(kind_phys) :: scalar_var end type physics_state - public allocate_physics_state + public :: physics_state + public :: allocate_physics_state contains diff --git a/test/var_compatibility_test/test_reports.py b/test/var_compatibility_test/test_reports.py index 6f10fc6d..347c4128 100755 --- a/test/var_compatibility_test/test_reports.py +++ b/test/var_compatibility_test/test_reports.py @@ -60,6 +60,7 @@ def usage(errmsg=None): _SUITE_FILES = [os.path.join(_BUILD_DIR, "ccpp", "ccpp_var_compatibility_suite_cap.F90")] _UTILITY_FILES = [os.path.join(_BUILD_DIR, "ccpp", "ccpp_kinds.F90"), os.path.join(_SRC_DIR, "ccpp_constituent_prop_mod.F90"), + os.path.join(_SRC_DIR, "ccpp_scheme_utils.F90"), os.path.join(_SRC_DIR, "ccpp_hashable.F90"), os.path.join(_SRC_DIR, "ccpp_hash_table.F90")] _CCPP_FILES = _UTILITY_FILES + \