SUBROUTINE CMACAD

!**** *CMACAD*  - ADJOINT OF NORMAL MODE INITIALIZATION

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

!**   Interface.
!     ----------
!        *CALL* *CMACAD

!        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 and J.N Thepaut : 91-01-15 (management of simulated observations)
!   M. Fisher                : 95-04-20 : added calls to ABORT
!        M.Hamrud      01-Oct-2003 CY28 Cleaning
!   M. Drusch                : 07-17-01 : nconf 302 added
!     ------------------------------------------------------------------

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

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

IMPLICIT NONE

!   1 : configuration of WRTRA      write (read) the trajectory
!   2 : configuration of LTINV      inverse Legendre transform
!   3 : configuration of FTINV      inverse Fourier transform
!   4 : configuration of GPC        grid point computations
!   5 : configuration of POS        post processing
!   6 : configuration of OBS        comparison to observations
!   7 : configuration of FTDIR      direct Fourier transform
!   8 : configuration of LTDIR      direct Legendre transform
!   9 : configuration of SPC        spectral space computations

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

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

REAL(KIND=JPRB) :: ZHOOK_HANDLE

#include "abor1.intfb.h"
#include "nnmi2ad.intfb.h"
#include "nnmi3ad.intfb.h"
#include "spnorm.intfb.h"
IF (LHOOK) CALL DR_HOOK('CMACAD',0,ZHOOK_HANDLE)
IF (LNLNMI) THEN

  IF (NCONF == 1.OR.NCONF == 131.OR.NCONF == 302 &
     & .OR.NCONF == 401.OR.NCONF == 501.OR.NCONF == 601 &
     & .OR.NCONF == 801) THEN  
    CALL NNMI3AD
  ELSEIF (NCONF == 201 &
     & .OR.NCONF == 421.OR.NCONF == 521)THEN  
    CALL NNMI2AD(2)
  ELSE
    WRITE (NULOUT,*) 'LNLNMI == .TRUE. INCOMPATIBLE WITH NCONF'
    CALL ABOR1('CMACAD: ABOR1 CALLED')
  ENDIF
ENDIF
!      -----------------------------------------------------------

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

IF (LNMI) THEN
  WRITE(UNIT=NULOUT,FMT='('' LINEAR NORMAL MODE INITIALISATION ADJOINT '')')
  IF (N1SDI == 1) CALL SPNORM(0)
  IF (NCONF == 201 &
     & .OR.NCONF == 421.OR.NCONF == 521)THEN  
    CALL NNMI2AD(1)
  ELSE
    WRITE (NULOUT,*) 'LNMI == .TRUE. IS INCOMPATIBLE WITH NCONF'
    CALL ABOR1('CMACAD: ABOR1 CALLED')
  ENDIF
  IF (N1SDI == 1) CALL SPNORM(0)
ENDIF

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

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