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 DOUBLE PRECISION ONE
170 parameter( one = 1.0d+0 )
171
172
173 LOGICAL LQUERY
174 CHARACTER COLBTOP, ROWBTOP
175 INTEGER I, II, IACOL, IAROW, ICTXT, J, JJ, K, LWMIN,
176 $ MP, MYCOL, MYROW, NPCOL, NPROW, NQ
177 DOUBLE PRECISION AJJ, ALPHA
178
179
180 EXTERNAL blacs_abort, blacs_gridinfo,
chk1mat, dgebr2d,
181 $ dgebs2d, dlarfg, dscal,
infog2l,
184
185
186 INTEGER INDXG2P, NUMROC
188
189
190 INTRINSIC dble,
max,
min, mod
191
192
193
194
195
196 ictxt = desca( ctxt_ )
197 CALL blacs_gridinfo( ictxt, nprow, npcol, myrow, mycol )
198
199
200
201 info = 0
202 IF( nprow.EQ.-1 ) THEN
203 info = -(600+ctxt_)
204 ELSE
205 CALL chk1mat( m, 1, n, 2, ia, ja, desca, 6, info )
206 IF( info.EQ.0 ) THEN
207 iarow =
indxg2p( ia, desca( mb_ ), myrow, desca( rsrc_ ),
208 $ nprow )
209 iacol =
indxg2p( ja, desca( nb_ ), mycol, desca( csrc_ ),
210 $ npcol )
211 mp =
numroc( m+mod( ia-1, desca( mb_ ) ), desca( mb_ ),
212 $ myrow, iarow, nprow )
213 nq =
numroc( n+mod( ja-1, desca( nb_ ) ), desca( nb_ ),
214 $ mycol, iacol, npcol )
215 lwmin = mp +
max( 1, nq )
216
217 work( 1 ) = dble( lwmin )
218 lquery = ( lwork.EQ.-1 )
219 IF( lwork.LT.lwmin .AND. .NOT.lquery )
220 $ info = -9
221 END IF
222 END IF
223
224 IF( info.NE.0 ) THEN
225 CALL pxerbla( ictxt,
'PDGEQR2', -info )
226 CALL blacs_abort( ictxt, 1 )
227 RETURN
228 ELSE IF( lquery ) THEN
229 RETURN
230 END IF
231
232
233
234 IF( m.EQ.0 .OR. n.EQ.0 )
235 $ RETURN
236
237 CALL pb_topget( ictxt, 'Broadcast', 'Rowwise', rowbtop )
238 CALL pb_topget( ictxt, 'Broadcast', 'Columnwise', colbtop )
239 CALL pb_topset( ictxt, 'Broadcast', 'Rowwise', 'I-ring' )
240 CALL pb_topset( ictxt, 'Broadcast', 'Columnwise', ' ' )
241
242 IF( desca( m_ ).EQ.1 ) THEN
243 CALL infog2l( ia, ja, desca, nprow, npcol, myrow, mycol, ii,
244 $ jj, iarow, iacol )
245 IF( myrow.EQ.iarow ) THEN
246 nq =
numroc( ja+n-1, desca( nb_ ), mycol, desca( csrc_ ),
247 $ npcol )
248 i = ii+(jj-1)*desca( lld_ )
249 IF( mycol.EQ.iacol ) THEN
250 ajj = a( i )
251 CALL dlarfg( 1, ajj, a( i ), 1, tau( jj ) )
252 IF( n.GT.1 ) THEN
253 alpha = one - tau( jj )
254 CALL dgebs2d( ictxt, 'Rowwise', ' ', 1, 1, alpha, 1 )
255 CALL dscal( nq-jj, alpha, a( i+desca( lld_ ) ),
256 $ desca( lld_ ) )
257 END IF
258 CALL dgebs2d( ictxt, 'Columnwise', ' ', 1, 1, tau( jj ),
259 $ 1 )
260 a( i ) = ajj
261 ELSE
262 IF( n.GT.1 ) THEN
263 CALL dgebr2d( ictxt, 'Rowwise', ' ', 1, 1, alpha,
264 $ 1, iarow, iacol )
265 CALL dscal( nq-jj+1, alpha, a( i ), desca( lld_ ) )
266 END IF
267 END IF
268 ELSE IF( mycol.EQ.iacol ) THEN
269 CALL dgebr2d( ictxt, 'Columnwise', ' ', 1, 1, tau( jj ), 1,
270 $ iarow, iacol )
271 END IF
272
273 ELSE
274
276 DO 10 j = ja, ja+k-1
277 i = ia + j - ja
278
279
280
281
282 CALL pdlarfg( m-j+ja, ajj, i, j, a,
min( i+1, ia+m-1 ), j,
283 $ desca, 1, tau )
284 IF( j.LT.ja+n-1 ) THEN
285
286
287
288 CALL pdelset( a, i, j, desca, one )
289
290 CALL pdlarf(
'Left', m-j+ja, n-j+ja-1, a, i, j, desca, 1,
291 $ tau, a, i, j+1, desca, work )
292 END IF
293 CALL pdelset( a, i, j, desca, ajj )
294
295 10 CONTINUE
296
297 END IF
298
299 CALL pb_topset( ictxt, 'Broadcast', 'Rowwise', rowbtop )
300 CALL pb_topset( ictxt, 'Broadcast', 'Columnwise', colbtop )
301
302 work( 1 ) = dble( lwmin )
303
304 RETURN
305
306
307
subroutine chk1mat(ma, mapos0, na, napos0, ia, ja, desca, descapos0, info)
integer function indxg2p(indxglob, nb, iproc, isrcproc, nprocs)
subroutine infog2l(grindx, gcindx, desc, nprow, npcol, myrow, mycol, lrindx, lcindx, rsrc, csrc)
integer function numroc(n, nb, iproc, isrcproc, nprocs)
subroutine pdelset(a, ia, ja, desca, alpha)
subroutine pdlarf(side, m, n, v, iv, jv, descv, incv, tau, c, ic, jc, descc, work)
subroutine pdlarfg(n, alpha, iax, jax, x, ix, jx, descx, incx, tau)
subroutine pxerbla(ictxt, srname, info)