This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
G77 bug ? or is this by design ?
- To: gcc-bugs at gcc dot gnu dot org
- Subject: G77 bug ? or is this by design ?
- From: Yuen Keong Ng <ykng at xs4all dot nl>
- Date: Mon, 14 Aug 2000 00:33:48 +0200
- Organization: TNO - Institute of Applied Physics
- Reply-To: ykng at xs4all dot nl
Dear Sir,
I am using the g77 fortran compiler and for a recent
project I have to read/access binary output files,
which are produced by another project.
An easy way of coding it appeared to buffer the I/O
through a character string by an inline read statement,
i.e. READ(string,'(A4)') value
This works fine for almost all values, except those
where a '0A'X value in one of the bytes of value
is encountered. In that case the byte(character)
returned is an ASCII SPC ('20'X).
Is this a bug ? Or is this actual by design?
In the latter case it might be sensible to add something
like the (bad) example code attached to this mail in
the G77 manual with an explanation why it shouldn't
be used.
Finally I want to know if there is a format specification
which properly handles a formatted binary read?
with kind regards,
Yuen Keong Ng
-----------------------------------------------------------------
_/ _/_/ _/ _/_/ _/ _/_/ _/_/_/
_/ _/ _/ _/ _/_/ _/ _/
_/ _/ _/ _/ _/ _/ _/ _/
_/ _/_/ _/ _/ _/ _/ _/_/_/
_/ _/ _/ _/ _/_/ _/ _/
_/_/ _/ _/_/ _/ _/ _/_/ _/ _/_/_/
^_*
TNO TPD E-mail: ykng@tpd.tno.nl
P.O. Box 155 *_^ Phone : +31 (15) 269 2082
2600 AD Delft FaX : +31 (15) 269 2111
THE NETHERLANDS ^_* Home : +31 (20) 6422 399
program ontrial
implicit none
character*4 inlinestream
integer*4 number,ntrial,nequ
equivalence (nequ,inlinestream(1:1))
number='0a'X
C --- here I do an inline write of number
write(*,*) 'number=',number
write(inlinestream,'(A4)') number
C --- here I read-back the number, but it is recognized as a CR character
C --- and a get an ASCII SPC ('20'X) instead
read(inlinestream,'(A4)') ntrial
write(*,*) 'read-back number =',ntrial,
+ ', however EQUIVALENCED number =',nequ
write(*,*) 'read-back number - EQUIVALENCED number =',ntrial-nequ
C --- is this behaviour by design or is this a bug?
end