      SUBROUTINE host (nchans, chan)
      IMPLICIT NONE
      INTEGER nchans
      INTEGER chan
      CALL OUTPUT (chan, 37, 1, 0)
      END

      SUBROUTINE worker1 (nchans, chans, dim, rank)
      IMPLICIT NONE
      INTEGER dim, nchans, result
      INTEGER chans(0:1)
      INTEGER rank (0 : dim - 1)
      CALL INPUT (chans(0), result, 1, 0)
      CALL OUTPUT(chans(1), result, 1, 0)
      WRITE (6, *) 'worker1 result =', result
      END

      SUBROUTINE worker2 (nchans, chan, dim, rank)
      IMPLICIT NONE
      INTEGER dim, nchans
      INTEGER chan, result
      INTEGER rank (0 : dim - 1)
      CALL INPUT (chan, result, 1, 0)
      WRITE (6, *) 'worker2 result =', result
      END

      IMPLICIT NONE
	EXTERNAL host, worker1, worker2
	INTEGER xid, yid
	INTEGER xsize, ysize
	INTEGER chan1, chan2, chans(0:1)
	INTEGER rank (2)
	PARAMETER (xid   = 0, yid   = 1)
	PARAMETER (xsize = 2, ysize = 3)
	PARAMETER (chan1 = 0, chan2=1)
        DATA chans /chan1, chan2/
	DATA rank /xid, yid/
	CALL acbegn ()
	CALL acindx (xid, xsize)
	CALL acindx (yid, ysize)
	CALL acchan (chan1, 0)
	CALL acchan (chan2, 0)
	CALL acarry (host,   1, chan1, 0)
	CALL acarry (worker1, 2, chans, 2, rank)
        CALL acarry (worker2, 1, chan2, 1, xid)
	CALL acdone ()
      END
