home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!spool.mu.edu!agate!boulder!khonshu!ejh
- From: ejh@khonshu.colorado.edu (Edward J. Hartnett)
- Newsgroups: comp.lang.fortran
- Subject: peculiar formatted read problem
- Message-ID: <1992Jul30.184123.7568@colorado.edu>
- Date: 30 Jul 92 18:41:23 GMT
- Article-I.D.: colorado.1992Jul30.184123.7568
- Sender: news@colorado.edu (The Daily Planet)
- Organization: Cooperative Institute for Research in the Environmental Sciences
- Lines: 29
- Nntp-Posting-Host: khonshu.colorado.edu
-
- I posted this message within locally, but couldn't get any good answers.
- I'm using SunOS 4.1.1, on an IPC. Can anyone shed any light on this?
-
- I have just spent quite a long time trying to track down a problem, and now
- that I've arrived at a solution, I don't get it. I am reading a file called
- defaults, which has two lines, the first is a directory name (a80) and the
- second line is a filename (a20). Here's the code:
-
- ddata_dir = '/home/khonshu/astex_data/'
- dfilein = 'RF01.TXT'
- open(LUDEF, file='defaults')
- read(LUDEF,'(a80)',err=3,end=3) ddata_dir
- read(LUDEF,*,err=3,end=3) dfilein
- 3 write(*,*) 'Data directory [',ddata_dir(:lnblnk(ddata_dir)),']?'
-
- This is set up such that if there is no defaults file, or if it is empty,
- there will still be a default. So I define ddata_dir and dfilein first,
- then open and read from the defaults file. If the default file is there,
- I read in new values for ddata_dir and dfilein. The above works fine.
- But, if I use default format for the first read (i.e. * instead of '(a80)')
- I get no error, no end of file, but the old value of ddata_dir is retained,
- even though there is a new value in the defaults file. Furthermore, dfilein
- IS read correctly from the file. So how can it skip over the first record,
- without either having an error (in which case it would go to line 3 and not
- read in dfilein), or reading in the ddata_dir which is in the defaults file?
-
- Just on trial and error, and in desperation, I changed the format to '(a80)'
- and now it works great. But I don't need a format of '(a20)' for fnamein,
- why?
-