
      SUBROUTINE host (nchans, chans, dim, rank)
      IMPLICIT NONE
      INTEGER dim, nchans
      INTEGER rank (0 : dim - 1), chans (0 : nchans - 1)

C       Stub for testing.

        INCLUDE 'aclmem.inc'
	INTEGER i, j, index, chan

	WRITE (6, *) 'I am "host"'
	WRITE (6, *) 'dimension =', dim
	WRITE (6, *) 'number of channels =', nchans

	DO 20 i = 0, dim - 1
	  index = rank (i)
	  WRITE (6, *) 'index:'
	  DO 10 j = 0, MEM (index + 1) + 3 -1
	    WRITE (6, *) MEM (index + j)
 10       CONTINUE
 20     CONTINUE

	DO 40 i = 0, nchans - 1
	  chan = chans (i)
	  WRITE (6, *) 'channel:'
	  WRITE (6, *) MEM (chan + 0)
	  WRITE (6, *) MEM (chan + 1)
	  WRITE (6, *) MEM (chan + 2)
	  DO 30 j = 0, MEM (chan + 2) - 1
	    WRITE (6, *) MEM (MEM (chan + 3 + j))
 30       CONTINUE
 40     CONTINUE

      END

      SUBROUTINE grid (nchans, chans, dim, rank)
      IMPLICIT NONE
      INTEGER dim, nchans
      INTEGER rank (0 : dim - 1), chans (0 : nchans - 1)

C       Stub for testing.

        INCLUDE 'aclmem.inc'
	INTEGER i, j, index, chan

	WRITE (6, *) 'I am "grid"'
	WRITE (6, *) 'dimension =', dim
	WRITE (6, *) 'number of channels =', nchans

	DO 20 i = 0, dim - 1
	  index = rank (i)
	  WRITE (6, *) 'index:'
	  DO 10 j = 0, MEM (index + 1) + 3 -1
	    WRITE (6, *) MEM (index + j)
 10       CONTINUE
 20     CONTINUE

	DO 40 i = 0, nchans - 1
	  chan = chans (i)
	  WRITE (6, *) 'channel:'
	  WRITE (6, *) MEM (chan + 0)
	  WRITE (6, *) MEM (chan + 1)
	  WRITE (6, *) MEM (chan + 2)
	  DO 30 j = 0, MEM (chan + 2) - 1
	    WRITE (6, *) MEM (MEM (chan + 3 + j))
 30       CONTINUE
 40     CONTINUE

      END

      SUBROUTINE line (nchans, chans, dim, rank)
      IMPLICIT NONE
      INTEGER dim, nchans
      INTEGER rank (0 : dim - 1), chans (0 : nchans - 1)

C       Stub for testing.

        INCLUDE 'aclmem.inc'
	INTEGER i, j, index, chan

	WRITE (6, *) 'I am "line"'
	WRITE (6, *) 'dimension =', dim
	WRITE (6, *) 'number of channels =', nchans

	DO 20 i = 0, dim - 1
	  index = rank (i)
	  WRITE (6, *) 'index:'
	  DO 10 j = 0, MEM (index + 1) + 3 -1
	    WRITE (6, *) MEM (index + j)
 10       CONTINUE
 20     CONTINUE

	DO 40 i = 0, nchans - 1
	  chan = chans (i)
	  WRITE (6, *) 'channel:'
	  WRITE (6, *) MEM (chan + 0)
	  WRITE (6, *) MEM (chan + 1)
	  WRITE (6, *) MEM (chan + 2)
	  DO 30 j = 0, MEM (chan + 2) - 1
	    WRITE (6, *) MEM (MEM (chan + 3 + j))
 30       CONTINUE
 40     CONTINUE

      END


      IMPLICIT NONE

	INCLUDE 'aclmem.inc'

	EXTERNAL host, grid, line
	INTEGER xid, yid, zid
	INTEGER xsize, ysize, zsize
	INTEGER hgchan, glchan
	INTEGER griddim (3), linedim (1)
	INTEGER hostch (1), gridch (2), linech (1)

	PARAMETER (xid = 0, yid = 1, zid = 2)
	PARAMETER (xsize = 3, ysize = 4, zsize = 5)

	PARAMETER (hgchan = 0, glchan = 1)

	DATA griddim /xid, yid, zid/, linedim /yid/
	DATA hostch /hgchan/, gridch /hgchan, glchan/, linech /glchan/

	CALL acbegn ()

	CALL acindx (xid, xsize)
	CALL acindx (yid, ysize)
	CALL acindx (zid, zsize)

	CALL acchan (hgchan, 0)
	CALL acchan (glchan, 1, linedim)

	CALL acarry (host, 1, hostch, 0)
	CALL acarry (grid, 2, gridch, 3, griddim)
	CALL acarry (line, 1, linech, 1, linedim)

	CALL acdone ()

      END

