next up previous contents
Next: Floating Point Data Migration Up: VMS Fortran Binary Read Previous: VMS Fortran Binary Read   Contents

Binary Read Calling Sequence

The routine package accesses files by file descriptor, an integer variable that is easily passed among multi-language routines.
The routines are stored in the ar library /$LVDLIB/liblvdr.a. All variables are passed to C routines by address. The Fortran caller must define the following variables:

        integer max_size
        parameter (max_size=100000)
        integer buf(max_size),fd,ret
        character file_name*50
with the following meaning:

The calling sequences are summarized below.

open:
\framebox{\tt open\_lvd(file\_name,fd,ret)} opens file with name file_name, returns file descriptor value in fd, and operation code in ret
close:
\framebox{\tt close\_lvd(fd)} closes file with associated file descriptor fd
read4:
\framebox{\tt read4\_lvd(buf,fd,ret)} reads integer*4 variables in buf, emulating the Fortran statement:
read(fd) ret,(buf(k),k=1,ret)
read2:
\framebox{\tt read2\_lvd(buf(2),fd,ret)} reads integer*2 variables in buf emulating the Fortran statement:
read(fd) buf(1),(buf(k),k=2,buf(1))

n.b. variables fd, ret are interger*4, read address is buf(2), the 2-byte word count must be set with the statement buf(1)=ret
readvms:
\framebox{\tt read\_vms(buf,fd,ret)} reads VMS RMS binary records without interpretation, and returns the user byte count in ret.
In case of integer*4 data the routine emulates the Fortran statement:
read(fd) ret/4,(buf(k),k=1,ret/4)

Return code values and meaning are described below.


Binary Read Return Codes
routine code meaning
open $-1$ no such file
any read $-2$ record too big
  $-1$ read error
  $0$ EOF in unput
read2_lvd $>0$ 2-byte word count, move to buf(1)
read4_lvd $>0$ 4-byte word count
read_vms $>0$ byte count


Programs that need our read tool must use the lvdr library to create the executable. A Makefile example follows to compile and link program migr_dist.f that needs routine read4_lvd to read data files imported using ftp.


Linking with make
 
LIBDIR = /$LVDLIB
 
migr_dist : migr_dist.o
f77 migr_dist.o -o migr_dist -L$(LIBDIR) -llvdr
 
migr_dist.o : migr_dist.f
f77 -c migr_dist.f
 



next up previous contents
Next: Floating Point Data Migration Up: VMS Fortran Binary Read Previous: VMS Fortran Binary Read   Contents
luvisetto 2003-01-23