Chapter 6. The assign Environment

Table of Contents
6.1. assign basics
6.2. assign and Fortran I/O
6.3. The assign environment file
6.4. Local assign

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.

6.1. assign basics

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:

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.

6.1.1. Open processing

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.

6.1.2. The assign command

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:

-I 

Specifies an incremental assign. All attributes are added to the attributes already assigned to the current assign_object. This option and the -O option are mutually exclusive.

-O 

Specifies a replacement assign. This is the default control option. All currently existing assign attributes for the current assign_object are replaced. This option and the -I option are mutually exclusive.

-R 

Removes all assign attributes for assign_object. If assign_object is not specified, all currently assigned attributes for all assign_objects are removed.

-V 

Views attributes for assign_object. If assign_object is not specified, all currently assigned attributes for all assign_objects are printed.

The following are the assign command attribute options:

-a actualfile 

The FILE= specifier or the actual file name.

-b bs 

Library buffer size in 4096-byte blocks.

-c 

Contiguous storage. Must be used with the -n option.

-d bdr 

Online tape bad data recovery. Specify either skipbad or acptbad for bdr.

-f fortstd 

Specify 90 to be compatible with the Fortran 90 standard and Cray's CF90 compiling system or 77 to be compatible with the FORTRAN 77 standard and Cray's CF77 compiling system.

-l buflev 

Kernel buffering. Specify none, ldcache, or full for buflev. If this is not set, the level of buffering is dependent on the type of open operation being performed.

-m setting 

Special handling of a direct access file that will be accessed concurrently by several processes or tasks. Special handling includes skipping the check that only one Fortran unit be connected to a unit, suppressing file truncation to true size by the I/O buffering routines, and ensuring that the file is not truncated by the I/O buffering routines. Enter either on or off for setting.

-n sz [:st] 

Amount of system file space to reserve for a file. This is a number of 4096-byte blocks. Used by Fortran I/O, FFIO, and auxiliary I/O (AQIO, WAIO, DRIO, and MSIO). The optional st value is an obsolete way to specify the -q assign attribute. Use of -q is preferable to using the st value on -n.

-p partlist 

File system partition list. Used by Fortran I/O, FFIO, and auxiliary I/O. partlist can be a single number, a range (m-n), a set ( m:n), or a combination of ranges and sets separated by colons.

-q ocblks 

Number of 4096-byte blocks to be allocated per file system partition. Used by Fortran I/O, FFIO, and auxiliary I/O.

-r setting 

Activate or suppress the passing of the O_RAW flag to the open(2) system call. setting can be either on or off.

-s ft 

File type. Enter text, cos, blocked, unblocked, u, sbin, bin, bmx, or tape for ft.

-t 

Temporary file.

-u bufcnt 

Buffer count. Specifies the number of buffers to be allocated for a file.

-w setting 

Activate or suppress the passing of the O_WELLFORMED flag to the open(2) system call. Used by Fortran I/O and FFIO. setting may be on or off.

-x setting 

Activate or suppress the passing of the O_PARALLEL flag to the open(2) system call. setting can be either on or off.

-y setting 

Suppresses repeat counts in list-directed output. setting can be either on or off. The default setting is off.

-C charcon 

Character set conversion information. Enter ascii, ebcdic, or cdc for charcon. If you specify the -C option, you must also specify the -F option. ebcdic and cdc are not supported on UNICOS/mk.

-D fildes 

Specifies a connection to a standard file. Enter stdin, stdout, or stderr for fildes.

-F spec [,specs] 

Flexible file I/O (FFIO) specification. See the assign man page for details about allowed values for spec and for details about hardware platform support. See the INTRO_FFIO(3F) man page for details about specifying the FFIO layers.

-L setting 

Activates or suppresses the passing of the O_LDRAW flag to the open(2) system call. Enter either on or off for setting.

-N numcon 

Foreign numeric conversion specification. See the assign(1) man page for details about allowed values for numcon and for details about hardware platform support.

-P scope 

Specifies the scope of a Fortran unit and allows specification of private I/O on UNICOS systems. See the assign(1) man page for details about allowed values for scope.

-S setting 

Suppresses use of a comma as a separator in list-directed output. Enter either on or off for setting. The default setting is off.

-T setting 

Activates or suppresses truncation after write for sequential Fortran files. Enter either on or off for setting.

-U setting 

Produces a non-UNICOS form of list-directed output. This is a global setting which sets the value for the -y, -S, and -W options. Enter either on or off for setting. The default setting is off.

-W setting 

Suppresses compressed width in list-directed output. Enter either on or off for setting. The default setting is off.

-Y setting 

Skips unmatched namelist groups in a namelist input record. Enter either on or off for setting. The default setting is off.

-Z setting 

Recognizes -0.0 for IEEE floating point systems and writes the minus sign for edit-directed, list-directed, and namelist output. Enter either on or off for setting.

assign_object 

Specifies either a file name or a unit number for assign_object. The assign command associates the attributes with the file or unit specified. These attributes are used during the processing of Fortran OPEN statements or during implicit file opens.

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.

6.1.3. Related library routines

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)

cmd 

Fortran character variable that contains a complete assign command in the format that is also acceptable to the ISHELL(3F) routine.

ier 

Integer variable that is assigned the exit status on return from the library interface routine.

iunit 

Integer variable or constant that contains the unit number to which attributes are assigned.

astring 

Fortran character variable that contains any attribute options and option values from the assign command. Control options -I, -O, and -R can also be passed.

fname 

Character variable or constant that contains the file name to which attributes are assigned.

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)