C     Fx compiler version 2.1
CC    TEMPLATE t(512)
CC    ALIGN a(I,J) WITH t(J)
CC    ALIGN b(I,J) WITH t(J)
CC    DISTRIBUTE t(BLOCK_CYCLIC(8,64))
C     CALL fx_sync()
C     CALL gen_bit_reverse_table(brt)
C     CALL gen_w_table(w)
C     t1clocks = 0
C     t2clocks = 0
C     f1clocks = 0
C     f2clocks = 0
C     DO k = 1, 20, 1
C     CALL dgen(a)
C     CALL timer_start()
C     CALL cffts(a,brt,w)
C     f1clocks = (f1clocks + timer_stop())
C     CALL timer_start()
C     IDXPERM(b,2,1) = a
C     t1clocks = (t1clocks + timer_stop())
C     CALL timer_start()
C     CALL cffts(b,brt,w)
C     f2clocks = (f2clocks + timer_stop())
C     CALL timer_start()
C     IDXPERM(a,2,1) = b
C     t2clocks = (t2clocks + timer_stop())
C     CALL chkmat(a)
C     ENDDO
C     t1clocks = (t1clocks / 20)
C     t2clocks = (t2clocks / 20)
C     f1clocks = (f1clocks / 20)
C     f2clocks = (f2clocks / 20)
C     CALL prperf(t1clocks,t2clocks,f1clocks,f1clocks)
C     END
      PROGRAM main
      INTEGER t1clocks
      INTEGER t2clocks
      EXTERNAL fxawaitmessages
      INTEGER fxprocessor
      EXTERNAL dgen
      INTEGER fxcellid
      INTEGER fxop
      INTEGER fxbufdataidx
      INTEGER fxbufoff0
      INTEGER fxbufoff1
      INTEGER k
      EXTERNAL fx_procstart
      INTEGER fxrslice0
      EXTERNAL cffts
      EXTERNAL fx_deinit
      EXTERNAL fxdcomord
      INTEGER fxdistarg
      EXTERNAL gen_bit_reverse_table
      EXTERNAL chkmat
      INTEGER fxaddr
      EXTERNAL msg_reduce
      EXTERNAL prperf
      EXTERNAL fxinitdesc
      EXTERNAL timer_stop
      INTEGER timer_stop
      INTEGER fxindextmp
      EXTERNAL gen_w_table
      EXTERNAL fxdsend
      EXTERNAL fx_init
      INTEGER fxawait
      INTEGER fxidiotic3_0
      EXTERNAL fx_set_module_geometry
      EXTERNAL fx_sync
      EXTERNAL fxallocinit
      INTEGER fxallocinit
      EXTERNAL fxadblk2
      INTEGER f1clocks
      INTEGER f2clocks
      EXTERNAL timer_start
      INTEGER fxslice0
      INTEGER fxbuffer(1)
      COMPLEX a(512,8)
      COMPLEX b(512,8)
      COMPLEX w(256)
      COMPLEX fxcbuffer(1)
      DOUBLE PRECISION fxdbuffer(1)
      LOGICAL fxlbuffer(1)
      REAL fxrbuffer(1)
      DOUBLE COMPLEX fxdcbuffer(1)
      INTEGER brt(512)
      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
      fxbufoff1 = fxallocinit(fxbuffer,556)
      fxbufoff0 = fxallocinit(fxbuffer,556)
      fxdistarray(1,1) = 2
      fxdistarray(2,1) = 0
      fxdistarray(3,1) = 8
      fxdistarray(4,1) = 64
      fxdistarray(5,1) = 0
      fxdistarray(6,1) = 0
      fxdistarray(3,2) = 512
      CALL fxinitdesc(1,2,fxdistarray,fxbdesc)
      fxdistarray(1,1) = 2
      fxdistarray(2,1) = 0
      fxdistarray(3,1) = 8
      fxdistarray(4,1) = 64
      fxdistarray(5,1) = 0
      fxdistarray(6,1) = 0
      fxdistarray(3,2) = 512
      CALL fxinitdesc(1,2,fxdistarray,fxadesc)
