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

  1. Path: sparky!uunet!munnari.oz.au!yoyo.aarnet.edu.au!sirius.ucs.adelaide.edu.au!spam!jnixon
  2. From: jnixon@spam.ua.oz (John Nixon)
  3. Newsgroups: comp.lang.fortran
  4. Subject: Re: Reading C output in FORTRAN
  5. Summary: direct access
  6. Message-ID: <1628@spam.ua.oz>
  7. Date: 29 Jul 92 08:06:12 GMT
  8. References: <1992Jul24.172254.24198@ll.mit.edu>
  9. Organization: Statistics, Pure & Applied Mathematics, University of Adelaide
  10. Lines: 47
  11.  
  12. In article <1992Jul24.172254.24198@ll.mit.edu> akearns@ll.mit.edu ( Adam Kearns) writes:
  13.  
  14. >       Hi. We have some files on a VAX that are STREAM_LF type, and we would
  15. >like to read them in FORTRAN using the READ command.  The file has a
  16. >fixed length of 16384 bytes.  The problem is that using the READ command
  17. >doesn't seem to move the file pointer to the where it stopped reading, so
  18. >we read the same data over again.  We have a way using QIO to read in the
  19. >file, but that requires computing the number of disk blocks we read and
  20. >starting from there.  This technique is rather inconvienent, espically
  21. >if a record ends in the middle of a disk block (for a different file,
  22. >obviously this one does).  It would be nice to be able to use the READ
  23. >command and have the program keep track of where it is in the file
  24. >like you can in VAX C.  Any suggestions would be appreciated.
  25.  
  26. Use something like:
  27.  
  28.         open(unit = iunit, status = 'old', file = name,
  29.      &       access = 'direct', recl = irecl,
  30.      &       iostat = istat, err = 10610, form = un_formatted)
  31.  
  32. which I have use on a Sun, and does work.  My files were actually
  33. created by a FORTRAN program on a CRAY and had the 64-bits reduced to
  34. 32-bits by the UNICOS (i.e. CRAY Unix) OS, so the unformatted files had
  35. numbers without the usual extranaous junk associated stripped off.  Then
  36. you need something like:
  37.  
  38.       irec = 1
  39.       read(unit = 1, rec = irec, err = 10060, end = 10070) nc1, nc2
  40.       irec = irec + 2 * nbytes
  41.  
  42. where it is assumed:
  43.  
  44.       parameter (irecl = 1)
  45.       parameter (nbytes = 4)
  46.  
  47. holds and *you* have to keep track of where you are by updating irec at
  48. appropriate times.
  49.  
  50. All this was actual code taken from working programs and hopefully
  51. explains itself pretty much.
  52.  
  53. Later,
  54.  
  55. --
  56. John Nixon {Research Dude} jnixon@spam.maths.adelaide.edu.au [08 228-5407]
  57. Department of Applied Mathematics, The University of Adelaide, SA, AUSTRALIA
  58. "Anonymous Techno Act" Sample of the Week: "Music & noise.  Noise & music."
  59.