From: angelv on
Hi all,

I have found the following problem with gfortran. A minimal code:

PROGRAM TEST
IMPLICIT NONE

INTEGER :: n, i, dat

READ*, n
DO i = 1,n
READ*, dat
PRINT*, dat
END DO
END PROGRAM TEST

And an input file (note that the file does not end in a newline):

[angelv(a)arce ~/temp]$ cat test.input
3
45
567
8945[angelv(a)arce ~/temp]$

Now, Intel Fortran and PGI have no problems with that, but gfortran
reports and End of file, as it can be seen below. What "should" be the
correct behaviour? Thought of asking here before reporting it as a bug
to gfortran.

Thanks,
Ángel

[angelv(a)arce ~/temp]$ ifort -o test test.f90
[angelv(a)arce ~/temp]$ ./test < test.input
45
567
8945
[angelv(a)arce ~/temp]$ pgf95 -o test test.f90
[angelv(a)arce ~/temp]$ ./test < test.input
45
567
8945
[angelv(a)arce ~/temp]$ gfortran -o test test.f90
[angelv(a)arce ~/temp]$ ./test < test.input
45
567
At line 8 of file test.f90
Fortran runtime error: End of file
[angelv(a)arce ~/temp]$
From: utab on
On Apr 24, 5:05 pm, angelv <txibi...(a)gmail.com> wrote:
> Hi all,
>
> I have found the following problem with gfortran. A minimal code:
>
> PROGRAM TEST
> IMPLICIT NONE
>
> INTEGER :: n, i, dat
>
> READ*, n
> DO i = 1,n
> READ*, dat
> PRINT*, dat
> END DO
> END PROGRAM TEST
>
> And an input file (note that the file does not end in a newline):
>
> [angelv(a)arce ~/temp]$ cat test.input
> 3
> 45
> 567
> 8945[angelv(a)arce ~/temp]$
>
> Now, Intel Fortran and PGI have no problems with that, but gfortran
> reports and End of file, as it can be seen below. What "should" be the
> correct behaviour? Thought of asking here before reporting it as a bug
> to gfortran.
>
> Thanks,
> Ángel
>
> [angelv(a)arce ~/temp]$ ifort -o test test.f90
> [angelv(a)arce ~/temp]$ ./test < test.input
> 45
> 567
> 8945
> [angelv(a)arce ~/temp]$ pgf95 -o test test.f90
> [angelv(a)arce ~/temp]$ ./test < test.input
> 45
> 567
> 8945
> [angelv(a)arce ~/temp]$ gfortran -o test test.f90
> [angelv(a)arce ~/temp]$ ./test < test.input
> 45
> 567
> At line 8 of file test.f90
> Fortran runtime error: End of file
> [angelv(a)arce ~/temp]$

Hey,

Are you sure of that, on my machine it seems perfectly OK

06:56 PM utab(a)PMA-05-013 ~ $ gfortran for.f90
06:56 PM utab(a)PMA-05-013 ~ $ vi dat
06:57 PM utab(a)PMA-05-013 ~ $ ./a.out <dat
45
567
8945

Rgds,
From: utab on
On Apr 24, 6:59 pm, utab <umut.ta...(a)gmail.com> wrote:
> On Apr 24, 5:05 pm, angelv <txibi...(a)gmail.com> wrote:
>
>
>
> > Hi all,
>
> > I have found the following problem with gfortran. A minimal code:
>
> > PROGRAM TEST
> > IMPLICIT NONE
>
> > INTEGER :: n, i, dat
>
> > READ*, n
> > DO i = 1,n
> > READ*, dat
> > PRINT*, dat
> > END DO
> > END PROGRAM TEST
>
> > And an input file (note that the file does not end in a newline):
>
> > [angelv(a)arce ~/temp]$ cat test.input
> > 3
> > 45
> > 567
> > 8945[angelv(a)arce ~/temp]$
>
> > Now, Intel Fortran and PGI have no problems with that, but gfortran
> > reports and End of file, as it can be seen below. What "should" be the
> > correct behaviour? Thought of asking here before reporting it as a bug
> > to gfortran.
>
> > Thanks,
> > Ángel
>
> > [angelv(a)arce ~/temp]$ ifort -o test test.f90
> > [angelv(a)arce ~/temp]$ ./test < test.input
> > 45
> > 567
> > 8945
> > [angelv(a)arce ~/temp]$ pgf95 -o test test.f90
> > [angelv(a)arce ~/temp]$ ./test < test.input
> > 45
> > 567
> > 8945
> > [angelv(a)arce ~/temp]$ gfortran -o test test.f90
> > [angelv(a)arce ~/temp]$ ./test < test.input
> > 45
> > 567
> > At line 8 of file test.f90
> > Fortran runtime error: End of file
> > [angelv(a)arce ~/temp]$
>
> Hey,
>
> Are you sure of that, on my machine it seems perfectly OK
>
> 06:56 PM utab(a)PMA-05-013 ~ $ gfortran for.f90
> 06:56 PM utab(a)PMA-05-013 ~ $ vi dat
> 06:57 PM utab(a)PMA-05-013 ~ $ ./a.out <dat
> 45
> 567
> 8945
>
> Rgds,

And my version is
GNU Fortran 95 (GCC) 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)

From: glen herrmannsfeldt on
angelv wrote:
(snip)

> And an input file (note that the file does not end in a newline):

Your input file is defective, so that either answer is right.

-- glen

From: Ron Shepard on
In article
<9db8499d-d05b-4ca5-9b6b-bbf8422ba231(a)59g2000hsb.googlegroups.com>,
angelv <txibilis(a)gmail.com> wrote:

> Now, Intel Fortran and PGI have no problems with that, but gfortran
> reports and End of file, as it can be seen below. What "should" be the
> correct behaviour?

It is up to the compiler to handle it the way it wants. Many people
prefer the way gfortran works in this case, and they think that the
other way is inconvenient because it does not identify the
incorrectly terminated record in the input file.

$.02 -Ron Shepard