ScaLAPACK 2.1  2.1
ScaLAPACK: Scalable Linear Algebra PACKage
pdlared2d.f
Go to the documentation of this file.
1  SUBROUTINE pdlared2d( N, IA, JA, DESC, BYROW, BYALL, WORK, LWORK )
2 *
3 * -- ScaLAPACK routine (version 1.7) --
4 * University of Tennessee, Knoxville, Oak Ridge National Laboratory,
5 * and University of California, Berkeley.
6 * December 12, 2005
7 *
8 * .. Scalar Arguments ..
9  INTEGER IA, JA, LWORK, N
10 * ..
11 * .. Array Arguments ..
12  INTEGER DESC( * )
13  DOUBLE PRECISION BYALL( * ), BYROW( * ), WORK( LWORK )
14 * ..
15 *
16 * Purpose
17 * =======
18 *
19 * PDLARED2D redistributes a 1D array
20 *
21 * It assumes that the input array, BYROW, is distributed across
22 * columns and that all process rows contain the same copy of
23 * BYROW. The output array, BYALL, will be identical on all processes
24 * and will contain the entire array.
25 *
26 * Notes
27 * =====
28 *
29 * Each global data object is described by an associated description
30 * vector. This vector stores the information required to establish
31 * the mapping between an object element and its corresponding process
32 * and memory location.
33 *
34 * Let A be a generic term for any 2D block cyclicly distributed array.
35 * Such a global array has an associated description vector DESCA.
36 * In the following comments, the character _ should be read as
37 * "of the global array".
38 *
39 * NOTATION STORED IN EXPLANATION
40 * --------------- -------------- --------------------------------------
41 * DTYPE_A(global) DESCA( DTYPE_ )The descriptor type. In this case,
42 * DTYPE_A = 1.
43 * CTXT_A (global) DESCA( CTXT_ ) The BLACS context handle, indicating
44 * the BLACS process grid A is distribu-
45 * ted over. The context itself is glo-
46 * bal, but the handle (the integer
47 * value) may vary.
48 * M_A (global) DESCA( M_ ) The number of rows in the global
49 * array A.
50 * N_A (global) DESCA( N_ ) The number of columns in the global
51 * array A.
52 * MB_A (global) DESCA( MB_ ) The blocking factor used to distribute
53 * the rows of the array.
54 * NB_A (global) DESCA( NB_ ) The blocking factor used to distribute
55 * the columns of the array.
56 * RSRC_A (global) DESCA( RSRC_ ) The process row over which the first
57 * row of the array A is distributed.
58 * CSRC_A (global) DESCA( CSRC_ ) The process column over which the
59 * first column of the array A is
60 * distributed.
61 * LLD_A (local) DESCA( LLD_ ) The leading dimension of the local
62 * array. LLD_A >= MAX(1,LOCr(M_A)).
63 *
64 * Let K be the number of rows or columns of a distributed matrix,
65 * and assume that its process grid has dimension p x q.
66 * LOCr( K ) denotes the number of elements of K that a process
67 * would receive if K were distributed over the p processes of its
68 * process column.
69 * Similarly, LOCc( K ) denotes the number of elements of K that a
70 * process would receive if K were distributed over the q processes of
71 * its process row.
72 * The values of LOCr() and LOCc() may be determined via a call to the
73 * ScaLAPACK tool function, NUMROC:
74 * LOCr( M ) = NUMROC( M, MB_A, MYROW, RSRC_A, NPROW ),
75 * LOCc( N ) = NUMROC( N, NB_A, MYCOL, CSRC_A, NPCOL ).
76 * An upper bound for these quantities may be computed by:
77 * LOCr( M ) <= ceil( ceil(M/MB_A)/NPROW )*MB_A
78 * LOCc( N ) <= ceil( ceil(N/NB_A)/NPCOL )*NB_A
79 *
80 * Arguments
81 * =========
82 *
83 * NP = Number of local rows in BYROW()
84 *
85 * N (global input) INTEGER
86 * The number of elements to be redistributed. N >= 0.
87 *
88 * IA (global input) INTEGER
89 * IA must be equal to 1
90 *
91 * JA (global input) INTEGER
92 * JA must be equal to 1
93 *
94 * DESC (global/local input) INTEGER Array of dimension DLEN_
95 * A 2D array descriptor, which describes BYROW
96 *
97 * BYROW (local input) distributed block cyclic DOUBLE PRECISION array
98 * global dimension (N), local dimension (NP)
99 * BYROW is distributed across the process columns
100 * All process rows are assumed to contain the same value
101 *
102 * BYALL (global output) DOUBLE PRECISION global dimension( N )
103 * local dimension (N)
104 * BYALL is exactly duplicated on all processes
105 * It contains the same values as BYROW, but it is replicated
106 * across all processes rather than being distributed
107 *
108 * BYALL(i) = BYROW( NUMROC(i,DESC( MB_ ),MYCOL,0,NPCOL ) on the procs
109 * whose MYCOL == mod((i-1)/DESC( MB_ ),NPCOL)
110 *
111 * WORK (local workspace) DOUBLE PRECISION dimension (LWORK)
112 * Used to hold the buffers sent from one process to another
113 *
114 * LWORK (local input) INTEGER size of WORK array
115 * LWORK >= NUMROC(N, DESC( MB_ ), 0, 0, NPROW)
116 *
117 * .. Parameters ..
118  INTEGER BLOCK_CYCLIC_2D, DLEN_, DTYPE_, CTXT_, M_, N_,
119  $ MB_, NB_, RSRC_, CSRC_, LLD_
120  parameter( block_cyclic_2d = 1, dlen_ = 9, dtype_ = 1,
121  $ ctxt_ = 2, m_ = 3, n_ = 4, mb_ = 5, nb_ = 6,
122  $ rsrc_ = 7, csrc_ = 8, lld_ = 9 )
123 * ..
124 * .. Local Scalars ..
125  INTEGER ALLI, BUFLEN, I, II, MB, MYCOL, MYROW, NPCOL,
126  $ NPROW, PROW
127 * ..
128 * .. External Functions ..
129  INTEGER NUMROC
130  EXTERNAL numroc
131 * ..
132 * .. External Subroutines ..
133  EXTERNAL blacs_gridinfo, dcopy, dgebr2d, dgebs2d
134 * ..
135 * .. Intrinsic Functions ..
136  INTRINSIC min
137 * ..
138 * .. Executable Statements ..
139 * This is just to keep ftnchek happy
140  IF( block_cyclic_2d*csrc_*ctxt_*dlen_*dtype_*lld_*mb_*m_*nb_*n_*
141  $ rsrc_.LT.0 )RETURN
142 *
143  CALL blacs_gridinfo( desc( ctxt_ ), nprow, npcol, myrow, mycol )
144  mb = desc( mb_ )
145 *
146  DO 30 prow = 0, nprow - 1
147  buflen = numroc( n, mb, prow, 0, nprow )
148  IF( myrow.EQ.prow ) THEN
149  CALL dcopy( buflen, byrow, 1, work, 1 )
150  CALL dgebs2d( desc( ctxt_ ), 'C', ' ', buflen, 1, work,
151  $ buflen )
152  ELSE
153  CALL dgebr2d( desc( ctxt_ ), 'C', ' ', buflen, 1, work,
154  $ buflen, prow, mycol )
155  END IF
156 *
157  alli = prow*mb
158  DO 20 ii = 1, buflen, mb
159  DO 10 i = 1, min( mb, buflen-ii+1 )
160  byall( alli+i ) = work( ii-1+i )
161  10 CONTINUE
162  alli = alli + mb*nprow
163  20 CONTINUE
164  30 CONTINUE
165 *
166  RETURN
167 *
168 * End of PSLARED2D
169 *
170  END
pdlared2d
subroutine pdlared2d(N, IA, JA, DESC, BYROW, BYALL, WORK, LWORK)
Definition: pdlared2d.f:2
min
#define min(A, B)
Definition: pcgemr.c:181