SUBROUTINE IFSODBDDR2F(KCMDDR2 ,KNSCLETH,KNSCLOTH,KNSMICTH)

!**** SUBROUTINE IFSODBDDR2F - FULL MODIFICATION OF ODB SECOND DDR

!        D. VASILJEVIC     ECMWF    30/08/1994

!     PURPOSE
!     -------

!        FULL MODIFICATION OF ODB SECOND DDR CREATION

!**   INTERFACE
!     ---------

!        CALL IFSODBDDR2F(KCMDDR2 ,KNSCLETH,KNSCLOTH,KNSMICTH)
!     WHERE:
!           KCMDDR2 =
!           KNSCLETH=
!           KNSCLOTH=
!           KNSMICTH=

!        IFSODBDDR2F IS CALLED BY OBADAT

!     METHOD
!     ------

!        ODB SECOND DDR IS RMODIFIED

!     EXTERNALS
!     ---------

!     MODIFICATIONS
!     -------------
!        M.Hamrud      01-Oct-2003 CY28 Cleaning

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

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

USE YOMCMA   , ONLY : NMXDCL
USE YOMCMDDR , ONLY :   NLEND2I  ,NLEND2R  ,NLEND2C  ,NCD2NI   ,NCD2T1   ,NCD2T2   ,NCD2IL   ,&
 & NCD2LFS  ,NCD2LSS  ,NCD2TL   ,NCD2TY   ,&
 & NCD2TM   ,NCD2SD  
USE YOMANCS  , ONLY : NMDI     
USE YOMLUN   , ONLY : NULOUT

IMPLICIT NONE

INTEGER(KIND=JPIM),INTENT(INOUT) :: KCMDDR2(NMXDCL) 
INTEGER(KIND=JPIM),INTENT(IN)    :: KNSCLETH 
INTEGER(KIND=JPIM),INTENT(IN)    :: KNSCLOTH 
INTEGER(KIND=JPIM),INTENT(IN)    :: KNSMICTH 
!-----------------------------------------------------------------------

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

! CHARACTER (LEN = 4) :: CL_4H = '    '

INTEGER(KIND=JPIM) :: IBE, IBS, IST, JRES, JPR
REAL(KIND=JPRB) :: ZHOOK_HANDLE

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

!*

!        1.       SECOND ODB DDR FORMAT (INTEGER SECTION)
!                 ---------------------------------------

IF (LHOOK) CALL DR_HOOK('IFSODBDDR2F',0,ZHOOK_HANDLE)
WRITE (NULOUT,'('' ddr 2 in '')')
DO JPR = 1 , 1024
  WRITE (NULOUT,'('' '',i4,1x,i10)') JPR,KCMDDR2(JPR)
ENDDO

!*          1.1   LEN. OF SECOND DDR ! LOOK OK

!KCMDDR2(NCD2LN  )=  NLENCD2

!*          1.2   NO. OF NON-INTEGER SECTIONS ! NOT GOOD (=0)

KCMDDR2(NCD2NI  )=  2

!*          1.3   TYPE OF FIRST NON-INTEGER SECTION ! NOT GOOD (=0)

!KCMDDR2(NCD2T1  )=  NREALSC
KCMDDR2(NCD2T1  )=  2

!*          1.4   TYPE OF SECOND NON-INTEGER SECTION ! NOT GOOD (=0)

!KCMDDR2(NCD2T2  )=  NCHARSC
KCMDDR2(NCD2T2  )=  3

!*          1.5   LEN. OF INTEGER SECTION ! NOT GOOD (=0)

KCMDDR2(NCD2IL  )=  NLEND2I ! (=1024)

!*          1.6   LEN. OF FIRST NON-INTEGER SECTION ! NOT GOOD (=0)

KCMDDR2(NCD2LFS )=  NLEND2R ! (=1024)

!*          1.7   LEN. OF SECOND NON-INTEGER SECTION ! NOT GOOD (=0)

KCMDDR2(NCD2LSS )=  NLEND2C ! (=1024)

!*          1.8   LEN. OF NEXT DDR ! LOOKS OK

!KCMDDR2(NCD2LND )=  0

!*          1.9   NO. OF CLEAR SATEM THICKNESS LAYERS ! NOT GOOD (=0)

KCMDDR2(NCD2TL  )=  KNSCLETH ! (=15)

!*          1.10  NO. OF CLOUDY SATEM THICKNESS LAYERS ! NOT GOOD (=0)

KCMDDR2(NCD2TY  )=  KNSCLOTH ! (=15)

!*          1.11  NO. OF MICROWAVE SATEM THICKNESS LAYERS ! NOT GOOD (=0)

KCMDDR2(NCD2TM  )=  KNSMICTH ! (=15)

!*          1.12  SATELLITE ID's AND NO. OF REPORTS (NOT USED)

!DO JSIR = NCD2SAI1,NCD2SAT6
!  KCMDDR2(JSIR    )=  NMDI
!ENDDO

!*          1.24  24-25 RESERVED

!DO JRES = 24 , 25
!  KCMDDR2(JRES    )=  NMDI
!ENDDO

!*          1.26  NO. OF SIMULATIONS PERFORMED

!KCMDDR2(NCD2NS  )=  0

!*          1.27  NO. OF THE FOLLOWING WORDS USED TO STORE BIT MAP
!                 INDICATING ADDITIONAL DEPARTURS CREATED ! NOT GOOD (=0)

KCMDDR2(NCD2SD  )=  10

!*          1.28  28-NS BIT MAP

IBS = NCD2SD+1
IBE = IBS+KCMDDR2(NCD2SD  )-1
DO JRES = IBS , IBE
  KCMDDR2(JRES    )=  0
ENDDO

!*          1.NS  NS-1024 NOT DEFINED ! NOT GOOD (=0)

IST = KCMDDR2(NCD2SD  ) + NCD2SD + 1
DO JRES = IST,KCMDDR2(NCD2IL  )
  KCMDDR2(JRES    )=  NMDI
ENDDO
!*
!-----------------------------------------------------------------------

!        2.       SECOND ODB DDR FORMAT (REAL SECTION)
!                 ------------------------------------

!*          2.1   1-1024 NOT-DEFINED

!IST = KCMDDR2(NCD2IL  )+1
!IEND= KCMDDR2(NCD2IL  )+KCMDDR2(NCD2LFS )
!DO JRES = IST , IEND
!  PCMDDR2(JRES    )=  RMDI
!ENDDO
!*
!-----------------------------------------------------------------------

!        3.       SECOND ODB DDR FORMAT (CHARACTER SECTION)
!                 -----------------------------------------

!*          3.1   1-1024 NOT-DEFINED

!IST = KCMDDR2(NCD2IL  )+KCMDDR2(NCD2LFS )+1
!IEND= KCMDDR2(NCD2IL  )+KCMDDR2(NCD2LFS )+KCMDDR2(NCD2LSS )
!DO JRES = IST , IEND
!  read(CL_4H,'(a4)') KCMDDR2(JRES    )
!ENDDO
!*
!-----------------------------------------------------------------------

!        4.       RETURN
!                 ------

WRITE (NULOUT,'('' ddr 2 out '')')
DO JPR = 1 , 1024
  WRITE (NULOUT,'('' '',i4,1x,i10)') JPR,KCMDDR2(JPR)
ENDDO

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