      module types
      integer ,  parameter:: I4B=SELECTED_INT_KIND (9) 
      integer ,  parameter:: I2B=SELECTED_INT_KIND (4) 
      integer ,  parameter:: I1B=SELECTED_INT_KIND (2) 
      integer ,  parameter:: SP=KIND (1.0D0) 
      end module


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


      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

         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

         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

      end interface
      end module


      subroutine connect0(g11, g12, g13, g22, g23, g33, gup11, gup12, gu&
     &p13, gup22, gup23, gup33, c111, c112, c113, c122, c123, c133, c211&
     &, c212, c213, c222, c223, c233, c311, c312, c313, c322, c323, c333&
     &, nx, ny, nz, h)
      use types
      use hpfprocessors
      real (SP),  dimension(:,:,:),intent(in):: g11,g12,g13,g22,g23,g33 

      real (SP),  dimension(:,:,:),intent(in):: gup11,gup12,gup13,gup22,&
     &gup23,gup33 
      real (SP),  dimension(:,:,:),intent(out):: c111,c112,c113,c122,c12&
     &3,c133 
      real (SP),  dimension(:,:,:),intent(out):: c211,c212,c213,c222,c22&
     &3,c233 
      real (SP),  dimension(:,:,:),intent(out):: c311,c312,c313,c322,c32&
     &3,c333 
!HPF$      distribute g11 * (*,*,block) onto * PROC
!HPF$      align with * g11 :: g12,g13,g22,g23,g33
!HPF$      align with * g11 :: gup11,gup12,gup13,gup22,gup23,gup33
!HPF$      align with * g11 :: c111,c112,c113,c122,c123,c133
!HPF$      align with * g11 :: c211,c212,c213,c222,c223,c233
!HPF$      align with * g11 :: c311,c312,c313,c322,c323,c333
      integer (I4B):: nx,ny,nz
      real (SP):: h
      real (SP),  dimension(size (g11,1),size (g11,2),size (g11,3)):: t1&
     &1,t12,t13,t21,t22,t23,t31,t32,t33 
!HPF$      align with g11 :: t11,t12,t13,t21,t22,t23,t31,t32,t33
      integer (I4B):: i,j,k
      interface 
         subroutine connect1(g11, g12, g13, g22, g23, g33, gup11, gup12,&
     & gup13, gup22, gup23, gup33, c111, c112, c113, c122, c123, c133, c&
     &211, c212, c213, c222, c223, c233, c311, c312, c313, c322, c323, c&
     &333, nx, ny, nz, h)
         use types
         use hpfprocessors
         use diff_interface
         real (SP),  dimension(:,:,:),intent(in):: g11,g12,g13,g22,g23,g&
     &33 
         real (SP),  dimension(:,:,:),intent(in):: gup11,gup12,gup13,gup&
     &22,gup23,gup33 
         real (SP),  dimension(:,:,:),intent(inout):: c111,c112,c113,c12&
     &2,c123,c133 
         real (SP),  dimension(:,:,:),intent(inout):: c211,c212,c213,c22&
     &2,c223,c233 
         real (SP),  dimension(:,:,:),intent(inout):: c311,c312,c313,c32&
     &2,c323,c333 
!HPF$      distribute g11 * (*,*,block) onto * PROC
!HPF$      align with * g11 :: g12,g13,g22,g23,g33
!HPF$      align with * g11 :: gup11,gup12,gup13,gup22,gup23,gup33
!HPF$      align with * g11 :: c111,c112,c113,c122,c123,c133
!HPF$      align with * g11 :: c211,c212,c213,c222,c223,c233
!HPF$      align with * g11 :: c311,c312,c313,c322,c323,c333
         integer (I4B):: nx,ny,nz
         real (SP):: h
         end subroutine

         subroutine connect2(g11, g12, g13, g22, g23, g33, gup11, gup12,&
     & gup13, gup22, gup23, gup33, c111, c112, c113, c122, c123, c133, c&
     &211, c212, c213, c222, c223, c233, c311, c312, c313, c322, c323, c&
     &333, nx, ny, nz, h)
         use types
         use hpfprocessors
         use diff_interface
         real (SP),  dimension(:,:,:),intent(in):: g11,g12,g13,g22,g23,g&
     &33 
         real (SP),  dimension(:,:,:),intent(in):: gup11,gup12,gup13,gup&
     &22,gup23,gup33 
         real (SP),  dimension(:,:,:),intent(inout):: c111,c112,c113,c12&
     &2,c123,c133 
         real (SP),  dimension(:,:,:),intent(inout):: c211,c212,c213,c22&
     &2,c223,c233 
         real (SP),  dimension(:,:,:),intent(inout):: c311,c312,c313,c32&
     &2,c323,c333 
