Skip to content

Commit

Permalink
Validates the MUSICA meta data against the CCPP standard names (ESCOM…
Browse files Browse the repository at this point in the history
…P#162)

Originator(s): @boulderdaze

Summary (include the keyword ['closes', 'fixes', 'resolves'] and issue
number):
- Add an automated checker that validates the MUSICA meta data against
the CCPP standard names
- Closes ESCOMP#120 

Describe any changes made to the namelist: N/A

List all files eliminated and why: N/A

List all files added and what they do:  N/A

List all existing files that have been modified, and describe the
changes:
```
M   doc/NamesNotInDictionary.txt
M   schemes/musica/musica_ccpp_namelist.xml
M   test/docker/Dockerfile.musica
M   test/docker/Dockerfile.musica.no_install
M   test/musica/CMakeLists.txt
```
List any test failures: N/A

Is this a science-changing update? New physics package, algorithm
change, tuning changes, etc? No

---------

Co-authored-by: Matt Dawson <[email protected]>
  • Loading branch information
boulderdaze and mattldawson authored Nov 26, 2024
1 parent 9cec536 commit 01e619f
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 17 deletions.
9 changes: 8 additions & 1 deletion doc/NamesNotInDictionary.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

#######################
Date/time of when script was run:
2024-11-18 15:44:54.993446
2024-11-21 12:02:27.234727
#######################

Non-dictionary standard names found in the following metadata files:
Expand Down Expand Up @@ -34,6 +34,7 @@ atmospheric_physics/schemes/sima_diagnostics/sima_state_diagnostics.meta

- air_pressure_at_interface
- air_pressure_of_dry_air_at_interface
- geopotential_height_wrt_surface_at_interface
- ln_air_pressure_at_interface
- ln_air_pressure_of_dry_air_at_interface
- surface_air_pressure
Expand Down Expand Up @@ -195,6 +196,7 @@ atmospheric_physics/schemes/zhang_mcfarlane/zm_convr.meta
- flag_for_no_deep_convection_in_pbl?
- freezing_point_of_water?
- gas_constant_of_water_vapor?
- geopotential_height_wrt_surface_at_interface
- horizontal_index_of_convective_columns_for_deep_convection_for_convective_columns
- in_cloud_water_vapor_mixing_ratio_wrt_moist_air_and_condensed_water_due_to_deep_convection
- initial_parcel_property_as_function_of_well-mixed_pbl_for_zhang_mcfarlane?
Expand Down Expand Up @@ -248,6 +250,7 @@ atmospheric_physics/schemes/zhang_mcfarlane/zm_conv_convtran.meta
atmospheric_physics/schemes/utilities/geopotential_temp.meta

- air_pressure_at_interface
- geopotential_height_wrt_surface_at_interface
- ln_air_pressure_at_interface

--------------------------
Expand Down Expand Up @@ -337,6 +340,7 @@ atmospheric_physics/schemes/tropopause_find/tropopause_find.meta
- air_pressure_at_interface
- fill_value_for_diagnostic_output
- fractional_calendar_days_on_end_of_current_timestep
- geopotential_height_wrt_surface_at_interface
- pi_constant
- ratio_of_dry_air_gas_constant_to_specific_heat_of_dry_air_at_constant_pressure
- tropopause_air_pressure
Expand Down Expand Up @@ -375,8 +379,11 @@ atmospheric_physics/schemes/musica/musica_ccpp.meta

- blackbody_temperature_at_surface
- dynamic_constituents_for_musica_ccpp
- extraterrestrial_radiation_flux
- geopotential_height_wrt_surface_at_interface
- micm_solver_type
- number_of_grid_cells
- number_of_photolysis_wavelength_grid_sections
- photolysis_wavelength_grid_interfaces
- surface_albedo_due_to_UV_and_VIS_direct

Expand Down
8 changes: 5 additions & 3 deletions schemes/musica/micm/musica_ccpp_micm.F90
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,15 @@ module musica_ccpp_micm
contains

!> Registers MICM constituent properties with the CCPP
subroutine micm_register(solver_type, num_grid_cells, constituent_props, errmsg, errcode)
subroutine micm_register(solver_type, number_of_grid_cells, constituent_props, &
errmsg, errcode)
use ccpp_constituent_prop_mod, only: ccpp_constituent_properties_t
use musica_micm, only: Rosenbrock, RosenbrockStandardOrder
use musica_util, only: error_t
use iso_c_binding, only: c_int

integer(c_int), intent(in) :: solver_type
integer(c_int), intent(in) :: num_grid_cells
integer(c_int), intent(in) :: number_of_grid_cells
type(ccpp_constituent_properties_t), allocatable, intent(out) :: constituent_props(:)
character(len=512), intent(out) :: errmsg
integer, intent(out) :: errcode
Expand All @@ -37,7 +38,8 @@ subroutine micm_register(solver_type, num_grid_cells, constituent_props, errmsg,
logical :: is_advected
integer :: i, species_index

micm => micm_t(trim(filename_of_micm_configuration), solver_type, num_grid_cells, error)
micm => micm_t(trim(filename_of_micm_configuration), solver_type, &
number_of_grid_cells, error)
if (has_error_occurred(error, errmsg, errcode)) return

allocate(constituent_props(micm%species_ordering%size()), stat=errcode)
Expand Down
10 changes: 6 additions & 4 deletions schemes/musica/musica_ccpp.F90
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,18 @@ module musica_ccpp

!> \section arg_table_musica_ccpp_register Argument Table
!! \htmlinclude musica_ccpp_register.html
subroutine musica_ccpp_register(solver_type, num_grid_cells, constituent_props, errmsg, errcode)
subroutine musica_ccpp_register(micm_solver_type, number_of_grid_cells, &
constituent_props, errmsg, errcode)
use ccpp_constituent_prop_mod, only: ccpp_constituent_properties_t

integer, intent(in) :: solver_type
integer, intent(in) :: num_grid_cells
integer, intent(in) :: micm_solver_type
integer, intent(in) :: number_of_grid_cells
type(ccpp_constituent_properties_t), allocatable, intent(out) :: constituent_props(:)
character(len=512), intent(out) :: errmsg
integer, intent(out) :: errcode

call micm_register(solver_type, num_grid_cells, constituent_props, errmsg, errcode)
call micm_register(micm_solver_type, number_of_grid_cells, constituent_props, &
errmsg, errcode)

end subroutine musica_ccpp_register

Expand Down
4 changes: 2 additions & 2 deletions schemes/musica/musica_ccpp.meta
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
[ccpp-arg-table]
name = musica_ccpp_register
type = scheme
[ solver_type ]
[ micm_solver_type ]
standard_name = micm_solver_type
units = none
type = integer
dimensions = ()
intent = in
[ num_grid_cells ]
[ number_of_grid_cells ]
standard_name = number_of_grid_cells
units = count
type = integer
Expand Down
14 changes: 11 additions & 3 deletions schemes/musica/musica_ccpp_namelist.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,16 @@
units
This is the CCPP unit specification of the variable (e.g., m s-1).
-->
<!-- MUSICA configuration options -->
<section name="MUSICA Standard Names">
<standard_name name="micm_solver_type">
<type kind="" units="none">integer</type>
</standard_name>
<standard_name name="number_of_grid_cells">
<type kind="" units="count">integer</type>
</standard_name>
</section>

<!-- MUSICA configuration options -->
<entry id="filename_of_micm_configuration">
<type>char*512</type>
<category>musica_ccpp</category>
Expand Down Expand Up @@ -115,5 +123,5 @@
<values>
<value>UNSET_PATH</value>
</values>

</entry_id_pg>
</entry>
</entry_id_pg>
7 changes: 6 additions & 1 deletion test/docker/Dockerfile.musica
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,19 @@ RUN git clone https://github.com/NCAR/cam-sima-chemistry-data.git \
&& git checkout ${CAM_SIMA_CHEMISTRY_DATA_TAG} \
&& mv mechanisms /home/test_user/atmospheric_physics/schemes/musica/configurations

# Must make ccpp-framework available before building test
# Make CCPP-framework available before building test
RUN cd atmospheric_physics/test \
&& mkdir lib \
&& cd lib \
&& git clone -b develop --depth 1 https://github.com/NCAR/ccpp-framework.git
ENV CCPP_SRC_PATH="lib/ccpp-framework/src"
ENV CCPP_FORTRAN_TOOLS_PATH="lib/ccpp-framework/scripts/fortran_tools"

# Make the CCPPStandardNames available
RUN cd atmospheric_physics/test/lib \
&& git clone --depth 1 https://github.com/ESCOMP/CCPPStandardNames.git
ENV CCPP_STD_NAMES_PATH="lib/CCPPStandardNames"

RUN cd atmospheric_physics/test \
&& cmake -S . -B build \
-D CMAKE_BUILD_TYPE={BUILD_TYPE} \
Expand Down
7 changes: 6 additions & 1 deletion test/docker/Dockerfile.musica.no_install
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,19 @@ RUN git clone https://github.com/NCAR/cam-sima-chemistry-data.git \
&& git checkout ${CAM_SIMA_CHEMISTRY_DATA_TAG} \
&& mv mechanisms /home/test_user/atmospheric_physics/schemes/musica/configurations

# Must make ccpp-framework available before building test
# Make ccpp-framework available before building test
RUN cd atmospheric_physics/test \
&& mkdir lib \
&& cd lib \
&& git clone -b develop --depth 1 https://github.com/NCAR/ccpp-framework.git
ENV CCPP_SRC_PATH="lib/ccpp-framework/src"
ENV CCPP_FORTRAN_TOOLS_PATH="lib/ccpp-framework/scripts/fortran_tools"

# Make the CCPPStandardNames available
RUN cd atmospheric_physics/test/lib \
&& git clone --depth 1 https://github.com/ESCOMP/CCPPStandardNames.git
ENV CCPP_STD_NAMES_PATH="lib/CCPPStandardNames"

RUN cd atmospheric_physics/test \
&& cmake -S . -B build \
-D CMAKE_BUILD_TYPE=${BUILD_TYPE} \
Expand Down
12 changes: 10 additions & 2 deletions test/musica/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ add_custom_target(
add_subdirectory(micm)
add_subdirectory(tuvx)

# Test metdadata
# Test metadata against the source code
find_package(Python REQUIRED)

file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/metadata_test)
Expand All @@ -75,7 +75,15 @@ add_custom_target(
)

add_test(
NAME test_metadata
NAME test_metadata_against_source_code
COMMAND ${Python_EXECUTABLE} ${CMAKE_BINARY_DIR}/../$ENV{CCPP_FORTRAN_TOOLS_PATH}/offline_check_fortran_vs_metadata.py
--directory ${CMAKE_BINARY_DIR}/metadata_test
)

# Test metadata against the CCPP standard names
add_test(
NAME test_metadata_against_ccpp_standard_names
COMMAND ${Python_EXECUTABLE} ${CMAKE_BINARY_DIR}/../$ENV{CCPP_STD_NAMES_PATH}/tools/meta_stdname_check.py
--metafile-loc ${CMAKE_BINARY_DIR}/metadata_test/musica_ccpp.meta
--stdname-dict ${CMAKE_BINARY_DIR}/../$ENV{CCPP_STD_NAMES_PATH}/standard_names.xml
)

0 comments on commit 01e619f

Please sign in to comment.