Skip to content

Commit

Permalink
Merge branch 'whannah/atm/fix-pg-compiler-bug' into next (PR #3128)
Browse files Browse the repository at this point in the history
When building with GNU in debug mode on certain machines it will complain
if fv_nphys=0 even though those blocks of code are never used. This
fixes the issue by using a dummy variable to hold the product of
fv_nphys*fv_nphys.

[BFB]

* whannah/atm/fix-pg-compiler-bug:
  Fix compiler error when fv_nphys=0
  • Loading branch information
rljacob committed Aug 16, 2019
2 parents 12fe474 + a95a046 commit 000bba9
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions components/cam/src/dynamics/se/dyn_grid.F90
Original file line number Diff line number Diff line change
Expand Up @@ -270,14 +270,16 @@ subroutine get_gcol_block_d(gcol, cnt, blockid, bcid, localblockid)
!----------------------------Local-Variables--------------------------------
integer :: sb, eb, ie, high, low
logical :: found
integer :: nphys_sq
integer, save :: iedex_save = 1
!---------------------------------------------------------------------------
if(gblocks_need_initialized) call gblocks_init()
if (fv_nphys > 0) then

! Note: the max() is to fool the compiler debug mode when fv_nphys=0
blockid(1) = 1 + ( (gcol-1) / max(1,fv_nphys*fv_nphys) )
bcid(1) = 1 + mod(gcol-1, fv_nphys*fv_nphys)
! Note: nphys_sq is to fool the compiler in debug mode when fv_nphys=0
nphys_sq = fv_nphys*fv_nphys
blockid(1) = 1 + (gcol-1) / nphys_sq
bcid(1) = 1 + mod(gcol-1, nphys_sq)

if (present(localblockid)) then
localblockid = -1
Expand Down

0 comments on commit 000bba9

Please sign in to comment.