      SUBROUTINE INITAL
      COMMON/T/     TIME,     NSTOP,     NORUN
     1      /Y/    T(21)
     2      /F/   TT(21)
     3      /S/   TX(21)
     4      /P/        V,         L
     5      /I/        N,        IP
C...
C...  TYPE SELECTED VARIABLES AS REAL
      REAL L
C...
C...  LENGTH
      L=1.0
C...
C...  VELOCITY
      V=1.0
C...
C...  NUMBER OF GRID POINTS
      N=21
C...
C...  INITIAL CONDITION
      DO 1 I=1,N
      T(I)=0.
1     CONTINUE
C...
C...  INITIALIZE COUNTER FOR THE OUTPUT
      IP=0
      RETURN
      END
      SUBROUTINE DERV
      COMMON/T/     TIME,     NSTOP,     NORUN
     1      /Y/    T(21)
     2      /F/   TT(21)
     3      /S/   TX(21)
     4      /P/        V,         L
     5      /I/        N,        IP
      REAL L
C...
C...  BOUNDARY CONDITION
      W=5.
      PI=3.1415927
      IF(TIME.LT.0.)T(1)=0.
      IF((W*TIME).GT.(PI))T(1)=0.
      IF(((W*TIME).GE.(0.0)).AND.((W*TIME).LE.(PI/2.0)))
     1  T(1)=1.0-COS(W*TIME)
      IF(((W*TIME).GE.(PI/2.0)).AND.((W*TIME).LE.(PI)))
     1  T(1)=1.0+COS(W*TIME)
      TT(1)=0.
C...
C...  DERIVATIVE TX
      CALL DSS012(0.,L,N,T,TX,V)
C...
C...  PDE
      DO 1 I=2,N
      TT(I)=-V*TX(I)
1     CONTINUE
      RETURN
      END
      SUBROUTINE PRINT(NI,NO)
      COMMON/T/     TIME,     NSTOP,     NORUN
     1      /Y/    T(21)
     2      /F/   TT(21)
     3      /S/   TX(21)
     4      /P/        V,         L
     5      /I/        N,        IP
      REAL L
C...
C...  PRINT A HEADING FOR THE NUMERICAL AND EXACT SOLUTIONS, INITIALIZE
C...  THE SUM OF SQUARES OF THE ERRORS
      IP=IP+1
      IF(IP.EQ.1)THEN
         WRITE(NO,1)
1        FORMAT(' ADVECTION EQUATION',//,
     1          9X,'t',4X,'T(1,t)',3X,'TE(1,t)',6X,'DIFF')
         SSE=0.
      END IF
C...
C...  CALCULATE THE EXACT SOLUTION, AND THE DIFFERENCE BETWEEN THE
C...  NUMERICAL AND EXACT SOLUTIONS
      W=5.
      PI=3.1415927
      TXV=TIME-L/V
      IF(TXV.LT.0.)TE=0.
      IF((W*TXV).GT.(PI))TE=0.
      IF(((W*TXV).GE.(0.0)).AND.((W*TXV).LE.(PI/2.0)))
     1  TE=1.0-COS(W*TXV)
      IF(((W*TXV).GE.(PI/2.0)).AND.((W*TXV).LE.(PI)))
     1  TE=1.0+COS(W*TXV)
      DIFF=T(N)-TE
C...
C...  PRINT THE NUMERICAL AND EXACT SOLUTIONS AT SELECTED TIMES
C...  IF((IP.GE.21).AND.(IP.LE.31))THEN
         WRITE(NO,2)TIME,T(N),TE,DIFF
2        FORMAT(F10.2,3F10.4)
C...  END IF
C...
C...  UPDATE THE SUM OF SQUARES OF THE ERRORS
      SSE=SSE+DIFF**2
C...
C...  PRINT THE SUM OF SQUARES OF THE ERRORS AT THE END OF THE RUN
      IF(IP.LT.51)RETURN
      WRITE(NO,3)SSE
3     FORMAT(//,' SSE = ',F7.3,//)
      RETURN
      END

