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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Format for Reading in Real Numbers

Status
Not open for further replies.

scftw7

Programmer
Feb 17, 2011
4
US
Hi,

I'm trying to read in from a text file the following sequence

100 A B -5585577.906775479

I've tried reading it using the following format:
10 FORMAT(I3,1X,A1,1X,A1,1X,F10.10)

and writing it using the following command:
READ(2,10) A,B,C,D
WRITE(*,10) A,B,C,D

However, upon output, it gives the following:


100 A B **********

Why is it doing this? Thank you

 
Because your floating point format is incorrect. It should be F20.10. Alternatively, use G format G20.10.
 
Okay, I tried F20.10, and it printed out the following:

318772740 A E -5585578.0000000000 ********** **********

It can't seem to read in the digits to the right of the decimal point.
 
Sorry, for the example above, it printed the following:

100 A B -5585578.0000000000
 
It can't seem to read in the digits to the right of the decimal point.

because the variable D has certainly been declared REAL (this is the default). A real variable is usually a 32bit value which corresponds to a maximum of 7 significant digits. Try DOUBLE PRECISION instead...

François Jacq
 
Thanks, the double precision did the trick
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top