Removing uneeded file.
[and.git] / PC^2 / pc2team / samps / sumit.f
blob49b023617a37cc730ee92cdbf0cfcb9d6c3f5684
2 * vi:ts=6:sw=6:ai:ic
4 * File: sum.f
5 * Purpose: to sum the numbers from num.dat
6 * Source: Fortran 77 (compiled under Linux/fort77)
7 * Author: pc2@ecs.csus.edu (laned)
8 * Source: FORTRAN 77
9 * OS: Tested under Linux
10 * $Id: sumit.f,v 1.1 2005/03/06 05:13:57 laned Exp $
12 *23456789
13 * On Open the STATUS can be:
15 * 'OLD' - file exists
16 * 'NEW" - create the file
17 * 'SCRATCH' - this file is only used as long as the program runs
18 * 'UNKNOWN' - none of the above, depends on OS
20 * IOSTAT returns an INTEGER
21 * .eq. 0 - OK
22 * .lt. 0 - error during I/O
23 * .gt. 0 - EOF
26 *23456789
28 INTEGER IOS
29 INTEGER IVALUE
30 INTEGER THESUM
31 CHARACTER INFILE * 20
33 INFILE = 'sumit.dat'
35 THESUM = 0
37 OPEN (UNIT = 5, FILE=INFILE, STATUS='OLD', IOSTAT=IOS)
39 IF (IOS .NE. 0) GOTO 200
41 100 CONTINUE
43 READ (5, 500, IOSTAT = IOS) IVALUE
44 * READ (5, '(I)', IOSTAT = IOS) IVALUE
46 IF (IVALUE .GT. 0) THEN
47 THESUM = THESUM + IVALUE
48 END IF
50 IF (IOS .NE. 0) GOTO 200
51 IF (IVALUE .EQ. 0) GOTO 200
53 GOTO 100
55 200 CONTINUE
57 IF (IOS .EQ. 2) THEN
58 PRINT *, 'FILE NOT FOUND ',INFILE
59 STOP
60 ELSE IF (IOS .GT. 0) THEN
61 PRINT *, 'ERROR NUMBER', IOS, ' ON FILE ',INFILE
62 STOP
63 END IF
65 PRINT *, 'THE SUM IS ',THESUM
67 CLOSE (UNIT = 5)
69 500 FORMAT (I12)
71 *23456789
72 END