On Apr 22, 11:42=A0pm, Luka Djigas <ldigas@[EMAIL PROTECTED]
> wrote:
> Hello all !
>
> files: CWxx.DAT where xx is the number which goes from 00 to xx
>
> and they look like this:
> 14 lines of rubbish, and unknown number of lines of data (below)
> =A0 =A0 3.500000E-01 =A0 =A0 =A0 =A05.427289 =A0 =A0 =A0 =A04.700469 =A0
=
=A07.268204E-01
> =A0 =A0 4.000000E-01 =A0 =A0 =A0 =A06.566324 =A0 =A0 =A0 =A05.225193 =A0
=
=A0 =A0 =A01.341131
> =A0 =A0 4.500000E-01 =A0 =A0 =A0 =A06.944819 =A0 =A0 =A0 =A05.329013 =A0
=
=A0 =A0 =A01.615806
> =A0 =A0 5.000000E-01 =A0 =A0 =A0 =A06.206076 =A0 =A0 =A0 =A04.943774 =A0
=
=A0 =A0 =A01.262302
> =A0 =A0 5.500000E-01 =A0 =A0 =A0 =A05.158059 =A0 =A0 =A0 =A04.395154 =A0
=
=A07.629050E-01
> --------------(this line is not in file, just to show this is the end)
>
> I'm trying to read the data so I can plot it. I've managed to come up
> with some kooky solution for determining whether the file exists and
> to read everything up to the data lines (see below, pay no attention
> to the comments, they're here purely for the purpose of
> self-confusion) but I'm having trouble finding a way in which I can
> read the data lines up to the file end, and determining how many lines
> I've read in that file.
>
> Is there some common way this is usually done ? I searched the
> archives, and found some examples. If I read it with read(1,*,end=3D...)
> I don't see how I would be able to read how many lines I've read.
>
> Please, any help on this would be appreciated.
>
> regards
> Luka
[code snipped]
What's wrong with brute force? Read each file twice, once to count the
number of records, then to read in the data. While counting records,
read in as a string and discard. No expensive format conversion is
done on pass 1. re-allocate the data array or create an automatic
array in a subroutine with the needed size.
-- e


|