C program to test out the features of the ACL libraries
C{{{  master
      SUBROUTINE master (nchans, chan)
      IMPLICIT NONE
      INTEGER nchans, chan(nchans)
      INTEGER psize, qsize, rsize, tsize
      LOGICAL ok
      INTEGER i, j, k, t, partial, minmax(0:1)
      REAL u, rpartial, extreme
      DOUBLEPRECISION v, dextreme
C     C{{{  declare tags
      INTEGER tend, tint, tcpx
      PARAMETER (tend = 0)
      PARAMETER (tint = 1)
      PARAMETER (tcpx = 3)
C     C}}}
      print *, 'Master has started'
C     C{{{  get sizes
      call INPUT(chan(1), psize, 1, tint)
      print *, 'First index of size ', psize
      call INPUT(chan(1), qsize, 1, tint)
      print *, 'Second index of size ', qsize
      call INPUT(chan(1), rsize, 1, tint)
      print *, 'Third index of size ', rsize
      call INPUT(chan(2), tsize, 1, tint)
      print *, 'Fourth index of size ', tsize
C     C}}}
C{{{  1D stuff
C{{{  send array
      DO 10 i = 0, psize-1
        call OUTPUT(chan(1), i, 1, tint)
10    CONTINUE
C}}}
C{{{  check element
      call INPUT(chan(1), t, 1, tint)
      IF (t .NE. 1) THEN
        print *, 'Received ', t, ' expecting 1'
        STOP "Error in OU1DEL or OU1D"
      ENDIF
      t = 42
      call OUTPUT(chan(1), t, 1, tint)
      print *, 'OU1DEL checks OK'
C}}}
C{{{  read array back in
      ok = .TRUE.
      DO 20 i = 0, psize-1
        call INPUT(chan(1), t, 1, tint)
        IF (t .NE. i) THEN
          ok = .FALSE.
        ENDIF
20    CONTINUE
      IF (.NOT. ok) THEN
        STOP " Error in OU1D or IN1D"
      ENDIF
      print *, 'OU1D and IN1D checked OK'
C}}}
C{{{  send array
      DO 30 i = 0, psize-1
        call OUTPUT(chan(1), -i, 1, tint)
30    CONTINUE
C}}}
C{{{  read array back in
      ok = .TRUE.
      DO 40 i = 0, psize-1
        call INPUT(chan(1), t, 1, tint)
        IF (t .NE. -i) THEN
          ok = .FALSE.
        ENDIF
40    CONTINUE
      IF (.NOT. ok) THEN
        STOP " Error in OU1DAR or IN1DAR"
      ENDIF
      print *, 'OU1DAR and IN1DAR checked OK'
C}}}
C}}}
C{{{  2D stuff
C{{{  send array
      DO 110 i = 0, psize-1
        DO 115 j = 0, qsize-1
          call OUTPUT(chan(1), qsize*i + j , 1, tint)
115     CONTINUE
110   CONTINUE
C}}}
C{{{  check element
      call INPUT(chan(1), t, 1, tint)
      IF (t .NE. 3) THEN
        print *, 'Received ', t, ' expecting 3'
        STOP "Error in OU2DEL or OU2D"
      ENDIF
      t = 42
      call OUTPUT(chan(1), t, 1, tint)
      print *, 'OU2DEL checks OK'
C}}}
C{{{  read array back in
      ok = .TRUE.
      DO 120 i = 0, psize-1
        DO 125 j = 0, qsize-1
          call INPUT(chan(1), t, 1, tint)
          IF (t .NE. (qsize*i+j)) THEN
            ok = .FALSE.
          ENDIF
125     CONTINUE
120   CONTINUE
      IF (.NOT. ok) THEN
        STOP " Error in OU2D or IN2D"
      ENDIF
      print *, 'OU2D and IN2D checked OK'
C}}}
C{{{  send array
      DO 130 i = 0, psize-1
        DO 135 j = 0, qsize-1
          call OUTPUT(chan(1), -(qsize*i+j), 1, tint)
135     CONTINUE
130   CONTINUE
C}}}
C{{{  read array back in
      ok = .TRUE.
      DO 140 i = 0, psize-1
        DO 145 j = 0, qsize-1
          call INPUT(chan(1), t, 1, tint)
          IF (t .NE. -(qsize*i+j)) THEN
            ok = .FALSE.
            print *, 'worker got ', t, ' expecting ', -(qsize*i+j)
          ENDIF
145     CONTINUE
140   CONTINUE
      IF (.NOT. ok) THEN
        STOP " Error in OU2DAR or IN2DAR"
      ENDIF
      print *, 'OU2DAR and IN2DAR checked OK'
C}}}
C}}}
C{{{  3D stuff
C{{{  send array
      DO 210 i = 0, psize-1
        DO 215 j = 0, qsize-1
          DO 217 k = 0, rsize-1
            call OUTPUT(chan(1), (qsize*i+j)*rsize+k , 1, tint)
217       CONTINUE
215     CONTINUE
210   CONTINUE
C}}}
C{{{  check element
      call INPUT(chan(1), t, 1, tint)
      IF (t .NE. 7) THEN
        print *, 'Received ', t, ' expecting 7'
        STOP "Error in OU3DEL or OU3D"
      ENDIF
      t = 42
      call OUTPUT(chan(1), t, 1, tint)
      print *, 'OU3DEL checks OK'
C}}}
C{{{  read array back in
      ok = .TRUE.
      DO 220 i = 0, psize-1
        DO 225 j = 0, qsize-1
          DO 227 k = 0, rsize-1
            call INPUT(chan(1), t, 1, tint)
            IF (t .NE. ((qsize*i+j)*rsize+k)) THEN
              ok = .FALSE.
            ENDIF
227       CONTINUE
225     CONTINUE
220   CONTINUE
      IF (.NOT. ok) THEN
        STOP " Error in OU3D or IN3D"
      ENDIF
      print *, 'OU3D and IN3D checked OK'
C}}}
C{{{  send array
      DO 230 i = 0, psize-1
        DO 235 j = 0, qsize-1
          DO 237 k = 0, rsize-1
            call OUTPUT(chan(1), -((qsize*i+j)*rsize+k), 1, tint)
237       CONTINUE
235     CONTINUE
230   CONTINUE
C}}}
C{{{  read array back in
      ok = .TRUE.
      DO 240 i = 0, psize-1
        DO 245 j = 0, qsize-1
          DO 247 k = 0, rsize-1
            call INPUT(chan(1), t, 1, tint)
            IF (t .NE. -((qsize*i+j)*rsize+k)) THEN
              ok = .FALSE.
            ENDIF
247       CONTINUE
245     CONTINUE
240   CONTINUE
      IF (.NOT. ok) THEN
        STOP " Error in OU3DAR or IN3DAR"
      ENDIF
      print *, 'OU3DAR and IN3DAR checked OK'
C}}}
C}}}
C
C{{{  check perms and stuff
C{{{  check for shift right (PDSI test)
C{{{  send array
      DO 50 i = 0, tsize-1
        call OUTPUT(chan(2), i, 1, tint)
50    CONTINUE
C}}}
C{{{  read array back in
      ok = .TRUE.
      DO 60 i = 0, tsize-1
        call INPUT(chan(2), t, 1, tint)
        IF (t .NE. MOD(i+tsize-1, tsize)) THEN
          ok = .FALSE.
        ENDIF
60    CONTINUE
      IF (.NOT. ok) THEN
        STOP " Error in PDS"
      ENDIF
      print *, 'PDS checked OK'
C}}}
C}}}
C{{{  check for shift right (PSHFTI test)
C{{{  send array
      DO 350 i = 0, tsize-1
        call OUTPUT(chan(2), i, 1, tint)
350   CONTINUE
C}}}
C{{{  read array back in
      ok = .TRUE.
      DO 360 i = 0, tsize-1
        call INPUT(chan(2), t, 1, tint)
        IF (t .NE. MOD(i+2, tsize)) THEN
          ok = .FALSE.
        ENDIF
360   CONTINUE
      IF (.NOT. ok) THEN
        STOP " Error in PSHFTI"
      ENDIF
      print *, 'PSHFTI checked OK'
C}}}
C}}}
C{{{  check for reflection (PREFLI test)
C{{{  send array
      DO 370 i = 0, tsize-1
        call OUTPUT(chan(2), i, 1, tint)
370   CONTINUE
C}}}
C{{{  read array back in
      ok = .TRUE.
      DO 380 i = 0, tsize-1
        call INPUT(chan(2), t, 1, tint)
        IF (t .NE. MOD(tsize-i, tsize)) THEN
          ok = .FALSE.
        ENDIF
380   CONTINUE
      IF (.NOT. ok) THEN
        STOP " Error in PREFLI (test 1)"
      ENDIF
      print *, 'PREFLI checked OK (test 1)'
C}}}
C}}}
C{{{  check for reflection (PREFLI test)
C{{{  send array
      DO 390 i = 0, tsize-1
        call OUTPUT(chan(2), i, 1, tint)
390   CONTINUE
C}}}
C{{{  read array back in
      ok = .TRUE.
      DO 400 i = 0, tsize-1
        call INPUT(chan(2), t, 1, tint)
        IF (t .NE. MOD(tsize+5-i, tsize)) THEN
          ok = .FALSE.
        ENDIF
400   CONTINUE
      IF (.NOT. ok) THEN
        STOP " Error in PREFLI (test 2)"
      ENDIF
      print *, 'PREFLI checked OK (test 2)'
C}}}
C}}}
C{{{  check PXORI
C{{{  send array
      DO 410 i = 0, tsize-1
        call OUTPUT(chan(2), i, 1, tint)
410   CONTINUE
C}}}
C{{{  read array back in
      ok = .TRUE.
      DO 420 i = 0, tsize-1
        call INPUT(chan(2), t, 1, tint)
        IF (IEOR(i, 5) .LT. 7) THEN
          IF (t .NE. IEOR(i, 5)) THEN
            ok = .FALSE.
          ENDIF
        ELSE
          IF (t .NE. i) THEN
            ok = .FALSE.
          ENDIF
        ENDIF
420   CONTINUE
      IF (.NOT. ok) THEN
        STOP " Error in PXORI"
      ENDIF
      print *, 'PXORI checked OK'
C}}}
C}}}
C{{{  check for swap (PSWAPI test)
C{{{  send array
      DO 430 i = 0, tsize-1
        call OUTPUT(chan(2), i, 1, tint)
430   CONTINUE
C}}}
C{{{  read array back in
      ok = .TRUE.
      DO 440 i = 0, tsize-1
        call INPUT(chan(2), t, 1, tint)
        IF ((i .EQ. 2) .OR. (i .EQ. 5)) THEN
          IF (t .NE. (7-i)) THEN
            ok = .FALSE.
          ENDIF
        ELSE
          IF (t .NE. i) THEN
            ok = .FALSE.
          ENDIF
        ENDIF
440   CONTINUE
      IF (.NOT. ok) THEN
        STOP " Error in PSWAPI"
      ENDIF
      print *, 'PSWAPI checked OK'
C}}}
C}}}
C}}}
C{{{  check partial operations on INTs
C{{{  send array
      DO 445 i = 1, tsize
        call OUTPUT(chan(2), i, 1, tint)
445   CONTINUE
C}}}
C{{{  check INSUM
      ok = .TRUE.
      DO 450 i = 1, tsize
        call INPUT(chan(2), t, 1, tint)
        IF (t .NE. i*(i+1)/2) THEN
          ok = .FALSE.
        ENDIF
450   CONTINUE
      IF (.NOT. ok) THEN
        STOP " Error in INSUM"
      ENDIF
      print *, 'INSUM checked OK'
C}}}
C{{{  check INPRD
      ok = .TRUE.
      partial = 1
      DO 455 i = 1, tsize
        partial = partial * i
        call INPUT(chan(2), t, 1, tint)
        IF (t .NE. partial) THEN
          ok = .FALSE.
        ENDIF
455   CONTINUE
      IF (.NOT. ok) THEN
        STOP " Error in INPRD"
      ENDIF
      print *, 'INPRD checked OK'
C}}}
C{{{  check INMAX
      ok = .TRUE.
      DO 460 i = 0, tsize-1
        call INPUT(chan(2), minmax, 2, tint)
        IF ((minmax(0) .NE. (i+1)) .OR. (minmax(1) .NE. i)) THEN
          ok = .FALSE.
        ENDIF
460   CONTINUE
      IF (.NOT. ok) THEN
        STOP " Error in INMAX"
      ENDIF
      print *, 'INMAX checked OK'
C}}}
C{{{  check INMIN
      ok = .TRUE.
      DO 470 i = 0, tsize-1
        call INPUT(chan(2), minmax, 2, tint)
        IF ((minmax(0) .NE. 1) .OR. (minmax(1) .NE. 0)) THEN
          ok = .FALSE.
        ENDIF
470   CONTINUE
      IF (.NOT. ok) THEN
        STOP " Error in INMIN"
      ENDIF
      print *, 'INMIN checked OK'
C}}}
C}}}
C{{{  check partial operations on REALS
C{{{  send array
      DO 530 i = 1, tsize
        call OUTPUT(chan(2), REAL(i), 1, tint)
530   CONTINUE
C}}}
C{{{  check RESUM
      ok = .TRUE.
      DO 540 i = 1, tsize
        call INPUT(chan(2), u, 1, tint)
        IF (u .NE. REAL(i*(i+1)/2)) THEN
          ok = .FALSE.
        ENDIF
540   CONTINUE
      IF (.NOT. ok) THEN
        STOP " Error in RESUM"
      ENDIF
      print *, 'RESUM checked OK'
C}}}
C{{{  check REPRD
      ok = .TRUE.
      rpartial = 1.0
      DO 550 i = 1, tsize
        rpartial = rpartial * REAL(i)
        call INPUT(chan(2), u, 1, tint)
        IF (u .NE. rpartial) THEN
          ok = .FALSE.
        ENDIF
550   CONTINUE
      IF (.NOT. ok) THEN
        STOP " Error in REPRD"
      ENDIF
      print *, 'REPRD checked OK'
C}}}
C{{{  check REMAX
      ok = .TRUE.
      DO 560 i = 0, tsize-1
        call INPUT(chan(2), extreme, 1, tint)
        IF (extreme .NE. REAL(i+1)) THEN
          ok = .FALSE.
        ENDIF
560   CONTINUE
      DO 565 i = 0, tsize-1
        call INPUT(chan(2), t, 1, tint)
        IF (t .NE. i) THEN
          ok = .FALSE.
        ENDIF
565   CONTINUE
      IF (.NOT. ok) THEN
        STOP " Error in REMAX"
      ENDIF
      print *, 'REMAX checked OK'
C}}}
C{{{  check REMIN
      ok = .TRUE.
      DO 570 i = 0, tsize-1
        call INPUT(chan(2), extreme, 1, tint)
        IF (extreme .NE. 1.0) THEN
          ok = .FALSE.
        ENDIF
570   CONTINUE
      DO 575 i = 0, tsize-1
        call INPUT(chan(2), t, 1, tint)
        IF (t .NE. 0) THEN
          ok = .FALSE.
        ENDIF
575   CONTINUE
      IF (.NOT. ok) THEN
        STOP " Error in REMIN"
      ENDIF
      print *, 'REMIN checked OK'
C}}}
C}}}
C{{{  check partial operations on DOUBLEPRECISION
C{{{  send array
      DO 480 i = 1, tsize
        call OUTPUT(chan(2), DBLE(i), 2, tint)
480   CONTINUE
C}}}
C{{{  check DPSUM
      ok = .TRUE.
      DO 490 i = 1, tsize
        call INPUT(chan(2), v, 2, tint)
        IF (v .NE. DBLE(i*(i+1)/2)) THEN
          ok = .FALSE.
        ENDIF
490   CONTINUE
      IF (.NOT. ok) THEN
        STOP " Error in DPSUM"
      ENDIF
      print *, 'DPSUM checked OK'
C}}}
C{{{  check DPPRD
      ok = .TRUE.
      rpartial = 1.0
      DO 500 i = 1, tsize
        rpartial = rpartial * DBLE(i)
        call INPUT(chan(2), v, 2, tint)
        IF (v .NE. rpartial) THEN
          ok = .FALSE.
        ENDIF
500   CONTINUE
      IF (.NOT. ok) THEN
        STOP " Error in DPPRD"
      ENDIF
      print *, 'DPPRD checked OK'
C}}}
C{{{  check DPMAX
      ok = .TRUE.
      DO 510 i = 0, tsize-1
        call INPUT(chan(2), dextreme, 2, tint)
        IF (dextreme .NE. DBLE(i+1)) THEN
          ok = .FALSE.
        ENDIF
510   CONTINUE
      DO 515 i = 0, tsize-1
        call INPUT(chan(2), t, 1, tint)
        IF (t .NE. i) THEN
          ok = .FALSE.
        ENDIF
515   CONTINUE
      IF (.NOT. ok) THEN
        STOP " Error in DPMAX"
      ENDIF
      print *, 'DPMAX checked OK'
C}}}
C{{{  check DPMIN
      ok = .TRUE.
      DO 520 i = 0, tsize-1
        call INPUT(chan(2), dextreme, 2, tint)
        IF (dextreme .NE. 1.0) THEN
          ok = .FALSE.
        ENDIF
520   CONTINUE
      DO 525 i = 0, tsize-1
        call INPUT(chan(2), t, 1, tint)
        IF (t .NE. 0) THEN
          ok = .FALSE.
        ENDIF
525   CONTINUE
      IF (.NOT. ok) THEN
        STOP " Error in DPMIN"
      ENDIF
      print *, 'DPMIN checked OK'
C}}}
C}}}
C{{{  finish
      call INTAG(chan(2), tend)
      print *, 'checked SYNCH, BCAST, BCSTEL, BCSTAR, PFXAND, '
      print *, 'PFXOR, GAND, GOR, OUTAG and INTAG'
C}}}
      END
C}}}
C
C{{{  worker1
      SUBROUTINE worker1 (nchans, chan, ndims, dims)
      IMPLICIT NONE
      INTEGER nchans, chan, ndims, dims(0:ndims-1)
C     C{{{  declare tags
      INTEGER tend, tint, tcpx
      PARAMETER (tend = 0)
      PARAMETER (tint = 1)
      PARAMETER (tcpx = 3)
C     C}}}
      INTEGER data(0:0), previous
      INTEGER Icoord, Isize
      call OUTPUT(chan, Isize(dims(0)), 1, tint)
      call OUTPUT(chan, Isize(dims(1)), 1, tint)
      call OUTPUT(chan, Isize(dims(2)), 1, tint)
C{{{  1D stuff
      call IN1D(chan, dims(0), data, 1, tint)
      call OU1DEL(chan, dims(0), data, 1, 1, tint)
      call IN1DEL(chan, dims(0), data, 1, 1, tint)
      IF (Icoord(dims(0)) .EQ. 1) THEN
        IF (data(0) .EQ. 42) THEN
          print *, 'IN1DEL checks OK'
          data(0) = 1
        ELSE
          STOP "Error in IN1DEL"
        ENDIF
      ENDIF
      call OU1D(chan, dims(0), data, 1, tint)
      previous = data(0)
      call IN1DAR(chan, dims(0), 1, data, 1, 1, tint)
      IF (data(0) .NE. -previous) THEN
        print *, 'worker got ', data(0), 'expecting ', -previous
      ENDIF
      call OU1DAR(chan, dims(0), 1, data, 1, 1, tint)
C}}}
C{{{  2D stuff
      call IN2D(chan, dims(0), dims(1), data, 1, tint)
      call OU2DEL(chan, dims(0), dims(1), data, 1, 1, 1, tint)
      call IN2DEL(chan, dims(0), dims(1), data, 1, 1, 1, tint)
      IF ((Icoord(dims(0)) .EQ. 1) .AND. (Icoord(dims(1)) .EQ. 1)) THEN
        IF (data(0) .EQ. 42) THEN
          print *, 'IN2DEL checks OK'
          data(0) = 3
        ELSE
          STOP "Error in IN2DEL"
        ENDIF
      ENDIF
      call OU2D(chan, dims(0), dims(1), data, 1, tint)
      previous = data(0)
      call IN2DAR(chan, dims(0), dims(1), 1, 1, data, 1, 1, 1, tint)
      IF (data(0) .NE. -previous) THEN
        print *, 'worker got ', data(0), ' expecting ', -previous
      ENDIF
      call OU2DAR(chan, dims(0), dims(1), 1, 1, data, 1, 1, 1, tint)
C}}}
C{{{  3D stuff
      call IN3D(chan, dims(0), dims(1), dims(2), data, 1, tint)
      call OU3DEL(chan, dims(0), dims(1), dims(2),
     :            data, 1, 1, 1, 1, tint)
      call IN3DEL(chan, dims(0), dims(1), dims(2),
     :            data, 1, 1, 1, 1, tint)
      IF ((Icoord(dims(0)) .EQ. 1) .AND. (Icoord(dims(1)) .EQ. 1) .AND.
     :    (Icoord(dims(2)) .EQ. 1)) THEN
        IF (data(0) .EQ. 42) THEN
          print *, 'IN3DEL checks OK'
          data(0) = 7
        ELSE
          STOP "Error in IN3DEL"
        ENDIF
      ENDIF
      call OU3D(chan, dims(0), dims(1), dims(2), data, 1, tint)
      previous = data(0)
      call IN3DAR(chan, dims(0), dims(1), dims(2), 1, 1, 1,
     :            data, 1, 1, 1, 1, tint)
      IF (data(0) .NE. -previous) THEN
        print *, 'worker got ', data(0), ' expecting ', -previous
      ENDIF
      call OU3DAR(chan, dims(0), dims(1), dims(2), 1, 1, 1,
     :            data, 1, 1, 1, 1, tint)
C}}}
      END
C}}}
C
C{{{  worker2
      SUBROUTINE worker2 (nchans, chan, ndims, x)
      IMPLICIT NONE
      INTEGER nchans, chan, ndims, x
      INTEGER data(0:0), partial(0:1), size, coord, tag, i
      INTEGER Isize, Icoord
      REAL rdata(0:0), rresult
      DOUBLEPRECISION ddata(0:0), dresult, result(0:6)
      LOGICAL bool
      LOGICAL GOR, GAND
C     C{{{  declare tags
      INTEGER tend, tint, tcpx
      PARAMETER (tend = 0)
      PARAMETER (tint = 1)
      PARAMETER (tcpx = 3)
C     C}}}
      size = Isize(x)
      coord = Icoord(x)
      call OUTPUT(chan, size, 1, tint)
C     C{{{  test perms
C     C{{{  test PDSI
      call IN1D(chan, x, data, 1, tint)
      call PDSI(x, data, 1, MOD(coord-1+size, size), MOD(coord+1, size))
      call OU1D(chan, x, data, 1, tint)
C     C}}}
C     C{{{  test PSHFTI
      call IN1D(chan, x, data, 1, tint)
      call PSHFTI(x, data, 1, -2)
      call OU1D(chan, x, data, 1, tint)
C     C}}}
C     C{{{  test PREFLI 1
      call IN1D(chan, x, data, 1, tint)
      call PREFLI(x, data, 1, 0)
      call OU1D(chan, x, data, 1, tint)
C     C}}}
C     C{{{  test PREFLI 2
      call IN1D(chan, x, data, 1, tint)
      call PREFLI(x, data, 1, 5)
      call OU1D(chan, x, data, 1, tint)
C     C}}}
C     C{{{  test PXORI
      call IN1D(chan, x, data, 1, tint)
      call PXORI(x, data, 1, 5)
      call OU1D(chan, x, data, 1, tint)
C     C}}}
C     C{{{  test PSWAPI
      call IN1D(chan, x, data, 1, tint)
      call PSWAPI(x, data, 1, 2, 5)
      call OU1D(chan, x, data, 1, tint)
C     C}}}
C     C}}}
C     C{{{  test partial ops on INTs
      call IN1D(chan, x, data, 1, tint)
C     C{{{  test INSUM
      call INSUM(x, partial(0), data(0))
      call OU1D(chan, x, partial(0), 1, tint)
C     C}}}
C     C{{{  test INPRD
      call INPRD(x, partial(0), data(0))
      call OU1D(chan, x, partial(0), 1, tint)
C     C}}}
C     C{{{  test INMAX
      call INMAX(x, partial(0), partial(1), data(0), coord)
      call OU1D(chan, x, partial, 2, tint)
C     C}}}
C     C{{{  test INMIN
      call INMIN(x, partial(0), partial(1), data(0), coord)
      call OU1D(chan, x, partial, 2, tint)
C     C}}}
C     C}}}
C     C{{{  test partial ops on REALs
      call IN1D(chan, x, rdata, 1, tint)
C     C{{{  test RESUM
      call RESUM(x, rresult, rdata(0))
      call OU1D(chan, x, rresult, 1, tint)
C     C}}}
C     C{{{  test REPRD
      call REPRD(x, rresult, rdata(0))
      call OU1D(chan, x, rresult, 1, tint)
C     C}}}
C     C{{{  test REMAX
      call REMAX(x, rresult, tag, rdata(0), coord)
      call OU1D(chan, x, rresult, 1, tint)
      call OU1D(chan, x, tag, 1, tint)
C     C}}}
C     C{{{  test REMIN
      call REMIN(x, rresult, tag, rdata(0), coord)
      call OU1D(chan, x, rresult, 1, tint)
      call OU1D(chan, x, tag, 1, tint)
C     C}}}
C     C}}}
C     C{{{  test partial ops on DOUBLEPRECISION
      call IN1D(chan, x, ddata, 2, tint)
C     C{{{  test DPSUM
      call DPSUM(x, dresult, ddata(0))
      call OU1D(chan, x, dresult, 2, tint)
C     C}}}
C     C{{{  test DPPRD
      call DPPRD(x, dresult, ddata(0))
      call OU1D(chan, x, dresult, 2, tint)
C     C}}}
C     C{{{  test DPMAX
      call DPMAX(x, dresult, tag, ddata(0), coord)
      call OU1D(chan, x, dresult, 2, tint)
      call OU1D(chan, x, tag, 1, tint)
C     C}}}
C     C{{{  test DPMIN
      call DPMIN(x, dresult, tag, ddata(0), coord)
      call OU1D(chan, x, dresult, 2, tint)
      call OU1D(chan, x, tag, 1, tint)
C     C}}}
C     C}}}
C{{{  test synch and broadcast
      call SYNCH(x, 1)
C{{{  test BCAST
      call BCAST(x, result, 7, DBLE(coord), 2)
      DO 10, i = 0, size-1
        IF (result(i) .NE. DBLE(i)) THEN
          STOP "BCAST failed"
        ENDIF
10    CONTINUE
C}}}
C{{{  test BCSTAR
      call BCSTAR(x, result, 7, 2, 1, DBLE(coord), 1)
      DO 20, i = 0, size-1
        IF (result(i) .NE. DBLE(i)) THEN
          STOP "BCSTAR failed"
        ENDIF
20    CONTINUE
C}}}
C{{{  test BCSTEL
      call BCSTEL(x, result, 2, DBLE(coord), 2, 3)
      IF (result(0) .NE. DBLE(3)) THEN
        STOP "BCSTEL failed"
      ENDIF
C}}}
C}}}
C     C{{{  test logical ops
C     C{{{  PFXAND
      IF (coord .EQ. 3) THEN
        call PFXAND(x, bool, .FALSE.)
      ELSE
        call PFXAND(x, bool, .TRUE.)
      ENDIF
      IF (coord .LT. 3) THEN
        IF (.NOT. bool) THEN
          STOP "PFXAND returned incorrect result"
        ENDIF
      ELSE
        IF (bool) THEN
          STOP "PFXAND returned incorrect result"
        ENDIF
      ENDIF
C     C}}}
C     C{{{  PFXOR
      IF (coord .EQ. 4) THEN
        call PFXOR(x, bool, .TRUE.)
      ELSE
        call PFXOR(x, bool, .FALSE.)
      ENDIF
      IF (coord .LT. 4) THEN
        IF (bool) THEN
          STOP "PFXOR returned incorrect result"
        ENDIF
      ELSE
        IF (.NOT. bool) THEN
          STOP "PFXOR returned incorrect result"
        ENDIF
      ENDIF
C     C}}}
C     C{{{  GAND
      IF (coord .EQ. 1) THEN
        bool = GAND(x, .FALSE.)
      ELSE
        bool = GAND(x, .TRUE.)
      ENDIF
      IF (bool) THEN
        STOP "GAND returned incorrect result"
      ENDIF
C     C}}}
C     C{{{  GOR
      IF (coord .EQ. 6) THEN
        bool = GOR(x, .TRUE.)
      ELSE
        bool = GOR(x, .FALSE.)
      ENDIF
      IF (.NOT. bool) THEN
        STOP "GOR returned incorrect result"
      ENDIF
C     C}}}
C     C}}}
      call OUTAG(chan, tend)
      END
C}}}
C
C{{{  configuration
      IMPLICIT NONE
      EXTERNAL master, worker
      INTEGER pid, qid, rid, tid
      INTEGER psize, qsize, rsize, tsize
      INTEGER chan1, chan2, null
      INTEGER line(1), rank(3), chans(2)
      EXTERNAL worker1, worker2
      PARAMETER (pid = 0, qid = 1, rid = 2, tid = 4)
      PARAMETER (psize = 2, qsize = 2, rsize = 2, tsize = 7)
      PARAMETER (chan1 = 0, chan2 = 1)
      DATA rank /pid, qid, rid/
      DATA line /tid/
      DATA chans /chan1, chan2/
      CALL acbegn ()
      CALL acindx (pid, psize)
      CALL acindx (qid, qsize)
      CALL acindx (rid, rsize)
      CALL acindx (tid, tsize)
      CALL acchan (chan1, 0)
      CALL acchan (chan2, 0)
      CALL acarry (master, 2, chans, 0, null)
      CALL acarry (worker1, 1, chan1, 3, rank)
      CALL acarry (worker2, 1, chan2, 1, line)
      CALL acdone ()
      END
C}}}
