       program ST
C      =======================================================
C      array section with strides
C      =======================================================
C      please send comments to haupt@npac.syr.edu

   
       integer N,M,K1,K2,I
       parameter ( N = 2048)
       parameter ( M = N/2 )
       real, dimension(N,N) :: A, B
       logical debug
       data debug /.false./       
c       data debug /.true./       

CHPF$  processors p(4,2)
CHPF$  template d(N,N)
CHPF$  distribute d(block,block) onto p
CHPF$  align WITH d :: A,B

       A=0
       K1=N-1
       K2=N/2      
 
       IF(.NOT.DEBUG) THEN
C
C       start_timer
C         call pcrc_clock(0)

       do it=1,4
         FORALL(I=1:N,J=1:N) B(I,J)= I/(J+1.0)
         A(1:N:2,K1)=B(1:M,K2)
         FORALL(I=2:M) A(I,K1)=A(2*I-1,K1)*B(I,1)
       enddo  
    
C         stop_timer
C         call pcrc_clock(1)

       ELSE
       
         FORALL(I=1:N,J=1:N) B(I,J)= I/(J+1.0)

          write(6,*) ' ---->  B(I,J)=I/(J+1.0)'
         DO i=1,3
          write(6,*) B(i,5),' should be',i/6.0
         ENDDO
         DO i=N-2,N
          write(6,*) B(i,5),' should be',i/6.0
         ENDDO
         write(6,*) ' '        

       A(1:N:2,K1)=B(1:M,K2)

          write(6,*) ' ---->  A(1:N:2,K1)=B(1:M,K2)'
          DO L=1,5
           ll=mod(l,2)
           write(6,*) a(l,k1),' should be', (l/2+1)/(k2+1.0)*ll
          ENDDO
          DO L=N-4,N
           ll=mod(l,2)
           write(6,*) a(l,k1),' should be', (l/2+1)/(k2+1.0)*ll
          ENDDO
          write(6,*) ' '        

       FORALL(I=2:M) A(I,K1)=A(2*I-1,K1)*B(I,1)

          write(6,*) ' ----> FORALL(I=2:M) A(I,K1)=A(2*I-1,K1)*B(I,1)'
          DO L=2,5
          q=l/(k2+1.0)
          x1=l/2.0
          y1=q*x1
          write(6,*) a(l,k1),' should be',y1 
         ENDDO
          DO L=M-3,M
          q=l/(k2+1.0)
          x1=l/2.0
          y1=q*x1
          write(6,*) a(l,k1),' should be',y1 
         ENDDO
       ENDIF

      print *,' ' 
      print *,'*******************************'
      print *,'         PARKBENCH '
      print *,' LOW LEVEL HPF BENCHMARK SUITE'
      print *,'         ST  KERNEL'
      print *,' PROBLEM SIZE: N =', N
      print *,' FINAL RESULT = ', A(M-1,K1)
      print *,' EXPECTED VALUE FOR SIZE 2048' 
      print *,' IS  510.502 +/- 0.001'
      print *,'*******************************'

c     print execution time

      STOP
      END





