3
4
5
6
7
8
9
10 INTEGER IA, INFO, JA, LWORK, M, N
11
12
13 INTEGER DESCA( * )
14 DOUBLE PRECISION A( * ), TAU( * ), 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 INTEGER BLOCK_CYCLIC_2D, CSRC_, CTXT_, DLEN_, DTYPE_,
165 $ LLD_, MB_, M_, NB_, N_, RSRC_
166 parameter( block_cyclic_2d = 1, dlen_ = 9, dtype_ = 1,
167 $ ctxt_ = 2, m_ = 3, n_ = 4, mb_ = 5, nb_ = 6,
168 $ rsrc_ = 7, csrc_ = 8, lld_ = 9 )
169
170
171 LOGICAL LQUERY
172 CHARACTER COLBTOP, ROWBTOP
173 INTEGER I, IACOL, IAROW, ICOFF, ICTXT, IINFO, IPW, J,
174 $ JB, JN, K, LWMIN, MP0, MYCOL, MYROW, NPCOL,
175 $ NPROW, NQ0
176
177
178 INTEGER IDUM1( 1 ), IDUM2( 1 )
179
180
183
184
185 INTEGER ICEIL, INDXG2P, NUMROC
187
188
189 INTRINSIC dble,
min, mod
190
191
192
193
194
195 ictxt = desca( ctxt_ )
196 CALL blacs_gridinfo( ictxt, nprow, npcol, myrow, mycol )
197
198
199
200 info = 0
201 IF( nprow.EQ.-1 ) THEN
202 info = -(600+ctxt_)
203 ELSE
204 CALL chk1mat( m, 1, n, 2, ia, ja, desca, 6, info )
205 IF( info.EQ.0 ) THEN
206 icoff = mod( ja-1, desca( nb_ ) )
207 iarow =
indxg2p( ia, desca( mb_ ), myrow, desca( rsrc_ ),
208 $ nprow )
209 iacol =
indxg2p( ja, desca( nb_ ), mycol, desca( csrc_ ),
210 $ npcol )
211 mp0 =
numroc( m+mod( ia-1, desca( mb_ ) ), desca( mb_ ),
212 $ myrow, iarow, nprow )
213 nq0 =
numroc( n+icoff, desca( nb_ ), mycol, iacol, npcol )
214 lwmin = desca( nb_ ) * ( mp0 + nq0 + desca( nb_ ) )
215
216 work( 1 ) = dble( lwmin )
217 lquery = ( lwork.EQ.-1 )
218 IF( lwork.LT.lwmin .AND. .NOT.lquery )
219 $ info = -9
220 END IF
221 IF( lwork.EQ.-1 ) THEN
222 idum1( 1 ) = -1
223 ELSE
224 idum1( 1 ) = 1
225 END IF
226 idum2( 1 ) = 9
227 CALL pchk1mat( m, 1, n, 2, ia, ja, desca, 6, 1, idum1, idum2,
228 $ info )
229 END IF
230
231 IF( info.NE.0 ) THEN
232 CALL pxerbla( ictxt,
'PDGEQRF', -info )
233 RETURN
234 ELSE IF( lquery ) THEN
235 RETURN
236 END IF
237
238
239
240 IF( m.EQ.0 .OR. n.EQ.0 )
241 $ RETURN
242
244 ipw = desca( nb_ ) * desca( nb_ ) + 1
245 CALL pb_topget( ictxt, 'Broadcast', 'Rowwise', rowbtop )
246 CALL pb_topget( ictxt, 'Broadcast', 'Columnwise', colbtop )
247 CALL pb_topset( ictxt, 'Broadcast', 'Rowwise', 'I-ring' )
248 CALL pb_topset( ictxt, 'Broadcast', 'Columnwise', ' ' )
249
250
251
252 jn =
min(
iceil( ja, desca( nb_ ) ) * desca( nb_ ), ja+k-1 )
253 jb = jn - ja + 1
254
255
256
257 CALL pdgeqr2( m, jb, a, ia, ja, desca, tau, work, lwork, iinfo )
258
259 IF( ja+jb.LE.ja+n-1 ) THEN
260
261
262
263
264 CALL pdlarft(
'Forward',
'Columnwise', m, jb, a, ia, ja, desca,
265 $ tau, work, work( ipw ) )
266
267
268
269 CALL pdlarfb(
'Left',
'Transpose',
'Forward',
'Columnwise', m,
270 $ n-jb, jb, a, ia, ja, desca, work, a, ia, ja+jb,
271 $ desca, work( ipw ) )
272 END IF
273
274
275
276 DO 10 j = jn+1, ja+k-1, desca( nb_ )
277 jb =
min( k-j+ja, desca( nb_ ) )
278 i = ia + j - ja
279
280
281
282
283 CALL pdgeqr2( m-j+ja, jb, a, i, j, desca, tau, work, lwork,
284 $ iinfo )
285
286 IF( j+jb.LE.ja+n-1 ) THEN
287
288
289
290
291 CALL pdlarft(
'Forward',
'Columnwise', m-j+ja, jb, a, i, j,
292 $ desca, tau, work, work( ipw ) )
293
294
295
296 CALL pdlarfb(
'Left',
'Transpose',
'Forward',
'Columnwise',
297 $ m-j+ja, n-j-jb+ja, jb, a, i, j, desca, work,
298 $ a, i, j+jb, desca, work( ipw ) )
299 END IF
300
301 10 CONTINUE
302
303 CALL pb_topset( ictxt, 'Broadcast', 'Rowwise', rowbtop )
304 CALL pb_topset( ictxt, 'Broadcast', 'Columnwise', colbtop )
305
306 work( 1 ) = dble( lwmin )
307
308 RETURN
309
310
311
subroutine chk1mat(ma, mapos0, na, napos0, ia, ja, desca, descapos0, info)
integer function iceil(inum, idenom)
integer function indxg2p(indxglob, nb, iproc, isrcproc, nprocs)
integer function numroc(n, nb, iproc, isrcproc, nprocs)
subroutine pchk1mat(ma, mapos0, na, napos0, ia, ja, desca, descapos0, nextra, ex, expos, info)
subroutine pdgeqr2(m, n, a, ia, ja, desca, tau, work, lwork, info)
subroutine pdlarfb(side, trans, direct, storev, m, n, k, v, iv, jv, descv, t, c, ic, jc, descc, work)
subroutine pdlarft(direct, storev, n, k, v, iv, jv, descv, tau, t, work)
subroutine pxerbla(ictxt, srname, info)