C     TEMPLATE t(512)
C     ALIGN a(I,J) WITH t(J)
C     ALIGN b(I,J) WITH t(J)
C     DISTRIBUTE t(BLOCK_CYCLIC(8,64))
      CALL fx_sync()
      CALL gen_bit_reverse_table(brt)
      CALL gen_w_table(w)
      t1clocks = 0
      t2clocks = 0
      f1clocks = 0
      f2clocks = 0
      DO k = 1, 20, 1
        fxdistarg = 1
        CALL dgen(a,fxadesc)
        CALL timer_start()
        fxdistarg = 1
        CALL cffts(a,brt,w,fxadesc,(-1),(-1))
        f1clocks = (f1clocks + timer_stop())
        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(fxbdesc((fxprocessor + 8),2),1), (MIN((
     $fxbdesc((fxprocessor + 8),2) + 7),512)), 1
            CALL fxadblk2(fxbufdataidx,fxbuffer((fxbufoff0 + 
     $fxbufdataidx)),b(((MAX((fxadesc((fxcellid + 8),2) + (-1)),0))
     $ + 1),(fxrslice0 + 1)),a(fxslice0,1),8,8,4096,(fxcellid - 
     $fxprocessor),fxbuffer((fxbufoff0 + 1)))
            fxrslice0 = (fxrslice0 + 1)
          ENDDO
          IF (fxbufdataidx.GT.4) THEN
            fxbuffer((fxbufoff0 + 2)) = 8
            fxbuffer((fxbufoff0 + 3)) = 8
            CALL fxdsend(fxprocessor,fxbuffer((fxbufoff0 + 1)),(
     $fxbufdataidx + (-1)),10)
            fxawait = (fxawait + 1)
          ENDIF
        ENDDO
        CALL fxawaitmessages(fxawait)
        t1clocks = (t1clocks + timer_stop())
        CALL timer_start()
        fxdistarg = 1
        CALL cffts(b,brt,w,fxbdesc,(-1),(-1))
        f2clocks = (f2clocks + timer_stop())
        CALL timer_start()
        CALL fx_sync()
        fxawait = 0
        DO fxindextmp = 1, 64, 1
          CALL fxdcomord(fxprocessor,fxop,fxindextmp)
          fxbufdataidx = 4
          fxbuffer((fxbufoff1 + 1)) = 0
          fxrslice0 = 0
          DO fxslice0 = MAX(fxadesc((fxprocessor + 8),2),1), (MIN((
     $fxadesc((fxprocessor + 8),2) + 7),512)), 1
            CALL fxadblk2(fxbufdataidx,fxbuffer((fxbufoff1 + 
     $fxbufdataidx)),a(((MAX((fxbdesc((fxcellid + 8),2) + (-1)),0))
     $ + 1),(fxrslice0 + 1)),b(fxslice0,1),8,8,4096,(fxcellid - 
     $fxprocessor),fxbuffer((fxbufoff1 + 1)))
            fxrslice0 = (fxrslice0 + 1)
          ENDDO
          IF (fxbufdataidx.GT.4) THEN
            fxbuffer((fxbufoff1 + 2)) = 8
            fxbuffer((fxbufoff1 + 3)) = 8
            CALL fxdsend(fxprocessor,fxbuffer((fxbufoff1 + 1)),(
     $fxbufdataidx + (-1)),10)
            fxawait = (fxawait + 1)
          ENDIF
        ENDDO
        CALL fxawaitmessages(fxawait)
        t2clocks = (t2clocks + timer_stop())
        fxdistarg = 1
        CALL chkmat(a,fxadesc)
      ENDDO
      t1clocks = (t1clocks / 20)
      t2clocks = (t2clocks / 20)
      f1clocks = (f1clocks / 20)
      f2clocks = (f2clocks / 20)
      CALL prperf(t1clocks,t2clocks,f1clocks,f1clocks)
      CALL fx_deinit()
      END
