!====================================================================
!  拡散方程式解法ルーチン(C-N法)
!  係数行列の計算
!
!  履歴  2000/01/07  小高正嗣
!====================================================================
      subroutine SETMTRX
     O  (  ELM_FOR, ELM_BCK, DL, D, DU,
     G     FDZ, 
     D     DTI, NZ, NZB      )
!--------------------------------------------------------------------
      implicit real*8 ( a-h,o-z )
!--------------------------------------------------------------------

      dimension FDZ(NZ)
      dimension ELM_FOR(NZ, NZ), ELM_BCK(NZ, NZ) 
      dimension DL(NZ-1), D(NZ), DU(NZ-1)

!--------------------------------------------------------------------

      do jz = 1, NZ
         do iz = 1, NZ
            ELM_FOR(iz,jz) = 0.0D0
            ELM_BCK(iz,jz) = 0.0D0
         end do
      end do

      do iz = 1, NZ
         ELM_FOR(iz,iz) = 2.0D0 * ( 1.0D0 + FDZ(iz)**2 / DTI )
         ELM_BCK(iz,iz) = - 2.0D0 * ( 1.0D0 - FDZ(iz)**2 / DTI )
      end do

      do iz = 1, NZ-1
         ELM_FOR(iz,iz+1) = -1.0D0
         ELM_FOR(iz+1,iz) = -1.0D0
         ELM_BCK(iz,iz+1) = - ELM_FOR(iz,iz+1) 
         ELM_BCK(iz+1,iz) = - ELM_FOR(iz+1,iz) 
      end do

      ELM_FOR(NZ,NZ-1) = -2.0D0 
      ELM_BCK(NZ,NZ-1) =  2.0D0 

!--------------------------------------------------------------------
      do iz = 1, NZ
         D(iz)  = ELM_FOR(iz,iz)
      end do
         
      do iz = 1, NZ-1
         DL(iz) = ELM_FOR(iz+1,iz)
         DU(iz) = ELM_FOR(iz,iz+1)
      end do
!--------------------------------------------------------------------

      return
      end
