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