Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Fortran > Re: Reading unk...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 2 of 9 Topic 8162 of 8656
Post > Topic >>

Re: Reading unknown number of lines in unknown number of files

by e p chandler <epc8@[EMAIL PROTECTED] > Apr 22, 2008 at 09:11 PM

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
 




 9 Posts in Topic:
Reading unknown number of lines in unknown number of files
Luka Djigas <ldigas@[E  2008-04-23 05:42:08 
Re: Reading unknown number of lines in unknown number of files
e p chandler <epc8@[EM  2008-04-22 21:11:26 
Re: Reading unknown number of lines in unknown number of files
nospam@[EMAIL PROTECTED]   2008-04-22 21:17:54 
Re: Reading unknown number of lines in unknown number of files
Terence <tbwright@[EMA  2008-04-22 22:08:40 
Re: Reading unknown number of lines in unknown number of files
Luka Djigas <ldigas@[E  2008-04-23 22:59:41 
Re: Reading unknown number of lines in unknown number of files
Luka Djigas <ldigas@[E  2008-04-23 23:05:56 
Re: Reading unknown number of lines in unknown number of files
nospam@[EMAIL PROTECTED]   2008-04-28 19:17:49 
Re: Reading unknown number of lines in unknown number of files
andrej.panjkov@[EMAIL PRO  2008-04-22 22:16:51 
Re: Reading unknown number of lines in unknown number of files
andrej.panjkov@[EMAIL PRO  2008-04-22 22:26:30 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Aug 30 8:20:42 CDT 2008.