home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / lang / fortran / 2888 < prev    next >
Encoding:
Internet Message Format  |  1992-07-30  |  2.0 KB

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