[comp.os.vms] Fortran Help

swartzbaugh@JPL-VLSI.ARPA (05/22/87)

I am looking for some help on finding the fastest (and 
most efficient) way of zeroing a large (400 X 500 X 10) 
array on a 8800 in VAX FORTRAN.  Assume the latest and 
greatest VMS operating system (if that makes any 
difference).  If there are a number of suggestions I 
will post a summary.

LEICHTER-JERRY@YALE.ARPA (05/23/87)

    I am looking for some help on finding the fastest (and  most efficient)
    way of zeroing a large (400 X 500 X 10)  array on a 8800 in VAX FORTRAN.
    Assume the latest and  greatest VMS operating system (if that makes any
    difference).  If there are a number of suggestions I  will post a summary.
    
The recommended way to fill memory with a given byte - zero or otherwise - is
with the MOVC5 instruction.  The LIB$MOVC5 routine provides this instruction
as a callable procedure.  The way you use it to fill memory is to specify the
desired byte as the fill, and a source length of 0.  Note that MOVC5 - and
LIB$MOVC5 - are limited to 65535 bytes at a shot, so you'd have to call the
routine in a loop.  There's a less-well-known alternative, OTS$MOVE5, which
does the loop internally, hence accepts a length of up to 2^31-1; it's
probably the way to go.  Both of these routines are easily called from
FORTRAN; they are documented in the System Routines - Run-Time Library
books.  (Note that OTS$ routines are in Part II.)

If only some parts of the array are touched in any given usage, or if your
access pattern is pretty "local", rather than jumping all over the whole
array over short periods, a much better approach is to allocate the array
dynamically as demand-0 memory, using SYS$CRMPSC.  SYS$CRMPSC is documented
in the System Services book; using it is somewhat harder, but I suspect this
is probably the best way to do things.

If you need to zero the array only once at program startup, specify the
initial value as all zeros - it's been too long since I used FORTRAN, but I
think you'd use BLOCK DATA.  This will result in the Linker specifying a
demand-0 section, and the image activator will do the $CRMPSC call for you.

							-- Jerry
-------