CC    TEMPLATE t(512)
CC    ALIGN a(I,J) WITH t(J)
CC    DISTRIBUTE t(BLOCK_CYCLIC(8,64))
C     a = cmplx(0.,0.)
C     a(257,257) = cmplx(512,512)
C     END
      SUBROUTINE dgen(a,fxadesc)
      INTEGER fxindex1
      INTEGER fxindex2
      INTEGER fxfirst0
      INTEGER fxfirst1
      INTEGER fxcellid
      INTEGER fxcc0
      INTEGER fxcc1
      EXTERNAL fxinitdescck
      EXTERNAL fx_procstart
      INTEGER fxstride0
      INTEGER fxstride1
      INTEGER fxlmlast0
      INTEGER fxlmlast1
      EXTERNAL ifxlm
      INTEGER ifxlm
      INTRINSIC cmplx
      COMPLEX cmplx
      INTEGER fxdistarg
      EXTERNAL fxdblcheck
      INTEGER fxlmfirst0
      INTEGER fxlmfirst1
      EXTERNAL msg_reduce
      EXTERNAL fxcl_inita
      INTEGER fxlast0
      INTEGER fxlast1
      INTEGER fxlmstride0
      INTEGER fxlmstride1
      EXTERNAL fxdistcheck
      EXTERNAL ifxowns
      INTEGER ifxowns
      COMPLEX a(512,8)
      INTEGER fxadesc(71,2)
      INTEGER fxdistarray(6,20)
      COMMON /fxcommon/ fxcellid,fxdistarg
      CALL fxdblcheck(fxdistarg,1,'dgen')
      fxdistarg = 0
      CALL fxdistcheck(fxadesc,1,1,'dgen')
      fxdistarray(1,1) = 2
      fxdistarray(2,1) = 0
      fxdistarray(3,1) = 8
      fxdistarray(4,1) = 64
      fxdistarray(5,1) = 0
      fxdistarray(6,1) = 0
      fxdistarray(3,2) = 512
      CALL fxinitdescck(1,2,fxdistarray,fxadesc,'a','dgen')
C     TEMPLATE t(512)
C     ALIGN a(I,J) WITH t(J)
C     DISTRIBUTE t(BLOCK_CYCLIC(8,64))
      CALL fxcl_inita(0,1,1,fxlast0,fxlmlast0,fxcc0,1,fxadesc((
     $fxcellid + 8),1),512,1,512,fxfirst0,fxlmfirst0)
      CALL fxcl_inita(0,1,1,fxlast1,fxlmlast1,fxcc1,1,fxadesc((
     $fxcellid + 8),2),512,1,8,fxfirst1,fxlmfirst1)
      DO fxindex1 = fxlmfirst0, fxlmlast0, 1
        DO fxindex2 = fxlmfirst1, fxlmlast1, 1
          a(fxindex1,fxindex2) = cmplx(0.,0.)
        ENDDO
      ENDDO
      IF (ifxowns(fxadesc,1,257,fxcellid).NE.0) THEN
        a(257,ifxlm(fxadesc,1,257)) = cmplx(512,512)
      ENDIF
      END
C     nv2 = 256
C     j = 1
C     brt(1) = j
C     DO i = 2, 512, 1
C     k = nv2
C6    CONTINUE
C     IF (k.LT.j) THEN
C     j = (j - k)
C     k = (k / 2)
C     GOTO 6 
C     ENDIF
C     j = (j + k)
C     brt(i) = j
C     ENDDO
C     RETURN 
C     END
      SUBROUTINE gen_bit_reverse_table(brt)
      INTEGER fxcellid
      INTEGER i
      INTEGER j
      INTEGER k
      EXTERNAL fx_procstart
      INTEGER fxdistarg
      EXTERNAL fxdblcheck
      EXTERNAL msg_reduce
      INTEGER nv2
      INTEGER brt(512)
      COMMON /fxcommon/ fxcellid,fxdistarg
      CALL fxdblcheck(fxdistarg,0,'gen_bit_reverse_table')
      nv2 = 256
      j = 1
      brt(1) = j
      DO i = 2, 512, 1
        k = nv2
