SUBROUTINE COBS(KSTART,KPROF,KSTGLO,KPROFE,&
 & PGNORDL,PGNORDM,PESIG,PGM,POROG,PRCORI,&
 & PGMV,PGMVS,PGFL,PPARITY,PB1)  

!**** *COBS* - PREPARATION FOR HORIZONTAL INTERPOLATION AT OBS. POINTS

!     Interface.
!     ---------
!        *CALL* *COBS(...)

!        Explicit arguments.
!        ------------------
!        KSTART to PGFL: (!!! missing comments, to be added later !!!)
!        PB1       : fields buffer for horiz interpolation at obs points

!     Author.
!     ------
!        Mats Hamrud and Drasko Vasiljevic  *ECMWF*

!     Modifications.
!     -------------
!        Original   : 92-03-31
!     F.Bouttier   92-12-01 : Securities for small models
!     V.Casse      93-05    : cleaning and use of GT1 and GPP for CANARI
!     M.Hamrud     95-03-01 : (F90 re-write)
!     V.Casse      96-12    : interpolation in the model geometry
!     F.Taillefer  97-05    : use of DL and DM for wind interpolation
!     E.Andersson  97-11-17 : Introduce CIW and O3
!     E.Holm       98-01-05 : Include logical switch LSPO3 for ozone
!     F.Taillefer  97-10-09 : added PESIG (model errors for CANARI)
!     Modified 98-08-10 by K. YESSAD: removal of LRPOLE option.
!       - removal of LRPOLE in YOMCT0.
!       - removal of code under LRPOLE.
!       - use routine INIPEX.
!     P.Moll       99-08-03 : implementation of achmt in cy21t1
!     P.Viterbo    99-09-01 : Surface tiles
!     R. El Khatib : 01-08-07 Pruning options
!     C. Fischer   03-06-03 : add kprofe for LAM/Jo gridpoint scan
!     M.Hamrud     03-08-01 : GFL introduction
!        M.Hamrud      01-Oct-2003 CY28 Cleaning
!        M.Hamrud      10-Jan-2004 CY28R1 Cleaning
!        M.Hamrud      01-Jul-2006 Revised surface fields
!        H.Hersbach    04-Jul-2008 add ocean current plus wave Charnock
!     K. Yessad (Dec 2008): remove dummy CDLOCK + cleanings
!        H.Hersbach    04-Dec-2009 add 10-m neutral wind,
!                                  replace climate with forecast surf. roughness,
!                                  determine ZPARITY
!    -------------------------------------------------------------------

USE PARKIND1  ,ONLY : JPIM     ,JPRB
USE YOMHOOK   ,ONLY : LHOOK,   DR_HOOK
USE YOMDIM   , ONLY : NFLEVG   ,NFTHER   ,NPROMA   
USE YOMCT0   , ONLY : LCANARI  ,LOBSC1   ,LOBSREF  ,&
 & LCASIG  
USE YOMCT0B  , ONLY : LECMWF
USE YOMPHY   , ONLY : LSOLV    ,LFGEL
USE YOMSC2   , ONLY : NFLDOBB1
USE SURFACE_FIELDS_MIX, ONLY : &
 & SP_SB, YSP_SBD, YSP_SB, &
 & SP_SG, YSP_SGD, YSP_SG, &
 & SP_RR, YSP_RRD, YSP_RR, SP_CL, &
 & SP_X2, YSP_X2 , YSP_CL, &
 & SD_VX, YSD_VX , &
 & SD_VV, YSD_VVD, YSD_VV, &
 & SD_VF, YSD_VFD, YSD_VF, &
 & SD_VD, YSD_VDD, YSD_VD, &
 & SD_WS, YSD_WSD, YSD_WS
USE YOMCT3   , ONLY : NSTEP
USE TRAJECTORY_MOD, ONLY: GET_TRAJ_SFC
USE YOMMP    , ONLY : NSLCORE   ,NASLB1
USE YOMGMV   , ONLY : NDIMGMV   ,NDIMGMVS,YT0
USE YOM_YGFL , ONLY : YGFL
USE GOMS_MIX , ONLY : NGOMGFL,YGOMGFL
USE YOMDPHY  , ONLY : LDIRCLSMOD
USE YOMOBS   , ONLY : LZ0FC
IMPLICIT NONE

