The FMT= specifier in a READ or WRITE statement can give either a line number of a FORMAT statement, an actual format string or a *.
Consider,
WRITE(17,FMT='(2X,2I4,1X,''name '',A7)')i,j,strThis writes out to the file output.dat the three variables i, j and str according to the specified format, ``2 spaces, (2X), 2 integer valued objects of 4 digits with no gaps, (2I4), one space, ( 1X), the string 'name ' and then 7 letters of a character object, (A7)''. The variables are taken from the I/O list at the end of the line. Note the double single quotes (escaped quote) around name. A single " could have been used here instead.
Consider,
READ(14,*) x,y
This reads two values from input.dat using free format and assigns the values to x and y.
Further consider,
WRITE(*,FMT=10) a,b 10 FORMAT('vals',2(F15.6,2X))
The WRITE statement uses the format specified in statement 10 to write to the standard output channel. The format is ``2 instances of: a real valued object spanning 15 columns with an accuracy of 6, decimal places, (F15.6), followed by two spaces (2X)''.
Given,
WRITE(*,FMT=10) -1.05133, 333356.0 WRITE(17,FMT='(2X,2I4,1X,''name '',A7)')11, -195, 'Philip' 10 FORMAT('vals',2(F15.6,2X))
the following is written,
11-195 name Philip -1.051330 333356.000000
Return to corresponding overview page