      SUBROUTINE INITAL
      PARAMETER (N=21)
      COMMON/T/      TIME,     NSTOP,     NORUN
     1      /Y/      T(N),     TS(N)
     2      /F/     TT(N),    TST(N)
     3      /S/     TZ(N),    TSZ(N)
     4      /P/         A,        AS,       RHO,        CP,      RHOS,
     5                CPS,        ZL,         D,         V,        VS,
     6                  U,        T0,        TE,       TS0,       TSE,
     7                 PI
     8      /I/        IP
C...
C...  SET THE MODEL PARAMETERS
C...
C...     TUBE CROSS SECTIONAL AREA (CM**2)
         A=2.0
C...
C...     SHELL CROSS SECTIONAL AREA (CM**2)
         AS=50.0
C...     
C...     TUBE SIDE FLUID DENSITY (GM/CM**3)
         RHO=1.0
C...
C...     TUBE SIDE FLUID HEAT CAPACITY (CAL/GM-C)
         CP=1.0
C...
C...     SHELL SIDE FLUID DENSITY (GM/CM**3)
         RHOS=1.0
C...
C...     SHELL SIDE FLUID HEAT CAPACITY (CAL/GM-C)
         CPS=1.0
C...
C...     EXCHANGER LENGTH (CM)
         ZL=200.
C...
C...     TUBE DIAMETER (CM)
         PI=4.0*ATAN(1.0)
         D=SQRT(A*4.0/PI)
C...
C...     TUBE SIDE FLUID VELOCITY (CM/SEC)
         V=10.0
C...
C...     SHELL SIDE FLUID VELOCITY (CM/SEC)
         VS=2.0
C...
C...     HEAT TRANSFER COEFFICIENT (CAL/SEC-CM**2-C)
         U=0.05
C...
C...  INITIAL CONDITIONS
      DO 1 I=1,N
       T(I)=F1(Z)
      TS(I)=F2(Z)
1     CONTINUE
C...
C...  INITIAL DERIVATIVES
      CALL DERV
C...
C...  INITIALIZE COUNTER USED IN SUBROUTINE PRINT
      IP=0
      RETURN
      END
      REAL FUNCTION F1(Z)
C...
C...  FUNCTION F1 SETS THE INITIAL CONDITION FOR T (T(Z,0) = F1(Z))
C...
      PARAMETER (N=21)
      COMMON/T/      TIME,     NSTOP,     NORUN
     1      /Y/      T(N),     TS(N)
     2      /F/     TT(N),    TST(N)
     3      /S/     TZ(N),    TSZ(N)
     4      /P/         A,        AS,       RHO,        CP,      RHOS,
     5                CPS,        ZL,         D,         V,        VS,
     6                  U,        T0,        TE,       TS0,       TSE,
     7                 PI
     8      /I/        IP
C...
C...  INITIAL TUBE SIDE FLUID TEMPERATURE (C)
      T0=25.0
      F1=T0
      RETURN
      END
      REAL FUNCTION F2(Z)
C...
C...  FUNCTION F2 SETS THE INITIAL CONDITION FOR TS (TS(Z,0) = F2(Z))
C...
      PARAMETER (N=21)
      COMMON/T/      TIME,     NSTOP,     NORUN
     1      /Y/      T(N),     TS(N)
     2      /F/     TT(N),    TST(N)
     3      /S/     TZ(N),    TSZ(N)
     4      /P/         A,        AS,       RHO,        CP,      RHOS,
     5                CPS,        ZL,         D,         V,        VS,
     6                  U,        T0,        TE,       TS0,       TSE,
     7                 PI
     8      /I/        IP
C...
C...  INITIAL SHELL SIDE FLUID TEMPERATURE (C)
      TS0=25.0
      F2=TS0
      RETURN
      END
      REAL FUNCTION G1(TIME)
C...
C...  FUNCTION G1 SETS THE BOUNDARY CONDITION FOR T (T(0,t) = G1(t))
C...
      PARAMETER (N=21)
      COMMON/T/       DUM,     NSTOP,     NORUN
     1      /Y/      T(N),     TS(N)
     2      /F/     TT(N),    TST(N)
     3      /S/     TZ(N),    TSZ(N)
     4      /P/         A,        AS,       RHO,        CP,      RHOS,
     5                CPS,        ZL,         D,         V,        VS,
     6                  U,        T0,        TE,       TS0,       TSE,
     7                 PI
     8      /I/        IP
