Skip to content

Commit

Permalink
Fix access violation crash (#2137)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
likeuclinux authored Feb 5, 2025
1 parent 94aa27a commit 33ce70c
Showing 1 changed file with 27 additions and 20 deletions.
47 changes: 27 additions & 20 deletions phys/module_bl_ysu.F
Original file line number Diff line number Diff line change
Expand Up @@ -353,27 +353,34 @@ subroutine ysu(u3d,v3d,t3d,qv3d,qc3d,qi3d,p3d,p3di,pi3d, &
present(b_v_bep) .and. present(b_t_bep) .and. present(b_q_bep) .and. &
present(b_e_bep) .and. present(dlg_bep) .and. present(dl_u_bep) .and. &
present(sf_bep) .and. present(vl_bep) .and. present(frc_urb2d)) then
do k = kts, kte
do i = its,ite
a_u_hv(i,k) = a_u_bep(i,k,j)
a_v_hv(i,k) = a_v_bep(i,k,j)
a_t_hv(i,k) = a_t_bep(i,k,j)
a_q_hv(i,k) = a_q_bep(i,k,j)
a_e_hv(i,k) = a_e_bep(i,k,j)
b_u_hv(i,k) = b_u_bep(i,k,j)
b_v_hv(i,k) = b_v_bep(i,k,j)
b_t_hv(i,k) = b_t_bep(i,k,j)
b_q_hv(i,k) = b_q_bep(i,k,j)
b_e_hv(i,k) = b_e_bep(i,k,j)
dlg_hv(i,k) = dlg_bep(i,k,j)
dl_u_hv(i,k) = dl_u_bep(i,k,j)
vlk_hv(i,k) = vl_bep(i,k,j)
sfk_hv(i,k) = sf_bep(i,k,j)

! following v4.5 logic to fix access violation
if(flag_bep) then

do k = kts, kte
do i = its,ite
a_u_hv(i,k) = a_u_bep(i,k,j)
a_v_hv(i,k) = a_v_bep(i,k,j)
a_t_hv(i,k) = a_t_bep(i,k,j)
a_q_hv(i,k) = a_q_bep(i,k,j)
a_e_hv(i,k) = a_e_bep(i,k,j)
b_u_hv(i,k) = b_u_bep(i,k,j)
b_v_hv(i,k) = b_v_bep(i,k,j)
b_t_hv(i,k) = b_t_bep(i,k,j)
b_q_hv(i,k) = b_q_bep(i,k,j)
b_e_hv(i,k) = b_e_bep(i,k,j)
dlg_hv(i,k) = dlg_bep(i,k,j)
dl_u_hv(i,k) = dl_u_bep(i,k,j)
vlk_hv(i,k) = vl_bep(i,k,j)
sfk_hv(i,k) = sf_bep(i,k,j)
enddo
enddo
enddo
do i = its, ite
frcurb_hv(i) = frc_urb2d(i,j)
enddo
do i = its, ite
frcurb_hv(i) = frc_urb2d(i,j)
enddo

endif

endif

do i = its, ite
Expand Down

0 comments on commit 33ce70c

Please sign in to comment.