2
3
4
5
6
7
8
9 INTEGER IA, JA, N, NB
10
11
12 INTEGER DESCA( * )
13 REAL A( * ), WORK( * )
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82 INTEGER BLOCK_CYCLIC_2D, DLEN_, DTYPE_, CTXT_, M_, N_,
83 $ MB_, NB_, RSRC_, CSRC_, LLD_
84 parameter( block_cyclic_2d = 1, dlen_ = 9, dtype_ = 1,
85 $ ctxt_ = 2, m_ = 3, n_ = 4, mb_ = 5, nb_ = 6,
86 $ rsrc_ = 7, csrc_ = 8, lld_ = 9 )
87
88
89 INTEGER I, ICTXT, IRECV, ISEND, J, JJ, JRECV, JSEND,
90 $ LDA, MAXIRECV, MAXISEND, MAXJRECV, MAXJSEND,
91 $ MINIRECV, MINISEND, MINJRECV, MINJSEND, MYCOL,
92 $ MYROW, NP, NPCOL, NPROW, NQ, RECVNB, SENDNB,
93 $ STARTCOL, STARTROW
94
95
96 EXTERNAL blacs_gridinfo, strrv2d, strsd2d
97
98
99 INTEGER NUMROC
101
102
104
105
106
107 IF( block_cyclic_2d*csrc_*ctxt_*dlen_*dtype_*lld_*mb_*m_*nb_*n_*
108 $ rsrc_.LT.0 )RETURN
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134 IF( n.LE.0 )
135 $ RETURN
136
137 ictxt = desca( ctxt_ )
138 lda = desca( lld_ )
139 CALL blacs_gridinfo( ictxt, nprow, npcol, myrow, mycol )
140
141
142 np =
numroc( n, 1, myrow, 0, nprow )
143 nq =
numroc( n, 1, mycol, 0, npcol )
144
145
146 IF( myrow.EQ.mycol ) THEN
147
148 DO 20 j = 1, np
149 DO 10 i = j + 1, nq
150 a( j+( i-1 )*lda ) = a( i+( j-1 )*lda )
151 10 CONTINUE
152 20 CONTINUE
153
154 ELSE
155 IF( myrow.GT.mycol ) THEN
156 startrow = 1
157 startcol = 2
158 ELSE
159 IF( myrow.EQ.mycol ) THEN
160 startrow = 2
161 startcol = 2
162 ELSE
163 startrow = 2
164 startcol = 1
165 END IF
166 END IF
167
168 DO 50 jj = 1,
max( np, nq ), nb
169 minjsend = startcol + jj - 1
170 minjrecv = startrow + jj - 1
171 maxjsend =
min( minjsend+nb-1, nq )
172 maxjrecv =
min( minjrecv+nb-1, np )
173
174 sendnb = maxjsend - minjsend + 1
175 recvnb = maxjrecv - minjrecv + 1
176
177 minisend = 1
178 minirecv = 1
179 maxisend =
min( np, jj+sendnb-1 )
180 maxirecv =
min( nq, jj+recvnb-1 )
181
182 isend = maxisend - minisend + 1
183 irecv = maxirecv - minirecv + 1
184 jsend = maxjsend - minjsend + 1
185 jrecv = maxjrecv - minjrecv + 1
186
187
188
189 DO 40 j = minjrecv, maxjrecv
190 DO 30 i = minirecv, maxirecv + j - maxjrecv
191 work( i+( j-minjrecv )*irecv ) = a( j+( i-1 )*lda )
192 30 CONTINUE
193 40 CONTINUE
194
195 IF( irecv.GT.0 .AND. jrecv.GT.0 )
196 $ CALL strsd2d( ictxt, 'U', 'N', irecv, jrecv, work, irecv,
197 $ mycol, myrow )
198
199 IF( isend.GT.0 .AND. jsend.GT.0 )
200 $ CALL strrv2d( ictxt, 'U', 'N', isend, jsend,
201 $ a( minisend+( minjsend-1 )*lda ), lda,
202 $ mycol, myrow )
203
204
205 50 CONTINUE
206
207 END IF
208
209 RETURN
210
211
212
integer function numroc(n, nb, iproc, isrcproc, nprocs)