SUBROUTINE OBSPREP(CDCONF)

!**** *OBSPREP* - PREPARATION OF OBSERVATIONS

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

!        PREPARATION OF OBSERVATIONS

!**   Interface.
!     ----------
!        *CALL* *OBSPREP(CDCONF)

!        Explicit arguments :
!        --------------------
!        CDCONF : CONFIGURATION OF WORK

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

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

!     Externals.
!     ----------
!        OBATABS- OBS. PARAMETERS
!        READOBA- READ IN OBSERVATIONS

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

!     Author.
!     -------
!        Drasko Vasiljevic *ECMWF*

!     Modifications.
!     --------------
!        Original : 92-03-04
!        M.Hamrud : 95-09-20 New CMA format
!        M.Hamrud      01-Oct-2003 CY28 Cleaning
!     ------------------------------------------------------------------

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

USE YOMDIMO  , ONLY : NOBTOT
USE YOMECTAB , ONLY :    NTSLTOB  ,NTSLTOBOFF,NTSLTOV  ,&
 & NTSLTOVOFF,NTSLNTV  ,NTSLNTVOFF,NTSLSCA  ,NTSLSCAOFF,&
 & NTSLOTNO  
USE YOMLUN   , ONLY :    NULERR

IMPLICIT NONE

CHARACTER(LEN=1)  ,INTENT(IN)    :: CDCONF 
INTEGER(KIND=JPIM) :: ITSLOTNO, IOBNTV, IOBSCA, IOBTOT, IOBTOV
INTEGER(KIND=JPIM) :: IOFFNTV, IOFFSCA, IOFFTOT, IOFFTOV
REAL(KIND=JPRB) :: ZHOOK_HANDLE

#include "abor1.intfb.h"
#include "obatabs.intfb.h"
!     ------------------------------------------------------------------

!*       1.    VAR AND OI ANALYSIS
!              -------------------

IF (LHOOK) CALL DR_HOOK('OBSPREP',0,ZHOOK_HANDLE)
IF(CDCONF == 'C'.OR.CDCONF == 'V') THEN
  IF(CDCONF == 'C') THEN
    IF(NOBTOT /= 0) THEN
      CALL ABOR1('OBSPREP:CDCONF == C IS DEAD')
    ENDIF
  ELSEIF(CDCONF == 'V') THEN
    ITSLOTNO = NTSLOTNO
!   IADDR = NTSLPT (NTSLOTNO)
    IOBTOT  = NTSLTOB(NTSLOTNO)
    IOFFTOT = NTSLTOBOFF(NTSLOTNO)
    IOBTOV  = NTSLTOV(NTSLOTNO)
    IOFFTOV = NTSLTOVOFF(NTSLOTNO)
    IOBNTV  = NTSLNTV(NTSLOTNO)
    IOFFNTV = NTSLNTVOFF(NTSLOTNO)
    IOBSCA  = NTSLSCA(NTSLOTNO)
    IOFFSCA = NTSLSCAOFF(NTSLOTNO)
    IF(IOBTOT /= 0) THEN
      CALL OBATABS(ITSLOTNO,&
       & IOBTOT ,IOBTOV ,IOBNTV ,IOBSCA ,&
       & IOFFTOT,IOFFTOV,IOFFNTV,IOFFSCA)  
    ENDIF
  ENDIF
ELSE
  WRITE(NULERR,'('' ** ERROR IN OBSPREP; BAD CDCONF '',A)')CDCONF
  CALL ABOR1('OBSPREP:BAD CDCONF')
ENDIF

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

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

