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:
- Set the runtime option scratch_vars.
- Set an environment variable with a name of the form XLFSCRATCH_unit for each 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/Users/username/data" # Somewhere besides /tmp.
export XLFRTEOPTS XLFSCRATCH_1 XLFSCRATCH_12 XLFSCRATCH_123
Notes:
- The XLFSCRATCH_number variable name must be in uppercase, and number must not have any leading zeros.
- scratch_vars=yes might be only part of the value for the XLFRTEOPTS variable, depending on what other runtime options you have set. See Setting runtime options for other options that might be part of the XLFRTEOPTS value.
- If the scratch_vars runtime 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.