Skip to content

Commit

Permalink
Updates from ESCOMP cam6_3_158 to cam6_4_041
Browse files Browse the repository at this point in the history
  • Loading branch information
Steve Goldhaber committed Nov 4, 2024
1 parent 8dba2ec commit a10f949
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 43 deletions.
12 changes: 9 additions & 3 deletions src_cam/chemistry.F90
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,8 @@ subroutine chem_readnl(nlfile)
tracer_srcs_fixed_ymd_out = tracer_srcs_fixed_ymd, &
tracer_srcs_fixed_tod_out = tracer_srcs_fixed_tod )

drydep_srf_file = ' '

if (masterproc) then
unitn = getunit()
open( unitn, file=trim(nlfile), status='old' )
Expand Down Expand Up @@ -1145,7 +1147,7 @@ subroutine chem_timestep_tend( state, ptend, cam_in, cam_out, dt, pbuf, fh2o)
use mo_gas_phase_chemdr, only : gas_phase_chemdr
use camsrfexch, only : cam_in_t, cam_out_t
use perf_mod, only : t_startf, t_stopf
use tropopause, only : tropopause_findChemTrop, tropopause_find
use tropopause, only : tropopause_findChemTrop, tropopause_find_cam
use mo_drydep, only : drydep_update
use mo_neu_wetdep, only : neu_wetdep_tend
use aerodep_flx, only : aerodep_flx_prescribed
Expand Down Expand Up @@ -1223,11 +1225,15 @@ subroutine chem_timestep_tend( state, ptend, cam_in, cam_out, dt, pbuf, fh2o)
!-----------------------------------------------------------------------
! get tropopause level
!-----------------------------------------------------------------------
!REMOVECAM - no longer need this when CAM is retired and pcols no longer exists
tropLev(:) = 0
tropLevChem(:) = 0
!REMOVECAM_END
if (.not.chem_use_chemtrop) then
call tropopause_find(state,tropLev)
call tropopause_find_cam(state,tropLev)
tropLevChem=tropLev
else
call tropopause_find(state,tropLev)
call tropopause_find_cam(state,tropLev)
call tropopause_findChemTrop(state, tropLevChem)
endif

Expand Down
55 changes: 36 additions & 19 deletions src_cam/physpkg.F90
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ module physpkg
use camsrfexch, only: cam_export

use modal_aero_calcsize, only: modal_aero_calcsize_init, modal_aero_calcsize_diag, modal_aero_calcsize_reg
use modal_aero_calcsize, only: modal_aero_calcsize_sub
use modal_aero_wateruptake, only: modal_aero_wateruptake_init, modal_aero_wateruptake_dr, modal_aero_wateruptake_reg

implicit none
Expand Down Expand Up @@ -93,6 +94,7 @@ module physpkg
integer :: dqcore_idx = 0 ! dqcore index in physics buffer
integer :: cmfmczm_idx = 0 ! Zhang-McFarlane convective mass fluxes
integer :: rliqbc_idx = 0 ! tphysbc reserve liquid
integer :: psl_idx = 0
!=======================================================================
contains
!=======================================================================
Expand Down Expand Up @@ -768,7 +770,7 @@ subroutine phys_init( phys_state, phys_tend, pbuf2d, cam_in, cam_out )
use clubb_intr, only: clubb_ini_cam
use tropopause, only: tropopause_init
use solar_data, only: solar_data_init
use dadadj_cam, only: dadadj_init
use dadadj_cam, only: dadadj_cam_init
use cam_abortutils, only: endrun
use nudging, only: Nudge_Model, nudging_init
use cam_snapshot, only: cam_snapshot_init
Expand Down Expand Up @@ -897,7 +899,7 @@ subroutine phys_init( phys_state, phys_tend, pbuf2d, cam_in, cam_out )
endif
endif

call cloud_diagnostics_init()
call cloud_diagnostics_init(pbuf2d)

call radheat_init(pref_mid)