6       CONTINUE
        IF (k.LT.j) THEN
          j = (j - k)
          k = (k / 2)
          GOTO 6 
        ENDIF
        j = (j + k)
        brt(i) = j
      ENDDO
      RETURN 
      END
C     pi = 3.141592653589793
C     wr = cos(((pi / 512) / 2))
C     wi = sin(((pi / 512) / 2))
C     w(1) = cmplx(1.,0.)
C     ptr = 1.
C     pti = 0.
C     DO i = 2, 256, 1
C     w(i) = cmplx(((ptr * wr) - (pti * wi)),((ptr * wi) + (pti * wr)
C    $))
C     ptr = real(w(i))
C     pti = aimag(w(i))
C     ENDDO
C     RETURN 
C     END
      SUBROUTINE gen_w_table(w)
      INTRINSIC real
      REAL real
      INTEGER fxcellid
      INTEGER i
      EXTERNAL fx_procstart
      INTRINSIC aimag
      REAL aimag
      INTRINSIC cmplx
      COMPLEX cmplx
      INTEGER fxdistarg
      REAL pi
      REAL wi
      REAL wr
      EXTERNAL fxdblcheck
      EXTERNAL msg_reduce
      INTRINSIC cos
      REAL cos
      INTRINSIC sin
      REAL sin
      REAL pti
      REAL ptr
      COMPLEX w(256)
      COMMON /fxcommon/ fxcellid,fxdistarg
      CALL fxdblcheck(fxdistarg,0,'gen_w_table')
      pi = 3.141592653589793
      wr = cos(((pi / 512) / 2))
      wi = sin(((pi / 512) / 2))
      w(1) = cmplx(1.,0.)
      ptr = 1.
      pti = 0.
      DO i = 2, 256, 1
        w(i) = cmplx(((ptr * wr) - (pti * wi)),((ptr * wi) + (pti * 
     $wr)))
        ptr = real(w(i))
        pti = aimag(w(i))
      ENDDO
      RETURN 
      END
CC    TEMPLATE t(512)
CC    ALIGN a(I,J) WITH t(J)
CC    DISTRIBUTE t(BLOCK_CYCLIC(8,64))
C     PDO (col = 1:512)
C     PIN a(:,col)
C     POUT a(:,col)
C     LOCAL
C     fxloopstart0 = (MAX(((fxcellid * 8) + 1),1))
C     fxlmidx0 = ifxlm(fxadesc,1,fxloopstart0)
C     DO col = fxloopstart0, MIN(((fxcellid * 8) + 8),512), 1
C     CALL fft(a(1,col),brt,w)
C     fxlmidx0 = (fxlmidx0 + 1)
C     ENDDO
C     ENDLOCAL
C     ENDPDO
C     RETURN 
C     END
      SUBROUTINE cffts(a,brt,w,fxadesc,fxbrtdesc,fxwdesc)
      INTEGER fxlmidx0
      INTEGER fxcellid
      INTEGER fxloopstart0
      EXTERNAL fxinitdescck
      EXTERNAL fx_procstart
      INTRINSIC float
      REAL float
      EXTERNAL ifxlm
      INTEGER ifxlm
      INTEGER fxdistarg
      EXTERNAL fxdblcheck
      EXTERNAL msg_reduce
      INTEGER col
      EXTERNAL fft
      EXTERNAL ifxceil
      INTEGER ifxceil
      EXTERNAL fxdistcheck
      COMPLEX a(512,8)
      COMPLEX w(256)
      INTEGER fxbrtdesc(71,1)
      INTEGER brt(512)
      INTEGER fxadesc(71,2)
      INTEGER fxwdesc(71,1)
      INTEGER fxdistarray(6,20)
      COMMON /fxcommon/ fxcellid,fxdistarg
      CALL fxdblcheck(fxdistarg,1,'cffts')
      fxdistarg = 0
      CALL fxdistcheck(fxwdesc,0,3,'cffts')
      CALL fxdistcheck(fxbrtdesc,0,2,'cffts')
      CALL fxdistcheck(fxadesc,1,1,'cffts')
      fxdistarray(1,1) = 2
      fxdistarray(2,1) = 0
      fxdistarray(3,1) = 8
      fxdistarray(4,1) = 64
      fxdistarray(5,1) = 0
      fxdistarray(6,1) = 0
      fxdistarray(3,2) = 512
      CALL fxinitdescck(1,2,fxdistarray,fxadesc,'a','cffts')
