Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove loop from Mersenne twister test #561

Merged
merged 2 commits into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion assimilation_code/modules/utilities/random_seq_mod.f90
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ module random_seq_mod

! the following routines were transcribed from C to F90, originally
! from the GNU scientific library: init_ran, ran_unif, ran_gauss,
! ran_gamma
! ran_gamma, ran_twist

integer, parameter :: N = 624 ! period parameters
integer, parameter :: M = 397
Expand Down
48 changes: 8 additions & 40 deletions developer_tests/random_seq/test_ran_unif.f90
Original file line number Diff line number Diff line change
Expand Up @@ -18,51 +18,19 @@ program test_ran_unif


type (random_seq_type) :: r
integer :: j, i, n, f, seq
logical :: write_this_one
character(len=50) :: formf = '(I12,4(F16.5))'
character(len=256) :: fname, temp

logical :: write_me = .true. ! if true, write each distribution into a file for later diagnostics
integer :: write_limit = 1000000 ! but only if rep count is not greater than this limit

! to add more tests or change the parameters, specify a test count
! and update the sets of inputs here:

integer, parameter :: ntests = 1
integer :: seq

call initialize_utilities('test_ran_unif')

write(*, *) ''

do j=1, ntests

call init_random_seq(r, 5)
call init_random_seq(r, 5)

n = j

! save all values in a file for post-plotting?
write_this_one = (write_me .and. n <= write_limit)

if (write_this_one) then
write(temp, "(A,I10)") "ran_unif_", n
call squeeze_out_blanks(temp, fname)
f = open_file(fname)
endif

seq = ran_twist(r)
seq = ran_twist(r)

if (seq == 953453411) then
write(*,*) 'ran_unif test: PASS'
if (write_this_one) write(f,*) 'PASS'
else
write(*,*) 'ran_unif test: FAIL'
if (write_this_one) write(f,*) 'FAIL'
endif

if (write_this_one) call close_file(f)

enddo
if (seq == 953453411) then
write(*,*) 'ran_unif test: PASS'
else
write(*,*) 'ran_unif test: FAIL'
endif

call finalize_utilities()

Expand Down