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