C     TEMPLATE t(512)
C     ALIGN a(I,J) WITH t(J)
C     DISTRIBUTE t(BLOCK_CYCLIC(8,64))
C     PDO (col = 1:512)
C     PIN a(:,col)
C     POUT a(:,col)
C     LOCAL
      fxloopstart0 = (MAX(((fxcellid * 8) + 1),1))
      fxlmidx0 = ifxlm(fxadesc,1,fxloopstart0)
      DO col = fxloopstart0, MIN(((fxcellid * 8) + 8),512), 1
        CALL fft(a(1,fxlmidx0),brt,w)
        fxlmidx0 = (fxlmidx0 + 1)
      ENDDO
C     ENDLOCAL
C     ENDPDO
      RETURN 
      END
CC    NOCHECK 
C     DO i = 1, 512, 1
C     j = brt(i)
C     IF (i.LT.j) THEN
C     tr = a(1,j)
C     ti = a(2,j)
C     a(1,j) = a(1,i)
C     a(2,j) = a(2,i)
C     a(1,i) = tr
C     a(2,i) = ti
C     ENDIF
C     ENDDO
C     ijdiff = 1
C     stride = 2
C     spowerofw = 256
C     DO stage = 1, 9, 1
C     first = 1
C     DO powerofw = 1, 256, spowerofw
C     pwr = w(1,powerofw)
C     pwi = w(2,powerofw)
C     DO i = first, 512, stride
C     j = (i + ijdiff)
C     jr = a(1,j)
C     ji = a(2,j)
C     ir = a(1,i)
C     ii = a(2,i)
C     tr = ((jr * pwr) - (ji * pwi))
C     ti = ((jr * pwi) + (ji * pwr))
C     a(1,j) = (ir - tr)
C     a(2,j) = (ii - ti)
C     a(1,i) = (ir + tr)
C     a(2,i) = (ii + ti)
C     ENDDO
C     first = (first + 1)
C     ENDDO
C     ijdiff = stride
C     stride = (stride * 2)
C     spowerofw = (spowerofw / 2)
C     ENDDO
C     RETURN 
C     END
      SUBROUTINE fft(a,brt,w)
      INTEGER fxcellid
      INTEGER powerofw
      INTEGER i
      INTEGER j
      EXTERNAL fx_procstart
      INTEGER stage
      INTEGER first
      INTEGER fxdistarg
      INTEGER spowerofw
      REAL ii
      REAL ji
      INTEGER ijdiff
      REAL ir
      REAL ti
      REAL jr
      REAL tr
      INTEGER stride
      EXTERNAL msg_reduce
      REAL pwi
      REAL pwr
      REAL a(2,512)
      REAL w(2,256)
      INTEGER brt(512)
      COMMON /fxcommon/ fxcellid,fxdistarg
