Skip to content

Commit 0226144

Browse files
committed
Fix test issue with using 0 for random_seed
I saw this issue with the nvhpc compiler; I'm not sure if other compilers would also have problems using 0 for the seed.
1 parent 13be2f7 commit 0226144

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/Infrastructure/TimeMgr/tests/ESMF_ClockUTest.F90

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ program ESMF_ClockTest
7878
! Random number
7979
real :: ranNum
8080
integer :: timevals(8)
81+
integer :: milliseconds
8182
integer, allocatable :: seed(:)
8283
integer :: seed_size
8384

@@ -1510,9 +1511,15 @@ program ESMF_ClockTest
15101511

15111512
if (rc.eq.ESMF_SUCCESS) then
15121513
call date_and_time(values=timevals)
1514+
milliseconds = timevals(8)
15131515
call random_seed (size=seed_size)
15141516
allocate (seed(seed_size))
1515-
seed=timevals(8)
1517+
if (milliseconds.eq.0) then
1518+
! random_seed needs non-zero values, at least with some compilers (e.g., nvhpc)
1519+
seed = 1000
1520+
else
1521+
seed = milliseconds
1522+
end if
15161523
call random_seed(put=seed)
15171524
deallocate (seed)
15181525
testResults = 0

0 commit comments

Comments
 (0)