C...
C...  ENTERING TUBE SIDE FLUID TEMPERATURE (C)
      TE=25.0
      G1=TE
      RETURN
      END
      REAL FUNCTION G2(TIME)
C...
C...  FUNCTION G2 SETS THE BOUNDARY CONDITION FOR TS (TS(ZL,t) = G2(t))
C...
      PARAMETER (N=21)
      COMMON/T/       DUM,     NSTOP,     NORUN
     1      /Y/      T(N),     TS(N)
     2      /F/     TT(N),    TST(N)
     3      /S/     TZ(N),    TSZ(N)
     4      /P/         A,        AS,       RHO,        CP,      RHOS,
     5                CPS,        ZL,         D,         V,        VS,
     6                  U,        T0,        TE,       TS0,       TSE,
     7                 PI
     8      /I/        IP
C...
C...  ENTERING SHELL SIDE FLUID TEMPERATURE (C)
      IF(TIME.LE.5.0)THEN
         TSE=25.0+20.0*TIME
      ELSE
         TSE=125.0
      END IF
      G2=TSE
      RETURN
      END
      SUBROUTINE DERV
      PARAMETER (N=21)
      COMMON/T/      TIME,     NSTOP,     NORUN
     1      /Y/      T(N),     TS(N)
     2      /F/     TT(N),    TST(N)
     3      /S/     TZ(N),    TSZ(N)
     4      /P/         A,        AS,       RHO,        CP,      RHOS,
     5                CPS,        ZL,         D,         V,        VS,
     6                  U,        T0,        TE,       TS0,       TSE,
     7                 PI
     8      /I/        IP
C...
C...  BOUNDARY CONDITION AT Z = 0
      T(1)=G1(TIME)
C...
C...  BOUNDARY CONDITION AT Z = ZL
      TS(N)=G2(TIME)
C...
C...  DERIVATIVE T
C...              Z
      CALL DSS020(0.,ZL,N,T,TZ,1.)
C...
C...  DERIVATIVE TS
C...               Z
      CALL DSS020(0.,ZL,N,TS,TSZ,-1.)
C...
C...  PDES
      DO 1 I=1,N
      TT(I)=-V * TZ(I)+U*PI*D/(A *RHO *CP )*(TS(I)-T(I))
      TST(I)=VS*TSZ(I)-U*PI*D/(AS*RHOS*CPS)*(TS(I)-T(I))
1     CONTINUE
C...
C...  THE BOUNDARY TEMPERATURES DO NOT CHANGE
       TT(1)=0.
      TST(N)=0.
      RETURN
      END
      SUBROUTINE PRINT(NI,NO)
      PARAMETER (N=21)
      COMMON/T/      TIME,     NSTOP,     NORUN
     1      /Y/      T(N),     TS(N)
     2      /F/     TT(N),    TST(N)
     3      /S/     TZ(N),    TSZ(N)
     4      /P/         A,        AS,       RHO,        CP,      RHOS,
     5                CPS,        ZL,         D,         V,        VS,
     6                  U,        T0,        TE,       TS0,       TSE,
     7                 PI
     8      /I/        IP
C...
C...  PRINT A HEADING FOR THE SOLUTION
      IP=IP+1
      IF(IP.EQ.1)THEN
         WRITE(NO,1)
1        FORMAT(6X,'TIME',4X,'T(0,t)  ',2X,'T(xL,t)',
     +                    2X,'TS(xL,t)',3X,'TS(0,t)')
      END IF
C...
C...  PRINT THE SOLUTION
      WRITE(NO,2)TIME,T(1),T(N),TS(N),TS(1)
2     FORMAT(F10.1,4F10.2)
C...
C...  CHECK THE STEADY STATE BALANCE A*RHO*CP*V*TZ = AS*RHOS*CPS*VS*TSZ
      IF(I.NE.51)RETURN

      RETURN
      END
