Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 77 additions & 0 deletions doc/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,6 +1,83 @@

===============================================================

Tag name: cam6_4_2xx
Originator(s): g8j39
Date: <merge date>
One-line Summary: Skip inactive SE tracer advection and PDC tendency diagnostic buffers
Github PR URL: <fill at merge>

Purpose of changes (include the issue number and title text for each relevant GitHub issue):
- Fixes #1761: SE: compute_adv_tends_xyz and applyCAMforcing allocate and copy 141-200 tracer arrays when tendency diagnostics are inactive

Describe any changes made to build system:
None.

Describe any changes made to the namelist:
None.

List any changes to the defaults for the boundary datasets:
None.

Describe any substantial timing or memory changes:
When TA<constituent> and *_PDC history fields are inactive on cesm3_0_beta10 (gfortran 13.4.0 -O2): comp_adv_tends1+2 drops from 4.98 s to 0.0009 s and applyCAMforc drops from 3.55 s to 2.28 s on 3-hour 32-task B1850CM (measured alongside two other SE changes, skipping about 150 MiB/rank of transient ftmp_fvm allocation; 2-pair whole-run coupled delta sits under 1%, near spread). On single-column ne3 runs, stock comp_adv_tends1+2 drops from 11.0 s (of 121.0 s TOT) on 695h FSCAMARM97 and 12.5 s (of 75.5 s TOT) on 120h FCSCAM to 0.03-0.04 s.

Code reviewed by:

List all files eliminated:
None.

List all files added and what they do:
None.

List all existing files that have been modified, and describe the changes:
M src/dynamics/se/advect_tend.F90
- Return early in compute_adv_tends_xyz when no tottnam history field is active.
M src/dynamics/se/dycore/prim_advance_mod.F90
- Make ftmp allocatable with checked allocate stat alongside ftmp_fvm, and guard ftmp/ftmp_fvm allocation, clipping-loss diagnostic stores, and output_qdp_var_dynamics in applyCAMforcing on WV_PDC, WI_PDC, WL_PDC, or TT_PDC being active.

If there were any failures reported from running test_driver.sh on any test
platform, and checkin with these failures has been OK'd by the gatekeeper,
then copy the lines from the td.*.status files for the failed tests to the
appropriate machine below. All failed tests must be justified.

derecho/intel/aux_cam:

derecho/nvhpc/aux_cam:

izumi/nag/aux_cam:

izumi/gnu/aux_cam:

CAM tag used for the baseline comparison tests if different than previous
tag:

Summarize any changes to answers, i.e.,
- what code configurations: none, bit-for-bit unchanged
- what platforms/compilers: N/A
- nature of change (roundoff; larger than roundoff but same climate; new
climate): none (bit-for-bit)

If bitwise differences were observed, how did you show they were no worse
than roundoff?
N/A

If this tag changes climate describe the run(s) done to evaluate the new
climate in enough detail that it(they) could be reproduced, i.e.,
- source tag (all code used must be in the repository): N/A
- platform/compilers: N/A
- configure commandline: N/A
- build-namelist command (or complete namelist): N/A
- MSS location of output: N/A

MSS location of control simulations used to validate new climate:
N/A

URL for AMWG diagnostics output used to validate new climate:
N/A

===============================================================

Tag name: cam6_4_223
Originator(s): cacraigucar, peverwhee, billsacks
Date: Nov 18, 2026
Expand Down
14 changes: 12 additions & 2 deletions src/dynamics/se/advect_tend.F90
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ module advect_tend
! - second call computes and outputs the tendencies
!----------------------------------------------------------------------
subroutine compute_adv_tends_xyz(elem,fvm,nets,nete,qn0,n0)
use cam_history, only: outfld
use cam_history, only: outfld, hist_fld_active
use time_manager, only: get_step_size
use constituents, only: tottnam,pcnst
use dimensions_mod, only: nc,np,nlev,use_cslam
Expand All @@ -41,9 +41,19 @@ subroutine compute_adv_tends_xyz(elem,fvm,nets,nete,qn0,n0)
integer, intent(in) :: nets,nete,qn0,n0
real(r8) :: dt
integer :: i,j,ic,nx,ie
logical :: init
logical :: init, any_active
real(r8), allocatable, dimension(:,:) :: ftmp

any_active = .false.
do ic = 1, pcnst
if (hist_fld_active(tottnam(ic))) then
any_active = .true.
exit
end if
end do
! Nothing to do if no total advective tendency field is on a history tape
if (.not. any_active) return