C     NOCHECK 
      DO i = 1, 512, 1
        j = brt(i)
        IF (i.LT.j) THEN
          tr = a(1,j)
          ti = a(2,j)
          a(1,j) = a(1,i)
          a(2,j) = a(2,i)
          a(1,i) = tr
          a(2,i) = ti
        ENDIF
      ENDDO
      ijdiff = 1
      stride = 2
      spowerofw = 256
      DO stage = 1, 9, 1
        first = 1
        DO powerofw = 1, 256, spowerofw
          pwr = w(1,powerofw)
          pwi = w(2,powerofw)
          DO i = first, 512, stride
            j = (i + ijdiff)
            jr = a(1,j)
            ji = a(2,j)
            ir = a(1,i)
            ii = a(2,i)
            tr = ((jr * pwr) - (ji * pwi))
            ti = ((jr * pwi) + (ji * pwr))
            a(1,j) = (ir - tr)
            a(2,j) = (ii - ti)
            a(1,i) = (ir + tr)
            a(2,i) = (ii + ti)
          ENDDO
          first = (first + 1)
        ENDDO
        ijdiff = stride
        stride = (stride * 2)
        spowerofw = (spowerofw / 2)
      ENDDO
      RETURN 
      END
CC    TEMPLATE t(512)
CC    ALIGN a(I,J) WITH t(J)
CC    DISTRIBUTE t(BLOCK_CYCLIC(8,64))
C     epsilon = 1e-4
C     errors = 0
C     PDO (k = 1:512)
C     PIN a(:,k)
C     LOCAL
C     fxloopstart0 = (MAX(((fxcellid * 8) + 1),1))
C     fxlmidx0 = ifxlm(fxadesc,1,fxloopstart0)
C     DO k = fxloopstart0, MIN(((fxcellid * 8) + 8),512), 1
C     sign = 1
C     IF (((k / 2) * 2).EQ.k) sign = (-1)
C     DO j = 1, 512, 1
C     IF (real(a(j,k)).GT.((sign * 512) + epsilon)) errors = (errors
C    $ + 1)
C     IF (real(a(j,k)).LT.((sign * 512) - epsilon)) errors = (errors
C    $ + 1)
C     IF (aimag(a(j,k)).GT.((sign * 512) + epsilon)) errors = (errors
C    $ + 1)
C     IF (aimag(a(j,k)).LT.((sign * 512) - epsilon)) errors = (errors
C    $ + 1)
C     sign = ( -sign)
C     ENDDO
C     fxlmidx0 = (fxlmidx0 + 1)
C     ENDDO
C     ENDLOCAL
C     ENDPDO
C     IF (errors.GT.0) THEN
C     WRITE (unit=6,fmt=*) 'errors = ',errors
C     ENDIF
C     END
      SUBROUTINE chkmat(a,fxadesc)
      INTEGER fxlmidx0
      INTRINSIC real
      REAL real
      INTEGER sign
      INTEGER fxcellid
      INTEGER fxloopstart0
      EXTERNAL fxinitdescck
      INTEGER j
      INTEGER k
      EXTERNAL fx_procstart
      INTRINSIC aimag
      REAL aimag
      INTRINSIC float
      REAL float
      EXTERNAL ifxlm
      INTEGER ifxlm
      INTEGER fxdistarg
      EXTERNAL fxdblcheck
      EXTERNAL msg_reduce
      INTEGER errors
      EXTERNAL ifxceil
      INTEGER ifxceil
      REAL epsilon
      EXTERNAL fxdistcheck
      COMPLEX a(512,8)
      INTEGER fxadesc(71,2)
      INTEGER fxdistarray(6,20)
      COMMON /fxcommon/ fxcellid,fxdistarg
      CALL fxdblcheck(fxdistarg,1,'chkmat')
      fxdistarg = 0
      CALL fxdistcheck(fxadesc,1,1,'chkmat')
      fxdistarray(1,1) = 2
      fxdistarray(2,1) = 0
      fxdistarray(3,1) = 8
      fxdistarray(4,1) = 64
      fxdistarray(5,1) = 0
      fxdistarray(6,1) = 0
      fxdistarray(3,2) = 512
      CALL fxinitdescck(1,2,fxdistarray,fxadesc,'a','chkmat')
