1 SUBROUTINE pzlawrite( FILNAM, M, N, A, IA, JA, DESCA, IRWRIT,
12 INTEGER IA, ICWRIT, IRWRIT, JA, M, N
17 COMPLEX*16 A( * ), WORK( * )
33 parameter( nout = 13 )
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, IACOL, IAROW, IB, ICTXT, ICURCOL,
42 $ icurrow, ii, iia, in, j, jb, jj, jja, jn, k,
43 $ lda, mycol, myrow, npcol, nprow
46 EXTERNAL blacs_barrier, blacs_gridinfo,
infog2l,
54 INTRINSIC dble, dimag,
min, mod
60 ictxt = desca( ctxt_ )
61 CALL blacs_gridinfo( ictxt, nprow, npcol, myrow, mycol )
63 IF( myrow.EQ.irwrit .AND. mycol.EQ.icwrit )
THEN
64 OPEN( nout, file=filnam, status=
'UNKNOWN' )
65 WRITE( nout, fmt = * ) m, n
68 CALL infog2l( ia, ja, desca, nprow, npcol, myrow, mycol,
69 $ iia, jja, iarow, iacol )
78 jn =
min( iceil( ja, desca( nb_ ) ) * desca( nb_ ), ja+n-1 )
81 in =
min( iceil( ia, desca( mb_ ) ) * desca( mb_ ), ia+m-1 )
83 IF( icurrow.EQ.irwrit .AND. icurcol.EQ.icwrit )
THEN
84 IF( myrow.EQ.irwrit .AND. mycol.EQ.icwrit )
THEN
86 WRITE( nout, fmt = 9999 ) a( ii+k+(jj+h-1)*lda )
90 IF( myrow.EQ.icurrow .AND. mycol.EQ.icurcol )
THEN
91 CALL zgesd2d( ictxt, ib, 1, a( ii+(jj+h-1)*lda ), lda,
93 ELSE IF( myrow.EQ.irwrit .AND. mycol.EQ.icwrit )
THEN
94 CALL zgerv2d( ictxt, ib, 1, work, desca( mb_ ),
97 WRITE( nout, fmt = 9999 ) dble(work( k )),
102 IF( myrow.EQ.icurrow )
104 icurrow = mod( icurrow+1, nprow )
105 CALL blacs_barrier( ictxt,
'All' )
109 DO 50 i = in+1, ia+m-1, desca( mb_ )
110 ib =
min( desca( mb_ ), ia+m-i )
111 IF( icurrow.EQ.irwrit .AND. icurcol.EQ.icwrit )
THEN
112 IF( myrow.EQ.irwrit .AND. mycol.EQ.icwrit )
THEN
114 WRITE( nout, fmt = 9999 )
115 $ dble(a( ii+k+(jj+h-1)*lda )),
116 $ dimag(a( ii+k+(jj+h-1)*lda ))
120 IF( myrow.EQ.icurrow .AND. mycol.EQ.icurcol )
THEN
121 CALL zgesd2d( ictxt, ib, 1, a( ii+(jj+h-1)*lda ),
122 $ lda, irwrit, icwrit )
123 ELSE IF( myrow.EQ.irwrit .AND. mycol.EQ.icwrit )
THEN
124 CALL zgerv2d( ictxt, ib, 1, work, desca( mb_ ),
127 WRITE( nout, fmt = 9999 ) dble(work( k )),
132 IF( myrow.EQ.icurrow )
134 icurrow = mod( icurrow+1, nprow )
135 CALL blacs_barrier( ictxt,
'All' )
142 IF( mycol.EQ.icurcol )
144 icurcol = mod( icurcol+1, npcol )
145 CALL blacs_barrier( ictxt,
'All' )
149 DO 130 j = jn+1, ja+n-1, desca( nb_ )
150 jb =
min( desca( nb_ ), ja+n-j )
152 in =
min( iceil( ia, desca( mb_ ) ) * desca( mb_ ), ia+m-1 )
154 IF( icurrow.EQ.irwrit .AND. icurcol.EQ.icwrit )
THEN
155 IF( myrow.EQ.irwrit .AND. mycol.EQ.icwrit )
THEN
157 WRITE( nout, fmt = 9999 )
158 $ dble(a( ii+k+(jj+h-1)*lda )),
159 $ dimag(a( ii+k+(jj+h-1)*lda ))
163 IF( myrow.EQ.icurrow .AND. mycol.EQ.icurcol )
THEN
164 CALL zgesd2d( ictxt, ib, 1, a( ii+(jj+h-1)*lda ),
165 $ lda, irwrit, icwrit )
166 ELSE IF( myrow.EQ.irwrit .AND. mycol.EQ.icwrit )
THEN
167 CALL zgerv2d( ictxt, ib, 1, work, desca( mb_ ),
170 WRITE( nout, fmt = 9999 ) dble(work( k )),
175 IF( myrow.EQ.icurrow )
177 icurrow = mod( icurrow+1, nprow )
178 CALL blacs_barrier( ictxt,
'All' )
182 DO 110 i = in+1, ia+m-1, desca( mb_ )
183 ib =
min( desca( mb_ ), ia+m-i )
184 IF( icurrow.EQ.irwrit .AND. icurcol.EQ.icwrit )
THEN
185 IF( myrow.EQ.irwrit .AND. mycol.EQ.icwrit )
THEN
187 WRITE( nout, fmt = 9999 )
188 $ dble(a( ii+k+(jj+h-1)*lda )),
189 $ dimag(a( ii+k+(jj+h-1)*lda ))
193 IF( myrow.EQ.icurrow .AND. mycol.EQ.icurcol )
THEN
194 CALL zgesd2d( ictxt, ib, 1, a( ii+(jj+h-1)*lda ),
195 $ lda, irwrit, icwrit )
196 ELSE IF( myrow.EQ.irwrit .AND. mycol.EQ.icwrit )
THEN
197 CALL zgerv2d( ictxt, ib, 1, work, desca( mb_ ),
200 WRITE( nout, fmt = 9999 ) dble(work( k )),
205 IF( myrow.EQ.icurrow )
207 icurrow = mod( icurrow+1, nprow )
208 CALL blacs_barrier( ictxt,
'All' )
215 IF( mycol.EQ.icurcol )
217 icurcol = mod( icurcol+1, npcol )
218 CALL blacs_barrier( ictxt,
'All' )
222 IF( myrow.EQ.irwrit .AND. mycol.EQ.icwrit )
THEN
226 9999
FORMAT( e15.8,e15.8 )