if (use_cslam) then
nx=nc
else
Expand Down
44 changes: 31 additions & 13 deletions src/dynamics/se/dycore/prim_advance_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -274,21 +274,34 @@ subroutine applyCAMforcing(elem,fvm,np1,np1_qdp,dt_dribble,dt_phys,nets,nete,nsu
use fvm_control_volume_mod, only: fvm_struct
use air_composition, only: thermodynamic_active_species_idx_dycore
use cam_thermo, only: get_dp, MASS_MIXING_RATIO
use cam_history, only: hist_fld_active
type (element_t) , intent(inout) :: elem(:)
type(fvm_struct) , intent(inout) :: fvm(:)
real (kind=r8), intent(in) :: dt_dribble, dt_phys
integer, intent(in) :: np1,nets,nete,np1_qdp,nsubstep

! local
integer :: i,j,k,ie,q
integer :: i,j,k,ie,q,ierr
real (kind=r8) :: v1,dt_local, dt_local_tracer,tmp
real (kind=r8) :: dt_local_tracer_fvm
real (kind=r8) :: ftmp(np,np,nlev,qsize,nets:nete) !diagnostics
real (kind=r8), allocatable :: ftmp(:,:,:,:,:) !diagnostics
real (kind=r8) :: pdel(np,np,nlev)
real (kind=r8), allocatable :: ftmp_fvm(:,:,:,:,:) !diagnostics
logical :: pdc_active

call t_startf('applyCAMforc')
if (use_cslam) allocate(ftmp_fvm(nc,nc,nlev,ntrac,nets:nete))
! Must match the fields written by output_qdp_var_dynamics(...,'PDC')
pdc_active = hist_fld_active('WV_PDC') .or. hist_fld_active('WI_PDC') .or. &
hist_fld_active('WL_PDC') .or. hist_fld_active('TT_PDC')
if (pdc_active) then
if (use_cslam) then
allocate(ftmp_fvm(nc,nc,nlev,ntrac,nets:nete), stat=ierr)
if (ierr /= 0) call endrun('applyCAMforcing: failed to allocate ftmp_fvm')
else
allocate(ftmp(np,np,nlev,qsize,nets:nete), stat=ierr)
if (ierr /= 0) call endrun('applyCAMforcing: failed to allocate ftmp')
end if
end if

if (ftype==0) then
!
Expand Down Expand Up @@ -360,14 +373,16 @@ subroutine applyCAMforcing(elem,fvm,np1,np1_qdp,dt_dribble,dt_phys,nets,nete,nsu
endif
endif
elem(ie)%state%Qdp(i,j,k,q,np1_qdp) = elem(ie)%state%Qdp(i,j,k,q,np1_qdp)+v1
ftmp(i,j,k,q,ie) = dt_local_tracer*&
elem(ie)%derived%FQ(i,j,k,q)-v1 !Only used for diagnostics!
if (pdc_active .and. .not. use_cslam) then
ftmp(i,j,k,q,ie) = dt_local_tracer*&
elem(ie)%derived%FQ(i,j,k,q)-v1 !Only used for diagnostics!
end if
enddo
enddo
enddo
enddo
else
ftmp(:,:,:,:,ie) = 0.0_r8
if (pdc_active .and. .not. use_cslam) ftmp(:,:,:,:,ie) = 0.0_r8
end if
if (use_cslam.and.dt_local_tracer_fvm>0) then
!
Expand All @@ -387,13 +402,13 @@ subroutine applyCAMforcing(elem,fvm,np1,np1_qdp,dt_dribble,dt_phys,nets,nete,nsu
end if
end if
fvm(ie)%c(i,j,k,q) = fvm(ie)%c(i,j,k,q)+ v1
ftmp_fvm(i,j,k,q,ie) = (tmp-v1)*fvm(ie)%dp_fvm(i,j,k) !Only used for diagnostics!
if (pdc_active) ftmp_fvm(i,j,k,q,ie) = (tmp-v1)*fvm(ie)%dp_fvm(i,j,k) !Only used for diagnostics!
end do
end do
end do
end do
else
if (use_cslam) ftmp_fvm(:,:,:,:,ie) = 0.0_r8
if (use_cslam .and. pdc_active) ftmp_fvm(:,:,:,:,ie) = 0.0_r8
end if

if (ftype_conserve==1.and..not.use_cslam) then
Expand Down Expand Up @@ -422,13 +437,16 @@ subroutine applyCAMforcing(elem,fvm,np1,np1_qdp,dt_dribble,dt_phys,nets,nete,nsu
dt_local*elem(ie)%derived%FM(:,:,:,:)
end if
end do
if (use_cslam) then
call output_qdp_var_dynamics(ftmp_fvm(:,:,:,:,:),nc,ntrac,nets,nete,'PDC')
else
call output_qdp_var_dynamics(ftmp(:,:,:,:,:),np,qsize,nets,nete,'PDC')
if (pdc_active) then
if (use_cslam) then
call output_qdp_var_dynamics(ftmp_fvm(:,:,:,:,:),nc,ntrac,nets,nete,'PDC')
deallocate(ftmp_fvm)
else
call output_qdp_var_dynamics(ftmp(:,:,:,:,:),np,qsize,nets,nete,'PDC')
deallocate(ftmp)
end if
end if
if (ftype==1.and.nsubstep==1) call tot_energy_dyn(elem,fvm,nets,nete,np1,np1_qdp,'p2d')
if (use_cslam) deallocate(ftmp_fvm)
call t_stopf('applyCAMforc')
end subroutine applyCAMforcing

Expand Down