C     TEMPLATE t(512)
C     ALIGN a(I,J) WITH t(J)
C     DISTRIBUTE t(BLOCK_CYCLIC(8,64))
      epsilon = 1e-4
      errors = 0
C     PDO (k = 1:512)
C     PIN a(:,k)
C     LOCAL
      fxloopstart0 = (MAX(((fxcellid * 8) + 1),1))
      fxlmidx0 = ifxlm(fxadesc,1,fxloopstart0)
      DO k = fxloopstart0, MIN(((fxcellid * 8) + 8),512), 1
        sign = 1
        IF (((k / 2) * 2).EQ.k) THEN
          sign = (-1)
        ENDIF
        DO j = 1, 512, 1
          IF (real(a(j,fxlmidx0)).GT.((sign * 512) + epsilon)) THEN
            errors = (errors + 1)
          ENDIF
          IF (real(a(j,fxlmidx0)).LT.((sign * 512) - epsilon)) THEN
            errors = (errors + 1)
          ENDIF
          IF (aimag(a(j,fxlmidx0)).GT.((sign * 512) + epsilon)) THEN
            errors = (errors + 1)
          ENDIF
          IF (aimag(a(j,fxlmidx0)).LT.((sign * 512) - epsilon)) THEN
            errors = (errors + 1)
          ENDIF
          sign = ( -sign)
        ENDDO
        fxlmidx0 = (fxlmidx0 + 1)
      ENDDO
C     ENDLOCAL
C     ENDPDO
      IF (errors.GT.0) THEN
        IF (fxcellid.EQ.0) THEN
          WRITE (unit=6,fmt=*) 'errors = ',errors
        ENDIF
      ENDIF
      END
