43
44
45
48#ifdef WITH_ASSERT
50#endif
51
52
53
54#include "implicit_f.inc"
55#include "comlock.inc"
56
57
58
59#include "mvsiz_p.inc"
60#include "assert.inc"
61#include "i25edge_c.inc"
62
63
64
65 INTEGER, INTENT(IN) :: S_STFE
66 INTEGER IRECT(4,*),CAND_M(*), CAND_S(*), IFPEN(*),
67 . I_STOK, NIN,IGAP ,ITASK, COUNT_REMSLVE(*),
68 . IEDGE, NEDGE, LEDGE(NLEDGE,*), MVOISIN(4,*), NSV(*), NRTM, IGAP0,IFQ
69 my_real ,
INTENT(IN) :: dgapload ,drad
71 . x(3,*),gap_m(*),v(3,*),stf(*),gap_m_l(*), gape(*), gap_e_l(*),
72 . stfe(s_stfe), cand_fx(4,*),cand_fy(4,*),cand_fz(4,*)
73
74
75
76
77#include "task_c.inc"
78#include "com01_c.inc"
79#include "param_c.inc"
80#include "parit_c.inc"
81
82
83
84 INTEGER I , L, IE, JE, NN1, NN2, SOL_EDGE, SH_EDGE,
85 . NRTMFT, NRTMLT
87 . x1s,x2s,y1s,y2s,z1s,z2s,
88 . x1,x2,x3,x4,
89 . y1,y2,y3,y4,
90 . z1,z2,z3,z4,
91 .
92 .
93 .
94 . xmins,xmaxs,ymins,ymaxs,zmins,zmaxs,
95 . xminm,xmaxm,yminm,ymaxm,zminm,zmaxm,
96 .
97 . dxm,dym,dzm,
98 . gapvd,s
99 INTEGER MSEG,CT
101 . gapv(mvsiz)
102 INTEGER LIST(MVSIZ), LISTI(MVSIZ)
103 INTEGER IS,JS,LS,NLS,NLT,NSEG,NLF,II,NLS2
104 INTEGER N1(MVSIZ),N2(MVSIZ)
105 INTEGER SG, FIRST, LAST,COUNT_CAND
106 INTEGER, DIMENSION(:),ALLOCATABLE ::
108 . DIMENSION(:,:),ALLOCATABLE :: boxm
109 SAVE tagm,boxm
110 INTEGER :: J
111 INTEGER :: MY_SIZE
112 INTEGER, DIMENSION(:), ALLOCATABLE :: LIST_REAL_CANDIDATE
113
114
115 sol_edge=iedge/10
116 sh_edge =iedge-10*sol_edge
117
118 count_cand = 0
119 ct = 0
120 mseg = nvsiz
121 first = 1 + i_stok*itask / nthread
122 last = i_stok*(itask+1) / nthread
123 my_size = last - first + 1
124 ALLOCATE( list_real_candidate(my_size) )
125
126 IF(sol_edge/=0)THEN
127
128 IF(itask==0)THEN
129 ALLOCATE(tagm(nrtm),boxm(6,nrtm))
130 tagm(1:nrtm)=0
131 END IF
132
134
135 DO i=first,last
136 l = cand_m(i)
137 IF(stf(l)/=zero)tagm(l)=1
138 END DO
139
141
142 nrtmft=1 + nrtm*itask / nthread
143 nrtmlt=nrtm*(itask+1) / nthread
144
145 DO l=nrtmft,nrtmlt
146
147 boxm(1,l)= ep30
148 boxm(2,l)=-ep30
149 boxm(3,l)= ep30
150 boxm(4,l)=-ep30
151 boxm(5,l)= ep30
152 boxm(6,l)=-ep30
153
154 IF(tagm(l)/=0)THEN
155
156 x1=x(1,irect(1,l))
157 y1=x(2,irect(1,l))
158 z1=x(3,irect(1,l))
159 x2=x(1,irect(2,l))
160 y2=x(2,irect(2,l))
161 z2=x(3,irect(2,l))
162 x3=x(1,irect(3,l))
163 y3=x(2,irect(3,l))
164 z3=x(3,irect(3,l))
165 x4=x(1,irect(4,l))
166 y4=x(2,irect(4,l))
167 z4=x(3,irect(4,l))
168
169 xminm =
min(x1,x2,x3,x4)
170 xmaxm =
max(x1,x2,x3,x4)
171 dxm = em02*(xmaxm-xminm)
172 xminm = xminm-dxm
173 xmaxm = xmaxm+dxm
174
175 yminm =
min(y1,y2,y3,y4)
176 ymaxm =
max(y1,y2,y3,y4)
177 dym = em02*(ymaxm-yminm)
178 yminm = yminm-dym
179 ymaxm = ymaxm+dym
180
181 zminm =
min(z1,z2,z3,z4)
182 zmaxm =
max(z1,z2,z3,z4)
183 dzm = em02*(zmaxm-zminm)
184 zminm = zminm-dzm
185 zmaxm = zmaxm+dzm
186
187 boxm(1,l)=xminm
188 boxm(2,l)=xmaxm
189 boxm(3,l)=yminm
190 boxm(4,l)=ymaxm
191 boxm(5,l)=zminm
192 boxm(6,l)=zmaxm
193
194 END IF
195 END DO
196
198
199 END IF
200
201 js = first-1
202 DO sg = first,last,mseg
203 nseg =
min(mseg,last-js)
204
205
206
207 IF(nspmd>1) THEN
208
209
210
211 nls = 0
212 nls2 = nseg+1
213 DO is = 1, nseg
214 i=js+is
215 IF(cand_s(i)<=nedge)THEN
216
217 IF(sh_edge==1.AND.
218 . ledge(7,cand_s(i))/=1.AND.
219 . ledge(3,cand_s(i))/=0) cycle
220 nls=nls+1
221 listi(nls)=is
222
223#ifdef WITH_ASSERT
224
229 debug_e2e(
int_checksum(ids,4,1)==d_em .AND. ledge(8,cand_s(i)) == d_es,i)
230#endif
231
232 ELSE
233 IF(sh_edge==1.AND.
234 .
ledge_fie(nin)%P(e_type,cand_s(i)-nedge)/=1.AND.
235 .
ledge_fie(nin)%P(e_right_seg,cand_s(i)-nedge)/=0) cycle
236 nls2=nls2-1
237 assert(is <= mvsiz)
238 assert(is > 0)
239 listi(nls2) = is
240#ifdef WITH_ASSERT
241
247#endif
248 ENDIF
249 ENDDO
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267 ELSE
268 nls = 0
269
270 DO is=1,nseg
271 i=js+is
272 IF(sh_edge==1.AND.
273 . ledge(7,cand_s(i))/=1.AND.
274 . ledge(3,cand_s(i))/=0) cycle
275
276
277#ifdef WITH_ASSERT
282 debug_e2e(
int_checksum(ids,4,1)==d_em.AND.ledge(8,cand_s(i)) == d_es,i)
283#endif
284
285 nls=nls+1
286 listi(nls)=is
287 ENDDO
288 ENDIF
289
290
291
292#include "vectorize.inc"
293 DO ls = 1, nls
294 is = listi(ls)
295 i=js+is
296 ie=cand_m(i)
297 je=cand_s(i)
298 gapv(is)=gape(je)
299 IF(sh_edge /= 0 .AND. igap0 /= 0) gapv(is)=two*gapv(is)
300 IF(igap==3)
301 . gapv(is)=
min(gapv(is),gap_m_l(ie)+gap_e_l(je))
302 gapv(is)=
max(gapv(is)+dgapload,drad)
303 ENDDO
304
305
306 nlf = 1
307 nlt = nls
308 nls = 0
309
310 DO ls = nlf, nlt
311 is = listi(ls)
312 i = js + is
313
314
315
316 l = ledge(1,cand_s(i))
317 s = zero
318#ifdef WITH_ASSERT
323 debug_e2e(
int_checksum(ids,4,1)==d_em .AND. ledge(8,cand_s(i)) == d_es,l)
324 debug_e2e(
int_checksum(ids,4,1)==d_em .AND. ledge(8,cand_s(i)) == d_es,ledge(ledge_weight,cand_s(i)))
325#endif
326
327 IF( l > 0 ) THEN
328 s = stfe(cand_s(i))
329 ELSEIF (l < 0) THEN
330
331
332
333 s = one
334
335 ENDIF
336
337#ifdef WITH_ASSERT
338 debug_e2e(
int_checksum(ids,4,1)==d_em .AND. ledge(8,cand_s(i)) == d_es,s)
339#endif
340
341 IF (s/=zero) THEN
342 n1(is)= ledge(5,cand_s(i))
343 n2(is)= ledge(6,cand_s(i))
344 z1s=x(3,n1(is))
345 z2s=x(3,n2(is))
346 gapvd = gapv(is)
347 zmins =
min(z1s,z2s)-gapvd
348 zmaxs =
max(z1s,z2s)+gapvd
349 zminm = boxm(5,cand_m(i))
350 zmaxm = boxm(6,cand_m(i))
351 zminm = zminm-gapvd
352 zmaxm = zmaxm+gapvd
353#ifdef WITH_ASSERT
358 debug_e2e(
int_checksum(ids,4,1)==d_em .AND. ledge(8,cand_s(i)) == d_es,zmaxs)
359 debug_e2e(
int_checksum(ids,4,1)==d_em .AND. ledge(8,cand_s(i)) == d_es,zmins)
360 debug_e2e(
int_checksum(ids,4,1)==d_em .AND. ledge(8,cand_s(i)) == d_es,zmaxm)
361 debug_e2e(
int_checksum(ids,4,1)==d_em .AND. ledge(8,cand_s(i)) == d_es,zminm)
362#endif
363
364 IF (zmaxs>=zminm.AND.zmaxm>=zmins) THEN
365 nls=nls+1
366 list(nls)=is
367 ENDIF
368 ENDIF
369 ENDDO
370
371 nlt=nls
372 nls=0
373
374 DO ls=nlf,nlt
375 is=list(ls)
376 i=js+is
377 y1s=x(2,n1(is))
378 y2s=x(2,n2(is))
379 gapvd = gapv(is)
380 ymins =
min(y1s,y2s)-gapvd
381 ymaxs =
max(y1s,y2s)+gapvd
382 yminm = boxm(3,cand_m(i))
383 ymaxm = boxm(4,cand_m(i))
384 yminm = yminm-gapvd
385 ymaxm = ymaxm+gapvd
386#ifdef WITH_ASSERT
391 debug_e2e(
int_checksum(ids,4,1)==d_em .AND. ledge(8,cand_s(i)) == d_es,ymaxs)
392 debug_e2e(
int_checksum(ids,4,1)==d_em .AND. ledge(8,cand_s(i)) == d_es,ymins)
393 debug_e2e(
int_checksum(ids,4,1)==d_em .AND. ledge(8,cand_s(i)) == d_es,ymaxm)
394 debug_e2e(
int_checksum(ids,4,1)==d_em .AND. ledge(8,cand_s(i)) == d_es,yminm)
395#endif
396
397 IF (ymaxs>=yminm.AND.ymaxm>=ymins) THEN
398 nls=nls+1
399 list(nls)=is
400 ENDIF
401 ENDDO
402
403 nlt = nls
404 nls=0
405
406 DO ls=nlf,nlt
407 is=list(ls)
408 i=js+is
409 x1s=x(1,n1(is))
410 x2s=x(1,n2(is))
411 gapvd = gapv(is)
412 xmins =
min(x1s,x2s)-gapvd
413 xmaxs =
max(x1s,x2s)+gapvd
414 xminm = boxm(1,cand_m(i))
415 xmaxm = boxm(2,cand_m(i))
416 xminm = xminm-gapvd
417 xmaxm = xmaxm+gapvd
418#ifdef WITH_ASSERT
423 debug_e2e(
int_checksum(ids,4,1)==d_em .AND. ledge(8,cand_s(i)) == d_es,xmaxs)
424 debug_e2e(
int_checksum(ids,4,1)==d_em .AND. ledge(8,cand_s(i)) == d_es,xmins)
425 debug_e2e(
int_checksum(ids,4,1)==d_em .AND. ledge(8,cand_s(i)) == d_es,xmaxm)
426 debug_e2e(
int_checksum(ids,4,1)==d_em .AND. ledge(8,cand_s(i)) == d_es,xminm)
427#endif
428
429 IF (xmaxs>=xminm.AND.xmaxm>=xmins) THEN
430 cand_s(i) = -cand_s(i)
431 count_cand = count_cand+1
432 list_real_candidate(count_cand) = i
433 ENDIF
434 ENDDO
435
436 IF(nspmd>1)THEN
437 nlf = nls2
438 nlt = nseg
439
440 DO ls = nlf, nlt
441 is = listi(ls)
442 i=js+is
443 ie=cand_m(i)
444 gapv(is)=
gapfie(nin)%P(cand_s(i)-nedge)
445 IF(sh_edge /= 0 .AND. igap0 /= 0) gapv(is)=two*gapv(is)
446
447 IF(igap==3)
448 . gapv(is)=
min(gapv(is),
gape_l_fie(nin)%P(cand_s(i)-nedge)+gap_m_l(ie))
449 gapv(is)=
max(gapv(is)+dgapload,drad)
450 ENDDO
451
452 nls=0
453
454 DO ls = nlf, nlt
455
456 is = listi(ls)
457 i=js+is
458 ii = cand_s(i)-nedge
459#ifdef WITH_ASSERT
465#endif
466
467 IF (
stifie(nin)%P(ii)/=zero)
THEN
468 nn1 = 2*(ii-1)+1
469 nn2 = 2*ii
470 z1s=
xfie(nin)%P(3,nn1)
471 z2s=
xfie(nin)%P(3,nn2)
472
473
474 gapvd = gapv(is)
475 zmins =
min(z1s,z2s)-gapvd
476 zmaxs =
max(z1s,z2s)+gapvd
477 zminm = boxm(5,cand_m(i))
478 zmaxm = boxm(6,cand_m(i))
479 zminm = zminm-gapvd
480 zmaxm = zmaxm+gapvd
481#ifdef WITH_ASSERT
486 debug_e2e(
int_checksum(ids,4,1)==d_em .AND.
ledge_fie(nin)%P(e_global_id,cand_s(i)-nedge) == d_es,zmaxs
489 debug_e2e(
int_checksum(ids,4,1)==d_em .AND.
ledge_fie(nin)%P(e_global_id,cand_s(i)-nedge) == d_es,zminm)
490#endif
491
492 IF (zmaxs>=zminm.AND.zmaxm>=zmins) THEN
493 nls=nls+1
494 list(nls)=is
495 ENDIF
496
497 ENDIF
498 ENDDO
499
500 nlf=1
501 nlt=nls
502 nls=0
503
504 DO ls=nlf,nlt
505 is=list(ls)
506 i=js+is
507 ii = cand_s(i)-nedge
508 nn1 = 2*(ii-1)+1
509 nn2 = 2*ii
510 y1s=
xfie(nin)%P(2,nn1)
511 y2s=
xfie(nin)%P(2,nn2)
512
513
514 gapvd = gapv(is)
515 ymins =
min(y1s,y2s)-gapvd
516 ymaxs =
max(y1s,y2s)+gapvd
517 yminm = boxm(3,cand_m(i))
518 ymaxm = boxm(4,cand_m(i))
519 yminm = yminm-gapvd
520 ymaxm = ymaxm+gapvd
521
522#ifdef WITH_ASSERT
527 debug_e2e(
int_checksum(ids,4,1)==d_em .AND.
ledge_fie(nin)%P(e_global_id,cand_s(i)-nedge) == d_es,ymaxs)
528 debug_e2e(
int_checksum(ids,4,1)==d_em .AND.
ledge_fie(nin)%P(e_global_id,cand_s(i)-nedge) == d_es,ymins)
529 debug_e2e(
int_checksum(ids,4,1)==d_em .AND.
ledge_fie(nin)%P(e_global_id,cand_s(i)-nedge) == d_es,ymaxm)
530 debug_e2e(
int_checksum(ids,4,1)==d_em .AND.
ledge_fie(nin)%P(e_global_id,cand_s(i)-nedge) == d_es,yminm)
531#endif
532
533 IF (ymaxs>=yminm.AND.ymaxm>=ymins) THEN
534 nls=nls+1
535 list(nls)=is
536 ENDIF
537 ENDDO
538
539 DO ls=nlf,nls
540 is=list(ls)
541 i=js+is
542 ii = cand_s(i)-nedge
543 nn1 = 2*(ii-1)+1
544 nn2 = 2*ii
545 x1s=
xfie(nin)%P(1,nn1)
546 x2s=
xfie(nin)%P(1,nn2)
547 gapvd = gapv(is)
548 xmins =
min(x1s,x2s)-gapvd
549 xmaxs =
max(x1s,x2s)+gapvd
550 xminm = boxm(1,cand_m(i))
551 xmaxm = boxm(2,cand_m(i))
552 xminm = xminm-gapvd
553 xmaxm = xmaxm+gapvd
554#ifdef WITH_ASSERT
559 debug_e2e(
int_checksum(ids,4,1)==d_em .AND.
ledge_fie(nin)%P(e_global_id,cand_s(i)-nedge) == d_es,xmaxs)
560 debug_e2e(
int_checksum(ids,4,1)==d_em .AND.
ledge_fie(nin)%P(e_global_id,cand_s(i)-nedge) == d_es,xmins)
561 debug_e2e(
int_checksum(ids,4,1)==d_em .AND.
ledge_fie(nin)%P(e_global_id,cand_s(i)-nedge) == d_es,xmaxm)
562 debug_e2e(
int_checksum(ids,4,1)==d_em .AND.
ledge_fie(nin)%P(e_global_id,cand_s(i)-nedge) == d_es,xminm)
563#endif
564
565 IF (xmaxs>=xminm.AND.xmaxm>=xmins) THEN
566
567 cand_s(i) = -cand_s(i)
568 count_cand = count_cand+1
569 ct = ct+1
570 list_real_candidate(count_cand) = i
571
572 ENDIF
573 ENDDO
575 END IF
576 js = js + nseg
577 ENDDO
578 IF (ifq > 0) THEN
579#include "vectorize.inc"
580 DO j=1,count_cand
581 i = list_real_candidate(j)
582 IF(ifpen(i) == 0 ) THEN
583 cand_fx(1:4,i) = zero
584 cand_fy(1:4,i) = zero
585 cand_fz(1:4,i) = zero
586 ENDIF
587 ENDDO
588 DO i=first,last
589 ifpen(i) = 0
590 ENDDO
591 ENDIF
592
593#include "lockon.inc"
594 lskyi_count=lskyi_count+count_cand*5
595 count_remslve(nin)=count_remslve(nin)+ct
596#include "lockoff.inc"
597
598
599
600 IF(sol_edge/=0)THEN
601
603
604 IF(itask==0)DEALLOCATE(tagm,boxm)
605
606 END IF
607
608 DEALLOCATE( list_real_candidate )
609
610 RETURN
integer, dimension(:), allocatable itab_debug
User Node Identifiers.
pure integer function int_checksum(a, siz1, siz2)
type(real_pointer), dimension(:), allocatable gape_l_fie
type(int_pointer2), dimension(:), allocatable ledge_fie
type(real_pointer), dimension(:), allocatable gapfie
type(real_pointer2), dimension(:), allocatable xfie
type(real_pointer), dimension(:), allocatable stifie