Topic: Where are Read/Write files live?

I understand the Read and write statements as far as how they specify the keyboard/monitor or an external file as the in/out recipient. But where do you specify where - what folder - the file is located? Is it a given that the file you are trying to read or write to is in the same location as the executable? Similarily, I wonder about “Print” - does it go so the system default printer with it’s default parameters. I’m so use do dialog boxes to specify those locations, which printer (with attributes like 2 sided, etc.).

So I see how it can read something like “MyData.txt” but where does MyData.txt live?

Re: Where are Read/Write files live?

I responded to this via email too a few moments ago.  Basically, you'll want to use OPEN statements to actually access files.  These files, by default, will be opened in the current working directory of your program.  In Simply Fortran, this is the same directory as the executable and/or project file is located.  This can be changed, but that's the default.

The Print statement is merely a shortcut for writing to the screen.  The following are equivalent:

WRITE(*,*) "I am writing to the screen"


PRINT *, "I am writing to the screen"

The Print statement can't be used to write to files, only the standard output.

Writing to a printer is far too complex, and there is no quick and easy way to do so.  It would require non-portable operating system calls.  Furthermore, modern printers have no good way to deal with Fortran's "line-by-line" output style any longer.  It's best to write to a file and subsequently print that file.

Jeff Armstrong
Approximatrix, LLC