Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Reading data with Tabs

genberg
Beginner
748 Views
My compiler is: Compact Fortran 6.6
I am trying to read data from a file which MAY or MAY NOT include
Tabs. The source below works in Absoft fortran but fails in Compact Fortran with "input conversion error"
SOURCE CODE:
open(unit=11,name='junk.bdf',type='old')
open(unit=21,name='junk.out',type='new')
100 continue
read(11,20) id,icp,x1,x2,x3,icd
20 format(bn,8x,i8,i8,f8.3,f8.3,f8.3,i8)
write(21,21) id,icp,x1,x2,x3,icd
21 format('GRID',4x,i8,i8,3f8.4,i8)
go to 100
stop
end
DATA FILE: (line 3 includes TABS and fails)
GRID 101 3 100. 3. 0.0 2
GRID 102 3 100. 4. 0.0 2
GRID 103 3 100. 5. 0.0 2
0 Kudos
3 Replies
TimP
Honored Contributor III
748 Views
I set it up to run the file through the expand program before Fortran sees it. This may not be to your taste, but you don't give any indication what constraints you intend to put on the solution.
0 Kudos
genberg
Beginner
748 Views
tim18-
Thanks for the reply. You mention the "expand" program.
What is that? How can I access it?

The files I want to read may be quite large. Tabs may or may not be sprinkled thoughout the data.

Thanks.
0 Kudos
TimP
Honored Contributor III
748 Views
I would use cygwin expand. http://www.cygwin.com/ Don't recall which installation option brings it in (textutils?), but that site tells you how to look it up. Evidently, the same program is included in MKS toolkit, and maybe in SFU.
I haven't looked to see whether it would be easy to build the official expand source with a lowest-common-denominator C compiler environment. No doubt, it could be done in Fortran too, by reading the line as a CHARACTER string, and expanding the string. I'm sure I haven't covered all the possibilities, some of which must have occurred to you.
0 Kudos
Reply