Skip to content

Commit

Permalink
Merge branch 'isolate_random_numbers'
Browse files Browse the repository at this point in the history
  • Loading branch information
daminton committed Dec 14, 2021
2 parents 4e930c5 + e1cd6bc commit e12a6ef
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 21 deletions.
4 changes: 2 additions & 2 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ PAR = -qopenmp -parallel
HEAPARR = -heap-arrays
OPTREPORT = -qopt-report=5
IPRODUCTION = -g -traceback -no-wrap-margin -assume byterecl -O3 -qopt-prefetch=0 -sox $(PAR) $(SIMDVEC) $(HEAPARR)
AM_FCFLAGS = $(IPRODUCTION) $(OPTREPORT)
IDEBUG = -O0 -g -traceback -debug all -nogen-interfaces -assume byterecl -m64 -heap-arrays -FR -no-pie -no-ftz -fpe-all=0 -mp1 -fp-model strict -fpe0 -align all -pad -ip -prec-div -prec-sqrt -assume protect-parens -CB -no-wrap-margin -init=snan,arrays
AM_FCFLAGS = $(IPRODUCTION)
#ifort debug flags
#AM_FCFLAGS = -O0 -p -g -debug all -traceback -CB -assume byterecl -m64 -heap-arrays -FR $(PAR) $(SIMDVEC)

#gfortran optimized flags
#AM_FCFLAGS = -O3 -fopenmp -ffree-form -g -fbounds-check -fbacktrace
Expand Down
13 changes: 8 additions & 5 deletions src/crater/crater_generate.f90
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,15 @@ subroutine crater_generate(user,crater,domain,prod,production_list,vdist,surf)
integer(I4B) :: k,khi,klo,Nk
integer(I8B) :: random_index,numremaining,nabove,nabovep1

!TESTING FOR VARIABLE FE MODERL
real(DP) :: mfe,bfe


! Get all six random numbers we need in one call
if (.not.domain%initialize) call random_number(rn)
if (.not.domain%initialize) then
! Initialize the random number generator with the current value of the seeds
call random_seed(put=crater%seedarr)
call random_number(rn)
! Save the current value of the seeds for the next time we need a new crater. This ensures we can get a repeatable population population of craters,
! regardless of whether other procedures that use the random number generator are used or not
call random_seed(get=crater%seedarr)
end if

! Find crater center position
if (domain%initialize) then
Expand Down
1 change: 1 addition & 0 deletions src/globals/module_globals.f90
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ module module_globals
real(DP) :: floordepth
real(DP) :: floordiam
real(DP) :: peakheight
integer(I4B),dimension(:),allocatable :: seedarr ! Random number generator seed array
end type cratertype

! Derived data type for domain variables (sizes and dimensions)
Expand Down
10 changes: 4 additions & 6 deletions src/main/CTEM.f90
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ program CTEM
integer(I8B) :: totalimpacts ! Total number of impacts ever produced
integer(I4B) :: ncount ! Current count in ctem_driver IDL run
integer(I4B) :: n, xp, yp, i ! Size of random number generator seed array
integer(I4B),dimension(:),allocatable :: seedarr ! Random number generator seed array
real(DP) :: curyear
real(DP) :: mass
real(DP) :: masstot
Expand Down Expand Up @@ -102,9 +101,9 @@ program CTEM
! Reset random number generator
call random_seed
call random_seed(size=n)
allocate(seedarr(n))
call io_read_const(totalimpacts,ncount,curyear,restart,fracdone,masstot,seedarr)
call random_seed(put=seedarr)
allocate(crater%seedarr(n))
call io_read_const(totalimpacts,ncount,curyear,restart,fracdone,masstot,crater%seedarr)
call random_seed(put=crater%seedarr)

! Read in old grid arrays, production function, and velocity distributions
if (restart .or. user%tallyonly) then
Expand All @@ -125,9 +124,8 @@ program CTEM
fracdone,nflux,ntotcrat,curyear,rclist)

! Get the last seed and save it to file
call random_seed(get=seedarr)
totalimpacts = totalimpacts + ntotcrat
call io_write_const(totalimpacts,ncount,curyear,restart,fracdone,masstot,seedarr)
call io_write_const(totalimpacts,ncount,curyear,restart,fracdone,masstot,crater%seedarr)
call crater_tally_true(domain,truelist(:,1:ntrue),ntrue,truedist)
end if

Expand Down
8 changes: 0 additions & 8 deletions src/realistic/realistic_perlin_noise.f90
Original file line number Diff line number Diff line change
Expand Up @@ -605,18 +605,10 @@ subroutine realistic_ejecta_texture(user,surf,crater,deltaMtot,inc,ejecta_dem)
real(DP) :: splatmag ! The magnitude of the splat features relative to the ejecta thickness
integer(I4B) :: nsplat_octaves
integer(I4B) :: nseed
integer(I4B),dimension(:),allocatable :: seed
real(DP),dimension(:),allocatable :: Sarr,Aarr
real(DP),dimension(:,:),allocatable :: anchor


!Executable code
call random_seed(size = nseed)
allocate(seed(nseed))
seed = 42 * (/ (i - 1, i = 1, nseed) /)
call random_seed(put = seed)
deallocate(seed)

! Copernicus values
num_octaves = 20

Expand Down

0 comments on commit e12a6ef

Please sign in to comment.