32
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 "com04_c.inc"
47#include "task_c.inc"
48
49
50
51 INTEGER IAD_ELEM(2,*),FR_ELEM(*), SIZE, LENR,WEIGHT_MD(*)
53
54
55
56#ifdef MPI
57 INTEGER MSGTYP,I,NOD,LOC_PROC,IERROR,
58 . SIZ,J,K,L,NB_NOD,
59 . STATUS(MPI_STATUS_SIZE),
60 . IAD_SEND(NSPMD+1),IAD_RECV(NSPMD+1),
61 . REQ_R(NSPMD),REQ_S(NSPMD),MSGOFF
62
63 my_real,
DIMENSION(:),
ALLOCATABLE :: sbuf,rbuf
64 DATA msgoff/7001/
65
66
67
68 ALLOCATE(sbuf(lenr+1))
69 ALLOCATE(rbuf(lenr+1))
70
71 loc_proc = ispmd+1
72 l = 1
73 iad_recv(1)=1
74
75
76 DO i=1,nspmd
77 siz = 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
90 l=1
91 iad_send(1)=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) = adm(nod)
96 l = l+1
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
106 msgtyp = msgoff
107 siz = iad_send(i+1)-iad_send(i)
108 l = iad_send(i)
109
111 s sbuf(l),siz,real,it_spmd(i),msgtyp,
112 g spmd_comm_world,req_s(i),ierror)
113 ENDIF
114 END DO
115
116 DO i = 1, nspmd
117
118 nb_nod = iad_elem(1,i+1)-iad_elem(1,i)
119 IF(nb_nod>0)THEN
120 CALL mpi_wait(req_r(i),status,ierror)
121 l = iad_recv(i)
122
123 DO j=iad_elem(1,i),iad_elem(1,i+1)-1
124
125 nod = fr_elem(j)
126 adm(nod) = adm(nod) + rbuf(l)
127 l = l+1
128 ENDDO
129 ENDIF
130 ENDDO
131
132 DO i = 1, nspmd
133 IF(iad_elem(1,i+1)-iad_elem(1,i)>0)THEN
134 CALL mpi_wait(req_s(i),status,ierror)
135 ENDIF
136 ENDDO
137
138
139
140 DO i = 1, numnod
141 IF(weight_md(i)==0) adm(i) = zero
142 ENDDO
143
144 DEALLOCATE(sbuf)
145 DEALLOCATE(rbuf)
146
147#endif
148 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)