INTEGER(KIND=JPIM),INTENT(IN)    :: KSTART 
INTEGER(KIND=JPIM),INTENT(IN)    :: KPROF 
INTEGER(KIND=JPIM),INTENT(IN)    :: KSTGLO 
INTEGER(KIND=JPIM),INTENT(IN)    :: KPROFE 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PGNORDL(NPROMA) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PGNORDM(NPROMA) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PESIG(2*NFLEVG+5,NPROMA) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PGM(NPROMA) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: POROG(NPROMA) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PRCORI(NPROMA) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PGMV(NPROMA,NFLEVG,NDIMGMV) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PGMVS(NPROMA,NDIMGMVS) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PGFL(NPROMA,NFLEVG,YGFL%NDIM) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PPARITY(NFLDOBB1) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PB1(NASLB1,NFLDOBB1) 

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

REAL(KIND=JPRB) :: ZSP_SB5(NPROMA,YSP_SBD%NLEVS,YSP_SBD%NDIM5)
REAL(KIND=JPRB) :: ZSP_SG5(NPROMA,YSP_SGD%NDIM5)
REAL(KIND=JPRB) :: ZSP_RR5(NPROMA,YSP_RRD%NDIM5)
REAL(KIND=JPRB) :: ZSD_VF5(NPROMA,YSD_VFD%NDIM5)
REAL(KIND=JPRB) :: ZSD_VD5(NPROMA,YSD_VDD%NDIM5)
REAL(KIND=JPRB) :: ZSD_VV5(NPROMA,YSD_VVD%NDIM5)
REAL(KIND=JPRB) :: ZSD_WS5(NPROMA,YSD_WSD%NDIM5)

INTEGER(KIND=JPIM) :: ISLCORE(KPROF)
INTEGER(KIND=JPIM) :: IBLK, IEND, IENDC, ILEV, &
 & ILEVEH, ILEVEZ, ILEVT, &
 & ILEVU, ILEVV, IOBB1AL, IOBB1ARG,  &
 & IOBB1CO, IOBB1DL, IOBB1DM, &
 & IOBB1EH, IOBB1EM, IOBB1EST, IOBB1ESN, &
 & IOBB1ET2,IOBB1EH2,IOBB1EV1, IOBB1EZ, IOBB1HV, &
 & IOBB1LS, IOBB1OR, IOBB1PRS, IOBB1PRW, &
 & IOBB1SAB, IOBB1SN, IOBB1SP, IOBB1T, &
 & IOBB1TS, IOBB1U, IOBB1V, IOBB1VG, &
 & IOBB1CI, IOBB1CVH, IOBB1CVL, IOBB1TVH, IOBB1TVL, &
 & IOBB1WL, IOBB1TCLS, IOBB1HUCLS,IOBB1UCU,IOBB1VCU,IOBB1CHN,&
 & IOBB1U10N,IOBB1V10N,&
 & IOBB1WS, IOBB1XOR, IOBB1XSN, IOBB1XTP, IOBB1XTS, &
 & IOBB1XWP, IOBB1XWS, IOBB1Z0, IOBB1Z0H, IOBBUF1, &
 & IPCT, IST, ISTC, JFLD, JLEV, JROF,ISTF,IROF,JGFL,IOBB1GFL,ILEVGFL
REAL(KIND=JPRB) :: ZHOOK_HANDLE

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

IF (LHOOK) CALL DR_HOOK('COBS',0,ZHOOK_HANDLE)

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

!*       1.    SET-UP.
!              ------

IPCT  = 1
IST   = KSTART
IEND  = KPROF
ISTC  = KSTART
IENDC = KPROFE

!    -------------------------------------------------------------------
!*       2.    Interface to global arrays.
!              --------------------------

!*       2.2   LOCATE BUFFERS

IOBBUF1 = 1
IOBB1U  = IOBBUF1
IOBB1V  = IOBB1U   + NFLEVG
IOBB1T  = IOBB1V   + NFLEVG
IOBB1GFL  = IOBB1T + NFLEVG
IOBB1SP = IOBB1GFL + NFLEVG*NGOMGFL
IOBB1TS = IOBB1SP  + 1
IOBB1WS = IOBB1TS  + 1
IOBB1SN = IOBB1WS  + 1
IOBB1Z0 = IOBB1SN  + 1
IOBB1WL = IOBB1Z0  + 1
IOBB1U10N=IOBB1WL  + 1
IOBB1V10N=IOBB1U10N+ 1
IOBB1OR = IOBB1V10N+ 1
IOBB1CO = IOBB1OR  + 1
IOBB1DL = IOBB1CO  + 1
IOBB1DM = IOBB1DL  + 1
IOBB1AL = IOBB1DM  + 1
IOBB1EM = IOBB1AL  + 1
IOBB1LS = IOBB1EM  + 1
IF (LECMWF) THEN
  IOBB1CI  = IOBB1LS  + 1
  IOBB1UCU = IOBB1CI  + 1
  IOBB1VCU = IOBB1UCU + 1
  IOBB1CHN = IOBB1VCU + 1
  IOBB1CVH = IOBB1CHN + 1
  IOBB1CVL = IOBB1CVH + 1
  IOBB1TVH = IOBB1CVL + 1
  IOBB1TVL = IOBB1TVH + 1
  IOBB1VG = IOBB1TVL
