33
34
35
36 USE spmd_comm_world_mod, ONLY : spmd_comm_world
37#include "implicit_f.inc"
38
39
40
41#include "spmd.inc"
42
43
44
45#include "com01_c.inc"
46#include "task_c.inc"
47
48
49
50 INTEGER IAD_ELEM(2,*),FR_ELEM(*), NSIZ, LENR
52
53
54
55#ifdef MPI
56 INTEGER MSGTYP,I,NOD,LOC_PROC,IERROR,
57 . SIZ,J,K,L,NB_NOD,
58 . STATUS(MPI_STATUS_SIZE),
59 . IAD_SEND(NSPMD+1),IAD_RECV(NSPMD+1),
60 . REQ_R(NSPMD),REQ_S(NSPMD),MSGOFF,NSIZ1
61
62 my_real,
DIMENSION(:),
ALLOCATABLE :: sbuf,rbuf
63
64 DATA msgoff/7000/
65
66
67
68 ALLOCATE(sbuf(lenr*nsiz))
69 ALLOCATE(rbuf(lenr*nsiz))
70
71 loc_proc = ispmd+1
72 l = 1
73 iad_recv(1)=1
74
75
76 DO i=1,nspmd
77 siz = nsiz*(iad_elem(1,i+1)-iad_elem(1,i))
78 IF(siz/=0) THEN
79 msgtyp = msgoff
81 s rbuf(l),siz,real,it_spmd(i),msgtyp,
82 g spmd_comm_world,req_r(i),ierror)
83 l = l+siz
84 END IF
85 iad_recv(i+1) = l
86 END DO
87
88
89 l=1
90 iad_send(1)=1
91 nsiz1 = nsiz-1
92 DO i=1,nspmd
93 DO j=iad_elem(1,i),iad_elem(1,i+1)-1
94 nod = fr_elem(j)
95 sbuf(l:l+nsiz1) = xnorm(1:nsiz,nod)
96 l = l+nsiz
97 END DO
98 iad_send(i+1) = l
99 END DO
100
101 DO i=1,nspmd
102
103 IF(iad_elem(1,i+1)-iad_elem(1,i)>0)THEN
104
105 msgtyp = msgoff
106 siz = iad_send(i+1)-iad_send(i)
107 l = iad_send(i)
109 s sbuf(l),siz,real,it_spmd(i),msgtyp,
110 g spmd_comm_world,req_s(i),ierror)
111 ENDIF
112 END DO
113
114
115 DO i = 1, nspmd
116
117 nb_nod = iad_elem(1,i+1)-iad_elem(1,i)
118 IF(nb_nod>0)THEN
119 CALL mpi_wait(req_r(i),status,ierror)
120 l = iad_recv(i)
121
122 DO j=iad_elem(1,i),iad_elem(1,i+1)-1
123
124 nod = fr_elem(j)
125 xnorm(1:nsiz,nod) = xnorm(1:nsiz,nod) + rbuf(l:l+nsiz1)
126 l = l+nsiz
127 ENDDO
128 ENDIF
129 ENDDO
130
131 DO i = 1, nspmd
132 IF(iad_elem(1,i+1)-iad_elem(1,i)>0)THEN
133 CALL mpi_wait(req_s(i),status,ierror)
134 ENDIF
135 ENDDO
136
137 DEALLOCATE(sbuf)
138 DEALLOCATE(rbuf)
139
140#endif
141 RETURN
subroutine mpi_isend(buf, cnt, datatype, dest, tag, comm, ireq, ierr)
subroutine mpi_wait(ireq, status, ierr)
subroutine mpi_irecv(buf, cnt, datatype, source, tag, comm, ireq, ierr)