[UP]


Manual Reference Pages  - scratch (3)

NAME

scratch(3f) - [M_io] Return the name of a scratch file (LICENSE:MIT)

CONTENTS

Synopsis
Description
Options
Example
Author
License

SYNOPSIS

function scratch(prefix) result(tname)

character(len=:),allocatable :: tname character(len=*),intent(in),optional :: prefix

DESCRIPTION

Fortran supports non-retainable scratch files via OPEN(STATUS=’SCRATCH’,... . There are circumstances where a file with a unique name is required instead. Specifying the pathname of a file can be required for performance reasons, file space limitations, or to support the ability for other processes or subprocesses to access the file.

SCRATCH(3f) Return the name of a scratch file in the scratch directory set by the most common environment variables used to designate a scratch directory.

$TMPDIR is the canonical environment variable in Unix and POSIX[1] used to specify a temporary directory for scratch space. If $TMPDIR is not set, $TEMP, $TEMPDIR, and $TMP are examined in that order. If nothing is set "/tmp/" is used.

OPTIONS

prefix an optional prefix for the leaf of the filename. A suffix created by genuuid(3) is used to make the name unique.

The default prefix is the basename of the program that called the procedure (the name trimmed of anything from the right-most period in the name to the end of the name)..

EXAMPLE

Sample:

    program demo_scratch
    use M_io, only : scratch
    implicit none
    write(*,*)’find good scratch file name candidates; one should test if writable’
    write(*,*)scratch(’JUNK:’)
    write(*,*)scratch(’’)
    write(*,*)scratch()
    end program demo_scratch
Results:

    find good scratch file name candidates; one should test if writable
    /cygdrive/c/Users/JSU/AppData/Local/Temp/JUNK:8462159a-2ca8-4961-7ff1-2ff4f9ebaca4
    /cygdrive/c/Users/JSU/AppData/Local/Temp/f7585e37-8557-4f25-777d-29abb6ffb981
    /cygdrive/c/Users/JSU/AppData/Local/Temp/demo_scratch-ec470965-42be-4ba6-4193-0f25cf2fa26c

AUTHOR

John S. Urban

LICENSE

MIT License


scratch (3) November 13, 2019
Generated by manServer 1.08 from 1d8d6cf2-74f1-4375-8471-fc2aa3f20f7f using man macros.