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
9 changes: 8 additions & 1 deletion src/control/cam_snapshot_common.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1235,7 +1235,14 @@ subroutine cam_pbuf_snapshot_all_outfld(lchnk, file_num, pbuf)

! Retrieve the pbuf data. Special handling for certain
! integer-type fields.
if( trim(pbuf_snapshot(i)%ddt_string) == 'clubbtop') then
! This will allow data written out to not be mangled,
! and also allow writing out snapshots with debug on in GNU compiler.
if( trim(pbuf_snapshot(i)%ddt_string) == 'clubbtop' .or. &
trim(pbuf_snapshot(i)%ddt_string) == 'ZM_JT' .or. &
trim(pbuf_snapshot(i)%ddt_string) == 'ZM_MAXG' .or. &
trim(pbuf_snapshot(i)%ddt_string) == 'ZM_IDEEP' .or. &
trim(pbuf_snapshot(i)%ddt_string) == 'NMXRGN' .or. &
trim(pbuf_snapshot(i)%ddt_string) == 'ACNUNM') then
call pbuf_get_field(pbuf, pbuf_idx, tmpptr2d_int)
! copy into real
allocate(tmpptr2d(size(tmpptr2d_int, 1), size(tmpptr2d_int, 2)))
Expand Down
23 changes: 19 additions & 4 deletions src/physics/cam/physpkg.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1531,6 +1531,12 @@ subroutine tphysac (ztodt, cam_in, &
ifld = pbuf_get_index('AST')
call pbuf_get_field(pbuf, ifld, ast, start=(/1,1,itim_old/), kount=(/pcols,pver,1/) )

! zero out local variables that may be written to snapshot for safety.
fh2o(:) = 0._r8 ! used in chem_timestep_tend.
surfric(:) = 0._r8 ! out from vertical_diffusion_tend.
obklen(:) = 0._r8 ! out from vertical_diffusion_tend.
flx_heat(:) = 0._r8 ! first out from gw_drag_cam.

!
! accumulate fluxes into net flux array for spectral dycores
! jrm Include latent heat of fusion for snow
Expand Down Expand Up @@ -2358,6 +2364,19 @@ subroutine tphysbc (ztodt, state, &

call t_stopf('bc_init')

! Zero-initialize subroutine-level variables for snapshot
cmfmc(:,:) = 0._r8
cmfcme(:,:) = 0._r8
zdu(:,:) = 0._r8
rliq(:) = 0._r8
rice(:) = 0._r8
dlf(:,:) = 0._r8
dlf2(:,:) = 0._r8
rliq2(:) = 0._r8
det_s(:) = 0._r8
det_ice(:) = 0._r8
net_flx(:) = 0._r8

!===================================================
! Global mean total energy fixer
!===================================================
Expand Down Expand Up @@ -2515,10 +2534,6 @@ subroutine tphysbc (ztodt, state, &
dlf(:,:) = 0._r8
end if

! Zero-initialize subroutine-level variables for snapshot
dlf2(:,:) = 0._r8
rliq2(:) = 0._r8

if (trim(cam_take_snapshot_before) == "convect_shallow_tend") then
call cam_snapshot_all_outfld_tphysbc(cam_snapshot_before_num, state, tend, cam_in, cam_out, pbuf, &
flx_heat, cmfmc, cmfcme, zdu, rliq, rice, dlf, dlf2, rliq2, det_s, det_ice, net_flx)
Expand Down
20 changes: 20 additions & 0 deletions src/physics/cam7/physpkg.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1623,6 +1623,15 @@ subroutine tphysac (ztodt, cam_in, &
call pbuf_get_field(pbuf, rliqbc_idx, rliqbc)
rliq(:ncol) = rliqbc(:ncol)

! zero out local variables that may be written to snapshot for safety.
fh2o(:) = 0._r8 ! used in chem_timestep_tend.
surfric(:) = 0._r8 ! out from vertical_diffusion_tend.
obklen(:) = 0._r8 ! out from vertical_diffusion_tend.
flx_heat(:) = 0._r8 ! first out from gw_drag_cam.
det_s(:) = 0._r8 ! out from clubb_tend_cam.
det_ice(:) = 0._r8 ! out from clubb_tend_cam.
net_flx(:) = 0._r8 ! out from radiation_tend.

!
! accumulate fluxes into net flux array for spectral dycores
! jrm Include latent heat of fusion for snow
Expand Down Expand Up @@ -2788,6 +2797,17 @@ subroutine tphysbc (ztodt, state, &

call t_stopf('bc_init')

! Zero-initialize subroutine-level variables for snapshot
cmfmc(:,:) = 0._r8
cmfcme(:,:) = 0._r8
zdu(:,:) = 0._r8
rliq(:) = 0._r8
rice(:) = 0._r8
dlf(:,:) = 0._r8
dlf2(:,:) = 0._r8
rliq2(:) = 0._r8
net_flx(:) = 0._r8

!===================================================
! Global mean total energy fixer
!===================================================
Expand Down
Loading