From 1e11d2f6790e705696fc5288744b8a1b02bda2ae Mon Sep 17 00:00:00 2001 From: Lizzie Lundgren Date: Tue, 21 Jul 2026 10:32:23 -0400 Subject: [PATCH 1/3] Move DynCore_GridCompMod functions used in AdvCore to new shared module This enables not building DynCore in models that only use AdvCore Signed-off-by: Lizzie Lundgren --- AdvCore_GridCompMod.F90 | 4 +- CMakeLists.txt | 1 + DynCore_GridCompMod.F90 | 81 +------------------------------------ fv_shared.F90 | 90 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 95 insertions(+), 81 deletions(-) create mode 100644 fv_shared.F90 diff --git a/AdvCore_GridCompMod.F90 b/AdvCore_GridCompMod.F90 index bca52d78..577f474b 100644 --- a/AdvCore_GridCompMod.F90 +++ b/AdvCore_GridCompMod.F90 @@ -69,8 +69,8 @@ module AdvCore_GridCompMod use fv_diagnostics_mod, only: prt_maxmin, prt_minmax use FV_StateMod, only: FV_Atm, setup_fv_dimensions_and_topology use FV_StateMod, only: AdvCoreTracers => T_TRACERS - use FVdycoreCubed_GridComp, only: field_is_cloud_water_species - use FVdycoreCubed_GridComp, only: get_short_name, is_name_in_list + use fv_shared, only: field_is_cloud_water_species + use fv_shared, only: get_short_name, is_name_in_list use pflogger, only: logger_t => logger diff --git a/CMakeLists.txt b/CMakeLists.txt index 763032b6..81964025 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,6 +13,7 @@ set (srcs GEOS_FV3_Utilities.F90 fv_regridding_utils.F90 fv_regrid_c2c.F90 + fv_shared.F90 rs_scaleMod.F90 ) if (BUILD_GEOS_GTFV3_INTERFACE) diff --git a/DynCore_GridCompMod.F90 b/DynCore_GridCompMod.F90 index 62c84836..619fe546 100644 --- a/DynCore_GridCompMod.F90 +++ b/DynCore_GridCompMod.F90 @@ -38,6 +38,8 @@ module FVdycoreCubed_GridComp ! FV Specific Module use fv_arrays_mod, only: REAL4, REAL8, FVPRC + use fv_shared, only: get_short_name, is_name_in_list + use fv_shared, only: field_is_cloud_water_species !use fv_grid_tools_mod, only: grid_type use FV_StateMod, only : & FV_Atm, & @@ -83,9 +85,6 @@ module FVdycoreCubed_GridComp logical :: DEBUG_TQ_ERRORS public :: SetServices ! Register component methods - public :: get_short_name - public :: field_is_cloud_water_species - public :: is_name_in_list !DESCRIPTION: This module implements the Dynamical Core as ! an ESMF gridded component. @@ -2656,82 +2655,6 @@ function get_adjusted_tracer_bundle(orig_bundle, hconfig, rc) result(adjusted_bu _RETURN(_SUCCESS) end function get_adjusted_tracer_bundle - function get_short_name(field, rc) result(short_name) - type(ESMF_Field) :: field - integer, intent(out) :: rc - character(len=:), allocatable :: short_name - - character(len=:), allocatable :: standard_name - integer :: status - - call MAPL_FieldGet(field, standard_name=standard_name, _RC) - select case (trim(standard_name)) - case ("specific_humidity") - short_name = "Q" - case ("mass_fraction_of_large_scale_cloud_liquid_water") - short_name = "QLLS" - case ("mass_fraction_of_convective_cloud_liquid_water") - short_name = "QLCN" - case ("mass_fraction_of_large_scale_cloud_ice_water") - short_name = "QILS" - case ("mass_fraction_of_convective_cloud_ice_water") - short_name = "QICN" - case ("large_scale_cloud_area_fraction") - short_name = "CLLS" - case ("convective_cloud_area_fraction") - short_name = "CLCN" - case ("mass_fraction_of_rain") - short_name = "QRAIN" - case ("mass_fraction_of_snow") - short_name = "QSNOW" - case ("mass_fraction_of_graupel") - short_name = "QGRAUPEL" - case default - ! _FAIL("Unrecognized standard_name: " // trim(standard_name)) - short_name = trim(standard_name) - end select - - _RETURN(_SUCCESS) - end function get_short_name - - function field_is_cloud_water_species(field_name) result(is_cloud_water_species) - character(len=*), intent(in) :: field_name - logical :: is_cloud_water_species - - is_cloud_water_species = .false. - if ( & - (trim(field_name) == "Q") .or. & - (trim(field_name) == "QLCN") .or. & - (trim(field_name) == "QLLS") .or. & - (trim(field_name) == "QICN") .or. & - (trim(field_name) == "QILS") .or. & - (trim(field_name) == "CLCN") .or. & - (trim(field_name) == "CLLS") .or. & - (trim(field_name) == "NCPL") .or. & - (trim(field_name) == "NCPI") .or. & - (trim(field_name) == "QRAIN") .or. & - (trim(field_name) == "QSNOW") .or. & - (trim(field_name) == "QGRAUPEL")) then - is_cloud_water_species = .true. - end if - end function field_is_cloud_water_species - - function is_name_in_list(name, list) result(is_in_list) - character(len=*), intent(in) :: name - character(len=ESMF_MAXSTR), intent(in) :: list(:) - logical :: is_in_list - - integer :: n - - is_in_list = .false. - do n = 1, size(list) - if (trim(name) == trim(list(n))) then - is_in_list = .true. - exit - end if - end do - end function is_name_in_list - !BOP !IROUTINE: run_add_incs diff --git a/fv_shared.F90 b/fv_shared.F90 new file mode 100644 index 00000000..3a9256d2 --- /dev/null +++ b/fv_shared.F90 @@ -0,0 +1,90 @@ +#include "MAPL.h" + +MODULE fv_shared + + USE ESMF + USE MAPL, ONLY : MAPL_FieldGet, MAPL_Verify + + IMPLICIT NONE + ! + ! Functions used in both AdvCore_GridCompMod and DynCore_GridCompMod + ! +CONTAINS + + function get_short_name(field, rc) result(short_name) + type(ESMF_Field) :: field + integer, intent(out) :: rc + character(len=:), allocatable :: short_name + + character(len=:), allocatable :: standard_name + integer :: status + + call MAPL_FieldGet(field, standard_name=standard_name, _RC) + select case (trim(standard_name)) + case ("specific_humidity") + short_name = "Q" + case ("mass_fraction_of_large_scale_cloud_liquid_water") + short_name = "QLLS" + case ("mass_fraction_of_convective_cloud_liquid_water") + short_name = "QLCN" + case ("mass_fraction_of_large_scale_cloud_ice_water") + short_name = "QILS" + case ("mass_fraction_of_convective_cloud_ice_water") + short_name = "QICN" + case ("large_scale_cloud_area_fraction") + short_name = "CLLS" + case ("convective_cloud_area_fraction") + short_name = "CLCN" + case ("mass_fraction_of_rain") + short_name = "QRAIN" + case ("mass_fraction_of_snow") + short_name = "QSNOW" + case ("mass_fraction_of_graupel") + short_name = "QGRAUPEL" + case default + ! _FAIL("Unrecognized standard_name: " // trim(standard_name)) + short_name = trim(standard_name) + end select + + _RETURN(_SUCCESS) + end function get_short_name + + function field_is_cloud_water_species(field_name) result(is_cloud_water_species) + character(len=*), intent(in) :: field_name + logical :: is_cloud_water_species + + is_cloud_water_species = .false. + if ( & + (trim(field_name) == "Q") .or. & + (trim(field_name) == "QLCN") .or. & + (trim(field_name) == "QLLS") .or. & + (trim(field_name) == "QICN") .or. & + (trim(field_name) == "QILS") .or. & + (trim(field_name) == "CLCN") .or. & + (trim(field_name) == "CLLS") .or. & + (trim(field_name) == "NCPL") .or. & + (trim(field_name) == "NCPI") .or. & + (trim(field_name) == "QRAIN") .or. & + (trim(field_name) == "QSNOW") .or. & + (trim(field_name) == "QGRAUPEL")) then + is_cloud_water_species = .true. + end if + end function field_is_cloud_water_species + + function is_name_in_list(name, list) result(is_in_list) + character(len=*), intent(in) :: name + character(len=ESMF_MAXSTR), intent(in) :: list(:) + logical :: is_in_list + + integer :: n + + is_in_list = .false. + do n = 1, size(list) + if (trim(name) == trim(list(n))) then + is_in_list = .true. + exit + end if + end do + end function is_name_in_list + +END MODULE fv_shared From ac2bd9734794ed159d9bd894416bbe48a0959a7f Mon Sep 17 00:00:00 2001 From: Lizzie Lundgren Date: Tue, 21 Jul 2026 13:27:03 -0400 Subject: [PATCH 2/3] Explicitly set access in fv_shared.F90 New additions to the file will not be private unless explicitly declared as public Signed-off-by: Lizzie Lundgren --- fv_shared.F90 | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/fv_shared.F90 b/fv_shared.F90 index 3a9256d2..06a2f722 100644 --- a/fv_shared.F90 +++ b/fv_shared.F90 @@ -6,9 +6,17 @@ MODULE fv_shared USE MAPL, ONLY : MAPL_FieldGet, MAPL_Verify IMPLICIT NONE + + private + + public :: get_short_name + public :: field_is_cloud_water_species + public :: is_name_in_list + ! ! Functions used in both AdvCore_GridCompMod and DynCore_GridCompMod ! + CONTAINS function get_short_name(field, rc) result(short_name) From bed958edecb1afec1bc2f814550d14a866dc224a Mon Sep 17 00:00:00 2001 From: Lizzie Lundgren Date: Tue, 21 Jul 2026 16:03:59 -0400 Subject: [PATCH 3/3] Add access declarations to jw.f90 and sw.f90 and improve readability Signed-off-by: Lizzie Lundgren --- jw.f90 | 57 +++++++++++++++++++++++++++++++++------------------------ sw.f90 | 25 ++++++++++++++++--------- 2 files changed, 49 insertions(+), 33 deletions(-) diff --git a/jw.f90 b/jw.f90 index 530a7119..70825549 100644 --- a/jw.f90 +++ b/jw.f90 @@ -1,6 +1,17 @@ MODULE jw + IMPLICIT NONE - ! + + PRIVATE + + PUBLIC :: temperature + PUBLIC :: surface_geopotential + PUBLIC :: u_wind + PUBLIC :: v_wind + PUBLIC :: tracer_q1_q2 + PUBLIC :: tracer_q3 + PUBLIC :: tracer_q + ! Functions for setting up initial conditions for the Jablonowski-Williamson test case. ! ! Given longitude (radians), latitude (radians), eta (pressure) and rotation_angle (degrees) @@ -35,31 +46,29 @@ MODULE jw ! and equator. ! ! Author: Peter Hjort Lauritzen (NCAR, pel@ucar.edu) - ! - INTEGER,PARAMETER :: r8 = SELECTED_REAL_KIND(12) ! 8 byte real - - REAL(r8), PARAMETER :: & - eta_strato = 0.2d0 ,&! tropopause level - u0 = 35.d0 ,&! 35 m/s - T0 = 288.d0 ,&! global mean T at surface - p0 = 100000.d0 ,&! global mean surface pressure - eta0 = 0.252d0 ,&! center of jets (hybrid) - ! - radius = 10.d0, & ! radius of the perturbation - perturbation_amplitude = 1.d0, & ! amplitude of u perturbation 1 m/s - perturbation_longitude = 20.d0, & ! longitudinal position, 20E - perturbation_latitude = 40.d0, & ! latitudinal position, 40N - perturbation_latitude_tracer = 55.d0, & - ! + + INTEGER, PARAMETER :: r8 = SELECTED_REAL_KIND(12) ! 8 byte real + + REAL(r8), PARAMETER :: & + eta_strato = 0.2d0 ,& ! tropopause level + u0 = 35.d0 ,& ! 35 m/s + T0 = 288.d0 ,& ! global mean T at surface + p0 = 100000.d0 ,& ! global mean surface pressure + eta0 = 0.252d0 ,& ! center of jets (hybrid) ! + radius = 10.d0 ,& ! radius of the perturbation + perturbation_amplitude = 1.d0 ,& ! amplitude of u perturbation 1 m/s + perturbation_longitude = 20.d0 ,& ! longitudinal position, 20E + perturbation_latitude = 40.d0 ,& ! latitudinal position, 40N + perturbation_latitude_tracer = 55.d0 ,& ! - Rd = 287.d0 ,&! gas constant J/(K kg) - g = 9.80616d0 ,&! gravitational acceleration (m/s^2) - a = 6371229.d0,&! Earth's radius in m - omega = 7.29212d-5,&! angular velocity 1/s - gamma = 0.005d0 ,&! lapse rate - pi = 3.14159265358979323846_R8,& ! pi - deg2rad = pi/180.d0 + Rd = 287.d0 ,& ! gas constant J/(K kg) + g = 9.80616d0 ,& ! gravitational acceleration (m/s^2) + a = 6371229.d0 ,& ! Earth's radius in m + omega = 7.29212d-5 ,& ! angular velocity 1/s + gamma = 0.005d0 ,& ! lapse rate + pi = 3.14159265358979323846_R8 ,& ! pi + deg2rad = pi/180.d0 CONTAINS ! diff --git a/sw.f90 b/sw.f90 index fed1659e..f5365367 100644 --- a/sw.f90 +++ b/sw.f90 @@ -1,14 +1,21 @@ MODULE sw + IMPLICIT NONE - INTEGER,PARAMETER :: r8 = SELECTED_REAL_KIND(12) ! 8 byte real - - REAL(r8), PARAMETER :: & - alpha = 0. ,&! angle of axis rotation about the poles - ! - ! - g = 9.80616d0 ,&! gravitational acceleration (m/s^2) - a = 6371229.d0,&! Earth's radius in m - omega = 7.29212d-5,&! angular velocity 1/s + + PRIVATE + + PUBLIC :: surface_geopotential + PUBLIC :: height + PUBLIC :: u_wind + PUBLIC :: v_wind + + INTEGER, PARAMETER :: r8 = SELECTED_REAL_KIND(12) ! 8 byte real + + REAL(r8), PARAMETER :: & + alpha = 0. ,&! angle of axis rotation about the poles + g = 9.80616d0 ,&! gravitational acceleration (m/s^2) + a = 6371229.d0 ,&! Earth's radius in m + omega = 7.29212d-5 ,&! angular velocity 1/s pi = 3.14159265358979323846_R8,& ! pi deg2rad = pi/180.d0