SUBROUTINE CMACTL

!**** *CMACTL*  - NORMAL MODE INITIALIZATION

!     Purpose.
!     --------

!**   Interface.
!     ----------
!        *CALL* *CMACTL

!        Explicit arguments :
!        --------------------
!        None

!        Implicit arguments :
!        --------------------
!        None

!     Method.
!     -------
!        See documentation

!     Externals.
!     ----------

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

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

!     Modifications.
!     --------------
!        Original : 87-10-15
!        F.Rabier : 91-08-30 : NEW CALL TO NNMI2
!        M. Fisher       : 95-04-20 : added calls to ABORT 
!        M.Hamrud      01-Oct-2003 CY28 Cleaning
!        M. Drusch       : 07-01-17 : introduce nconf 302  
!     ------------------------------------------------------------------

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

USE YOMCT0   , ONLY : NCONF
USE YOMNMIA  , ONLY : LNMI     ,LNLNMI
USE YOMLUN   , ONLY : NULOUT

IMPLICIT NONE

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

!*       1.    LINEAR NORMAL MODE INITIALIZATION.
!              ----------------------------------

REAL(KIND=JPRB) :: ZHOOK_HANDLE

#include "abor1.intfb.h"
#include "nnmi2tl.intfb.h"
#include "nnmi3tl.intfb.h"
IF (LHOOK) CALL DR_HOOK('CMACTL',0,ZHOOK_HANDLE)
IF (LNMI) THEN
  IF (NCONF == 201 &
     & .OR.NCONF == 421.OR.NCONF == 521) THEN  
! option 1 of NNMI2 : linear initialisation (MOPRJ with KMO=1)
    CALL NNMI2TL(1)
  ELSE
    WRITE (NULOUT,*) 'LNMI == .TRUE. IS INCOMPATIBLE WITH NCONF'
    CALL ABOR1('CMACTL: ABOR1 CALLED')
  ENDIF
ENDIF

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

!*       2.    NON-LINEAR NORMAL MODE INITIALIZATION.
!              --------------------------------------

IF (LNLNMI) THEN
  IF (NCONF == 201 &
     & .OR.NCONF == 421.OR.NCONF == 521) THEN  
! option 2 of NNMI2 : NITNMI iterations of 2D NMI sheme
    CALL NNMI2TL(2)
  ELSEIF (NCONF == 1 &
     & .OR.NCONF == 131 &
     & .OR.NCONF == 302 &
     & .OR.NCONF == 401.OR.NCONF == 501.OR.NCONF == 601 &
     & .OR.NCONF == 801) THEN  
    CALL NNMI3TL
  ELSE
    WRITE (NULOUT,*) 'LNLNMI == .TRUE. INCOMPATIBLE WITH NCONF'
    CALL ABOR1('CMACTL: ABOR1 CALLED')
  ENDIF

ENDIF

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

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