
      MODULE types
      
!    symbolic names for 4, 2, and 1 byte integers
	
	INTEGER, PARAMETER :: I4B = SELECTED_INT_KIND(9)
	INTEGER, PARAMETER :: I2B = SELECTED_INT_KIND(4)
	INTEGER, PARAMETER :: I1B = SELECTED_INT_KIND(2)

! and for single and double precision reals
!	INTEGER, PARAMETER :: SP = KIND(1.0)
!	INTEGER, PARAMETER :: DP = KIND(1.0D0)
	INTEGER, PARAMETER :: SP = KIND(1.0D0)

      END MODULE types


	
module hpfprocessors
!HPF$ PROCESSORS PROC(4)
end module hpfprocessors


module diff_interface

INTERFACE
subroutine diff_x(nx,ny,nz,h,f,df)
use types
use hpfprocessors
integer(I4B)                :: nx,ny,nz
real(SP) h
real(SP), dimension(:,:,:), intent(IN)  :: f
real(SP), dimension(:,:,:), intent(OUT) :: df

!HPF$ DISTRIBUTE *(*,*,BLOCK) ONTO *PROC :: f
!HPF$ ALIGN WITH *f                      :: df
end subroutine diff_x

subroutine diff_y(nx,ny,nz,h,f,df)
use types
use hpfprocessors
integer(I4B)                :: nx,ny,nz
real(SP) h
real(SP), dimension(:,:,:), intent(IN)  :: f
real(SP), dimension(:,:,:), intent(OUT) :: df

!HPF$ DISTRIBUTE *(*,*,BLOCK) ONTO *PROC :: f
!HPF$ ALIGN WITH *f                      :: df
end subroutine diff_y

subroutine diff_z(nx,ny,nz,h,f,df)
use types
use hpfprocessors
integer(I4B)                :: nx,ny,nz
real(SP) h
real(SP), dimension(:,:,:), intent(IN)  :: f
real(SP), dimension(:,:,:), intent(OUT) :: df

!HPF$ DISTRIBUTE *(*,*,BLOCK) ONTO *PROC :: f
!HPF$ ALIGN WITH *f                      :: df
end subroutine diff_z

END INTERFACE
end module diff_interface







subroutine evolve_k2(gup11,gup12,gup13,gup22,gup23,gup33,         &
                     t11,t12,t13,t21,t22,t23,t31,t32,t33) 

use types
use hpfprocessors

real(SP), dimension(:,:,:), intent(IN) :: gup11,gup12,gup13,gup22,gup23,gup33
real(SP), dimension(:,:,:), intent(INOUT):: t11,t12,t13,t21,t22,t23,t31,t32,t33

!HPF$ DISTRIBUTE *(*,*,BLOCK) ONTO *PROC :: gup11 
!HPF$ ALIGN WITH *gup11 :: gup12,gup13,gup22,gup23,gup33
!HPF$ ALIGN WITH *gup11 :: t11,t12,t13,t21,t22,t23,t31,t32,t33

real(SP),dimension(size(gup11,1),size(gup11,2),size(gup11,3)) ::    &
                                                             temp1,temp2,temp3
!HPF$ ALIGN WITH gup11 :: temp1,temp2,temp3


!   raise the first index of t{ab}


      temp1 = t11
      temp2 = t21
      temp3 = t31

      t11 = gup11 * temp1 + gup12 * temp2 + gup13 * temp3
      t21 = gup12 * temp1 + gup22 * temp2 + gup23 * temp3
      t31 = gup13 * temp1 + gup23 * temp2 + gup33 * temp3

      temp1 = t12
      temp2 = t22
      temp3 = t32

      t12 = gup11 * temp1 + gup12 * temp2 + gup13 * temp3
      t22 = gup12 * temp1 + gup22 * temp2 + gup23 * temp3
      t32 = gup13 * temp1 + gup23 * temp2 + gup33 * temp3

      temp1 = t13
      temp2 = t23
      temp3 = t33

      t13 = gup11 * temp1 + gup12 * temp2 + gup13 * temp3
      t23 = gup12 * temp1 + gup22 * temp2 + gup23 * temp3
      t33 = gup13 * temp1 + gup23 * temp2 + gup33 * temp3


      t11 = - t11
      t12 = - t12
      t13 = - t13
      t21 = - t21
      t22 = - t22
      t23 = - t23
      t31 = - t31
      t32 = - t32
      t33 = - t33

return
end









