3
4
5
6
7
8
9
10 INTEGER IA, IC, JA, JC, M, N
11 REAL ALPHA, BETA
12
13
14 INTEGER DESCA( * ), DESCC( * )
15 REAL A( * ), C( * )
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137 INTEGER BLOCK_CYCLIC_2D, CSRC_, CTXT_, DLEN_, DTYPE_,
138 $ LLD_, MB_, M_, NB_, N_, RSRC_
139 parameter( block_cyclic_2d = 1, dlen_ = 9, dtype_ = 1,
140 $ ctxt_ = 2, m_ = 3, n_ = 4, mb_ = 5, nb_ = 6,
141 $ rsrc_ = 7, csrc_ = 8, lld_ = 9 )
142 REAL ZERO, ONE
143 parameter( zero = 0.0e+0, one = 1.0e+0 )
144
145
146 INTEGER I, IACOL, IAROW, ICCOL, ICOFF, ICROW, IIA,
147 $ IIC, IOFFA, IOFFC, IROFF, J, JJA, JJC, LDA,
148 $ LDC, MP, MYCOL, MYROW, NPCOL, NPROW, NQ
149
150
151 EXTERNAL blacs_gridinfo,
infog2l
152
153
154 INTEGER NUMROC
156
157
158
159
160
161 CALL blacs_gridinfo( desca(ctxt_), nprow, npcol, myrow, mycol )
162
163
164
165 IF( (m.EQ.0).OR.(n.EQ.0).OR.
166 $ ((alpha.EQ.zero).AND.(beta.EQ.one)) )
167 $ RETURN
168
169 CALL infog2l( ia, ja, desca, nprow, npcol, myrow, mycol,
170 $ iia, jja, iarow, iacol )
171 CALL infog2l( ic, jc, descc, nprow, npcol, myrow, mycol,
172 $ iic, jjc, icrow, iccol )
173
174 iroff = mod( ia-1, desca(mb_) )
175 icoff = mod( ja-1, desca(nb_) )
176 mp =
numroc( m+iroff, desca(mb_), myrow, iarow, nprow )
177 nq =
numroc( n+icoff, desca(nb_), mycol, iacol, npcol )
178 IF( myrow.EQ.iarow )
179 $ mp = mp-iroff
180 IF( mycol.EQ.iacol )
181 $ nq = nq-icoff
182 lda = desca(lld_)
183 ldc = descc(lld_)
184
185 IF( nq.EQ.1 ) THEN
186 IF( beta.EQ.zero ) THEN
187 IF( alpha.EQ.zero ) THEN
188 ioffc = iic + (jjc-1)*ldc
189 DO 10 i = ioffc, ioffc+mp-1
190 c( i ) = zero
191 10 CONTINUE
192 ELSE
193 ioffa = iia + (jja-1)*lda
194 ioffc = iic + (jjc-1)*ldc
195 DO 20 i = ioffc, ioffc+mp-1
196 c( i ) = alpha * a( ioffa )
197 ioffa = ioffa + 1
198 20 CONTINUE
199 END IF
200 ELSE
201 IF( alpha.EQ.one ) THEN
202 IF( beta.EQ.one ) THEN
203 ioffa = iia + (jja-1)*lda
204 ioffc = iic + (jjc-1)*ldc
205 DO 30 i = ioffc, ioffc+mp-1
206 c( i ) = c( i ) + a( ioffa )
207 ioffa = ioffa + 1
208 30 CONTINUE
209 ELSE
210 ioffa = iia + (jja-1)*lda
211 ioffc = iic + (jjc-1)*ldc
212 DO 40 i = ioffc, ioffc+mp-1
213 c( i ) = beta * c( i ) + a( ioffa )
214 ioffa = ioffa + 1
215 40 CONTINUE
216 END IF
217 ELSE IF( beta.EQ.one ) THEN
218 ioffa = iia + (jja-1)*lda
219 ioffc = iic + (jjc-1)*ldc
220 DO 50 i = ioffc, ioffc+mp-1
221 c( i ) = c( i ) + alpha * a( ioffa )
222 ioffa = ioffa + 1
223 50 CONTINUE
224 ELSE
225 ioffa = iia + (jja-1)*lda
226 ioffc = iic + (jjc-1)*ldc
227 DO 60 i = ioffc, ioffc+mp-1
228 c( i ) = beta * c( i ) + alpha * a( ioffa )
229 ioffa = ioffa + 1
230 60 CONTINUE
231 END IF
232 END IF
233 ELSE
234 IF( beta.EQ.zero ) THEN
235 IF( alpha.EQ.zero ) THEN
236 ioffc = iic+(jjc-1)*ldc
237 DO 80 j = 1, nq
238 DO 70 i = ioffc, ioffc+mp-1
239 c( i ) = zero
240 70 CONTINUE
241 ioffc = ioffc + ldc
242 80 CONTINUE
243 ELSE
244 ioffa = iia+(jja-1)*lda
245 ioffc = iic+(jjc-1)*ldc
246 DO 100 j = 1, nq
247 DO 90 i = ioffc, ioffc+mp-1
248 c( i ) = alpha * a( ioffa )
249 ioffa = ioffa + 1
250 90 CONTINUE
251 ioffa = ioffa + lda - mp
252 ioffc = ioffc + ldc
253 100 CONTINUE
254 END IF
255 ELSE
256 IF( alpha.EQ.one ) THEN
257 IF( beta.EQ.one ) THEN
258 ioffa = iia+(jja-1)*lda
259 ioffc = iic+(jjc-1)*ldc
260 DO 120 j = 1, nq
261 DO 110 i = ioffc, ioffc+mp-1
262 c( i ) = c( i ) + a( ioffa )
263 ioffa = ioffa + 1
264 110 CONTINUE
265 ioffa = ioffa + lda - mp
266 ioffc = ioffc + ldc
267 120 CONTINUE
268 ELSE
269 ioffa = iia+(jja-1)*lda
270 ioffc = iic+(jjc-1)*ldc
271 DO 140 j = 1, nq
272 DO 130 i = ioffc, ioffc+mp-1
273 c( i ) = beta * c( i ) + a( ioffa )
274 ioffa = ioffa + 1
275 130 CONTINUE
276 ioffa = ioffa + lda - mp
277 ioffc = ioffc + ldc
278 140 CONTINUE
279 END IF
280 ELSE IF( beta.EQ.one ) THEN
281 ioffa = iia+(jja-1)*lda
282 ioffc = iic+(jjc-1)*ldc
283 DO 160 j = 1, nq
284 DO 150 i = ioffc, ioffc+mp-1
285 c( i ) = c( i ) + alpha * a( ioffa )
286 ioffa = ioffa + 1
287 150 CONTINUE
288 ioffa = ioffa + lda - mp
289 ioffc = ioffc + ldc
290 160 CONTINUE
291 ELSE
292 ioffa = iia+(jja-1)*lda
293 ioffc = iic+(jjc-1)*ldc
294 DO 180 j = 1, nq
295 DO 170 i = ioffc, ioffc+mp-1
296 c( i ) = beta * c( i ) + alpha * a( ioffa )
297 ioffa = ioffa + 1
298 170 CONTINUE
299 ioffa = ioffa + lda - mp
300 ioffc = ioffc + ldc
301 180 CONTINUE
302 END IF
303 END IF
304 END IF
305
306 RETURN
307
308
309
subroutine infog2l(grindx, gcindx, desc, nprow, npcol, myrow, mycol, lrindx, lcindx, rsrc, csrc)
integer function numroc(n, nb, iproc, isrcproc, nprocs)