
      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_k5(k11m1,k12m1,k13m1,k21m1,k22m1,k23m1,k31m1,k32m1,k33m1, &
                    t11,t12,t13,t21,t22,t23,t31,t32,t33,dt)

use types
use hpfprocessors

real(SP), dimension(:,:,:), intent(INOUT):: k11m1,k12m1,k13m1,k21m1,k22m1, &
                                            k23m1,k31m1,k32m1,k33m1
real(SP), dimension(:,:,:), intent(INOUT):: t11,t12,t13,t21,t22,t23,t31,t32,t33
real(SP) dt

!HPF$ DISTRIBUTE *(*,*,BLOCK) ONTO *PROC :: k11m1 
!HPF$ ALIGN WITH *k11m1 :: k12m1,k13m1,k21m1,k22m1,k23m1,k31m1,k32m1,k33m1
!HPF$ ALIGN WITH *k11m1 :: t11,t12,t13,t21,t22,t23,t31,t32,t33

!     Evolve one timestep via leapfrog method ( i.e. time-centered)

      t11 = 2.0d0*dt*t11 + k11m1 
      t12 = 2.0d0*dt*t12 + k12m1 
      t13 = 2.0d0*dt*t13 + k13m1 
      t21 = 2.0d0*dt*t21 + k21m1 
      t22 = 2.0d0*dt*t22 + k22m1 
      t23 = 2.0d0*dt*t23 + k23m1 
      t31 = 2.0d0*dt*t31 + k31m1 
      t32 = 2.0d0*dt*t32 + k32m1 
      t33 = 2.0d0*dt*t33 + k33m1 

      k11m1 = t11
      k12m1 = t12
      k13m1 = t13
      k21m1 = t21
      k22m1 = t22
      k23m1 = t23
      k31m1 = t31
      k32m1 = t32
      k33m1 = t33

      return
      end




