48
49
50
51
52
53
54! * rcv data if local nmn > 0 & remote nsn > 0 (--> given by sort_comm(nin)%NBIRECV)
55
56
57
58
59 USE timer_mod
60 USE fill_voxel_mod
63 USE multi_fvm_mod
66
67
68
69 USE spmd_comm_world_mod, ONLY : spmd_comm_world
70#include "implicit_f.inc"
71
72
73
74#include "spmd.inc"
75
76
77
78#include "com01_c.inc"
79#include "com04_c.inc"
80#include "task_c.inc"
81#include "timeri_c.inc"
82
83
84
85 TYPE(TIMER_) :: TIMERS
86 INTEGER NIN, IFQ, INACTI, IGAP,INTTH,NSN,NSNR,
87 . ITIED,
88 . NSNFIOLD(NSPMD),
89 . ISENDTO(NINTER+1,NSPMD+1), IRCVFROM(NINTER+1,NSPMD+1),
90 . ITYP
91 INTEGER :: GOT_PREVIEW
92 INTEGER ::
93 TYPE(inter_struct_type), DIMENSION(NINTER), INTENT(inout) :: INTER_STRUCT
94 TYPE(sorting_comm_type), DIMENSION(NINTER), INTENT(inout) :: SORT_COMM
96 INTEGER :: NSV(NSN)
97 INTEGER :: NRTM
99
100
101
102#ifdef MPI
103 INTEGER MSGTYP,INFO,I,NOD, DT_CST, LOC_PROC,P,IDEB,
104 . SIZ,J, L, BUFSIZ, LEN, NB, IERROR1, IAD,
105 . STATUS(MPI_STATUS_SIZE),IERROR,REQ_SB(NSPMD),
106 . REQ_RB(NSPMD),KK,NBIRECV,IRINDEXI(NSPMD),
107 . REQ_RD(NSPMD),REQ_SD(NSPMD),
108 . REQ_RC(NSPMD),REQ_SC(NSPMD),
109 . INDEXI,ISINDEXI(NSPMD),
110 . MSGOFF, MSGOFF2, MSGOFF3, MSGOFF4, MSGOFF5,
111 . RSIZ, ISIZ, L2, REQ_RD2(NSPMD),
112 . LEN2, RSHIFT, ISHIFT, ND, JDEB, Q, NBB
113
114 INTEGER :: P_LOC
115 INTEGER :: KEY,CODE
116
117 DATA msgoff4/6026/
118 DATA msgoff5/6027/
119
121 . xmaxb,ymaxb,zmaxb,xminb,yminb,zminb
122
123 INTEGER, DIMENSION(:), ALLOCATABLE :: ITAGNSNFI
124 my_real,
DIMENSION(:,:),
ALLOCATABLE :: xtmp
125 INTEGER :: ADRESS, LOCAL_RANK
126 INTEGER :: SIZE_S
127 INTEGER :: OFFSET(NSPMD)
128 INTEGER :: DUMMY(1)
129
130
131
132
133
134
135
136
137 loc_proc = ispmd + 1
138
139 IF(inacti==5.OR.inacti==6.OR.inacti==7.OR.ifq>0
140 . .OR.itied/=0.OR.ityp==23.OR.ityp==24
141 . .OR.ityp==25) THEN
142 DO p = 1, nspmd
143 nsnfiold(p) = inter_struct(nin)%NSNFIOLD(p)
144 END DO
145 END IF
146 nsnr = sort_comm(nin)%NSNR
147 offset(1:nspmd) = nsnr+1
148
149
150 IF(.NOT. (ircvfrom(nin,loc_proc)==0.AND.isendto(nin,loc_proc)==0)) THEN
151
152 IF (imonm > 0)
CALL startime(timers,25)
153
154
155
156
157 IF(ircvfrom(nin,loc_proc)/=0) THEN
158
159 rsiz = sort_comm(nin)%RSIZ
160 isiz = sort_comm(nin)%ISIZ
161
162 IF(nsnr>0) THEN
163
164 ALLOCATE(xrem(rsiz,nsnr),stat=ierror)
165 ALLOCATE(
irem(isiz,nsnr),stat=ierror)
166
167
168 IF(ierror/=0) THEN
169 CALL ancmsg(msgid=20,anmode=aninfo)
171 ENDIF
172 ideb = 1
173 DO l = 1, sort_comm(nin)%NBIRECV
174 p = sort_comm(nin)%ISINDEXI(l)
175 len =
nsnfi(nin)%P(p)*rsiz
176 msgtyp = msgoff4
177 offset(l) = ideb
179 1 xrem(1,ideb),len,real,it_spmd(p),
180 2 msgtyp,spmd_comm_world,req_rd(l),ierror)
181
182 len2 =
nsnfi(nin)%P(p)*isiz
183 msgtyp = msgoff5
185 1
irem(1,ideb),len2,mpi_integer,it_spmd(p),
186 2 msgtyp,spmd_comm_world,req_rd2(l),ierror)
187 ideb = ideb +
nsnfi(nin)%P(p)
188 ENDDO
189 ENDIF
190 ENDIF
191
192
193
194
195 DO p=1,nspmd
196 IF(p/=loc_proc) THEN
197 IF(sort_comm(nin)%NB(p)/=0 ) THEN
198 msgtyp = msgoff4
199 size_s = sort_comm(nin)%NB(p) * sort_comm(nin)%RSIZ
201 1 sort_comm(nin)%DATA_PROC(p)%RBUF(1),size_s,real,it_spmd(p),msgtyp,
202 2 spmd_comm_world,sort_comm(nin)%REQ_SD2(p),ierror)
203 msgtyp = msgoff5
204 size_s = sort_comm(nin)%NB(p) * sort_comm(nin)%ISIZ
206 1 sort_comm(nin)%DATA_PROC(p)%IBUF(1),size_s,mpi_integer,
207 2 it_spmd(p),msgtyp,
208 3 spmd_comm_world,sort_comm(nin)%REQ_SD3(p),ierror)
209 ENDIF
210 ENDIF
211 ENDDO
212
213
214
215 if(got_preview == 1) THEN
216
217 CALL fill_voxel_local_partial(nsn,nsv,nsnr,nrtm,numnod,x,stfns,inter_struct(nin),dummy,0)
218 ENDIF
219
220
221
222
223 IF(ircvfrom(nin,loc_proc)/=0) THEN ! nmn > 0
224 IF(nsnr>0) THEN
225 DO l = 1, sort_comm(nin)%NBIRECV
226 CALL mpi_waitany(sort_comm(nin)%NBIRECV,req_rd,indexi,status,ierror)
227
228
229
230 if(got_preview==1) then
231 call fill_voxel_remote(
232 . offset(indexi),
233 . offset(indexi+1)-1,
234 . nsn,
235 . nsnr,
236 . inter_struct(nin)%nbx,
237 . inter_struct(nin)%nby,
238 . inter_struct(nin)%nbz,
239 . size(xrem,1),
240 . inter_struct(nin)%voxel,
241 . inter_struct(nin)%next_nod,
242 . inter_struct(nin)%size_node,
243 . inter_struct(nin)%nb_voxel_on,
244 . inter_struct(nin)%list_nb_voxel_on,
245 . inter_struct(nin)%last_nod,
246 . xrem,
247 . inter_struct(nin)%box_limit_main)
248 endif
249 CALL mpi_wait(req_rd2(indexi),status,ierror)
250
251
252 ENDDO
253
257 ENDIF
258 ENDIF
259
260
261
262
263 IF(isendto(nin,loc_proc)/=0) THEN
264 DO p = 1, nspmd
265 IF(ircvfrom(nin,p)/=0) THEN
266 IF(p/=loc_proc) THEN
267 IF(sort_comm(nin)%NB(p)/=0) THEN
268 IF(nmn/=0) THEN
269 CALL mpi_wait(sort_comm(nin)%REQ_SD2(p),status,ierror)
270 DEALLOCATE(sort_comm(nin)%DATA_PROC(p)%RBUF)
271
272 CALL mpi_wait(sort_comm(nin)%REQ_SD3(p),status,ierror)
273 DEALLOCATE(sort_comm(nin)%DATA_PROC(p)%IBUF)
274 sort_comm(nin)%NB(p) = 0
275 ENDIF
276 END IF
277 ENDIF
278 ENDIF
279 ENDDO
280 ENDIF
281
282 ELSE
283
284 if(got_preview == 1) THEN
285
286 CALL fill_voxel_local_partial(nsn,nsv,nsnr,nrtm,numnod,x,stfns,inter_struct(nin),dummy,0)
287 ENDIF
288
289 ENDIF
290
291 IF (imonm > 0)
CALL stoptime(timers,25)
292#endif
293 RETURN
294
subroutine mpi_isend(buf, cnt, datatype, dest, tag, comm, ireq, ierr)
subroutine mpi_wait(ireq, status, ierr)
subroutine mpi_waitany(cnt, array_of_requests, index, status, ierr)
subroutine mpi_irecv(buf, cnt, datatype, source, tag, comm, ireq, ierr)
type(int_pointer), dimension(:), allocatable nsnfi
integer, dimension(:,:), allocatable irem
subroutine ancmsg(msgid, msgtype, anmode, i1, i2, i3, i4, i5, i6, i7, i8, i9, i10, i11, i12, i13, i14, i15, i16, i17, i18, i19, i20, r1, r2, r3, r4, r5, r6, r7, r8, r9, c1, c2, c3, c4, c5, c6, c7, c8, c9, prmode)
subroutine startime(event, itask)
subroutine stoptime(event, itask)