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 > Reading unknown...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 9 Topic 8162 of 8551
Post > Topic >>

Reading unknown number of lines in unknown number of files

by Luka Djigas <ldigas@[EMAIL PROTECTED] > Apr 23, 2008 at 05:42 AM

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)
    3.500000E-01        5.427289        4.700469    7.268204E-01
    4.000000E-01        6.566324        5.225193        1.341131
    4.500000E-01        6.944819        5.329013        1.615806
    5.000000E-01        6.206076        4.943774        1.262302
    5.500000E-01        5.158059        4.395154    7.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=...)
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



      character(8) file_name
      logical existence
      character(100) not_im****tant_line
      dimension fn(25),cw(25),cw0(25),cwi(25)

!      Provjera koji fileovi CWxx.DAT postoje, i koji je zadnji xx
      do 1 i=0,99
      write(file_name,'("CW",i2.2,".DAT")')i
      inquire(file=file_name, exist=existence)
      if(.not.existence) then
!         write(*,'(" File ",a8," ne postoji")')file_name
      else
         n_last_file=i
      end if
1     continue
!      ----------------------------

      do 2 i=0,n_last_file
      write(file_name,'("CW",i2.2,".DAT")')i
      open(unit=1, file=file_name, status='old')
      rewind(1)

      do 3 j=1,14
      read(1,'(a100)')not_im****tant_line
3     continue



      do 4 j1=1,25
      read(1,*)fn(j1),cw(j1),cw0(j1),cwi(j1)
4     continue

      close(1)
2     continue
      end program
 




 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 Fri Jul 25 16:57:46 CDT 2008.