File: fclose.f

package info (click to toggle)
x13as 1.1-b59-1
  • links: PTS, VCS
  • area: non-free
  • in suites: bookworm
  • size: 9,088 kB
  • sloc: fortran: 114,121; makefile: 14
file content (69 lines) | stat: -rw-r--r-- 3,085 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
C     Last change:  BCM  28 Oct 97    4:14 pm
**==fclose.f    processed by SPAG 4.03F  at 09:48 on  1 Mar 1994
      SUBROUTINE fclose(Handle)
      IMPLICIT NONE
c-----------------------------------------------------------------------
c     Opens a file with the given options and assigns a file handle
c-----------------------------------------------------------------------
c Parameters and include files
c-----------------------------------------------------------------------
      INCLUDE 'stdio.i'
c-----------------------------------------------------------------------
c Namelist Input Arguments
c Name  Type Description
c-----------------------------------------------------------------------
c handle  i  Unit number of the next available file
c-----------------------------------------------------------------------
      INTEGER Handle
c-----------------------------------------------------------------------
c Local Arguments
c Name  Type Description
c-----------------------------------------------------------------------
c ifile   i  Index for the current file handle
c jfile   i  Index for the current file
c-----------------------------------------------------------------------
      INTEGER ifile,jfile
c-----------------------------------------------------------------------
c     If handle=ALLFIL close all the files
c-----------------------------------------------------------------------
      IF(Handle.eq.ALLFIL)THEN
       DO WHILE (Nfile.gt.1)
        CLOSE(Fillst(Nfile))
        Nfile=Nfile-1
       END DO
       IF(Opnsin)CLOSE(STDIN)
       IF(Opnsot)CLOSE(STDOUT)
c-----------------------------------------------------------------------
c     Else close the file with the unit number handle
c-----------------------------------------------------------------------
      ELSE IF(Handle.eq.STDIN)THEN
       IF(Opnsin)CLOSE(STDIN)
      ELSE IF(Handle.eq.STDOUT)THEN
       IF(Opnsot)CLOSE(STDOUT)
      ELSE
       DO ifile=1,Nfile
        IF(Fillst(ifile).eq.Handle)THEN
c-----------------------------------------------------------------------
c     If the file is in the list of open files then close it and
c put the file handle in the unopened files part of the list
c-----------------------------------------------------------------------
         CLOSE(Handle)
c     ------------------------------------------------------------------
         DO jfile=ifile,Nfile-1
          Fillst(jfile)=Fillst(jfile+1)
         END DO
c     ------------------------------------------------------------------
         Fillst(Nfile)=Handle
         Nfile=Nfile-1
         GO TO 10
        END IF
       END DO
c     ------------------------------------------------------------------
       PRINT 1010,Handle
c Later we are going to want to call the files by there file names
c because the user won't know what the unit numbers are.
 1010  FORMAT(/,' File',i3,' not found to close')
      END IF
c     ------------------------------------------------------------------
   10 RETURN
      END