OpenRadioss 2025.1.11
OpenRadioss project
Loading...
Searching...
No Matches
pdlange.f
Go to the documentation of this file.
1 DOUBLE PRECISION FUNCTION pdlange( NORM, M, N, A, IA, JA, DESCA,
2 $ WORK )
3 IMPLICIT NONE
4*
5* -- ScaLAPACK auxiliary routine (version 1.7) --
6* University of Tennessee, Knoxville, Oak Ridge National Laboratory,
7* and University of California, Berkeley.
8* May 1, 1997
9*
10* .. Scalar Arguments ..
11 CHARACTER norm
12 INTEGER ia, ja, m, n
13* ..
14* .. Array Arguments ..
15 INTEGER desca( * )
16 DOUBLE PRECISION a( * ), work( * )
17* ..
18*
19* Purpose
20* =======
21*
22* PDLANGE returns the value of the one norm, or the Frobenius norm,
23* or the infinity norm, or the element of largest absolute value of a
24* distributed matrix sub( A ) = A(IA:IA+M-1, JA:JA+N-1).
25*
26* PDLANGE returns the value
27*
28* ( max(abs(A(i,j))), NORM = 'M' or 'm' with IA <= i <= IA+M-1,
29* ( and JA <= j <= JA+N-1,
30* (
31* ( norm1( sub( A ) ), NORM = '1', 'O' or 'o'
32* (
33* ( normI( sub( A ) ), NORM = 'I' or 'i'
34* (
35* ( normF( sub( A ) ), NORM = 'F', 'f', 'E' or 'e'
36*
37* where norm1 denotes the one norm of a matrix (maximum column sum),
38* normI denotes the infinity norm of a matrix (maximum row sum) and
39* normF denotes the Frobenius norm of a matrix (square root of sum of
40* squares). Note that max(abs(A(i,j))) is not a matrix norm.
41*
42* Notes
43* =====
44*
45* Each global data object is described by an associated description
46* vector. This vector stores the information required to establish
47* the mapping between an object element and its corresponding process
48* and memory location.
49*
50* Let A be a generic term for any 2D block cyclicly distributed array.
51* Such a global array has an associated description vector DESCA.
52* In the following comments, the character _ should be read as
53* "of the global array".
54*
55* NOTATION STORED IN EXPLANATION
56* --------------- -------------- --------------------------------------
57* DTYPE_A(global) DESCA( DTYPE_ )The descriptor type. In this case,
58* DTYPE_A = 1.
59* CTXT_A (global) DESCA( CTXT_ ) The BLACS context handle, indicating
60* the BLACS process grid A is distribu-
61* ted over. The context itself is glo-
62* bal, but the handle (the integer
63* value) may vary.
64* M_A (global) DESCA( M_ ) The number of rows in the global
65* array A.
66* N_A (global) DESCA( N_ ) The number of columns in the global
67* array A.
68* MB_A (global) DESCA( MB_ ) The blocking factor used to distribute
69* the rows of the array.
70* NB_A (global) DESCA( NB_ ) The blocking factor used to distribute
71* the columns of the array.
72* RSRC_A (global) DESCA( RSRC_ ) The process row over which the first
73* row of the array A is distributed.
74* CSRC_A (global) DESCA( CSRC_ ) The process column over which the
75* first column of the array A is
76* distributed.
77* LLD_A (local) DESCA( LLD_ ) The leading dimension of the local
78* array. LLD_A >= MAX(1,LOCr(M_A)).
79*
80* Let K be the number of rows or columns of a distributed matrix,
81* and assume that its process grid has dimension p x q.
82* LOCr( K ) denotes the number of elements of K that a process
83* would receive if K were distributed over the p processes of its
84* process column.
85* Similarly, LOCc( K ) denotes the number of elements of K that a
86* process would receive if K were distributed over the q processes of
87* its process row.
88* The values of LOCr() and LOCc() may be determined via a call to the
89* ScaLAPACK tool function, NUMROC:
90* LOCr( M ) = NUMROC( M, MB_A, MYROW, RSRC_A, NPROW ),
91* LOCc( N ) = NUMROC( N, NB_A, MYCOL, CSRC_A, NPCOL ).
92* An upper bound for these quantities may be computed by:
93* LOCr( M ) <= ceil( ceil(M/MB_A)/NPROW )*MB_A
94* LOCc( N ) <= ceil( ceil(N/NB_A)/NPCOL )*NB_A
95*
96* Arguments
97* =========
98*
99* NORM (global input) CHARACTER
100* Specifies the value to be returned in PDLANGE as described
101* above.
102*
103* M (global input) INTEGER
104* The number of rows to be operated on i.e the number of rows
105* of the distributed submatrix sub( A ). When M = 0, PDLANGE
106* is set to zero. M >= 0.
107*
108* N (global input) INTEGER
109* The number of columns to be operated on i.e the number of
110* columns of the distributed submatrix sub( A ). When N = 0,
111* PDLANGE is set to zero. N >= 0.
112*
113* A (local input) DOUBLE PRECISION pointer into the local memory
114* to an array of dimension (LLD_A, LOCc(JA+N-1)) containing the
115* local pieces of the distributed matrix sub( A ).
116*
117* IA (global input) INTEGER
118* The row index in the global array A indicating the first
119* row of sub( A ).
120*
121* JA (global input) INTEGER
122* The column index in the global array A indicating the
123* first column of sub( A ).
124*
125* DESCA (global and local input) INTEGER array of dimension DLEN_.
126* The array descriptor for the distributed matrix A.
127*
128* WORK (local workspace) DOUBLE PRECISION array dimension (LWORK)
129* LWORK >= 0 if NORM = 'M' or 'm' (not referenced),
130* Nq0 if NORM = '1', 'O' or 'o',
131* Mp0 if NORM = 'I' or 'i',
132* 0 if NORM = 'F', 'f', 'E' or 'e' (not referenced),
133* where
134*
135* IROFFA = MOD( IA-1, MB_A ), ICOFFA = MOD( JA-1, NB_A ),
136* IAROW = INDXG2P( IA, MB_A, MYROW, RSRC_A, NPROW ),
137* IACOL = INDXG2P( JA, NB_A, MYCOL, CSRC_A, NPCOL ),
138* Mp0 = NUMROC( M+IROFFA, MB_A, MYROW, IAROW, NPROW ),
139* Nq0 = NUMROC( N+ICOFFA, NB_A, MYCOL, IACOL, NPCOL ),
140*
141* INDXG2P and NUMROC are ScaLAPACK tool functions; MYROW,
142* MYCOL, NPROW and NPCOL can be determined by calling the
143* subroutine BLACS_GRIDINFO.
144*
145* =====================================================================
146*
147* .. Parameters ..
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 DOUBLE PRECISION one, zero
154 parameter( one = 1.0d+0, zero = 0.0d+0 )
155* ..
156* .. Local Scalars ..
157 INTEGER i, iacol, iarow, ictxt, ii, icoff, ioffa,
158 $ iroff, j, jj, lda, mp, mycol, myrow, npcol,
159 $ nprow, nq
160 DOUBLE PRECISION sum, value
161* ..
162* .. Local Arrays ..
163 DOUBLE PRECISION ssq( 2 ), colssq( 2 )
164* ..
165* .. External Subroutines ..
167 $ dgebs2d, dgamx2d, dgsum2d, dlassq,
169* ..
170* .. External Functions ..
171 LOGICAL lsame
172 INTEGER idamax, numroc
173 EXTERNAL lsame, idamax, numroc
174* ..
175* .. Intrinsic Functions ..
176 INTRINSIC abs, max, min, mod, sqrt
177* ..
178* .. Executable Statements ..
179*
180* Get grid parameters.
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* max norm
203*
204 ELSE IF( lsame( norm, 'M' ) ) THEN
205*
206* Find max(abs(A(i,j))).
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 dgamx2d( ictxt, 'All', ' ', 1, 1, VALUE, 1, i, j, -1,
219 $ 0, 0 )
220*
221************************************************************************
222* one norm
223*
224 ELSE IF( lsame( norm, 'o.OR..EQ.' ) NORM'1' ) THEN
225*
226* Find norm1( sub( A ) ).
227*
228.GT. IF( NQ0 ) THEN
229 IOFFA = ( JJ - 1 ) * LDA
230 DO 40 J = JJ, JJ+NQ-1
231 SUM = ZERO
232.GT. IF( MP0 ) 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* Find sum of global matrix columns and store on row 0 of
243* process grid
244*
245 CALL DGSUM2D( ICTXT, 'columnwise', ' ', 1, NQ, WORK, 1,
246 $ 0, MYCOL )
247*
248* Find maximum sum of columns for 1-norm
249*
250.EQ. IF( MYROW0 ) THEN
251.GT. IF( NQ0 ) THEN
252 VALUE = WORK( IDAMAX( NQ, WORK, 1 ) )
253 ELSE
254 VALUE = ZERO
255 END IF
256 CALL DGAMX2D( ICTXT, 'rowwise', ' ', 1, 1, VALUE, 1, I, J,
257 $ -1, 0, 0 )
258 END IF
259*
260************************************************************************
261* inf norm
262*
263 ELSE IF( LSAME( NORM, 'i' ) ) THEN
264*
265* Find normI( sub( A ) ).
266*
267.GT. IF( MP0 ) THEN
268 IOFFA = II + ( JJ - 1 ) * LDA
269 DO 60 I = II, II+MP-1
270 SUM = ZERO
271.GT. IF( NQ0 ) 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* Find sum of global matrix rows and store on column 0 of
282* process grid
283*
284 CALL DGSUM2D( ICTXT, 'rowwise', ' ', MP, 1, WORK, MAX( 1, MP ),
285 $ MYROW, 0 )
286*
287* Find maximum sum of rows for supnorm
288*
289.EQ. IF( MYCOL0 ) THEN
290.GT. IF( MP0 ) THEN
291 VALUE = WORK( IDAMAX( MP, WORK, 1 ) )
292 ELSE
293 VALUE = ZERO
294 END IF
295 CALL DGAMX2D( ICTXT, 'columnwise', ' ', 1, 1, VALUE, 1, I,
296 $ J, -1, 0, 0 )
297 END IF
298*
299************************************************************************
300* Frobenius norm
301* SSQ(1) is scale
302* SSQ(2) is sum-of-squares
303*
304 ELSE IF( ( LSAME( NORM, 'f.OR.' ) ) ( LSAME( NORM, 'e' ) ) ) THEN
305*
306* Find normF( sub( A ) ).
307*
308 SSQ(1) = ZERO
309 SSQ(2) = ONE
310 IOFFA = II + ( JJ - 1 ) * LDA
311.GT. IF( NQ0 ) THEN
312 DO 70 J = IOFFA, IOFFA + NQ*LDA - 1, LDA
313 COLSSQ(1) = ZERO
314 COLSSQ(2) = ONE
315 CALL DLASSQ( MP, A( J ), 1, COLSSQ(1), COLSSQ(2) )
316 CALL DCOMBSSQ( SSQ, COLSSQ )
317 70 CONTINUE
318 END IF
319*
320* Perform the global scaled sum
321*
322 CALL PDTREECOMB( ICTXT, 'all', 2, SSQ, 0, 0, DCOMBSSQ )
323 VALUE = SSQ( 1 ) * SQRT( SSQ( 2 ) )
324*
325 END IF
326*
327.EQ..AND..EQ. IF( MYROW0 MYCOL0 ) THEN
328 CALL DGEBS2D( ICTXT, 'all', ' ', 1, 1, VALUE, 1 )
329 ELSE
330 CALL DGEBR2D( ICTXT, 'all', ' ', 1, 1, VALUE, 1, 0, 0 )
331 END IF
332*
333 PDLANGE = VALUE
334*
335 RETURN
336*
337* End of PDLANGE
338*
339 END
norm(diag(diag(diag(inv(mat))) -id.SOL), 2) % destroy mumps instance id.JOB
subroutine dlassq(n, x, incx, scl, sumsq)
DLASSQ updates a sum of squares represented in scaled form.
Definition dlassq.f90:137
logical function lsame(ca, cb)
LSAME
Definition lsame.f:53
integer function idamax(n, dx, incx)
IDAMAX
Definition idamax.f:71
#define min(a, b)
Definition macros.h:20
#define max(a, b)
Definition macros.h:21
subroutine dgebs2d(contxt, scope, top, m, n, a, lda)
Definition mpi.f:1082
subroutine dgebr2d(contxt, scope, top, m, n, a, lda)
Definition mpi.f:1123
subroutine infog2l(grindx, gcindx, desc, nprow, npcol, myrow, mycol, lrindx, lcindx, rsrc, csrc)
Definition mpi.f:937
subroutine blacs_gridinfo(cntxt, nprow, npcol, myrow, mycol)
Definition mpi.f:754
integer function numroc(n, nb, iproc, isrcproc, nprocs)
Definition mpi.f:786
double precision function pdlange(norm, m, n, a, ia, ja, desca, work)
Definition pdlange.f:3
subroutine dcombssq(v1, v2)
Definition pdtreecomb.f:259
subroutine pdtreecomb(ictxt, scope, n, mine, rdest0, cdest0, subptr)
Definition pdtreecomb.f:3