• Aucun résultat trouvé

Connecting to an External FOe-OPEN Statement

Dans le document FORMAT (3(1) STOP (Page 109-113)

An OPEN statement connects a FORTRAN 1/0 unit number with an external file and may state other file characteristics. Direct files and VSAM files must be opened with an OPEN statement. For other types of files, the OPEN statement is optional.

The parameters in the OPEN statement are:

UNIT

FILE

which is an integer expression that specifies the I/O unit to be connected.

For more information, see "Specifying the Input/Output UNIT Parameter"

on page 81.

which specifies the name of the data definition statement (ddname in MVS and CMS; filename on the DLBL statement in VSE) to be represented internally by the unit number.

Note: On all systems, the name of the file must be specified if the default name is not desired. The name can contain up to seven alphameric characters, the first of which must be alphabetic.

If a file status of SCRATCH is specified, the name must not be specified.

The FILE parameter cannot be specified if the default name is desired.

Example (VM):

OPEN (UNIT=15, FILE='myfile1' , ... )

FILEDEF MYFILE1 DISK SAMPLE DATA A

If you do not use a FILEDEF command, the filename is always FILE, and the file type is taken from the OPEN statement-in this case, myfile 1.

If, on the other hand, you do not use a FILEDEF command and FILE is not specified in the OPEN statement, the default filename, filetype, and filemode are:

FILE FTxxF001 A1 where:

xx is the unit number to which you are putting out the data.

For VSAM keyed files, the default is FTxxKnn, where:

xx is the unit number (00 through 99), and nn is the key sequence number (01 through 09).

For VM, the filename specified in the OPEN statement is the ddname.

Example (MVS):

//MYFILE1 DD DSN=SAMPLE, ...

OPEN (UNIT=15, FILE='myfile1', ... )

The default name of the file is FTxxFOOl, where xx is the unit number to which you are putting out the data.

Chapter 5. Programming Input and Output

83

For VSAM keyed files, the default is FTxxKnn, where:

xx is the unit number (00 through 99), and nn is the key sequence number (01 through 09).

For MVS, the filename specified in the OPEN statement is the ddname.

Example (VSE):

//DLBL myfile1, ...

OPEN (UNIT=15, FILE='rnyfile1', •.. )

For VSE, the filename specified in the OPEN statement is the filename specified in the DLBL statement. Your installation may have set up default DLBLs specifying default filenames. If OPEN is specified without a filename, a filename must have been supplied on a DLBL statement; for example, with default filenames such as USYSOO through USYS04.

For VSAM sequential and direct files, the default is USYSxx; for VSAM keyed files, the default is FTxxKnn:

where

xx is the unit number (00 through 99), and nn is the key sequence number (01 through 09) STATUS

which lets you specify the file status of this file, as follows:

NEW for a file that you're creating for the first time OLD for a file that already exists

SCRATCH for a temporary file to be used during this job and then erased at the end of the job

UNKNOWN for a file whose status is not currently known to the program; it mayor may not currently exist. If it does not exist, it will be created.

ACCESS

which lets you specify the access method for this file: SEQUENTIAL or DIRECT.

mM Extension Or KEYED.

'"-_ _ _ _ _ _ _ _ _ End of mM Extension _ _ _ _ _ _ _ _ _ ~

Sequential files are always assumed; therefore, for this type of file, specifying the ACCESS parameter is not required. However, specifying it is useful for documentation.

For direct and keyed files, you must specify the access method.

BLANK

which lets you specify how blanks in numeric fields of a formatted input record are to be treated:

NULL blanks are ignored

ZERO any blanks that aren't leading blanks are treated as zeros FORM

RECL

which lets you specify whether this file is connected for formatted or unformatted input/output. For sequential files, the default is

FORMATTED; for direct or keyed files, the default is UNFORMATTED.

which lets you specify the logical record length of a direct file. Must not be used for sequential or keyed files.

IBM Extension ACTION

KEYS

which indicates the type of file processing to be done.

WRITE to open a VSAM file for loading of records

READ to open a non-empty VSAM file for retrieval operations READWRITE to open a VSAM file to allow possible update as well as

retrieval operations.

The following parameters can only be used if ACCESS=KEYED.

which is a list of one or more different primary or alternate index keys which may be used to access the KSDS.

PASSWORD

which is the password that is required to access the VSAM KSDS.

""'-_ _ _ _ _ _ _ _ _ _ End of mM Extension _ _ _ _ _ _ _ _ _ _ ...

To see the formats of the above parameters, see VS FORTRAN Language and Library Reference.

Chapter 5. Programming Input and Output

85

Handling Multiple Files

In MVS and VM, you can refer to multiple files using the same unit number-but to do so, you must use the default name for the file:

FTxxFyyy where

xx is the unit number (00 through 99), and

yyy is the file sequence number (001 through 999).

In MVS and VM, the file sequence number identifies the data set sequence number.

The file sequence number for a given unit number is incremented when an END=

branch is taken for a READ statement, or when an ENDFILE statement is

executed. Execution of a REWIND or CLOSE resets the sequence number to 001.

In MVS and VM, each file sequence number refers to a separate physical

sequential file. Each of these files must be described by

a

separate DD statement (MVS) or a CMS FILEDEF command (VM). Refer to Chapter 12, "Using VS FORTRAN under MVS" on page 257, or Chapter 11, "Using VS FORTRAN under VM" on page 227, for a discussion of ddname requirements.

Dans le document FORMAT (3(1) STOP (Page 109-113)