- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I inadvertently executed an implicit unformatted write to a specific unit number in a FORTRAN program (I neglected to open the file first). The documentation states that a file named fort.n, where n is the unit number, will be generated in such cases (or depending on project settings I can be prompted for a file to use). Neither of these is happening. What I'm seeing instead is that another file I've opened for read access and subsequently closed is being overwritten by the unformatted data. This file happens to be listed as a command line argument. After some experimentation I've determined that if I have any files listed as command line arguments, one of them will be overwritten by the unformatted data (sometimes the first, sometimes the second, depending on where I do the implicit write in my code). If I have none listed, them I'm prompted for a file name. Can anyone explain this?
Thanks,
Steve
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Since Fortran programs traditionally did not process command line arguments (in fact, before Fortran 2003, one had to call compiler-specific subroutines/functions even to obtain command line arguments), there is something in the source code beyond what you have written. Without having lines of code that obtain the command line arguments, there is no obvious way for your program to perform differently with no arguments as compared to running with one or more arguments.
What you are seeing may be the result of taking a program which connected files to unit numbers based on command line arguments, and putting some additional file I/O which does not adhere to the original assumptions.
You may put in a number of INQUIRE statements to understand what is happening to the file status at various points in the program.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The prompt comes from the /fpscomp:filesfromcmd option when you open a file with an empty filename.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Regards,
Arjen
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Steve

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page