Arjen Markus wrote:
>> >Using mkstemp is certainly safer but I was unable to call it from a FORTRAN program (mktemp, on the contrary is easy to call).
> Calling it should be easy enough, but the result is a file descriptor,
> which is meaningless in Fortran. You would need a way to translate the
> C-style file descriptor to a Fortran-style LU-number.
How about:
OPEN(..., status='scratch')
That's more portable and simpler than calling mktemp manually.
In case of gfortran, it calls internally mkstemp (if available) or
mktemp. (For the latter it checks whether the file already exists and
takes care of the 26-files limit per thread (and template pattern),
which e.g. Windows' mktemp has.)
It only gets difficult if the temporary file should be kept after
exiting the program - or if the file descriptor has to be passed to a C
function. [For the latter, some compilers have a vendor intrinsic to
convert it to a descriptor, e.g. FNUM(unit).]
Tobias