| Application Programmer's I/O Guide - S-3695-35 | ||
|---|---|---|
| Prev Section | Next Section | |
Fortran programs require the ability to alter many details of a Fortran file connection. You may need to specify device residency, an alternative file name, a file space allocation scheme, file structure, or data conversion properties of a connected file.
This chapter describes the assign(1) command and the ASSIGN(3F) library routine, which are used for these purposes. The ffassign command provides an interface to assign processing from C. See the ffassign man page for details about its use.
The assign command passes information to Fortran OPEN statements and to the ffopen(3C), AQOPEN(3F), WOPEN(3F), OPENDR(3F), and OPENMS(3F) routines.
This information is called the assign environment; it consists of the following elements:
A list of unit numbers
File names
File name patterns that have attributes associated with them
Any file name, file name pattern, or unit number to which assign options are attached is called an assign_object. When the unit or file is opened from Fortran, the options are used to set up the properties of the connection.
The I/O library routines apply options to a file connection for all related assign_objects.
If the assign_object is a unit, the application of options to the unit occurs whenever that unit becomes connected.
If the assign_object is a file name or pattern, the application of options to the file connection occurs whenever a matching file name is opened from a Fortran program.
When any of the previously listed library I/O routines open a file, they use assign options for any assign_objects which apply to this open request. Any of the following assign_objects or categories might apply to a given open request:
g:all options apply to any open request.
g:su, g:sf, g:du, g:aq, and g:ff each apply to types of open requests (for example, sequential unformatted, sequential formatted, and so on).
u:unit_number applies whenever unit unit_number is opened.
p:pattern applies whenever a file whose name matches pattern is opened. The assign environment can contain only one p: assign_object which matches the current open file. The exception is that the p:%pattern (which uses the % wildcard character) is silently ignored if a more specific pattern also matches the current filename being opened.
f:filename applies whenever a file with the name filename is opened.
Options from the assign objects in these categories are collected to create the complete set of options used for any particular open. The options are collected in the listed order, with options collected later in the list of assign objects overriding those collected earlier.
The following is the syntax for the assign command:
UNICOS and UNICOS/mk systems:
assign [-I] [-O] [-a actualfile] [-b bs] [-c] [-d bdr] [-f fortstd] [-l buflev] [ -m setting] [-n sz[:st]] [-p partlist] [-q ocblks] [-r setting] [-s ft] [-t] [-u bufcnt] [-w setting] [-x setting] [-y setting] [-C charcon] [-D fildes] [-F spec[,specs]] [-L setting] [-N numcon] [-P scope] [-R] [-S setting] [-T setting] [-U setting] [-V] [-W setting] [-Y setting] [-Z setting] assign_object |
The following two specifications cannot be used with any other options:
assign -R [assign_object] |
assign -V [assign_object] |
The following is a summary of the assign command options. For details, see the assign(1) and INTRO_FFIO(3F) man pages. The assign command is implemented through the ASSIGN(3F), ASNFILE(3F), and ASNUNIT(3F) routines for Programming Environment releases prior to 1.2.
The following are the assign command control options:
The following are the assign command attribute options:
Use one of the following formats for assign_object:
f:file_name (for example, f:file1)
g:io_type; io_type can be su, sf, du, df, ff, or aq (for example, g:ff)
p:pattern (for example, p:file%)
u:unit_number (for example, u:9)
file_name (for example, myfile)
When the p: pattern form is used, the % and _ wildcard characters can be used. The % matches any string of 0 or more characters. The _ matches any single character. The % performs like the * when doing file name matching in shells. However, the % character also matches strings of characters containing the / character.
The ASSIGN, ASNUNIT(3F), ASNFILE, and ASNRM(3F) routines can be called from a Fortran program to access and update the assign environment. The ASSIGN routine provides an easy interface to ASSIGN processing from a Fortran program. The ASNUNIT and ASNFILE routines assign attributes to units and files, respectively. The ASNRM routine removes all entries currently in the assign environment.
The calling sequences for the assign library routines are as follows:
CALL ASSIGN (cmd [,ier])
CALL ASNUNIT (iunit,astring,ier)
CALL ASNFILE (fname,astring,ier)
CALL ASNRM (ier) |
A status of 0 indicates normal return and a status of greater than 0 indicates a specific error status. Use the explain command to determine the meaning of the error status. For more information about the explain command, see the explain(1) man page.
The following calls are equivalent to the assign -s u f:file command:
CALL ASSIGN('assign -s u f:file',ier)
CALL ASNFILE('file','-s u',IER) |
The following call is equivalent to executing the assign -I -n 2 u:99 command:
IUN = 99 CALL ASNUNIT(IUN,'-I -n 2',IER) |
The following call is equivalent to executing the assign -R command:
CALL ASNRM(IER) |
| Prev Section | Table of Contents | Title Page | Next Section |
| C I/O | Up one level | assign and Fortran I/O |