Skip to content

Commit

Permalink
model/fv_regional_bc.F90: add comments and a sanity check for buffer …
Browse files Browse the repository at this point in the history
…sizes
  • Loading branch information
climbfuji authored and tsupinie committed Jul 20, 2020
1 parent 3110292 commit 531a0d6
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion model/fv_regional_bc.F90
Original file line number Diff line number Diff line change
Expand Up @@ -6554,6 +6554,11 @@ subroutine exch_uv(domain, bd, npz, u, v)
js=bd%js
je=bd%je

! The size of these buffers must match the number of indices
! required below to send/receive the data. In particular,
! buf1 and buf4 must be of the same size (sim. for buf2 and buf3).
! Changes to the code below should be tested with debug flags
! enabled (out-of-bounds reads/writes).
allocate(buf1(1:24*npz))
allocate(buf2(1:36*npz))
allocate(buf3(1:36*npz))
Expand Down Expand Up @@ -6605,8 +6610,9 @@ subroutine exch_uv(domain, bd, npz, u, v)
buf3(ic)=v(i,j,k)
enddo
enddo

enddo
if (ic/=size(buf2).or.ic/=size(buf3)) &
call mpp_error(FATAL,'Buffer sizes buf2 and buf3 in routine exch_uv do not match actual message size')
call MPI_Issend(buf3,size(buf3),_DYN_MPI_REAL,north_pe,mype &
,MPI_COMM_WORLD,ihandle3,isend)
endif
Expand Down Expand Up @@ -6639,6 +6645,8 @@ subroutine exch_uv(domain, bd, npz, u, v)
enddo

enddo
if (ic/=size(buf1).or.ic/=size(buf4)) &
call mpp_error(FATAL,'Buffer sizes buf1 and buf4 in routine exch_uv do not match actual message size')
call MPI_Issend(buf4,size(buf4),_DYN_MPI_REAL,south_pe,mype &
,MPI_COMM_WORLD,ihandle4,isend)
endif
Expand Down

0 comments on commit 531a0d6

Please sign in to comment.