Skip to content

Commit 33ce70c

Browse files
authored
Fix access violation crash (#2137)
TYPE: bug fix KEYWORDS: crash, access violation error SOURCE: Charlie Li, software developer from lakes environmental, Canada DESCRIPTION OF CHANGES: Problem: WRF crashed for access violation frequently, due to the change made in PR #1991 when namelist.input has sf_urban_physics = 0 and bl_pbl_physics = 1. Because those arrays from urban models are always available, but their memories are not available if the urban option is not turned on. This causes the access violation in module_bl_ysu.F Solution: The fix is actually using v4.5 logic to check on the flag 'flag_bep' before using the arrays. LIST OF MODIFIED FILES: phys/module_bl_ysu.F TESTS CONDUCTED: The Jenkins tests are all passing. RELEASE NOTE: This PR fixes a access violation error when a PGI compiler is used with urban variables in module_bl_ysu.F when urban option is turned off and the memories of those arrays are not available.
1 parent 94aa27a commit 33ce70c

File tree

1 file changed

+27
-20
lines changed

1 file changed

+27
-20
lines changed

phys/module_bl_ysu.F

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -353,27 +353,34 @@ subroutine ysu(u3d,v3d,t3d,qv3d,qc3d,qi3d,p3d,p3di,pi3d, &
353353
present(b_v_bep) .and. present(b_t_bep) .and. present(b_q_bep) .and. &
354354
present(b_e_bep) .and. present(dlg_bep) .and. present(dl_u_bep) .and. &
355355
present(sf_bep) .and. present(vl_bep) .and. present(frc_urb2d)) then
356-
do k = kts, kte
357-
do i = its,ite
358-
a_u_hv(i,k) = a_u_bep(i,k,j)
359-
a_v_hv(i,k) = a_v_bep(i,k,j)
360-
a_t_hv(i,k) = a_t_bep(i,k,j)
361-
a_q_hv(i,k) = a_q_bep(i,k,j)
362-
a_e_hv(i,k) = a_e_bep(i,k,j)
363-
b_u_hv(i,k) = b_u_bep(i,k,j)
364-
b_v_hv(i,k) = b_v_bep(i,k,j)
365-
b_t_hv(i,k) = b_t_bep(i,k,j)
366-
b_q_hv(i,k) = b_q_bep(i,k,j)
367-
b_e_hv(i,k) = b_e_bep(i,k,j)
368-
dlg_hv(i,k) = dlg_bep(i,k,j)
369-
dl_u_hv(i,k) = dl_u_bep(i,k,j)
370-
vlk_hv(i,k) = vl_bep(i,k,j)
371-
sfk_hv(i,k) = sf_bep(i,k,j)
356+
357+
! following v4.5 logic to fix access violation
358+
if(flag_bep) then
359+
360+
do k = kts, kte
361+
do i = its,ite
362+
a_u_hv(i,k) = a_u_bep(i,k,j)
363+
a_v_hv(i,k) = a_v_bep(i,k,j)
364+
a_t_hv(i,k) = a_t_bep(i,k,j)
365+
a_q_hv(i,k) = a_q_bep(i,k,j)
366+
a_e_hv(i,k) = a_e_bep(i,k,j)
367+
b_u_hv(i,k) = b_u_bep(i,k,j)
368+
b_v_hv(i,k) = b_v_bep(i,k,j)
369+
b_t_hv(i,k) = b_t_bep(i,k,j)
370+
b_q_hv(i,k) = b_q_bep(i,k,j)
371+
b_e_hv(i,k) = b_e_bep(i,k,j)
372+
dlg_hv(i,k) = dlg_bep(i,k,j)
373+
dl_u_hv(i,k) = dl_u_bep(i,k,j)
374+
vlk_hv(i,k) = vl_bep(i,k,j)
375+
sfk_hv(i,k) = sf_bep(i,k,j)
376+
enddo
372377
enddo
373-
enddo
374-
do i = its, ite
375-
frcurb_hv(i) = frc_urb2d(i,j)
376-
enddo
378+
do i = its, ite
379+
frcurb_hv(i) = frc_urb2d(i,j)
380+
enddo
381+
382+
endif
383+
377384
endif
378385

379386
do i = its, ite

0 commit comments

Comments
 (0)