Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!mcsun!cernvax!achille From: achille@cernvax.UUCP (achille petrilli) Newsgroups: comp.lang.fortran Subject: Re: File handling in Fortran 77 Message-ID: <2540@cernvax.UUCP> Date: 30 Aug 90 23:17:24 GMT References: <1990Aug29.173235.9405@ux1.cso.uiuc.edu> <55875@iuvax.cs.indiana.edu> Organization: CERN, European Laboratory for Particle Physics Lines: 48 In article <55875@iuvax.cs.indiana.edu> bomgard@copper.ucs.indiana.edu (Tim Bomgardner) writes: >In article burley@world.std.com (James C Burley) writes: >>In article <1990Aug29.173235.9405@ux1.cso.uiuc.edu> mcdonald@aries.scs.uiuc.edu (Doug McDonald) writes: >> >> This has always bothered me. A file is just a sequence of it, usually >> organized as bytes - a text file must be in "bytes". >> ... >> >>You don't. Standard Fortran is built on older and more baroque/primitive >>file storage technology than C/UNIX. Fortran allows systems to implement >> ... >> >Rubbish. The answer is right there in front of you. Set RECL=1, >ACCESS='DIRECT' in the open statement. For those of you who don't >believe me, I'll be happy to email you fortran implementations of get, >put, and seek that use no tricks whatsoever. > A few comments about this method: 1) Some fortran implementation I know of put control information into the DIRECT access file to record the record length (e.g. Apollo's ftn at sr9.x). In this case you could generate easily a huge overhead (In the Apollo the overhead per record is a couple of bytes, 4 or 8 I don't remember). 2) If I remember correctly, the f77 standard does NOT specify in which units the RECL is specified. I just tried to write 3 direct/unformatted records on Ultrix with f77 and fort (the VAX/VMS compiler running under Ultrix), each record having a RECL=4. I include the source for people who want to try this: program main open(1,file='/tmp/jkl', + form='unformatted',access='direct',recl=4,status='new') write(1,rec=1) 1 write(1,rec=2) 2 write(1,rec=3) 3 close(1) end f77 produced a 12 bytes output file, fort a 48 bytes one. You can extrapolate what your RECL=1 would have produced in the 2 cases. 3) For DIRECT access, you have to specify the record number every record you read/write. That's not exactly a byte stream. 4) I'd guess the overhead WRT an equivalent C program should be enormous, given that every byte (or longword in the case of VAX fortran) written is treated as a record. I wouldn't really bend fortran that way to do these sort of things, it's not meant to do it simply. Achille Petrilli Management Information Systems