Fortran

Guide To Learn

Core elements of Fortran

Exercise: Redirect stdout and stderr to files

Let’s redirect output to standard output and error channels into their respective files from within the Fortran program. Why would you want to do this? For some applications that run for a long time, such as large weather and ocean prediction models that can run for days, it’s useful to write standard output and error […]

Opening files in read-only or write-only mode

Sooner or later, you’ll run across files that are meant to be used as read-only; for example, important satellite data that shouldn’t be overwritten. Similarly, some files will be useful only in write-only mode, such as the quick notes that we’ve been working on in this section. Fortran allows you to open a file in […]

Opening a file and writing to it

The first step involves getting the filename as a command-line argument, opening the file for writing, and allowing the user to write into it. To implement this is relatively straightforward but will require quite a few new language elements. Let’s take a look at the complete program first, as shown in the following listing. Listing […]

Scroll to top