Merge branch 'master' into reconnection

This commit is contained in:
Grzegorz Kowal 2018-02-09 17:44:00 -02:00
commit 0cbf80c41e
3 changed files with 52 additions and 54 deletions

View File

@ -308,9 +308,10 @@ program amun
!
call setup_mpi(div(:), per(:), .false.)
! initialize the random number generator
! initialize the random number generator (passes the number of OpenMP threads
! and the current thread number)
!
call initialize_random(nprocs, nproc)
call initialize_random(1, 0)
! initialize geometry modules and print info
!

View File

@ -796,13 +796,17 @@ module io
!! 1. RESTORE PARAMETERS AND META BLOCKS FROM THE FIRST FILE
!!
! prepare the filename
! prepare the filename using the current process number; in case the file does
! not exist decrease it until the file corresponding to lower process number
! is found;
!
write (fl, "(a,'r',i6.6,'_',i5.5,'.h5')") trim(respath), nrest, 0
! check if the HDF5 file exists
!
inquire(file = fl, exist = info)
info = .false.
lfile = nproc + 1
do while (.not. info .and. lfile > 0)
lfile = lfile - 1
write (fl, "(a,'r',i6.6,'_',i5.5,'.h5')") trim(respath), nrest, lfile
inquire(file = fl, exist = info)
end do
! quit, if file does not exist
!
@ -1567,7 +1571,7 @@ module io
! set the seed values
!
call set_seeds(lnseeds, seeds(:))
call set_seeds(lnseeds, seeds(:), nproc /= lnproc)
! deallocate seed array
!
@ -2653,7 +2657,7 @@ module io
! local allocatable arrays
!
integer(kind=4), dimension(:) , allocatable :: lev, ref
integer(kind=4), dimension(:) , allocatable :: ids, lev, ref
integer(kind=4), dimension(:,:) , allocatable :: cor
real (kind=8), dimension(:,:,:), allocatable :: bnd
@ -2688,6 +2692,7 @@ module io
! allocate arrays to store coordinates
!
allocate(ids(cm(1)))
allocate(lev(cm(1)))
allocate(ref(cm(1)))
allocate(cor(cm(1),cm(2)))
@ -2699,6 +2704,10 @@ module io
pdata => list_data
do while(associated(pdata))
! fill in the IDs array
!
ids(l) = pdata%meta%id
! fill in the level array
!
lev(l) = pdata%meta%level
@ -2728,6 +2737,7 @@ module io
! write the arrays to the HDF5 file
!
call write_array(gid, 'ids' , cm(1), ids)
call write_array(gid, 'levels', cm(1), lev)
call write_array(gid, 'refine', cm(1), ref)
call write_array(gid, 'coords', cm(:), cor)
@ -2738,6 +2748,7 @@ module io
! deallocate temporary arrays
!
if (allocated(ids)) deallocate(ids)
if (allocated(lev)) deallocate(lev)
if (allocated(ref)) deallocate(ref)
if (allocated(cor)) deallocate(cor)

View File

@ -80,7 +80,7 @@ module random
!
!===============================================================================
!
subroutine initialize_random(nprocs, nproc)
subroutine initialize_random(nthreads, nthread)
! obtain required variables from other modules
!
@ -92,7 +92,7 @@ module random
! subroutine arguments
!
integer, intent(in) :: nprocs, nproc
integer, intent(in) :: nthreads, nthread
! local variables
!
@ -112,9 +112,9 @@ module random
call start_timer(iri)
#endif /* PROFILE */
! set the processor number
! set the thread number
!
kp = nproc
kp = nthread
! obtain the generator type
!
@ -122,7 +122,7 @@ module random
! calculate the number of seeds
!
nseeds = 2 * nprocs
nseeds = nthreads
lseed = nseeds - 1
! allocate seeds for random number generator
@ -138,12 +138,8 @@ module random
seeds(i) = 123456789 * r
end do
case default
call random_number(r)
do i = 0, nprocs - 1
seeds(i) = 123456789 * r
end do
call random_number(r)
do i = nprocs, lseed
r = 0.1234567890123456789
do i = 0, lseed
seeds(i) = 123456789 * r
end do
end select
@ -204,7 +200,7 @@ module random
!
!===============================================================================
!
subroutine set_seeds(np, seed)
subroutine set_seeds(np, nseeds, generate)
! declare all variables as implicit
!
@ -212,8 +208,9 @@ module random
! input arguments
!
integer , intent(in) :: np
integer(kind=4), dimension(0:np-1), intent(in) :: seed
integer , intent(in) :: np
integer(kind=4), dimension(np), intent(in) :: nseeds
logical , intent(in) :: generate
! local variables
!
@ -230,35 +227,24 @@ module random
! set the seeds only if the input array and seeds have the same sizes
!
if (np == nseeds) then
seeds(0:lseed) = seed(0:lseed)
else
! if the input array and seeds have different sizes, expand or shrink seeds
!
select case(gentype)
case('random')
l = min(lseed, np - 1)
seeds(0:l) = seed(0:l)
if (l < lseed) then
do i = l + 1, lseed
call random_number(r)
seeds(i) = 123456789 * r
end do
end if
case default
l = nseeds / 2
do i = 0, l - 1
seeds(i) = seed(0)
l = min(lseed, np - 1)
seeds(0:l) = nseeds(1:l+1)
select case(gentype)
case('random')
if (generate) then
do i = 0, lseed
call random_number(r)
seeds(i) = 123456789 * r
end do
do i = l, lseed
seeds(i) = seed(np-1)
else
do i = l + 1, lseed
call random_number(r)
seeds(i) = 123456789 * r
end do
end select
end if
end if
case default
seeds(l+1:lseed) = seeds(0)
end select
#ifdef PROFILE
! stop accounting time for the random number generator
@ -279,7 +265,7 @@ module random
!
!===============================================================================
!
subroutine get_seeds(seed)
subroutine get_seeds(rseeds)
! declare all variables as implicit
!
@ -287,7 +273,7 @@ module random
! output arguments
!
integer(kind=4), dimension(0:lseed), intent(out) :: seed
integer(kind=4), dimension(nseeds), intent(out) :: rseeds
!
!-------------------------------------------------------------------------------
!
@ -297,7 +283,7 @@ module random
call start_timer(iri)
#endif /* PROFILE */
seed(0:lseed) = seeds(0:lseed)
rseeds(1:nseeds) = seeds(0:lseed)
#ifdef PROFILE
! stop accounting time for the random number generator