ScaLAPACK  2.0.2
ScaLAPACK: Scalable Linear Algebra PACKage
pdlaswp.f
Go to the documentation of this file.
00001       SUBROUTINE PDLASWP( DIREC, ROWCOL, N, A, IA, JA, DESCA, K1, K2,
00002      $                    IPIV )
00003 *
00004 *  -- ScaLAPACK auxiliary routine (version 1.7) --
00005 *     University of Tennessee, Knoxville, Oak Ridge National Laboratory,
00006 *     and University of California, Berkeley.
00007 *     May 1, 1997
00008 *
00009 *     .. Scalar Arguments ..
00010       CHARACTER          DIREC, ROWCOL
00011       INTEGER            IA, JA, K1, K2, N
00012 *     ..
00013 *     .. Array Arguments ..
00014       INTEGER            DESCA( * ), IPIV( * )
00015       DOUBLE PRECISION   A( * )
00016 *     ..
00017 *
00018 *  Purpose:
00019 *  ========
00020 *
00021 *  PDLASWP performs a series of row or column interchanges on
00022 *  the distributed matrix sub( A ) = A(IA:IA+M-1,JA:JA+N-1).  One
00023 *  interchange is initiated for each of rows or columns K1 trough K2 of
00024 *  sub( A ). This routine assumes that the pivoting information has
00025 *  already been broadcast along the process row or column.
00026 *  Also note that this routine will only work for K1-K2 being in the
00027 *  same MB (or NB) block.  If you want to pivot a full matrix, use
00028 *  PDLAPIV.
00029 *
00030 *  Notes
00031 *  =====
00032 *
00033 *  Each global data object is described by an associated description
00034 *  vector.  This vector stores the information required to establish
00035 *  the mapping between an object element and its corresponding process
00036 *  and memory location.
00037 *
00038 *  Let A be a generic term for any 2D block cyclicly distributed array.
00039 *  Such a global array has an associated description vector DESCA.
00040 *  In the following comments, the character _ should be read as
00041 *  "of the global array".
00042 *
00043 *  NOTATION        STORED IN      EXPLANATION
00044 *  --------------- -------------- --------------------------------------
00045 *  DTYPE_A(global) DESCA( DTYPE_ )The descriptor type.  In this case,
00046 *                                 DTYPE_A = 1.
00047 *  CTXT_A (global) DESCA( CTXT_ ) The BLACS context handle, indicating
00048 *                                 the BLACS process grid A is distribu-
00049 *                                 ted over. The context itself is glo-
00050 *                                 bal, but the handle (the integer
00051 *                                 value) may vary.
00052 *  M_A    (global) DESCA( M_ )    The number of rows in the global
00053 *                                 array A.
00054 *  N_A    (global) DESCA( N_ )    The number of columns in the global
00055 *                                 array A.
00056 *  MB_A   (global) DESCA( MB_ )   The blocking factor used to distribute
00057 *                                 the rows of the array.
00058 *  NB_A   (global) DESCA( NB_ )   The blocking factor used to distribute
00059 *                                 the columns of the array.
00060 *  RSRC_A (global) DESCA( RSRC_ ) The process row over which the first
00061 *                                 row of the array A is distributed.
00062 *  CSRC_A (global) DESCA( CSRC_ ) The process column over which the
00063 *                                 first column of the array A is
00064 *                                 distributed.
00065 *  LLD_A  (local)  DESCA( LLD_ )  The leading dimension of the local
00066 *                                 array.  LLD_A >= MAX(1,LOCr(M_A)).
00067 *
00068 *  Let K be the number of rows or columns of a distributed matrix,
00069 *  and assume that its process grid has dimension p x q.
00070 *  LOCr( K ) denotes the number of elements of K that a process
00071 *  would receive if K were distributed over the p processes of its
00072 *  process column.
00073 *  Similarly, LOCc( K ) denotes the number of elements of K that a
00074 *  process would receive if K were distributed over the q processes of
00075 *  its process row.
00076 *  The values of LOCr() and LOCc() may be determined via a call to the
00077 *  ScaLAPACK tool function, NUMROC:
00078 *          LOCr( M ) = NUMROC( M, MB_A, MYROW, RSRC_A, NPROW ),
00079 *          LOCc( N ) = NUMROC( N, NB_A, MYCOL, CSRC_A, NPCOL ).
00080 *  An upper bound for these quantities may be computed by:
00081 *          LOCr( M ) <= ceil( ceil(M/MB_A)/NPROW )*MB_A
00082 *          LOCc( N ) <= ceil( ceil(N/NB_A)/NPCOL )*NB_A
00083 *
00084 *  Arguments
00085 *  =========
00086 *
00087 *  DIREC   (global input) CHARACTER
00088 *          Specifies in which order the permutation is applied:
00089 *          = 'F' (Forward)
00090 *          = 'B' (Backward)
00091 *
00092 *  ROWCOL  (global input) CHARACTER
00093 *          Specifies if the rows or columns are permuted:
00094 *          = 'R' (Rows)
00095 *          = 'C' (Columns)
00096 *
00097 *  N       (global input) INTEGER
00098 *          If ROWCOL = 'R', the length of the rows of the distributed
00099 *          matrix A(*,JA:JA+N-1) to be permuted;
00100 *          If ROWCOL = 'C', the length of the columns of the distributed
00101 *          matrix A(IA:IA+N-1,*) to be permuted.
00102 *
00103 *  A       (local input/local output) DOUBLE PRECISION pointer into the
00104 *          local memory to an array of dimension (LLD_A, * ).
00105 *          On entry, this array contains the local pieces of the distri-
00106 *          buted matrix to which the row/columns interchanges will be
00107 *          applied. On exit the permuted distributed matrix.
00108 *
00109 *  IA      (global input) INTEGER
00110 *          The row index in the global array A indicating the first
00111 *          row of sub( A ).
00112 *
00113 *  JA      (global input) INTEGER
00114 *          The column index in the global array A indicating the
00115 *          first column of sub( A ).
00116 *
00117 *  DESCA   (global and local input) INTEGER array of dimension DLEN_.
00118 *          The array descriptor for the distributed matrix A.
00119 *
00120 *  K1      (global input) INTEGER
00121 *          The first element of IPIV for which a row or column inter-
00122 *          change will be done.
00123 *
00124 *  K2      (global input) INTEGER
00125 *          The last element of IPIV for which a row or column inter-
00126 *          change will be done.
00127 *
00128 *  IPIV    (local input) INTEGER array, dimension LOCr(M_A)+MB_A for
00129 *          row pivoting and LOCc(N_A)+NB_A for column pivoting.  This
00130 *          array is tied to the matrix A, IPIV(K) = L implies rows
00131 *          (or columns) K and L are to be interchanged.
00132 *
00133 *  =====================================================================
00134 *
00135 *     .. Parameters ..
00136       INTEGER            BLOCK_CYCLIC_2D, CSRC_, CTXT_, DLEN_, DTYPE_,
00137      $                   LLD_, MB_, M_, NB_, N_, RSRC_
00138       PARAMETER          ( BLOCK_CYCLIC_2D = 1, DLEN_ = 9, DTYPE_ = 1,
00139      $                     CTXT_ = 2, M_ = 3, N_ = 4, MB_ = 5, NB_ = 6,
00140      $                     RSRC_ = 7, CSRC_ = 8, LLD_ = 9 )
00141 *     ..
00142 *     .. Local Scalars ..
00143       INTEGER            I, ICURCOL, ICURROW, IIA, IP, J, JJA, JP,
00144      $                   MYCOL, MYROW, NPCOL, NPROW
00145 *     ..
00146 *     .. External Subroutines ..
00147       EXTERNAL           BLACS_GRIDINFO, INFOG2L, PDSWAP
00148 *     ..
00149 *     .. External Functions ..
00150       LOGICAL            LSAME
00151       EXTERNAL           LSAME
00152 *     ..
00153 *     .. Executable Statements ..
00154 *
00155 *     Quick return if possible
00156 *
00157       IF( N.EQ.0 )
00158      $   RETURN
00159 *
00160       CALL BLACS_GRIDINFO( DESCA( CTXT_ ), NPROW, NPCOL, MYROW, MYCOL )
00161 *
00162       IF( LSAME( ROWCOL, 'R' ) ) THEN
00163          IF( LSAME( DIREC, 'F' ) ) THEN
00164             CALL INFOG2L( K1, JA, DESCA, NPROW, NPCOL, MYROW, MYCOL,
00165      $                    IIA, JJA, ICURROW, ICURCOL )
00166             DO 10 I = K1, K2
00167                IP = IPIV( IIA+I-K1 )
00168                IF( IP.NE.I )
00169      $            CALL PDSWAP( N, A, I, JA, DESCA, DESCA( M_ ), A, IP,
00170      $                         JA, DESCA, DESCA( M_ ) )
00171    10       CONTINUE
00172          ELSE
00173             CALL INFOG2L( K2, JA, DESCA, NPROW, NPCOL, MYROW, MYCOL,
00174      $                    IIA, JJA, ICURROW, ICURCOL )
00175             DO 20 I = K2, K1, -1
00176                IP = IPIV( IIA+I-K1 )
00177                IF( IP.NE.I )
00178      $            CALL PDSWAP( N, A, I, JA, DESCA, DESCA( M_ ), A, IP,
00179      $                         JA, DESCA, DESCA( M_ ) )
00180    20       CONTINUE
00181          END IF
00182       ELSE
00183          IF( LSAME( DIREC, 'F' ) ) THEN
00184             CALL INFOG2L( IA, K1, DESCA, NPROW, NPCOL, MYROW, MYCOL,
00185      $                    IIA, JJA, ICURROW, ICURCOL )
00186             DO 30 J = K1, K2
00187                JP = IPIV( JJA+J-K1 )
00188                IF( JP.NE.J )
00189      $            CALL PDSWAP( N, A, IA, J, DESCA, 1, A, IA, JP,
00190      $                         DESCA, 1 )
00191    30       CONTINUE
00192          ELSE
00193             CALL INFOG2L( IA, K2, DESCA, NPROW, NPCOL, MYROW, MYCOL,
00194      $                    IIA, JJA, ICURROW, ICURCOL )
00195             DO 40 J = K2, K1, -1
00196                JP = IPIV( JJA+J-K1 )
00197                IF( JP.NE.J )
00198      $            CALL PDSWAP( N, A, IA, J, DESCA, 1, A, IA, JP,
00199      $                         DESCA, 1 )
00200    40       CONTINUE
00201          END IF
00202       END IF
00203 *
00204       RETURN
00205 *
00206 *     End PDLASWP
00207 *
00208       END