SCALAPACK 2.2.2
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches

◆ pdlagen()

subroutine pdlagen ( logical  inplace,
character*1  aform,
character*1  diag,
integer  offa,
integer  m,
integer  n,
integer  ia,
integer  ja,
integer, dimension( * )  desca,
integer  iaseed,
double precision, dimension( lda, * )  a,
integer  lda 
)

Definition at line 508 of file pdblastim.f.

510*
511* -- PBLAS test routine (version 2.0) --
512* University of Tennessee, Knoxville, Oak Ridge National Laboratory,
513* and University of California, Berkeley.
514* April 1, 1998
515*
516* .. Scalar Arguments ..
517 LOGICAL INPLACE
518 CHARACTER*1 AFORM, DIAG
519 INTEGER IA, IASEED, JA, LDA, M, N, OFFA
520* ..
521* .. Array Arguments ..
522 INTEGER DESCA( * )
523 DOUBLE PRECISION A( LDA, * )
524* ..
525*
526* Purpose
527* =======
528*
529* PDLAGEN generates (or regenerates) a submatrix sub( A ) denoting
530* A(IA:IA+M-1,JA:JA+N-1).
531*
532* Notes
533* =====
534*
535* A description vector is associated with each 2D block-cyclicly dis-
536* tributed matrix. This vector stores the information required to
537* establish the mapping between a matrix entry and its corresponding
538* process and memory location.
539*
540* In the following comments, the character _ should be read as
541* "of the distributed matrix". Let A be a generic term for any 2D
542* block cyclicly distributed matrix. Its description vector is DESCA:
543*
544* NOTATION STORED IN EXPLANATION
545* ---------------- --------------- ------------------------------------
546* DTYPE_A (global) DESCA( DTYPE_ ) The descriptor type.
547* CTXT_A (global) DESCA( CTXT_ ) The BLACS context handle, indicating
548* the NPROW x NPCOL BLACS process grid
549* A is distributed over. The context
550* itself is global, but the handle
551* (the integer value) may vary.
552* M_A (global) DESCA( M_ ) The number of rows in the distribu-
553* ted matrix A, M_A >= 0.
554* N_A (global) DESCA( N_ ) The number of columns in the distri-
555* buted matrix A, N_A >= 0.
556* IMB_A (global) DESCA( IMB_ ) The number of rows of the upper left
557* block of the matrix A, IMB_A > 0.
558* INB_A (global) DESCA( INB_ ) The number of columns of the upper
559* left block of the matrix A,
560* INB_A > 0.
561* MB_A (global) DESCA( MB_ ) The blocking factor used to distri-
562* bute the last M_A-IMB_A rows of A,
563* MB_A > 0.
564* NB_A (global) DESCA( NB_ ) The blocking factor used to distri-
565* bute the last N_A-INB_A columns of
566* A, NB_A > 0.
567* RSRC_A (global) DESCA( RSRC_ ) The process row over which the first
568* row of the matrix A is distributed,
569* NPROW > RSRC_A >= 0.
570* CSRC_A (global) DESCA( CSRC_ ) The process column over which the
571* first column of A is distributed.
572* NPCOL > CSRC_A >= 0.
573* LLD_A (local) DESCA( LLD_ ) The leading dimension of the local
574* array storing the local blocks of
575* the distributed matrix A,
576* IF( Lc( 1, N_A ) > 0 )
577* LLD_A >= MAX( 1, Lr( 1, M_A ) )
578* ELSE
579* LLD_A >= 1.
580*
581* Let K be the number of rows of a matrix A starting at the global in-
582* dex IA,i.e, A( IA:IA+K-1, : ). Lr( IA, K ) denotes the number of rows
583* that the process of row coordinate MYROW ( 0 <= MYROW < NPROW ) would
584* receive if these K rows were distributed over NPROW processes. If K
585* is the number of columns of a matrix A starting at the global index
586* JA, i.e, A( :, JA:JA+K-1, : ), Lc( JA, K ) denotes the number of co-
587* lumns that the process MYCOL ( 0 <= MYCOL < NPCOL ) would receive if
588* these K columns were distributed over NPCOL processes.
589*
590* The values of Lr() and Lc() may be determined via a call to the func-
591* tion PB_NUMROC:
592* Lr( IA, K ) = PB_NUMROC( K, IA, IMB_A, MB_A, MYROW, RSRC_A, NPROW )
593* Lc( JA, K ) = PB_NUMROC( K, JA, INB_A, NB_A, MYCOL, CSRC_A, NPCOL )
594*
595* Arguments
596* =========
597*
598* INPLACE (global input) LOGICAL
599* On entry, INPLACE specifies if the matrix should be generated
600* in place or not. If INPLACE is .TRUE., the local random array
601* to be generated will start in memory at the local memory lo-
602* cation A( 1, 1 ), otherwise it will start at the local posi-
603* tion induced by IA and JA.
604*
605* AFORM (global input) CHARACTER*1
606* On entry, AFORM specifies the type of submatrix to be genera-
607* ted as follows:
608* AFORM = 'S', sub( A ) is a symmetric matrix,
609* AFORM = 'H', sub( A ) is a Hermitian matrix,
610* AFORM = 'T', sub( A ) is overrwritten with the transpose
611* of what would normally be generated,
612* AFORM = 'C', sub( A ) is overwritten with the conjugate
613* transpose of what would normally be genera-
614* ted.
615* AFORM = 'N', a random submatrix is generated.
616*
617* DIAG (global input) CHARACTER*1
618* On entry, DIAG specifies if the generated submatrix is diago-
619* nally dominant or not as follows:
620* DIAG = 'D' : sub( A ) is diagonally dominant,
621* DIAG = 'N' : sub( A ) is not diagonally dominant.
622*
623* OFFA (global input) INTEGER
624* On entry, OFFA specifies the offdiagonal of the underlying
625* matrix A(1:DESCA(M_),1:DESCA(N_)) of interest when the subma-
626* trix is symmetric, Hermitian or diagonally dominant. OFFA = 0
627* specifies the main diagonal, OFFA > 0 specifies a subdiago-
628* nal, and OFFA < 0 specifies a superdiagonal (see further de-
629* tails).
630*
631* M (global input) INTEGER
632* On entry, M specifies the global number of matrix rows of the
633* submatrix sub( A ) to be generated. M must be at least zero.
634*
635* N (global input) INTEGER
636* On entry, N specifies the global number of matrix columns of
637* the submatrix sub( A ) to be generated. N must be at least
638* zero.
639*
640* IA (global input) INTEGER
641* On entry, IA specifies A's global row index, which points to
642* the beginning of the submatrix sub( A ).
643*
644* JA (global input) INTEGER
645* On entry, JA specifies A's global column index, which points
646* to the beginning of the submatrix sub( A ).
647*
648* DESCA (global and local input) INTEGER array
649* On entry, DESCA is an integer array of dimension DLEN_. This
650* is the array descriptor for the matrix A.
651*
652* IASEED (global input) INTEGER
653* On entry, IASEED specifies the seed number to generate the
654* matrix A. IASEED must be at least zero.
655*
656* A (local output) DOUBLE PRECISION array
657* On entry, A is an array of dimension (LLD_A, Ka), where Ka is
658* at least Lc( 1, JA+N-1 ). On exit, this array contains the
659* local entries of the randomly generated submatrix sub( A ).
660*
661* LDA (local input) INTEGER
662* On entry, LDA specifies the local leading dimension of the
663* array A. When INPLACE is .FALSE., LDA is usually DESCA(LLD_).
664* This restriction is however not enforced, and this subroutine
665* requires only that LDA >= MAX( 1, Mp ) where
666*
667* Mp = PB_NUMROC( M, IA, IMB_A, MB_A, MYROW, RSRC_A, NPROW ).
668*
669* PB_NUMROC is a ScaLAPACK tool function; MYROW, MYCOL, NPROW
670* and NPCOL can be determined by calling the BLACS subroutine
671* BLACS_GRIDINFO.
672*
673* Further Details
674* ===============
675*
676* OFFD is tied to the matrix described by DESCA, as opposed to the
677* piece that is currently (re)generated. This is a global information
678* independent from the distribution parameters. Below are examples of
679* the meaning of OFFD for a global 7 by 5 matrix:
680*
681* ---------------------------------------------------------------------
682* OFFD | 0 -1 -2 -3 -4 0 -1 -2 -3 -4 0 -1 -2 -3 -4
683* -------|-------------------------------------------------------------
684* | | OFFD=-1 | OFFD=0 OFFD=2
685* | V V
686* 0 | . d . . . -> d . . . . . . . . .
687* 1 | . . d . . . d . . . . . . . .
688* 2 | . . . d . . . d . . -> d . . . .
689* 3 | . . . . d . . . d . . d . . .
690* 4 | . . . . . . . . . d . . d . .
691* 5 | . . . . . . . . . . . . . d .
692* 6 | . . . . . . . . . . . . . . d
693* ---------------------------------------------------------------------
694*
695* -- Written on April 1, 1998 by
696* Antoine Petitet, University of Tennessee, Knoxville 37996, USA.
697*
698* =====================================================================
699*
700* .. Parameters ..
701 INTEGER BLOCK_CYCLIC_2D_INB, CSRC_, CTXT_, DLEN_,
702 $ DTYPE_, IMB_, INB_, LLD_, MB_, M_, NB_, N_,
703 $ RSRC_
704 parameter( block_cyclic_2d_inb = 2, dlen_ = 11,
705 $ dtype_ = 1, ctxt_ = 2, m_ = 3, n_ = 4,
706 $ imb_ = 5, inb_ = 6, mb_ = 7, nb_ = 8,
707 $ rsrc_ = 9, csrc_ = 10, lld_ = 11 )
708 INTEGER JMP_1, JMP_COL, JMP_IMBV, JMP_INBV, JMP_LEN,
709 $ JMP_MB, JMP_NB, JMP_NPIMBLOC, JMP_NPMB,
710 $ JMP_NQINBLOC, JMP_NQNB, JMP_ROW
711 parameter( jmp_1 = 1, jmp_row = 2, jmp_col = 3,
712 $ jmp_mb = 4, jmp_imbv = 5, jmp_npmb = 6,
713 $ jmp_npimbloc = 7, jmp_nb = 8, jmp_inbv = 9,
714 $ jmp_nqnb = 10, jmp_nqinbloc = 11,
715 $ jmp_len = 11 )
716* ..
717* .. Local Scalars ..
718 LOGICAL DIAGDO, SYMM, HERM, NOTRAN
719 INTEGER CSRC, I, IACOL, IAROW, ICTXT, IIA, ILOCBLK,
720 $ ILOCOFF, ILOW, IMB, IMB1, IMBLOC, IMBVIR, INB,
721 $ INB1, INBLOC, INBVIR, INFO, IOFFDA, ITMP, IUPP,
722 $ IVIR, JJA, JLOCBLK, JLOCOFF, JVIR, LCMT00,
723 $ LMBLOC, LNBLOC, LOW, MAXMN, MB, MBLKS, MP,
724 $ MRCOL, MRROW, MYCDIST, MYCOL, MYRDIST, MYROW,
725 $ NB, NBLKS, NPCOL, NPROW, NQ, NVIR, RSRC, UPP
726 DOUBLE PRECISION ALPHA
727* ..
728* .. Local Arrays ..
729 INTEGER DESCA2( DLEN_ ), IMULADD( 4, JMP_LEN ),
730 $ IRAN( 2 ), JMP( JMP_LEN ), MULADD0( 4 )
731* ..
732* .. External Subroutines ..
733 EXTERNAL blacs_gridinfo, pb_ainfog2l, pb_binfo,
737* ..
738* .. External Functions ..
739 LOGICAL LSAME
740 EXTERNAL lsame
741* ..
742* .. Intrinsic Functions ..
743 INTRINSIC dble, max, min
744* ..
745* .. Data Statements ..
746 DATA ( muladd0( i ), i = 1, 4 ) / 20077, 16838,
747 $ 12345, 0 /
748* ..
749* .. Executable Statements ..
750*
751* Convert descriptor
752*
753 CALL pb_desctrans( desca, desca2 )
754*
755* Test the input arguments
756*
757 ictxt = desca2( ctxt_ )
758 CALL blacs_gridinfo( ictxt, nprow, npcol, myrow, mycol )
759*
760* Test the input parameters
761*
762 info = 0
763 IF( nprow.EQ.-1 ) THEN
764 info = -( 1000 + ctxt_ )
765 ELSE
766 symm = lsame( aform, 'S' )
767 herm = lsame( aform, 'H' )
768 notran = lsame( aform, 'N' )
769 diagdo = lsame( diag, 'D' )
770 IF( .NOT.( symm.OR.herm.OR.notran ) .AND.
771 $ .NOT.( lsame( aform, 'T' ) ) .AND.
772 $ .NOT.( lsame( aform, 'C' ) ) ) THEN
773 info = -2
774 ELSE IF( ( .NOT.diagdo ) .AND.
775 $ ( .NOT.lsame( diag, 'N' ) ) ) THEN
776 info = -3
777 END IF
778 CALL pb_chkmat( ictxt, m, 5, n, 6, ia, ja, desca2, 10, info )
779 END IF
780*
781 IF( info.NE.0 ) THEN
782 CALL pxerbla( ictxt, 'PDLAGEN', -info )
783 RETURN
784 END IF
785*
786* Quick return if possible
787*
788 IF( ( m.LE.0 ).OR.( n.LE.0 ) )
789 $ RETURN
790*
791* Start the operations
792*
793 mb = desca2( mb_ )
794 nb = desca2( nb_ )
795 imb = desca2( imb_ )
796 inb = desca2( inb_ )
797 rsrc = desca2( rsrc_ )
798 csrc = desca2( csrc_ )
799*
800* Figure out local information about the distributed matrix operand
801*
802 CALL pb_ainfog2l( m, n, ia, ja, desca2, nprow, npcol, myrow,
803 $ mycol, imb1, inb1, mp, nq, iia, jja, iarow,
804 $ iacol, mrrow, mrcol )
805*
806* Decide where the entries shall be stored in memory
807*
808 IF( inplace ) THEN
809 iia = 1
810 jja = 1
811 END IF
812*
813* Initialize LCMT00, MBLKS, NBLKS, IMBLOC, INBLOC, LMBLOC, LNBLOC,
814* ILOW, LOW, IUPP, and UPP.
815*
816 ioffda = ja + offa - ia
817 CALL pb_binfo( ioffda, mp, nq, imb1, inb1, mb, nb, mrrow,
818 $ mrcol, lcmt00, mblks, nblks, imbloc, inbloc,
819 $ lmbloc, lnbloc, ilow, low, iupp, upp )
820*
821* Initialize ILOCBLK, ILOCOFF, MYRDIST, JLOCBLK, JLOCOFF, MYCDIST
822* This values correspond to the square virtual underlying matrix
823* of size MAX( M_ + MAX( 0, -OFFA ), N_ + MAX( 0, OFFA ) ) used
824* to set up the random sequence. For practical purposes, the size
825* of this virtual matrix is upper bounded by M_ + N_ - 1.
826*
827 itmp = max( 0, -offa )
828 ivir = ia + itmp
829 imbvir = imb + itmp
830 nvir = desca2( m_ ) + itmp
831*
832 CALL pb_locinfo( ivir, imbvir, mb, myrow, rsrc, nprow, ilocblk,
833 $ ilocoff, myrdist )
834*
835 itmp = max( 0, offa )
836 jvir = ja + itmp
837 inbvir = inb + itmp
838 nvir = max( max( nvir, desca2( n_ ) + itmp ),
839 $ desca2( m_ ) + desca2( n_ ) - 1 )
840*
841 CALL pb_locinfo( jvir, inbvir, nb, mycol, csrc, npcol, jlocblk,
842 $ jlocoff, mycdist )
843*
844 IF( symm .OR. herm .OR. notran ) THEN
845*
846 CALL pb_initjmp( .true., nvir, imbvir, inbvir, imbloc, inbloc,
847 $ mb, nb, rsrc, csrc, nprow, npcol, 1, jmp )
848*
849* Compute constants to jump JMP( * ) numbers in the sequence
850*
851 CALL pb_initmuladd( muladd0, jmp, imuladd )
852*
853* Compute and set the random value corresponding to A( IA, JA )
854*
855 CALL pb_setlocran( iaseed, ilocblk, jlocblk, ilocoff, jlocoff,
856 $ myrdist, mycdist, nprow, npcol, jmp,
857 $ imuladd, iran )
858*
859 CALL pb_dlagen( 'Lower', aform, a( iia, jja ), lda, lcmt00,
860 $ iran, mblks, imbloc, mb, lmbloc, nblks, inbloc,
861 $ nb, lnbloc, jmp, imuladd )
862*
863 END IF
864*
865 IF( symm .OR. herm .OR. ( .NOT. notran ) ) THEN
866*
867 CALL pb_initjmp( .false., nvir, imbvir, inbvir, imbloc, inbloc,
868 $ mb, nb, rsrc, csrc, nprow, npcol, 1, jmp )
869*
870* Compute constants to jump JMP( * ) numbers in the sequence
871*
872 CALL pb_initmuladd( muladd0, jmp, imuladd )
873*
874* Compute and set the random value corresponding to A( IA, JA )
875*
876 CALL pb_setlocran( iaseed, ilocblk, jlocblk, ilocoff, jlocoff,
877 $ myrdist, mycdist, nprow, npcol, jmp,
878 $ imuladd, iran )
879*
880 CALL pb_dlagen( 'Upper', aform, a( iia, jja ), lda, lcmt00,
881 $ iran, mblks, imbloc, mb, lmbloc, nblks, inbloc,
882 $ nb, lnbloc, jmp, imuladd )
883*
884 END IF
885*
886 IF( diagdo ) THEN
887*
888 maxmn = max( desca2( m_ ), desca2( n_ ) )
889 alpha = dble( maxmn )
890*
891 IF( ioffda.GE.0 ) THEN
892 CALL pdladom( inplace, min( max( 0, m-ioffda ), n ), alpha,
893 $ a, min( ia+ioffda, ia+m-1 ), ja, desca )
894 ELSE
895 CALL pdladom( inplace, min( m, max( 0, n+ioffda ) ), alpha,
896 $ a, ia, min( ja-ioffda, ja+n-1 ), desca )
897 END IF
898*
899 END IF
900*
901 RETURN
902*
903* End of PDLAGEN
904*
subroutine pb_ainfog2l(m, n, i, j, desc, nprow, npcol, myrow, mycol, imb1, inb1, mp, nq, ii, jj, prow, pcol, rprow, rpcol)
Definition pblastst.f:2023
subroutine pb_binfo(offd, m, n, imb1, inb1, mb, nb, mrrow, mrcol, lcmt00, mblks, nblks, imbloc, inbloc, lmbloc, lnbloc, ilow, low, iupp, upp)
Definition pblastst.f:3577
subroutine pb_setran(iran, iac)
Definition pblastst.f:4759
subroutine pb_locinfo(i, inb, nb, myroc, srcproc, nprocs, ilocblk, ilocoff, mydist)
Definition pblastst.f:3910
subroutine pb_chkmat(ictxt, m, mpos0, n, npos0, ia, ja, desca, dpos0, info)
Definition pblastst.f:2742
subroutine pb_jump(k, muladd, irann, iranm, ima)
Definition pblastst.f:4648
subroutine pb_setlocran(seed, ilocblk, jlocblk, ilocoff, jlocoff, myrdist, mycdist, nprow, npcol, jmp, imuladd, iran)
Definition pblastst.f:4302
subroutine pb_initmuladd(muladd0, jmp, imuladd)
Definition pblastst.f:4196
subroutine pb_desctrans(descin, descout)
Definition pblastst.f:2964
subroutine pb_initjmp(colmaj, nvir, imbvir, inbvir, imbloc, inbloc, mb, nb, rsrc, csrc, nprow, npcol, stride, jmp)
Definition pblastst.f:4045
subroutine pb_jumpit(muladd, irann, iranm)
Definition pblastst.f:4822
#define max(A, B)
Definition pcgemr.c:180
#define min(A, B)
Definition pcgemr.c:181
subroutine pb_dlagen(uplo, aform, a, lda, lcmt00, iran, mblks, imbloc, mb, lmbloc, nblks, inbloc, nb, lnbloc, jmp, imuladd)
Definition pdblastst.f:9737
subroutine pdladom(inplace, n, alpha, a, ia, ja, desca)
Definition pdblastst.f:8242
subroutine pxerbla(ictxt, srname, info)
Definition pxerbla.f:2
logical function lsame(ca, cb)
Definition tools.f:1724
Here is the call graph for this function: