This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: gfortran I/O issues.


Hi,

I thought the "," was a separator and the read should stop for that
integer and go on to the next.

I think ifort must treat this as legal (the test case is derived from
code supplied by a customer of mine who uses ifort).  I'll ask what
version he uses (probably 10).  Maybe the compiler got stricter?

About the extra line in gfortran 4.1/4.2, ifort 11, sunf95 and openf95
it looks like the string is parsed as three comma delimited integers
then it prints the results and THEN goes to the error message which
seems strange in itself.

Later gfortrans (4.3, 4.4) will happily do the same parsing and printing
if the ierr flag is removed.  So something somewhere must be recognizing
the comma as a separator.  Perhaps if is not standard it gets flagged as
an error?  If so is there any way to relax this interpretation then?

Thanks,

Ed

-----Original Message-----
From: Tobias Burnus [mailto:burnus@net-b.de] 
Sent: Thursday, January 22, 2009 2:26 PM
To: Smith-Rowland, Edward M
Cc: 3dw4rd@verizon.net; fortran@gcc.gnu.org
Subject: Re: gfortran I/O issues.


Hi,

Smith-Rowland, Edward M wrote:
> I think there is a bug in gfortran where an error is flagged for this 
> example. I'm just reading a comma delimited string into a size 3 
> array.
>   
I believe the error message is OK, but I leave it to our experts to
check the standard.

 * * *

I get with gfortran 4.3/4.4, NAG f95  5.1, g95, pathscale 3.1, pgf95 7.1
the same output (modulo a few spaces):

 0 0 0
 line =  255,255,255
 Error

while gfortran 4.1/4.2, ifort 11, sunf95 and openf95 print:

 0 0 0
 line =  255,255,255
 255 255 255   <<<<<<<<<< Note the extra line.
 Error


Without 'err=1' one gets the run-time error messages:

gfortran 4.3/4.4: Fortran runtime error: Bad value during integer read
NAG f95: Invalid character in integer input field
g95: Fortran runtime error: Bad value during integer read
pgi: PGFIO-F-217/formatted read/internal file/attempt to read past end
of file.
pathf95:   A READ operation tried to read past the end-of-file.


I think it is OK to give an error when reading the string:

' 255,255,255 '
 1234567890123

using the format '(3I12)'. Using I12 one grabs " 255,255,255" which I
would regard as strange integer string. (What is the meaning of "," in
an integer?)

However, I might miss something and the "," is regarded as separator
even in this case and it overrules the "I12". Jerry, what do you think?

Tobias


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]