      SUBROUTINE INITAL
      COMMON/T/     T, NSTOP, NORUN
     1      /Y/     C
     2      /F/  DCDT
     3      /C/     K,     Q,     V,    CI
      REAL          K
C...
C...  SET THE MODEL PARAMETERS
      K=0.
      Q=1.
      V=1.
C...
C...  INITIAL CONDITION
      CI=1.
      C=CI
      RETURN
      END
      SUBROUTINE DERV
      COMMON/T/     T, NSTOP, NORUN
     1      /Y/     C
     2      /F/  DCDT
     3      /C/     K,     Q,     V,    CI
      REAL          K
C...
C...  ODE
      DCDT=(1.0/V)*(-(Q+V*K)*C)
      RETURN
      END
      SUBROUTINE PRINT(NI,NO)
      COMMON/T/     T, NSTOP, NORUN
     1      /Y/     C
     2      /F/  DCDT
     3      /C/     K,     Q,     V,    CI
      REAL          K
C...
C...  PRINT A HEADING FOR THE SOLUTION
      IF(T.LT.0.001)WRITE(NO,1)
1     FORMAT(9X,'T',6X,'C(T)',5X,'CA(T)',7X,'ABS',7X,'REL')
C...
C...  PRINT THE NUMERICAL SOLUTION, ANALYTICAL SOLUTION, ABSOLUTE
C...  AND RELATIVE DIFFERENCES BETWEEN THE SOLUTIONS
C...
C...     ANALYTICAL SOLUTION
         CA=CI*EXP(-(Q+V*K)/V*T)
C...
C...     ABSOLUTE DIFFERENCE
         ABS=C-CA
C...
C...     RELATIVE DIFFERENCE
         REL=ABS/C
C...
C...     PRINT THE SOLUTIONS
         WRITE(NO,2)T,C,CA,ABS,REL
2        FORMAT(F10.1,4F10.5)
C...
C...  AT THE END OF THE SECOND RUN, PERFORM AN EULER INTEGRATION
C...  FOR A SERIES OF STEP SIZES TO DETERMINE THE APPARENT ORDER
C...  OF THE EULER METHOD
      IF((NORUN.EQ.2).AND.(T.GT.9.99))CALL EULER(NI,NO)
      RETURN
      END
      SUBROUTINE EULER(NI,NO)
C...
C...  SUBROUTINE EULER PERFORMS A FIXED STEP EULER INTEGRATION
C...  FOR A SERIES OF STEP SIZES
C...
      COMMON/T/     T, NSTOP, NORUN
     1      /Y/     C
     2      /F/  DCDT
     3      /C/     K,     Q,     V,    CI
      REAL          K
C...
C...  STEP THROUGH A SERIES OF NSTEPS STEPS
      NSTEPS=4
      DO 1 NSTEP=1,NSTEPS
C...
C...  SELECT THE STEP SIZE
      IF(NSTEP.EQ.1)THEN
         H=1.0
         INC=1
      ELSE IF(NSTEP.EQ.2)THEN
         H=0.1
         INC=10
      ELSE IF(NSTEP.EQ.3)THEN
         H=0.01
         INC=100
      ELSE IF(NSTEP.EQ.4)THEN
         H=0.001
         INC=1000
      END IF
C...
C...  PRINT A HEADING
      WRITE(NO,3)H
3     FORMAT(//,' FIXED STEP EULER INTEGRATION FOR H = ',F7.4,//,
     1 9X,'T',6X,'C(T)',5X,'CA(T)',6X,'DIFF')
C...
C...  START THE INTEGRATION
      T=0.
      C=CI
      I=0
C...
C...  PRINT THE ANALYTICAL AND NUMERICAL SOLUTIONS AND THE DIFFERENCE
2     IF((I/INC*INC).EQ.I)THEN
C...
C...     ANALYTICAL SOLUTION
         CA=CI*EXP(-(Q+V*K)/V*T)
C...
C...     DIFFERENCE BETWEEN THE SOLUTIONS
         DIFF=C-CA
C...
C...     PRINT THE SOLUTIONS
         WRITE(NO,4)T,C,CA,DIFF
4        FORMAT(F10.1,2F10.5,F10.6)
      END IF
C...
C...  TEST FOR THE END OF THE RUN
      IF(T.GT.9.999)GO TO 1
C...
C...  TAKE THE NEXT STEP ALONG THE SOLUTION
      CALL DERV
      C=C+DCDT*H
      T=T+H
      I=I+1
      GO TO 2
1     CONTINUE
      END
