Fortran read last line from file

broken image
broken image

2.1.1 Accessing Named Files The OPEN statement's FILE= specifier establishes the association of a logical unit to a named, physical file at runtime. A Fortran logical unit can be associated with a specific, named file through the OPEN statement.Īlso, certain preconnected units are automatically associated with specific files at the start of program execution.

broken image

The asterisk stands for standard input file when it appears in a READ statement it stands for standard output file when it appears in a WRITE or PRINT statement.

broken image

The character * can appear as a logical unit identifier. Logical units are identified in an I/O statement by a logical unit number, a nonnegative integer from 0 to the maximum 4-byte integer value (2,147,483,647). The output of the below code is 1 rarther than 7 (look up.Ģ.1 Accessing Files From Within Fortran Programs Data is transferred between the program and devices or files through a Fortran logical unit. The first part (lines 1-12) of the code is defining the function and the second part (lines 14-19) is where I call the function in a program. The below piece of code is my attempt to build a function that takes in the filename 'data.txt' and produces the number of lines of the file.