       SUBROUTINE Z_ALLOC(nelem,elsize,array,address,offset)
C
C----------------------------------------------------------------------
C
C.IDENTIFICATION: Subroutine Z_ALLOC
C.LIBRARY:        VOS (VMS  experimental version)
C.AUTHOR:         L.Chiappetti - IFCTR Milano
C.VERSIONS:       0.0 - 22 Jul 92 - Original version
C.VERSIONS:       1.0 - 29 Oct 92 - New error handling codes
C 
C.PURPOSE:        Allocate memory                             
C.METHOD:         call system routine calloc
C.SYNTAX:         CALL Z_ALLOC(nelem,elsize,array,address,offset)               
C.PARAMETERS:     INTEGER nelem    : number of elements to be allocated     (in)
C                 INTEGER elsize   : size in bytes of array to be allocated (in)
C                 any     array    : array handle (dimension as array(1))   (in)
C                 INTEGER address  : address of memory allocated            (out)
C                 INTEGER offset   : offset from array(1) to address        (out) 
C.RESTRICTIONS:   
C.NOTES:          error code is set in VOSCOMMON_ERROR
C                 to be used as follows :
C                 DIMENSION ARRAY(1)
C                 ...
C                 CALL Z_ALLOC(nelem,elsize,ARRAY,address,offset)
C                 ... then either in same program
C                     use ARRAY(I+OFFSET) to access I-th element of array
C                 ... or pass it as a proper array to a subroutine
C                     CALL SUB(ARRAY(1+OFFSET)
C                     ... where in subroutine one has
C                     SUBROUTINE SUB(ARRAY)
C                     DIMENSION ARRAY(*)
C 
C.FILES:          none
C.REFERENCES      zc_alloc in VOS library
C
C----------------------------------------------------------------------
C
C
C      INCLUDE 'implicit_none.inc'
       INTEGER  nelem,elsize,address,offset,array(*)
       INTEGER  ZC_ALLOC
       INCLUDE 'voscommon.inc'
       INCLUDE 'errors.inc'
C
C      set default return error codes, and verify string length
C
       VOSCOMMON_ERROR=0
       VOSCOMMON_SYSTEMERROR=0
       ADDRESS=0
       OFFSET =0
C
C      the only difference between the Unix and VMS version is that this one
C      forces %REF argument passage by reference. This allows to use ZC_ALLOC
C      with CHARACTERS too (in VMS they are otherwise passed by descriptor)
C      it is possible that this call is unnecessary, since this routine never
C      knows the argument "array" is CHARACTER in the calling program
C  
C-->   should also check nelem and elsize are valid values ? 
       VOSCOMMON_SYSTEMERROR=ZC_ALLOC
     . (nelem,elsize,%ref(array),address,offset)
C      if array is character it is returned null, not blank !
C      assign VOS error code
       IF(VOSCOMMON_SYSTEMERROR.NE.0)VOSCOMMON_ERROR=VE_ALLOC
       RETURN
       END    
