root / synthbench / euroben-dm / mod1h / .svn / text-base / nearn_3d.f.svn-base @ 0:839f52ef7657
History | View | Annotate | Download (3.6 kB)
1 |
Subroutine nearn_3d( title, me, npes, nrpt, ncases, n, tn, |
---|---|
2 |
& ops ) |
3 |
! ---------------------------------------------------------------------- |
4 |
Use numerics |
5 |
Use max_params |
6 |
Implicit None |
7 |
|
8 |
Include 'mpif.h' |
9 |
|
10 |
Character*50 :: title |
11 |
Integer :: me, npes, nrpt, ncases, n |
12 |
Real(l_) :: tn(maxcases), ops, timer |
13 |
Real(l_) :: a(nmax), b(nmax), c(nmax), d(nmax), e(nmax) |
14 |
Real(l_) :: buffer(24*(nmax+MPI_Bsend_Overhead/8)) |
15 |
Real(l_) :: t1, t2 |
16 |
Integer :: k, tag |
17 |
Integer :: comm, commcart, ie, type |
18 |
Integer :: status(MPI_Status_Size) |
19 |
Integer, Parameter :: dim = 3 |
20 |
Integer :: dims(dim) |
21 |
Integer :: pos(dim) |
22 |
Logical :: periods(dim) |
23 |
Integer :: moi, myid |
24 |
Integer :: north, south, west, east, up, down |
25 |
Integer :: size |
26 |
Save a, b, c, d, e |
27 |
! ---------------------------------------------------------------------- |
28 |
comm = MPI_Comm_World |
29 |
type = MPI_Real8 |
30 |
title = ' N PEs <-- 6N PEs; Nearst nbr 3D' |
31 |
nrpt = 100 |
32 |
ncases = npes |
33 |
ops = 6*8*n |
34 |
size = 8*n |
35 |
tn(1:maxcases) = 1.0e-15_l_ |
36 |
|
37 |
periods = .TRUE. ! --- Introduce topology |
38 |
dims = 0 |
39 |
|
40 |
Call MPI_Comm_Rank( comm, myid, ie) |
41 |
Call MPI_Dims_Create( npes, dim, dims, ie ) |
42 |
Call MPI_Cart_Create( comm, dim, dims, periods, .true., commcart, |
43 |
& ie ) |
44 |
|
45 |
! --- Get position and rank in Cartesian grid. |
46 |
|
47 |
Call MPI_Cart_Get( commcart, dim, dims, periods, pos, ie ) |
48 |
Call MPI_Cart_Rank( commcart, pos, moi, ie ) |
49 |
Call MPI_Buffer_Attach( buffer, 24*(size+MPI_Bsend_Overhead), ie ) |
50 |
|
51 |
! --- Get rank of neighbours. |
52 |
|
53 |
Call MPI_Cart_Coords( commcart, myid, dim, dims, ie ) |
54 |
Call MPI_Cart_Shift( commcart, 0, -1, myid, west, ie ) |
55 |
Call MPI_Cart_Shift( commcart, 0, 1, myid, east, ie ) |
56 |
Call MPI_Cart_Shift( commcart, 1, 1, myid, north, ie ) |
57 |
Call MPI_Cart_Shift( commcart, 1, -1, myid, south, ie ) |
58 |
Call MPI_Cart_Shift( commcart, 2, 1, myid, up, ie ) |
59 |
Call MPI_Cart_Shift( commcart, 2, -1, myid, down, ie) |
60 |
|
61 |
t1 = timer() |
62 |
Do k = 1, nrpt |
63 |
tag = (nrpt * npes * 6) |
64 |
Call MPI_Bsend( a, n, type, west, tag + moi, commcart, ie ) |
65 |
Call MPI_Bsend( a, n, type, east, tag + moi+1, commcart, ie ) |
66 |
Call MPI_Bsend( a, n, type, north, tag + moi+2, commcart, ie ) |
67 |
Call MPI_Bsend( a, n, type, south, tag + moi+3, commcart, ie ) |
68 |
Call MPI_Bsend( a, n, type, up, tag + moi + 4, commcart, ie ) |
69 |
Call MPI_Bsend( a, n, type, down, tag + moi+5, commcart, ie ) |
70 |
Call MPI_Recv( b, n, type, west, tag + west + 1, |
71 |
& commcart, status, ie ) |
72 |
Call MPI_Recv( c, n, type, east, tag + east, |
73 |
& commcart, status, ie ) |
74 |
Call MPI_Recv( d, n, type, north, tag + north + 3, |
75 |
& commcart, status, ie ) |
76 |
Call MPI_Recv( e, n, type, south, tag + south + 2, |
77 |
& commcart, status, ie ) |
78 |
Call MPI_Recv( d, n, type, up, tag + up + 5, |
79 |
& commcart, status, ie ) |
80 |
Call MPI_Recv( e, n, type, down, tag + down + 4, |
81 |
& commcart, status, ie ) |
82 |
End Do |
83 |
t2 = timer () |
84 |
tn(myid+1) = Max( 1.0e-15_l_, (t2-t1) / (2*nrpt ) ) |
85 |
Call MPI_Buffer_Detach( buffer, size, ie ) |
86 |
! ---------------------------------------------------------------------- |
87 |
End Subroutine nearn_3d |
88 |
|