| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333 | *DECK POIS3D      SUBROUTINE POIS3D (LPEROD, L, C1, MPEROD, M, C2, NPEROD, N, A, B,     +   C, LDIMF, MDIMF, F, IERROR, W)C***BEGIN PROLOGUE  POIS3DC***PURPOSE  Solve a three-dimensional block tridiagonal linear systemC            which arises from a finite difference approximation to aC            three-dimensional Poisson equation using the FourierC            transform package FFTPAK written by Paul Swarztrauber.C***LIBRARY   SLATEC (FISHPACK)C***CATEGORY  I2B4BC***TYPE      SINGLE PRECISION (POIS3D-S)C***KEYWORDS  ELLIPTIC PDE, FISHPACK, HELMHOLTZ, POISSONC***AUTHOR  Adams, J., (NCAR)C           Swarztrauber, P. N., (NCAR)C           Sweet, R., (NCAR)C***DESCRIPTIONCC     Subroutine POIS3D solves the linear system of equationsCC       C1*(X(I-1,J,K)-2.*X(I,J,K)+X(I+1,J,K))C     + C2*(X(I,J-1,K)-2.*X(I,J,K)+X(I,J+1,K))C     + A(K)*X(I,J,K-1)+B(K)*X(I,J,K)+C(K)*X(I,J,K+1) = F(I,J,K)CC     for  I=1,2,...,L , J=1,2,...,M , and K=1,2,...,N .CC     The indices K-1 and K+1 are evaluated modulo N, i.e.C     X(I,J,0) = X(I,J,N) and X(I,J,N+1) = X(I,J,1). The unknownsC     X(0,J,K), X(L+1,J,K), X(I,0,K), and X(I,M+1,K) are assumed to takeC     on certain prescribed values described below.CC    * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *CCC    * * * * * * * *    Parameter Description     * * * * * * * * * *CCC            * * * * * *   On Input    * * * * * *CC     LPEROD   Indicates the values that X(0,J,K) and X(L+1,J,K) areC              assumed to have.CC              = 0  If X(0,J,K) = X(L,J,K) and X(L+1,J,K) = X(1,J,K).C              = 1  If X(0,J,K) = X(L+1,J,K) = 0.C              = 2  If X(0,J,K) = 0  and X(L+1,J,K) = X(L-1,J,K).C              = 3  If X(0,J,K) = X(2,J,K) and X(L+1,J,K) = X(L-1,J,K).C              = 4  If X(0,J,K) = X(2,J,K) and X(L+1,J,K) = 0.CC     L        The number of unknowns in the I-direction. L must be atC              least 3.CC     C1       The real constant that appears in the above equation.CC     MPEROD   Indicates the values that X(I,0,K) and X(I,M+1,K) areC              assumed to have.CC              = 0  If X(I,0,K) = X(I,M,K) and X(I,M+1,K) = X(I,1,K).C              = 1  If X(I,0,K) = X(I,M+1,K) = 0.C              = 2  If X(I,0,K) = 0 and X(I,M+1,K) = X(I,M-1,K).C              = 3  If X(I,0,K) = X(I,2,K) and X(I,M+1,K) = X(I,M-1,K).C              = 4  If X(I,0,K) = X(I,2,K) and X(I,M+1,K) = 0.CC     M        The number of unknowns in the J-direction. M must be atC              least 3.CC     C2       The real constant which appears in the above equation.CC     NPEROD   = 0  If A(1) and C(N) are not zero.C              = 1  If A(1) = C(N) = 0.CC     N        The number of unknowns in the K-direction. N must be atC              least 3.CCC     A,B,C    One-dimensional arrays of length N that specify theC              coefficients in the linear equations given above.CC              If NPEROD = 0 the array elements must not depend upon theC              index K, but must be constant.  Specifically, theC              subroutine checks the following conditionCC                          A(K) = C(1)C                          C(K) = C(1)C                          B(K) = B(1)CC                  for K=1,2,...,N.CC     LDIMF    The row (or first) dimension of the three-dimensionalC              array F as it appears in the program calling POIS3D.C              This parameter is used to specify the variable dimensionC              of F.  LDIMF must be at least L.CC     MDIMF    The column (or second) dimension of the three-dimensionalC              array F as it appears in the program calling POIS3D.C              This parameter is used to specify the variable dimensionC              of F.  MDIMF must be at least M.CC     F        A three-dimensional array that specifies the values ofC              the right side of the linear system of equations givenC              above.  F must be dimensioned at least L x M x N.CC     W        A one-dimensional array that must be provided by theC              user for work space.  The length of W must be at leastC              30 + L + M + 2*N + MAX(L,M,N) +C              7*(INT((L+1)/2) + INT((M+1)/2)).CCC            * * * * * *   On Output   * * * * * *CC     F        Contains the solution X.CC     IERROR   An error flag that indicates invalid input parameters.C              Except for number zero, a solution is not attempted.C              = 0  No errorC              = 1  If LPEROD .LT. 0 or .GT. 4C              = 2  If L .LT. 3C              = 3  If MPEROD .LT. 0 or .GT. 4C              = 4  If M .LT. 3C              = 5  If NPEROD .LT. 0 or .GT. 1C              = 6  If N .LT. 3C              = 7  If LDIMF .LT. LC              = 8  If MDIMF .LT. MC              = 9  If A(K) .NE. C(1) or C(K) .NE. C(1) or B(I) .NE.B(1)C                      for some K=1,2,...,N.C              = 10 If NPEROD = 1 and A(1) .NE. 0 or C(N) .NE. 0CC              Since this is the only means of indicating a possiblyC              incorrect call to POIS3D, the user should test IERRORC              after the call.CC *Long Description:CC    * * * * * * *   Program Specifications    * * * * * * * * * * * *CC     Dimension of   A(N),B(N),C(N),F(LDIMF,MDIMF,N),C     Arguments      W(see argument list)CC     Latest         December 1, 1978C     RevisionCC     Subprograms    POIS3D,POS3D1,TRIDQ,RFFTI,RFFTF,RFFTF1,RFFTB,C     Required       RFFTB1,COSTI,COST,SINTI,SINT,COSQI,COSQF,COSQF1C                    COSQB,COSQB1,SINQI,SINQF,SINQB,CFFTI,CFFTI1,C                    CFFTB,CFFTB1,PASSB2,PASSB3,PASSB4,PASSB,CFFTF,C                    CFFTF1,PASSF1,PASSF2,PASSF3,PASSF4,PASSF,PIMACH,CC     Special        NONEC     ConditionsCC     Common         NONEC     BlocksCC     I/O            NONECC     Precision      SingleCC     Specialist     Roland SweetCC     Language       FORTRANCC     History        Written by Roland Sweet at NCAR in July 1977CC     Algorithm      This subroutine solves three-dimensional blockC                    tridiagonal linear systems arising from finiteC                    difference approximations to three-dimensionalC                    Poisson equations using the Fourier transformC                    package FFTPAK written by Paul Swarztrauber.CC     Space          6561(decimal) = 14641(octal) locations on theC     Required       NCAR Control Data 7600CC     Timing and        The execution time T on the NCAR Control DataC     Accuracy       7600 for subroutine POIS3D is roughly proportionalC                    to L*M*N*(log2(L)+log2(M)+5), but also depends onC                    input parameters LPEROD and MPEROD.  Some typicalC                    values are listed in the table below when NPEROD=0.C                       To measure the accuracy of the algorithm aC                    uniform random number generator was used to createC                    a solution array X for the system given in theC                    'PURPOSE' withCC                       A(K) = C(K) = -0.5*B(K) = 1,       K=1,2,...,NCC                    and, when NPEROD = 1CC                       A(1) = C(N) = 0C                       A(N) = C(1) = 2.CC                    The solution X was substituted into the given sys-C                    tem and, using double precision, a right side Y wasC                    computed.  Using this array Y subroutine POIS3D wasC                    called to produce an approximate solution Z.  ThenC                    the relative error, defined asCC                    E = MAX(ABS(Z(I,J,K)-X(I,J,K)))/MAX(ABS(X(I,J,K)))CC                    where the two maxima are taken over I=1,2,...,L,C                    J=1,2,...,M and K=1,2,...,N, was computed.  TheC                    value of E is given in the table below for someC                    typical values of L,M and N.CCC                       L(=M=N)   LPEROD    MPEROD    T(MSECS)    EC                       ------    ------    ------    --------  ------CC                         16        0         0         272     1.E-13C                         15        1         1         287     4.E-13C                         17        3         3         338     2.E-13C                         32        0         0        1755     2.E-13C                         31        1         1        1894     2.E-12C                         33        3         3        2042     7.E-13CCC     Portability    American National Standards Institute FORTRAN.C                    The machine dependent constant PI is defined inC                    function PIMACH.CC     Required       COS,SIN,ATANC     ResidentC     RoutinesCC     Reference      NONECC    * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *CC***REFERENCES  (NONE)C***ROUTINES CALLED  POS3D1C***REVISION HISTORY  (YYMMDD)C   801001  DATE WRITTENC   890531  Changed all specific intrinsics to generic.  (WRB)C   890531  REVISION DATE from Version 3.2C   891214  Prologue converted to Version 4.0 format.  (BAB)C***END PROLOGUE  POIS3D      DIMENSION       A(*)       ,B(*)       ,C(*)       ,     1                F(LDIMF,MDIMF,*)       ,W(*)       ,SAVE(6)C***FIRST EXECUTABLE STATEMENT  POIS3D      LP = LPEROD+1      MP = MPEROD+1      NP = NPEROD+1CC     CHECK FOR INVALID INPUT.C      IERROR = 0      IF (LP.LT.1 .OR. LP.GT.5) IERROR = 1      IF (L .LT. 3) IERROR = 2      IF (MP.LT.1 .OR. MP.GT.5) IERROR = 3      IF (M .LT. 3) IERROR = 4      IF (NP.LT.1 .OR. NP.GT.2) IERROR = 5      IF (N .LT. 3) IERROR = 6      IF (LDIMF .LT. L) IERROR = 7      IF (MDIMF .LT. M) IERROR = 8      IF (NP .NE. 1) GO TO 103      DO 101 K=1,N         IF (A(K) .NE. C(1)) GO TO 102         IF (C(K) .NE. C(1)) GO TO 102         IF (B(K) .NE. B(1)) GO TO 102  101 CONTINUE      GO TO 104  102 IERROR = 9  103 IF (NPEROD.EQ.1 .AND. (A(1).NE.0. .OR. C(N).NE.0.)) IERROR = 10  104 IF (IERROR .NE. 0) GO TO 122      IWYRT = L+1      IWT = IWYRT+M      IWD = IWT+MAX(L,M,N)+1      IWBB = IWD+N      IWX = IWBB+N      IWY = IWX+7*((L+1)/2)+15      GO TO (105,114),NPCC     REORDER UNKNOWNS WHEN NPEROD = 0.C  105 NH = (N+1)/2      NHM1 = NH-1      NODD = 1      IF (2*NH .EQ. N) NODD = 2      DO 111 I=1,L         DO 110 J=1,M            DO 106 K=1,NHM1               NHPK = NH+K               NHMK = NH-K               W(K) = F(I,J,NHMK)-F(I,J,NHPK)               W(NHPK) = F(I,J,NHMK)+F(I,J,NHPK)  106       CONTINUE            W(NH) = 2.*F(I,J,NH)            GO TO (108,107),NODD  107       W(N) = 2.*F(I,J,N)  108       DO 109 K=1,N               F(I,J,K) = W(K)  109       CONTINUE  110    CONTINUE  111 CONTINUE      SAVE(1) = C(NHM1)      SAVE(2) = A(NH)      SAVE(3) = C(NH)      SAVE(4) = B(NHM1)      SAVE(5) = B(N)      SAVE(6) = A(N)      C(NHM1) = 0.      A(NH) = 0.      C(NH) = 2.*C(NH)      GO TO (112,113),NODD  112 B(NHM1) = B(NHM1)-A(NH-1)      B(N) = B(N)+A(N)      GO TO 114  113 A(N) = C(NH)  114 CONTINUE      CALL POS3D1 (LP,L,MP,M,N,A,B,C,LDIMF,MDIMF,F,W,W(IWYRT),W(IWT),     1             W(IWD),W(IWX),W(IWY),C1,C2,W(IWBB))      GO TO (115,122),NP  115 DO 121 I=1,L         DO 120 J=1,M            DO 116 K=1,NHM1               NHMK = NH-K               NHPK = NH+K               W(NHMK) = .5*(F(I,J,NHPK)+F(I,J,K))               W(NHPK) = .5*(F(I,J,NHPK)-F(I,J,K))  116       CONTINUE            W(NH) = .5*F(I,J,NH)            GO TO (118,117),NODD  117       W(N) = .5*F(I,J,N)  118       DO 119 K=1,N               F(I,J,K) = W(K)  119       CONTINUE  120    CONTINUE  121 CONTINUE      C(NHM1) = SAVE(1)      A(NH) = SAVE(2)      C(NH) = SAVE(3)      B(NHM1) = SAVE(4)      B(N) = SAVE(5)      A(N) = SAVE(6)  122 CONTINUE      RETURN      END
 |