3 IMPLICIT NONE
4
5
6
7
8
9
10
11 CHARACTER NORM
12 INTEGER IA, JA, M, N
13
14
15 INTEGER DESCA( * )
16 REAL WORK( * )
17 COMPLEX A( * )
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 INTEGER BLOCK_CYCLIC_2D, CSRC_, CTXT_, DLEN_, DTYPE_,
150 $ LLD_, MB_, M_, NB_, N_, RSRC_
151 parameter( block_cyclic_2d = 1, dlen_ = 9, dtype_ = 1,
152 $ ctxt_ = 2, m_ = 3, n_ = 4, mb_ = 5, nb_ = 6,
153 $ rsrc_ = 7, csrc_ = 8, lld_ = 9 )
154 REAL ONE, ZERO
155 parameter( one = 1.0e+0, zero = 0.0e+0 )
156
157
158 INTEGER I, IACOL, IAROW, ICTXT, II, ICOFF, IOFFA,
159 $ IROFF, J, JJ, LDA, MP, MYCOL, MYROW, NPCOL,
160 $ NPROW, NQ
161 REAL SUM, VALUE
162
163
164 REAL SSQ( 2 ), COLSSQ( 2 )
165
166
168 $ sgebr2d, sgebs2d, sgamx2d, sgsum2d,
170
171
172 LOGICAL LSAME
173 INTEGER ISAMAX, NUMROC
175
176
177 INTRINSIC abs,
max,
min, mod, sqrt
178
179
180
181
182
183 ictxt = desca( ctxt_ )
184 CALL blacs_gridinfo( ictxt, nprow, npcol, myrow, mycol )
185
186 CALL infog2l( ia, ja, desca, nprow, npcol, myrow, mycol, ii, jj,
187 $ iarow, iacol )
188 iroff = mod( ia-1, desca( mb_ ) )
189 icoff = mod( ja-1, desca( nb_ ) )
190 mp =
numroc( m+iroff, desca( mb_ ), myrow, iarow, nprow )
191 nq =
numroc( n+icoff, desca( nb_ ), mycol, iacol, npcol )
192 IF( myrow.EQ.iarow )
193 $ mp = mp - iroff
194 IF( mycol.EQ.iacol )
195 $ nq = nq - icoff
196 lda = desca( lld_ )
197
198 IF(
min( m, n ).EQ.0 )
THEN
199
200 VALUE = zero
201
202
203
204
205 ELSE IF(
lsame( norm,
'M' ) )
THEN
206
207
208
209 VALUE = zero
210 IF( nq.GT.0 .AND. mp.GT.0 ) THEN
211 ioffa = (jj-1)*lda
212 DO 20 j = jj, jj+nq-1
213 DO 10 i = ii, mp+ii-1
214 VALUE =
max(
VALUE, abs( a( ioffa+i ) ) )
215 10 CONTINUE
216 ioffa = ioffa + lda
217 20 CONTINUE
218 END IF
219 CALL sgamx2d( ictxt, 'All', ' ', 1, 1, VALUE, 1, i, j, -1,
220 $ 0, 0 )
221
222
223
224
225 ELSE IF(
lsame( norm,
'O' ) .OR. norm.EQ.
'1' )
THEN
226
227
228
229 IF( nq.GT.0 ) THEN
230 ioffa = ( jj - 1 ) * lda
231 DO 40 j = jj, jj+nq-1
232 sum = zero
233 IF( mp.GT.0 ) THEN
234 DO 30 i = ii, mp+ii-1
235 sum = sum + abs( a( ioffa+i ) )
236 30 CONTINUE
237 END IF
238 ioffa = ioffa + lda
239 work( j-jj+1 ) = sum
240 40 CONTINUE
241 END IF
242
243
244
245
246 CALL sgsum2d( ictxt, 'Columnwise', ' ', 1, nq, work, 1,
247 $ 0, mycol )
248
249
250
251 IF( myrow.EQ.0 ) THEN
252 IF( nq.GT.0 ) THEN
253 VALUE = work( isamax( nq, work, 1 ) )
254 ELSE
255 VALUE = zero
256 END IF
257 CALL sgamx2d( ictxt, 'Rowwise', ' ', 1, 1, VALUE, 1, i, j,
258 $ -1, 0, 0 )
259 END IF
260
261
262
263
264 ELSE IF(
lsame( norm,
'I' ) )
THEN
265
266
267
268 IF( mp.GT.0 ) THEN
269 ioffa = ii + ( jj - 1 ) * lda
270 DO 60 i = ii, ii+mp-1
271 sum = zero
272 IF( nq.GT.0 ) THEN
273 DO 50 j = ioffa, ioffa + nq*lda - 1, lda
274 sum = sum + abs( a( j ) )
275 50 CONTINUE
276 END IF
277 work( i-ii+1 ) = sum
278 ioffa = ioffa + 1
279 60 CONTINUE
280 END IF
281
282
283
284
285 CALL sgsum2d( ictxt,
'Rowwise',
' ', mp, 1, work,
max( 1, mp ),
286 $ myrow, 0 )
287
288
289
290 IF( mycol.EQ.0 ) THEN
291 IF( mp.GT.0 ) THEN
292 VALUE = work( isamax( mp, work, 1 ) )
293 ELSE
294 VALUE = zero
295 END IF
296 CALL sgamx2d( ictxt, 'Columnwise', ' ', 1, 1, VALUE, 1, i,
297 $ j, -1, 0, 0 )
298 END IF
299
300
301
302
303
304
305 ELSE IF( (
lsame( norm,
'F' ) ) .OR. (
lsame( norm,
'E' ) ) )
THEN
306
307
308
309 ssq(1) = zero
310 ssq(2) = one
311 ioffa = ii + ( jj - 1 ) * lda
312 IF( nq.GT.0 ) THEN
313 DO 70 j = ioffa, ioffa + nq*lda - 1, lda
314 colssq(1) = zero
315 colssq(2) = one
316 CALL classq( mp, a( j ), 1, colssq(1), colssq(2) )
318 70 CONTINUE
319 END IF
320
321
322
324 VALUE = ssq( 1 ) * sqrt( ssq( 2 ) )
325
326 END IF
327
328 IF( myrow.EQ.0 .AND. mycol.EQ.0 ) THEN
329 CALL sgebs2d( ictxt, 'All', ' ', 1, 1, VALUE, 1 )
330 ELSE
331 CALL sgebr2d( ictxt, 'All', ' ', 1, 1, VALUE, 1, 0, 0 )
332 END IF
333
335
336 RETURN
337
338
339
subroutine infog2l(grindx, gcindx, desc, nprow, npcol, myrow, mycol, lrindx, lcindx, rsrc, csrc)
integer function numroc(n, nb, iproc, isrcproc, nprocs)
real function pclange(norm, m, n, a, ia, ja, desca, work)
subroutine pstreecomb(ictxt, scope, n, mine, rdest0, cdest0, subptr)
subroutine scombssq(v1, v2)