Skip to content

Commit

Permalink
Pass cp_or_cv_dycore explicitly to cam_thermo_water_update in prepara…
Browse files Browse the repository at this point in the history
…tion for CCPP scheme
  • Loading branch information
jimmielin committed Dec 12, 2024
1 parent 63dff8f commit 55ea5b3
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 20 deletions.
16 changes: 7 additions & 9 deletions src/data/air_composition.F90
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ module air_composition
use runtime_obj, only: unset_real, unset_int
use phys_vars_init_check, only: std_name_len
use physics_types, only: cpairv, rairv, cappav, mbarv, zvirv
use physics_types, only: cp_or_cv_dycore

implicit none
private
Expand Down Expand Up @@ -540,22 +539,22 @@ end subroutine dry_air_composition_update
!===========================================================================
!---------------------------------------------------------------------------
! water_composition_update: Update generalized cp or cv depending on dycore
! (enthalpy for pressure-based dynamical cores and internal energy for z-based dynamical cores)
!---------------------------------------------------------------------------
!===========================================================================
subroutine water_composition_update(mmr, ncol, energy_formula, to_dry_factor)
subroutine water_composition_update(mmr, ncol, energy_formula, cp_or_cv_dycore, to_dry_factor)
use cam_thermo_formula, only: ENERGY_FORMULA_DYCORE_FV, ENERGY_FORMULA_DYCORE_SE, ENERGY_FORMULA_DYCORE_MPAS
use string_utils, only: stringify

real(kind_phys), intent(in) :: mmr(:,:,:) ! constituents array
integer, intent(in) :: ncol ! number of columns
integer, intent(in) :: energy_formula ! energy formula for dynamical core
real(kind_phys), optional, intent(in) :: to_dry_factor(:,:)
real(kind_phys), intent(in) :: mmr(:,:,:) ! constituents array
integer, intent(in) :: ncol ! number of columns
integer, intent(in) :: energy_formula ! energy formula for dynamical core
real(kind_phys), intent(out) :: cp_or_cv_dycore(:,:) ! enthalpy or heat capacity, dycore dependent [J K-1 kg-1]
real(kind_phys), optional, intent(in) :: to_dry_factor(:,:)

character(len=*), parameter :: subname = 'water_composition_update'

! update enthalpy or internal energy scaling factor for energy consistency with CAM physics
! cp_or_cv_dycore is now a registry variable (physics_types) in CAM-SIMA instead of in-module

if (energy_formula == ENERGY_FORMULA_DYCORE_FV) then
! FV: moist pressure vertical coordinate does not need update.
else if (energy_formula == ENERGY_FORMULA_DYCORE_SE) then
Expand All @@ -576,7 +575,6 @@ subroutine water_composition_update(mmr, ncol, energy_formula, to_dry_factor)
else
call endrun(subname//': dycore energy formula (value = '//stringify((/energy_formula/))//') not supported')
end if

end subroutine water_composition_update

!===========================================================================
Expand Down
15 changes: 8 additions & 7 deletions src/data/cam_thermo.F90
Original file line number Diff line number Diff line change
Expand Up @@ -267,18 +267,19 @@ end subroutine cam_thermo_dry_air_update
!
!***************************************************************************
!
subroutine cam_thermo_water_update(mmr, ncol, pver, energy_formula, to_dry_factor)
subroutine cam_thermo_water_update(mmr, ncol, pver, energy_formula, cp_or_cv_dycore, to_dry_factor)
use air_composition, only: water_composition_update
use string_utils, only: stringify
!-----------------------------------------------------------------------
! Update the physics "constants" that vary
!-------------------------------------------------------------------------

real(kind_phys), intent(in) :: mmr(:,:,:) ! constituents array (mmr = dry mixing ratio, if not use to_dry_factor to convert)
integer, intent(in) :: ncol ! number of columns
integer, intent(in) :: pver ! number of vertical levels
integer, intent(in) :: energy_formula
real(kind_phys), optional, intent(in) :: to_dry_factor(:,:)
real(kind_phys), intent(in) :: mmr(:,:,:) ! constituents array (mmr = dry mixing ratio, if not use to_dry_factor to convert)
integer, intent(in) :: ncol ! number of columns
integer, intent(in) :: pver ! number of vertical levels
integer, intent(in) :: energy_formula
real(kind_phys), intent(out) :: cp_or_cv_dycore(:,:) ! enthalpy or heat capacity, dycore dependent [J K-1 kg-1]
real(kind_phys), optional, intent(in) :: to_dry_factor(:,:)

character(len=*), parameter :: subname = 'cam_thermo_water_update: '

Expand All @@ -291,7 +292,7 @@ subroutine cam_thermo_water_update(mmr, ncol, pver, energy_formula, to_dry_facto
end if
end if

call water_composition_update(mmr, ncol, energy_formula, to_dry_factor=to_dry_factor)
call water_composition_update(mmr, ncol, energy_formula, cp_or_cv_dycore, to_dry_factor=to_dry_factor)
end subroutine cam_thermo_water_update

!===========================================================================
Expand Down
10 changes: 6 additions & 4 deletions src/dynamics/se/dp_coupling.F90
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,7 @@ subroutine derived_phys_dry(cam_runtime_opts, phys_state, phys_tend)
use air_composition, only: thermodynamic_active_species_idx
use air_composition, only: dry_air_species_num
use physics_types, only: cpairv, rairv, zvirv, cappav
use physics_types, only: cp_or_cv_dycore
use physics_grid, only: columns_on_task
use geopotential_temp, only: geopotential_temp_run
use static_energy, only: update_dry_static_energy_run
Expand Down Expand Up @@ -804,10 +805,11 @@ subroutine derived_phys_dry(cam_runtime_opts, phys_state, phys_tend)
! (note: at this point q is dry)
!
call cam_thermo_water_update( &
mmr = const_data_ptr, & ! dry MMR
ncol = pcols, &
pver = pver, &
energy_formula = ENERGY_FORMULA_DYCORE_SE &
mmr = const_data_ptr, & ! dry MMR
ncol = pcols, &
pver = pver, &
energy_formula = ENERGY_FORMULA_DYCORE_SE, &
cp_or_cv_dycore = cp_or_cv_dycore &
)

!$omp parallel do num_threads(horz_num_threads) private (k, i)
Expand Down

0 comments on commit 55ea5b3

Please sign in to comment.