3
4
5
6
7
8
9
10 CHARACTER AFORM, DIAG
11 INTEGER IA, IASEED, JA, M, N
12 DOUBLE PRECISION ANORM, FRESID
13
14
15 INTEGER DESCA( * )
16 DOUBLE PRECISION A( * ), WORK( * )
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
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 INTEGER BLOCK_CYCLIC_2D, CSRC_, CTXT_, DLEN_, DTYPE_,
149 $ LLD_, MB_, M_, NB_, N_, RSRC_
150 parameter( block_cyclic_2d = 1, dlen_ = 9, dtype_ = 1,
151 $ ctxt_ = 2, m_ = 3, n_ = 4, mb_ = 5, nb_ = 6,
152 $ rsrc_ = 7, csrc_ = 8, lld_ = 9 )
153 DOUBLE PRECISION ONE
154 parameter( one = 1.0d+0 )
155
156
157 INTEGER IACOL, IAROW, ICOFF, ICTXT, IIA, IOFFA, IROFF,
158 $ JB, JJ, JJA, JN, LDA, LDW, MP, MYCOL, MYROW,
159 $ NPCOL, NPROW, NQ
160 DOUBLE PRECISION EPS
161
162
164
165
166 INTEGER ICEIL, NUMROC
167 DOUBLE PRECISION PDLAMCH, PDLANGE
169
170
172
173
174
175 ictxt = desca( ctxt_ )
176 CALL blacs_gridinfo( ictxt, nprow, npcol, myrow, mycol )
178 CALL infog2l( ia, ja, desca, nprow, npcol, myrow, mycol, iia, jja,
179 $ iarow, iacol )
180
181
182
183 iroff = mod( ia-1, desca( mb_ ) )
184 icoff = mod( ja-1, desca( nb_ ) )
185 mp =
numroc( m+iroff, desca( mb_ ), myrow, iarow, nprow )
186 nq =
numroc( n+icoff, desca( nb_ ), mycol, iacol, npcol )
187 IF( myrow.EQ.iarow )
188 $ mp = mp-iroff
189 IF( mycol.EQ.iacol )
190 $ nq = nq-icoff
191 jn =
min(
iceil( ja, desca( nb_ ) ) * desca( nb_ ), ja+n-1 )
193 lda = desca( lld_ )
194 ioffa = iia + ( jja - 1 )*lda
195
196
197
198 IF( mycol.EQ.iacol ) THEN
199 jb = jn-ja+1
200 CALL pdmatgen( ictxt, aform, diag, desca( m_ ), desca( n_ ),
201 $ desca( mb_ ), desca( nb_ ), work, ldw,
202 $ desca( rsrc_ ), desca( csrc_ ), iaseed, iia-1,
203 $ mp, jja-1, jb, myrow, mycol, nprow, npcol )
204 CALL dmatadd( mp, jb, -one, work, ldw, one, a( ioffa ), lda )
205 jja = jja + jb
206 nq = nq - jb
207 ioffa = ioffa + jb * lda
208 END IF
209
210
211
212 DO 10 jj = jja, jja+nq-1, desca( nb_ )
213 jb =
min( desca( nb_ ), jja+nq-jj )
214 ioffa = iia + ( jj - 1 ) * lda
215 CALL pdmatgen( ictxt, aform, diag, desca( m_ ), desca( n_ ),
216 $ desca( mb_ ), desca( nb_ ), work, ldw,
217 $ desca( rsrc_ ), desca( csrc_ ), iaseed, iia-1,
218 $ mp, jj-1, jb, myrow, mycol, nprow, npcol )
219 CALL dmatadd( mp, jb, -one, work, ldw, one, a( ioffa ), lda )
220 10 CONTINUE
221
222
223
224 fresid =
pdlange(
'I', m, n, a, ia, ja, desca, work ) /
225 $ (
max( m, n ) * eps * anorm )
226
227 RETURN
228
229
230
subroutine pdmatgen(ictxt, aform, diag, m, n, mb, nb, a, lda, iarow, iacol, iseed, iroff, irnum, icoff, icnum, myrow, mycol, nprow, npcol)
subroutine dmatadd(m, n, alpha, a, lda, beta, c, ldc)
integer function iceil(inum, idenom)
subroutine infog2l(grindx, gcindx, desc, nprow, npcol, myrow, mycol, lrindx, lcindx, rsrc, csrc)
integer function numroc(n, nb, iproc, isrcproc, nprocs)
double precision function pdlamch(ictxt, cmach)
double precision function pdlange(norm, m, n, a, ia, ja, desca, work)