1 |
cnh |
1.7 |
C $Header: /u/u0/gcmpack/MITgcm/pkg/exch2/exch2_recv_rx1.template,v 1.6 2008/07/29 20:25:23 jmc Exp $ |
2 |
edhill |
1.2 |
C $Name: $ |
3 |
|
|
|
4 |
jmc |
1.4 |
#include "CPP_EEOPTIONS.h" |
5 |
|
|
#include "W2_OPTIONS.h" |
6 |
afe |
1.1 |
|
7 |
|
|
SUBROUTINE EXCH2_RECV_RX1( |
8 |
|
|
I tIlo, tIhi, tiStride, |
9 |
|
|
I tJlo, tJhi, tjStride, |
10 |
|
|
I tKlo, tKhi, tkStride, |
11 |
|
|
I thisTile, thisI, nN, |
12 |
|
|
I e2Bufr1_RX, e2BufrRecSize, |
13 |
|
|
I mnb, nt, |
14 |
|
|
U array, |
15 |
|
|
I i1Lo, i1Hi, j1Lo, j1Hi, k1Lo, k1Hi, |
16 |
|
|
U e2_msgHandles, myTiles, |
17 |
|
|
I commSetting, |
18 |
|
|
I myThid ) |
19 |
|
|
|
20 |
|
|
IMPLICIT NONE |
21 |
|
|
|
22 |
jmc |
1.4 |
#include "SIZE.h" |
23 |
|
|
#include "EEPARAMS.h" |
24 |
|
|
#include "EESUPPORT.h" |
25 |
afe |
1.1 |
#include "W2_EXCH2_TOPOLOGY.h" |
26 |
|
|
|
27 |
|
|
C === Routine arguments === |
28 |
|
|
C tIlo, tIhi, tIstride :: index range in I that will be filled in target "array" |
29 |
|
|
C tJlo, tJhi, tJstride :: index range in J that will be filled in target "array" |
30 |
|
|
C tKlo, tKhi, tKstride :: index range in K that will be filled in target "array" |
31 |
|
|
C thisTile :: Rank of the receiveing tile |
32 |
|
|
C thisI :: Index of the receiving tile within this process (used |
33 |
|
|
C :: to select buffer slots that are allowed). |
34 |
|
|
C nN :: Neighbour entry that we are processing |
35 |
|
|
C e2Bufr1_RX :: Data transport buffer array. This array is used in one of |
36 |
|
|
C :: two ways. For PUT communication the entry in the buffer |
37 |
|
|
C :: associated with the source for this receive (determined |
38 |
|
|
C :: from the opposing_send index) is read. For MSG communication |
39 |
|
|
C :: the entry in the buffer associated with this neighbor of this |
40 |
|
|
C :: tile is used as a receive location for loading a linear |
41 |
|
|
C :: stream of bytes. |
42 |
|
|
C e2BufrRecSize :: Number of elements in each entry of e2Bufr1_RX |
43 |
|
|
C mnb :: Second dimension of e2Bufr1_RX |
44 |
|
|
C nt :: Third dimension of e2Bufr1_RX |
45 |
|
|
C array :: Target array that this receive writes to. |
46 |
|
|
C i1Lo, i1Hi :: I coordinate bounds of target array |
47 |
|
|
C j1Lo, j1Hi :: J coordinate bounds of target array |
48 |
|
|
C k1Lo, k1Hi :: K coordinate bounds of target array |
49 |
|
|
C e2_msgHandles :: Synchronization and coordination data structure used to coordinate access |
50 |
|
|
C :: to e2Bufr1_RX or to regulate message buffering. In PUT communication |
51 |
|
|
C :: sender will increment handle entry once data is ready in buffer. |
52 |
|
|
C :: Receiver will decrement handle once data is consumed from buffer. For |
53 |
|
|
C :: MPI MSG communication MPI_Wait uses hanlde to check Isend has cleared. |
54 |
|
|
C :: This is done in routine after receives. |
55 |
|
|
C myTiles :: List of nt tiles that this process owns. |
56 |
|
|
C commSetting :: Mode of communication used to exchnage with this neighbor |
57 |
|
|
C myThid :: Thread number of this instance of EXCH2_RECV_RX1 |
58 |
|
|
C |
59 |
|
|
INTEGER tILo, tIHi, tiStride |
60 |
|
|
INTEGER tJLo, tJHi, tjStride |
61 |
|
|
INTEGER tKLo, tKHi, tkStride |
62 |
|
|
INTEGER i1Lo, i1Hi, j1Lo, j1Hi, k1Lo, k1Hi |
63 |
|
|
INTEGER thisTile, nN, thisI |
64 |
|
|
INTEGER e2BufrRecSize |
65 |
|
|
INTEGER mnb, nt |
66 |
|
|
_RX e2Bufr1_RX( e2BufrRecSize, mnb, nt, 2 ) |
67 |
|
|
_RX array(i1Lo:i1Hi,j1Lo:j1Hi,k1Lo:k1Hi) |
68 |
|
|
INTEGER e2_msgHandles(mnb, nt) |
69 |
|
|
INTEGER myThid |
70 |
|
|
INTEGER myTiles(nt) |
71 |
|
|
CHARACTER commSetting |
72 |
|
|
|
73 |
|
|
C == Local variables == |
74 |
|
|
C itl, jtl, ktl :: Loop counters |
75 |
|
|
C :: itl etc... target local |
76 |
|
|
C :: itc etc... target canonical |
77 |
|
|
C :: isl etc... source local |
78 |
|
|
C :: isc etc... source canonical |
79 |
|
|
INTEGER itl, jtl, ktl |
80 |
jmc |
1.3 |
c INTEGER itc, jtc, ktc |
81 |
|
|
c INTEGER isc, jsc, ksc |
82 |
|
|
c INTEGER isl, jsl, ksl |
83 |
afe |
1.1 |
C tt :: Target tile |
84 |
|
|
C iBufr :: Buffer counter |
85 |
|
|
INTEGER tt |
86 |
|
|
INTEGER iBufr |
87 |
|
|
C mb, nb :: Selects e2Bufr, msgHandle record to use |
88 |
|
|
C ir :: |
89 |
|
|
INTEGER mb, nb, ir |
90 |
|
|
C oN :: Opposing send record number |
91 |
|
|
INTEGER oN |
92 |
|
|
C Loop counters |
93 |
jmc |
1.3 |
c INTEGER I, nri, nrj, nrk |
94 |
|
|
INTEGER I |
95 |
afe |
1.1 |
|
96 |
|
|
C MPI setup |
97 |
jmc |
1.3 |
#ifdef ALLOW_USE_MPI |
98 |
|
|
c INTEGER theTag, theSize, theType |
99 |
|
|
INTEGER theTag, theType |
100 |
afe |
1.1 |
INTEGER sProc, tProc |
101 |
jmc |
1.3 |
INTEGER nri, nrj, nrk |
102 |
afe |
1.1 |
INTEGER mpiStatus(MPI_STATUS_SIZE), mpiRc |
103 |
jmc |
1.3 |
#ifdef W2_E2_DEBUG_ON |
104 |
|
|
CHARACTER*(MAX_LEN_MBUF) messageBuffer |
105 |
|
|
#endif |
106 |
afe |
1.1 |
#endif |
107 |
|
|
|
108 |
|
|
tt=exch2_neighbourId(nN, thisTile ) |
109 |
jmc |
1.6 |
oN=exch2_opposingSend(nN, thisTile ) |
110 |
afe |
1.1 |
|
111 |
|
|
C Handle receive end data transport according to communication mechanism between |
112 |
|
|
C source and target tile |
113 |
|
|
IF ( commSetting .EQ. 'P' ) THEN |
114 |
|
|
C 1 Need to check and spin on data ready assertion for multithreaded mode, for now do nothing i.e. |
115 |
|
|
C assume only one thread per process. |
116 |
|
|
|
117 |
|
|
C 2 Need to set e2Bufr to use put buffer from opposing send. |
118 |
jmc |
1.6 |
oN = exch2_opposingSend(nN, thisTile ) |
119 |
afe |
1.1 |
mb = oN |
120 |
|
|
DO I=1,nt |
121 |
|
|
IF ( myTiles(I) .EQ. tt ) THEN |
122 |
|
|
nb = I |
123 |
|
|
ir = 1 |
124 |
|
|
ENDIF |
125 |
|
|
ENDDO |
126 |
|
|
C Get data from e2Bufr(1,mb,nb) |
127 |
|
|
ELSEIF ( commSetting .EQ. 'M' ) THEN |
128 |
|
|
#ifdef ALLOW_USE_MPI |
129 |
|
|
C Setup MPI stuff here |
130 |
|
|
nb = thisI |
131 |
|
|
mb = nN |
132 |
|
|
ir = 2 |
133 |
|
|
theTag = (tt-1)*MAX_NEIGHBOURS + oN |
134 |
|
|
tProc = exch2_tProc(thisTile)-1 |
135 |
|
|
sProc = exch2_tProc(tt)-1 |
136 |
|
|
theType = MPI_REAL8 |
137 |
|
|
nri = (tIhi-tIlo+1)/tiStride |
138 |
|
|
nrj = (tJhi-tJlo+1)/tjStride |
139 |
|
|
nrk = (tKhi-tKlo+1)/tkStride |
140 |
|
|
iBufr = nri*nrj*nrk |
141 |
|
|
CALL MPI_Recv( e2Bufr1_RX(1,mb,nb,ir), iBufr, theType, sProc, |
142 |
|
|
& theTag, MPI_COMM_MODEL, mpiStatus, mpiRc ) |
143 |
|
|
#ifdef W2_E2_DEBUG_ON |
144 |
|
|
WRITE(messageBuffer,'(A,I4,A,I4,A)') ' RECV FROM TILE=', tt, |
145 |
|
|
& ' (proc = ',sProc,')' |
146 |
|
|
CALL PRINT_MESSAGE(messageBuffer, |
147 |
|
|
I standardMessageUnit,SQUEEZE_RIGHT, |
148 |
|
|
I myThid) |
149 |
heimbach |
1.5 |
WRITE(messageBuffer,'(A,I4,A,I4,A)') ' INTO TILE=', thisTile, |
150 |
afe |
1.1 |
& ' (proc = ',tProc,')' |
151 |
|
|
CALL PRINT_MESSAGE(messageBuffer, |
152 |
|
|
I standardMessageUnit,SQUEEZE_RIGHT, |
153 |
|
|
I myThid) |
154 |
|
|
WRITE(messageBuffer,'(A,I10)') ' TAG=', theTag |
155 |
|
|
CALL PRINT_MESSAGE(messageBuffer, |
156 |
|
|
I standardMessageUnit,SQUEEZE_RIGHT, |
157 |
|
|
I myThid) |
158 |
|
|
WRITE(messageBuffer,'(A,I4)') ' NEL=', iBufr |
159 |
|
|
CALL PRINT_MESSAGE(messageBuffer, |
160 |
|
|
I standardMessageUnit,SQUEEZE_RIGHT, |
161 |
|
|
I myThid) |
162 |
|
|
#endif /* W2_E2_DEBUG_ON */ |
163 |
|
|
C Set mb to neighbour entry |
164 |
|
|
C Set nt to this tiles rank |
165 |
|
|
mb = nN |
166 |
|
|
#endif |
167 |
|
|
ELSE |
168 |
|
|
STOP 'EXCH2_RECV_RX1:: commSetting VALUE IS INVALID' |
169 |
|
|
ENDIF |
170 |
|
|
|
171 |
|
|
iBufr=0 |
172 |
|
|
DO ktl=tKlo,tKhi,tKStride |
173 |
|
|
DO jtl=tJLo, tJHi, tjStride |
174 |
|
|
DO itl=tILo, tIHi, tiStride |
175 |
|
|
C Read from e2Bufr1_RX(iBufr,mb,nb) |
176 |
|
|
iBufr=iBufr+1 |
177 |
|
|
array(itl,jtl,ktl)=e2Bufr1_RX(iBufr,mb,nb,ir) |
178 |
|
|
ENDDO |
179 |
|
|
ENDDO |
180 |
|
|
ENDDO |
181 |
|
|
|
182 |
|
|
RETURN |
183 |
|
|
END |
184 |
edhill |
1.2 |
|
185 |
|
|
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
186 |
|
|
|
187 |
|
|
CEH3 ;;; Local Variables: *** |
188 |
|
|
CEH3 ;;; mode:fortran *** |
189 |
|
|
CEH3 ;;; End: *** |