XL Fortran for AIX 8.1

User's Guide


Choosing Locations and Names for Input/Output Files

If you need to override the default locations and names for input/output files, you can use the following methods without making any changes to the source code.

Naming Files That Are Connected with No Explicit Name

To give a specific name to a file that would usually have a name of the form fort.unit, you must set the run-time option unit_vars and then set an environment variable with a name of the form XLFUNIT_unit for each scratch file.

The association is between a unit number in the Fortran program and a path name in the file system.

For example, suppose that the Fortran program contains the following statements:

      OPEN (UNIT=1, FORM='FORMATTED', ACCESS='SEQUENTIAL', RECL=1024)
      ...
      OPEN (UNIT=12, FORM='UNFORMATTED', ACCESS='DIRECT', RECL=131072)
      ...
      OPEN (UNIT=123, FORM='UNFORMATTED', ACCESS='SEQUENTIAL', RECL=997)

XLFRTEOPTS="unit_vars=yes"     # Allow overriding default names.
XLFUNIT_1="/tmp/molecules.dat" # Use this named file.
XLFUNIT_12="../data/scratch"   # Relative to current directory.
XLFUNIT_123="/home/user/data"  # Somewhere besides /tmp.
export XLFRTEOPTS XLFUNIT_1 XLFUNIT_12 XLFUNIT_123

Notes:

  1. The XLFUNIT_number variable name must be in uppercase, and number must not have any leading zeros.
  2. unit_vars=yes might be only part of the value for the XLFRTEOPTS variable, depending on what other run-time options you have set. See Setting Run-Time Options for other options that might be part of the XLFRTEOPTS value.
  3. If the unit_vars run-time option is set to no or is undefined or if the applicable XLFUNIT_number variable is not set when the program is run, the program uses a default name (fort.unit) for the file and puts it in the current directory.

Naming Scratch Files

To place all scratch files in a particular directory, set the TMPDIR environment variable to the name of the directory. The program then opens the scratch files in this directory. You might need to do this if your /tmp directory is too small to hold the scratch files.

To give a specific name to a scratch file, you must do the following:

  1. Set the run-time option scratch_vars.
  2. Set an environment variable with a name of the form XLFSCRATCH_unit for each scratch file.

The association is between a unit number in the Fortran program and a path name in the file system. In this case, the TMPDIR variable does not affect the location of the scratch file.

For example, suppose that the Fortran program contains the following statements:

      OPEN (UNIT=1, STATUS='SCRATCH', &
            FORM='FORMATTED', ACCESS='SEQUENTIAL', RECL=1024)
      ...
      OPEN (UNIT=12, STATUS='SCRATCH', &
            FORM='UNFORMATTED', ACCESS='DIRECT', RECL=131072)
      ...
      OPEN (UNIT=123, STATUS='SCRATCH', &
            FORM='UNFORMATTED', ACCESS='SEQUENTIAL', RECL=997)

XLFRTEOPTS="scratch_vars=yes"     # Turn on scratch file naming.
XLFSCRATCH_1="/tmp/molecules.dat" # Use this named file.
XLFSCRATCH_12="../data/scratch"   # Relative to current directory.
XLFSCRATCH_123="/home/user/data"  # Somewhere besides /tmp.
export XLFRTEOPTS XLFSCRATCH_1 XLFSCRATCH_12 XLFSCRATCH_123

Notes:

  1. The XLFSCRATCH_number variable name must be in uppercase, and number must not have any leading zeros.
  2. scratch_vars=yes might be only part of the value for the XLFRTEOPTS variable, depending on what other run-time options you have set. See Setting Run-Time Options for other options that might be part of the XLFRTEOPTS value.
  3. If the scratch_vars run-time option is set to no or is undefined or if the applicable XLFSCRATCH_number variable is not set when the program is run, the program chooses a unique file name for the scratch file and puts it in the directory named by the TMPDIR variable or in the /tmp directory if the TMPDIR variable is not set.


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]