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

Go to the source code of this file.

Functions/Subroutines

subroutine pzunmr2 (side, trans, m, n, k, a, ia, ja, desca, tau, c, ic, jc, descc, work, lwork, info)

Function/Subroutine Documentation

◆ pzunmr2()

subroutine pzunmr2 ( character side,
character trans,
integer m,
integer n,
integer k,
complex*16, dimension( * ) a,
integer ia,
integer ja,
integer, dimension( * ) desca,
complex*16, dimension( * ) tau,
complex*16, dimension( * ) c,
integer ic,
integer jc,
integer, dimension( * ) descc,
complex*16, dimension( * ) work,
integer lwork,
integer info )

Definition at line 1 of file pzunmr2.f.

3*
4* -- ScaLAPACK routine (version 1.7) --
5* University of Tennessee, Knoxville, Oak Ridge National Laboratory,
6* and University of California, Berkeley.
7* May 25, 2001
8*
9* .. Scalar Arguments ..
10 CHARACTER SIDE, TRANS
11 INTEGER IA, IC, INFO, JA, JC, K, LWORK, M, N
12* ..
13* .. Array Arguments ..
14 INTEGER DESCA( * ), DESCC( * )
15 COMPLEX*16 A( * ), C( * ), TAU( * ), WORK( * )
16* ..
17*
18* Purpose
19* =======
20*
21* PZUNMR2 overwrites the general complex M-by-N distributed matrix
22* sub( C ) = C(IC:IC+M-1,JC:JC+N-1) with
23*
24* SIDE = 'L' SIDE = 'R'
25* TRANS = 'N': Q * sub( C ) sub( C ) * Q
26* TRANS = 'C': Q**H * sub( C ) sub( C ) * Q**H
27*
28* where Q is a complex unitary distributed matrix defined as the
29* product of K elementary reflectors
30*
31* Q = H(1)' H(2)' . . . H(k)'
32*
33* as returned by PZGERQF. Q is of order M if SIDE = 'L' and of order N
34* if SIDE = 'R'.
35*
36* Notes
37* =====
38*
39* Each global data object is described by an associated description
40* vector. This vector stores the information required to establish
41* the mapping between an object element and its corresponding process
42* and memory location.
43*
44* Let A be a generic term for any 2D block cyclicly distributed array.
45* Such a global array has an associated description vector DESCA.
46* In the following comments, the character _ should be read as
47* "of the global array".
48*
49* NOTATION STORED IN EXPLANATION
50* --------------- -------------- --------------------------------------
51* DTYPE_A(global) DESCA( DTYPE_ )The descriptor type. In this case,
52* DTYPE_A = 1.
53* CTXT_A (global) DESCA( CTXT_ ) The BLACS context handle, indicating
54* the BLACS process grid A is distribu-
55* ted over. The context itself is glo-
56* bal, but the handle (the integer
57* value) may vary.
58* M_A (global) DESCA( M_ ) The number of rows in the global
59* array A.
60* N_A (global) DESCA( N_ ) The number of columns in the global
61* array A.
62* MB_A (global) DESCA( MB_ ) The blocking factor used to distribute
63* the rows of the array.
64* NB_A (global) DESCA( NB_ ) The blocking factor used to distribute
65* the columns of the array.
66* RSRC_A (global) DESCA( RSRC_ ) The process row over which the first
67* row of the array A is distributed.
68* CSRC_A (global) DESCA( CSRC_ ) The process column over which the
69* first column of the array A is
70* distributed.
71* LLD_A (local) DESCA( LLD_ ) The leading dimension of the local
72* array. LLD_A >= MAX(1,LOCr(M_A)).
73*
74* Let K be the number of rows or columns of a distributed matrix,
75* and assume that its process grid has dimension p x q.
76* LOCr( K ) denotes the number of elements of K that a process
77* would receive if K were distributed over the p processes of its
78* process column.
79* Similarly, LOCc( K ) denotes the number of elements of K that a
80* process would receive if K were distributed over the q processes of
81* its process row.
82* The values of LOCr() and LOCc() may be determined via a call to the
83* ScaLAPACK tool function, NUMROC:
84* LOCr( M ) = NUMROC( M, MB_A, MYROW, RSRC_A, NPROW ),
85* LOCc( N ) = NUMROC( N, NB_A, MYCOL, CSRC_A, NPCOL ).
86* An upper bound for these quantities may be computed by:
87* LOCr( M ) <= ceil( ceil(M/MB_A)/NPROW )*MB_A
88* LOCc( N ) <= ceil( ceil(N/NB_A)/NPCOL )*NB_A
89*
90* Arguments
91* =========
92*
93* SIDE (global input) CHARACTER
94* = 'L': apply Q or Q**H from the Left;
95* = 'R': apply Q or Q**H from the Right.
96*
97* TRANS (global input) CHARACTER
98* = 'N': No transpose, apply Q;
99* = 'C': Conjugate transpose, apply Q**H.
100*
101* M (global input) INTEGER
102* The number of rows to be operated on i.e the number of rows
103* of the distributed submatrix sub( C ). M >= 0.
104*
105* N (global input) INTEGER
106* The number of columns to be operated on i.e the number of
107* columns of the distributed submatrix sub( C ). N >= 0.
108*
109* K (global input) INTEGER
110* The number of elementary reflectors whose product defines the
111* matrix Q. If SIDE = 'L', M >= K >= 0, if SIDE = 'R',
112* N >= K >= 0.
113*
114* A (local input) COMPLEX*16 pointer into the local memory
115* to an array of dimension (LLD_A,LOCc(JA+M-1)) if SIDE='L',
116* and (LLD_A,LOCc(JA+N-1)) if SIDE='R', where
117* LLD_A >= MAX(1,LOCr(IA+K-1)); On entry, the i-th row must
118* contain the vector which defines the elementary reflector
119* H(i), IA <= i <= IA+K-1, as returned by PZGERQF in the
120* K rows of its distributed matrix argument A(IA:IA+K-1,JA:*).
121* A(IA:IA+K-1,JA:*) is modified by the routine but restored on
122* exit.
123*
124* IA (global input) INTEGER
125* The row index in the global array A indicating the first
126* row of sub( A ).
127*
128* JA (global input) INTEGER
129* The column index in the global array A indicating the
130* first column of sub( A ).
131*
132* DESCA (global and local input) INTEGER array of dimension DLEN_.
133* The array descriptor for the distributed matrix A.
134*
135* TAU (local input) COMPLEX*16, array, dimension LOCc(IA+K-1).
136* This array contains the scalar factors TAU(i) of the
137* elementary reflectors H(i) as returned by PZGERQF.
138* TAU is tied to the distributed matrix A.
139*
140* C (local input/local output) COMPLEX*16 pointer into the
141* local memory to an array of dimension (LLD_C,LOCc(JC+N-1)).
142* On entry, the local pieces of the distributed matrix sub(C).
143* On exit, sub( C ) is overwritten by Q*sub( C ) or Q'*sub( C )
144* or sub( C )*Q' or sub( C )*Q.
145*
146* IC (global input) INTEGER
147* The row index in the global array C indicating the first
148* row of sub( C ).
149*
150* JC (global input) INTEGER
151* The column index in the global array C indicating the
152* first column of sub( C ).
153*
154* DESCC (global and local input) INTEGER array of dimension DLEN_.
155* The array descriptor for the distributed matrix C.
156*
157* WORK (local workspace/local output) COMPLEX*16 array,
158* dimension (LWORK)
159* On exit, WORK(1) returns the minimal and optimal LWORK.
160*
161* LWORK (local or global input) INTEGER
162* The dimension of the array WORK.
163* LWORK is local input and must be at least
164* If SIDE = 'L', LWORK >= MpC0 + MAX( MAX( 1, NqC0 ), NUMROC(
165* NUMROC( M+IROFFC,MB_A,0,0,NPROW ),MB_A,0,0,LCMP ) );
166* if SIDE = 'R', LWORK >= NqC0 + MAX( 1, MpC0 );
167*
168* where LCMP = LCM / NPROW with LCM = ICLM( NPROW, NPCOL ),
169*
170* IROFFC = MOD( IC-1, MB_C ), ICOFFC = MOD( JC-1, NB_C ),
171* ICROW = INDXG2P( IC, MB_C, MYROW, RSRC_C, NPROW ),
172* ICCOL = INDXG2P( JC, NB_C, MYCOL, CSRC_C, NPCOL ),
173* MpC0 = NUMROC( M+IROFFC, MB_C, MYROW, ICROW, NPROW ),
174* NqC0 = NUMROC( N+ICOFFC, NB_C, MYCOL, ICCOL, NPCOL ),
175*
176* ILCM, INDXG2P and NUMROC are ScaLAPACK tool functions;
177* MYROW, MYCOL, NPROW and NPCOL can be determined by calling
178* the subroutine BLACS_GRIDINFO.
179*
180* If LWORK = -1, then LWORK is global input and a workspace
181* query is assumed; the routine only calculates the minimum
182* and optimal size for all work arrays. Each of these
183* values is returned in the first entry of the corresponding
184* work array, and no error message is issued by PXERBLA.
185*
186*
187* INFO (local output) INTEGER
188* = 0: successful exit
189* < 0: If the i-th argument is an array and the j-entry had
190* an illegal value, then INFO = -(i*100+j), if the i-th
191* argument is a scalar and had an illegal value, then
192* INFO = -i.
193*
194* Alignment requirements
195* ======================
196*
197* The distributed submatrices A(IA:*, JA:*) and C(IC:IC+M-1,JC:JC+N-1)
198* must verify some alignment properties, namely the following
199* expressions should be true:
200*
201* If SIDE = 'L',
202* ( NB_A.EQ.MB_C .AND. ICOFFA.EQ.IROFFC )
203* If SIDE = 'R',
204* ( NB_A.EQ.NB_C .AND. ICOFFA.EQ.ICOFFC .AND. IACOL.EQ.ICCOL )
205*
206* =====================================================================
207*
208* .. Parameters ..
209 INTEGER BLOCK_CYCLIC_2D, CSRC_, CTXT_, DLEN_, DTYPE_,
210 $ LLD_, MB_, M_, NB_, N_, RSRC_
211 parameter( block_cyclic_2d = 1, dlen_ = 9, dtype_ = 1,
212 $ ctxt_ = 2, m_ = 3, n_ = 4, mb_ = 5, nb_ = 6,
213 $ rsrc_ = 7, csrc_ = 8, lld_ = 9 )
214 COMPLEX*16 ONE
215 parameter( one = ( 1.0d+0, 0.0d+0 ) )
216* ..
217* .. Local Scalars ..
218 LOGICAL LEFT, LQUERY, NOTRAN
219 CHARACTER COLBTOP, ROWBTOP
220 INTEGER I, I1, I2, I3, IACOL, ICCOL, ICOFFA, ICOFFC,
221 $ ICROW, ICTXT, IROFFC, LCM, LCMP, LWMIN, MI,
222 $ MPC0, MYCOL, MYROW, NI, NPCOL, NPROW, NQ, NQC0
223 COMPLEX*16 AII
224* ..
225* .. External Subroutines ..
226 EXTERNAL blacs_abort, blacs_gridinfo, chk1mat,
227 $ pb_topget, pb_topset, pxerbla, pzelset,
229* ..
230* .. External Functions ..
231 LOGICAL LSAME
232 INTEGER ILCM, INDXG2P, NUMROC
233 EXTERNAL ilcm, indxg2p, lsame, numroc
234* ..
235* .. Intrinsic Functions ..
236 INTRINSIC dble, dcmplx, max, mod
237* ..
238* .. Executable Statements ..
239*
240* Get grid parameters
241*
242 ictxt = desca( ctxt_ )
243 CALL blacs_gridinfo( ictxt, nprow, npcol, myrow, mycol )
244*
245* Test the input parameters
246*
247 info = 0
248 IF( nprow.EQ.-1 ) THEN
249 info = -(900+ctxt_)
250 ELSE
251 left = lsame( side, 'l' )
252 NOTRAN = LSAME( TRANS, 'n' )
253*
254* NQ is the order of Q
255*
256 IF( LEFT ) THEN
257 NQ = M
258 CALL CHK1MAT( K, 5, M, 3, IA, JA, DESCA, 9, INFO )
259 ELSE
260 NQ = N
261 CALL CHK1MAT( K, 5, N, 4, IA, JA, DESCA, 9, INFO )
262 END IF
263 CALL CHK1MAT( M, 3, N, 4, IC, JC, DESCC, 14, INFO )
264.EQ. IF( INFO0 ) THEN
265 ICOFFA = MOD( JA-1, DESCA( NB_ ) )
266 IROFFC = MOD( IC-1, DESCC( MB_ ) )
267 ICOFFC = MOD( JC-1, DESCC( NB_ ) )
268 IACOL = INDXG2P( JA, DESCA( NB_ ), MYCOL, DESCA( CSRC_ ),
269 $ NPCOL )
270 ICROW = INDXG2P( IC, DESCC( MB_ ), MYROW, DESCC( RSRC_ ),
271 $ NPROW )
272 ICCOL = INDXG2P( JC, DESCC( NB_ ), MYCOL, DESCC( CSRC_ ),
273 $ NPCOL )
274 MPC0 = NUMROC( M+IROFFC, DESCC( MB_ ), MYROW, ICROW, NPROW )
275 NQC0 = NUMROC( N+ICOFFC, DESCC( NB_ ), MYCOL, ICCOL, NPCOL )
276*
277 IF( LEFT ) THEN
278 LCM = ILCM( NPROW, NPCOL )
279 LCMP = LCM / NPROW
280 LWMIN = MPC0 + MAX( MAX( 1, NQC0 ), NUMROC( NUMROC(
281 $ M+IROFFC, DESCA( MB_ ), 0, 0, NPROW ),
282 $ DESCA( MB_ ), 0, 0, LCMP ) )
283 ELSE
284 LWMIN = NQC0 + MAX( 1, MPC0 )
285 END IF
286*
287 WORK( 1 ) = DCMPLX( DBLE( LWMIN ) )
288.EQ. LQUERY = ( LWORK-1 )
289.NOT..AND..NOT. IF( LEFT LSAME( SIDE, 'r' ) ) THEN
290 INFO = -1
291.NOT..AND..NOT. ELSE IF( NOTRAN LSAME( TRANS, 'c' ) ) THEN
292 INFO = -2
293.LT..OR..GT. ELSE IF( K0 KNQ ) THEN
294 INFO = -5
295.AND..NE. ELSE IF( LEFT DESCA( NB_ )DESCC( MB_ ) ) THEN
296 INFO = -(900+NB_)
297.AND..NE. ELSE IF( LEFT ICOFFAIROFFC ) THEN
298 INFO = -12
299.NOT..AND..NE. ELSE IF( LEFT ICOFFAICOFFC ) THEN
300 INFO = -13
301.NOT..AND..NE. ELSE IF( LEFT IACOLICCOL ) THEN
302 INFO = -13
303.NOT..AND..NE. ELSE IF( LEFT DESCA( NB_ )DESCC( NB_ ) ) THEN
304 INFO = -(1400+NB_)
305.NE. ELSE IF( ICTXTDESCC( CTXT_ ) ) THEN
306 INFO = -(1400+CTXT_)
307.LT..AND..NOT. ELSE IF( LWORKLWMIN LQUERY ) THEN
308 INFO = -16
309 END IF
310 END IF
311 END IF
312*
313.NE. IF( INFO0 ) THEN
314 CALL PXERBLA( ICTXT, 'pzunmr2', -INFO )
315 CALL BLACS_ABORT( ICTXT, 1 )
316 RETURN
317 ELSE IF( LQUERY ) THEN
318 RETURN
319 END IF
320*
321* Quick return if possible
322*
323.EQ..OR..EQ..OR..EQ. IF( M0 N0 K0 )
324 $ RETURN
325*
326 CALL PB_TOPGET( ICTXT, 'broadcast', 'rowwise', ROWBTOP )
327 CALL PB_TOPGET( ICTXT, 'broadcast', 'columnwise', COLBTOP )
328*
329.AND..NOT..OR..NOT..AND. IF( ( LEFT NOTRAN LEFT NOTRAN ) ) THEN
330 I1 = IA
331 I2 = IA + K - 1
332 I3 = 1
333 ELSE
334 I1 = IA + K - 1
335 I2 = IA
336 I3 = -1
337 END IF
338*
339 IF( LEFT ) THEN
340 NI = N
341 ELSE
342 MI = M
343 CALL PB_TOPSET( ICTXT, 'broadcast', 'rowwise', ' ' )
344 IF( NOTRAN ) THEN
345 CALL PB_TOPSET( ICTXT, 'broadcast', 'columnwise', 'i-ring' )
346 ELSE
347 CALL PB_TOPSET( ICTXT, 'broadcast', 'columnwise', 'd-ring' )
348 END IF
349 END IF
350*
351 DO 10 I = I1, I2, I3
352 IF( LEFT ) THEN
353*
354* H(i) or H(i)' is applied to C(ic:ic+m-k+i-ia,jc:jc+n-1)
355*
356 MI = M - K + I - IA + 1
357 ELSE
358*
359* H(i) or H(i)' is applied to C(ic:ic+m-1,jc:jc+n-k+i-ia+1)
360*
361 NI = N - K + I - IA + 1
362 END IF
363*
364* Apply H(i) or H(i)'
365*
366 CALL PZLACGV( NQ-K+I-IA, A, I, JA, DESCA, DESCA( M_ ) )
367 CALL PZELSET2( AII, A, I, JA+NQ-K+I-IA, DESCA, ONE )
368 IF( NOTRAN ) THEN
369 CALL PZLARFC( SIDE, MI, NI, A, I, JA, DESCA, DESCA( M_ ),
370 $ TAU, C, IC, JC, DESCC, WORK )
371 ELSE
372 CALL PZLARF( SIDE, MI, NI, A, I, JA, DESCA, DESCA( M_ ),
373 $ TAU, C, IC, JC, DESCC, WORK )
374 END IF
375 CALL PZELSET( A, I, JA+NQ-K+I-IA, DESCA, AII )
376 CALL PZLACGV( NQ-K+I-IA, A, I, JA, DESCA, DESCA( M_ ) )
377*
378 10 CONTINUE
379*
380 CALL PB_TOPSET( ICTXT, 'broadcast', 'rowwise', ROWBTOP )
381 CALL PB_TOPSET( ICTXT, 'broadcast', 'columnwise', COLBTOP )
382*
383 WORK( 1 ) = DCMPLX( DBLE( LWMIN ) )
384*
385 RETURN
386*
387* End of PZUNMR2
388*
logical function lsame(ca, cb)
LSAME
Definition lsame.f:53
integer function ilcm(m, n)
Definition ilcm.f:2
#define max(a, b)
Definition macros.h:21
integer function indxg2p(indxglob, nb, iproc, isrcproc, nprocs)
Definition mpi.f:947
subroutine chk1mat(ma, mapos0, na, napos0, ia, ja, desca, descapos0, info)
Definition mpi.f:1577
subroutine pxerbla(contxt, srname, info)
Definition mpi.f:1600
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 pzelset2(alpha, a, ia, ja, desca, beta)
Definition pzelset2.f:2
subroutine pzelset(a, ia, ja, desca, alpha)
Definition pzelset.f:2
subroutine pzlacgv(n, x, ix, jx, descx, incx)
Definition pzlacgv.f:2
subroutine pzlarf(side, m, n, v, iv, jv, descv, incv, tau, c, ic, jc, descc, work)
Definition pzlarf.f:3
subroutine pzlarfc(side, m, n, v, iv, jv, descv, incv, tau, c, ic, jc, descc, work)
Definition pzlarfc.f:3
subroutine pzunmr2(side, trans, m, n, k, a, ia, ja, desca, tau, c, ic, jc, descc, work, lwork, info)
Definition pzunmr2.f:3