Re: noob question re: space delimited input



On Sat, 25 Nov 2006, nichevo@xxxxxxxxx wrote:

I am probably overlooking something very simple. I just don't see what
it is.

I have a test input file that called 'input.txt' containing:
1111 2222 3333
1111. 2222. 3333.

and a program:
...
open (unit=1, file='input.txt')
...
do while (length .NE. maxSize)
read (1, *, IOSTAT=ios) a, b, c
if (ios .EQ. -1) exit
length = length + 1
print*, a, b, c
end do

It reads the appropriate amount of entries before iostat returns '-1'
but my output looks like:
16777216 0 0
37810344 0 0

If I change the the type of a, b, and c to real, I get one wacky real
number and two 0's per line.

It is obviously not reading space delimited. I have been fiddling with
it for way too long now. I would appreciate some advice.

Your program works for me (with "..." removed, so maxSize is probably
set to zero!) using gfortran on linux (Fedora Core 5), so
you could have something odd in the data file or even a buggy compiler.

The input file was 33 bytes, here is a hex dump:

$ od -x input.txt
0000000 3131 3131 3220 3232 2032 3333 3333 310a
0000020 3131 2e31 3220 3232 2e32 3320 3333 2e33
0000040 000a

I tried replacing the spaces with tabs and get the same output, but
other compilers may not be as flexible.

--
George N. White III <aa056@xxxxxxxxxxxxxx>

.