ELSE
  IOBB1VG = IOBB1LS  + 1
  IOBB1TCLS = IOBB1VG + 1
  IOBB1HUCLS = IOBB1TCLS + 1
ENDIF
IF ( LCASIG ) THEN
! model errors
  IF (LDIRCLSMOD) THEN
    IOBB1EZ  = IOBB1HUCLS  + 1
  ELSE
    IOBB1EZ  = IOBB1VG + 1
  ENDIF
  IOBB1EH  = IOBB1EZ + NFLEVG
  IOBB1EST = IOBB1EH + NFLEVG
  IOBB1ESN = IOBB1EST + 1
  IOBB1ET2 = IOBB1ESN + 1
  IOBB1EH2 = IOBB1ET2 + 1
  IOBB1EV1 = IOBB1EH2 + 1
ELSE
  IF (LDIRCLSMOD) THEN
    IOBB1EV1 = IOBB1HUCLS 
  ELSE
    IOBB1EV1 = IOBB1VG
  ENDIF
ENDIF
IF ( LCANARI ) THEN
  IOBB1PRW = IOBB1EV1 + 1
  IOBB1PRS = IOBB1PRW + 1
! surface climatology (NVCLIX)
  IOBB1XOR = IOBB1PRS + 1
  IOBB1XTS = IOBB1XOR + 1
  IOBB1XWS = IOBB1XTS + 0
  IOBB1XWP = IOBB1XWS + 0
  IOBB1XSN = IOBB1XWP + 1
  IOBB1XTP = IOBB1XSN + 0
ELSE
  IOBB1XTP = IOBB1EV1
ENDIF
IF ( LSOLV ) THEN
  IOBB1ARG= IOBB1XTP + 1
  IOBB1SAB= IOBB1ARG + 1
  IOBB1HV = IOBB1SAB + 1
  IOBB1Z0H= IOBB1HV  + 1
ENDIF

!*       2.3   READ SURFACE FIELDS

IBLK=(KSTGLO-1)/NPROMA+1
IF ( LOBSC1.OR. LOBSREF .OR. LCANARI ) THEN
!        Reference model run
ELSE
!        Perturbed model run : read from trajectory fields
  CALL GET_TRAJ_SFC(NSTEP,IBLK,IST,IEND,&
   & PSP_SB=ZSP_SB5,PSP_SG=ZSP_SG5,PSP_RR=ZSP_RR5,&
   & PSD_VF=ZSD_VF5,PSD_VD=ZSD_VD5,PSD_VV=ZSD_VV5,PSD_WS=ZSD_WS5)
ENDIF

!    -------------------------------------------------------------------
!*       3.    FILL OBBUFFERS.
!              --------------

!*       3.0   PRESET PB1 (that it is strange !)

!                 Preset PB1 in case not all fields are filled to
!                 avoid floating point errors in subsequent code
DO JROF = IST , IEND
  IROF = NSLCORE(KSTGLO+JROF-1)
  ISLCORE(JROF)=IROF
ENDDO

ISTF=1+(3+NGOMGFL)*NFLEVG+1
DO JFLD = ISTF , NFLDOBB1
  DO JROF = IST , IEND
    IROF = ISLCORE(JROF)
    PB1(IROF,JFLD) = 999999999.0_JPRB
  ENDDO
ENDDO

!*       3.1   COPY

!*       3.1.1 WIND : MAP FACTOR (V.Casse)
!              T and Q : if exist
!              WC and CC : if exist

DO JLEV = 1 , NFLEVG
  ILEVU   = IOBB1U   + JLEV-1
  ILEVV   = IOBB1V   + JLEV-1
  ILEVT   = IOBB1T   + JLEV-1
