C     Fx compiler version 3.0
C     SUBROUTINE doit(blksize1)
CC#define 17  1
CC      integer 17 
CC    TEMPLATE ta(60000)
CC    TEMPLATE tb(30000)
CC    ALIGN a(I) WITH ta(I)
CC    ALIGN b(I) WITH tb(I)
CC    DISTRIBUTE ta(BLOCK_CYCLIC(17,4))
CC    DISTRIBUTE tb(BLOCK_CYCLIC(17,4))
CCCC      print *, 100
C     PDO (i = 1:60000)
C     POUT a(i)
C     LOCAL
C     IF (fxcellid.LT.4) THEN
C     fxloopstart0 = (MAX((((fxcellid * 17) + 1) + (ifxceil(((1 - ((
C    $fxcellid + 1) * 17)) / real(68))) * 68)),1))
C     fxlmidx0 = ifxlm(fxadesc,0,fxloopstart0)
C     DO fxp0_blkno0 = ifxceil(((1 - ((fxcellid + 1) * 17)) / real(68
C    $))), ifxfloor((59999 / real(68)))
C     DO i = MAX((((fxcellid * 17) + 1) + (fxp0_blkno0 * 68)),1), (
C    $MIN(((((fxcellid * 17) + 1) + (fxp0_blkno0 * 68)) + 16),60000))
C     a(i) = i
C     fxlmidx0 = (fxlmidx0 + 1)
C     ENDDO
C     ENDDO
C     ENDIF
C     ENDLOCAL
C     ENDPDO
CCCC      print *, 101
C     PDO (i = 1:30000)
C     POUT b(i)
C     LOCAL
C     IF (fxcellid.LT.4) THEN
C     fxloopstart0 = (MAX((((fxcellid * 17) + 1) + (ifxceil(((1 - ((
C    $fxcellid + 1) * 17)) / real(68))) * 68)),1))
C     fxlmidx0 = ifxlm(fxbdesc,0,fxloopstart0)
C     DO fxp1_blkno0 = ifxceil(((1 - ((fxcellid + 1) * 17)) / real(68
C    $))), ifxfloor((29999 / real(68)))
C     DO i = MAX((((fxcellid * 17) + 1) + (fxp1_blkno0 * 68)),1), (
C    $MIN(((((fxcellid * 17) + 1) + (fxp1_blkno0 * 68)) + 16),30000))
C     b(i) = ( -i)
C     fxlmidx0 = (fxlmidx0 + 1)
C     ENDDO
C     ENDDO
C     ENDIF
C     ENDLOCAL
C     ENDPDO
CCCC      print *, 102
C     a(::6) = b(::3)
CCCC      print *, 103
C     errors = 0
C     PDO (i = 1:60000)
C     PIN a(i)
C     LOCAL
C     IF (fxcellid.LT.4) THEN
C     fxloopstart0 = (MAX((((fxcellid * 17) + 1) + (ifxceil(((1 - ((
C    $fxcellid + 1) * 17)) / real(68))) * 68)),1))
C     fxlmidx0 = ifxlm(fxadesc,0,fxloopstart0)
C     DO fxp2_blkno0 = ifxceil(((1 - ((fxcellid + 1) * 17)) / real(68
C    $))), ifxfloor((59999 / real(68)))
C     DO i = MAX((((fxcellid * 17) + 1) + (fxp2_blkno0 * 68)),1), (
C    $MIN(((((fxcellid * 17) + 1) + (fxp2_blkno0 * 68)) + 16),60000))
CC      pmvars errors
CC      pcommutative
CC      pinit
CC         errors = 0
CC      pbody
C     idx = ((i + (-1)) / 6)
C     IF ((idx * 6).EQ.(i + (-1))) THEN
C     IF (a(i).NE.( -((idx * 3) + 1))) THEN
C     WRITE (unit=6,fmt=*) i,a(i),( -(idx * 3) + 1)
C     errors = (errors + 1)
C     ENDIF
C     ELSE
C     IF (a(i).NE.i) THEN
C     WRITE (unit=6,fmt=*) i,a(i)
C     errors = (errors + 1)
C     ENDIF
C     ENDIF
CC      pmerge
CC         errors = left(errors) + right(errors)
C     fxlmidx0 = (fxlmidx0 + 1)
C     ENDDO
C     ENDDO
C     ENDIF
C     ENDLOCAL
C     ENDPDO
C     LOCAL
C     WRITE (unit=6,fmt=*) errors
C     ENDLOCAL
C     END


      SUBROUTINE doit(blksize1)
      INTEGER a(15011)
      INTEGER b(7514)
      INTEGER errors
      INTEGER i
      INTEGER idx
      INTEGER fxdistarg
      INTEGER fxcellid
      INTEGER fxccbdesc(1,11)
      INTEGER fxccadesc(1,11)
      EXTERNAL fxdblcheck
      INTEGER fxlmidx0
      EXTERNAL ifxceil
      INTEGER ifxceil
      INTRINSIC real
      REAL real
      INTEGER fxp0_blkno0
      EXTERNAL ifxfloor
      INTEGER ifxfloor
      INTEGER fxloopstart0
      EXTERNAL ifxlm
      INTEGER ifxlm
      INTEGER fxadesc(71,1)
      INTEGER fxp1_blkno0
      INTEGER fxbdesc(71,1)
      INTEGER fxp2_blkno0
      EXTERNAL fx_procstart
      INTEGER fxdistarray(6,20)
      EXTERNAL fxinitdesc
      EXTERNAL ccom_fun_0
      EXTERNAL ccom_fun_1
      EXTERNAL msg_reduce
      EXTERNAL ccom_fun_2
      COMMON /fxcommon/ fxcellid,fxdistarg

      CALL fxdblcheck(fxdistarg,0,'doit')
      fxdistarray(1,1) = 1
      fxdistarray(2,1) = 0
      fxdistarray(3,1) = 17
      fxdistarray(4,1) = 4
      fxdistarray(5,1) = 0
      fxdistarray(6,1) = 0
      CALL fxinitdesc(1,1,fxdistarray,fxbdesc,(-1),(-1))
      CALL ccom_fun_0(fxccbdesc)
      fxdistarray(1,1) = 1
      fxdistarray(2,1) = 0
      fxdistarray(3,1) = 17
      fxdistarray(4,1) = 4
      fxdistarray(5,1) = 0
      fxdistarray(6,1) = 0
      CALL fxinitdesc(1,1,fxdistarray,fxadesc,(-1),(-1))
      CALL ccom_fun_1(fxccadesc)
