ScaLAPACK  2.0.2
ScaLAPACK: Scalable Linear Algebra PACKage
infog2l.f
Go to the documentation of this file.
00001       SUBROUTINE INFOG2L( GRINDX, GCINDX, DESC, NPROW, NPCOL, MYROW,
00002      $                    MYCOL, LRINDX, LCINDX, RSRC, CSRC )
00003 *
00004 *  -- ScaLAPACK tools 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       INTEGER            CSRC, GCINDX, GRINDX, LRINDX, LCINDX, MYCOL,
00011      $                   MYROW, NPCOL, NPROW, RSRC
00012 *     ..
00013 *     .. Array Arguments ..
00014       INTEGER            DESC( * )
00015 *     ..
00016 *
00017 *  Purpose
00018 *  =======
00019 *
00020 *  INFOG2L computes the starting local indexes LRINDX, LCINDX corres-
00021 *  ponding to the distributed submatrix starting globally at the entry
00022 *  pointed by GRINDX, GCINDX. This routine returns the coordinates in
00023 *  the grid of the process owning the matrix entry of global indexes
00024 *  GRINDX, GCINDX, namely RSRC and CSRC.
00025 *
00026 *  Notes
00027 *  =====
00028 *
00029 *  Each global data object is described by an associated description
00030 *  vector.  This vector stores the information required to establish
00031 *  the mapping between an object element and its corresponding process
00032 *  and memory location.
00033 *
00034 *  Let A be a generic term for any 2D block cyclicly distributed array.
00035 *  Such a global array has an associated description vector DESCA.
00036 *  In the following comments, the character _ should be read as
00037 *  "of the global array".
00038 *
00039 *  NOTATION        STORED IN      EXPLANATION
00040 *  --------------- -------------- --------------------------------------
00041 *  DTYPE_A(global) DESCA( DTYPE_ )The descriptor type.  In this case,
00042 *                                 DTYPE_A = 1.
00043 *  CTXT_A (global) DESCA( CTXT_ ) The BLACS context handle, indicating
00044 *                                 the BLACS process grid A is distribu-
00045 *                                 ted over. The context itself is glo-
00046 *                                 bal, but the handle (the integer
00047 *                                 value) may vary.
00048 *  M_A    (global) DESCA( M_ )    The number of rows in the global
00049 *                                 array A.
00050 *  N_A    (global) DESCA( N_ )    The number of columns in the global
00051 *                                 array A.
00052 *  MB_A   (global) DESCA( MB_ )   The blocking factor used to distribute
00053 *                                 the rows of the array.
00054 *  NB_A   (global) DESCA( NB_ )   The blocking factor used to distribute
00055 *                                 the columns of the array.
00056 *  RSRC_A (global) DESCA( RSRC_ ) The process row over which the first
00057 *                                 row of the array A is distributed.
00058 *  CSRC_A (global) DESCA( CSRC_ ) The process column over which the
00059 *                                 first column of the array A is
00060 *                                 distributed.
00061 *  LLD_A  (local)  DESCA( LLD_ )  The leading dimension of the local
00062 *                                 array.  LLD_A >= MAX(1,LOCr(M_A)).
00063 *
00064 *  Let K be the number of rows or columns of a distributed matrix,
00065 *  and assume that its process grid has dimension p x q.
00066 *  LOCr( K ) denotes the number of elements of K that a process
00067 *  would receive if K were distributed over the p processes of its
00068 *  process column.
00069 *  Similarly, LOCc( K ) denotes the number of elements of K that a
00070 *  process would receive if K were distributed over the q processes of
00071 *  its process row.
00072 *  The values of LOCr() and LOCc() may be determined via a call to the
00073 *  ScaLAPACK tool function, NUMROC:
00074 *          LOCr( M ) = NUMROC( M, MB_A, MYROW, RSRC_A, NPROW ),
00075 *          LOCc( N ) = NUMROC( N, NB_A, MYCOL, CSRC_A, NPCOL ).
00076 *  An upper bound for these quantities may be computed by:
00077 *          LOCr( M ) <= ceil( ceil(M/MB_A)/NPROW )*MB_A
00078 *          LOCc( N ) <= ceil( ceil(N/NB_A)/NPCOL )*NB_A
00079 *
00080 *  Arguments
00081 *  =========
00082 *
00083 *  GRINDX    (global input) INTEGER
00084 *            The global row starting index of the submatrix.
00085 *
00086 *  GCINDX    (global input) INTEGER
00087 *            The global column starting index of the submatrix.
00088 *
00089 *  DESC      (input) INTEGER array of dimension DLEN_.
00090 *            The array descriptor for the underlying distributed matrix.
00091 *
00092 *  NPROW     (global input) INTEGER
00093 *            The total number of process rows over which the distributed
00094 *            matrix is distributed.
00095 *
00096 *  NPCOL     (global input) INTEGER
00097 *            The total number of process columns over which the
00098 *            distributed matrix is distributed.
00099 *
00100 *  MYROW     (local input) INTEGER
00101 *            The row coordinate of the process calling this routine.
00102 *
00103 *  MYCOL     (local input) INTEGER
00104 *            The column coordinate of the process calling this routine.
00105 *
00106 *  LRINDX    (local output) INTEGER
00107 *            The local rows starting index of the submatrix.
00108 *
00109 *  LCINDX    (local output) INTEGER
00110 *            The local columns starting index of the submatrix.
00111 *
00112 *  RSRC      (global output) INTEGER
00113 *            The row coordinate of the process that possesses the first
00114 *            row and column of the submatrix.
00115 *
00116 *  CSRC      (global output) INTEGER
00117 *            The column coordinate of the process that possesses the
00118 *            first row and column of the submatrix.
00119 *
00120 *  =====================================================================
00121 *
00122 *     .. Parameters ..
00123       INTEGER            BLOCK_CYCLIC_2D, CSRC_, CTXT_, DLEN_, DTYPE_,
00124      $                   LLD_, MB_, M_, NB_, N_, RSRC_
00125       PARAMETER          ( BLOCK_CYCLIC_2D = 1, DLEN_ = 9, DTYPE_ = 1,
00126      $                     CTXT_ = 2, M_ = 3, N_ = 4, MB_ = 5, NB_ = 6,
00127      $                     RSRC_ = 7, CSRC_ = 8, LLD_ = 9 )
00128 *     ..
00129 *     .. Local Scalars ..
00130       INTEGER            CBLK, GCCPY, GRCPY, RBLK
00131 *     ..
00132 *     .. Intrinsic Functions ..
00133       INTRINSIC          MOD
00134 *     ..
00135 *     .. Executable Statements ..
00136 *
00137       GRCPY = GRINDX-1
00138       GCCPY = GCINDX-1
00139 *
00140       RBLK = GRCPY / DESC(MB_)
00141       CBLK = GCCPY / DESC(NB_)
00142       RSRC = MOD( RBLK + DESC(RSRC_), NPROW )
00143       CSRC = MOD( CBLK + DESC(CSRC_), NPCOL )
00144 *
00145       LRINDX = ( RBLK / NPROW + 1 ) * DESC(MB_) + 1
00146       LCINDX = ( CBLK / NPCOL + 1 ) * DESC(NB_) + 1
00147 *
00148       IF( MOD( MYROW+NPROW-DESC(RSRC_), NPROW ) .GE.
00149      $    MOD( RBLK, NPROW ) ) THEN
00150          IF( MYROW.EQ.RSRC )
00151      $      LRINDX = LRINDX + MOD( GRCPY, DESC(MB_) )
00152          LRINDX = LRINDX - DESC(MB_)
00153       END IF
00154 *
00155       IF( MOD( MYCOL+NPCOL-DESC(CSRC_), NPCOL ) .GE.
00156      $    MOD( CBLK, NPCOL ) ) THEN
00157          IF( MYCOL.EQ.CSRC )
00158      $      LCINDX = LCINDX + MOD( GCCPY, DESC(NB_) )
00159          LCINDX = LCINDX - DESC(NB_)
00160       END IF
00161 *
00162       RETURN
00163 *
00164 *     End of INFOG2L
00165 *
00166       END