This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/31614] New: Inability to read ascii text with generic 'f' format
- From: "Catherine dot M dot Moroney at jpl dot nasa dot gov" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 17 Apr 2007 23:39:05 -0000
- Subject: [Bug fortran/31614] New: Inability to read ascii text with generic 'f' format
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
I have a text file that I want to read, consisting of some text, integers and
floats. I'm
not able to get the code to compile without exactly specifying the width and
number
of decimal places for the ints and floats.
Ideally, I would like to be able to write a line of code like:
read(10,'(10x, f, f)') and have it compile and correctly read in the
data. Instead, I find that I have to exactly specify both the field
width and number of decimal places "read(10,'(10x, e13.9, f10.5))".
I've got some very large text files with irregular formattting, and it
would be very nice if I could just specify (10x,f,f) as my formatting
statement. Is this possible in gfortran?
And, can I attach files when filing a bug report?
Sample text file:
solzen= 0.0000000E+00 10.00000
All Wind Speeds
alb,xindx,imin,frac,aeropt = 6.761 0.023 11 100.0
0.19440E+00
1.8679 1.8538 1.8439 1.8197 1.7722 1.7360 1.7019
1.6785 1.6615 1.6644
1.6870 1.6701 1.6074 1.5229 1.4210 1.3474 1.2725
1.2308 1.2161 1.2165
Sample code:
PROGRAM fread
implicit none
character(len=200) :: flname, chjunk, chformat
real :: sza_low, sza_upp
integer :: istat
flname="data.txt"
open(10, file=flname, form='formatted', access='sequential', &
action='read', pad='yes', status='old')
read(10,'(12x, e13.9, f11.5)', iostat=istat) sza_low, sza_upp
! read(10,'(A11, e13.9, f11.5)',iostat=istat) chjunk2, sza_low, sza_upp
! read(10,'(A11, f13.9, f11.5)',iostat=istat) chjunk2, sza_low, sza_upp
write(*,*) istat
write(*,*) chjunk
write(*,*) sza_low
write(*,*) sza_upp
END PROGRAM fread
--
Summary: Inability to read ascii text with generic 'f' format
Product: gcc
Version: 4.1.1
Status: UNCONFIRMED
Severity: minor
Priority: P3
Component: fortran
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: Catherine dot M dot Moroney at jpl dot nasa dot gov
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31614