Xiaogang Wang writes:
> How can I make a directory in fortran?
You can't in standard Fortran. (For that matter, you can't in
standard most other languages either). Fortran has no concept
of a directory.
You will need to use something platform-specific. Your compiler might
provide something compiler-specific. Or you can find a system
interface for this and figure out how to call it from Fortran.
Probably the closest to portable is to call a procedure to invoke
a system shell with the appropriate shell command. The appropriate
shell command is system-dependent, but only a few possibilities
suffice for most systems you will likely see. The procedure to
invoke a system command is nonstandard and varies from compiler to
compiler, but almost all compilers have one - more than have
a "delete file" procedure.
> How can I delete a file in fortran?
> One clumsy way I can think of is to open the file, rewind, and close.
> The file is still there but has lenght 0.
No, a rewind does not cause the file to have zero length. A
rewind just positions the file, it doesn't change it.
Review the syntax of the close statement. It has a delete option.
That's the best you can do in standard Fortran.
Note that it isn't perfect. You do have to be able to sucessfully
open the file. In some cases, that may be difficult if you don't
know the file's characteristics (such as whether it is formatted
or unormatted, or even a non-Fortran file).
More reliable is to do something system-dependent (with the
same possibilities as fro your first question). Though if you
know enough about the file to be able to open it, the trick
of open an dthen close with delete should work ok.
--
Richard Maine | Good judgment comes from experience;
[log in to unmask] | experience comes from bad judgment.
| -- Mark Twain
|