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

Go to the source code of this file.

Functions/Subroutines

subroutine pdlafchk (aform, diag, m, n, a, ia, ja, desca, iaseed, anorm, fresid, work)

Function/Subroutine Documentation

◆ pdlafchk()

subroutine pdlafchk ( character aform,
character diag,
integer m,
integer n,
double precision, dimension( * ) a,
integer ia,
integer ja,
integer, dimension( * ) desca,
integer iaseed,
double precision anorm,
double precision fresid,
double precision, dimension( * ) work )

Definition at line 1 of file pdlafchk.f.

3*
4* -- ScaLAPACK auxiliary routine (version 1.7) --
5* University of Tennessee, Knoxville, Oak Ridge National Laboratory,
6* and University of California, Berkeley.
7* May 1, 1997
8*
9* .. Scalar Arguments ..
10 CHARACTER AFORM, DIAG
11 INTEGER IA, IASEED, JA, M, N
12 DOUBLE PRECISION ANORM, FRESID
13* ..
14* .. Array Arguments ..
15 INTEGER DESCA( * )
16 DOUBLE PRECISION A( * ), WORK( * )
17* ..
18*
19* Purpose
20* =======
21*
22* PDLAFCHK computes the residual
23* || sub( A ) - sub( Ao ) || / (|| sub( Ao ) ||*eps*MAX(M,N)),
24* where Ao will be regenerated by the parallel random matrix generator,
25* sub( A ) = A( IA:IA+M-1, JA:JA+N-1 ) and ||.|| stands for the infini-
26* ty norm.
27*
28* Notes
29* =====
30*
31* Each global data object is described by an associated description
32* vector. This vector stores the information required to establish
33* the mapping between an object element and its corresponding process
34* and memory location.
35*
36* Let A be a generic term for any 2D block cyclicly distributed array.
37* Such a global array has an associated description vector DESCA.
38* In the following comments, the character _ should be read as
39* "of the global array".
40*
41* NOTATION STORED IN EXPLANATION
42* --------------- -------------- --------------------------------------
43* DTYPE_A(global) DESCA( DTYPE_ )The descriptor type. In this case,
44* DTYPE_A = 1.
45* CTXT_A (global) DESCA( CTXT_ ) The BLACS context handle, indicating
46* the BLACS process grid A is distribu-
47* ted over. The context itself is glo-
48* bal, but the handle (the integer
49* value) may vary.
50* M_A (global) DESCA( M_ ) The number of rows in the global
51* array A.
52* N_A (global) DESCA( N_ ) The number of columns in the global
53* array A.
54* MB_A (global) DESCA( MB_ ) The blocking factor used to distribute
55* the rows of the array.
56* NB_A (global) DESCA( NB_ ) The blocking factor used to distribute
57* the columns of the array.
58* RSRC_A (global) DESCA( RSRC_ ) The process row over which the first
59* row of the array A is distributed.
60* CSRC_A (global) DESCA( CSRC_ ) The process column over which the
61* first column of the array A is
62* distributed.
63* LLD_A (local) DESCA( LLD_ ) The leading dimension of the local
64* array. LLD_A >= MAX(1,LOCr(M_A)).
65*
66* Let K be the number of rows or columns of a distributed matrix,
67* and assume that its process grid has dimension p x q.
68* LOCr( K ) denotes the number of elements of K that a process
69* would receive if K were distributed over the p processes of its
70* process column.
71* Similarly, LOCc( K ) denotes the number of elements of K that a
72* process would receive if K were distributed over the q processes of
73* its process row.
74* The values of LOCr() and LOCc() may be determined via a call to the
75* ScaLAPACK tool function, NUMROC:
76* LOCr( M ) = NUMROC( M, MB_A, MYROW, RSRC_A, NPROW ),
77* LOCc( N ) = NUMROC( N, NB_A, MYCOL, CSRC_A, NPCOL ).
78* An upper bound for these quantities may be computed by:
79* LOCr( M ) <= ceil( ceil(M/MB_A)/NPROW )*MB_A
80* LOCc( N ) <= ceil( ceil(N/NB_A)/NPCOL )*NB_A
81*
82* Arguments
83* =========
84*
85* AFORM (global input) CHARACTER
86* sub( A ) is overwritten with:
87* - a symmetric matrix, if AFORM = 'S';
88* - a Hermitian matrix, if AFORM = 'H';
89* - the transpose of what would normally be generated,
90* if AFORM = 'T';
91* - the conjugate transpose of what would normally be
92* generated, if AFORM = 'C';
93* - otherwise a random matrix.
94*
95* DIAG (global input) CHARACTER
96* if DIAG = 'D' : sub( A ) is diagonally dominant.
97*
98* M (global input) INTEGER
99* The number of rows to be operated on, i.e. the number of rows
100* of the distributed submatrix sub( A ). M >= 0.
101*
102* N (global input) INTEGER
103* The number of columns to be operated on, i.e. the number of
104* columns of the distributed submatrix sub( A ). N >= 0.
105*
106* A (local input/local output) DOUBLE PRECISION pointer into the
107* local memory to an array of dimension (LLD_A,LOCc(JA+N-1)).
108* On entry, this array contains the local pieces of the M-by-N
109* distributed matrix sub( A ) to be checked. On exit, this
110* array contains the local pieces of the difference
111* sub( A ) - sub( Ao ).
112*
113* IA (global input) INTEGER
114* The row index in the global array A indicating the first
115* row of sub( A ).
116*
117* JA (global input) INTEGER
118* The column index in the global array A indicating the
119* first column of sub( A ).
120*
121* DESCA (global and local input) INTEGER array of dimension DLEN_.
122* The array descriptor for the distributed matrix A.
123*
124* IASEED (global input) INTEGER
125* The seed number to generate the original matrix Ao.
126*
127* ANORM (global input) DOUBLE PRECISION
128* The Infinity norm of sub( A ).
129*
130* FRESID (global output) DOUBLE PRECISION
131* The maximum (worst) factorizational error.
132*
133* WORK (local workspace) DOUBLE PRECISION array, dimension (LWORK).
134* LWORK >= MpA0 * NB_A, where
135*
136* IROFFA = MOD( IA-1, MB_A ),
137* IAROW = INDXG2P( IA, MB_A, MYROW, RSRC_A, NPROW ),
138* MpA0 = NUMROC( M+IROFFA, MB_A, MYROW, IAROW, NPROW ),
139*
140* WORK is used to store a block of columns of sub( A ).
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
154 parameter( one = 1.0d+0 )
155* ..
156* .. Local Scalars ..
157 INTEGER IACOL, IAROW, ICOFF, ICTXT, IIA, IOFFA, IROFF,
158 $ JB, JJ, JJA, JN, LDA, LDW, MP, MYCOL, MYROW,
159 $ NPCOL, NPROW, NQ
160 DOUBLE PRECISION EPS
161* ..
162* .. External Subroutines ..
164* ..
165* .. External Functions ..
166 INTEGER ICEIL, NUMROC
167 DOUBLE PRECISION PDLAMCH, PDLANGE
168 EXTERNAL iceil, numroc, pdlamch, pdlange
169* ..
170* .. Intrinsic Functions ..
171 INTRINSIC max, min, mod
172* ..
173* .. Executable Statements ..
174*
175 ictxt = desca( ctxt_ )
176 CALL blacs_gridinfo( ictxt, nprow, npcol, myrow, mycol )
177 eps = pdlamch( ictxt, 'eps' )
178 CALL INFOG2L( IA, JA, DESCA, NPROW, NPCOL, MYROW, MYCOL, IIA, JJA,
179 $ IAROW, IACOL )
180*
181* Compute sub( A ) := sub( A ) - sub( Ao )
182*
183 IROFF = MOD( IA-1, DESCA( MB_ ) )
184 ICOFF = MOD( JA-1, DESCA( NB_ ) )
185 MP = NUMROC( M+IROFF, DESCA( MB_ ), MYROW, IAROW, NPROW )
186 NQ = NUMROC( N+ICOFF, DESCA( NB_ ), MYCOL, IACOL, NPCOL )
187.EQ. IF( MYROWIAROW )
188 $ MP = MP-IROFF
189.EQ. IF( MYCOLIACOL )
190 $ NQ = NQ-ICOFF
191 JN = MIN( ICEIL( JA, DESCA( NB_ ) ) * DESCA( NB_ ), JA+N-1 )
192 LDW = MAX( 1, MP )
193 LDA = DESCA( LLD_ )
194 IOFFA = IIA + ( JJA - 1 )*LDA
195*
196* Handle first block of columns separately
197*
198.EQ. IF( MYCOLIACOL ) THEN
199 JB = JN-JA+1
200 CALL PDMATGEN( ICTXT, AFORM, DIAG, DESCA( M_ ), DESCA( N_ ),
201 $ DESCA( MB_ ), DESCA( NB_ ), WORK, LDW,
202 $ DESCA( RSRC_ ), DESCA( CSRC_ ), IASEED, IIA-1,
203 $ MP, JJA-1, JB, MYROW, MYCOL, NPROW, NPCOL )
204 CALL DMATADD( MP, JB, -ONE, WORK, LDW, ONE, A( IOFFA ), LDA )
205 JJA = JJA + JB
206 NQ = NQ - JB
207 IOFFA = IOFFA + JB * LDA
208 END IF
209*
210* Handle the remaning blocks of columns
211*
212 DO 10 JJ = JJA, JJA+NQ-1, DESCA( NB_ )
213 JB = MIN( DESCA( NB_ ), JJA+NQ-JJ )
214 IOFFA = IIA + ( JJ - 1 ) * LDA
215 CALL PDMATGEN( ICTXT, AFORM, DIAG, DESCA( M_ ), DESCA( N_ ),
216 $ DESCA( MB_ ), DESCA( NB_ ), WORK, LDW,
217 $ DESCA( RSRC_ ), DESCA( CSRC_ ), IASEED, IIA-1,
218 $ MP, JJ-1, JB, MYROW, MYCOL, NPROW, NPCOL )
219 CALL DMATADD( MP, JB, -ONE, WORK, LDW, ONE, A( IOFFA ), LDA )
220 10 CONTINUE
221*
222* Calculate factor residual
223*
224 FRESID = PDLANGE( 'i', M, N, A, IA, JA, DESCA, WORK ) /
225 $ ( MAX( M, N ) * EPS * ANORM )
226*
227 RETURN
228*
229* End PDLAFCHK
230*
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 dmatadd(m, n, alpha, a, lda, beta, c, ldc)
Definition dmatadd.f:2
integer function iceil(inum, idenom)
Definition iceil.f:2
#define min(a, b)
Definition macros.h:20
#define max(a, b)
Definition macros.h:21
subroutine infog2l(grindx, gcindx, desc, nprow, npcol, myrow, mycol, lrindx, lcindx, rsrc, csrc)
Definition mpi.f:937
double precision function pdlange(norm, m, n, a, ia, ja, desca, work)
Definition mpi.f:1311
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 pdlamch(ictxt, cmach)
Definition pdblastst.f:6769