C Sun1996-Ex1-mod

C U(1) = u, U(2) = w

C-----------------------------------------------------------------------
      SUBROUTINE F(T, X, U, UX, UXX, FVAL, NPDE)
C-----------------------------------------------------------------------
C PURPOSE: DEFINE THE PDE AND SPATIAL ODE SYSTEM (U AND W)
C-----------------------------------------------------------------------
      INTEGER NPDE
      DOUBLE PRECISION T, X, U(NPDE), UX(NPDE), UXX(NPDE), FVAL(NPDE)
      DOUBLE PRECISION SOURCE
C
      SOURCE = EXP(X)*COS(T) - EXP(X) * SIN(T) * 
     +         ((X**2 + X + 2.0D0) / (2.0D0 * X))
C
C     FVAL(1): U_T = U_XX + (1/X)*U + (1/2)*W + SOURCE
      FVAL(1) = UXX(1) + (1.0D0/X)*U(1) + 0.5D0*U(2) + SOURCE
C
C     FVAL(2): W_X - X*U = 0 
      FVAL(2) = UX(2) - X * U(1)
C
      RETURN
      END

C-----------------------------------------------------------------------
      SUBROUTINE BNDXA(T, U, UX, BVAL, NPDE)
C-----------------------------------------------------------------------
C PURPOSE: BOUNDARY CONDITIONS AT X = 1.0 (B(T, U, UX) = 0)
C-----------------------------------------------------------------------
      INTEGER                 NPDE
      DOUBLE PRECISION        T, U(NPDE), UX(NPDE), BVAL(NPDE)
C
C     LEFT BOUNDARY CONDITION FOR U
      BVAL(1) = U(1) - EXP(1.0D0) * SIN(T)
C
C     lEFT BOUNDARY CONDITION FOR W
      BVAL(2) = U(2)
C
      RETURN
      END

C-----------------------------------------------------------------------
      SUBROUTINE BNDXB(T, U, UX, BVAL, NPDE)
C-----------------------------------------------------------------------
C PURPOSE: BOUNDARY CONDITIONS AT X = 2.0 (B(T, U, UX) = 0)
C-----------------------------------------------------------------------
      INTEGER                 NPDE
      DOUBLE PRECISION        T, U(NPDE), UX(NPDE), BVAL(NPDE)
C
C     RIGHT BOUNDARY CONDITION FOR U
      BVAL(1) = UX(1) + U(1) - 2.0D0 * EXP(2.0D0) * SIN(T)
C
C     RESIDUAL FORM OF THE W_X ODE AT X=2
      BVAL(2) = UX(2) - 2.0D0 * U(1)
C
      RETURN
      END

C-----------------------------------------------------------------------
      SUBROUTINE UINIT(X, U, NPDE)
C-----------------------------------------------------------------------
C PURPOSE: INITIAL CONDITIONS AT T = 0.0
C-----------------------------------------------------------------------
      INTEGER                 NPDE
      DOUBLE PRECISION        X, U(NPDE)
C
      U(1) = 0.0D0

      U(2) = 0.0D0
C
      RETURN
      END

C-----------------------------------------------------------------------
      SUBROUTINE TRUU(T, X, U, NPDE)
C-----------------------------------------------------------------------
C PURPOSE: ANALYTICAL EXACT SOLUTION
C-----------------------------------------------------------------------
      INTEGER                 NPDE
      DOUBLE PRECISION        T, X, U(NPDE)
C
C     EXACT SOLUTION FOR U
      U(1) = EXP(X) * SIN(T)
C
C     EXACT SOLUTION FOR  W
      U(2) = (X - 1.0D0) * EXP(X) * SIN(T)
C
      RETURN
      END