Debian Codegraph @

debian/external_deps/fetk/punc/src/pmg/src_f77/rchd.f

raw
1 c* ///////////////////////////////////////////////////////////////////////////
2 c* @file rchd.f
3 c* @author Michael Holst
4 c* @brief Richardson iteration.
5 c* @version $Id: rchd.f,v 1.2 2010/08/12 05:45:41 fetk Exp $
6 c* @attention
7 c* @verbatim
8 c*
9 c* PMG -- Parallel algebraic MultiGrid
10 c* Copyright (C) 1994-- Michael Holst.
11 c*
12 c* Michael Holst <[email protected]>
13 c* University of California, San Diego
14 c* Department of Mathematics, 5739 AP&M
15 c* 9500 Gilman Drive, Dept. 0112
16 c* La Jolla, CA 92093-0112 USA
17 c* http://math.ucsd.edu/~mholst
18 c*
19 c* This file is part of PMG.
20 c*
21 c* PMG is free software; you can redistribute it and/or modify
22 c* it under the terms of the GNU General Public License as published by
23 c* the Free Software Foundation; either version 2 of the License, or
24 c* (at your option) any later version.
25 c*
26 c* PMG is distributed in the hope that it will be useful,
27 c* but WITHOUT ANY WARRANTY; without even the implied warranty of
28 c* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29 c* GNU General Public License for more details.
30 c*
31 c* You should have received a copy of the GNU General Public License
32 c* along with PMG; if not, write to the Free Software
33 c* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
34 c*
35 c* Linking PMG statically or dynamically with other modules is making a
36 c* combined work based on PMG. Thus, the terms and conditions of the GNU
37 c* General Public License cover the whole combination.
38 c*
39 c* SPECIAL GPL EXCEPTION
40 c* In addition, as a special exception, the copyright holders of PMG
41 c* give you permission to combine the PMG program with free software
42 c* programs and libraries that are released under the GNU LGPL or with
43 c* code included in releases of ISIM, PMV, PyMOL, SMOL, VMD, and Vision.
44 c* Such combined software may be linked with PMG and redistributed together
45 c* in original or modified form as mere aggregation without requirement that
46 c* the entire work be under the scope of the GNU General Public License.
47 c* This special exception permission is also extended to any software listed
48 c* in the SPECIAL GPL EXCEPTION clauses by the FEtk and APBS libraries.
49 c*
50 c* Note that people who make modified versions of PMG are not obligated
51 c* to grant this special exception for their modified versions; it is
52 c* their choice whether to do so. The GNU General Public License gives
53 c* permission to release a modified version without this exception; this
54 c* exception also makes it possible to release a modified version which
55 c* carries forward this exception.
56 c*
57 c* @endverbatim
58 c* ///////////////////////////////////////////////////////////////////////////
59
60 subroutine rich(nx,ny,nz,ipc,rpc,ac,cc,fc,x,w1,w2,r,
61 2 itmax,iters,errtol,omega,iresid,iadjoint)
62 c* *********************************************************************
63 c* purpose:
64 c*
65 c* call the fast diagonal iterative method.
66 c*
67 c* author: michael holst
68 c* *********************************************************************
69 implicit none
70 integer ipc(*),itmax,iters,iresid,iadjoint,nx,ny,nz
71 integer numdia
72 double precision omega,errtol
73 double precision rpc(*),ac(nx*ny*nz,*),cc(nx,ny,nz),fc(nx,ny,nz)
74 double precision x(nx,ny,nz),w1(nx,ny,nz),w2(nx,ny,nz)
75 double precision r(nx,ny,nz)
76 c*
77 cmdir 0 0
78 c*
79 c* *** do in one step ***
80 numdia = ipc(11)
81 if (numdia .eq. 7) then
82 call rich7(nx,ny,nz,ipc,rpc,ac(1,1),cc,fc,
83 2 ac(1,2),ac(1,3),ac(1,4),
84 3 x,w1,w2,r,
85 4 itmax,iters,errtol,omega,iresid,iadjoint)
86 elseif (numdia .eq. 27) then
87 call rich27(nx,ny,nz,ipc,rpc,ac(1,1),cc,fc,
88 2 ac(1,2),ac(1,3),ac(1,4),ac(1,5),ac(1,6),ac(1,7),ac(1,8),
89 3 ac(1,9),ac(1,10),ac(1,11),ac(1,12),ac(1,13),ac(1,14),
90 4 x,w1,w2,r,
91 5 itmax,iters,errtol,omega,iresid,iadjoint)
92 else
93 print*,'% RICH: invalid stencil type given...'
94 endif
95 c*
96 c* *** return and end ***
97 return
98 end
99 subroutine rich7(nx,ny,nz,ipc,rpc,
100 2 oC,cc,fc,
101 3 oE,oN,uC,
102 4 x,w1,w2,r,
103 5 itmax,iters,errtol,omega,iresid,iadjoint)
104 c* *********************************************************************
105 c* purpose:
106 c*
107 c* linear richardson's iteration (hackbusch, page 185)
108 c*
109 c* author: michael holst
110 c* *********************************************************************
111 implicit none
112 integer ipc(*),itmax,iters,iresid,iadjoint,nx,ny,nz
113 integer i,j,k
114 double precision omega,errtol
115 double precision rpc(*),oE(nx,ny,nz),oN(nx,ny,nz),uC(nx,ny,nz)
116 double precision fc(nx,ny,nz),oC(nx,ny,nz),cc(nx,ny,nz)
117 double precision x(nx,ny,nz),w1(nx,ny,nz),w2(nx,ny,nz)
118 double precision r(nx,ny,nz)
119 c*
120 cmdir 0 0
121 c*
122 c* *** do the richardson's iteration itmax times ***
123 do 30 iters = 1, itmax
124 c*
125 c* *** first get the residual ***
126 call mresid7_1s(nx,ny,nz,ipc,rpc,oC,cc,fc,oE,oN,uC,x,r)
127 c*
128 c* *** do it ***
129 cmdir 3 1
130 do 10 k=2,nz-1
131 cmdir 3 2
132 do 11 j=2,ny-1
133 cmdir 3 3
134 do 12 i=2,nx-1
135 x(i,j,k) = x(i,j,k) + omega*r(i,j,k)
136 12 continue
137 11 continue
138 10 continue
139 c*
140 c* *** main loop ***
141 30 continue
142 c*
143 c* *** if specified, return the new residual as well ***
144 if (iresid .eq. 1) then
145 call mresid7_1s(nx,ny,nz,ipc,rpc,oC,cc,fc,oE,oN,uC,x,r)
146 endif
147 c*
148 c* *** return and end ***
149 return
150 end
151 subroutine rich27(nx,ny,nz,ipc,rpc,
152 2 oC,cc,fc,
153 3 oE,oN,uC,oNE,oNW,uE,uW,uN,uS,uNE,uNW,uSE,uSW,
154 4 x,w1,w2,r,
155 5 itmax,iters,errtol,omega,iresid,iadjoint)
156 c* *********************************************************************
157 c* purpose:
158 c*
159 c* linear richardson's iteration (hackbusch, page 185)
160 c*
161 c* author: michael holst
162 c* *********************************************************************
163 implicit none
164 integer ipc(*),itmax,iters,iresid,iadjoint,nx,ny,nz
165 integer i,j,k
166 double precision omega,errtol
167 double precision rpc(*),oE(nx,ny,nz),oN(nx,ny,nz),uC(nx,ny,nz)
168 double precision oNE(nx,ny,nz),oNW(nx,ny,nz),uE(nx,ny,nz)
169 double precision uW(nx,ny,nz),uN(nx,ny,nz),uS(nx,ny,nz)
170 double precision uNE(nx,ny,nz),uNW(nx,ny,nz),uSE(nx,ny,nz)
171 double precision uSW(nx,ny,nz)
172 double precision fc(nx,ny,nz),oC(nx,ny,nz),cc(nx,ny,nz)
173 double precision x(nx,ny,nz),w1(nx,ny,nz),w2(nx,ny,nz)
174 double precision r(nx,ny,nz)
175 c*
176 cmdir 0 0
177 c*
178 c* *** do the richardson's iteration itmax times ***
179 do 30 iters = 1, itmax
180 c*
181 c* *** first get the residual ***
182 call mresid27_1s(nx,ny,nz,ipc,rpc,oC,cc,fc,
183 2 oE,oN,uC,oNE,oNW,uE,uW,uN,uS,uNE,uNW,uSE,uSW,
184 3 x,r)
185 c*
186 c* *** do it ***
187 cmdir 3 1
188 do 10 k=2,nz-1
189 cmdir 3 2
190 do 11 j=2,ny-1
191 cmdir 3 3
192 do 12 i=2,nx-1
193 x(i,j,k) = x(i,j,k) + omega*r(i,j,k)
194 12 continue
195 11 continue
196 10 continue
197 c*
198 c* *** main loop ***
199 30 continue
200 c*
201 c* *** if specified, return the new residual as well ***
202 if (iresid .eq. 1) then
203 call mresid27_1s(nx,ny,nz,ipc,rpc,oC,cc,fc,
204 2 oE,oN,uC,oNE,oNW,uE,uW,uN,uS,uNE,uNW,uSE,uSW,
205 3 x,r)
206 endif
207 c*
208 c* *** return and end ***
209 return
210 end
211