Expand Down Expand Up @@ -932,7 +934,7 @@ subroutine phys_init( phys_state, phys_tend, pbuf2d, cam_in, cam_out )
call metdata_phys_init()
#endif
call tropopause_init()
call dadadj_init()
call dadadj_cam_init()

prec_dp_idx = pbuf_get_index('PREC_DP')
snow_dp_idx = pbuf_get_index('SNOW_DP')
Expand Down Expand Up @@ -1050,6 +1052,8 @@ subroutine phys_init( phys_state, phys_tend, pbuf2d, cam_in, cam_out )
dtcore_idx = pbuf_get_index('DTCORE')
dqcore_idx = pbuf_get_index('DQCORE')

psl_idx = pbuf_get_index('PSL')

end subroutine phys_init

!
Expand All @@ -1068,9 +1072,7 @@ subroutine phys_run1(phys_state, ztodt, phys_tend, pbuf2d, cam_in, cam_out)
use check_energy, only: check_energy_gmean
use spmd_utils, only: mpicom
use physics_buffer, only: physics_buffer_desc, pbuf_get_chunk, pbuf_allocate
#if (defined BFB_CAM_SCAM_IOP )
use cam_history, only: outfld
#endif
use cam_history, only: outfld, write_camiop
use cam_abortutils, only: endrun
#if ( defined OFFLINE_DYN )
use metdata, only: get_met_srf1
Expand Down Expand Up @@ -1138,11 +1140,11 @@ subroutine phys_run1(phys_state, ztodt, phys_tend, pbuf2d, cam_in, cam_out)
!-----------------------------------------------------------------------
!

#if (defined BFB_CAM_SCAM_IOP )
do c=begchunk, endchunk
call outfld('Tg',cam_in(c)%ts,pcols ,c )
end do
#endif
if (write_camiop) then
do c=begchunk, endchunk
call outfld('Tg',cam_in(c)%ts,pcols ,c )
end do
end if

call t_barrierf('sync_bc_physics', mpicom)
call t_startf ('bc_physics')
Expand Down Expand Up @@ -1420,6 +1422,7 @@ subroutine tphysac (ztodt, cam_in, &
use tropopause, only: tropopause_output
use cam_diagnostics, only: diag_phys_writeout, diag_conv, diag_clip_tend_writeout
use aero_model, only: aero_model_wetdep
use aero_wetdep_cam, only: wetdep_lq
use physics_buffer, only: col_type_subcol
use check_energy, only: check_energy_timestep_init
use carma_intr, only: carma_wetdep_tend, carma_timestep_tend, carma_emission_tend
Expand Down Expand Up @@ -1943,10 +1946,22 @@ subroutine tphysac (ztodt, cam_in, &
! wet scavenging but not 'convect_deep_tend2'.
! -------------------------------------------------------------------------------

call t_startf('bc_aerosols')
if (clim_modal_aero .and. .not. prog_modal_aero) then
call modal_aero_calcsize_diag(state, pbuf)
call modal_aero_wateruptake_dr(state, pbuf)
call t_startf('aerosol_wet_processes')
if (clim_modal_aero) then
if (prog_modal_aero) then
call physics_ptend_init(ptend, state%psetcols, 'aero_water_uptake', lq=wetdep_lq)
! Do calculations of mode radius and water uptake if:
! 1) modal aerosols are affecting the climate, or
! 2) prognostic modal aerosols are enabled
call modal_aero_calcsize_sub(state, ptend, ztodt, pbuf)
! for prognostic modal aerosols the transfer of mass between aitken and accumulation
! modes is done in conjunction with the dry radius calculation
call modal_aero_wateruptake_dr(state, pbuf)
call physics_update(state, ptend, ztodt, tend)
else
call modal_aero_calcsize_diag(state, pbuf)
call modal_aero_wateruptake_dr(state, pbuf)
endif
endif

