-
Notifications
You must be signed in to change notification settings - Fork 5
/
topology_m.f90
46 lines (37 loc) · 1.36 KB
/
topology_m.f90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
!
! Copyright (C) 2013, Northwestern University
! See COPYRIGHT notice in top-level directory.
!
module topology_m
! module for topology variables
use mpi
implicit none
integer gcomm
integer npes ! total number of processors
integer myid ! rank of local processor
integer mypx, mypy, mypz
contains
!----< initialize_topology() >-----------------------------------
subroutine initialize_topology(npx,npy,npz)
! routine initializes some MPI stuff and the Cartesian MPI grid
implicit none
integer npx, npy, npz
integer err
! check for npes compatibility
if (npx*npy*npz .NE. npes) then
1000 format(' npx*npy*npz is not equal to npes, npx = ', &
i5,' npy = ', i5, ' npz = ', i5, ' npes = ', i5)
if (myid .EQ. 0) then
print 1000, npx,npy,npz,npes
endif
call MPI_Comm_free(gcomm,err)
call MPI_Finalize(err)
stop
endif
! initialize Cartesian grid
mypz = myid/(npx*npy)
mypx = mod(myid-(mypz*npx*npy), npx)
mypy = (myid-(mypz*npx*npy))/npx
! print*,'myid=',myid,' mypx=',mypx,' mypy=',mypy,' mypz=',mypz
end subroutine initialize_topology
end module topology_m