ARRFoffset


Synopsis


       INTEGER FUNCTION ARRFoffset(array_ptr,
      . basevec,
      . type)

       INTEGER array_ptr
       DIMENSION basevec(1)

Description

This routine enables FORTRAN programmers to access memory locations specified by a pointer in a portable manner.

Arguments

array_ptr

The address of a memory area allocated with ARRFalloc or returned by ARRFretptr or by one of the get_array access routines described below (expressed as an integer).

basevec

A local array, used as a reference location. This array can be dimensioned with one element.

type

A code for the data type of the local array basevec , expressed as an integer. It is used to compute the correct addressing offset according to the size of the elements of the local array. The meaningful codes predefined in the include file omf.inc are:

Code

 

basevec(1) data type

 

DTYPE_INT

INTEGER

DTYPE_FLOAT

REAL

DTYPE_DOUBLE

DOUBLE PRECISION

 

Returned value

The addressing offset of an allocated memory area with respect to the first element of basevec .

Example


C Allocate a memory area and fill some values in
#include <avs/omf.inc>
       INTEGER iaddr, offset, size
       REAL base(1)
       ...
       size = 2000
       iaddr = ARRFalloc(0,DTYPE_FLOAT,size,0)
       IF (iaddr .EQ. 0) PRINT*,'Error allocating memory area'        offset = ARRFoffset(iaddr,base,DTYPE_FLOAT)
C
       DO 100 i=1,size base(offset+i) = FLOAT(i)
 100   CONTINUE

See also

Related modules:

•      See ARRFincr_refcnt

•      See ARRFfree

•      See ARRFalloc

•      See ARRFretptr