3
4
5
6
7
8
9
10 INTEGER IA, INFO, JA, LWORK, M, N, ORDER
11
12
13 INTEGER DESCA( * ), ISEED( 4 )
14 DOUBLE PRECISION A( * ), D( * ), WORK( * )
15
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169 INTEGER BLOCK_CYCLIC_2D, DLEN_, DTYPE_, CTXT_, M_, N_,
170 $ MB_, NB_, RSRC_, CSRC_, LLD_
171 parameter( block_cyclic_2d = 1, dlen_ = 9, dtype_ = 1,
172 $ ctxt_ = 2, m_ = 3, n_ = 4, mb_ = 5, nb_ = 6,
173 $ rsrc_ = 7, csrc_ = 8, lld_ = 9 )
174 DOUBLE PRECISION ZERO
175 parameter( zero = 0.0d+0 )
176
177
178 INTEGER CSRC_A, DTAU1, DTAU2, I, IACOL, IAROW, ICOFFA,
179 $ IROFFA, LCM, LCMQ, LDAA, LQ_WORK, LWMIN, MB_A,
180 $ MP, MYCOL, MYROW, NB_A, NPCOL, NPROW, NQ,
181 $ PTR2AA, PTR2TAU, PTR2WORK, QR_WORK, RSRC_A,
182 $ SIZE, SIZELQF, SIZEMLQRIGHT, SIZEMQRLEFT,
183 $ SIZEQRF
184
185
189
190
191 INTEGER ILCM, INDXG2P, NUMROC
193
194
196
197
198
199 IF( block_cyclic_2d*dlen_*dtype_*m_*n_.LT.0 )RETURN
200
201
202
203 CALL blacs_gridinfo( desca( ctxt_ ), nprow, npcol, myrow, mycol )
204
205
206
207 info = 0
209 IF( nprow.EQ.-1 ) THEN
210 info = -607
211 ELSE
212 CALL chk1mat( m, 1, n, 2, ia, ja, desca, 8, info )
213 END IF
214
215 ldaa = desca( lld_ )
216 mb_a = desca( mb_ )
217 nb_a = desca( nb_ )
218 rsrc_a = desca( rsrc_ )
219 csrc_a = desca( csrc_ )
220 lcm =
ilcm( nprow, npcol )
221 lcmq = lcm / npcol
222 iroffa = mod( ia-1, mb_a )
223 icoffa = mod( ja-1, nb_a )
224 iarow =
indxg2p( ia, mb_a, myrow, rsrc_a, nprow )
225 iacol =
indxg2p( ja, nb_a, mycol, csrc_a, npcol )
226 dtau1 =
numroc( ja+size-1, nb_a, mycol, iacol, npcol )
227 dtau2 =
numroc( ia+size-1, mb_a, myrow, iarow, nprow )
228 mp =
numroc( m+iroffa, mb_a, myrow, iarow, nprow )
229 nq =
numroc( n+icoffa, nb_a, mycol, iacol, npcol )
230
231 sizemqrleft =
max( ( mb_a*( mb_a-1 ) ) / 2, ( mp+nq )*mb_a ) +
232 $ ( mp+nb_a )*nb_a
233 sizemlqright =
max( ( mb_a*( mb_a-1 ) ) / 2, ( mp+nq )*mb_a ) +
234 $ mb_a*mb_a
235 sizeqrf = nb_a*mp + mb_a*nq + nb_a*nb_a + 100
236 sizelqf = nb_a*( mp+nq+nb_a ) + 100
237
238 qr_work = ldaa*
max( 1, nq ) + 200 +
max( 1, dtau1 ) +
239 $
max( sizemqrleft, sizeqrf )
240 lq_work = ldaa*
max( 1, nq ) + 200 +
max( 1, dtau2 ) +
241 $
max( sizemlqright, sizelqf )
242 lwmin =
max( qr_work, lq_work )
243 work( 1 ) = lwmin
244 IF( lwork.EQ.-1 )
245 $ GO TO 20
246
247
248
249 IF( info.EQ.0 ) THEN
250 IF( size.NE.order ) THEN
251 info = -9
252 ELSE IF( lwork.LT.lwmin ) THEN
253 info = -11
254 END IF
255 END IF
256 IF( info.LT.0 ) THEN
257 CALL pxerbla( desca( ctxt_ ),
'PDLAGGE', -info )
258 RETURN
259 END IF
260
261
262
263 CALL pdlaset(
'Full', m, n, zero, zero, a, ia, ja, desca )
264 DO 10 i = 1, SIZE
265 CALL pdelset( a, i, i, desca, d( i ) )
266 10 CONTINUE
267
268
269
270 ptr2aa = 2
271 ptr2tau = ptr2aa + ldaa*
max( 1, nq ) + 100
272 ptr2work = ptr2tau +
max( 1, dtau1 ) + 100
273
274 CALL pdlaset(
'All', m, n, zero, zero, work( ptr2aa ), ia, ja,
275 $ desca )
276
277
278
279 CALL pdmatgen( desca( ctxt_ ),
'N',
'N', m, n, desca( mb_ ),
280 $ desca( nb_ ), work( ptr2aa ), desca( lld_ ),
281 $ desca( rsrc_ ), desca( csrc_ ), iseed( 1 ), 0, mp,
282 $ 0, nq, myrow, mycol, nprow, npcol )
283
284
285
286 CALL pdgeqrf( m, n, work( ptr2aa ), ia, ja, desca,
287 $ work( ptr2tau ), work( ptr2work ), sizeqrf, info )
288
289
290
291 CALL pdormqr(
'L',
'N', m, n,
SIZE, work( ptr2aa ), ia, ja, desca,
292 $ work( ptr2tau ), a, ia, ja, desca, work( ptr2work ),
293 $ sizemqrleft, info )
294
295
296
297
298 ptr2work = ptr2tau +
max( 1, dtau2 ) + 100
299
300
301
302 CALL pdmatgen( desca( ctxt_ ),
'N',
'N', m, n, desca( mb_ ),
303 $ desca( nb_ ), work( ptr2aa ), desca( lld_ ),
304 $ desca( rsrc_ ), desca( csrc_ ), iseed( 2 ), 0, mp,
305 $ 0, nq, myrow, mycol, nprow, npcol )
306
307
308
309 CALL pdgelqf( m, n, work( ptr2aa ), ia, ja, desca,
310 $ work( ptr2tau ), work( ptr2work ), sizelqf, info )
311
312
313
314 CALL pdormlq(
'R',
'N', m, n,
SIZE, work( ptr2aa ), ia, ja, desca,
315 $ work( ptr2tau ), a, ia, ja, desca, work( ptr2work ),
316 $ sizemlqright, info )
317
318
319
320 20 CONTINUE
321 RETURN
subroutine pdmatgen(ictxt, aform, diag, m, n, mb, nb, a, lda, iarow, iacol, iseed, iroff, irnum, icoff, icnum, myrow, mycol, nprow, npcol)
subroutine chk1mat(ma, mapos0, na, napos0, ia, ja, desca, descapos0, info)
integer function ilcm(m, n)
integer function indxg2p(indxglob, nb, iproc, isrcproc, nprocs)
integer function numroc(n, nb, iproc, isrcproc, nprocs)
subroutine pdlaset(uplo, m, n, alpha, beta, a, ia, ja, desca)
subroutine pdelset(a, ia, ja, desca, alpha)
subroutine pdgelqf(m, n, a, ia, ja, desca, tau, work, lwork, info)
subroutine pdgeqrf(m, n, a, ia, ja, desca, tau, work, lwork, info)
subroutine pdormlq(side, trans, m, n, k, a, ia, ja, desca, tau, c, ic, jc, descc, work, lwork, info)
subroutine pdormqr(side, trans, m, n, k, a, ia, ja, desca, tau, c, ic, jc, descc, work, lwork, info)
subroutine pxerbla(ictxt, srname, info)