Fortran

Guide To Learn

New Fortran elements, at a glance

  • readprint, and write–Statements for reading and writing data to files on disk or standard streams, such as standard input, output, or error
  • Format strings –For formatting values of any built-in data type into text.
  • openclose, and inquire–Statements to open, close, and get information about a file, respectively
  • trim–A built-in function that returns the input character string without any trailing blanks

Summary

  • Six core syntax elements provide most of Fortran’s I/O functionality: readprintwriteopenclose, and inquire.
  • Use read and write for input and output of any data, respectively.
  • You can access standard input, output, and error streams from the iso_fortran _env module as input_unitoutput_unit, and error_unit.
  • Fortran I/O units are unique integer identifiers that let you access standard streams and files on disk that you work with, akin to file handles in other programming languages. Use them in your code to write to standard streams in a portable way.
  • Use format strings to convert numbers and other non-text data into text. For example, i3 formats an integer into text with width 3, whereas f5.2 will format a real number into text with a total width of 5 and a width of 2 for the fractional part.
  • You can use the open statement to open existing or new files, as well as to redirect output from standard streams to files on disk.
  • You can use the inquire statement to get information about a file, including whether the file is open or not.
New Fortran elements, at a glance

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to top