1 SUBROUTINE pzlaread( FILNAM, A, DESCA, IRREAD, ICREAD, WORK )
11 INTEGER ICREAD, IRREAD
16 COMPLEX*16 A( * ), WORK( * )
34 INTEGER BLOCK_CYCLIC_2D, CSRC_, CTXT_, DLEN_, DT_,
35 $ LLD_, MB_, M_, NB_, N_, RSRC_
36 parameter( block_cyclic_2d = 1, dlen_ = 9, dt_ = 1,
37 $ ctxt_ = 2, m_ = 3, n_ = 4, mb_ = 5, nb_ = 6,
38 $ rsrc_ = 7, csrc_ = 8, lld_ = 9 )
41 INTEGER H, I, IB, ICTXT, ICURCOL, ICURROW, II, J, JB,
42 $ JJ, K, LDA, M, MYCOL, MYROW, N, NPCOL, NPROW
43 DOUBLE PRECISION REAL_PART, IMAG_PART
49 EXTERNAL blacs_gridinfo,
infog2l, zgerv2d, zgesd2d,
57 INTRINSIC dcmplx,
min, mod
63 ictxt = desca( ctxt_ )
64 CALL blacs_gridinfo( ictxt, nprow, npcol, myrow, mycol )
66 IF( myrow.EQ.irread .AND. mycol.EQ.icread )
THEN
67 OPEN( nin, file=filnam, status=
'OLD' )
68 READ( nin, fmt = * ) ( iwork( i ), i = 1, 2 )
69 CALL igebs2d( ictxt,
'All',
' ', 2, 1, iwork, 2 )
71 CALL igebr2d( ictxt,
'All',
' ', 2, 1, iwork, 2, irread,
77 IF( m.LE.0 .OR. n.LE.0 )
80 IF( m.GT.desca( m_ ).OR. n.GT.desca( n_ ) )
THEN
81 IF( myrow.EQ.0 .AND. mycol.EQ.0 )
THEN
82 WRITE( *, fmt = * )
'PZLAREAD: Matrix too big to fit in'
83 WRITE( *, fmt = * )
'Abort ...'
85 CALL blacs_abort( ictxt, 0 )
90 icurrow = desca( rsrc_ )
91 icurcol = desca( csrc_ )
96 DO 50 j = 1, n, desca( nb_ )
97 jb =
min( desca( nb_ ), n-j+1 )
102 DO 30 i = 1, m, desca( mb_ )
103 ib =
min( desca( mb_ ), m-i+1 )
104 IF( icurrow.EQ.irread .AND. icurcol.EQ.icread )
THEN
105 IF( myrow.EQ.irread .AND. mycol.EQ.icread )
THEN
107 READ( nin , fmt = *) real_part, imag_part
108 a( ii+k+(jj+h-1)*lda ) = dcmplx(real_part, imag_part)
112 IF( myrow.EQ.icurrow .AND. mycol.EQ.icurcol )
THEN
113 CALL zgerv2d( ictxt, ib, 1, a( ii+(jj+h-1)*lda ),
114 $ lda, irread, icread )
115 ELSE IF( myrow.EQ.irread .AND. mycol.EQ.icread )
THEN
117 READ( nin, fmt = * ) real_part, imag_part
118 work(k)=dcmplx(real_part,imag_part)
120 CALL zgesd2d( ictxt, ib, 1, work, desca( mb_ ),
124 IF( myrow.EQ.icurrow )
126 icurrow = mod( icurrow+1, nprow )
130 icurrow = desca( rsrc_ )
133 IF( mycol.EQ.icurcol )
135 icurcol = mod( icurcol+1, npcol )
139 IF( myrow.EQ.irread .AND. mycol.EQ.icread )
THEN