!HPF$      distribute g11 * (*,*,block) onto * PROC
!HPF$      align with * g11 :: g12,g13,g22,g23,g33
!HPF$      align with * g11 :: gup11,gup12,gup13,gup22,gup23,gup33
!HPF$      align with * g11 :: c111,c112,c113,c122,c123,c133
!HPF$      align with * g11 :: c211,c212,c213,c222,c223,c233
!HPF$      align with * g11 :: c311,c312,c313,c322,c323,c333
         integer (I4B):: nx,ny,nz
         real (SP):: h
         end subroutine

         subroutine connect3(g11, g12, g13, g22, g23, g33, gup11, gup12,&
     & gup13, gup22, gup23, gup33, c111, c112, c113, c122, c123, c133, c&
     &211, c212, c213, c222, c223, c233, c311, c312, c313, c322, c323, c&
     &333, nx, ny, nz, h)
         use types
         use hpfprocessors
         use diff_interface
         real (SP),  dimension(:,:,:),intent(in):: g11,g12,g13,g22,g23,g&
     &33 
         real (SP),  dimension(:,:,:),intent(in):: gup11,gup12,gup13,gup&
     &22,gup23,gup33 
         real (SP),  dimension(:,:,:),intent(inout):: c111,c112,c113,c12&
     &2,c123,c133 
         real (SP),  dimension(:,:,:),intent(inout):: c211,c212,c213,c22&
     &2,c223,c233 
         real (SP),  dimension(:,:,:),intent(inout):: c311,c312,c313,c32&
     &2,c323,c333 
!HPF$      distribute g11 * (*,*,block) onto * PROC
!HPF$      align with * g11 :: g12,g13,g22,g23,g33
!HPF$      align with * g11 :: gup11,gup12,gup13,gup22,gup23,gup33
!HPF$      align with * g11 :: c111,c112,c113,c122,c123,c133
!HPF$      align with * g11 :: c211,c212,c213,c222,c223,c233
!HPF$      align with * g11 :: c311,c312,c313,c322,c323,c333
         integer (I4B):: nx,ny,nz
         real (SP):: h
         end subroutine

         subroutine connect4(g11, g12, g13, g22, g23, g33, gup11, gup12,&
     & gup13, gup22, gup23, gup33, c111, c112, c113, c122, c123, c133, c&
     &211, c212, c213, c222, c223, c233, c311, c312, c313, c322, c323, c&
     &333, nx, ny, nz, h)
         use types
         use hpfprocessors
         use diff_interface
         real (SP),  dimension(:,:,:),intent(in):: g11,g12,g13,g22,g23,g&
     &33 
         real (SP),  dimension(:,:,:),intent(in):: gup11,gup12,gup13,gup&
     &22,gup23,gup33 
         real (SP),  dimension(:,:,:),intent(inout):: c111,c112,c113,c12&
     &2,c123,c133 
         real (SP),  dimension(:,:,:),intent(inout):: c211,c212,c213,c22&
     &2,c223,c233 
         real (SP),  dimension(:,:,:),intent(inout):: c311,c312,c313,c32&
     &2,c323,c333 
!HPF$      distribute g11 * (*,*,block) onto * PROC
!HPF$      align with * g11 :: g12,g13,g22,g23,g33
!HPF$      align with * g11 :: gup11,gup12,gup13,gup22,gup23,gup33
!HPF$      align with * g11 :: c111,c112,c113,c122,c123,c133
!HPF$      align with * g11 :: c211,c212,c213,c222,c223,c233
!HPF$      align with * g11 :: c311,c312,c313,c322,c323,c333
         integer (I4B):: nx,ny,nz
         real (SP):: h
         end subroutine

         subroutine connect5(g11, g12, g13, g22, g23, g33, gup11, gup12,&
     & gup13, gup22, gup23, gup33, c111, c112, c113, c122, c123, c133, c&
     &211, c212, c213, c222, c223, c233, c311, c312, c313, c322, c323, c&
     &333, nx, ny, nz, h)
         use types
         use hpfprocessors
         use diff_interface
         real (SP),  dimension(:,:,:),intent(in):: g11,g12,g13,g22,g23,g&
     &33 
         real (SP),  dimension(:,:,:),intent(in):: gup11,gup12,gup13,gup&
     &22,gup23,gup33 
         real (SP),  dimension(:,:,:),intent(inout):: c111,c112,c113,c12&
     &2,c123,c133 
         real (SP),  dimension(:,:,:),intent(inout):: c211,c212,c213,c22&
     &2,c223,c233 
         real (SP),  dimension(:,:,:),intent(inout):: c311,c312,c313,c32&
     &2,c323,c333 