C#define 17  1
C      integer 17 
C     TEMPLATE ta(60000)
C     TEMPLATE tb(30000)
C     ALIGN a(I) WITH ta(I)
C     ALIGN b(I) WITH tb(I)
C     DISTRIBUTE ta(BLOCK_CYCLIC(17,4))
C     DISTRIBUTE tb(BLOCK_CYCLIC(17,4))
CCC      print *, 100
C     PDO (i = 1:60000)
C     POUT a(i)
C     LOCAL
      IF (fxcellid.LT.4) THEN
        fxloopstart0 = (MAX((((fxcellid * 17) + 1) + (ifxceil(((1 - (
     $(fxcellid + 1) * 17)) / real(68))) * 68)),1))
        fxlmidx0 = ifxlm(fxadesc,0,fxloopstart0)
        DO fxp0_blkno0 = ifxceil(((1 - ((fxcellid + 1) * 17)) / real(
     $68))), ifxfloor((59999 / real(68)))
          DO i = MAX((((fxcellid * 17) + 1) + (fxp0_blkno0 * 68)),1)
     $, (MIN(((((fxcellid * 17) + 1) + (fxp0_blkno0 * 68)) + 16),
     $60000))
            a(fxlmidx0) = i
            fxlmidx0 = (fxlmidx0 + 1)
          ENDDO
        ENDDO
      ENDIF
