/[MITgcm]/MITgcm/pkg/exch2/exch2_recv_rx1.template
ViewVC logotype

Contents of /MITgcm/pkg/exch2/exch2_recv_rx1.template

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.3 - (show annotations) (download)
Fri Jul 22 18:21:55 2005 UTC (18 years, 10 months ago) by jmc
Branch: MAIN
Changes since 1.2: +13 -8 lines
comment out unused variable declaration (get less warnings for unused var)

1 C $Header: /u/gcmpack/MITgcm/pkg/exch2/exch2_recv_rx1.template,v 1.2 2004/04/05 15:27:06 edhill Exp $
2 C $Name: $
3
4 #include "CPP_OPTIONS.h"
5
6 SUBROUTINE EXCH2_RECV_RX1(
7 I tIlo, tIhi, tiStride,
8 I tJlo, tJhi, tjStride,
9 I tKlo, tKhi, tkStride,
10 I thisTile, thisI, nN,
11 I e2Bufr1_RX, e2BufrRecSize,
12 I mnb, nt,
13 U array,
14 I i1Lo, i1Hi, j1Lo, j1Hi, k1Lo, k1Hi,
15 U e2_msgHandles, myTiles,
16 I commSetting,
17 I myThid )
18
19 IMPLICIT NONE
20
21 C
22 #include "W2_OPTIONS.h"
23 #include "W2_EXCH2_TOPOLOGY.h"
24
25 #include "EEPARAMS.h"
26 C
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 c INTEGER itc, jtc, ktc
81 c INTEGER isc, jsc, ksc
82 c INTEGER isl, jsl, ksl
83 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 c INTEGER I, nri, nrj, nrk
94 INTEGER I
95
96 C MPI setup
97 #include "SIZE.h"
98 #include "EESUPPORT.h"
99 #ifdef ALLOW_USE_MPI
100 c INTEGER theTag, theSize, theType
101 INTEGER theTag, theType
102 INTEGER sProc, tProc
103 INTEGER nri, nrj, nrk
104 INTEGER mpiStatus(MPI_STATUS_SIZE), mpiRc
105 #ifdef W2_E2_DEBUG_ON
106 CHARACTER*(MAX_LEN_MBUF) messageBuffer
107 #endif
108 #endif
109
110 tt=exch2_neighbourId(nN, thisTile )
111 oN=exch2_opposingSend_record(nN, thisTile )
112
113 C Handle receive end data transport according to communication mechanism between
114 C source and target tile
115 IF ( commSetting .EQ. 'P' ) THEN
116 C 1 Need to check and spin on data ready assertion for multithreaded mode, for now do nothing i.e.
117 C assume only one thread per process.
118
119 C 2 Need to set e2Bufr to use put buffer from opposing send.
120 oN = exch2_opposingSend_record(nN, thisTile )
121 mb = oN
122 DO I=1,nt
123 IF ( myTiles(I) .EQ. tt ) THEN
124 nb = I
125 ir = 1
126 ENDIF
127 ENDDO
128 C Get data from e2Bufr(1,mb,nb)
129 ELSEIF ( commSetting .EQ. 'M' ) THEN
130 #ifdef ALLOW_USE_MPI
131 C Setup MPI stuff here
132 nb = thisI
133 mb = nN
134 ir = 2
135 theTag = (tt-1)*MAX_NEIGHBOURS + oN
136 & + 10000*(
137 & (thisTile-1)*MAX_NEIGHBOURS + oN
138 & )
139 tProc = exch2_tProc(thisTile)-1
140 sProc = exch2_tProc(tt)-1
141 theType = MPI_REAL8
142 nri = (tIhi-tIlo+1)/tiStride
143 nrj = (tJhi-tJlo+1)/tjStride
144 nrk = (tKhi-tKlo+1)/tkStride
145 iBufr = nri*nrj*nrk
146 CALL MPI_Recv( e2Bufr1_RX(1,mb,nb,ir), iBufr, theType, sProc,
147 & theTag, MPI_COMM_MODEL, mpiStatus, mpiRc )
148 #ifdef W2_E2_DEBUG_ON
149 WRITE(messageBuffer,'(A,I4,A,I4,A)') ' RECV FROM TILE=', tt,
150 & ' (proc = ',sProc,')'
151 CALL PRINT_MESSAGE(messageBuffer,
152 I standardMessageUnit,SQUEEZE_RIGHT,
153 I myThid)
154 WRITE(messageBuffer,'(A,I4,A,I4,A)') ' INTO TILE=', thisTile,
155 & ' (proc = ',tProc,')'
156 CALL PRINT_MESSAGE(messageBuffer,
157 I standardMessageUnit,SQUEEZE_RIGHT,
158 I myThid)
159 WRITE(messageBuffer,'(A,I10)') ' TAG=', theTag
160 CALL PRINT_MESSAGE(messageBuffer,
161 I standardMessageUnit,SQUEEZE_RIGHT,
162 I myThid)
163 WRITE(messageBuffer,'(A,I4)') ' NEL=', iBufr
164 CALL PRINT_MESSAGE(messageBuffer,
165 I standardMessageUnit,SQUEEZE_RIGHT,
166 I myThid)
167 #endif /* W2_E2_DEBUG_ON */
168 C Set mb to neighbour entry
169 C Set nt to this tiles rank
170 mb = nN
171 #endif
172 ELSE
173 STOP 'EXCH2_RECV_RX1:: commSetting VALUE IS INVALID'
174 ENDIF
175
176 iBufr=0
177 DO ktl=tKlo,tKhi,tKStride
178 DO jtl=tJLo, tJHi, tjStride
179 DO itl=tILo, tIHi, tiStride
180 C Read from e2Bufr1_RX(iBufr,mb,nb)
181 iBufr=iBufr+1
182 array(itl,jtl,ktl)=e2Bufr1_RX(iBufr,mb,nb,ir)
183 ENDDO
184 ENDDO
185 ENDDO
186
187 RETURN
188 END
189
190 C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
191
192 CEH3 ;;; Local Variables: ***
193 CEH3 ;;; mode:fortran ***
194 CEH3 ;;; End: ***

  ViewVC Help
Powered by ViewVC 1.1.22