Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
ElmerCSC
GitHub Repository: ElmerCSC/elmerfem
Path: blob/devel/mathlibs/src/parpack/pcneigh.f
5198 views
1
c\BeginDoc
2
c
3
c\Name: pcneigh
4
c
5
c Message Passing Layer: MPI
6
c
7
c\Description:
8
c Compute the eigenvalues of the current upper Hessenberg matrix
9
c and the corresponding Ritz estimates given the current residual norm.
10
c
11
c\Usage:
12
c call pcneigh
13
c ( COMM, RNORM, N, H, LDH, RITZ, BOUNDS, Q, LDQ, WORKL, RWORK, IERR )
14
c
15
c\Arguments
16
c COMM MPI Communicator for the processor grid. (INPUT)
17
c
18
c RNORM Real scalar. (INPUT)
19
c Residual norm corresponding to the current upper Hessenberg
20
c matrix H.
21
c
22
c N Integer. (INPUT)
23
c Size of the matrix H.
24
c
25
c H Complex N by N array. (INPUT)
26
c H contains the current upper Hessenberg matrix.
27
c
28
c LDH Integer. (INPUT)
29
c Leading dimension of H exactly as declared in the calling
30
c program.
31
c
32
c RITZ Complex array of length N. (OUTPUT)
33
c On output, RITZ(1:N) contains the eigenvalues of H.
34
c
35
c BOUNDS Complex array of length N. (OUTPUT)
36
c On output, BOUNDS contains the Ritz estimates associated with
37
c the eigenvalues held in RITZ. This is equal to RNORM
38
c times the last components of the eigenvectors corresponding
39
c to the eigenvalues in RITZ.
40
c
41
c Q Complex N by N array. (WORKSPACE)
42
c Workspace needed to store the eigenvectors of H.
43
c
44
c LDQ Integer. (INPUT)
45
c Leading dimension of Q exactly as declared in the calling
46
c program.
47
c
48
c WORKL Complex work array of length N**2 + 3*N. (WORKSPACE)
49
c Private (replicated) array on each PE or array allocated on
50
c the front end. This is needed to keep the full Schur form
51
c of H and also in the calculation of the eigenvectors of H.
52
c
53
c RWORK Real work array of length N (WORKSPACE)
54
c Private (replicated) array on each PE or array allocated on
55
c the front end.
56
c
57
c IERR Integer. (OUTPUT)
58
c Error exit flag from clahqr or ctrevc.
59
c
60
c\EndDoc
61
c
62
c-----------------------------------------------------------------------
63
c
64
c\BeginLib
65
c
66
c\Local variables:
67
c xxxxxx Complex
68
c
69
c\Routines called:
70
c pivout Parallel ARPACK utility routine that prints integers.
71
c second ARPACK utility routine for timing.
72
c pcmout Parallel ARPACK utility routine that prints matrices
73
c pcvout Parallel ARPACK utility routine that prints vectors.
74
c psvout Parallel ARPACK utility routine that prints vectors.
75
c clacpy LAPACK matrix copy routine.
76
c clahqr LAPACK routine to compute the Schur form of an
77
c upper Hessenberg matrix.
78
c claset LAPACK matrix initialization routine.
79
c ctrevc LAPACK routine to compute the eigenvectors of a matrix
80
c in upper triangular form
81
c ccopy Level 1 BLAS that copies one vector to another.
82
c csscal Level 1 BLAS that scales a complex vector by a real number.
83
c scnrm2 Level 1 BLAS that computes the norm of a vector.
84
c
85
c
86
c\Author
87
c Danny Sorensen Phuong Vu
88
c Richard Lehoucq CRPC / Rice University
89
c Dept. of Computational & Houston, Texas
90
c Applied Mathematics
91
c Rice University
92
c Houston, Texas
93
c
94
c\Parallel Modifications
95
c Kristi Maschhoff
96
c
97
c\Revision history:
98
c Starting Point: Serial Complex Code FILE: neigh.F SID: 2.1
99
c
100
c\SCCS Information:
101
c FILE: neigh.F SID: 1.2 DATE OF SID: 4/19/96
102
c
103
c\Remarks
104
c None
105
c
106
c\EndLib
107
c
108
c-----------------------------------------------------------------------
109
c
110
subroutine pcneigh (comm, rnorm, n, h, ldh, ritz, bounds,
111
& q, ldq, workl, rwork, ierr)
112
c
113
c %--------------------%
114
c | MPI Communicator |
115
c %--------------------%
116
c
117
integer comm
118
c
119
c %----------------------------------------------------%
120
c | Include files for debugging and timing information |
121
c %----------------------------------------------------%
122
c
123
include 'debug.h'
124
include 'stat.h'
125
c
126
c %------------------%
127
c | Scalar Arguments |
128
c %------------------%
129
c
130
integer ierr, n, ldh, ldq
131
Real
132
& rnorm
133
c
134
c %-----------------%
135
c | Array Arguments |
136
c %-----------------%
137
c
138
Complex
139
& bounds(n), h(ldh,n), q(ldq,n), ritz(n),
140
& workl(n*(n+3))
141
Real
142
& rwork(n)
143
c
144
c %------------%
145
c | Parameters |
146
c %------------%
147
c
148
Complex
149
& one, zero
150
Real
151
& rone
152
parameter (one = (1.0, 0.0), zero = (0.0, 0.0),
153
& rone = 1.0)
154
c
155
c %------------------------%
156
c | Local Scalars & Arrays |
157
c %------------------------%
158
c
159
logical select(1)
160
integer j, msglvl
161
Complex
162
& vl(1)
163
Real
164
& temp
165
c
166
c %----------------------%
167
c | External Subroutines |
168
c %----------------------%
169
c
170
external clacpy, clahqr, csscal, ctrevc, ccopy,
171
& pcmout, pcvout, second
172
c
173
c %--------------------%
174
c | External Functions |
175
c %--------------------%
176
c
177
Real
178
& scnrm2
179
external scnrm2
180
c
181
c %-----------------------%
182
c | Executable Statements |
183
c %-----------------------%
184
c
185
c
186
c %-------------------------------%
187
c | Initialize timing statistics |
188
c | & message level for debugging |
189
c %-------------------------------%
190
c
191
call second (t0)
192
msglvl = mceigh
193
c
194
if (msglvl .gt. 2) then
195
call pcmout (comm, logfil, n, n, h, ldh, ndigit,
196
& '_neigh: Entering upper Hessenberg matrix H ')
197
end if
198
c
199
c %----------------------------------------------------------%
200
c | 1. Compute the eigenvalues, the last components of the |
201
c | corresponding Schur vectors and the full Schur form T |
202
c | of the current upper Hessenberg matrix H. |
203
c | clahqr returns the full Schur form of H |
204
c | in WORKL(1:N**2), and the Schur vectors in q. |
205
c %----------------------------------------------------------%
206
c
207
call clacpy ('All', n, n, h, ldh, workl, n)
208
call claset ('All', n, n, zero, one, q, ldq)
209
call clahqr (.true., .true., n, 1, n, workl, ldh, ritz,
210
& 1, n, q, ldq, ierr)
211
if (ierr .ne. 0) go to 9000
212
c
213
call ccopy (n, q(n-1,1), ldq, bounds, 1)
214
if (msglvl .gt. 1) then
215
call pcvout (comm, logfil, n, bounds, ndigit,
216
& '_neigh: last row of the Schur matrix for H')
217
end if
218
c
219
c %----------------------------------------------------------%
220
c | 2. Compute the eigenvectors of the full Schur form T and |
221
c | apply the Schur vectors to get the corresponding |
222
c | eigenvectors. |
223
c %----------------------------------------------------------%
224
c
225
call ctrevc ('Right', 'Back', select, n, workl, n, vl, n, q,
226
& ldq, n, n, workl(n*n+1), rwork, ierr)
227
c
228
if (ierr .ne. 0) go to 9000
229
c
230
c %------------------------------------------------%
231
c | Scale the returning eigenvectors so that their |
232
c | Euclidean norms are all one. LAPACK subroutine |
233
c | ctrevc returns each eigenvector normalized so |
234
c | that the element of largest magnitude has |
235
c | magnitude 1; here the magnitude of a complex |
236
c | number (x,y) is taken to be |x| + |y|. |
237
c %------------------------------------------------%
238
c
239
do 10 j=1, n
240
temp = scnrm2( n, q(1,j), 1 )
241
call csscal ( n, rone / temp, q(1,j), 1 )
242
10 continue
243
c
244
if (msglvl .gt. 1) then
245
call ccopy(n, q(n,1), ldq, workl, 1)
246
call pcvout (comm, logfil, n, workl, ndigit,
247
& '_neigh: Last row of the eigenvector matrix for H')
248
end if
249
c
250
c %----------------------------%
251
c | Compute the Ritz estimates |
252
c %----------------------------%
253
c
254
call ccopy(n, q(n,1), n, bounds, 1)
255
call csscal(n, rnorm, bounds, 1)
256
c
257
if (msglvl .gt. 2) then
258
call pcvout (comm, logfil, n, ritz, ndigit,
259
& '_neigh: The eigenvalues of H')
260
call pcvout (comm, logfil, n, bounds, ndigit,
261
& '_neigh: Ritz estimates for the eigenvalues of H')
262
end if
263
c
264
call second(t1)
265
tceigh = tceigh + (t1 - t0)
266
c
267
9000 continue
268
return
269
c
270
c %----------------%
271
c | End of pcneigh |
272
c %----------------%
273
c
274
end
275
276