| Application Programmer's I/O Guide - S-3695-35 | ||
|---|---|---|
| Prev Section | Chapter 6. The assign Environment | Next Section |
Assign processing lets you tune file connections. The following sections describe several areas of assign command usage and provide examples of each use.
The -a option specifies the actual file name to which a connection is made. This option allows files to be created in alternative directories without changing the FILE= specifier on an OPEN statement.
For example, consider the following assign command issued to open unit 1:
assign -a /tmp/mydir/tmpfile u:1 |
The program then opens unit 1 with any of the following statements:
WRITE(1) variable ! implicit open OPEN(1) ! unnamed open OPEN(1,FORM='FORMATTED') ! unnamed open |
Unit 1 is connected to file /tmp/mydir/tmpfile. Without the -a attribute, unit 1 would be connected to file fort.1.
To allocate a file on an SSD-resident or memory-resident file system on a UNICOS system, you can use an assign command such as the following:
assign -a /ssd/myfile u:1 |
When the -a attribute is associated with a file, any Fortran open that is set to connect to the file causes a connection to the actual file name. An assign command of the following form causes a connection to file $TMPDIR/joe:
assign -a $TMPDIR/joe ftfile |
This is true when any of the following statements are executed in a program:
OPEN(IUN,FILE='ftfile')
CALL AQOPEN(AQP,AQPSIZE,'ftfile',ISTAT)
CALL OPENMS('ftfile',INDARR,LEN,IT)
CALL OPENDR('ftfile',INDARR,LEN,IT)
CALL WOPEN('ftfile',BLOCKS,ISTATS)
WRITE('ftfile') ARRAY |
If the following assign command is issued and is in effect, any Fortran INQUIRE statement whose FILE= specification is foo refers to the file named actual instead of the file named foo for purposes of the EXISTS=, OPENED=, or UNIT= specifiers:
assign -a actual f:foo |
If the following assign command is issued and is in effect, the -a attribute does not affect INQUIRE statements with a UNIT= specifier:
assign -a actual ftfile |
When the following OPEN statement is executed, INQUIRE(UNIT=n,NAME=fname) returns a value of ftfile in fname, as if no assign had occurred:
OPEN(n,file='ftfile') |
The I/O library routines use only the actual file (-a) attributes from the assign environment when processing an INQUIRE statement. During an INQUIRE statement that contains a FILE= specifier, the I/O library searches the assign environment for a reference to the file name that the FILE= specifier supplies. If an assign-by-filename exists for the file name, the I/O library determines whether an actual name from the -a option is associated with the file name. If the assign-by-filename supplied an actual name, the I/O library uses the name to return values for the EXIST=, OPENED=, and UNIT= specifiers; otherwise, it uses the file name. The name returned for the NAME= specifier is the file name supplied in the FILE= specifier. The actual file name is not returned.
Fortran I/O uses five different file structures: text structure, unblocked structure, bmx or tape, pure data structure, and COS blocked structure. By default, a file structure is selected for a unit based on the type of Fortran I/O selected at open time. If an alternative file structure is needed, the user can select a file structure by using the -s and -F options on the assign command.
No assign_object can have both -s and -F attributes associated with it. Some file structures are available as -F attributes but are not available as -s attributes. The -F option is more flexible than the -s option; it allows nested file structures and buffer size specifications for some attribute values. The following list summarizes how to select the different file structures with different options to the assign command:
For more information about file structures, see Chapter 7.
The following are examples of file structure selection:
To select unblocked file structure for a sequential unformatted file:
IUN = 1 CALL ASNUNIT(IUN,'-s unblocked',IER) OPEN(IUN,FORM='UNFORMATTED',ACCESS='SEQUENTIAL') |
You can use the assign -s u command to specify the unblocked file structure for a sequential unformatted file. When this option is selected, the I/O is unbuffered. Each Fortran READ or WRITE statement results in a read or write(2) system call such as the following:
CALL ASNFILE('fort.1','-s u',IER)
OPEN(1,FORM='UNFORMATTED',ACCESS='SEQUENTIAL') |
Use the following command to assign unit 10 a COS blocked structure:
assign -F cos u:10 |
The size of the buffer used for a Fortran file can have a substantial effect on I/O performance. A larger buffer size usually decreases the system time needed to process sequential files. However, large buffers increase a program's memory usage; therefore, optimizing the buffer size for each file accessed in a program on a case-by-case basis can help increase I/O performance and can minimize memory usage.
The -b option on the assign command specifies a buffer size, in blocks, for the unit. The -b option can be used with the -s option, but it cannot be used with the -F option. Use the -F option to provide I/O path specifications that include buffer sizes; the -b, and -u options do not apply when -F is specified.
For more information about the selection of buffer sizes, see Chapter 8, and the assign man page.
The following are some examples of buffer size specification using the assign -b and assign -F options:
If unit 1 is a large sequential file for which many Fortran READ or WRITE statements are issued, you can increase the buffer size to a large value, using the following assign command:
assign -b 336 u:1 |
If unit 1 is to be connected to a large sequential unformatted file with COS blocked structure on UNICOS or UNICOS/mk systems, enter either of the following assign commands to specify a buffer size of 336:
assign -b 336 u:1 assign -F cos:336 u:1 |
The buffer size for the example was calculated by multiplying tracks-per-cylinder for one type of disk by the track size in sectors of that disk.
If file foo is a small file or is accessed infrequently, minimize the buffer size using the following assign command:
assign -b 1 f:foo |
The Fortran I/O library can read and write files with record blocking and data formats native to operating systems from other vendors. The assign -F command specifies a foreign record blocking; the assign -C command specifies the type of character conversion; the -N option specifies the type of numeric data conversion. When -N or -C is specified, the data is converted automatically during the processing of Fortran READ and WRITE statements. For example, assume that a record in file fgnfile contains the following character and integer data:
character*4 ch integer int open(iun,FILE='fgnfile',FORM='UNFORMATTED') read(iun) ch, int |
Use the following assign command to specify foreign record blocking and foreign data formats for character and integer data:
assign -F ibm.vbs -N ibm -C ebcdic fgnfile |
File allocation can be specified with the -n, -c, and -p options to the assign command. The -n option specifies the amount of disk space to reserve at the time of a Fortran open. The -c and -p options specify the configuration of the allocated space, the -c option specifies contiguous allocation, and the -p option specifies striping (the file system partitions where file allocation will be tried) across disk devices.
There is no guarantee that blocks will actually be allocated on the specified partitions. The partlist argument can be one integer, a range of integers (m - n), a set of integers ( m: n), or a combination of ranges and sets separated by colons. The partition numbers are submitted directly through the ialloc system calls. This option achieves file striping on the specified partition.
You cannot specify the -c and -p options without the -n option. The I/O library issues ialloc system calls to preallocate file space and to process the -c and -p attributes. The ialloc system call requires the -n attribute to determine the amount of file space to reserve.
For example, to specify file allocation on partitions 0 through 2, partition 4, and partitions 6 through 8, contiguous allocation in each partition, and a total of 100 4096-byte blocks of file space preallocated, you would enter the following command:
assign -p 0-2:4:6-8 -c -n 100 foo |
The assign -F command has two specifications that alter the device where a file is resident. If you specify -F sds, a file will be SDS-resident; if you specify -F mr, a file will be memory resident. Because the sds and mr flexible file I/O layers do not define a record-based file structure, they must be nested beneath a file structure layer when record blocking is needed.
Examples of device allocation follow:
If unit 1 is a sequential unformatted file that is to be SDS-resident, the following Fortran statements connect the unit:
CALL ASNUNIT(1,'-F cos,sds.scr.novfl:0:100',IER) OPEN(1,FORM='UNFORMATTED') |
The -F cos specification selects COS blocked structure. The sds.scr.novfl:0:100 specification indicates that the file should be SDS-resident, that it will not be kept when it is time to close, and that it can grow in size to one hundred 4096-byte blocks.
If unit 2 is a sequential unformatted file that is to be memory resident, the following Fortran statements connect the unit:
CALL ASNUNIT (2,'-F cos,mr',IER) OPEN(2,FORM='UNFORMATTED') |
The -F cos,mr specification selects COS blocked structure with memory residency.
For more information about device allocation, see Chapter 9.
Fortran unformatted direct-access I/O supports number tuning and memory cache page size (buffer) tuning; it also supports specification of the prevailing direction of file access. The assign -b command specifies the size of each buffer in 4096-byte blocks, and the -u option specifies the number of buffers maintained for the connected file.
To open unit 1 for direct unformatted access and to specify 10 separate regions of the file that will be heavily accessed, use the following assign command:
assign -u 10 u:1 |
The assign -T option activates or suppresses truncation after the writing of a sequential Fortran file. The -T on option specifies truncation; this behavior is consistent with the Fortran standard and is the default setting for most assign -s fs specifications. Use assign -T off to suppress truncation in applications in which GETPOS(3F) and SETPOS(3F) are used to simulate random access to a file that has sequential I/O.
The assign(1) man page lists the default setting of the -T option for each -s fs specification. It also indicates if suppression or truncation is allowed for each of these specifications.
FFIO layers that are specified by using the -F option vary in their support for suppression of truncation with -T off.
The following figure summarizes the available access methods and the default buffer sizes for UNICOS systems.
| Prev Section | Table of Contents | Title Page | Next Section |
| The assign Environment | Up one level | The assign environment file |