1 SUBROUTINE pslawrite( FILNAM, M, N, A, IA, JA, DESCA, IRWRIT,
12 INTEGER IA, ICWRIT, IRWRIT, JA, M, N
17 REAL 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,
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 sgesd2d( ictxt, ib, 1, a( ii+(jj+h-1)*lda ), lda,
93 ELSE IF( myrow.EQ.irwrit .AND. mycol.EQ.icwrit )
THEN
94 CALL sgerv2d( ictxt, ib, 1, work, desca( mb_ ),
97 WRITE( nout, fmt = 9999 ) work( k )
101 IF( myrow.EQ.icurrow )
103 icurrow = mod( icurrow+1, nprow )
104 CALL blacs_barrier( ictxt,
'All' )
108 DO 50 i = in+1, ia+m-1, desca( mb_ )
109 ib =
min( desca( mb_ ), ia+m-i )
110 IF( icurrow.EQ.irwrit .AND. icurcol.EQ.icwrit )
THEN
111 IF( myrow.EQ.irwrit .AND. mycol.EQ.icwrit )
THEN
113 WRITE( nout, fmt = 9999 ) a( ii+k+(jj+h-1)*lda )
117 IF( myrow.EQ.icurrow .AND. mycol.EQ.icurcol )
THEN
118 CALL sgesd2d( ictxt, ib, 1, a( ii+(jj+h-1)*lda ),
119 $ lda, irwrit, icwrit )
120 ELSE IF( myrow.EQ.irwrit .AND. mycol.EQ.icwrit )
THEN
121 CALL sgerv2d( ictxt, ib, 1, work, desca( mb_ ),
124 WRITE( nout, fmt = 9999 ) work( k )
128 IF( myrow.EQ.icurrow )
130 icurrow = mod( icurrow+1, nprow )
131 CALL blacs_barrier( ictxt,
'All' )
138 IF( mycol.EQ.icurcol )
140 icurcol = mod( icurcol+1, npcol )
141 CALL blacs_barrier( ictxt,
'All' )
145 DO 130 j = jn+1, ja+n-1, desca( nb_ )
146 jb =
min( desca( nb_ ), ja+n-j )
148 in =
min( iceil( ia, desca( mb_ ) ) * desca( mb_ ), ia+m-1 )
150 IF( icurrow.EQ.irwrit .AND. icurcol.EQ.icwrit )
THEN
151 IF( myrow.EQ.irwrit .AND. mycol.EQ.icwrit )
THEN
153 WRITE( nout, fmt = 9999 ) a( ii+k+(jj+h-1)*lda )
157 IF( myrow.EQ.icurrow .AND. mycol.EQ.icurcol )
THEN
158 CALL sgesd2d( ictxt, ib, 1, a( ii+(jj+h-1)*lda ),
159 $ lda, irwrit, icwrit )
160 ELSE IF( myrow.EQ.irwrit .AND. mycol.EQ.icwrit )
THEN
161 CALL sgerv2d( ictxt, ib, 1, work, desca( mb_ ),
164 WRITE( nout, fmt = 9999 ) work( k )
168 IF( myrow.EQ.icurrow )
170 icurrow = mod( icurrow+1, nprow )
171 CALL blacs_barrier( ictxt,
'All' )
175 DO 110 i = in+1, ia+m-1, desca( mb_ )
176 ib =
min( desca( mb_ ), ia+m-i )
177 IF( icurrow.EQ.irwrit .AND. icurcol.EQ.icwrit )
THEN
178 IF( myrow.EQ.irwrit .AND. mycol.EQ.icwrit )
THEN
180 WRITE( nout, fmt = 9999 ) a( ii+k+(jj+h-1)*lda )
184 IF( myrow.EQ.icurrow .AND. mycol.EQ.icurcol )
THEN
185 CALL sgesd2d( ictxt, ib, 1, a( ii+(jj+h-1)*lda ),
186 $ lda, irwrit, icwrit )
187 ELSE IF( myrow.EQ.irwrit .AND. mycol.EQ.icwrit )
THEN
188 CALL sgerv2d( ictxt, ib, 1, work, desca( mb_ ),
191 WRITE( nout, fmt = 9999 ) work( k )
195 IF( myrow.EQ.icurrow )
197 icurrow = mod( icurrow+1, nprow )
198 CALL blacs_barrier( ictxt,
'All' )
205 IF( mycol.EQ.icurcol )
207 icurcol = mod( icurcol+1, npcol )
208 CALL blacs_barrier( ictxt,
'All' )
212 IF( myrow.EQ.irwrit .AND. mycol.EQ.icwrit )
THEN