Assignment of files to FORTRAN units is done using FUNCTION NOPFIL to open a file and SUBROUTINE CLOFIL to close it.
Fifteen units are required by CCSL and managed by it; if not forbidden by the particular operating system they are units 20-34. The user of standard programs should find that his input and output are taken care of by calls of NOPFIL already in the system. A user writing or modifying a main program will need to know more details, in order to deal with his own files.
Note The length of the leaf part of file-names in CCSL is restricted to 10 characters: a main part of up to 6 characters optionally followed by a period (.) and and extension of up to 3 characters.
LUNIT=14
CALL OPNFIL(LUNIT,1)
NOPFIL can interpret relative directory specifications in UNIX (eg ../) or VMS
(eg [-.]) and absolute file or directory names given as environment variables
($
CARRIAGECONTROL='FORTRAN'
Fortran carriage control is not recognised by UNIX.
MODE may have up to 5 digits.The least significant, MODE1, indicates the file-type; the second digit, MODE2, shows how to obtain the file name; the third, MODE3, deals with default extensions; the fourth, MODE4, selects formatted or unformatted files and the fifth, MODE5, selects sequential or direct access files.
Character data such as a message or the file name are transmitted to NOPFIL via the COMMON /SCRACH/ which can contain 200 characters, and within NOPFIL is divided into MESSAG and NAMFIL of 100 characters each. The maximum length of both these strings is configurable when building the system.
The significance of MODE is as follows:
The short names (10 characters) are stored in COMMON FILNAM and
may be obtained by declaring the COMMON and obeying:
CHARACTER*10 NAME,FILNOM
NAME=FILNOM(LUN)
CALL CLOFIL(LUN)
C MINIMAL FOURIER PROGRAM.
CALL PREFIN
LUNI= NOPFIL(1)
CALL RECIP
CALL OPSYM(2)
CALL SETFOU
. . . map-producing code - see various main program examples
STOP
END
It contains one explicit call to NOPFIL; however the call to PREFIN
provokes several other calls to NOPFIL, one of which sends the message:
The call to
NOPFIL in the main program sends
the message:
Give name of input file :
and the user should type the name of the file containing his reflection data.
A less trivial example is given in the fragments from the main program ABSMSF
reproduced below.
ABSMSF is a program which reads a file containing
reflection intensities in the special format produced by the sorting
programs
ARRNGE and
ARRINC.
The file name has the extension .ARR.
It then makes
an absorption correction if required and calculates the
average of the corrected intensity over all equivalent reflections. Finally
it writes an output file containing
the mean structure factors and their standard deviations.
PROGRAM ABSMSF
.
.
DIMENSION LUN(2)
CHARACTER*56 HEDING
LOGICAL INC
.
.
COMMON /IOUNIT/LPT,ITI,ITO,IPLO,LUNI,IOUT
COMMON /REFS/K(3,2),LL(48,2),R(500,2),SCALE(2),INC,II,FF(3,2)
COMMON/SCRACH/MESSAG,NAMFIL
CHARACTER *40 MESSAG
CHARACTER *60 NAMFIL
DATA HEADNG/'(5X,''h'',4X,''k'',4X,''l'',10X,''Fobs'',7X,
1''DFobs''/)'/
.
.
IF (INC.EQ.0) GO TO 2
C ALTER THE FORMAT FOR FLOATING POINT OUTPUT:
HEADNG(2:2)='6'
HEADNG(9:9)='7'
HEADNG(16:16)='7'
HEADNG(23:24)='12'
.
.
NAMFIL='.ARR'
LUN(1)=NOPFIL(101)
NAMFIL='.SF '
LOUT=NOPFIL(102)
.
.
STOP
END
The first call to NOPFIL asks the user for the name of the input file
and uses the default .ARR if no ``." is found in the reply.
The second call creates a new file for output with the same name as
the input file but with extension .SF (structure factors).