Skip to content

Commit 04947fc

Browse files
committed
Merge branch 'jgfouca/gw_fixes' into next (PR #7429)
Fix a couple sources of uninitialized memory errors in cam/gw vdiff_lu_solver had a couple places where uninitialized memory was being used. We just need to be sure to initialize arrays when they are created and this problem goes away. gw_front::gw_cm_src was trickier, the second spread call was producing an array that had inconsistent size in dim2 (-ngwv:ngwv) compared to c and cref which are (-pgwv:pgwv). [BFB]
2 parents f28f827 + 75dd51b commit 04947fc

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

components/eam/src/physics/cam/gw/gw_common.F90

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -752,10 +752,8 @@ subroutine gwd_precalc_rhoi(ncol, ngwv, dt, tend_level, pmid, pint, t, gwut, ubm
752752

753753
! Calculate tendency on each constituent.
754754
do m = 1, size(q,3)
755-
756755
call gw_diff_tend(ncol, pver, kbotbg, ktop, q(:,:,m), dt, &
757756
decomp, qtgw(:,:,m))
758-
759757
enddo
760758

761759
! Calculate tendency from diffusing dry static energy (dttdf).

components/eam/src/physics/cam/gw/gw_front.F90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ subroutine gw_cm_src(ncol, ngwv, kbot, u, v, frontgf, &
227227

228228
! Set phase speeds as reference speeds plus the wind speed at the source
229229
! level.
230-
c = spread(cref, 1, ncol) + spread(abs(ubi(:,kbot)),2,2*ngwv+1)
230+
c = spread(cref, 1, ncol) + spread(abs(ubi(:,kbot)),2,2*pgwv+1)
231231

232232
end subroutine gw_cm_src
233233

components/eam/src/physics/cam/vdiff_lu_solver.F90

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,8 @@ subroutine vd_lu_solve(pcols, pver, ncol, &
226226
! Main Computation Begins !
227227
! ----------------------- !
228228

229+
zf = 0.0_r8
230+
229231
! Calculate zf(k). Terms zf(k) and ze(k) are required in solution of
230232
! tridiagonal matrix defined by implicit diffusion equation.
231233
! Note that only levels ntop through nbot need be solved for.
@@ -277,6 +279,12 @@ pure function lu_decomp_alloc(ncol, pver) result(new_decomp)
277279
allocate(new_decomp%dnom(ncol,pver))
278280
allocate(new_decomp%ze(ncol,pver))
279281

282+
! Initialize to zero
283+
new_decomp%ca = 0.0_r8
284+
new_decomp%cc = 0.0_r8
285+
new_decomp%dnom = 0.0_r8
286+
new_decomp%ze = 0.0_r8
287+
280288
end function lu_decomp_alloc
281289

282290
! LU decomposition deallocation.

0 commit comments

Comments
 (0)