6
7
8
9
10
11
12
13 CHARACTER DIST, PACK, SYM
14 INTEGER IA, INFO, JA, KL, KU, LWORK, M, MODE, N, ORDER
15 DOUBLE PRECISION COND, DMAX
16
17
18 INTEGER DESCA( * ), ISEED( 4 )
19 DOUBLE PRECISION D( * )
20 COMPLEX*16 A( * ), WORK( * )
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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200 INTEGER BLOCK_CYCLIC_2D, DLEN_, DTYPE_, CTXT_, M_, N_,
201 $ MB_, NB_, RSRC_, CSRC_, LLD_
202 parameter( block_cyclic_2d = 1, dlen_ = 9, dtype_ = 1,
203 $ ctxt_ = 2, m_ = 3, n_ = 4, mb_ = 5, nb_ = 6,
204 $ rsrc_ = 7, csrc_ = 8, lld_ = 9 )
205 DOUBLE PRECISION ZERO, ONE
206 parameter( zero = 0.0d+0, one = 1.0d+0 )
207 COMPLEX*16 ZZERO
208 parameter( zzero = ( 0.0d+0, 0.0d+0 ) )
209
210
211 INTEGER I, IDIST, IINFO, IPACK, IRSIGN, ISYM, LLB,
212 $ MNMIN, MYCOL, MYROW, NP, NPCOL, NPROW, NQ
213 DOUBLE PRECISION ALPHA, TEMP
214
215
216 INTEGER IDUM1( 1 ), IDUM2( 1 )
217
218
219 LOGICAL LSAME
220 INTEGER NUMROC
222
223
226
227
228 INTRINSIC abs,
max,
min, mod
229
230
231
232 IF( block_cyclic_2d*csrc_*ctxt_*dlen_*dtype_*lld_*mb_*m_*nb_*n_*
233 $ rsrc_.LT.0 )RETURN
234
235
236
237
238
239 info = 0
240
241 CALL blacs_gridinfo( desca( ctxt_ ), nprow, npcol, myrow, mycol )
242 IF( ( myrow.GE.nprow .OR. myrow.LT.0 ) .OR.
243 $ ( mycol.GE.npcol .OR. mycol.LT.0 ) )RETURN
244
245 np =
numroc( n, desca( mb_ ), myrow, 0, nprow )
246 nq =
numroc( n, desca( nb_ ), mycol, 0, npcol )
247
248
249
250 IF( m.EQ.0 .OR. n.EQ.0 )
251 $ RETURN
252
253
254
255 IF(
lsame( dist,
'U' ) )
THEN
256 idist = 1
257 ELSE IF(
lsame( dist,
'S' ) )
THEN
258 idist = 2
259 ELSE IF(
lsame( dist,
'N' ) )
THEN
260 idist = 3
261 ELSE
262 idist = -1
263 END IF
264
265
266
267 IF(
lsame( sym,
'N' ) )
THEN
268 isym = 1
269 irsign = 0
270 ELSE IF(
lsame( sym,
'P' ) )
THEN
271 isym = 2
272 irsign = 0
273 ELSE IF(
lsame( sym,
'S' ) )
THEN
274 isym = 2
275 irsign = 1
276 ELSE IF(
lsame( sym,
'H' ) )
THEN
277 isym = 2
278 irsign = 1
279 ELSE
280 isym = -1
281 END IF
282
283
284
285 IF(
lsame( pack,
'N' ) )
THEN
286 ipack = 0
287 ELSE
288 ipack = 1
289 END IF
290
291
292
295
296 IF( order.EQ.0 )
297 $ order = n
298
299
300
301 IF( nprow.EQ.-1 ) THEN
302 info = -( 1600+ctxt_ )
303 ELSE
304 CALL chk1mat( m, 1, n, 2, ia, ja, desca, 16, info )
305 IF( info.EQ.0 ) THEN
306 IF( m.NE.n .AND. isym.NE.1 ) THEN
307 info = -2
308 ELSE IF( idist.EQ.-1 ) THEN
309 info = -3
310 ELSE IF( isym.EQ.-1 ) THEN
311 info = -5
312 ELSE IF( abs( mode ).GT.6 ) THEN
313 info = -7
314 ELSE IF( ( mode.NE.0 .AND. abs( mode ).NE.6 ) .AND. cond.LT.
315 $ one ) THEN
316 info = -8
317 ELSE IF( kl.LT.0 ) THEN
318 info = -10
319 ELSE IF( ku.LT.0 .OR. ( isym.NE.1 .AND. kl.NE.ku ) ) THEN
320 info = -11
321 ELSE IF( ( order.LT.0 ) .OR. ( order.GT.n ) ) THEN
322 info = -17
323 END IF
324 END IF
325 CALL pchk1mat( m, 1, n, 2, ia, ja, desca, 16, 0, idum1, idum2,
326 $ info )
327 END IF
328
329
330
331 IF( isym.NE.2 ) THEN
332 info = -5
333 ELSE IF( ipack.NE.0 ) THEN
334 info = -12
335 ELSE IF( kl.GT.0 .AND. kl.LT.m-1 ) THEN
336 info = -10
337 ELSE IF( ku.GT.0 .AND. ku.LT.n-1 ) THEN
338 info = -11
339 ELSE IF( llb.NE.0 .AND. llb.NE.m-1 ) THEN
340 info = -10
341 END IF
342 IF( info.NE.0 ) THEN
343 CALL pxerbla( desca( ctxt_ ),
'PZLATMS', -info )
344 RETURN
345 END IF
346
347
348
349 DO 10 i = 1, 4
350 iseed( i ) = mod( abs( iseed( i ) ), 4096 )
351 10 CONTINUE
352
353 IF( mod( iseed( 4 ), 2 ).NE.1 )
354 $ iseed( 4 ) = iseed( 4 ) + 1
355
356
357
358
359
360 CALL dlatm1( mode, cond, irsign, idist, iseed, d, mnmin, iinfo )
361
362 IF( iinfo.NE.0 ) THEN
363 info = 1
364 RETURN
365 END IF
366
367
368 IF( mode.NE.0 .AND. abs( mode ).NE.6 ) THEN
369
370
371
372 temp = abs( d( 1 ) )
373 DO 20 i = 2, mnmin
374 temp =
max( temp, abs( d( i ) ) )
375 20 CONTINUE
376
377 IF( temp.GT.zero ) THEN
378 alpha = dmax / temp
379 ELSE
380 info = 2
381 RETURN
382 END IF
383
384 CALL dscal( mnmin, alpha, d, 1 )
385
386 END IF
387
388 CALL zlaset( 'A', np, nq, zzero, zzero, a, desca( lld_ ) )
389
390
391
392 CALL pzlaghe( m, llb, d, a, ia, ja, desca, iseed, order, work,
393 $ lwork, iinfo )
394
395 RETURN
396
397
398
subroutine chk1mat(ma, mapos0, na, napos0, ia, ja, desca, descapos0, info)
subroutine dlatm1(mode, cond, irsign, idist, iseed, d, n, info)
integer function numroc(n, nb, iproc, isrcproc, nprocs)
subroutine pchk1mat(ma, mapos0, na, napos0, ia, ja, desca, descapos0, nextra, ex, expos, info)
subroutine pxerbla(ictxt, srname, info)
subroutine pzlaghe(n, k, d, a, ia, ja, desca, iseed, order, work, lwork, info)