From 38fdbb21c4da0c625f9c964d503b12ad909c3775 Mon Sep 17 00:00:00 2001 From: Haipeng Lin Date: Thu, 24 Oct 2024 14:52:30 -0400 Subject: [PATCH] Read cp_or_cv_dycore and identify dycore information from CAM snapshot --- src/data/cam_thermo_formula.F90 | 13 +++++++++++++ src/data/registry.xml | 1 + src/dynamics/none/dyn_grid.F90 | 16 ++++++++++------ src/physics/utils/phys_comp.F90 | 2 ++ tools/stdnames_to_inputnames_dictionary.xml | 5 +++++ 5 files changed, 31 insertions(+), 6 deletions(-) diff --git a/src/data/cam_thermo_formula.F90 b/src/data/cam_thermo_formula.F90 index 56a56cf7..c3e2c15b 100644 --- a/src/data/cam_thermo_formula.F90 +++ b/src/data/cam_thermo_formula.F90 @@ -21,4 +21,17 @@ module cam_thermo_formula ! energy_formula_physics: energy formula used for physics integer, public :: energy_formula_physics = ENERGY_FORMULA_DYCORE_FV + ! Public subroutines + public :: cam_thermo_formula_init + +contains + subroutine cam_thermo_formula_init() + use phys_vars_init_check, only: mark_as_initialized + + ! Physics energy formulation is always FV (moist pressure coordinate) + energy_formula_physics = ENERGY_FORMULA_DYCORE_FV + call mark_as_initialized("total_energy_formula_for_physics") + + end subroutine cam_thermo_formula_init + end module cam_thermo_formula diff --git a/src/data/registry.xml b/src/data/registry.xml index bda3800d..d2445ab9 100644 --- a/src/data/registry.xml +++ b/src/data/registry.xml @@ -428,6 +428,7 @@ allocatable="allocatable"> Enthalpy or internal energy scaling factor for energy consistency horizontal_dimension vertical_layer_dimension + cp_or_cv_dycore diff --git a/src/dynamics/none/dyn_grid.F90 b/src/dynamics/none/dyn_grid.F90 index 8e5a2a69..d18cbc07 100644 --- a/src/dynamics/none/dyn_grid.F90 +++ b/src/dynamics/none/dyn_grid.F90 @@ -637,10 +637,11 @@ end subroutine find_dimension !=========================================================================== subroutine find_energy_formula(file, grid_is_latlon) - use pio, only: file_desc_t, var_desc_t - use pio, only: pio_inq_att, PIO_NOERR - use cam_thermo_formula, only: energy_formula_physics, energy_formula_dycore - use cam_thermo_formula, only: ENERGY_FORMULA_DYCORE_SE, ENERGY_FORMULA_DYCORE_FV, ENERGY_FORMULA_DYCORE_MPAS + use pio, only: file_desc_t + use pio, only: pio_inq_att, pio_global, PIO_NOERR + use cam_thermo_formula, only: energy_formula_physics, energy_formula_dycore + use cam_thermo_formula, only: ENERGY_FORMULA_DYCORE_SE, ENERGY_FORMULA_DYCORE_FV, ENERGY_FORMULA_DYCORE_MPAS + use phys_vars_init_check, only: mark_as_initialized ! Find which dynamical core is used in and set the energy formulation ! (also called vc_dycore in CAM) @@ -649,7 +650,6 @@ subroutine find_energy_formula(file, grid_is_latlon) logical, intent(in) :: grid_is_latlon ! Local variables - type(var_desc_t) :: vardesc integer :: ierr, xtype character(len=*), parameter :: subname = 'find_energy_formula' @@ -663,7 +663,7 @@ subroutine find_energy_formula(file, grid_is_latlon) endif else ! Is SE dycore? - ierr = pio_inq_att(file, vardesc, 'ne', xtype) + ierr = pio_inq_att(file, pio_global, 'ne', xtype) if (ierr == PIO_NOERR) then ! Has ne property - is SE dycore. ! if has fv_nphys then is physics grid (ne..pg..), but the energy formulation is the same. @@ -681,6 +681,10 @@ subroutine find_energy_formula(file, grid_is_latlon) endif endif + if(energy_formula_dycore /= -1) then + call mark_as_initialized("total_energy_formula_for_dycore") + endif + end subroutine end module dyn_grid diff --git a/src/physics/utils/phys_comp.F90 b/src/physics/utils/phys_comp.F90 index abe0428a..59ec39ab 100644 --- a/src/physics/utils/phys_comp.F90 +++ b/src/physics/utils/phys_comp.F90 @@ -134,6 +134,7 @@ subroutine phys_init() use physics_grid, only: columns_on_task use vert_coord, only: pver, pverp use cam_thermo, only: cam_thermo_init + use cam_thermo_formula, only: cam_thermo_formula_init use physics_types, only: allocate_physics_types_fields use cam_ccpp_cap, only: cam_ccpp_physics_initialize use cam_ccpp_cap, only: ccpp_physics_suite_part_list @@ -142,6 +143,7 @@ subroutine phys_init() integer :: i_group call cam_thermo_init(columns_on_task, pver, pverp) + call cam_thermo_formula_init() call allocate_physics_types_fields(columns_on_task, pver, pverp, & set_init_val_in=.true., reallocate_in=.false.) diff --git a/tools/stdnames_to_inputnames_dictionary.xml b/tools/stdnames_to_inputnames_dictionary.xml index 0ac72a21..78dc69f2 100644 --- a/tools/stdnames_to_inputnames_dictionary.xml +++ b/tools/stdnames_to_inputnames_dictionary.xml @@ -196,6 +196,11 @@ state_tw_cur + + + cp_or_cv_dycore + + RHO