if (trim(cam_take_snapshot_before) == "aero_model_wetdep") then
Expand Down Expand Up @@ -1988,7 +2003,7 @@ subroutine tphysac (ztodt, cam_in, &
! check tracer integrals
call check_tracers_chng(state, tracerint, "cmfmca", nstep, ztodt, zero_tracers)

call t_stopf('bc_aerosols')
call t_stopf('aerosol_wet_processes')

endif

Expand Down Expand Up @@ -2061,7 +2076,7 @@ subroutine tphysac (ztodt, cam_in, &
call cam_snapshot_all_outfld_tphysac(cam_snapshot_before_num, state, tend, cam_in, cam_out, pbuf,&
fh2o, surfric, obklen, flx_heat, cmfmc, dlf, det_s, det_ice, net_flx)
end if
call aoa_tracers_timestep_tend(state, ptend, cam_in%cflx, cam_in%landfrac, ztodt)
call aoa_tracers_timestep_tend(state, ptend, ztodt)
if ( (trim(cam_take_snapshot_after) == "aoa_tracers_timestep_tend") .and. &
(trim(cam_take_snapshot_before) == trim(cam_take_snapshot_after))) then
call cam_snapshot_ptend_outfld(ptend, lchnk)
Expand Down Expand Up @@ -2417,7 +2432,7 @@ subroutine tphysac (ztodt, cam_in, &
!
! Note: this operation will NOT be reverted with set_wet_to_dry after set_dry_to_wet call
!
call set_dry_to_wet(state)
call set_dry_to_wet(state, convert_cnst_type='dry')

if (trim(cam_take_snapshot_before) == "physics_dme_adjust") then
call cam_snapshot_all_outfld_tphysac(cam_snapshot_before_num, state, tend, cam_in, cam_out, pbuf,&
Expand Down Expand Up @@ -2513,7 +2528,9 @@ subroutine tphysbc (ztodt, state, &
use physics_types, only: physics_update, &
physics_state_check, &
dyn_te_idx
use cam_diagnostics, only: diag_conv_tend_ini, diag_conv, diag_export, diag_state_b4_phys_write
use physconst, only: rair, gravit
use cam_diagnostics, only: diag_conv_tend_ini, diag_export, diag_state_b4_phys_write
use cam_diagnostic_utils, only: cpslec
use cam_history, only: outfld
use constituents, only: qmin
use air_composition, only: thermodynamic_active_species_liq_num,thermodynamic_active_species_liq_idx
Expand Down
4 changes: 2 additions & 2 deletions src_cam/prescribed_volcaero.F90
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ subroutine prescribed_volcaero_adv( state, pbuf2d)
use physics_buffer, only : physics_buffer_desc, pbuf_get_field, pbuf_get_chunk
use ppgrid, only : begchunk, endchunk, pcols, pver
use cam_history, only : outfld
use tropopause, only : tropopause_find, TROP_ALG_TWMO, TROP_ALG_CLIMATE
use tropopause, only : tropopause_find_cam, TROP_ALG_TWMO, TROP_ALG_CLIMATE

! Arguments
type(physics_state), intent(in) :: state(begchunk:endchunk)
Expand All @@ -234,7 +234,7 @@ subroutine prescribed_volcaero_adv( state, pbuf2d)

do c = begchunk,endchunk
pbuf_chnk => pbuf_get_chunk(pbuf2d, c)
call tropopause_find(state(c), tropLev, primary=TROP_ALG_TWMO, backup=TROP_ALG_CLIMATE)
call tropopause_find_cam(pstate=state(c), tropLev=tropLev, primary=TROP_ALG_TWMO, backup=TROP_ALG_CLIMATE)
ncol = state(c)%ncol
do band=1,solar_bands
write(c3,'(i3)') band
Expand Down
4 changes: 2 additions & 2 deletions src_cam/radiation.F90
Original file line number Diff line number Diff line change
Expand Up @@ -753,7 +753,7 @@ subroutine radiation_tend( &
num_rrtmg_levs

use interpolate_data, only: vertinterp
use tropopause, only: tropopause_find, TROP_ALG_HYBSTOB, TROP_ALG_CLIMATE
use tropopause, only: tropopause_find_cam, TROP_ALG_HYBSTOB, TROP_ALG_CLIMATE

use cospsimulator_intr, only: docosp, cospsimulator_intr_run, cosp_nradsteps
! OSLO_AERO begin
Expand Down Expand Up @@ -1011,7 +1011,7 @@ subroutine radiation_tend( &

! Find tropopause height if needed for diagnostic output
if (hist_fld_active('FSNR') .or. hist_fld_active('FLNR')) then
call tropopause_find(state, troplev, tropP=p_trop, primary=TROP_ALG_HYBSTOB, backup=TROP_ALG_CLIMATE)
call tropopause_find_cam(state, troplev, tropP=p_trop, primary=TROP_ALG_HYBSTOB, backup=TROP_ALG_CLIMATE)
endif

! Get time of next radiation calculation - albedos will need to be
Expand Down
24 changes: 7 additions & 17 deletions src_cam/vertical_diffusion.F90
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ module vertical_diffusion
type(vdiff_selector) :: fieldlist_molec ! Logical switches for molecular diffusion
integer :: tke_idx, kvh_idx, kvm_idx ! TKE and eddy diffusivity indices for fields in the physics buffer
integer :: kvt_idx ! Index for kinematic molecular conductivity
integer :: turbtype_idx, smaw_idx ! Turbulence type and instability functions
integer :: tauresx_idx, tauresy_idx ! Redisual stress for implicit surface stress

character(len=fieldname_len) :: vdiffnam(pcnst) ! Names of vertical diffusion tendencies
Expand Down Expand Up @@ -232,8 +231,6 @@ subroutine vd_register()
call pbuf_add_field('kvm', 'global', dtype_r8, (/pcols, pverp/), kvm_idx )
call pbuf_add_field('pblh', 'global', dtype_r8, (/pcols/), pblh_idx)
call pbuf_add_field('tke', 'global', dtype_r8, (/pcols, pverp/), tke_idx)
call pbuf_add_field('turbtype', 'global', dtype_i4, (/pcols, pverp/), turbtype_idx)
call pbuf_add_field('smaw', 'global', dtype_r8, (/pcols, pverp/), smaw_idx)

call pbuf_add_field('tauresx', 'global', dtype_r8, (/pcols/), tauresx_idx)
call pbuf_add_field('tauresy', 'global', dtype_r8, (/pcols/), tauresy_idx)
Expand Down Expand Up @@ -432,7 +429,7 @@ subroutine vertical_diffusion_init(pbuf2d)
do_pbl_diags = .true.
call init_hb_diff(gravit, cpair, ntop_eddy, nbot_eddy, pref_mid, karman, eddy_scheme)
!
! run HB scheme where CLUBB is not active when running cam_dev or cam6 physics
! run HB scheme where CLUBB is not active when running cam7 or cam6 physics
! else init_hb_diff is called just for diagnostic purposes
!
if (do_hb_above_clubb) then
Expand Down Expand Up @@ -652,8 +649,6 @@ subroutine vertical_diffusion_init(pbuf2d)
! Initialization of some pbuf fields
if (is_first_step()) then
! Initialization of pbuf fields tke, kvh, kvm are done in phys_inidat
call pbuf_set_field(pbuf2d, turbtype_idx, 0 )
call pbuf_set_field(pbuf2d, smaw_idx, 0.0_r8)
call pbuf_set_field(pbuf2d, tauresx_idx, 0.0_r8)
call pbuf_set_field(pbuf2d, tauresy_idx, 0.0_r8)
if (trim(shallow_scheme) == 'UNICON') then
Expand Down Expand Up @@ -760,9 +755,6 @@ subroutine vertical_diffusion_tend( &

real(r8) :: dtk(pcols,pver) ! T tendency from KE dissipation
real(r8), pointer :: tke(:,:) ! Turbulent kinetic energy [ m2/s2 ]
integer(i4),pointer :: turbtype(:,:) ! Turbulent interface types [ no unit ]
real(r8), pointer :: smaw(:,:) ! Normalized Galperin instability function
! ( 0<= <=4.964 and 1 at neutral )

real(r8), pointer :: qtl_flx(:,:) ! overbar(w'qtl') where qtl = qv + ql
real(r8), pointer :: qti_flx(:,:) ! overbar(w'qti') where qti = qv + qi
Expand Down Expand Up @@ -898,7 +890,7 @@ subroutine vertical_diffusion_tend( &
! ----------------------- !

! Assume 'wet' mixing ratios in diffusion code.
call set_dry_to_wet(state)
call set_dry_to_wet(state, convert_cnst_type='dry')

rztodt = 1._r8 / ztodt
lchnk = state%lchnk
Expand All @@ -909,7 +901,6 @@ subroutine vertical_diffusion_tend( &
call pbuf_get_field(pbuf, tpert_idx, tpert)
call pbuf_get_field(pbuf, qpert_idx, qpert)
call pbuf_get_field(pbuf, pblh_idx, pblh)
call pbuf_get_field(pbuf, turbtype_idx, turbtype)

! Interpolate temperature to interfaces.
do k = 2, pver
Expand Down Expand Up @@ -1002,7 +993,6 @@ subroutine vertical_diffusion_tend( &
!----------------------------------------------------------------------- !
call pbuf_get_field(pbuf, kvm_idx, kvm_in)
call pbuf_get_field(pbuf, kvh_idx, kvh_in)
call pbuf_get_field(pbuf, smaw_idx, smaw)
call pbuf_get_field(pbuf, tke_idx, tke)

! Get potential temperature.
Expand All @@ -1015,7 +1005,7 @@ subroutine vertical_diffusion_tend( &
ztodt, p, tint, rhoi, cldn, wstarent, &
kvm_in, kvh_in, ksrftms, dragblj, tauresx, tauresy, &
rrho, ustar, pblh, kvm, kvh, kvq, cgh, cgs, tpert, qpert, &
tke, sprod, sfi, turbtype, smaw)
tke, sprod, sfi)

! The diag_TKE scheme does not calculate the Monin-Obukhov length, which is used in dry deposition calculations.
! Use the routines from pbl_utils to accomplish this. Assumes ustar and rrho have been set.
Expand Down Expand Up @@ -1044,7 +1034,7 @@ subroutine vertical_diffusion_tend( &

case ( 'CLUBB_SGS' )
!
! run HB scheme where CLUBB is not active when running cam_dev
! run HB scheme where CLUBB is not active when running cam7
!
if (do_hb_above_clubb) then
call compute_hb_free_atm_diff( ncol , &
Expand Down Expand Up @@ -1181,7 +1171,7 @@ subroutine vertical_diffusion_tend( &
tauy = 0._r8
shflux = 0._r8
cflux(:,1) = 0._r8
if (cam_physpkg_is("cam_dev")) then
if (cam_physpkg_is("cam7")) then
! surface fluxes applied in clubb emissions module
cflux(:,2:) = 0._r8
else
Expand Down Expand Up @@ -1363,7 +1353,7 @@ subroutine vertical_diffusion_tend( &
endif
end do
! convert wet mmr back to dry before conservation check
call set_wet_to_dry(state)
call set_wet_to_dry(state, convert_cnst_type='dry')

if (.not. do_pbl_diags) then
slten(:ncol,:) = ( sl(:ncol,:) - sl_prePBL(:ncol,:) ) * rztodt
Expand Down Expand Up @@ -1533,7 +1523,7 @@ subroutine vertical_diffusion_tend( &
call outfld( 'KVT' , kvt, pcols, lchnk )
call outfld( 'KVM' , kvm, pcols, lchnk )
call outfld( 'CGS' , cgs, pcols, lchnk )
dtk(:ncol,:) = dtk(:ncol,:) / cpair ! Normalize heating for history
dtk(:ncol,:) = dtk(:ncol,:) / cpair / ztodt ! Normalize heating for history
call outfld( 'DTVKE' , dtk, pcols, lchnk )
dtk(:ncol,:) = ptend%s(:ncol,:) / cpair ! Normalize heating for history using dtk
call outfld( 'DTV' , dtk, pcols, lchnk )
Expand Down

0 comments on commit a10f949

Please sign in to comment.