C     tsecs = ((t1clocks + t2clocks) / 2e7)
C     fsecs = ((f1clocks + f2clocks) / 2e7)
C     secs = (tsecs + fsecs)
C     tpercent = ((tsecs / secs) * 100)
C     fpercent = ((fsecs / secs) * 100)
C     flops = 23592960.
C     mflops = ((flops / 1e6) / secs)
C     eff = ((fsecs / secs) * 100)
C     WRITE (unit=6,fmt=*) '+++++++++++++++++++++++++++++++'
C     WRITE (unit=6,fmt=*) '2D FFT: ',512,' X ',512,' Matrix'
C     WRITE (unit=6,fmt=*) '+++++++++++++++++++++++++++++++'
C     WRITE (unit=6,fmt=*) 'Time per input vector:'
C     WRITE (unit=6,fmt=*) ' '
C     WRITE (unit=6,fmt=*) 'Step 1: fft          : ',f1clocks / 2e7,
C    $'sec  '
C     WRITE (unit=6,fmt=*) 'Step 2: transpose    : ',t1clocks / 2e7,
C    $'sec  '
C     WRITE (unit=6,fmt=*) 'Step 3: fft          : ',f2clocks / 2e7,
C    $'sec  '
C     WRITE (unit=6,fmt=*) 'Step 4: transpose    : ',t2clocks / 2e7,
C    $'sec  '
C     WRITE (unit=6,fmt=*) ' '
C     WRITE (unit=6,fmt=*) 'total transpose      : ',tsecs,'sec  ',
C    $tpercent,'%'
C     WRITE (unit=6,fmt=*) 'total ffts           : ',fsecs,'sec  ',
C    $fpercent,'%'
C     WRITE (unit=6,fmt=*) 'total(s)             : ',secs,'sec'
C     WRITE (unit=6,fmt=*) ' '
C     WRITE (unit=6,fmt=*) 'mflop/s              : ',mflops
C     WRITE (unit=6,fmt=*) 'efficiency           : ',eff
C     WRITE (unit=6,fmt=*) ' '
C     END
      SUBROUTINE prperf(t1clocks,t2clocks,f1clocks,f2clocks)
      INTEGER t1clocks
      INTEGER t2clocks
      REAL secs
      INTEGER fxcellid
      INTEGER fpercent
      INTEGER tpercent
      EXTERNAL fx_procstart
      REAL fsecs
      REAL tsecs
      REAL flops
      INTEGER fxdistarg
      EXTERNAL fxdblcheck
      EXTERNAL msg_reduce
      REAL mflops
      REAL eff
      INTEGER f1clocks
      INTEGER f2clocks
      COMMON /fxcommon/ fxcellid,fxdistarg
      CALL fxdblcheck(fxdistarg,0,'prperf')
      tsecs = ((t1clocks + t2clocks) / 2e7)
      fsecs = ((f1clocks + f2clocks) / 2e7)
      secs = (tsecs + fsecs)
      tpercent = ((tsecs / secs) * 100)
      fpercent = ((fsecs / secs) * 100)
      flops = 23592960.
      mflops = ((flops / 1e6) / secs)
      eff = ((fsecs / secs) * 100)
      IF (fxcellid.EQ.0) THEN
        WRITE (unit=6,fmt=*) '+++++++++++++++++++++++++++++++'
      ENDIF
      IF (fxcellid.EQ.0) THEN
        WRITE (unit=6,fmt=*) '2D FFT: ',512,' X ',512,' Matrix'
      ENDIF
      IF (fxcellid.EQ.0) THEN
        WRITE (unit=6,fmt=*) '+++++++++++++++++++++++++++++++'
      ENDIF
      IF (fxcellid.EQ.0) THEN
        WRITE (unit=6,fmt=*) 'Time per input vector:'
      ENDIF
      IF (fxcellid.EQ.0) THEN
        WRITE (unit=6,fmt=*) ' '
      ENDIF
      IF (fxcellid.EQ.0) THEN
        WRITE (unit=6,fmt=*) 'Step 1: fft          : ',f1clocks / 2e7
     $,'sec  '
      ENDIF
      IF (fxcellid.EQ.0) THEN
        WRITE (unit=6,fmt=*) 'Step 2: transpose    : ',t1clocks / 2e7
     $,'sec  '
      ENDIF
      IF (fxcellid.EQ.0) THEN
        WRITE (unit=6,fmt=*) 'Step 3: fft          : ',f2clocks / 2e7
     $,'sec  '
      ENDIF
      IF (fxcellid.EQ.0) THEN
        WRITE (unit=6,fmt=*) 'Step 4: transpose    : ',t2clocks / 2e7
     $,'sec  '
      ENDIF
      IF (fxcellid.EQ.0) THEN
        WRITE (unit=6,fmt=*) ' '
      ENDIF
      IF (fxcellid.EQ.0) THEN
        WRITE (unit=6,fmt=*) 'total transpose      : ',tsecs,'sec  ',
     $tpercent,'%'
      ENDIF
      IF (fxcellid.EQ.0) THEN
        WRITE (unit=6,fmt=*) 'total ffts           : ',fsecs,'sec  ',
     $fpercent,'%'
      ENDIF
      IF (fxcellid.EQ.0) THEN
        WRITE (unit=6,fmt=*) 'total(s)             : ',secs,'sec'
      ENDIF
      IF (fxcellid.EQ.0) THEN
        WRITE (unit=6,fmt=*) ' '
      ENDIF
      IF (fxcellid.EQ.0) THEN
        WRITE (unit=6,fmt=*) 'mflop/s              : ',mflops
      ENDIF
      IF (fxcellid.EQ.0) THEN
        WRITE (unit=6,fmt=*) 'efficiency           : ',eff
      ENDIF
      IF (fxcellid.EQ.0) THEN
        WRITE (unit=6,fmt=*) ' '
      ENDIF
      END
