This example demonstrates opening a new file for writing some data into the file. Please note that the parameters in brackets are optional.
The close statement has the following syntax −Ĭlose (u) Once done, it should be closed using the close statement. It specifies the length of each record in a direct access file.Īfter the file has been opened, it is accessed by read and write statements. Can have either of the two values FORMATTED or UNFORMATTED. It gives the formatting status of the file. Can have either of the two values, SEQUENTIAL or DIRECT. A scratch file is created and deleted when closed or the program ends. A character string and can have one of the three values NEW, OLD or SCRATCH. It is a label to which the control jumps in case of any error. If the open statement is successful then the ios value returned is zero else a non-zero value. It is the I/O status identifier and should be an integer variable. The unit number u could be any number in the range 9-99 and it indicates the file, you may choose any number but every open file in the program must have a unique number The following table describes the most commonly used specifiers − Sr.No However, the open statement may have a general form − The open command is used to open files for reading or writing. Opening and Closing Filesīefore using a file you must open the file. The OPEN, WRITE, READ and CLOSE statements allow you to achieve this. You can read and write to one or more files. In this chapter you will study file input and output functionalities provided by Fortran.
#Plots in simply fortran how to
In the last chapter, you have seen how to read data from, and write data to the terminal. Fortran allows you to read data from, and write data into files.