Skip to content

Commit

Permalink
Fixing a compilation failure due to incorrect calling of "random_seed…
Browse files Browse the repository at this point in the history
…" in g3 #294

TYPE: bug fix

KEYWORDS: compilation, gfortran, cumulus, g3

SOURCE: internal

DESCRIPTION OF CHANGES: There is an incorrect implementation of the intrinsic fortran function random_seed in the G3 scheme (cu_physics=5). The current code assumes that the random seed vector fed to the random_seed function is of size 12, but this is not standardized, nor required by the fortran standard. The newest version of gfortran (7.1.0) uses 33 elements in its seed vector, so trying to feed it a 12-element vector causes a compilation failure. The correct procedure is to call random_seed(size=X), which will give the correct seed vector size as X. X can then be used to allocate the correct size for the seed vector.

This fix should not impact any results. Per Georg Grell, this code is unused in the current scheme.

LIST OF MODIFIED FILES:
M phys/module_cu_g3.F

TESTS CONDUCTED: WTF passed. WRF now compiles and runs for gfortran 7.1.0 on Cheyenne. Fix applied for WRFPLUS (which initiated this investigation) also compiles successfully.
(cherry picked from commit e9e0d26)
  • Loading branch information
mkavulich committed Aug 15, 2017
1 parent d06bac6 commit fe764d7
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion phys/module_cu_g3.F
Original file line number Diff line number Diff line change
Expand Up @@ -3122,7 +3122,8 @@ SUBROUTINE cup_forcing_ens_3d(closure_n,xland,aa0,aa1,xaa0,mbdt,dtime,ierr,ierr2
pcrit,acrit,acritt

integer :: nall2,ixxx,irandom
integer, dimension (12) :: seed
integer, allocatable :: seed(:)
integer :: seed_size


DATA PCRIT/850.,800.,750.,700.,650.,600.,550.,500.,450.,400., &
Expand All @@ -3133,6 +3134,9 @@ SUBROUTINE cup_forcing_ens_3d(closure_n,xland,aa0,aa1,xaa0,mbdt,dtime,ierr,ierr2
DATA ACRITT/.203,.515,.521,.566,.625,.665,.659,.688, &
.743,.813,.886,.947,1.138,1.377,1.896/
!
call random_seed(size=seed_size) ! Get size of seed array.
allocate(seed(1:seed_size)) ! Allocate according to returned size

seed=0
seed(2)=j
seed(3)=ktau
Expand Down

0 comments on commit fe764d7

Please sign in to comment.