Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
certik opened this issue Jan 27, 2020 · 6 comments
Open

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

certik opened this issue Jan 27, 2020 · 6 comments
Labels
topic: IO Common input/output related features

Comments

@certik
Copy link
Member

certik commented Jan 27, 2020

Other languages:

@epagone
Copy link

epagone commented Jan 27, 2020

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

@certik
Copy link
Member Author

certik commented Jan 27, 2020

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

@urbanjost
Copy link

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
Copy link
Member Author

certik commented Jan 28, 2020

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

@jvdp1
Copy link
Member

jvdp1 commented Jan 28, 2020

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
Copy link
Member Author

certik commented Jan 28, 2020

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.

@awvwgk awvwgk added the topic: IO Common input/output related features label Sep 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: IO Common input/output related features
Projects
None yet
Development

No branches or pull requests

5 participants