Merge branch 'master' into reconnection
This commit is contained in:
commit
0cbf80c41e
@ -308,9 +308,10 @@ program amun
|
|||||||
!
|
!
|
||||||
call setup_mpi(div(:), per(:), .false.)
|
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
|
! initialize geometry modules and print info
|
||||||
!
|
!
|
||||||
|
27
src/io.F90
27
src/io.F90
@ -796,13 +796,17 @@ module io
|
|||||||
|
|
||||||
!! 1. RESTORE PARAMETERS AND META BLOCKS FROM THE FIRST FILE
|
!! 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
|
info = .false.
|
||||||
|
lfile = nproc + 1
|
||||||
! check if the HDF5 file exists
|
do while (.not. info .and. lfile > 0)
|
||||||
!
|
lfile = lfile - 1
|
||||||
inquire(file = fl, exist = info)
|
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
|
! quit, if file does not exist
|
||||||
!
|
!
|
||||||
@ -1567,7 +1571,7 @@ module io
|
|||||||
|
|
||||||
! set the seed values
|
! set the seed values
|
||||||
!
|
!
|
||||||
call set_seeds(lnseeds, seeds(:))
|
call set_seeds(lnseeds, seeds(:), nproc /= lnproc)
|
||||||
|
|
||||||
! deallocate seed array
|
! deallocate seed array
|
||||||
!
|
!
|
||||||
@ -2653,7 +2657,7 @@ module io
|
|||||||
|
|
||||||
! local allocatable arrays
|
! local allocatable arrays
|
||||||
!
|
!
|
||||||
integer(kind=4), dimension(:) , allocatable :: lev, ref
|
integer(kind=4), dimension(:) , allocatable :: ids, lev, ref
|
||||||
integer(kind=4), dimension(:,:) , allocatable :: cor
|
integer(kind=4), dimension(:,:) , allocatable :: cor
|
||||||
real (kind=8), dimension(:,:,:), allocatable :: bnd
|
real (kind=8), dimension(:,:,:), allocatable :: bnd
|
||||||
|
|
||||||
@ -2688,6 +2692,7 @@ module io
|
|||||||
|
|
||||||
! allocate arrays to store coordinates
|
! allocate arrays to store coordinates
|
||||||
!
|
!
|
||||||
|
allocate(ids(cm(1)))
|
||||||
allocate(lev(cm(1)))
|
allocate(lev(cm(1)))
|
||||||
allocate(ref(cm(1)))
|
allocate(ref(cm(1)))
|
||||||
allocate(cor(cm(1),cm(2)))
|
allocate(cor(cm(1),cm(2)))
|
||||||
@ -2699,6 +2704,10 @@ module io
|
|||||||
pdata => list_data
|
pdata => list_data
|
||||||
do while(associated(pdata))
|
do while(associated(pdata))
|
||||||
|
|
||||||
|
! fill in the IDs array
|
||||||
|
!
|
||||||
|
ids(l) = pdata%meta%id
|
||||||
|
|
||||||
! fill in the level array
|
! fill in the level array
|
||||||
!
|
!
|
||||||
lev(l) = pdata%meta%level
|
lev(l) = pdata%meta%level
|
||||||
@ -2728,6 +2737,7 @@ module io
|
|||||||
|
|
||||||
! write the arrays to the HDF5 file
|
! 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, 'levels', cm(1), lev)
|
||||||
call write_array(gid, 'refine', cm(1), ref)
|
call write_array(gid, 'refine', cm(1), ref)
|
||||||
call write_array(gid, 'coords', cm(:), cor)
|
call write_array(gid, 'coords', cm(:), cor)
|
||||||
@ -2738,6 +2748,7 @@ module io
|
|||||||
|
|
||||||
! deallocate temporary arrays
|
! deallocate temporary arrays
|
||||||
!
|
!
|
||||||
|
if (allocated(ids)) deallocate(ids)
|
||||||
if (allocated(lev)) deallocate(lev)
|
if (allocated(lev)) deallocate(lev)
|
||||||
if (allocated(ref)) deallocate(ref)
|
if (allocated(ref)) deallocate(ref)
|
||||||
if (allocated(cor)) deallocate(cor)
|
if (allocated(cor)) deallocate(cor)
|
||||||
|
@ -80,7 +80,7 @@ module random
|
|||||||
!
|
!
|
||||||
!===============================================================================
|
!===============================================================================
|
||||||
!
|
!
|
||||||
subroutine initialize_random(nprocs, nproc)
|
subroutine initialize_random(nthreads, nthread)
|
||||||
|
|
||||||
! obtain required variables from other modules
|
! obtain required variables from other modules
|
||||||
!
|
!
|
||||||
@ -92,7 +92,7 @@ module random
|
|||||||
|
|
||||||
! subroutine arguments
|
! subroutine arguments
|
||||||
!
|
!
|
||||||
integer, intent(in) :: nprocs, nproc
|
integer, intent(in) :: nthreads, nthread
|
||||||
|
|
||||||
! local variables
|
! local variables
|
||||||
!
|
!
|
||||||
@ -112,9 +112,9 @@ module random
|
|||||||
call start_timer(iri)
|
call start_timer(iri)
|
||||||
#endif /* PROFILE */
|
#endif /* PROFILE */
|
||||||
|
|
||||||
! set the processor number
|
! set the thread number
|
||||||
!
|
!
|
||||||
kp = nproc
|
kp = nthread
|
||||||
|
|
||||||
! obtain the generator type
|
! obtain the generator type
|
||||||
!
|
!
|
||||||
@ -122,7 +122,7 @@ module random
|
|||||||
|
|
||||||
! calculate the number of seeds
|
! calculate the number of seeds
|
||||||
!
|
!
|
||||||
nseeds = 2 * nprocs
|
nseeds = nthreads
|
||||||
lseed = nseeds - 1
|
lseed = nseeds - 1
|
||||||
|
|
||||||
! allocate seeds for random number generator
|
! allocate seeds for random number generator
|
||||||
@ -138,12 +138,8 @@ module random
|
|||||||
seeds(i) = 123456789 * r
|
seeds(i) = 123456789 * r
|
||||||
end do
|
end do
|
||||||
case default
|
case default
|
||||||
call random_number(r)
|
r = 0.1234567890123456789
|
||||||
do i = 0, nprocs - 1
|
do i = 0, lseed
|
||||||
seeds(i) = 123456789 * r
|
|
||||||
end do
|
|
||||||
call random_number(r)
|
|
||||||
do i = nprocs, lseed
|
|
||||||
seeds(i) = 123456789 * r
|
seeds(i) = 123456789 * r
|
||||||
end do
|
end do
|
||||||
end select
|
end select
|
||||||
@ -204,7 +200,7 @@ module random
|
|||||||
!
|
!
|
||||||
!===============================================================================
|
!===============================================================================
|
||||||
!
|
!
|
||||||
subroutine set_seeds(np, seed)
|
subroutine set_seeds(np, nseeds, generate)
|
||||||
|
|
||||||
! declare all variables as implicit
|
! declare all variables as implicit
|
||||||
!
|
!
|
||||||
@ -212,8 +208,9 @@ module random
|
|||||||
|
|
||||||
! input arguments
|
! input arguments
|
||||||
!
|
!
|
||||||
integer , intent(in) :: np
|
integer , intent(in) :: np
|
||||||
integer(kind=4), dimension(0:np-1), intent(in) :: seed
|
integer(kind=4), dimension(np), intent(in) :: nseeds
|
||||||
|
logical , intent(in) :: generate
|
||||||
|
|
||||||
! local variables
|
! local variables
|
||||||
!
|
!
|
||||||
@ -230,35 +227,24 @@ module random
|
|||||||
|
|
||||||
! set the seeds only if the input array and seeds have the same sizes
|
! set the seeds only if the input array and seeds have the same sizes
|
||||||
!
|
!
|
||||||
if (np == nseeds) then
|
l = min(lseed, np - 1)
|
||||||
|
seeds(0:l) = nseeds(1:l+1)
|
||||||
seeds(0:lseed) = seed(0:lseed)
|
select case(gentype)
|
||||||
|
case('random')
|
||||||
else
|
if (generate) then
|
||||||
|
do i = 0, lseed
|
||||||
! if the input array and seeds have different sizes, expand or shrink seeds
|
call random_number(r)
|
||||||
!
|
seeds(i) = 123456789 * r
|
||||||
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)
|
|
||||||
end do
|
end do
|
||||||
do i = l, lseed
|
else
|
||||||
seeds(i) = seed(np-1)
|
do i = l + 1, lseed
|
||||||
|
call random_number(r)
|
||||||
|
seeds(i) = 123456789 * r
|
||||||
end do
|
end do
|
||||||
end select
|
end if
|
||||||
|
case default
|
||||||
end if
|
seeds(l+1:lseed) = seeds(0)
|
||||||
|
end select
|
||||||
|
|
||||||
#ifdef PROFILE
|
#ifdef PROFILE
|
||||||
! stop accounting time for the random number generator
|
! 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
|
! declare all variables as implicit
|
||||||
!
|
!
|
||||||
@ -287,7 +273,7 @@ module random
|
|||||||
|
|
||||||
! output arguments
|
! 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)
|
call start_timer(iri)
|
||||||
#endif /* PROFILE */
|
#endif /* PROFILE */
|
||||||
|
|
||||||
seed(0:lseed) = seeds(0:lseed)
|
rseeds(1:nseeds) = seeds(0:lseed)
|
||||||
|
|
||||||
#ifdef PROFILE
|
#ifdef PROFILE
|
||||||
! stop accounting time for the random number generator
|
! stop accounting time for the random number generator
|
||||||
|
Loading…
x
Reference in New Issue
Block a user