C     ENDLOCAL
C     ENDPDO
CCC      print *, 101
C     PDO (i = 1:30000)
C     POUT b(i)
C     LOCAL
      IF (fxcellid.LT.4) THEN
        fxloopstart0 = (MAX((((fxcellid * 17) + 1) + (ifxceil(((1 - (
     $(fxcellid + 1) * 17)) / real(68))) * 68)),1))
        fxlmidx0 = ifxlm(fxbdesc,0,fxloopstart0)
        DO fxp1_blkno0 = ifxceil(((1 - ((fxcellid + 1) * 17)) / real(
     $68))), ifxfloor((29999 / real(68)))
          DO i = MAX((((fxcellid * 17) + 1) + (fxp1_blkno0 * 68)),1)
     $, (MIN(((((fxcellid * 17) + 1) + (fxp1_blkno0 * 68)) + 16),
     $30000))
            b(fxlmidx0) = ( -i)
            fxlmidx0 = (fxlmidx0 + 1)
          ENDDO
        ENDDO
      ENDIF
C     ENDLOCAL
C     ENDPDO
CCC      print *, 102
      CALL ccom_fun_2(a,b)
CCC      print *, 103
      errors = 0
C     PDO (i = 1:60000)
C     PIN a(i)
C     LOCAL
      IF (fxcellid.LT.4) THEN
        fxloopstart0 = (MAX((((fxcellid * 17) + 1) + (ifxceil(((1 - (
     $(fxcellid + 1) * 17)) / real(68))) * 68)),1))
        fxlmidx0 = ifxlm(fxadesc,0,fxloopstart0)
        DO fxp2_blkno0 = ifxceil(((1 - ((fxcellid + 1) * 17)) / real(
     $68))), ifxfloor((59999 / real(68)))
          DO i = MAX((((fxcellid * 17) + 1) + (fxp2_blkno0 * 68)),1)
     $, (MIN(((((fxcellid * 17) + 1) + (fxp2_blkno0 * 68)) + 16),
     $60000))
C      pmvars errors
C      pcommutative
C      pinit
C         errors = 0
C      pbody
            idx = ((i + (-1)) / 6)
            IF ((idx * 6).EQ.(i + (-1))) THEN
              IF (a(fxlmidx0).NE.( -((idx * 3) + 1))) THEN
                WRITE (unit=6,fmt=*) i,a(fxlmidx0),( -(idx * 3) + 1)
                errors = (errors + 1)
              ENDIF
            ELSE
              IF (a(fxlmidx0).NE.i) THEN
                WRITE (unit=6,fmt=*) i,a(fxlmidx0)
                errors = (errors + 1)
              ENDIF
            ENDIF
C      pmerge
C         errors = left(errors) + right(errors)
            fxlmidx0 = (fxlmidx0 + 1)
          ENDDO
        ENDDO
      ENDIF
C     ENDLOCAL
C     ENDPDO
C     LOCAL
      WRITE (unit=6,fmt=*) errors
C     ENDLOCAL
      END


C
C     ------------------------------------------------- 
C

C     PROGRAM alltoall
C     CALL doit(17)
C     END


      PROGRAM alltoall
      INTEGER fxcellid
      EXTERNAL doit
      INTEGER fxdistarg
      EXTERNAL fx_procstart
      EXTERNAL fx_init
      EXTERNAL getarg
      CHARACTER*256 fx_executable_name
      EXTERNAL ccom_init
      COMMON /fxcommon/ fxcellid,fxdistarg

      CALL getarg(0,fx_executable_name)
      CALL fx_init(fxcellid,1,0,0,0,4,fx_executable_name)
      CALL ccom_init(0)
      fxdistarg = 0
      CALL doit(17)
      END


C
C     ------------------------------------------------- 
C

