Skip to content

Functions to open a temporary file (temporary directory) #126

Open
@certik

Description

@certik
Member

Other languages:

Activity

epagone

epagone commented on Jan 27, 2020

@epagone

I might be missing something obvious, but why can't we just use open(status='SCRATCH',...)?

certik

certik commented on Jan 27, 2020

@certik
MemberAuthor

We could. I haven't thought of that as an option.

urbanjost

urbanjost commented on Jan 28, 2020

@urbanjost

There are some similiar routines described in
M_io and M_io.f90 and M_path.f90 in GPF. There are seperate routines for a true status='scratch' file and a unique scratchfile name; and a discussion of the pros and cons of how status='scratch' is implemented (there is a big variation in implementations) at wiki that brings up a few relevant points about how depending on status='scratch' has pitfalls because of bad implementations. I really like the idea of making a scratch directory, especially if it was cleaned up automatically like a scratch file should be; I do not have anything like that. The python implementation does not clean up at termination automatically.

certik

certik commented on Jan 28, 2020

@certik
MemberAuthor

Python's mkdtemp does not clean up, but TemporaryDirectory does.

jvdp1

jvdp1 commented on Jan 28, 2020

@jvdp1
Member

I really like the idea of making a scratch directory, especially if it was cleaned up automatically like a scratch file should be; I do not have anything like that.

@urbanjost: I like this idea too. Would it be possible with derived types and a final procedure?

certik

certik commented on Jan 28, 2020

@certik
MemberAuthor

Yes, we should use a derived type with a finalizer for this. I updated the issue description with links to temporary files and directories implementation in Python, Rust and Julia.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic: IOCommon input/output related features

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @certik@jvdp1@epagone@awvwgk@urbanjost

        Issue actions

          Functions to open a temporary file (temporary directory) · Issue #126 · fortran-lang/stdlib