Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

format file

Status
Not open for further replies.

bobo12

Programmer
Dec 26, 2004
74
US
suppose FMAT is ,Character*127 FMAT

OPEN (10,FILE='NEWT',STATUS='NEW')
WRITE (10,'(A)') FMAT
CLOSE (10)

so what's the point of writing the first element of FMAT to a file? is this a control character?
or is it writing the whole 127 characters of FMAT?

fortran 77
 
An A by itself will print the whole string like a %s in C. A followed by a number will print that number of characters from the string. For example A5 is the same as %5s. The equivalent of %c is A1

Also note that format statements in Fortran are not the same as those in C. In Fortran, the output is driven by the data: in C it is driven by the format.

Code:
printf ("%d %d\n", a, b, c, d, e);

write (*, '(I5 I5)') a, b, c, d, e
The C coding will only print the values of a and b. The Fortran coding will print the value of a and b on one line, c and d on the next line, and e on the next line.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top