
      SUBROUTINE host (nchans, chan)
      IMPLICIT NONE
      INTEGER nchans
      INTEGER chan

	LOGICAL report
	INTEGER local, procid
	COMMON /acids/ report, local, procid

	INTEGER acmsiz, NULL
	PARAMETER (acmsiz = 10000, NULL = -1)

	INTEGER MEM (0 : acmsiz - 1)
	INTEGER acptr
	COMMON /aclmem/ MEM, acptr

        INTEGER result, rlen

        WRITE (6, *) 'I am the host, pid', MEM (procid + local)
C        CALL INPUT (chan, result, rlen, tag)
        CALL IORTI (chan, result, rlen)
	WRITE (6, *) 'result =', result
      END

      SUBROUTINE worker (nchans, chan, dim, rank)
      IMPLICIT NONE
      INTEGER dim, nchans
      INTEGER chan
      INTEGER rank (0 : dim - 1)

	LOGICAL report
	INTEGER local, procid
	COMMON /acids/ report, local, procid

	INTEGER acmsiz, NULL
	PARAMETER (acmsiz = 10000, NULL = -1)

	INTEGER MEM (0 : acmsiz - 1)
	INTEGER acptr
	COMMON /aclmem/ MEM, acptr

        INTEGER icoord

        WRITE (6, *) 'I am worker',
     1    icoord (rank (0)), icoord (rank (1)), ' pid',
     2    MEM (procid + local)
C        CALL OUTPUT (chan, 37, 1, 0)
        CALL IORTO (chan, 37, 1)
      END


      IMPLICIT NONE

	EXTERNAL host, worker
	INTEGER xid, yid
	INTEGER xsize, ysize
	INTEGER chan
	INTEGER rank (2)

	PARAMETER (xid   = 0, yid   = 1)
	PARAMETER (xsize = 2, ysize = 3)

	PARAMETER (chan = 0)

	DATA rank /xid, yid/

	CALL acbegn ()

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

	CALL acchan (chan, 0)

	CALL acarry (host,   1, chan, 0)
	CALL acarry (worker, 1, chan, 2, rank)

	CALL acdone ()
      END

