OpenRadioss 2025.1.11
OpenRadioss project
Loading...
Searching...
No Matches
pddtlaschk.f File Reference

Go to the source code of this file.

Functions/Subroutines

subroutine pddtlaschk (symm, uplo, trans, n, bwl, bwu, nrhs, x, ix, jx, descx, iaseed, a, ia, ja, desca, ibseed, anorm, resid, work, worksiz)

Function/Subroutine Documentation

◆ pddtlaschk()

subroutine pddtlaschk ( character symm,
character uplo,
character trans,
integer n,
integer bwl,
integer bwu,
integer nrhs,
double precision, dimension( * ) x,
integer ix,
integer jx,
integer, dimension( * ) descx,
integer iaseed,
double precision, dimension( * ) a,
integer ia,
integer ja,
integer, dimension( * ) desca,
integer ibseed,
double precision anorm,
double precision resid,
double precision, dimension( * ) work,
integer worksiz )

Definition at line 1 of file pddtlaschk.f.

4*
5*
6* -- ScaLAPACK routine (version 1.7) --
7* University of Tennessee, Knoxville, Oak Ridge National Laboratory,
8* and University of California, Berkeley.
9* November 15, 1997
10*
11* .. Scalar Arguments ..
12 CHARACTER SYMM, TRANS, UPLO
13 INTEGER BWL, BWU, IA, IASEED, IBSEED,
14 $ IX, JA, JX, N, NRHS, WORKSIZ
15 DOUBLE PRECISION ANORM, RESID
16* ..
17* .. Array Arguments ..
18 INTEGER DESCA( * ), DESCX( * )
19 DOUBLE PRECISION A( * ), WORK( * ), X( * )
20* .. External Functions ..
21 LOGICAL LSAME
22* ..
23*
24* Purpose
25* =======
26*
27* PDDTLASCHK computes the residual
28* || sub( A )*sub( X ) - B || / (|| sub( A ) ||*|| sub( X ) ||*eps*N)
29* to check the accuracy of the factorization and solve steps in the
30* LU and Cholesky decompositions, where sub( A ) denotes
31* A(IA:IA+N-1,JA,JA+N-1), sub( X ) denotes X(IX:IX+N-1, JX:JX+NRHS-1).
32*
33* Notes
34* =====
35*
36* Each global data object is described by an associated description
37* vector. This vector stores the information required to establish
38* the mapping between an object element and its corresponding process
39* and memory location.
40*
41* Let A be a generic term for any 2D block cyclicly distributed array.
42* Such a global array has an associated description vector DESCA.
43* In the following comments, the character _ should be read as
44* "of the global array".
45*
46* NOTATION STORED IN EXPLANATION
47* --------------- -------------- --------------------------------------
48* DTYPE_A(global) DESCA( DTYPE_ )The descriptor type. In this case,
49* DTYPE_A = 1.
50* CTXT_A (global) DESCA( CTXT_ ) The BLACS context handle, indicating
51* the BLACS process grid A is distribu-
52* ted over. The context itself is glo-
53* bal, but the handle (the integer
54* value) may vary.
55* M_A (global) DESCA( M_ ) The number of rows in the global
56* array A.
57* N_A (global) DESCA( N_ ) The number of columns in the global
58* array A.
59* MB_A (global) DESCA( MB_ ) The blocking factor used to distribute
60* the rows of the array.
61* NB_A (global) DESCA( NB_ ) The blocking factor used to distribute
62* the columns of the array.
63* RSRC_A (global) DESCA( RSRC_ ) The process row over which the first
64* row of the array A is distributed.
65* CSRC_A (global) DESCA( CSRC_ ) The process column over which the
66* first column of the array A is
67* distributed.
68* LLD_A (local) DESCA( LLD_ ) The leading dimension of the local
69* array. LLD_A >= MAX(1,LOCr(M_A)).
70*
71* Let K be the number of rows or columns of a distributed matrix,
72* and assume that its process grid has dimension p x q.
73* LOCr( K ) denotes the number of elements of K that a process
74* would receive if K were distributed over the p processes of its
75* process column.
76* Similarly, LOCc( K ) denotes the number of elements of K that a
77* process would receive if K were distributed over the q processes of
78* its process row.
79* The values of LOCr() and LOCc() may be determined via a call to the
80* ScaLAPACK tool function, NUMROC:
81* LOCr( M ) = NUMROC( M, MB_A, MYROW, RSRC_A, NPROW ),
82* LOCc( N ) = NUMROC( N, NB_A, MYCOL, CSRC_A, NPCOL ).
83* An upper bound for these quantities may be computed by:
84* LOCr( M ) <= ceil( ceil(M/MB_A)/NPROW )*MB_A
85* LOCc( N ) <= ceil( ceil(N/NB_A)/NPCOL )*NB_A
86*
87* Arguments
88* =========
89*
90* SYMM (global input) CHARACTER
91* if SYMM = 'S', sub( A ) is a symmetric distributed band
92* matrix, otherwise sub( A ) is a general distributed matrix.
93*
94* UPLO (global input) CHARACTER
95* if SYMM = 'S', then
96* if UPLO = 'L', the lower half of the matrix is stored
97* if UPLO = 'U', the upper half of the matrix is stored
98* if SYMM != 'S' or 'H', then
99* if UPLO = 'D', the matrix is stable during factorization
100* without interchanges
101* if UPLO != 'D', the matrix is general
102*
103* TRANS if TRANS= 'T', A 'Transpose' is used as the
104* coefficient matrix in the solve.
105*
106* N (global input) INTEGER
107* The number of columns to be operated on, i.e. the number of
108* columns of the distributed submatrix sub( A ). N >= 0.
109*
110* NRHS (global input) INTEGER
111* The number of right-hand-sides, i.e the number of columns
112* of the distributed matrix sub( X ). NRHS >= 1.
113*
114* X (local input) DOUBLE PRECISION pointer into the local memory
115* to an array of dimension (LLD_X,LOCq(JX+NRHS-1). This array
116* contains the local pieces of the answer vector(s) sub( X ) of
117* sub( A ) sub( X ) - B, split up over a column of processes.
118*
119* IX (global input) INTEGER
120* The row index in the global array X indicating the first
121* row of sub( X ).
122*
123* DESCX (global and local input) INTEGER array of dimension DLEN_.
124* The array descriptor for the distributed matrix X.
125*
126* IASEED (global input) INTEGER
127* The seed number to generate the original matrix Ao.
128*
129* JA (global input) INTEGER
130* The column index in the global array A indicating the
131* first column of sub( A ).
132*
133* DESCA (global and local input) INTEGER array of dimension DLEN_.
134* The array descriptor for the distributed matrix A.
135*
136* IBSEED (global input) INTEGER
137* The seed number to generate the original matrix B.
138*
139* ANORM (global input) DOUBLE PRECISION
140* The 1-norm or infinity norm of the distributed matrix
141* sub( A ).
142*
143* RESID (global output) DOUBLE PRECISION
144* The residual error:
145* ||sub( A )*sub( X )-B|| / (||sub( A )||*||sub( X )||*eps*N).
146*
147* WORK (local workspace) DOUBLE PRECISION array, dimension (LWORK)
148* IF SYMM='S'
149* LWORK >= max(5,NB)+2*NB
150* IF SYMM!='S' or 'H'
151* LWORK >= max(5,NB)+2*NB
152*
153* WORKSIZ (local input) size of WORK.
154*
155* =====================================================================
156*
157* Code Developer: Andrew J. Cleary, University of Tennessee.
158* Current address: Lawrence Livermore National Labs.
159* This version released: August, 2001.
160*
161* =====================================================================
162*
163* .. Parameters ..
164 DOUBLE PRECISION ZERO, ONE
165 parameter( one = 1.0d+0, zero = 0.0d+0 )
166 INTEGER BLOCK_CYCLIC_2D, CSRC_, CTXT_, DLEN_, DTYPE_,
167 $ LLD_, MB_, M_, NB_, N_, RSRC_
168 parameter( block_cyclic_2d = 1, dlen_ = 9, dtype_ = 1,
169 $ ctxt_ = 2, m_ = 3, n_ = 4, mb_ = 5, nb_ = 6,
170 $ rsrc_ = 7, csrc_ = 8, lld_ = 9 )
171 INTEGER INT_ONE
172 parameter( int_one = 1 )
173* ..
174* .. Local Scalars ..
175 INTEGER IACOL, IAROW, ICTXT,
176 $ IIA, IIX, IPB, IPW,
177 $ IXCOL, IXROW, J, JJA, JJX, LDA,
178 $ MYCOL, MYROW, NB, NP, NPCOL, NPROW, NQ
179 INTEGER I, START
180 INTEGER BW, INFO, IPPRODUCT, WORK_MIN
181 DOUBLE PRECISION DIVISOR, EPS, RESID1, NORMX
182* ..
183* .. Local Arrays ..
184* ..
185* .. External Subroutines ..
186 EXTERNAL blacs_gridinfo, dgamx2d, dgebr2d,
187 $ dgebs2d, dgemm, dgerv2d, dgesd2d,
188 $ dgsum2d, dlaset, pbdtran, pdmatgen
189* ..
190* .. External Functions ..
191 INTEGER IDAMAX, NUMROC
192 DOUBLE PRECISION PDLAMCH
193 EXTERNAL idamax, numroc, pdlamch
194* ..
195* .. Intrinsic Functions ..
196 INTRINSIC abs, dble, max, min, mod
197* ..
198* .. Executable Statements ..
199*
200* Get needed initial parameters
201*
202 ictxt = desca( ctxt_ )
203 nb = desca( nb_ )
204*
205 IF( lsame( symm, 'S' ) ) THEN
206 bw = bwl
207 start = 1
208 work_min = max(5,nb)+2*nb
209 ELSE
210 bw = max(bwl, bwu)
211 IF( lsame( uplo, 'D' )) THEN
212 start = 1
213 ELSE
214 start = 2
215 ENDIF
216 work_min = max(5,nb)+2*nb
217 ENDIF
218*
219 IF ( worksiz .LT. work_min ) THEN
220 CALL pxerbla( ictxt, 'pdtlaschk', -18 )
221 RETURN
222 END IF
223*
224 CALL BLACS_GRIDINFO( ICTXT, NPROW, NPCOL, MYROW, MYCOL )
225*
226 EPS = PDLAMCH( ICTXT, 'eps' )
227 RESID = 0.0D+0
228 DIVISOR = ANORM * EPS * DBLE( N )
229*
230 CALL INFOG2L( IA, JA, DESCA, NPROW, NPCOL, MYROW, MYCOL, IIA, JJA,
231 $ IAROW, IACOL )
232 CALL INFOG2L( IX, JX, DESCX, NPROW, NPCOL, MYROW, MYCOL, IIX, JJX,
233 $ IXROW, IXCOL )
234 NP = NUMROC( (3), DESCA( MB_ ), MYROW, 0, NPROW )
235 NQ = NUMROC( N, DESCA( NB_ ), MYCOL, 0, NPCOL )
236*
237 IPB = 1
238 IPPRODUCT = 1 + DESCA( NB_ )
239 IPW = 1 + 2*DESCA( NB_ )
240*
241 LDA = DESCA( LLD_ )
242*
243* Regenerate A
244*
245 IF( LSAME( SYMM, 's' )) THEN
246 CALL PDBMATGEN( ICTXT, UPLO, 'd', BW, BW, N, BW+1,
247 $ DESCA( NB_ ), A, DESCA( LLD_ ), 0, 0,
248 $ IASEED, MYROW, MYCOL, NPROW, NPCOL )
249 ELSE
250*
251 CALL PDBMATGEN( ICTXT, 'n', UPLO, BWL, BWU, N,
252 $ DESCA( MB_ ), DESCA( NB_ ), A,
253 $ DESCA( LLD_ ), 0, 0, IASEED, MYROW,
254 $ MYCOL, NPROW, NPCOL )
255 ENDIF
256*
257* Matrix formed above has the diagonals shifted from what was
258* input to the tridiagonal routine. Shift them back.
259*
260* Send elements to neighboring processors
261*
262.GT. IF( MYCOL0 ) THEN
263 CALL DGESD2D( ICTXT, 1, 1, A( START+2), LDA,
264 $ MYROW, MYCOL-1 )
265 ENDIF
266*
267.LT. IF( MYCOLNPCOL-1 ) THEN
268 CALL DGESD2D( ICTXT, 1, 1,
269 $ A( START+( DESCA( NB_ )-1 )*LDA ),
270 $ LDA, MYROW, MYCOL+1 )
271 ENDIF
272*
273* Shift local elements
274*
275 DO 220 I=0,DESCA( NB_ )-1
276 A( START+2+(I)*LDA ) = A( START+2+(I+1)*LDA )
277 220 CONTINUE
278*
279 DO 230 I=DESCA( NB_ )-1,0,-1
280 A( START+(I+1)*LDA ) = A( START+(I)*LDA )
281 230 CONTINUE
282*
283* Receive elements from neighboring processors
284*
285.LT. IF( MYCOLNPCOL-1 ) THEN
286 CALL DGERV2D( ICTXT, 1, 1,
287 $ A( START+2+( DESCA( NB_ )-1 )*LDA ),
288 $ LDA, MYROW, MYCOL+1 )
289 ENDIF
290*
291.GT. IF( MYCOL0 ) THEN
292 CALL DGERV2D( ICTXT, 1, 1, A( START), LDA,
293 $ MYROW, MYCOL-1 )
294 ENDIF
295*
296* Loop over the rhs
297*
298 RESID = 0.0
299*
300 DO 40 J = 1, NRHS
301*
302* Multiply A * current column of X
303*
304*
305 CALL PDGBDCMV( BWL+BWU+1, BWL, BWU, TRANS, N, A, 1, DESCA,
306 $ 1, X( 1 + (J-1)*DESCX( LLD_ )), 1, DESCX,
307 $ WORK( IPPRODUCT ), WORK( IPW ),
308 $ (INT_ONE+2)*INT_ONE, INFO )
309*
310*
311* Regenerate column of B
312*
313 CALL PDMATGEN( DESCX( CTXT_ ), 'no', 'no', DESCX( M_ ),
314 $ DESCX( N_ ), DESCX( MB_ ), DESCX( NB_ ),
315 $ WORK( IPB ), DESCX( LLD_ ), DESCX( RSRC_ ),
316 $ DESCX( CSRC_ ), IBSEED, 0, NQ, J-1, 1, MYCOL,
317 $ MYROW, NPCOL, NPROW )
318*
319* Figure || A * X - B || & || X ||
320*
321 CALL PDAXPY( N, -ONE, WORK( IPPRODUCT ), 1, 1, DESCX, 1,
322 $ WORK( IPB ), 1, 1, DESCX, 1 )
323*
324 CALL PDNRM2( N, NORMX,
325 $ X, 1, J, DESCX, 1 )
326*
327 CALL PDNRM2( N, RESID1,
328 $ WORK( IPB ), 1, 1, DESCX, 1 )
329*
330*
331* Calculate residual = ||Ax-b|| / (||x||*||A||*eps*N)
332*
333 RESID1 = RESID1 / ( NORMX*DIVISOR )
334*
335 RESID = MAX( RESID, RESID1 )
336*
337 40 CONTINUE
338*
339 RETURN
340*
341* End of PDTLASCHK
342*
subroutine pdmatgen(ictxt, aform, diag, m, n, mb, nb, a, lda, iarow, iacol, iseed, iroff, irnum, icoff, icnum, myrow, mycol, nprow, npcol)
Definition pdmatgen.f:4
subroutine dlaset(uplo, m, n, alpha, beta, a, lda)
DLASET initializes the off-diagonal elements and the diagonal elements of a matrix to given values.
Definition dlaset.f:110
logical function lsame(ca, cb)
LSAME
Definition lsame.f:53
integer function idamax(n, dx, incx)
IDAMAX
Definition idamax.f:71
subroutine dgemm(transa, transb, m, n, k, alpha, a, lda, b, ldb, beta, c, ldc)
DGEMM
Definition dgemm.f:187
#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 pxerbla(contxt, srname, info)
Definition mpi.f:1600
subroutine dgebr2d(contxt, scope, top, m, n, a, lda)
Definition mpi.f:1123
subroutine blacs_gridinfo(cntxt, nprow, npcol, myrow, mycol)
Definition mpi.f:754
integer function numroc(n, nb, iproc, isrcproc, nprocs)
Definition mpi.f:786
subroutine pbdtran(icontxt, adist, trans, m, n, nb, a, lda, beta, c, ldc, iarow, iacol, icrow, iccol, work)
Definition pbdtran.f:3
double precision function pdlamch(ictxt, cmach)
Definition pdblastst.f:6769