Debian Codegraph @

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

raw
1 c* ///////////////////////////////////////////////////////////////////////////
2 c* @file ninterpd.f
3 c* @author Michael Holst
4 c* @brief Nonlinear version of operator-based interpolation.
5 c* @version $Id: ninterpd.f,v 1.2 2010/08/12 05:45:37 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 ninterp(nxc,nyc,nzc,nxf,nyf,nzf,xin,xout,pc,
61 2 ipc,rpc,ac,cc,fc)
62 c* *********************************************************************
63 c* purpose:
64 c*
65 c* driver for nonlinear operator-based interpolation.
66 c*
67 c* author: michael holst
68 c* *********************************************************************
69 integer nxf,nyf,nzf,nxc,nyc,nzc,numdia
70 double precision xin(*),xout(*),pc(nxc*nyc*nzc,*)
71 integer ipc(*)
72 double precision rpc(*),ac(nxf*nyf*nzf,*),cc(*),fc(*)
73 c*
74 c* *** doit ***
75 numdia = ipc(11)
76 if (numdia .eq. 7) then
77 call ninterp7(nxc,nyc,nzc,nxf,nyf,nzf,xin,xout,
78 2 pc(1,1),pc(1,2),pc(1,3),pc(1,4),pc(1,5),pc(1,6),
79 3 pc(1,7),pc(1,8),pc(1,9),pc(1,10),pc(1,11),pc(1,12),
80 4 pc(1,13),pc(1,14),pc(1,15),pc(1,16),pc(1,17),pc(1,18),
81 5 pc(1,19),pc(1,20),pc(1,21),pc(1,22),pc(1,23),pc(1,24),
82 6 pc(1,25),pc(1,26),pc(1,27),
83 7 ipc,rpc,ac(1,1),ac(1,2),ac(1,3),ac(1,4),cc,fc)
84 elseif (numdia .eq. 27) then
85 call ninterp27(nxc,nyc,nzc,nxf,nyf,nzf,xin,xout,
86 2 pc(1,1),pc(1,2),pc(1,3),pc(1,4),pc(1,5),pc(1,6),
87 3 pc(1,7),pc(1,8),pc(1,9),pc(1,10),pc(1,11),pc(1,12),
88 4 pc(1,13),pc(1,14),pc(1,15),pc(1,16),pc(1,17),pc(1,18),
89 5 pc(1,19),pc(1,20),pc(1,21),pc(1,22),pc(1,23),pc(1,24),
90 6 pc(1,25),pc(1,26),pc(1,27),
91 7 ipc,rpc,ac(1,1),ac(1,2),ac(1,3),ac(1,4),
92 8 ac(1,5),ac(1,6),ac(1,7),ac(1,8),ac(1,9),ac(1,10),ac(1,11),
93 9 ac(1,12),ac(1,13),ac(1,14),cc,fc)
94 else
95 print*,'% NINTERP: invalid stencil type given...'
96 endif
97 c*
98 c* *** return and end ***
99 return
100 end
101 subroutine ninterp7(nxc,nyc,nzc,nxf,nyf,nzf,xin,xout,
102 2 oPC,oPN,oPS,oPE,oPW,oPNE,oPNW,oPSE,oPSW,
103 3 uPC,uPN,uPS,uPE,uPW,uPNE,uPNW,uPSE,uPSW,
104 4 dPC,dPN,dPS,dPE,dPW,dPNE,dPNW,dPSE,dPSW,
105 5 ipc,rpc,oC,oE,oN,uC,cc,fc)
106 c* *********************************************************************
107 c* purpose:
108 c*
109 c* 7-diagonal nonlinear operator-based interpolation.
110 c*
111 c* author: michael holst
112 c* *********************************************************************
113 implicit none
114 integer nxc,nyc,nzc,nxf,nyf,nzf,i,j,k,jj,ii,kk
115 double precision xin(nxc,nyc,nzc),xout(nxf,nyf,nzf)
116 double precision oPC(nxc,nyc,nzc),oPN(nxc,nyc,nzc)
117 double precision oPS(nxc,nyc,nzc),oPE(nxc,nyc,nzc)
118 double precision oPW(nxc,nyc,nzc),oPNE(nxc,nyc,nzc)
119 double precision oPNW(nxc,nyc,nzc),oPSE(nxc,nyc,nzc)
120 double precision oPSW(nxc,nyc,nzc),uPC(nxc,nyc,nzc)
121 double precision uPN(nxc,nyc,nzc),uPS(nxc,nyc,nzc)
122 double precision uPE(nxc,nyc,nzc),uPW(nxc,nyc,nzc)
123 double precision uPNE(nxc,nyc,nzc),uPNW(nxc,nyc,nzc)
124 double precision uPSE(nxc,nyc,nzc),uPSW(nxc,nyc,nzc)
125 double precision dPC(nxc,nyc,nzc),dPN(nxc,nyc,nzc)
126 double precision dPS(nxc,nyc,nzc),dPE(nxc,nyc,nzc)
127 double precision dPW(nxc,nyc,nzc),dPNE(nxc,nyc,nzc)
128 double precision dPNW(nxc,nyc,nzc),dPSE(nxc,nyc,nzc)
129 double precision dPSW(nxc,nyc,nzc)
130 integer ipc(*)
131 double precision rpc(*),cc(nxf,nyf,nzf),fc(nxf,nyf,nzf)
132 double precision oC(nxf,nyf,nzf)
133 double precision oE(nxf,nyf,nzf),oN(nxf,nyf,nzf),uC(nxf,nyf,nzf)
134 integer i1,j1,k1,key
135 double precision c_scal,dc_scal
136 double precision UU,AA,BB,DD,FF,zNN,DzNN,zntol,zndenom,znerror
137 double precision change
138 integer nitmax,niters,ifail_tol,ipkey
139 c*
140 c* *********************************************************************
141 c* setup
142 c* *********************************************************************
143 c*
144 cmdir 0 0
145 c*
146 c* *** nonlinear iteration tolerance and itmax ***
147 nitmax = 10
148 zntol = 1.0e-5
149 ifail_tol = 0
150 ipkey = ipc(10)
151 key = 0
152 c*
153 c* *** verify correctness of the input boundary points ***
154 call fbound00(nxc,nyc,nzc,xin)
155 c*
156 c* *** doit ***
157 cmdir 3 1
158 do 10 k = 1, nzf-2, 2
159 kk = (k-1) / 2 + 1
160 cmdir 3 2
161 do 11 j = 1, nyf-2, 2
162 jj = (j-1) / 2 + 1
163 cmdir 3 3
164 do 12 i = 1, nxf-2, 2
165 ii = (i-1) / 2 + 1
166 c*
167 c* *********************************************************************
168 c* type 1 -- fine grid points common to a coarse grid point
169 c* *********************************************************************
170 c*
171 c* *** copy coinciding points from coarse grid to fine grid ***
172 xout(i,j,k) = xin(ii,jj,kk)
173 c*
174 c* *********************************************************************
175 c* type 2 -- fine grid points common to a coarse grid plane
176 c* *********************************************************************
177 c*
178 c* *********************************************************************
179 c* *** fine grid pts common only to y-z planes on coarse grid ***
180 c* *** (intermediate pts between 2 grid points on x-row) ***
181 xout(i+1,j,k) = oPE(ii,jj,kk) * xin(ii,jj,kk)
182 2 + oPW(ii+1,jj,kk) * xin(ii+1,jj,kk)
183 i1 = i+1
184 j1 = j
185 k1 = k
186 c*
187 c* *** setup the 1d equation ***
188 DD = ( oC(i1,j1,k1)
189 2 - uC(i1,j1,k1)
190 3 - uC(i1,j1,max0(1,k1-1)) * dble(min0(1,k1-1))
191 4 - oN(i1,j1,k1)
192 5 - oN(i1,max0(1,j1-1),k1) * dble(min0(1,j1-1)) )
193 if (DD .eq. 0.0d0) then
194 DD = 1.0d0
195 else
196 DD = 1.0d0 / DD
197 endif
198 UU = xout(i1,j1,k1)
199 AA = 1.0d0
200 BB = cc(i1,j1,k1)
201 FF = key * fc(i1,j1,k1) + xout(i1,j1,k1)
202 c*
203 c* *** evaluate residual of 1d system
204 zNN = AA * UU + DD * c_scal(BB,UU,ipkey) - FF
205 c*
206 c* *** setup for newton's method
207 niters = 0
208 zndenom = zNN
209 if (zndenom .eq. 0.0d0) zndenom = 1.0d0
210 znerror = zNN / zndenom
211 c*
212 c* *** the 1d newton's method ***
213 if (znerror .lt. zntol) goto 23
214 if (niters .gt. nitmax) goto 22
215 21 continue
216 niters = niters + 1
217 c*
218 c* *** construct jacobian matrix of NN ***
219 DzNN = AA + DD * dc_scal(BB,UU,ipkey)
220 c*
221 c* *** solve the linear system ***
222 change = - zNN / DzNN
223 c*
224 c* *** update the solution ***
225 UU = UU + change
226 c*
227 c* *** evaluate residual of 1d system ***
228 zNN = AA * UU + DD * c_scal(BB,UU,ipkey) - FF
229 c*
230 c* *** compute error ***
231 znerror = zNN / zndenom
232 c*
233 c* *** tolerance and itmax check ***
234 if (znerror .lt. zntol) goto 23
235 if (niters .gt. nitmax) goto 22
236 c*
237 c* *** loop ***
238 goto 21
239 c*
240 c* *** tolerance not reached ***
241 22 continue
242 ifail_tol = ifail_tol + 1
243 c*
244 c* *** tolerance reached ***
245 23 continue
246 c*
247 c* *** newton's method complete -- update solution value ***
248 xout(i1,j1,k1) = UU
249 c*
250 c* *********************************************************************
251 c* *** fine grid pts common only to x-z planes on coarse grid ***
252 c* *** (intermediate pts between 2 grid points on a y-row) ***
253 xout(i,j+1,k) = oPN(ii,jj,kk) * xin(ii,jj,kk)
254 2 + oPS(ii,jj+1,kk) * xin(ii,jj+1,kk)
255 i1 = i
256 j1 = j+1
257 k1 = k
258 c*
259 c* *** setup the 1d equation ***
260 DD = ( oC(i1,j1,k1)
261 2 - oE(i1,j1,k1)
262 3 - oE(max0(1,i1-1),j1,k1) * dble(min0(1,i1-1))
263 4 - uC(i1,j1,k1)
264 5 - uC(i1,j1,max0(1,k1-1)) * dble(min0(1,k1-1)) )
265 if (DD .eq. 0.0d0) then
266 DD = 1.0d0
267 else
268 DD = 1.0d0 / DD
269 endif
270 UU = xout(i1,j1,k1)
271 AA = 1.0d0
272 BB = cc(i1,j1,k1)
273 FF = key * fc(i1,j1,k1) + xout(i1,j1,k1)
274 c*
275 c* *** evaluate residual of 1d system
276 zNN = AA * UU + DD * c_scal(BB,UU,ipkey) - FF
277 c*
278 c* *** setup for newton's method
279 niters = 0
280 zndenom = zNN
281 if (zndenom .eq. 0.0d0) zndenom = 1.0d0
282 znerror = zNN / zndenom
283 c*
284 c* *** the 1d newton's method ***
285 if (znerror .lt. zntol) goto 33
286 if (niters .gt. nitmax) goto 32
287 31 continue
288 niters = niters + 1
289 c*
290 c* *** construct jacobian matrix of NN ***
291 DzNN = AA + DD * dc_scal(BB,UU,ipkey)
292 c*
293 c* *** solve the linear system ***
294 change = - zNN / DzNN
295 c*
296 c* *** update the solution ***
297 UU = UU + change
298 c*
299 c* *** evaluate residual of 1d system ***
300 zNN = AA * UU + DD * c_scal(BB,UU,ipkey) - FF
301 c*
302 c* *** compute error ***
303 znerror = zNN / zndenom
304 c*
305 c* *** tolerance and itmax check ***
306 if (znerror .lt. zntol) goto 33
307 if (niters .gt. nitmax) goto 32
308 c*
309 c* *** loop ***
310 goto 31
311 c*
312 c* *** tolerance not reached ***
313 32 continue
314 ifail_tol = ifail_tol + 1
315 c*
316 c* *** tolerance reached ***
317 33 continue
318 c*
319 c* *** newton's method complete -- update solution value ***
320 xout(i1,j1,k1) = UU
321 c*
322 c* *********************************************************************
323 c* *** fine grid pts common only to x-y planes on coarse grid ***
324 c* *** (intermediate pts between 2 grid points on a z-row) ***
325 xout(i,j,k+1) = uPC(ii,jj,kk) * xin(ii,jj,kk)
326 2 + dPC(ii,jj,kk+1) * xin(ii,jj,kk+1)
327 i1 = i
328 j1 = j
329 k1 = k+1
330 c*
331 c* *** setup the 1d equation ***
332 DD = ( oC(i1,j1,k1)
333 2 - oE(i1,j1,k1)
334 3 - oE(max0(1,i1-1),j1,k1) * dble(min0(1,i1-1))
335 4 - oN(i1,j1,k1)
336 5 - oN(i1,max0(1,j1-1),k1) * dble(min0(1,j1-1)) )
337 if (DD .eq. 0.0d0) then
338 DD = 1.0d0
339 else
340 DD = 1.0d0 / DD
341 endif
342 UU = xout(i1,j1,k1)
343 AA = 1.0d0
344 BB = cc(i1,j1,k1)
345 FF = key * fc(i1,j1,k1) + xout(i1,j1,k1)
346 c*
347 c* *** evaluate residual of 1d system
348 zNN = AA * UU + DD * c_scal(BB,UU,ipkey) - FF
349 c*
350 c* *** setup for newton's method
351 niters = 0
352 zndenom = zNN
353 if (zndenom .eq. 0.0d0) zndenom = 1.0d0
354 znerror = zNN / zndenom
355 c*
356 c* *** the 1d newton's method ***
357 if (znerror .lt. zntol) goto 43
358 if (niters .gt. nitmax) goto 42
359 41 continue
360 niters = niters + 1
361 c*
362 c* *** construct jacobian matrix of NN ***
363 DzNN = AA + DD * dc_scal(BB,UU,ipkey)
364 c*
365 c* *** solve the linear system ***
366 change = - zNN / DzNN
367 c*
368 c* *** update the solution ***
369 UU = UU + change
370 c*
371 c* *** evaluate residual of 1d system ***
372 zNN = AA * UU + DD * c_scal(BB,UU,ipkey) - FF
373 c*
374 c* *** compute error ***
375 znerror = zNN / zndenom
376 c*
377 c* *** tolerance and itmax check ***
378 if (znerror .lt. zntol) goto 43
379 if (niters .gt. nitmax) goto 42
380 c*
381 c* *** loop ***
382 goto 41
383 c*
384 c* *** tolerance not reached ***
385 42 continue
386 ifail_tol = ifail_tol + 1
387 c*
388 c* *** tolerance reached ***
389 43 continue
390 c*
391 c* *** newton's method complete -- update solution value ***
392 xout(i1,j1,k1) = UU
393 c*
394 c* *********************************************************************
395 c* type 3 -- fine grid points common to a coarse grid line
396 c* *********************************************************************
397 c*
398 c* *********************************************************************
399 c* *** fine grid pts common only to z planes on coarse grid ***
400 c* *** (intermediate pts between 4 grid pts on the xy-plane***
401 xout(i+1,j+1,k) = oPNE(ii,jj,kk) * xin(ii,jj,kk)
402 2 + oPNW(ii+1,jj,kk) * xin(ii+1,jj,kk)
403 3 + oPSE(ii,jj+1,kk) * xin(ii,jj+1,kk)
404 4 + oPSW(ii+1,jj+1,kk) * xin(ii+1,jj+1,kk)
405 i1 = i+1
406 j1 = j+1
407 k1 = k
408 c*
409 c* *** setup the 1d equation ***
410 DD = ( oC(i1,j1,k1)
411 2 - uC(i1,j1,k1)
412 3 - uC(i1,j1,max0(1,k1-1)) * dble(min0(1,k1-1)) )
413 if (DD .eq. 0.0d0) then
414 DD = 1.0d0
415 else
416 DD = 1.0d0 / DD
417 endif
418 UU = xout(i1,j1,k1)
419 AA = 1.0d0
420 BB = cc(i1,j1,k1)
421 FF = key * fc(i1,j1,k1) + xout(i1,j1,k1)
422 c*
423 c* *** evaluate residual of 1d system
424 zNN = AA * UU + DD * c_scal(BB,UU,ipkey) - FF
425 c*
426 c* *** setup for newton's method
427 niters = 0
428 zndenom = zNN
429 if (zndenom .eq. 0.0d0) zndenom = 1.0d0
430 znerror = zNN / zndenom
431 c*
432 c* *** the 1d newton's method ***
433 if (znerror .lt. zntol) goto 53
434 if (niters .gt. nitmax) goto 52
435 51 continue
436 niters = niters + 1
437 c*
438 c* *** construct jacobian matrix of NN ***
439 DzNN = AA + DD * dc_scal(BB,UU,ipkey)
440 c*
441 c* *** solve the linear system ***
442 change = - zNN / DzNN
443 c*
444 c* *** update the solution ***
445 UU = UU + change
446 c*
447 c* *** evaluate residual of 1d system ***
448 zNN = AA * UU + DD * c_scal(BB,UU,ipkey) - FF
449 c*
450 c* *** compute error ***
451 znerror = zNN / zndenom
452 c*
453 c* *** tolerance and itmax check ***
454 if (znerror .lt. zntol) goto 53
455 if (niters .gt. nitmax) goto 52
456 c*
457 c* *** loop ***
458 goto 51
459 c*
460 c* *** tolerance not reached ***
461 52 continue
462 ifail_tol = ifail_tol + 1
463 c*
464 c* *** tolerance reached ***
465 53 continue
466 c*
467 c* *** newton's method complete -- update solution value ***
468 xout(i1,j1,k1) = UU
469 c*
470 c* *********************************************************************
471 c* *** fine grid pts common only to y planes on coarse grid ***
472 c* *** (intermediate pts between 4 grid pts on the xz-plane***
473 xout(i+1,j,k+1) = uPE(ii,jj,kk) * xin(ii,jj,kk)
474 2 + uPW(ii+1,jj,kk) * xin(ii+1,jj,kk)
475 3 + dPE(ii,jj,kk+1) * xin(ii,jj,kk+1)
476 4 + dPW(ii+1,jj,kk+1) * xin(ii+1,jj,kk+1)
477 i1 = i+1
478 j1 = j
479 k1 = k+1
480 c*
481 c* *** setup the 1d equation ***
482 DD = ( oC(i1,j1,k1)
483 2 - oN(i1,j1,k1)
484 3 - oN(i1,max0(1,j1-1),k1) * dble(min0(1,j1-1)) )
485 if (DD .eq. 0.0d0) then
486 DD = 1.0d0
487 else
488 DD = 1.0d0 / DD
489 endif
490 UU = xout(i1,j1,k1)
491 AA = 1.0d0
492 BB = cc(i1,j1,k1)
493 FF = key * fc(i1,j1,k1) + xout(i1,j1,k1)
494 c*
495 c* *** evaluate residual of 1d system
496 zNN = AA * UU + DD * c_scal(BB,UU,ipkey) - FF
497 c*
498 c* *** setup for newton's method
499 niters = 0
500 zndenom = zNN
501 if (zndenom .eq. 0.0d0) zndenom = 1.0d0
502 znerror = zNN / zndenom
503 c*
504 c* *** the 1d newton's method ***
505 if (znerror .lt. zntol) goto 63
506 if (niters .gt. nitmax) goto 62
507 61 continue
508 niters = niters + 1
509 c*
510 c* *** construct jacobian matrix of NN ***
511 DzNN = AA + DD * dc_scal(BB,UU,ipkey)
512 c*
513 c* *** solve the linear system ***
514 change = - zNN / DzNN
515 c*
516 c* *** update the solution ***
517 UU = UU + change
518 c*
519 c* *** evaluate residual of 1d system ***
520 zNN = AA * UU + DD * c_scal(BB,UU,ipkey) - FF
521 c*
522 c* *** compute error ***
523 znerror = zNN / zndenom
524 c*
525 c* *** tolerance and itmax check ***
526 if (znerror .lt. zntol) goto 63
527 if (niters .gt. nitmax) goto 62
528 c*
529 c* *** loop ***
530 goto 61
531 c*
532 c* *** tolerance not reached ***
533 62 continue
534 ifail_tol = ifail_tol + 1
535 c*
536 c* *** tolerance reached ***
537 63 continue
538 c*
539 c* *** newton's method complete -- update solution value ***
540 xout(i1,j1,k1) = UU
541 c*
542 c* *********************************************************************
543 c* *** fine grid pts common only to x planes on coarse grid ***
544 c* *** (intermediate pts between 4 grid pts on the yz-plane***
545 xout(i,j+1,k+1) = uPN(ii,jj,kk) * xin(ii,jj,kk)
546 2 + uPS(ii,jj+1,kk) * xin(ii,jj+1,kk)
547 3 + dPN(ii,jj,kk+1) * xin(ii,jj,kk+1)
548 4 + dPS(ii,jj+1,kk+1) * xin(ii,jj+1,kk+1)
549 i1 = i
550 j1 = j+1
551 k1 = k+1
552 c*
553 c* *** setup the 1d equation ***
554 DD = ( oC(i1,j1,k1)
555 2 - oE(i1,j1,k1)
556 3 - oE(max0(1,i1-1),j1,k1) * dble(min0(1,i1-1)) )
557 if (DD .eq. 0.0d0) then
558 DD = 1.0d0
559 else
560 DD = 1.0d0 / DD
561 endif
562 UU = xout(i1,j1,k1)
563 AA = 1.0d0
564 BB = cc(i1,j1,k1)
565 FF = key * fc(i1,j1,k1) + xout(i1,j1,k1)
566 c*
567 c* *** evaluate residual of 1d system
568 zNN = AA * UU + DD * c_scal(BB,UU,ipkey) - FF
569 c*
570 c* *** setup for newton's method
571 niters = 0
572 zndenom = zNN
573 if (zndenom .eq. 0.0d0) zndenom = 1.0d0
574 znerror = zNN / zndenom
575 c*
576 c* *** the 1d newton's method ***
577 if (znerror .lt. zntol) goto 73
578 if (niters .gt. nitmax) goto 72
579 71 continue
580 niters = niters + 1
581 c*
582 c* *** construct jacobian matrix of NN ***
583 DzNN = AA + DD * dc_scal(BB,UU,ipkey)
584 c*
585 c* *** solve the linear system ***
586 change = - zNN / DzNN
587 c*
588 c* *** update the solution ***
589 UU = UU + change
590 c*
591 c* *** evaluate residual of 1d system ***
592 zNN = AA * UU + DD * c_scal(BB,UU,ipkey) - FF
593 c*
594 c* *** compute error ***
595 znerror = zNN / zndenom
596 c*
597 c* *** tolerance and itmax check ***
598 if (znerror .lt. zntol) goto 73
599 if (niters .gt. nitmax) goto 72
600 c*
601 c* *** loop ***
602 goto 71
603 c*
604 c* *** tolerance not reached ***
605 72 continue
606 ifail_tol = ifail_tol + 1
607 c*
608 c* *** tolerance reached ***
609 73 continue
610 c*
611 c* *** newton's method complete -- update solution value ***
612 xout(i1,j1,k1) = UU
613 c*
614 c* *********************************************************************
615 c* type 4 -- fine grid points not common to coarse grid pts/lines/planes
616 c* *********************************************************************
617 c*
618 c* *** completely interior points ***
619 xout(i+1,j+1,k+1) =
620 2 + uPNE(ii,jj,kk) * xin(ii,jj,kk)
621 3 + uPNW(ii+1,jj,kk) * xin(ii+1,jj,kk)
622 4 + uPSE(ii,jj+1,kk) * xin(ii,jj+1,kk)
623 5 + uPSW(ii+1,jj+1,kk) * xin(ii+1,jj+1,kk)
624 6 + dPNE(ii,jj,kk+1) * xin(ii,jj,kk+1)
625 7 + dPNW(ii+1,jj,kk+1) * xin(ii+1,jj,kk+1)
626 8 + dPSE(ii,jj+1,kk+1) * xin(ii,jj+1,kk+1)
627 9 + dPSW(ii+1,jj+1,kk+1) * xin(ii+1,jj+1,kk+1)
628 i1 = i+1
629 j1 = j+1
630 k1 = k+1
631 c*
632 c* *** setup the 1d equation ***
633 DD = oC(i1,j1,k1)
634 if (DD .eq. 0.0d0) then
635 DD = 1.0d0
636 else
637 DD = 1.0d0 / DD
638 endif
639 UU = xout(i1,j1,k1)
640 AA = 1.0d0
641 BB = cc(i1,j1,k1)
642 FF = key * fc(i1,j1,k1) + xout(i1,j1,k1)
643 c*
644 c* *** evaluate residual of 1d system
645 zNN = AA * UU + DD * c_scal(BB,UU,ipkey) - FF
646 c*
647 c* *** setup for newton's method
648 niters = 0
649 zndenom = zNN
650 if (zndenom .eq. 0.0d0) zndenom = 1.0d0
651 znerror = zNN / zndenom
652 c*
653 c* *** the 1d newton's method ***
654 if (znerror .lt. zntol) goto 83
655 if (niters .gt. nitmax) goto 82
656 81 continue
657 niters = niters + 1
658 c*
659 c* *** construct jacobian matrix of NN ***
660 DzNN = AA + DD * dc_scal(BB,UU,ipkey)
661 c*
662 c* *** solve the linear system ***
663 change = - zNN / DzNN
664 c*
665 c* *** update the solution ***
666 UU = UU + change
667 c*
668 c* *** evaluate residual of 1d system ***
669 zNN = AA * UU + DD * c_scal(BB,UU,ipkey) - FF
670 c*
671 c* *** compute error ***
672 znerror = zNN / zndenom
673 c*
674 c* *** tolerance and itmax check ***
675 if (znerror .lt. zntol) goto 83
676 if (niters .gt. nitmax) goto 82
677 c*
678 c* *** loop ***
679 goto 81
680 c*
681 c* *** tolerance not reached ***
682 82 continue
683 ifail_tol = ifail_tol + 1
684 c*
685 c* *** tolerance reached ***
686 83 continue
687 c*
688 c* *** newton's method complete -- update solution value ***
689 xout(i1,j1,k1) = UU
690 c*
691 c* *** main loop ***
692 12 continue
693 11 continue
694 10 continue
695 c*
696 c* *** verify correctness of the output boundary points ***
697 call fbound00(nxf,nyf,nzf,xout)
698 c*
699 c* *** messages ***
700 if (ifail_tol .gt. 0) then
701 print*,'% NINTERP7: 1d newton tolerance failures: ',ifail_tol
702 endif
703 c*
704 c* *** return and end ***
705 return
706 end
707 subroutine ninterp27(nxc,nyc,nzc,nxf,nyf,nzf,xin,xout,
708 2 oPC,oPN,oPS,oPE,oPW,oPNE,oPNW,oPSE,oPSW,
709 3 uPC,uPN,uPS,uPE,uPW,uPNE,uPNW,uPSE,uPSW,
710 4 dPC,dPN,dPS,dPE,dPW,dPNE,dPNW,dPSE,dPSW,
711 5 ipc,rpc,
712 6 oC,oE,oN,uC,oNE,oNW,uE,uW,uN,uS,uNE,uNW,uSE,uSW,
713 7 cc,fc)
714 c* *********************************************************************
715 c* purpose:
716 c*
717 c* 27-diagonal nonlinear operator-based interpolation.
718 c*
719 c* author: michael holst
720 c* *********************************************************************
721 implicit none
722 integer nxc,nyc,nzc,nxf,nyf,nzf,i,j,k,jj,ii,kk
723 double precision xin(nxc,nyc,nzc),xout(nxf,nyf,nzf)
724 double precision oPC(nxc,nyc,nzc),oPN(nxc,nyc,nzc)
725 double precision oPS(nxc,nyc,nzc),oPE(nxc,nyc,nzc)
726 double precision oPW(nxc,nyc,nzc),oPNE(nxc,nyc,nzc)
727 double precision oPNW(nxc,nyc,nzc),oPSE(nxc,nyc,nzc)
728 double precision oPSW(nxc,nyc,nzc),uPC(nxc,nyc,nzc)
729 double precision uPN(nxc,nyc,nzc),uPS(nxc,nyc,nzc)
730 double precision uPE(nxc,nyc,nzc),uPW(nxc,nyc,nzc)
731 double precision uPNE(nxc,nyc,nzc),uPNW(nxc,nyc,nzc)
732 double precision uPSE(nxc,nyc,nzc),uPSW(nxc,nyc,nzc)
733 double precision dPC(nxc,nyc,nzc),dPN(nxc,nyc,nzc)
734 double precision dPS(nxc,nyc,nzc),dPE(nxc,nyc,nzc)
735 double precision dPW(nxc,nyc,nzc),dPNE(nxc,nyc,nzc)
736 double precision dPNW(nxc,nyc,nzc),dPSE(nxc,nyc,nzc)
737 double precision dPSW(nxc,nyc,nzc)
738 integer ipc(*)
739 double precision rpc(*),cc(nxf,nyf,nzf),fc(nxf,nyf,nzf)
740 double precision oC(nxf,nyf,nzf),oE(nxf,nyf,nzf)
741 double precision oN(nxf,nyf,nzf),uC(nxf,nyf,nzf)
742 double precision oNE(nxf,nyf,nzf),oNW(nxf,nyf,nzf)
743 double precision uE(nxf,nyf,nzf),uW(nxf,nyf,nzf)
744 double precision uN(nxf,nyf,nzf),uS(nxf,nyf,nzf)
745 double precision uNE(nxf,nyf,nzf),uNW(nxf,nyf,nzf)
746 double precision uSE(nxf,nyf,nzf),uSW(nxf,nyf,nzf)
747 integer i1,j1,k1,key
748 double precision c_scal,dc_scal
749 double precision UU,AA,BB,DD,FF,zNN,DzNN,zntol,zndenom,znerror
750 double precision change
751 integer nitmax,niters,ifail_tol,ipkey
752 c*
753 c* *********************************************************************
754 c* setup
755 c* *********************************************************************
756 c*
757 cmdir 0 0
758 c*
759 c* *** nonlinear iteration tolerance and itmax ***
760 nitmax = 10
761 zntol = 1.0e-5
762 ifail_tol = 0
763 ipkey = ipc(10)
764 key = 0
765 c*
766 c* *** verify correctness of the input boundary points ***
767 call fbound00(nxc,nyc,nzc,xin)
768 c*
769 c* *** doit ***
770 cmdir 3 1
771 do 10 k = 1, nzf-2, 2
772 kk = (k-1) / 2 + 1
773 cmdir 3 2
774 do 11 j = 1, nyf-2, 2
775 jj = (j-1) / 2 + 1
776 cmdir 3 3
777 do 12 i = 1, nxf-2, 2
778 ii = (i-1) / 2 + 1
779 c*
780 c* *********************************************************************
781 c* type 1 -- fine grid points common to a coarse grid point
782 c* *********************************************************************
783 c*
784 c* *** copy coinciding points from coarse grid to fine grid ***
785 xout(i,j,k) = xin(ii,jj,kk)
786 c*
787 c* *********************************************************************
788 c* type 2 -- fine grid points common to a coarse grid plane
789 c* *********************************************************************
790 c*
791 c* *********************************************************************
792 c* *** fine grid pts common only to y-z planes on coarse grid ***
793 c* *** (intermediate pts between 2 grid points on x-row) ***
794 xout(i+1,j,k) = oPE(ii,jj,kk) * xin(ii,jj,kk)
795 2 + oPW(ii+1,jj,kk) * xin(ii+1,jj,kk)
796 i1 = i+1
797 j1 = j
798 k1 = k
799 c*
800 c* *** setup the 1d equation ***
801 DD = ( oC(i1,j1,k1)
802 2 - uC(i1,j1,k1)
803 3 - uC(i1,j1,max0(1,k1-1)) * dble(min0(1,k1-1))
804 4 - oN(i1,j1,k1)
805 5 - oN(i1,max0(1,j1-1),k1) * dble(min0(1,j1-1))
806 6 - uN(i1,j1,k1)
807 7 - uS(i1,j1,k1)
808 8 - uN(i1,j1,max0(1,k1-1)) * dble(min0(1,k1-1))
809 9 - uS(i1,j1,max0(1,k1-1)) * dble(min0(1,k1-1)) )
810 if (DD .eq. 0.0d0) then
811 DD = 1.0d0
812 else
813 DD = 1.0d0 / DD
814 endif
815 UU = xout(i1,j1,k1)
816 AA = 1.0d0
817 BB = cc(i1,j1,k1)
818 FF = key * fc(i1,j1,k1) + xout(i1,j1,k1)
819 c*
820 c* *** evaluate residual of 1d system
821 zNN = AA * UU + DD * c_scal(BB,UU,ipkey) - FF
822 c*
823 c* *** setup for newton's method
824 niters = 0
825 zndenom = zNN
826 if (zndenom .eq. 0.0d0) zndenom = 1.0d0
827 znerror = zNN / zndenom
828 c*
829 c* *** the 1d newton's method ***
830 if (znerror .lt. zntol) goto 23
831 if (niters .gt. nitmax) goto 22
832 21 continue
833 niters = niters + 1
834 c*
835 c* *** construct jacobian matrix of NN ***
836 DzNN = AA + DD * dc_scal(BB,UU,ipkey)
837 c*
838 c* *** solve the linear system ***
839 change = - zNN / DzNN
840 c*
841 c* *** update the solution ***
842 UU = UU + change
843 c*
844 c* *** evaluate residual of 1d system ***
845 zNN = AA * UU + DD * c_scal(BB,UU,ipkey) - FF
846 c*
847 c* *** compute error ***
848 znerror = zNN / zndenom
849 c*
850 c* *** tolerance and itmax check ***
851 if (znerror .lt. zntol) goto 23
852 if (niters .gt. nitmax) goto 22
853 c*
854 c* *** loop ***
855 goto 21
856 c*
857 c* *** tolerance not reached ***
858 22 continue
859 ifail_tol = ifail_tol + 1
860 c*
861 c* *** tolerance reached ***
862 23 continue
863 c*
864 c* *** newton's method complete -- update solution value ***
865 xout(i1,j1,k1) = UU
866 c*
867 c* *********************************************************************
868 c* *** fine grid pts common only to x-z planes on coarse grid ***
869 c* *** (intermediate pts between 2 grid points on a y-row) ***
870 xout(i,j+1,k) = oPN(ii,jj,kk) * xin(ii,jj,kk)
871 2 + oPS(ii,jj+1,kk) * xin(ii,jj+1,kk)
872 i1 = i
873 j1 = j+1
874 k1 = k
875 c*
876 c* *** setup the 1d equation ***
877 DD = ( oC(i1,j1,k1)
878 2 - oE(i1,j1,k1)
879 3 - oE(max0(1,i1-1),j1,k1) * dble(min0(1,i1-1))
880 4 - uC(i1,j1,k1)
881 5 - uC(i1,j1,max0(1,k1-1)) * dble(min0(1,k1-1))
882 6 - uE(i1,j1,k1)
883 7 - uW(i1,j1,k1)
884 8 - uE(i1,j1,max0(1,k1-1)) * dble(min0(1,k1-1))
885 9 - uW(i1,j1,max0(1,k1-1)) * dble(min0(1,k1-1)) )
886 if (DD .eq. 0.0d0) then
887 DD = 1.0d0
888 else
889 DD = 1.0d0 / DD
890 endif
891 UU = xout(i1,j1,k1)
892 AA = 1.0d0
893 BB = cc(i1,j1,k1)
894 FF = key * fc(i1,j1,k1) + xout(i1,j1,k1)
895 c*
896 c* *** evaluate residual of 1d system
897 zNN = AA * UU + DD * c_scal(BB,UU,ipkey) - FF
898 c*
899 c* *** setup for newton's method
900 niters = 0
901 zndenom = zNN
902 if (zndenom .eq. 0.0d0) zndenom = 1.0d0
903 znerror = zNN / zndenom
904 c*
905 c* *** the 1d newton's method ***
906 if (znerror .lt. zntol) goto 33
907 if (niters .gt. nitmax) goto 32
908 31 continue
909 niters = niters + 1
910 c*
911 c* *** construct jacobian matrix of NN ***
912 DzNN = AA + DD * dc_scal(BB,UU,ipkey)
913 c*
914 c* *** solve the linear system ***
915 change = - zNN / DzNN
916 c*
917 c* *** update the solution ***
918 UU = UU + change
919 c*
920 c* *** evaluate residual of 1d system ***
921 zNN = AA * UU + DD * c_scal(BB,UU,ipkey) - FF
922 c*
923 c* *** compute error ***
924 znerror = zNN / zndenom
925 c*
926 c* *** tolerance and itmax check ***
927 if (znerror .lt. zntol) goto 33
928 if (niters .gt. nitmax) goto 32
929 c*
930 c* *** loop ***
931 goto 31
932 c*
933 c* *** tolerance not reached ***
934 32 continue
935 ifail_tol = ifail_tol + 1
936 c*
937 c* *** tolerance reached ***
938 33 continue
939 c*
940 c* *** newton's method complete -- update solution value ***
941 xout(i1,j1,k1) = UU
942 c*
943 c* *********************************************************************
944 c* *** fine grid pts common only to x-y planes on coarse grid ***
945 c* *** (intermediate pts between 2 grid points on a z-row) ***
946 xout(i,j,k+1) = uPC(ii,jj,kk) * xin(ii,jj,kk)
947 2 + dPC(ii,jj,kk+1) * xin(ii,jj,kk+1)
948 i1 = i
949 j1 = j
950 k1 = k+1
951 c*
952 c* *** setup the 1d equation ***
953 DD = ( oC(i1,j1,k1)
954 2 - oE(i1,j1,k1)
955 3 - oE(max0(1,i1-1),j1,k1) * dble(min0(1,i1-1))
956 4 - oN(i1,j1,k1)
957 5 - oN(i1,max0(1,j1-1),k1) * dble(min0(1,j1-1))
958 6 - oNE(i1,j1,k1)
959 7 - oNW(i1,j1,k1)
960 8 - oNE(i1-1,j1-1,k1) * dble(min0(1,i1-1))
961 8 * dble(min0(1,j1-1))
962 9 - oNW(i1+1,j1-1,k1) * dble(min0(1,j1-1)) )
963 if (DD .eq. 0.0d0) then
964 DD = 1.0d0
965 else
966 DD = 1.0d0 / DD
967 endif
968 UU = xout(i1,j1,k1)
969 AA = 1.0d0
970 BB = cc(i1,j1,k1)
971 FF = key * fc(i1,j1,k1) + xout(i1,j1,k1)
972 c*
973 c* *** evaluate residual of 1d system
974 zNN = AA * UU + DD * c_scal(BB,UU,ipkey) - FF
975 c*
976 c* *** setup for newton's method
977 niters = 0
978 zndenom = zNN
979 if (zndenom .eq. 0.0d0) zndenom = 1.0d0
980 znerror = zNN / zndenom
981 c*
982 c* *** the 1d newton's method ***
983 if (znerror .lt. zntol) goto 43
984 if (niters .gt. nitmax) goto 42
985 41 continue
986 niters = niters + 1
987 c*
988 c* *** construct jacobian matrix of NN ***
989 DzNN = AA + DD * dc_scal(BB,UU,ipkey)
990 c*
991 c* *** solve the linear system ***
992 change = - zNN / DzNN
993 c*
994 c* *** update the solution ***
995 UU = UU + change
996 c*
997 c* *** evaluate residual of 1d system ***
998 zNN = AA * UU + DD * c_scal(BB,UU,ipkey) - FF
999 c*
1000 c* *** compute error ***
1001 znerror = zNN / zndenom
1002 c*
1003 c* *** tolerance and itmax check ***
1004 if (znerror .lt. zntol) goto 43
1005 if (niters .gt. nitmax) goto 42
1006 c*
1007 c* *** loop ***
1008 goto 41
1009 c*
1010 c* *** tolerance not reached ***
1011 42 continue
1012 ifail_tol = ifail_tol + 1
1013 c*
1014 c* *** tolerance reached ***
1015 43 continue
1016 c*
1017 c* *** newton's method complete -- update solution value ***
1018 xout(i1,j1,k1) = UU
1019 c*
1020 c* *********************************************************************
1021 c* type 3 -- fine grid points common to a coarse grid line
1022 c* *********************************************************************
1023 c*
1024 c* *********************************************************************
1025 c* *** fine grid pts common only to z planes on coarse grid ***
1026 c* *** (intermediate pts between 4 grid pts on the xy-plane***
1027 xout(i+1,j+1,k) = oPNE(ii,jj,kk) * xin(ii,jj,kk)
1028 2 + oPNW(ii+1,jj,kk) * xin(ii+1,jj,kk)
1029 3 + oPSE(ii,jj+1,kk) * xin(ii,jj+1,kk)
1030 4 + oPSW(ii+1,jj+1,kk) * xin(ii+1,jj+1,kk)
1031 i1 = i+1
1032 j1 = j+1
1033 k1 = k
1034 c*
1035 c* *** setup the 1d equation ***
1036 DD = ( oC(i1,j1,k1)
1037 2 - uC(i1,j1,k1)
1038 3 - uC(i1,j1,max0(1,k1-1)) * dble(min0(1,k1-1)) )
1039 if (DD .eq. 0.0d0) then
1040 DD = 1.0d0
1041 else
1042 DD = 1.0d0 / DD
1043 endif
1044 UU = xout(i1,j1,k1)
1045 AA = 1.0d0
1046 BB = cc(i1,j1,k1)
1047 FF = key * fc(i1,j1,k1) + xout(i1,j1,k1)
1048 c*
1049 c* *** evaluate residual of 1d system
1050 zNN = AA * UU + DD * c_scal(BB,UU,ipkey) - FF
1051 c*
1052 c* *** setup for newton's method
1053 niters = 0
1054 zndenom = zNN
1055 if (zndenom .eq. 0.0d0) zndenom = 1.0d0
1056 znerror = zNN / zndenom
1057 c*
1058 c* *** the 1d newton's method ***
1059 if (znerror .lt. zntol) goto 53
1060 if (niters .gt. nitmax) goto 52
1061 51 continue
1062 niters = niters + 1
1063 c*
1064 c* *** construct jacobian matrix of NN ***
1065 DzNN = AA + DD * dc_scal(BB,UU,ipkey)
1066 c*
1067 c* *** solve the linear system ***
1068 change = - zNN / DzNN
1069 c*
1070 c* *** update the solution ***
1071 UU = UU + change
1072 c*
1073 c* *** evaluate residual of 1d system ***
1074 zNN = AA * UU + DD * c_scal(BB,UU,ipkey) - FF
1075 c*
1076 c* *** compute error ***
1077 znerror = zNN / zndenom
1078 c*
1079 c* *** tolerance and itmax check ***
1080 if (znerror .lt. zntol) goto 53
1081 if (niters .gt. nitmax) goto 52
1082 c*
1083 c* *** loop ***
1084 goto 51
1085 c*
1086 c* *** tolerance not reached ***
1087 52 continue
1088 ifail_tol = ifail_tol + 1
1089 c*
1090 c* *** tolerance reached ***
1091 53 continue
1092 c*
1093 c* *** newton's method complete -- update solution value ***
1094 xout(i1,j1,k1) = UU
1095 c*
1096 c* *********************************************************************
1097 c* *** fine grid pts common only to y planes on coarse grid ***
1098 c* *** (intermediate pts between 4 grid pts on the xz-plane***
1099 xout(i+1,j,k+1) = uPE(ii,jj,kk) * xin(ii,jj,kk)
1100 2 + uPW(ii+1,jj,kk) * xin(ii+1,jj,kk)
1101 3 + dPE(ii,jj,kk+1) * xin(ii,jj,kk+1)
1102 4 + dPW(ii+1,jj,kk+1) * xin(ii+1,jj,kk+1)
1103 i1 = i+1
1104 j1 = j
1105 k1 = k+1
1106 c*
1107 c* *** setup the 1d equation ***
1108 DD = ( oC(i1,j1,k1)
1109 2 - oN(i1,j1,k1)
1110 3 - oN(i1,max0(1,j1-1),k1) * dble(min0(1,j1-1)) )
1111 if (DD .eq. 0.0d0) then
1112 DD = 1.0d0
1113 else
1114 DD = 1.0d0 / DD
1115 endif
1116 UU = xout(i1,j1,k1)
1117 AA = 1.0d0
1118 BB = cc(i1,j1,k1)
1119 FF = key * fc(i1,j1,k1) + xout(i1,j1,k1)
1120 c*
1121 c* *** evaluate residual of 1d system
1122 zNN = AA * UU + DD * c_scal(BB,UU,ipkey) - FF
1123 c*
1124 c* *** setup for newton's method
1125 niters = 0
1126 zndenom = zNN
1127 if (zndenom .eq. 0.0d0) zndenom = 1.0d0
1128 znerror = zNN / zndenom
1129 c*
1130 c* *** the 1d newton's method ***
1131 if (znerror .lt. zntol) goto 63
1132 if (niters .gt. nitmax) goto 62
1133 61 continue
1134 niters = niters + 1
1135 c*
1136 c* *** construct jacobian matrix of NN ***
1137 DzNN = AA + DD * dc_scal(BB,UU,ipkey)
1138 c*
1139 c* *** solve the linear system ***
1140 change = - zNN / DzNN
1141 c*
1142 c* *** update the solution ***
1143 UU = UU + change
1144 c*
1145 c* *** evaluate residual of 1d system ***
1146 zNN = AA * UU + DD * c_scal(BB,UU,ipkey) - FF
1147 c*
1148 c* *** compute error ***
1149 znerror = zNN / zndenom
1150 c*
1151 c* *** tolerance and itmax check ***
1152 if (znerror .lt. zntol) goto 63
1153 if (niters .gt. nitmax) goto 62
1154 c*
1155 c* *** loop ***
1156 goto 61
1157 c*
1158 c* *** tolerance not reached ***
1159 62 continue
1160 ifail_tol = ifail_tol + 1
1161 c*
1162 c* *** tolerance reached ***
1163 63 continue
1164 c*
1165 c* *** newton's method complete -- update solution value ***
1166 xout(i1,j1,k1) = UU
1167 c*
1168 c* *********************************************************************
1169 c* *** fine grid pts common only to x planes on coarse grid ***
1170 c* *** (intermediate pts between 4 grid pts on the yz-plane***
1171 xout(i,j+1,k+1) = uPN(ii,jj,kk) * xin(ii,jj,kk)
1172 2 + uPS(ii,jj+1,kk) * xin(ii,jj+1,kk)
1173 3 + dPN(ii,jj,kk+1) * xin(ii,jj,kk+1)
1174 4 + dPS(ii,jj+1,kk+1) * xin(ii,jj+1,kk+1)
1175 i1 = i
1176 j1 = j+1
1177 k1 = k+1
1178 c*
1179 c* *** setup the 1d equation ***
1180 DD = ( oC(i1,j1,k1)
1181 2 - oE(i1,j1,k1)
1182 3 - oE(max0(1,i1-1),j1,k1) * dble(min0(1,i1-1)) )
1183 if (DD .eq. 0.0d0) then
1184 DD = 1.0d0
1185 else
1186 DD = 1.0d0 / DD
1187 endif
1188 UU = xout(i1,j1,k1)
1189 AA = 1.0d0
1190 BB = cc(i1,j1,k1)
1191 FF = key * fc(i1,j1,k1) + xout(i1,j1,k1)
1192 c*
1193 c* *** evaluate residual of 1d system
1194 zNN = AA * UU + DD * c_scal(BB,UU,ipkey) - FF
1195 c*
1196 c* *** setup for newton's method
1197 niters = 0
1198 zndenom = zNN
1199 if (zndenom .eq. 0.0d0) zndenom = 1.0d0
1200 znerror = zNN / zndenom
1201 c*
1202 c* *** the 1d newton's method ***
1203 if (znerror .lt. zntol) goto 73
1204 if (niters .gt. nitmax) goto 72
1205 71 continue
1206 niters = niters + 1
1207 c*
1208 c* *** construct jacobian matrix of NN ***
1209 DzNN = AA + DD * dc_scal(BB,UU,ipkey)
1210 c*
1211 c* *** solve the linear system ***
1212 change = - zNN / DzNN
1213 c*
1214 c* *** update the solution ***
1215 UU = UU + change
1216 c*
1217 c* *** evaluate residual of 1d system ***
1218 zNN = AA * UU + DD * c_scal(BB,UU,ipkey) - FF
1219 c*
1220 c* *** compute error ***
1221 znerror = zNN / zndenom
1222 c*
1223 c* *** tolerance and itmax check ***
1224 if (znerror .lt. zntol) goto 73
1225 if (niters .gt. nitmax) goto 72
1226 c*
1227 c* *** loop ***
1228 goto 71
1229 c*
1230 c* *** tolerance not reached ***
1231 72 continue
1232 ifail_tol = ifail_tol + 1
1233 c*
1234 c* *** tolerance reached ***
1235 73 continue
1236 c*
1237 c* *** newton's method complete -- update solution value ***
1238 xout(i1,j1,k1) = UU
1239 c*
1240 c* *********************************************************************
1241 c* type 4 -- fine grid points not common to coarse grid pts/lines/planes
1242 c* *********************************************************************
1243 c*
1244 c* *** completely interior points ***
1245 xout(i+1,j+1,k+1) =
1246 2 + uPNE(ii,jj,kk) * xin(ii,jj,kk)
1247 3 + uPNW(ii+1,jj,kk) * xin(ii+1,jj,kk)
1248 4 + uPSE(ii,jj+1,kk) * xin(ii,jj+1,kk)
1249 5 + uPSW(ii+1,jj+1,kk) * xin(ii+1,jj+1,kk)
1250 6 + dPNE(ii,jj,kk+1) * xin(ii,jj,kk+1)
1251 7 + dPNW(ii+1,jj,kk+1) * xin(ii+1,jj,kk+1)
1252 8 + dPSE(ii,jj+1,kk+1) * xin(ii,jj+1,kk+1)
1253 9 + dPSW(ii+1,jj+1,kk+1) * xin(ii+1,jj+1,kk+1)
1254 i1 = i+1
1255 j1 = j+1
1256 k1 = k+1
1257 c*
1258 c* *** setup the 1d equation ***
1259 DD = oC(i1,j1,k1)
1260 if (DD .eq. 0.0d0) then
1261 DD = 1.0d0
1262 else
1263 DD = 1.0d0 / DD
1264 endif
1265 UU = xout(i1,j1,k1)
1266 AA = 1.0d0
1267 BB = cc(i1,j1,k1)
1268 FF = key * fc(i1,j1,k1) + xout(i1,j1,k1)
1269 c*
1270 c* *** evaluate residual of 1d system
1271 zNN = AA * UU + DD * c_scal(BB,UU,ipkey) - FF
1272 c*
1273 c* *** setup for newton's method
1274 niters = 0
1275 zndenom = zNN
1276 if (zndenom .eq. 0.0d0) zndenom = 1.0d0
1277 znerror = zNN / zndenom
1278 c*
1279 c* *** the 1d newton's method ***
1280 if (znerror .lt. zntol) goto 83
1281 if (niters .gt. nitmax) goto 82
1282 81 continue
1283 niters = niters + 1
1284 c*
1285 c* *** construct jacobian matrix of NN ***
1286 DzNN = AA + DD * dc_scal(BB,UU,ipkey)
1287 c*
1288 c* *** solve the linear system ***
1289 change = - zNN / DzNN
1290 c*
1291 c* *** update the solution ***
1292 UU = UU + change
1293 c*
1294 c* *** evaluate residual of 1d system ***
1295 zNN = AA * UU + DD * c_scal(BB,UU,ipkey) - FF
1296 c*
1297 c* *** compute error ***
1298 znerror = zNN / zndenom
1299 c*
1300 c* *** tolerance and itmax check ***
1301 if (znerror .lt. zntol) goto 83
1302 if (niters .gt. nitmax) goto 82
1303 c*
1304 c* *** loop ***
1305 goto 81
1306 c*
1307 c* *** tolerance not reached ***
1308 82 continue
1309 ifail_tol = ifail_tol + 1
1310 c*
1311 c* *** tolerance reached ***
1312 83 continue
1313 c*
1314 c* *** newton's method complete -- update solution value ***
1315 xout(i1,j1,k1) = UU
1316 c*
1317 c* *** main loop ***
1318 12 continue
1319 11 continue
1320 10 continue
1321 c*
1322 c* *** verify correctness of the output boundary points ***
1323 call fbound00(nxf,nyf,nzf,xout)
1324 c*
1325 c* *** messages ***
1326 if (ifail_tol .gt. 0) then
1327 print*,'% NINTERP27: 1d newton tolerance failures: ',ifail_tol
1328 endif
1329 c*
1330 c* *** return and end ***
1331 return
1332 end
1333