Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

READ statement

schyn
Beginner
740 Views

I have a problem with the READ statement. Here it is.

If INCARD is '3 ', ASURCH will be '3 ' thru the READ statement below.

CHARACTER*3 INCHARD

INCARD = '3 '

READ (INCARD, 100, ERR=9000) ASURCH

100 FORMAT (BZ, A3)

Later, if I make another READ statement below to make ASURCH into a REAL number (F3.2), I will not get '3.0' but '0.02999999' instead. Why?

READ(ASURCH, 130) SURCHR

130 FORMAT(F3.2)

Please help.

0 Kudos
2 Replies
Steven_L_Intel1
Employee
740 Views
You're getting .03 read in. Since there's no BZ in the 130 format, the default is BN and blanks are ignored. So you effectively have 'bb3' (where b is blank) and a F3.2 reads that as .03. By the way, BZ is meaningless for an A format.
0 Kudos
schyn
Beginner
740 Views

'BZ' was the problem. Thanks for the help.

0 Kudos
Reply