.TITLE RDLEN .IDENT /850321/ ;+ ;.ENTRY RDLEN ; - R D L E N ; FILE: RDLEN.MAR ; SYSTEM: VMS V4.0 ; LANGUAGE: MACRO32 ; AUTHOR: M. OOTHOUDT ; DATE: 850321 ;- ; ; ****************************************************************** ; * Copyright, 1984, The Regents of the University of California. * ; * * ; * This software was produced under a U.S. Government contract * ; * (W-7405-ENG-36) by the Los Alamos National Laboratory, which * ; * is operated by the University of California for the U.S. De- * ; * partment of Energy. The U.S. Government is licensed to use, * ; * reproduce, and distribute this software. Permission is grant- * ; * ed to the public to copy and use this software without charge, * ; * provided that this notice and any statement of authorship are * ; * reproduced on all copies. Neither the Government nor the Uni- * ; * versity makes any warranty, express of implied, or assumes any * ; * liability or responsibility for the use of this software. * ; ****************************************************************** ; ; REFERENCES: ; ; REVISIONS: ;+ ; ;****PURPOSE: Tell User the number of bytes of user data returned ; by a FORTRAN Unformatted READ on a LUN. ; ;****RESTRICTIONS: ; ;****CALLING SEQUENCE: CALL RDLEN (LUN,LEN) ; ; ; INPUT: ; ; LUN = (I*2) LUN READ was done on ; ; MODIFIED: None ; ; ; OUTPUT: ; ; LEN = (I*2) # of bytes returned to the user by the last READ on LUN ; ; CMN BLOCKS USED: None ; ;****RESOURCES: ; LIBRARIES: VMSRTL:FOR$RAB ; OTHER SUBR: None ; DISK FILES: File open on LUN ; DEVICES: Device on LUN ; SGAS: None ; EVENT FLAGS: None ; SYSTEM DIR: None ; ;****NOTES: ; 1. When doing an Unformatted FORTRAN READ on a file, there is ; no way to determine how many bytes were put into the user's array by ; the READ. This routine will give the correct number of bytes: ; ; BYTE ARRAY(100) ; open file on LUN Unformatted ; READ(LUN)ARRAY ; CALL RDLEN (LUN,LEN) ; ; LEN contains the number of bytes in ARRAY. ; ; 2. Unformatted FORTRAN READs and WRITEs can be more than a ; factor of 10 faster (WALL clock and CPU time) than a similar Formatted ; IO. Thus Unformatted IO should be used wherever possible. The only ; real reason for using Formatted IO is that a human being will have ; to read the IO. ; ; 3. Text files created with FORTRAN WRITEs or an EDITOR may be ; READ Unformatted. However, the OPEN statement for the READ MUST ; specify RECORDTYPE='VARIABLE' to avoid "Segemented record format" ; errors. ; ; 4. Reads into FORTRAN arrays that are longer than the disk ; record will return an error of 67, "data underrun." This can usually ; be treated as success. ;- ; Data .PSECT QLIB_DATA,WRT,NOEXE FORRABCALL: ;Arg list for FOR$RAB call .LONG 1 LUN: .BLKL 1 ;Addr of LUN ; Code .PSECT QLIB_CODE,NOWRT,EXE .ENTRY RDLEN,^M<> MOVAL @4(AP),LUN ;Set up FOR$RAB call CALLG FORRABCALL,G^FOR$RAB ;RAB addr put into R0 MOVW RAB$W_RSZ(R0),@8(AP) ;Return rec size RET .END