From ae3b049d302e0beb8e951652cc29567b2d967cd3 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Thu, 27 Oct 2022 09:21:37 +0200 Subject: [PATCH] avoid repeated random sequences on different processes we don't use random numbers a lot and there are no reported problems yet. Still, this is safer. --- src/math.f90 | 11 ++++++++++- src/parallelization.f90 | 6 ++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/math.f90 b/src/math.f90 index 889e4ccd2..ff0c604b3 100644 --- a/src/math.f90 +++ b/src/math.f90 @@ -10,8 +10,17 @@ module math use IO use config use YAML_types + use parallelization use LAPACK_interface +#ifdef PETSC +#include + use PETScSys +#if (PETSC_VERSION_MAJOR==3 && PETSC_VERSION_MINOR>14) && !defined(PETSC_HAVE_MPI_F90MODULE_VISIBILITY) + use MPI_f08 +#endif +#endif + implicit none(type,external) public #if __INTEL_COMPILER >= 1900 @@ -105,7 +114,7 @@ subroutine math_init() call random_seed(get = seed) end if - call random_seed(put = seed) + call random_seed(put = seed + worldrank*42_MPI_INTEGER_KIND) call random_number(randTest) print'(/,a,i2)', ' size of random seed: ', randSize diff --git a/src/parallelization.f90 b/src/parallelization.f90 index 5c7e9bff3..2934cf65c 100644 --- a/src/parallelization.f90 +++ b/src/parallelization.f90 @@ -27,15 +27,13 @@ module parallelization #ifndef PETSC integer, parameter, public :: & - MPI_INTEGER_KIND = pI64 + MPI_INTEGER_KIND = pI64 !< needed for MSC.Marc integer(MPI_INTEGER_KIND), parameter, public :: & - worldrank = 0_MPI_INTEGER_KIND, & !< MPI dummy worldrank - worldsize = 1_MPI_INTEGER_KIND !< MPI dummy worldsize #else integer(MPI_INTEGER_KIND), protected, public :: & +#endif worldrank = 0_MPI_INTEGER_KIND, & !< MPI worldrank (/=0 for MPI simulations only) worldsize = 1_MPI_INTEGER_KIND !< MPI worldsize (/=1 for MPI simulations only) -#endif #ifndef PETSC public :: parallelization_bcast_str