!OCL NOVREC
  DO JROF = IST , IEND
    IROF = ISLCORE(JROF)
    PB1(IROF,ILEVU) = PGMV (JROF,JLEV,YT0%MU) * PGM(JROF)
    PB1(IROF,ILEVV) = PGMV (JROF,JLEV,YT0%MV) * PGM(JROF)
    IF(NFTHER /= 0) THEN
      PB1(IROF,ILEVT) = PGMV(JROF,JLEV,YT0%MT)
    ELSE
      PB1(IROF,ILEVT) = 0.0_JPRB
    ENDIF
  ENDDO
ENDDO
DO JGFL=1,NGOMGFL
  DO JLEV = 1 , NFLEVG
    ILEVGFL = IOBB1GFL+(JGFL-1)*NFLEVG+JLEV-1
    DO JROF = IST , IEND
      IROF = ISLCORE(JROF)
      PB1(IROF,ILEVGFL) = PGFL(JROF,JLEV,YGOMGFL(JGFL)%MPMDL)
    ENDDO
  ENDDO
ENDDO

!*       3.1.2 SURFACE PRESSURE

DO JROF = IST , IEND
  IROF = ISLCORE(JROF)
  PB1(IROF,IOBB1SP) = PGMVS(JROF,YT0%MSP)
ENDDO

!*       3.1.3 PHYSICAL AND CONSTANT FIELDS

!     Security : no surface in vorticity model

DO JROF = IST , IEND
  IROF = ISLCORE(JROF)
  PB1(IROF,IOBB1OR) = POROG  (JROF)
  PB1(IROF,IOBB1CO) = PRCORI (JROF)
  PB1(IROF,IOBB1DL) = PGNORDL(JROF)
  PB1(IROF,IOBB1DM) = PGNORDM(JROF)
ENDDO

!OCL NOVREC
DO JROF = IST , IEND
  IROF = ISLCORE(JROF)
  IF ( LCANARI .OR. LOBSC1.OR. LOBSREF ) THEN
    IF ( LECMWF ) THEN
      PB1(IROF,IOBB1WS)  = SP_SB(JROF,1,YSP_SB%YQ%MP0,IBLK)
      PB1(IROF,IOBB1CI)  = SD_VF(JROF,YSD_VF%YCI%MP  ,IBLK)
      PB1(IROF,IOBB1CVH) = SD_VF(JROF,YSD_VF%YCVH%MP ,IBLK)
      PB1(IROF,IOBB1CVL) = SD_VF(JROF,YSD_VF%YCVL%MP ,IBLK)
      PB1(IROF,IOBB1TVH) = SD_VF(JROF,YSD_VF%YTVH%MP ,IBLK)
      PB1(IROF,IOBB1TVL) = SD_VF(JROF,YSD_VF%YTVL%MP ,IBLK)
      PB1(IROF,IOBB1UCU) = SD_VF(JROF,YSD_VF%YUCUR%MP,IBLK)
      PB1(IROF,IOBB1VCU) = SD_VF(JROF,YSD_VF%YVCUR%MP,IBLK)
      PB1(IROF,IOBB1U10N)= SD_VD(JROF,YSD_VD%Y10NU%MP,IBLK)
      PB1(IROF,IOBB1V10N)= SD_VD(JROF,YSD_VD%Y10NV%MP,IBLK)
      PB1(IROF,IOBB1CHN) = SD_WS(JROF,YSD_WS%YCHAR%MP,IBLK)
      IF(LZ0FC) THEN
         PB1(IROF,IOBB1Z0)  = SD_VD(JROF,YSD_VD%YZ0F%MP ,IBLK)
      ELSE
         PB1(IROF,IOBB1Z0) =  SD_VF(JROF,YSD_VF%YZ0F%MP ,IBLK)
      ENDIF
    ELSE
      PB1(IROF,IOBB1WS) = SP_RR(JROF,YSP_RR%YW%MP0 ,IBLK)
      PB1(IROF,IOBB1VG) = SD_VF(JROF,YSD_VF%YVEG%MP,IBLK)
      PB1(IROF,IOBB1Z0) = SD_VF(JROF,YSD_VF%YZ0F%MP ,IBLK)
      IF (LDIRCLSMOD) THEN
        PB1(IROF,IOBB1TCLS) = SP_CL(JROF,YSP_CL%YTCLS%MP,IBLK)
        PB1(IROF,IOBB1HUCLS) = SP_CL(JROF,YSP_CL%YHUCLS%MP,IBLK)
      ENDIF
    ENDIF
    PB1(IROF,IOBB1TS) = SP_RR(JROF,YSP_RR%YT%MP0 ,IBLK)
    PB1(IROF,IOBB1SN) = SP_SG(JROF,YSP_SG%YF%MP0 ,IBLK)
