f90_preconn_io: Automatic File Preconnection Module

Table of Contents

1 Name

f90_preconn_io — Module controlling automatic file preconnection

2 Usage

USE F90_PRECONN_IO

3 Synopsis

Generic Procedures
GET_PCIO_OPTIONS, IOINIT.

4 Procedure Descriptions

Note that in the descriptions below, LOGICAL(*) means any kind of LOGICAL. Also, note that although the VERBOSE argument is an optional argument, the actual argument is not permitted to be a non-present optional dummy argument.

SUBROUTINE GET_PCIO_OPTIONS(BLANK,POSITION,PREFIX,VERBOSE)
CHARACTER(*),OPTIONAL,INTENT(OUT) :: BLANK,POSITION,PREFIX
LOGICAL(*),OPTIONAL,INTENT(OUT) :: VERBOSE

Returns the current settings for file preconnection; the meanings for these settings are described under the IOINIT routine. Both the BLANK and POSITION values are returned in upper case, even if lower case was used in a call to IOINIT to set them.

SUBROUTINE IOINIT(BLANK,POSITION,PREFIX,VERBOSE)
CHARACTER(*),OPTIONAL,INTENT(IN) :: BLANK,POSITION,PREFIX
LOGICAL(*),OPTIONAL,INTENT(IN) :: VERBOSE

This procedure controls automatic file preconnection. Files can be automatically preconnected when a logical unit is initially referenced without an OPEN statement; preconnection does not occur again after file CLOSE.

The name of the file to be preconnected is determined first by searching for an environment variable of the form FORTnn where nn is the two-digit logical unit number; e.g. FORT03. If this environment variable is found its value is used as the filename; otherwise the name “fort.n” is used; e.g. ‘fort.3’. The file is opened either with FORM='FORMATTED' or FORM='UNFORMATTED' depending on whether the initial reference is with a formatted or unformatted i/o statement.

The BLANK and POSITION arguments control the BLANK= and POSITION= keywords in the implied OPEN statement when the file is preconnected; initially these are set to BLANK='NULL' and POSITION='REWIND'. Note that these have no meaning (and no effect) for unformatted files.

The PREFIX argument changes the prefix used to find the environment variable containing the preconnected file name. Initially this is ‘FORT’. Only the first 30 characters of PREFIX are used.

The VERBOSE argument controls activity reporting; if it is .TRUE., subsequent preconnection activity will produce informative messages on the standard error unit.

5 Example

   USE F90_PRECONN_IO
   CALL IOINIT(BLANK='ZERO',PREFIX='MYFILE')
   READ (99,10) I,J,K,L,M
10 FORMAT(I3,I1,I3,I1,I3)
When the READ statement is executed, the environment variable MYFILE99 is interrogated to discover which file is to be automatically preconnected to unit 99. The unit will be connected with BLANK='ZERO'. If no environment variable is found the file ‘fort.99’ will be opened.

6 See Also

nag_modules(3), nagfor(1).

7 Bugs

Please report any bugs found to ‘support@nag.co.uk’ or ‘support@nag.com’, along with any suggestions for improvements.