!HPF$      distribute g11 * (*,*,block) onto * PROC
!HPF$      align with * g11 :: g12,g13,g22,g23,g33
!HPF$      align with * g11 :: gup11,gup12,gup13,gup22,gup23,gup33
!HPF$      align with * g11 :: c111,c112,c113,c122,c123,c133
!HPF$      align with * g11 :: c211,c212,c213,c222,c223,c233
!HPF$      align with * g11 :: c311,c312,c313,c322,c323,c333
         integer (I4B):: nx,ny,nz
         real (SP):: h
         end subroutine

         subroutine connect6(g11, g12, g13, g22, g23, g33, gup11, gup12,&
     & gup13, gup22, gup23, gup33, c111, c112, c113, c122, c123, c133, c&
     &211, c212, c213, c222, c223, c233, c311, c312, c313, c322, c323, c&
     &333, nx, ny, nz, h)
         use types
         use hpfprocessors
         use diff_interface
         real (SP),  dimension(:,:,:),intent(in):: g11,g12,g13,g22,g23,g&
     &33 
         real (SP),  dimension(:,:,:),intent(in):: gup11,gup12,gup13,gup&
     &22,gup23,gup33 
         real (SP),  dimension(:,:,:),intent(inout):: c111,c112,c113,c12&
     &2,c123,c133 
         real (SP),  dimension(:,:,:),intent(inout):: c211,c212,c213,c22&
     &2,c223,c233 
         real (SP),  dimension(:,:,:),intent(inout):: c311,c312,c313,c32&
     &2,c323,c333 
!HPF$      distribute g11 * (*,*,block) onto * PROC
!HPF$      align with * g11 :: g12,g13,g22,g23,g33
!HPF$      align with * g11 :: gup11,gup12,gup13,gup22,gup23,gup33
!HPF$      align with * g11 :: c111,c112,c113,c122,c123,c133
!HPF$      align with * g11 :: c211,c212,c213,c222,c223,c233
!HPF$      align with * g11 :: c311,c312,c313,c322,c323,c333
         integer (I4B):: nx,ny,nz
         real (SP):: h
         end subroutine

      end interface
      c111 = 0
      c112 = 0
      c113 = 0
      c122 = 0
      c123 = 0
      c133 = 0
      c211 = 0
      c212 = 0
      c213 = 0
      c222 = 0
      c223 = 0
      c233 = 0
      c311 = 0
      c312 = 0
      c313 = 0
      c322 = 0
      c323 = 0
      c333 = 0
      call connect1 (g11,g12,g13,g22,g23,g33,gup11,gup12,gup13,gup22,gup&
     &23,gup33,c111,c112,c113,c122,c123,c133,c211,c212,c213,c222,c223,c2&
     &33,c311,c312,c313,c322,c323,c333,nx,ny,nz,h)
      call connect2 (g11,g12,g13,g22,g23,g33,gup11,gup12,gup13,gup22,gup&
     &23,gup33,c111,c112,c113,c122,c123,c133,c211,c212,c213,c222,c223,c2&
     &33,c311,c312,c313,c322,c323,c333,nx,ny,nz,h)
      call connect3 (g11,g12,g13,g22,g23,g33,gup11,gup12,gup13,gup22,gup&
     &23,gup33,c111,c112,c113,c122,c123,c133,c211,c212,c213,c222,c223,c2&
     &33,c311,c312,c313,c322,c323,c333,nx,ny,nz,h)
      call connect4 (g11,g12,g13,g22,g23,g33,gup11,gup12,gup13,gup22,gup&
     &23,gup33,c111,c112,c113,c122,c123,c133,c211,c212,c213,c222,c223,c2&
     &33,c311,c312,c313,c322,c323,c333,nx,ny,nz,h)
      call connect5 (g11,g12,g13,g22,g23,g33,gup11,gup12,gup13,gup22,gup&
     &23,gup33,c111,c112,c113,c122,c123,c133,c211,c212,c213,c222,c223,c2&
     &33,c311,c312,c313,c322,c323,c333,nx,ny,nz,h)
      call connect6 (g11,g12,g13,g22,g23,g33,gup11,gup12,gup13,gup22,gup&
     &23,gup33,c111,c112,c113,c122,c123,c133,c211,c212,c213,c222,c223,c2&
     &33,c311,c312,c313,c322,c323,c333,nx,ny,nz,h)
      return
      end subroutine