!          Note: WL,ALBF,EMISF,FLSM and FVEG are constants
    PB1(IROF,IOBB1WL) = 1.0_JPRB
    PB1(IROF,IOBB1AL) = SD_VF(JROF,YSD_VF%YALBF%MP ,IBLK)
    PB1(IROF,IOBB1EM) = SD_VF(JROF,YSD_VF%YEMISF%MP,IBLK)
    PB1(IROF,IOBB1LS) = SD_VF(JROF,YSD_VF%YLSM%MP  ,IBLK)
!          Note: there is no TL code for Canari obs, nor for LSOLV fields
    IF ( LCANARI ) THEN
!              precipitations fields
      PB1(IROF,IOBB1PRW) =SP_X2(JROF,YSP_X2%YX2(1)%MP0,IBLK)+&
       & SP_X2(JROF,YSP_X2%YX2(2)%MP0,IBLK)
      PB1(IROF,IOBB1PRS) =SP_X2(JROF,YSP_X2%YX2(3)%MP0,IBLK)+&
       & SP_X2(JROF,YSP_X2%YX2(4)%MP0,IBLK)
!              surface climatology (NVCLIX)
      PB1(IROF,IOBB1XOR) = SD_VX(JROF,YSD_VX%YORO%MP,IBLK)
      PB1(IROF,IOBB1XTS) = SD_VX(JROF,YSD_VX%YTSC%MP,IBLK)
!              PB1(IROF,IOBB1XWS) = SD_VX(JROF,YSD_VX%YPWS%MP,IBLK)
!              PB1(IROF,IOBB1XWP) = SD_VX(JROF,YSD_VX%YPWP%MP,IBLK)
      PB1(IROF,IOBB1XSN) = SD_VX(JROF,YSD_VX%YSNO%MP,IBLK)
!              PB1(IROF,IOBB1XTP) = SD_VX(JROF,YSD_VX%YTPC%MP,IBLK)
    ENDIF
    IF ( LSOLV ) THEN
      PB1(IROF,IOBB1ARG) = SD_VV(JROF,YSD_VV%YARG%MP,IBLK)
      PB1(IROF,IOBB1SAB) = SD_VV(JROF,YSD_VV%YSAB%MP,IBLK)
      PB1(IROF,IOBB1HV ) = SD_VV(JROF,YSD_VV%YHV %MP,IBLK)
      IF (YSD_VVD%NUMFLDS >= 8) THEN
        PB1(IROF,IOBB1Z0H) = SD_VV(JROF,YSD_VV%YZ0H%MP,IBLK)
      ENDIF
      IF (LFGEL) THEN
        PB1(IROF,IOBB1SAB) = SP_RR(JROF,YSP_RR%YRR(4)%MP0,IBLK)
      ENDIF
    ENDIF
  ELSE
    IF ( LECMWF ) THEN
      PB1(IROF,IOBB1WS)  = ZSP_SB5(JROF,1,YSP_SB%YQ%MP5)
      PB1(IROF,IOBB1CI)  = ZSD_VF5(JROF,YSD_VF%YCI%MP5)
      PB1(IROF,IOBB1CVH) = ZSD_VF5(JROF,YSD_VF%YCVH%MP5)
      PB1(IROF,IOBB1CVL) = ZSD_VF5(JROF,YSD_VF%YCVL%MP5)
      PB1(IROF,IOBB1TVH) = ZSD_VF5(JROF,YSD_VF%YTVH%MP5)
      PB1(IROF,IOBB1TVL) = ZSD_VF5(JROF,YSD_VF%YTVL%MP5)
      PB1(IROF,IOBB1UCU) = ZSD_VF5(JROF,YSD_VF%YUCUR%MP5)
      PB1(IROF,IOBB1VCU) = ZSD_VF5(JROF,YSD_VF%YVCUR%MP5)
      PB1(IROF,IOBB1U10N)= ZSD_VD5(JROF,YSD_VD%Y10NU%MP5)
      PB1(IROF,IOBB1V10N)= ZSD_VD5(JROF,YSD_VD%Y10NV%MP5)
      PB1(IROF,IOBB1CHN) = ZSD_WS5(JROF,YSD_WS%YCHAR%MP5)
      IF(LZ0FC) THEN
         PB1(IROF,IOBB1Z0)  = ZSD_VD5(JROF,YSD_VD%YZ0F%MP5)
      ELSE
         PB1(IROF,IOBB1Z0)  = ZSD_VF5(JROF,YSD_VF%YZ0F%MP5)
      ENDIF
    ELSE
      PB1(IROF,IOBB1WS) = ZSP_RR5(JROF,YSP_RR%YW%MP5)
      PB1(IROF,IOBB1VG) = ZSD_VF5(JROF,YSD_VF%YVEG%MP5 )
      PB1(IROF,IOBB1Z0) = ZSD_VF5(JROF,YSD_VF%YZ0F%MP5)
    ENDIF
    PB1(IROF,IOBB1TS) = ZSP_RR5(JROF,YSP_RR%YT%MP5)
    PB1(IROF,IOBB1SN) = ZSP_SG5(JROF,YSP_SG%YF%MP5)
