hw3crt.f 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627
  1. *DECK HW3CRT
  2. SUBROUTINE HW3CRT (XS, XF, L, LBDCND, BDXS, BDXF, YS, YF, M,
  3. + MBDCND, BDYS, BDYF, ZS, ZF, N, NBDCND, BDZS, BDZF, ELMBDA,
  4. + LDIMF, MDIMF, F, PERTRB, IERROR, W)
  5. C***BEGIN PROLOGUE HW3CRT
  6. C***PURPOSE Solve the standard seven-point finite difference
  7. C approximation to the Helmholtz equation in Cartesian
  8. C coordinates.
  9. C***LIBRARY SLATEC (FISHPACK)
  10. C***CATEGORY I2B1A1A
  11. C***TYPE SINGLE PRECISION (HW3CRT-S)
  12. C***KEYWORDS CARTESIAN, ELLIPTIC, FISHPACK, HELMHOLTZ, PDE
  13. C***AUTHOR Adams, J., (NCAR)
  14. C Swarztrauber, P. N., (NCAR)
  15. C Sweet, R., (NCAR)
  16. C***DESCRIPTION
  17. C
  18. C Subroutine HW3CRT solves the standard seven-point finite
  19. C difference approximation to the Helmholtz equation in Cartesian
  20. C coordinates:
  21. C
  22. C (d/dX)(dU/dX) + (d/dY)(dU/dY) + (d/dZ)(dU/dZ)
  23. C
  24. C + LAMBDA*U = F(X,Y,Z) .
  25. C
  26. C * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  27. C
  28. C
  29. C * * * * * * * * Parameter Description * * * * * * * * * *
  30. C
  31. C
  32. C * * * * * * On Input * * * * * *
  33. C
  34. C XS,XF
  35. C The range of X, i.e. XS .LE. X .LE. XF .
  36. C XS must be less than XF.
  37. C
  38. C L
  39. C The number of panels into which the interval (XS,XF) is
  40. C subdivided. Hence, there will be L+1 grid points in the
  41. C X-direction given by X(I) = XS+(I-1)DX for I=1,2,...,L+1,
  42. C where DX = (XF-XS)/L is the panel width. L must be at
  43. C least 5 .
  44. C
  45. C LBDCND
  46. C Indicates the type of boundary conditions at X = XS and X = XF.
  47. C
  48. C = 0 If the solution is periodic in X, i.e.
  49. C U(L+I,J,K) = U(I,J,K).
  50. C = 1 If the solution is specified at X = XS and X = XF.
  51. C = 2 If the solution is specified at X = XS and the derivative
  52. C of the solution with respect to X is specified at X = XF.
  53. C = 3 If the derivative of the solution with respect to X is
  54. C specified at X = XS and X = XF.
  55. C = 4 If the derivative of the solution with respect to X is
  56. C specified at X = XS and the solution is specified at X=XF.
  57. C
  58. C BDXS
  59. C A two-dimensional array that specifies the values of the
  60. C derivative of the solution with respect to X at X = XS.
  61. C when LBDCND = 3 or 4,
  62. C
  63. C BDXS(J,K) = (d/dX)U(XS,Y(J),Z(K)), J=1,2,...,M+1,
  64. C K=1,2,...,N+1.
  65. C
  66. C When LBDCND has any other value, BDXS is a dummy variable.
  67. C BDXS must be dimensioned at least (M+1)*(N+1).
  68. C
  69. C BDXF
  70. C A two-dimensional array that specifies the values of the
  71. C derivative of the solution with respect to X at X = XF.
  72. C When LBDCND = 2 or 3,
  73. C
  74. C BDXF(J,K) = (d/dX)U(XF,Y(J),Z(K)), J=1,2,...,M+1,
  75. C K=1,2,...,N+1.
  76. C
  77. C When LBDCND has any other value, BDXF is a dummy variable.
  78. C BDXF must be dimensioned at least (M+1)*(N+1).
  79. C
  80. C YS,YF
  81. C The range of Y, i.e. YS .LE. Y .LE. YF.
  82. C YS must be less than YF.
  83. C
  84. C M
  85. C The number of panels into which the interval (YS,YF) is
  86. C subdivided. Hence, there will be M+1 grid points in the
  87. C Y-direction given by Y(J) = YS+(J-1)DY for J=1,2,...,M+1,
  88. C where DY = (YF-YS)/M is the panel width. M must be at
  89. C least 5 .
  90. C
  91. C MBDCND
  92. C Indicates the type of boundary conditions at Y = YS and Y = YF.
  93. C
  94. C = 0 If the solution is periodic in Y, i.e.
  95. C U(I,M+J,K) = U(I,J,K).
  96. C = 1 If the solution is specified at Y = YS and Y = YF.
  97. C = 2 If the solution is specified at Y = YS and the derivative
  98. C of the solution with respect to Y is specified at Y = YF.
  99. C = 3 If the derivative of the solution with respect to Y is
  100. C specified at Y = YS and Y = YF.
  101. C = 4 If the derivative of the solution with respect to Y is
  102. C specified at Y = YS and the solution is specified at Y=YF.
  103. C
  104. C BDYS
  105. C A two-dimensional array that specifies the values of the
  106. C derivative of the solution with respect to Y at Y = YS.
  107. C When MBDCND = 3 or 4,
  108. C
  109. C BDYS(I,K) = (d/dY)U(X(I),YS,Z(K)), I=1,2,...,L+1,
  110. C K=1,2,...,N+1.
  111. C
  112. C When MBDCND has any other value, BDYS is a dummy variable.
  113. C BDYS must be dimensioned at least (L+1)*(N+1).
  114. C
  115. C BDYF
  116. C A two-dimensional array that specifies the values of the
  117. C derivative of the solution with respect to Y at Y = YF.
  118. C When MBDCND = 2 or 3,
  119. C
  120. C BDYF(I,K) = (d/dY)U(X(I),YF,Z(K)), I=1,2,...,L+1,
  121. C K=1,2,...,N+1.
  122. C
  123. C When MBDCND has any other value, BDYF is a dummy variable.
  124. C BDYF must be dimensioned at least (L+1)*(N+1).
  125. C
  126. C ZS,ZF
  127. C The range of Z, i.e. ZS .LE. Z .LE. ZF.
  128. C ZS must be less than ZF.
  129. C
  130. C N
  131. C The number of panels into which the interval (ZS,ZF) is
  132. C subdivided. Hence, there will be N+1 grid points in the
  133. C Z-direction given by Z(K) = ZS+(K-1)DZ for K=1,2,...,N+1,
  134. C where DZ = (ZF-ZS)/N is the panel width. N must be at least 5.
  135. C
  136. C NBDCND
  137. C Indicates the type of boundary conditions at Z = ZS and Z = ZF.
  138. C
  139. C = 0 If the solution is periodic in Z, i.e.
  140. C U(I,J,N+K) = U(I,J,K).
  141. C = 1 If the solution is specified at Z = ZS and Z = ZF.
  142. C = 2 If the solution is specified at Z = ZS and the derivative
  143. C of the solution with respect to Z is specified at Z = ZF.
  144. C = 3 If the derivative of the solution with respect to Z is
  145. C specified at Z = ZS and Z = ZF.
  146. C = 4 If the derivative of the solution with respect to Z is
  147. C specified at Z = ZS and the solution is specified at Z=ZF.
  148. C
  149. C BDZS
  150. C A two-dimensional array that specifies the values of the
  151. C derivative of the solution with respect to Z at Z = ZS.
  152. C When NBDCND = 3 or 4,
  153. C
  154. C BDZS(I,J) = (d/dZ)U(X(I),Y(J),ZS), I=1,2,...,L+1,
  155. C J=1,2,...,M+1.
  156. C
  157. C When NBDCND has any other value, BDZS is a dummy variable.
  158. C BDZS must be dimensioned at least (L+1)*(M+1).
  159. C
  160. C BDZF
  161. C A two-dimensional array that specifies the values of the
  162. C derivative of the solution with respect to Z at Z = ZF.
  163. C When NBDCND = 2 or 3,
  164. C
  165. C BDZF(I,J) = (d/dZ)U(X(I),Y(J),ZF), I=1,2,...,L+1,
  166. C J=1,2,...,M+1.
  167. C
  168. C When NBDCND has any other value, BDZF is a dummy variable.
  169. C BDZF must be dimensioned at least (L+1)*(M+1).
  170. C
  171. C ELMBDA
  172. C The constant LAMBDA in the Helmholtz equation. If
  173. C LAMBDA .GT. 0, a solution may not exist. However, HW3CRT will
  174. C attempt to find a solution.
  175. C
  176. C F
  177. C A three-dimensional array that specifies the values of the
  178. C right side of the Helmholtz equation and boundary values (if
  179. C any). For I=2,3,...,L, J=2,3,...,M, and K=2,3,...,N
  180. C
  181. C F(I,J,K) = F(X(I),Y(J),Z(K)).
  182. C
  183. C On the boundaries F is defined by
  184. C
  185. C LBDCND F(1,J,K) F(L+1,J,K)
  186. C ------ --------------- ---------------
  187. C
  188. C 0 F(XS,Y(J),Z(K)) F(XS,Y(J),Z(K))
  189. C 1 U(XS,Y(J),Z(K)) U(XF,Y(J),Z(K))
  190. C 2 U(XS,Y(J),Z(K)) F(XF,Y(J),Z(K)) J=1,2,...,M+1
  191. C 3 F(XS,Y(J),Z(K)) F(XF,Y(J),Z(K)) K=1,2,...,N+1
  192. C 4 F(XS,Y(J),Z(K)) U(XF,Y(J),Z(K))
  193. C
  194. C MBDCND F(I,1,K) F(I,M+1,K)
  195. C ------ --------------- ---------------
  196. C
  197. C 0 F(X(I),YS,Z(K)) F(X(I),YS,Z(K))
  198. C 1 U(X(I),YS,Z(K)) U(X(I),YF,Z(K))
  199. C 2 U(X(I),YS,Z(K)) F(X(I),YF,Z(K)) I=1,2,...,L+1
  200. C 3 F(X(I),YS,Z(K)) F(X(I),YF,Z(K)) K=1,2,...,N+1
  201. C 4 F(X(I),YS,Z(K)) U(X(I),YF,Z(K))
  202. C
  203. C NBDCND F(I,J,1) F(I,J,N+1)
  204. C ------ --------------- ---------------
  205. C
  206. C 0 F(X(I),Y(J),ZS) F(X(I),Y(J),ZS)
  207. C 1 U(X(I),Y(J),ZS) U(X(I),Y(J),ZF)
  208. C 2 U(X(I),Y(J),ZS) F(X(I),Y(J),ZF) I=1,2,...,L+1
  209. C 3 F(X(I),Y(J),ZS) F(X(I),Y(J),ZF) J=1,2,...,M+1
  210. C 4 F(X(I),Y(J),ZS) U(X(I),Y(J),ZF)
  211. C
  212. C F must be dimensioned at least (L+1)*(M+1)*(N+1).
  213. C
  214. C NOTE:
  215. C
  216. C If the table calls for both the solution U and the right side F
  217. C on a boundary, then the solution must be specified.
  218. C
  219. C LDIMF
  220. C The row (or first) dimension of the arrays F,BDYS,BDYF,BDZS,
  221. C and BDZF as it appears in the program calling HW3CRT. this
  222. C parameter is used to specify the variable dimension of these
  223. C arrays. LDIMF must be at least L+1.
  224. C
  225. C MDIMF
  226. C The column (or second) dimension of the array F and the row (or
  227. C first) dimension of the arrays BDXS and BDXF as it appears in
  228. C the program calling HW3CRT. This parameter is used to specify
  229. C the variable dimension of these arrays.
  230. C MDIMF must be at least M+1.
  231. C
  232. C W
  233. C A one-dimensional array that must be provided by the user for
  234. C work space. The length of W must be at least 30 + L + M + 5*N
  235. C + MAX(L,M,N) + 7*(INT((L+1)/2) + INT((M+1)/2))
  236. C
  237. C
  238. C * * * * * * On Output * * * * * *
  239. C
  240. C F
  241. C Contains the solution U(I,J,K) of the finite difference
  242. C approximation for the grid point (X(I),Y(J),Z(K)) for
  243. C I=1,2,...,L+1, J=1,2,...,M+1, and K=1,2,...,N+1.
  244. C
  245. C PERTRB
  246. C If a combination of periodic or derivative boundary conditions
  247. C is specified for a Poisson equation (LAMBDA = 0), a solution
  248. C may not exist. PERTRB is a constant, calculated and subtracted
  249. C from F, which ensures that a solution exists. PWSCRT then
  250. C computes this solution, which is a least squares solution to
  251. C the original approximation. This solution is not unique and is
  252. C unnormalized. The value of PERTRB should be small compared to
  253. C the right side F. Otherwise, a solution is obtained to an
  254. C essentially different problem. This comparison should always
  255. C be made to insure that a meaningful solution has been obtained.
  256. C
  257. C IERROR
  258. C An error flag that indicates invalid input parameters. Except
  259. C for numbers 0 and 12, a solution is not attempted.
  260. C
  261. C = 0 No error
  262. C = 1 XS .GE. XF
  263. C = 2 L .LT. 5
  264. C = 3 LBDCND .LT. 0 .OR. LBDCND .GT. 4
  265. C = 4 YS .GE. YF
  266. C = 5 M .LT. 5
  267. C = 6 MBDCND .LT. 0 .OR. MBDCND .GT. 4
  268. C = 7 ZS .GE. ZF
  269. C = 8 N .LT. 5
  270. C = 9 NBDCND .LT. 0 .OR. NBDCND .GT. 4
  271. C = 10 LDIMF .LT. L+1
  272. C = 11 MDIMF .LT. M+1
  273. C = 12 LAMBDA .GT. 0
  274. C
  275. C Since this is the only means of indicating a possibly incorrect
  276. C call to HW3CRT, the user should test IERROR after the call.
  277. C
  278. C *Long Description:
  279. C
  280. C * * * * * * * Program Specifications * * * * * * * * * * * *
  281. C
  282. C Dimension of BDXS(MDIMF,N+1),BDXF(MDIMF,N+1),BDYS(LDIMF,N+1),
  283. C Arguments BDYF(LDIMF,N+1),BDZS(LDIMF,M+1),BDZF(LDIMF,M+1),
  284. C F(LDIMF,MDIMF,N+1),W(see argument list)
  285. C
  286. C Latest December 1, 1978
  287. C Revision
  288. C
  289. C Subprograms HW3CRT,POIS3D,POS3D1,TRIDQ,RFFTI,RFFTF,RFFTF1,
  290. C Required RFFTB,RFFTB1,COSTI,COST,SINTI,SINT,COSQI,COSQF,
  291. C COSQF1,COSQB,COSQB1,SINQI,SINQF,SINQB,CFFTI,
  292. C CFFTI1,CFFTB,CFFTB1,PASSB2,PASSB3,PASSB4,PASSB,
  293. C CFFTF,CFFTF1,PASSF1,PASSF2,PASSF3,PASSF4,PASSF,
  294. C PIMACH
  295. C
  296. C Special NONE
  297. C Conditions
  298. C
  299. C Common NONE
  300. C Blocks
  301. C
  302. C I/O NONE
  303. C
  304. C Precision Single
  305. C
  306. C Specialist Roland Sweet
  307. C
  308. C Language FORTRAN
  309. C
  310. C History Written by Roland Sweet at NCAR in July 1977
  311. C
  312. C Algorithm This subroutine defines the finite difference
  313. C equations, incorporates boundary data, and
  314. C adjusts the right side of singular systems and
  315. C then calls POIS3D to solve the system.
  316. C
  317. C Space 7862(decimal) = 17300(octal) locations on the
  318. C Required NCAR Control Data 7600
  319. C
  320. C Timing and The execution time T on the NCAR Control Data
  321. C Accuracy 7600 for subroutine HW3CRT is roughly proportional
  322. C to L*M*N*(log2(L)+log2(M)+5), but also depends on
  323. C input parameters LBDCND and MBDCND. Some typical
  324. C values are listed in the table below.
  325. C The solution process employed results in a loss
  326. C of no more than three significant digits for L,M
  327. C and N as large as 32. More detailed information
  328. C about accuracy can be found in the documentation
  329. C for subroutine POIS3D which is the routine that
  330. C actually solves the finite difference equations.
  331. C
  332. C
  333. C L(=M=N) LBDCND(=MBDCND=NBDCND) T(MSECS)
  334. C ------- ---------------------- --------
  335. C
  336. C 16 0 300
  337. C 16 1 302
  338. C 16 3 348
  339. C 32 0 1925
  340. C 32 1 1929
  341. C 32 3 2109
  342. C
  343. C Portability American National Standards Institute FORTRAN.
  344. C The machine dependent constant PI is defined in
  345. C function PIMACH.
  346. C
  347. C Required COS,SIN,ATAN
  348. C Resident
  349. C Routines
  350. C
  351. C Reference NONE
  352. C
  353. C * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  354. C
  355. C***REFERENCES (NONE)
  356. C***ROUTINES CALLED POIS3D
  357. C***REVISION HISTORY (YYMMDD)
  358. C 801001 DATE WRITTEN
  359. C 890531 Changed all specific intrinsics to generic. (WRB)
  360. C 890531 REVISION DATE from Version 3.2
  361. C 891214 Prologue converted to Version 4.0 format. (BAB)
  362. C***END PROLOGUE HW3CRT
  363. C
  364. C
  365. DIMENSION BDXS(MDIMF,*) ,BDXF(MDIMF,*) ,
  366. 1 BDYS(LDIMF,*) ,BDYF(LDIMF,*) ,
  367. 2 BDZS(LDIMF,*) ,BDZF(LDIMF,*) ,
  368. 3 F(LDIMF,MDIMF,*) ,W(*)
  369. C***FIRST EXECUTABLE STATEMENT HW3CRT
  370. IERROR = 0
  371. IF (XF .LE. XS) IERROR = 1
  372. IF (L .LT. 5) IERROR = 2
  373. IF (LBDCND.LT.0 .OR. LBDCND.GT.4) IERROR = 3
  374. IF (YF .LE. YS) IERROR = 4
  375. IF (M .LT. 5) IERROR = 5
  376. IF (MBDCND.LT.0 .OR. MBDCND.GT.4) IERROR = 6
  377. IF (ZF .LE. ZS) IERROR = 7
  378. IF (N .LT. 5) IERROR = 8
  379. IF (NBDCND.LT.0 .OR. NBDCND.GT.4) IERROR = 9
  380. IF (LDIMF .LT. L+1) IERROR = 10
  381. IF (MDIMF .LT. M+1) IERROR = 11
  382. IF (IERROR .NE. 0) GO TO 188
  383. DY = (YF-YS)/M
  384. TWBYDY = 2./DY
  385. C2 = 1./(DY**2)
  386. MSTART = 1
  387. MSTOP = M
  388. MP1 = M+1
  389. MP = MBDCND+1
  390. GO TO (104,101,101,102,102),MP
  391. 101 MSTART = 2
  392. 102 GO TO (104,104,103,103,104),MP
  393. 103 MSTOP = MP1
  394. 104 MUNK = MSTOP-MSTART+1
  395. DZ = (ZF-ZS)/N
  396. TWBYDZ = 2./DZ
  397. NP = NBDCND+1
  398. C3 = 1./(DZ**2)
  399. NP1 = N+1
  400. NSTART = 1
  401. NSTOP = N
  402. GO TO (108,105,105,106,106),NP
  403. 105 NSTART = 2
  404. 106 GO TO (108,108,107,107,108),NP
  405. 107 NSTOP = NP1
  406. 108 NUNK = NSTOP-NSTART+1
  407. LP1 = L+1
  408. DX = (XF-XS)/L
  409. C1 = 1./(DX**2)
  410. TWBYDX = 2./DX
  411. LP = LBDCND+1
  412. LSTART = 1
  413. LSTOP = L
  414. C
  415. C ENTER BOUNDARY DATA FOR X-BOUNDARIES.
  416. C
  417. GO TO (122,109,109,112,112),LP
  418. 109 LSTART = 2
  419. DO 111 J=MSTART,MSTOP
  420. DO 110 K=NSTART,NSTOP
  421. F(2,J,K) = F(2,J,K)-C1*F(1,J,K)
  422. 110 CONTINUE
  423. 111 CONTINUE
  424. GO TO 115
  425. 112 DO 114 J=MSTART,MSTOP
  426. DO 113 K=NSTART,NSTOP
  427. F(1,J,K) = F(1,J,K)+TWBYDX*BDXS(J,K)
  428. 113 CONTINUE
  429. 114 CONTINUE
  430. 115 GO TO (122,116,119,119,116),LP
  431. 116 DO 118 J=MSTART,MSTOP
  432. DO 117 K=NSTART,NSTOP
  433. F(L,J,K) = F(L,J,K)-C1*F(LP1,J,K)
  434. 117 CONTINUE
  435. 118 CONTINUE
  436. GO TO 122
  437. 119 LSTOP = LP1
  438. DO 121 J=MSTART,MSTOP
  439. DO 120 K=NSTART,NSTOP
  440. F(LP1,J,K) = F(LP1,J,K)-TWBYDX*BDXF(J,K)
  441. 120 CONTINUE
  442. 121 CONTINUE
  443. 122 LUNK = LSTOP-LSTART+1
  444. C
  445. C ENTER BOUNDARY DATA FOR Y-BOUNDARIES.
  446. C
  447. GO TO (136,123,123,126,126),MP
  448. 123 DO 125 I=LSTART,LSTOP
  449. DO 124 K=NSTART,NSTOP
  450. F(I,2,K) = F(I,2,K)-C2*F(I,1,K)
  451. 124 CONTINUE
  452. 125 CONTINUE
  453. GO TO 129
  454. 126 DO 128 I=LSTART,LSTOP
  455. DO 127 K=NSTART,NSTOP
  456. F(I,1,K) = F(I,1,K)+TWBYDY*BDYS(I,K)
  457. 127 CONTINUE
  458. 128 CONTINUE
  459. 129 GO TO (136,130,133,133,130),MP
  460. 130 DO 132 I=LSTART,LSTOP
  461. DO 131 K=NSTART,NSTOP
  462. F(I,M,K) = F(I,M,K)-C2*F(I,MP1,K)
  463. 131 CONTINUE
  464. 132 CONTINUE
  465. GO TO 136
  466. 133 DO 135 I=LSTART,LSTOP
  467. DO 134 K=NSTART,NSTOP
  468. F(I,MP1,K) = F(I,MP1,K)-TWBYDY*BDYF(I,K)
  469. 134 CONTINUE
  470. 135 CONTINUE
  471. 136 CONTINUE
  472. C
  473. C ENTER BOUNDARY DATA FOR Z-BOUNDARIES.
  474. C
  475. GO TO (150,137,137,140,140),NP
  476. 137 DO 139 I=LSTART,LSTOP
  477. DO 138 J=MSTART,MSTOP
  478. F(I,J,2) = F(I,J,2)-C3*F(I,J,1)
  479. 138 CONTINUE
  480. 139 CONTINUE
  481. GO TO 143
  482. 140 DO 142 I=LSTART,LSTOP
  483. DO 141 J=MSTART,MSTOP
  484. F(I,J,1) = F(I,J,1)+TWBYDZ*BDZS(I,J)
  485. 141 CONTINUE
  486. 142 CONTINUE
  487. 143 GO TO (150,144,147,147,144),NP
  488. 144 DO 146 I=LSTART,LSTOP
  489. DO 145 J=MSTART,MSTOP
  490. F(I,J,N) = F(I,J,N)-C3*F(I,J,NP1)
  491. 145 CONTINUE
  492. 146 CONTINUE
  493. GO TO 150
  494. 147 DO 149 I=LSTART,LSTOP
  495. DO 148 J=MSTART,MSTOP
  496. F(I,J,NP1) = F(I,J,NP1)-TWBYDZ*BDZF(I,J)
  497. 148 CONTINUE
  498. 149 CONTINUE
  499. C
  500. C DEFINE A,B,C COEFFICIENTS IN W-ARRAY.
  501. C
  502. 150 CONTINUE
  503. IWB = NUNK+1
  504. IWC = IWB+NUNK
  505. IWW = IWC+NUNK
  506. DO 151 K=1,NUNK
  507. I = IWC+K-1
  508. W(K) = C3
  509. W(I) = C3
  510. I = IWB+K-1
  511. W(I) = -2.*C3+ELMBDA
  512. 151 CONTINUE
  513. GO TO (155,155,153,152,152),NP
  514. 152 W(IWC) = 2.*C3
  515. 153 GO TO (155,155,154,154,155),NP
  516. 154 W(IWB-1) = 2.*C3
  517. 155 CONTINUE
  518. PERTRB = 0.
  519. C
  520. C FOR SINGULAR PROBLEMS ADJUST DATA TO INSURE A SOLUTION WILL EXIST.
  521. C
  522. GO TO (156,172,172,156,172),LP
  523. 156 GO TO (157,172,172,157,172),MP
  524. 157 GO TO (158,172,172,158,172),NP
  525. 158 IF (ELMBDA) 172,160,159
  526. 159 IERROR = 12
  527. GO TO 172
  528. 160 CONTINUE
  529. MSTPM1 = MSTOP-1
  530. LSTPM1 = LSTOP-1
  531. NSTPM1 = NSTOP-1
  532. XLP = (2+LP)/3
  533. YLP = (2+MP)/3
  534. ZLP = (2+NP)/3
  535. S1 = 0.
  536. DO 164 K=2,NSTPM1
  537. DO 162 J=2,MSTPM1
  538. DO 161 I=2,LSTPM1
  539. S1 = S1+F(I,J,K)
  540. 161 CONTINUE
  541. S1 = S1+(F(1,J,K)+F(LSTOP,J,K))/XLP
  542. 162 CONTINUE
  543. S2 = 0.
  544. DO 163 I=2,LSTPM1
  545. S2 = S2+F(I,1,K)+F(I,MSTOP,K)
  546. 163 CONTINUE
  547. S2 = (S2+(F(1,1,K)+F(1,MSTOP,K)+F(LSTOP,1,K)+F(LSTOP,MSTOP,K))/
  548. 1 XLP)/YLP
  549. S1 = S1+S2
  550. 164 CONTINUE
  551. S = (F(1,1,1)+F(LSTOP,1,1)+F(1,1,NSTOP)+F(LSTOP,1,NSTOP)+
  552. 1 F(1,MSTOP,1)+F(LSTOP,MSTOP,1)+F(1,MSTOP,NSTOP)+
  553. 2 F(LSTOP,MSTOP,NSTOP))/(XLP*YLP)
  554. DO 166 J=2,MSTPM1
  555. DO 165 I=2,LSTPM1
  556. S = S+F(I,J,1)+F(I,J,NSTOP)
  557. 165 CONTINUE
  558. 166 CONTINUE
  559. S2 = 0.
  560. DO 167 I=2,LSTPM1
  561. S2 = S2+F(I,1,1)+F(I,1,NSTOP)+F(I,MSTOP,1)+F(I,MSTOP,NSTOP)
  562. 167 CONTINUE
  563. S = S2/YLP+S
  564. S2 = 0.
  565. DO 168 J=2,MSTPM1
  566. S2 = S2+F(1,J,1)+F(1,J,NSTOP)+F(LSTOP,J,1)+F(LSTOP,J,NSTOP)
  567. 168 CONTINUE
  568. S = S2/XLP+S
  569. PERTRB = (S/ZLP+S1)/((LUNK+1.-XLP)*(MUNK+1.-YLP)*
  570. 1 (NUNK+1.-ZLP))
  571. DO 171 I=1,LUNK
  572. DO 170 J=1,MUNK
  573. DO 169 K=1,NUNK
  574. F(I,J,K) = F(I,J,K)-PERTRB
  575. 169 CONTINUE
  576. 170 CONTINUE
  577. 171 CONTINUE
  578. 172 CONTINUE
  579. NPEROD = 0
  580. IF (NBDCND .EQ. 0) GO TO 173
  581. NPEROD = 1
  582. W(1) = 0.
  583. W(IWW-1) = 0.
  584. 173 CONTINUE
  585. CALL POIS3D (LBDCND,LUNK,C1,MBDCND,MUNK,C2,NPEROD,NUNK,W,W(IWB),
  586. 1 W(IWC),LDIMF,MDIMF,F(LSTART,MSTART,NSTART),IR,W(IWW))
  587. C
  588. C FILL IN SIDES FOR PERIODIC BOUNDARY CONDITIONS.
  589. C
  590. IF (LP .NE. 1) GO TO 180
  591. IF (MP .NE. 1) GO TO 175
  592. DO 174 K=NSTART,NSTOP
  593. F(1,MP1,K) = F(1,1,K)
  594. 174 CONTINUE
  595. MSTOP = MP1
  596. 175 IF (NP .NE. 1) GO TO 177
  597. DO 176 J=MSTART,MSTOP
  598. F(1,J,NP1) = F(1,J,1)
  599. 176 CONTINUE
  600. NSTOP = NP1
  601. 177 DO 179 J=MSTART,MSTOP
  602. DO 178 K=NSTART,NSTOP
  603. F(LP1,J,K) = F(1,J,K)
  604. 178 CONTINUE
  605. 179 CONTINUE
  606. 180 CONTINUE
  607. IF (MP .NE. 1) GO TO 185
  608. IF (NP .NE. 1) GO TO 182
  609. DO 181 I=LSTART,LSTOP
  610. F(I,1,NP1) = F(I,1,1)
  611. 181 CONTINUE
  612. NSTOP = NP1
  613. 182 DO 184 I=LSTART,LSTOP
  614. DO 183 K=NSTART,NSTOP
  615. F(I,MP1,K) = F(I,1,K)
  616. 183 CONTINUE
  617. 184 CONTINUE
  618. 185 CONTINUE
  619. IF (NP .NE. 1) GO TO 188
  620. DO 187 I=LSTART,LSTOP
  621. DO 186 J=MSTART,MSTOP
  622. F(I,J,NP1) = F(I,J,1)
  623. 186 CONTINUE
  624. 187 CONTINUE
  625. 188 CONTINUE
  626. RETURN
  627. END