! Programmer: Elizabeth Adams

! Course: CS 355 Spring 2003

! Date: February 5, 2003

! Language: FORTRAN (using only features present in early FORTRAN)

! Compiler: Lahey FORTRAN 95

! Environmment: Windows NT

! Source Filename: EndErr.FOR

! Executable Filename: EndErr.exe

 

 

! Purpose: This program was written to illustrate the    

!          primitive exception handling mechanisms

!          included in FORTRAN from the beginning

 

! Input Description: 3 digit integers entered from the keyboard

 

! Output Description: echo of each integer entered

 

 

 

! The line with label 10 tries to read an integer from the keyboard

 

! If the user types <ctrl>z which indicates the end of file, the

! program ends by transferring control to the line labeled 15. 

 

! If the user enters a value with a decimal point or

! a character, the program jumps t the line labeled 13 and

! prints an error message and then the program ends.

 

  10  READ(5, 20, END=15, ERR=13) NUMBER

     

! Echo the input

      WRITE (6,11) NUMBER

 

! Go get another number     

      GO TO 10

 

! Print the number the user typed in 

  13  WRITE (6, 12)

 

! Format descriptors for input and output 

  20  FORMAT (I3)

  11  FORMAT (' ', I10)

  12  FORMAT ('0', 'OOPS, YOU MISTYPED SOMETHING')

 

! Stop the program's execution 

  15  STOP

      END