Skip to content

Commit e3e48a7

Browse files
author
Daniel Ruprecht
committed
advection boundaries test now uses generic random number generator
1 parent f476263 commit e3e48a7

File tree

1 file changed

+23
-8
lines changed

1 file changed

+23
-8
lines changed

test/src/advection_boundaries_test.f90

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,31 @@ PROGRAM advection_boundaries_test
1313
DOUBLE PRECISION, PARAMETER :: pi = 3.1415926535897932_8 ! underscore indicates rounding to real(8) precision
1414
DOUBLE PRECISION, ALLOCATABLE, DIMENSION(:,:,:,:) :: Q, RQ, Qbc, RQbc
1515
DOUBLE PRECISION :: dx, dy, dz, x, y, z
16-
INTEGER :: Nx, Ny, Nz, i, j, k, order, Nthreads, nt, seed, time1(8)
16+
INTEGER :: Nx, Ny, Nz, i, j, k, order, Nthreads, nt, seed_size, clock
17+
INTEGER, PARAMETER :: N_min = 6, N_max = 128
1718

18-
CALL DATE_AND_TIME(values=time1)
19-
seed = 1000*time1(7)+time1(8)
20-
CALL SRAND(seed)
19+
INTEGER, ALLOCATABLE, DIMENSION(:) :: seed
20+
REAL :: random_real
21+
22+
CALL RANDOM_SEED(size = seed_size)
23+
ALLOCATE(seed(seed_size))
24+
CALL SYSTEM_CLOCK(count = clock)
25+
seed = clock + 37 * (/ (i - 1, i = 1, seed_size) /)
26+
CALL RANDOM_SEED(put = seed)
27+
DEALLOCATE(seed)
2128

2229
! Generate random values of Nx, Ny, Nz that are at least 6, to exclude too small domains
23-
Nx = 6 + INT( RAND()*128 )
24-
Ny = 6 + INT( RAND()*128 )
25-
Nz = 6 + INT( RAND()*128 )
30+
CALL RANDOM_NUMBER(random_real)
31+
Nx = N_min + FLOOR( (N_max+1-N_min)*random_real )
32+
CALL RANDOM_NUMBER(random_real)
33+
Ny = N_min + FLOOR( (N_max+1-N_min)*random_real )
34+
CALL RANDOM_NUMBER(random_real)
35+
Nz = N_min + FLOOR( (N_max+1-N_min)*random_real )
36+
37+
write(*,*), Nx
38+
write(*,*), Ny
39+
write(*,*), Nz
40+
2641
Nthreads = 8
2742

2843
ALLOCATE(Q( -2:Nx+3,-2:Ny+3,-2:Nz+3,0:Nthreads-1))
@@ -111,4 +126,4 @@ PROGRAM advection_boundaries_test
111126

112127
PRINT*, '\x1B[32m[0] -- Successful: GetRHSAdvection produces identical results when ghost-cells are filled manually or through the boundaries module.\x1B[0m'
113128

114-
END PROGRAM advection_boundaries_test
129+
END PROGRAM advection_boundaries_test

0 commit comments

Comments
 (0)