1 SUBROUTINE pzmatadd( M, N, ALPHA, A, IA, JA, DESCA, BETA, C, IC,
10 INTEGER IA, IC, JA, JC, M, N
11 COMPLEX*16 ALPHA, BETA
14 INTEGER DESCA( * ), DESCC( * )
15 COMPLEX*16 A( * ), C( * )
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 )
143 parameter( zero = ( 0.0d+0, 0.0d+0 ),
144 $ one = ( 1.0d+0, 0.0d+0 ) )
147 INTEGER I, IACOL, IAROW, ICCOL, ICOFF, ICROW, IIA,
148 $ iic, ioffa, ioffc, iroff, j, jja, jjc, lda,
149 $ ldc, mp, mycol, myrow, npcol, nprow, nq
152 EXTERNAL blacs_gridinfo,
infog2l
162 CALL blacs_gridinfo( desca(ctxt_), nprow, npcol, myrow, mycol )
166 IF( (m.EQ.0).OR.(n.EQ.0).OR.
167 $ ((alpha.EQ.zero).AND.(beta.EQ.one)) )
170 CALL infog2l( ia, ja, desca, nprow, npcol, myrow, mycol,
171 $ iia, jja, iarow, iacol )
172 CALL infog2l( ic, jc, descc, nprow, npcol, myrow, mycol,
173 $ iic, jjc, icrow, iccol )
175 iroff = mod( ia-1, desca(mb_) )
176 icoff = mod( ja-1, desca(nb_) )
177 mp = numroc( m+iroff, desca(mb_), myrow, iarow, nprow )
178 nq = numroc( n+icoff, desca(nb_), mycol, iacol, npcol )
187 IF( beta.EQ.zero )
THEN
188 IF( alpha.EQ.zero )
THEN
189 ioffc = iic + (jjc-1)*ldc
190 DO 10 i = ioffc, ioffc+mp-1
194 ioffa = iia + (jja-1)*lda
195 ioffc = iic + (jjc-1)*ldc
196 DO 20 i = ioffc, ioffc+mp-1
197 c( i ) = alpha * a( ioffa )
202 IF( alpha.EQ.one )
THEN
203 IF( beta.EQ.one )
THEN
204 ioffa = iia + (jja-1)*lda
205 ioffc = iic + (jjc-1)*ldc
206 DO 30 i = ioffc, ioffc+mp-1
207 c( i ) = c( i ) + a( ioffa )
211 ioffa = iia + (jja-1)*lda
212 ioffc = iic + (jjc-1)*ldc
213 DO 40 i = ioffc, ioffc+mp-1
214 c( i ) = beta * c( i ) + a( ioffa )
218 ELSE IF( beta.EQ.one )
THEN
219 ioffa = iia + (jja-1)*lda
220 ioffc = iic + (jjc-1)*ldc
221 DO 50 i = ioffc, ioffc+mp-1
222 c( i ) = c( i ) + alpha * a( ioffa )
226 ioffa = iia + (jja-1)*lda
227 ioffc = iic + (jjc-1)*ldc
228 DO 60 i = ioffc, ioffc+mp-1
229 c( i ) = beta * c( i ) + alpha * a( ioffa )
235 IF( beta.EQ.zero )
THEN
236 IF( alpha.EQ.zero )
THEN
237 ioffc = iic+(jjc-1)*ldc
239 DO 70 i = ioffc, ioffc+mp-1
245 ioffa = iia+(jja-1)*lda
246 ioffc = iic+(jjc-1)*ldc
248 DO 90 i = ioffc, ioffc+mp-1
249 c( i ) = alpha * a( ioffa )
252 ioffa = ioffa + lda - mp
257 IF( alpha.EQ.one )
THEN
258 IF( beta.EQ.one )
THEN
259 ioffa = iia+(jja-1)*lda
260 ioffc = iic+(jjc-1)*ldc
262 DO 110 i = ioffc, ioffc+mp-1
263 c( i ) = c( i ) + a( ioffa )
266 ioffa = ioffa + lda - mp
270 ioffa = iia+(jja-1)*lda
271 ioffc = iic+(jjc-1)*ldc
273 DO 130 i = ioffc, ioffc+mp-1
274 c( i ) = beta * c( i ) + a( ioffa )
277 ioffa = ioffa + lda - mp
281 ELSE IF( beta.EQ.one )
THEN
282 ioffa = iia+(jja-1)*lda
283 ioffc = iic+(jjc-1)*ldc
285 DO 150 i = ioffc, ioffc+mp-1
286 c( i ) = c( i ) + alpha * a( ioffa )
289 ioffa = ioffa + lda - mp
293 ioffa = iia+(jja-1)*lda
294 ioffc = iic+(jjc-1)*ldc
296 DO 170 i = ioffc, ioffc+mp-1
297 c( i ) = beta * c( i ) + alpha * a( ioffa )
300 ioffa = ioffa + lda - mp