!            Note: WL,ALBF,EMISF,FLSM and FVEG are constants
    PB1(IROF,IOBB1WL) = 1.0_JPRB
    PB1(IROF,IOBB1AL) = ZSD_VF5(JROF,YSD_VF%YALBF%MP5 )
    PB1(IROF,IOBB1EM) = ZSD_VF5(JROF,YSD_VF%YEMISF%MP5)
    PB1(IROF,IOBB1LS) = ZSD_VF5(JROF,YSD_VF%YLSM%MP5  )
    IF ( LSOLV ) THEN
      PB1(IROF,IOBB1ARG) = ZSD_VV5(JROF,YSD_VV%YARG%MP5)
      PB1(IROF,IOBB1SAB) = ZSD_VV5(JROF,YSD_VV%YSAB%MP5)
      PB1(IROF,IOBB1HV ) = ZSD_VV5(JROF,YSD_VV%YHV%MP5)
      IF (YSD_VVD%NUMFLDS >= 8) THEN
        PB1(IROF,IOBB1Z0H) = ZSD_VV5(JROF,YSD_VV%YZ0H%MP5)
      ENDIF
      IF (LFGEL) THEN
        PB1(IROF,IOBB1SAB) = ZSP_RR5(JROF,YSP_RR%YRR(4)%MP5)
      ENDIF
    ENDIF
  ENDIF

ENDDO

!*       3.1.4 MODEL ERRORS FIELDS

IF ( LCASIG ) THEN
  DO JLEV = 1 , NFLEVG
    ILEVEZ = IOBB1EZ + JLEV-1
    ILEVEH = IOBB1EH + JLEV-1
    ILEV=NFLEVG+JLEV
!OCL NOVREC
    DO JROF = IST , IEND
      IROF = ISLCORE(JROF)
      PB1(IROF,ILEVEZ) = PESIG(JLEV,JROF)
      PB1(IROF,ILEVEH) = PESIG(ILEV,JROF)
    ENDDO
  ENDDO
  ILEV=2*NFLEVG+1
!OCL NOVREC
  DO JROF = IST , IEND
    IROF = ISLCORE(JROF)
    PB1(IROF,IOBB1EST) = PESIG(ILEV,JROF)
    PB1(IROF,IOBB1ESN) = PESIG(ILEV+1,JROF)
    PB1(IROF,IOBB1ET2) = PESIG(ILEV+2,JROF)
    PB1(IROF,IOBB1EH2) = PESIG(ILEV+3,JROF)
    PB1(IROF,IOBB1EV1) = PESIG(ILEV+4,JROF)
  ENDDO
ENDIF

!*     4. FILL PARITY ATTRIBUTE (1 FOR SCALAR, -1 FOR VECTOR FIELD)

IF (KSTGLO==1) THEN
   PPARITY(1:NFLDOBB1)=1
   PPARITY(IOBB1U:IOBB1U+NFLEVG-1)=-1
   PPARITY(IOBB1V:IOBB1V+NFLEVG-1)=-1
   PPARITY(IOBB1U10N)=-1
   PPARITY(IOBB1V10N)=-1
   IF(LECMWF) THEN
      PPARITY(IOBB1UCU)=-1
      PPARITY(IOBB1VCU)=-1
   ENDIF
ENDIF

!    -------------------------------------------------------------------
IF (LHOOK) CALL DR_HOOK('COBS',1,ZHOOK_HANDLE)
END SUBROUTINE COBS
