6
7
8
9
10
11
12 INTEGER IA, IC, IQ, JA, JC, JQ, LWORK, MS, NV, RESULT
13 REAL EPSNORMA, THRESH, TSTNRM
14
15
16
17 INTEGER DESCA( * ), DESCC( * ), DESCQ( * )
18 REAL W( * ), WORK( * )
19 COMPLEX A( * ), C( * ), Q( * )
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183 INTEGER INFO, J, LOCALCOL, MP, MYCOL, MYROW, NPCOL,
184 $ NPROW, NQ, PCOL
185 REAL NORM
186
187
188 INTEGER BLOCK_CYCLIC_2D, DLEN_, DTYPE_, CTXT_, M_, N_,
189 $ MB_, NB_, RSRC_, CSRC_, LLD_
190 parameter( block_cyclic_2d = 1, dlen_ = 9, dtype_ = 1,
191 $ ctxt_ = 2, m_ = 3, n_ = 4, mb_ = 5, nb_ = 6,
192 $ rsrc_ = 7, csrc_ = 8, lld_ = 9 )
193 COMPLEX ONE, NEGONE
194 parameter( one = 1.0e+0, negone = -1.0e+0 )
195
196
197 INTEGER INDXG2L, INDXG2P, NUMROC
198 REAL PCLANGE
200
201
202 EXTERNAL blacs_gridinfo,
chk1mat, clacpy, csscal,
204
205
207
208
209
210 IF( block_cyclic_2d*csrc_*ctxt_*dlen_*dtype_*lld_*mb_*m_*nb_*n_*
211 $ rsrc_.LT.0 )RETURN
212
213 result = 0
214
215 CALL blacs_gridinfo( desca( ctxt_ ), nprow, npcol, myrow, mycol )
216
217 info = 0
218 CALL chk1mat( ms, 1, ms, 1, ia, ja, desca, 6, info )
219 CALL chk1mat( ms, 1, nv, 2, iq, jq, descq, 12, info )
220 CALL chk1mat( ms, 1, nv, 2, ic, jc, descc, 16, info )
221
222 IF( info.EQ.0 ) THEN
223
224 mp =
numroc( ms, desca( mb_ ), myrow, 0, nprow )
225 nq =
numroc( nv, desca( nb_ ), mycol, 0, npcol )
226
227 IF( iq.NE.1 ) THEN
228 info = -10
229 ELSE IF( jq.NE.1 ) THEN
230 info = -11
231 ELSE IF( ia.NE.1 ) THEN
232 info = -4
233 ELSE IF( ja.NE.1 ) THEN
234 info = -5
235 ELSE IF( ic.NE.1 ) THEN
236 info = -14
237 ELSE IF( jc.NE.1 ) THEN
238 info = -15
239 ELSE IF( lwork.LT.nq ) THEN
240 info = -19
241 END IF
242 END IF
243
244 IF( info.NE.0 ) THEN
245 CALL pxerbla( desca( ctxt_ ),
'PCSEPCHK', -info )
246 RETURN
247 END IF
248
249
250
251 CALL clacpy( 'A', mp, nq, q, descq( lld_ ), c, descc( lld_ ) )
252
253
254 DO 10 j = 1, nv
255 pcol =
indxg2p( j, descc( nb_ ), 0, 0, npcol )
256 localcol =
indxg2l( j, descc( nb_ ), 0, 0, npcol )
257
258 IF( mycol.EQ.pcol ) THEN
259 CALL csscal( mp, w( j ), c( ( localcol-1 )*descc( lld_ )+
260 $ 1 ), 1 )
261 END IF
262 10 CONTINUE
263
264
265
266
267 CALL pcgemm( 'N', 'N', ms, nv, ms, negone, a, 1, 1, desca, q, 1,
268 $ 1, descq, one, c, 1, 1, descc )
269
270
271
272
273 norm =
pclange(
'M', ms, nv, c, 1, 1, descc, work )
274
275
276 tstnrm = norm / epsnorma /
max( ms, 1 )
277
278 IF( tstnrm.GT.thresh .OR. ( tstnrm-tstnrm.NE.0.0e0 ) ) THEN
279 result = 1
280 END IF
281
282
283 RETURN
284
285
286
subroutine chk1mat(ma, mapos0, na, napos0, ia, ja, desca, descapos0, info)
integer function indxg2l(indxglob, nb, iproc, isrcproc, nprocs)
integer function indxg2p(indxglob, nb, iproc, isrcproc, nprocs)
integer function numroc(n, nb, iproc, isrcproc, nprocs)
real function pclange(norm, m, n, a, ia, ja, desca, work)
subroutine pxerbla(ictxt, srname, info)