Consider the following little Fortran test program called prog.f:
program readtest
implicit none
character*80 c_text
real value
integer len
c_text = 'i'
len = len_trim(c_text)
read(c_text(:len),*,err=20) value
ccc read(c_text,*,err=20) value
ccc read(c_text,'(F9.3)',err=20) value
print *,'successfully decoded c_text=i'
print *,'should never reach this line'
stop
20 print *,'failed to decode c_text=i'
print *,'should always reach this line'
stop
end program
If this code is compiled with a recent gfortran version, it will fail with
the following error (example here OS 11.3, 64-bit[*] but the same happens
on RHEL6):
$> gfortran -O2 -Wall -g prog.f
$> a.out
At line 8 of file prog.f
Fortran runtime error: End of file
If the code is compiled with an old(er) version of gfortran, or if the
code is compiled with the Intel compiler, it will work:
$> ifort -O2 -warn all -g prog.f
$> a.out
failed to decode c_text=i
should always reach this line
Bug or feature or stupid mistake on my side?
Regards,
Thomas
[*] GNU Fortran (SUSE Linux) 4.5.0 20100604 [gcc-4_5-branch revision
160292]
--
To unsubscribe, e-mail: opensuse-programming+unsubscribe(a)opensuse.org
For additional commands, e-mail: opensuse-programming+help(a)opensuse.org