Re: noob question re: space delimited input



Thanks George, dpb, and Richard. I also appreciate the tips on style
and good practice.

I have tried everything you guys suggested, still no go, it must be
something to do with the compiler or maybe the dos shell I am running
it in. My actual program had most everything initialized since it is
part of a subroutine. I am going to try with a different compiler, any
suggestions?

Thanks again guys.

George N. White III wrote:
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>

.



Relevant Pages

  • Re: Ten Commandments (On Topic!)
    ... group can be different from compiler to compiler whereas `parsers' can be written in 100% portable fortran. ... one can use NAMELIST strictly for the user-prepared part of the input file since that is where it is very useful. ... to correctly transfer the data from the input file to the variables). ...
    (comp.lang.fortran)
  • Re: COBOL compiler written in COBOL
    ... >back then (systems analyst) but you rang a bell mentioning the GEORGE ... The code for each instruction calls READ-WORD as needed and generates ... see it's easy - anyone could write a compiler in COBOL:) ...
    (comp.lang.cobol)
  • Language lawyer interpretation needed
    ... OpenWatcom v1.2 F77 compiler is being checked against the NIST test suite. ... they carry the proper input in comments, so I was able to construct an input file ... With the source file and the input file "changed" to avoid tab replacement, ...
    (comp.lang.fortran)
  • Re: probable FAQ that I dont know where to find
    ... >> I have a PIC project, and I am new to PICs. ... designing the software for a 16F controller; ... C18 compiler, but using a chip that one would think would need a C16 ... George, aka Clark ...
    (comp.arch.embedded)
  • Re: QteStartViewCreation - create source debugger views
    ... Steve Richter wrote: ... set DBGVIEW to anything that gets the compiler ... input file by the next stage in the compile, ... ILE RPG Root Source View - created by RPG preprocessor for the original ...
    (comp.sys.ibm.as400.misc)