SUBROUTINE SUBMAT

!**** *SUBMAT*  Initialize vertical structure matrix

!     Purpose.
!     --------
!           Initialize vertical structure matrix used for semi-implicit
!         scheme and the normal mode initialization.

!**   Interface.
!     ----------
!        *CALL* *SUBMAT

!        Explicit arguments :  None
!        --------------------
!        Implicit arguments :
!        --------------------
!           Matrix SIB in YOMDYN
!     Method.
!     -------
!        See documentation

!     Externals.    SIGAM - gamma operator of the semi-implicit
!     ----------    SITNU - tau and nu operators of the semi-implicit

!     Reference.
!     ----------
!        ECMWF Research Department documentation of the IFS

!     Author.
!     -------
!        Mats Hamrud and Philippe Courtier  *ECMWF*

!     Modifications.
!     --------------
!        Original : 87-10-15
!        M.Hamrud      01-Oct-2003 CY28 Cleaning
!     ------------------------------------------------------------------

USE PARKIND1  ,ONLY : JPIM     ,JPRB
USE YOMHOOK   ,ONLY : LHOOK,   DR_HOOK

USE YOMDIM   , ONLY : NFLEVG
USE YOMDYN   , ONLY : SIB

IMPLICIT NONE

!     ZD   : DIVERGENCE ARRAY
!     ZT   : TEMPERATURE ARRAY
!     ZSP  : SURFACE PRESSURE ARRAY

REAL(KIND=JPRB) :: ZD(NFLEVG,NFLEVG)
REAL(KIND=JPRB) :: ZT(NFLEVG,NFLEVG)
REAL(KIND=JPRB) :: ZSP(NFLEVG)

INTEGER(KIND=JPIM) :: JLEV, JLON
REAL(KIND=JPRB) :: ZHOOK_HANDLE

#include "sigam.intfb.h"
#include "sitnu.intfb.h"

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

!*       1.    INITIALIZE.
!              -----------

IF (LHOOK) CALL DR_HOOK('SUBMAT',0,ZHOOK_HANDLE)
DO JLEV=1,NFLEVG
  DO JLON=1,NFLEVG
    ZD(JLON,JLEV)=1.0_JPRB-MIN(ABS(REAL(JLON-JLEV,JPRB)),1.0_JPRB)
  ENDDO
ENDDO

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

!*       2.    COMPUTES THE MATRIX.
!              --------------------

CALL SITNU(1,NFLEVG,ZD,ZT,ZSP,NFLEVG)
CALL SIGAM(1,NFLEVG,ZD,ZT,ZSP,NFLEVG)
!      ----------------------------------------------------------------

!*       3.    STORAGE OF MATRIX.
!              ------------------

DO JLEV=1,NFLEVG
  DO JLON=1,NFLEVG
    SIB(JLON,JLEV)=ZD(JLON,JLEV)
  ENDDO
ENDDO

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

IF (LHOOK) CALL DR_HOOK('SUBMAT',1,ZHOOK_HANDLE)
END SUBROUTINE SUBMAT
