Skip to content

Commit

Permalink
Read cp_or_cv_dycore and identify dycore information from CAM snapshot
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmielin committed Oct 25, 2024
1 parent 8fca3a4 commit 38fdbb2
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 6 deletions.
13 changes: 13 additions & 0 deletions src/data/cam_thermo_formula.F90
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions src/data/registry.xml
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,7 @@
allocatable="allocatable">
<long_name>Enthalpy or internal energy scaling factor for energy consistency</long_name>
<dimensions>horizontal_dimension vertical_layer_dimension</dimensions>
<ic_file_input_names>cp_or_cv_dycore</ic_file_input_names>
</variable>
<!-- Constituent Variables -->
<!-- These are only used to set possible IC file input names, as the constituents object handles allocation. -->
Expand Down
16 changes: 10 additions & 6 deletions src/dynamics/none/dyn_grid.F90
Original file line number Diff line number Diff line change
Expand Up @@ -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 <file> and set the energy formulation
! (also called vc_dycore in CAM)
Expand All @@ -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'

Expand All @@ -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.
Expand All @@ -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
2 changes: 2 additions & 0 deletions src/physics/utils/phys_comp.F90
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.)
Expand Down
5 changes: 5 additions & 0 deletions tools/stdnames_to_inputnames_dictionary.xml
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,11 @@
<ic_file_input_name>state_tw_cur</ic_file_input_name>
</ic_file_input_names>
</entry>
<entry stdname="specific_heat_for_air_used_in_dycore">
<ic_file_input_names>
<ic_file_input_name>cp_or_cv_dycore</ic_file_input_name>
</ic_file_input_names>
</entry>
<entry stdname="density_of_dry_air_at_stp">
<ic_file_input_names>
<ic_file_input_name>RHO</ic_file_input_name>
Expand Down

0 comments on commit 38fdbb2

Please sign in to comment.