C     Fx compiler version 2.1
CC    TEMPLATE t(1024)
CC    ALIGN a(I,J) WITH t(I)
CC    ALIGN b(I,J) WITH t(J)
CC    DISTRIBUTE t(BLOCK_CYCLIC(16,64))
C     CALL fx_sync()
C     CALL timer_start()
C     a = b
C     clocks = timer_stop()
C     mbytes = (real(4194304) / 1e6)
C     secs = (real(clocks) / 2e7)
C     msecs = (secs * 1e3)
C     WRITE (unit=6,fmt=*) 'size=',1024,'msecs=',msecs,'mbytes/s=',
C    $mbytes / secs
C     END
      PROGRAM main
      EXTERNAL fxawaitmessages
      INTEGER fxprocessor
      INTRINSIC real
      REAL real
      REAL secs
      INTEGER fxcellid
      INTEGER fxop
      INTEGER fxbufdataidx
      INTEGER fxbufoff0
      EXTERNAL fx_procstart
      INTEGER fxrslice0
      REAL msecs
      EXTERNAL fx_deinit
      EXTERNAL fxdcomord
      INTEGER fxdistarg
      INTEGER fxaddr
      INTEGER clocks
      EXTERNAL msg_reduce
      REAL mbytes
      EXTERNAL fxinitdesc
      EXTERNAL timer_stop
      INTEGER timer_stop
      INTEGER fxindextmp
      EXTERNAL fxdsend
      EXTERNAL fx_init
      INTEGER fxawait
      INTEGER fxidiotic3_0
      EXTERNAL fx_set_module_geometry
      EXTERNAL fx_sync
      EXTERNAL fxallocinit
      INTEGER fxallocinit
      EXTERNAL fxadblk1
      EXTERNAL timer_start
      INTEGER fxslice0
      INTEGER fxbuffer(1)
      REAL a(16,1024)
      REAL b(1024,16)
      COMPLEX fxcbuffer(1)
      DOUBLE PRECISION fxdbuffer(1)
      LOGICAL fxlbuffer(1)
      REAL fxrbuffer(1)
      DOUBLE COMPLEX fxdcbuffer(1)
      INTEGER fxadesc(71,2)
      INTEGER fxbdesc(71,2)
      INTEGER fxdistarray(6,20)
      EQUIVALENCE (fxbuffer,fxrbuffer)
      EQUIVALENCE (fxbuffer,fxlbuffer)
      EQUIVALENCE (fxbuffer,fxdbuffer)
      EQUIVALENCE (fxbuffer,fxcbuffer)
      EQUIVALENCE (fxbuffer,fxdcbuffer)
      COMMON /fxcommon/ fxcellid,fxdistarg
      CALL fx_init(fxcellid,1,1,0,0)
      CALL fx_set_module_geometry(0,0,0,8,8)
      fxdistarg = 0
      fxbufoff0 = fxallocinit(fxbuffer,1100)
      fxdistarray(1,1) = 2
      fxdistarray(2,1) = 0
      fxdistarray(3,1) = 16
      fxdistarray(4,1) = 64
      fxdistarray(5,1) = 0
      fxdistarray(6,1) = 0
      fxdistarray(3,2) = 1024
      CALL fxinitdesc(1,2,fxdistarray,fxbdesc)
      fxdistarray(1,1) = 1
      fxdistarray(2,1) = 0
      fxdistarray(3,1) = 16
      fxdistarray(4,1) = 64
      fxdistarray(5,1) = 0
      fxdistarray(6,1) = 0
      fxdistarray(3,2) = 1024
      CALL fxinitdesc(1,2,fxdistarray,fxadesc)
C     TEMPLATE t(1024)
C     ALIGN a(I,J) WITH t(I)
C     ALIGN b(I,J) WITH t(J)
C     DISTRIBUTE t(BLOCK_CYCLIC(16,64))
      CALL fx_sync()
      CALL timer_start()
      CALL fx_sync()
      fxawait = 0
      DO fxindextmp = 1, 64, 1
        CALL fxdcomord(fxprocessor,fxop,fxindextmp)
        fxbufdataidx = 4
        fxbuffer((fxbufoff0 + 1)) = 0
        fxrslice0 = 0
        DO fxslice0 = MAX(fxadesc((fxprocessor + 8),1),1), (MIN((
     $fxadesc((fxprocessor + 8),1) + 15),1024)), 1
          CALL fxadblk1(fxbufdataidx,fxbuffer((fxbufoff0 + 
     $fxbufdataidx)),a((fxrslice0 + 1),((MAX((fxbdesc((fxcellid + 8),
     $2) + (-1)),0)) + 1)),b(fxslice0,1),16,64,4096,(fxcellid - 
     $fxprocessor),fxbuffer((fxbufoff0 + 1)))
          fxrslice0 = (fxrslice0 + 1)
        ENDDO
        IF (fxbufdataidx.GT.4) THEN
          fxbuffer((fxbufoff0 + 2)) = 64
          fxbuffer((fxbufoff0 + 3)) = 16
          CALL fxdsend(fxprocessor,fxbuffer((fxbufoff0 + 1)),(
     $fxbufdataidx + (-1)),9)
          fxawait = (fxawait + 1)
        ENDIF
      ENDDO
      CALL fxawaitmessages(fxawait)
      clocks = timer_stop()
      mbytes = (real(4194304) / 1e6)
      secs = (real(clocks) / 2e7)
      msecs = (secs * 1e3)
      IF (fxcellid.EQ.0) THEN
        WRITE (unit=6,fmt=*) 'size=',1024,'msecs=',msecs,'mbytes/s=',
     $mbytes / secs
      ENDIF
      CALL fx_deinit()
      END
