SUBROUTINE CACOVA( KTASK , LDFLAI, KNLX  , PLAT  , PLON  , PRESS ,&
 & PSIG  , KNBPV , KIV   , KASELS, KOSELS, PDSELS,&
 & KNSELS, KNIN  , PCOVAR, PCOREL )  
!****------------------------------------------------------------------------
!****   CACOVA : Calcul des valeurs absolues des correlations et "covariances".
!****   ------   (called by CASELA)
!****------------------------------------------------------------------------
!  But : Calcul des valeurs absolues des correlations et des
!  ---   "covariances" entre les erreurs du guess en un point donne
!        pour les variables que l'on souhaite analyser et les erreurs
!        du guess correspondant a une serie de predicteurs selectionnes
!        (les covariances sont normees par les ecarts-types d'erreur
!        du guess correspondant aux predicteurs).

!  Arguments d'entree :
!  ------------------
!    KTASK  : numero de la tache executant CACOVA
!    LDFLAI : tableau indiquant les variables de la table NVX a analyser
!    KNLX   : nombre de mots de LDFLAI egaux a .TRUE.
!    PLAT   : latitude du point d'analyse en radians
!    PLON   : longitude du point d'analyse en radians
!    PRESS  : tableau des pressions de chaque niveau en Pascals
!    PSIG   : tableau des ecart-types d'erreur du guess pour chaque predictant
!    KNBPV  : nombre de niveaux pression
!          Selon la table NVY :
!    KASELS : tableau des adresses des predicteurs
!    KOSELS : tableau des adresses des observations contenant les predicteurs
!    PDSELS : tableau distances entre les predicteurs et le point d'analyse
!    KNSELS : tableau du nombre effectif de predicteurs
!    KNIN   : nombre total des predicteurs (somme des KNSELS)

!  Arguments de sortie :
!  -------------------
!    PCOVAR : tableau des "covariances" normees
!    PCOREL : tableau des valeurs absolues des correlations
!    PSIG   : ecart-type d'erreur du  guess pour chaque predictant,
!             y compris  pour les  epaisseurs  pour lesquelles  les
!             valeurs donnees en entree sont alors ecrasees.

!  Sous-programmes aval : CASINU - CASI1T - CACO1T - CASI2T
!  --------------------   CACO2T

!  COMMON utilises : YOMDB  - YOMOBA - YOMCT0 - YOMCST
!  ---------------   QAPABL - QAPAVU - QACOST - QALORI

!  Algorithme :
!  ----------
!    Les correlations sont calculees dans l'ordre Z, T, U, V, Hu
!    des predictants, et, pour  chaque  predictant, dans l'ordre
!    Z,T,U,V,DZ,HU  pour les predicteurs.
!    Ceci determine le rangement des correlations dans PCOREL et des
!    covariances dans PCOVAR.

!    PCOVAR pourra etre utilise pour le second membre du systeme
!    lineaire, soit tel quel, soit allege si l'on souhaite effectuer
!    une selection statistique (a l'aide de PCOREL).

!  Modifications : LG 03/00  p.2.7 for snow added
!  -------------   FT 11/00  CMAFOC --> ODB
!                  LG 11/00  vertical part of the corr. for snow added
!        M.Hamrud      01-Oct-2003 CY28 Cleaning
!      E. Sevault 18-May-2009 : optimisation of a short loop with a specific
!                          compiler directive on NEC
!----------------------------------------------------------------------------

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

USE YOMCT0   , ONLY : NTASKS
USE QAPABL   , ONLY : JPKZMA
USE QAPAVU   , ONLY : JPNVX    ,JPNVY    ,JPPXZ    ,JPPXT    ,JPPYZ    ,&
 & JPPXU    ,JPPXV    ,JPPXHU   ,JPPXST   ,JPPXSN   ,&
 & JPPYT    ,JPPYU    ,JPPYV    ,JPPYDZ   ,JPPYHU   ,&
 & JPPYST   ,JPPXU1   ,JPPXV1   ,JPPXT2   ,JPPXH2   ,&
 & JPPYU1   ,JPPYV1   ,JPPYT2   ,JPPYH2   ,JPPYSN  
USE YOMCST   , ONLY : RA
USE YOMDB
USE QACOST   , ONLY : QPOHZ    ,QPOHUD   ,QPOSST   ,QRMU     ,&
 & QRNU     ,QPOHHU   ,QPOVZ    ,QPOVH    ,&
 & QPOHT2   ,QPOHH2   ,QPOVORBL ,QPODIVBL ,&
 & QNUBL    ,QKPBL    ,QPOHSN   ,QPOHPSN  
USE QALORI   , ONLY : LCORRF

IMPLICIT NONE

INTEGER(KIND=JPIM),INTENT(IN)    :: KNLX 
INTEGER(KIND=JPIM),INTENT(IN)    :: KNBPV 
INTEGER(KIND=JPIM),INTENT(IN)    :: KNIN 
INTEGER(KIND=JPIM),INTENT(IN)    :: KTASK 
LOGICAL           ,INTENT(IN)    :: LDFLAI(0:JPNVX) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PLAT 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PLON 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PRESS(KNBPV) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PSIG(JPNVX,KNBPV) 
INTEGER(KIND=JPIM),INTENT(IN)    :: KIV 
INTEGER(KIND=JPIM),INTENT(IN)    :: KASELS(JPNVY,JPKZMA) 
INTEGER(KIND=JPIM),INTENT(IN)    :: KOSELS(JPNVY,JPKZMA) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PDSELS(JPNVY,JPKZMA) 
INTEGER(KIND=JPIM),INTENT(IN)    :: KNSELS(JPNVY) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PCOVAR(KNIN,KNLX,KNBPV) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PCOREL(KNIN,KNLX,KNBPV) 
REAL(KIND=JPRB) ::    ZSINPX(JPNVY,JPKZMA), ZCOSPX(JPNVY,JPKZMA)
REAL(KIND=JPRB) ::    ZSINPY(JPNVY,JPKZMA), ZCOSPY(JPNVY,JPKZMA)

INTEGER(KIND=JPIM) :: IAD, IPRE, IX, IY, JIP, JIPRE, JJPRE, JSEL, JV, JX, JY

REAL(KIND=JPRB) :: ZH2DIV, ZH2HU, ZH2SST, ZH2Z, ZKH, ZKZ, ZLAT, ZLON, &
 & ZLIMB, ZLIMH, ZMU, ZNU2, ZPRESS, ZSINUS, ZZPPRRSS, ZKPBL, &
 & ZH2T2, ZH2H2, ZH2VORBL, ZH2DIVBL, ZNU2BL, ZH2SN, ZDISTP2, ZV2P2SN  
REAL(KIND=JPRB) :: ZHOOK_HANDLE

#include "abor1.intfb.h"

#include "qavari.h"
#include "qastat.h"
#include "qadits.h"
#include "openmp_obs.h"

!----------------------------------------------------------------------------
!  - 1 -  Initialisations
!         ---------------

! Initialisation a zero de toutes les correlations et covariances;
! on ne les calculera pas quand elles devront etre nulles.

IF (LHOOK) CALL DR_HOOK('CACOVA',0,ZHOOK_HANDLE)
DO JX = 1 , KNLX
  DO JY = 1 , KNIN
    PCOVAR(JY,JX,1) = 0.0_JPRB
    PCOREL(JY,JX,1) = 0.0_JPRB
  ENDDO
ENDDO

! Initialisation des constantes pour les fonctions d'autocorrelation.
! Ces valeurs sont utilisees par les fonctions "in line" du comdeck QASTAT
!   (a partir du comdeck QACOST).

IF ( KTASK  <  1.OR.  KTASK  >  NTASKS ) CALL ABOR1('CACOVA: BAD TASK NUMBER')
ZH2Z   = QPOHZ(KIV,KTASK) ** 2
ZH2DIV = QPOHUD(KIV,KTASK) ** 2
ZH2HU  = QPOHHU(KIV,KTASK) ** 2
ZNU2   = QRNU(KIV,KTASK) ** 2
ZMU    = QRMU(KIV,KTASK)

ZH2SST = QPOSST(KTASK) ** 2
ZH2T2  = QPOHT2(KTASK) ** 2
ZH2H2  = QPOHH2(KTASK) ** 2
ZH2SN  = QPOHSN(KTASK) ** 2
ZH2VORBL = QPOVORBL(KTASK) ** 2
ZH2DIVBL = QPODIVBL(KTASK) ** 2
ZNU2BL   = QNUBL(KTASK) **2
ZKPBL    = QKPBL(KTASK)
ZV2P2SN  = QPOHPSN(KTASK) ** 2

! Initialisation  des sinus et cosinus  de "projection", pour le cas ou on
! doit calculer des covariances faisant intervenir le vent.

IF ( LDFLAI(JPPYU) .OR. LDFLAI(JPPYV) .OR.&
   & ( KNSELS(JPPYU) > 0 ) .OR. ( KNSELS(JPPYV) > 0 ) .OR.&
   & LDFLAI(JPPYU1) .OR. LDFLAI(JPPYV1) .OR.&
   & ( KNSELS(JPPYU1) > 0 ) .OR. ( KNSELS(JPPYV1) > 0 ) ) THEN  
  DO JJPRE = 1 , JPNVY
    DO JSEL = 1 , KNSELS(JJPRE)
      IAD    = KOSELS(JJPRE,JSEL)
      ZLAT   = ROBHDR(IAD,MDBLAT)
      ZLON   = ROBHDR(IAD,MDBLON)
      ZSINUS = CASINU(PLAT,PLON,ZLAT,ZLON)
      IF (ZSINUS < 1.E-10_JPRB) THEN
        ZSINPX(JJPRE,JSEL) = 0.0_JPRB
        ZCOSPX(JJPRE,JSEL) = 1.0_JPRB
        ZSINPY(JJPRE,JSEL) = 0.0_JPRB
        ZCOSPY(JJPRE,JSEL) = 1.0_JPRB
      ELSE
        ZSINPX(JJPRE,JSEL) = CASI1N(PLAT,ZLAT,COS(ZLON-PLON))/ZSINUS
        ZCOSPX(JJPRE,JSEL) = CACON(ZLAT,SIN(ZLON-PLON))/ZSINUS
        ZSINPY(JJPRE,JSEL) = CASI2N(PLAT,ZLAT,COS(ZLON-PLON))/ZSINUS
        ZCOSPY(JJPRE,JSEL) = CACON(PLAT,SIN(ZLON-PLON))/ZSINUS
      ENDIF
    ENDDO
  ENDDO
ENDIF

! IX et IY serviront a reperer les elements de PCOVAR et PCOREL au cours
! des calculs
IX = 0

!----------------------------------------------------------------------------
!  - 2 -  Calcul des correlations : partie horizontale
!         --------------------------------------------

!  - 2.1 -  predictant Z et predicteurs

IF ( LDFLAI(JPPXZ) ) THEN
  IX = IX + 1
  IY = 0
  IPRE = JPPYZ
  DO JSEL = 1 , KNSELS(IPRE)
    IY  = IY + 1
    PCOREL(IY,IX,1) = FRHZZ(PDSELS(IPRE,JSEL),ZH2Z)
  ENDDO
  IPRE = JPPYT
  DO JSEL = 1 , KNSELS(IPRE)
    IY  = IY + 1
    PCOREL(IY,IX,1) = FRHZT(PDSELS(IPRE,JSEL),ZH2Z)
  ENDDO
  IPRE = JPPYU
  DO JSEL = 1 , KNSELS(IPRE)
    IY  = IY + 1
    PCOREL(IY,IX,1) = FRHZU(PDSELS(IPRE,JSEL),ZH2Z,ZNU2,ZMU,&
     & ZSINPY(IPRE,JSEL))  
  ENDDO
  IPRE = JPPYV
  DO JSEL = 1 , KNSELS(IPRE)
    IY  = IY + 1
    PCOREL(IY,IX,1) = FRHZV(PDSELS(IPRE,JSEL),ZH2Z,ZNU2,ZMU,&
     & ZCOSPY(IPRE,JSEL))  
  ENDDO
  IPRE = JPPYDZ
  DO JSEL = 1 , KNSELS(IPRE)
    IY  = IY + 1
    PCOREL(IY,IX,1) = FRHZZ(PDSELS(IPRE,JSEL),ZH2Z)
  ENDDO
ENDIF

!  - 2.2 -  predictant T et predicteurs

IF ( LDFLAI(JPPXT) ) THEN
  IX = IX + 1
  IY = 0
  IPRE = JPPYZ
  DO JSEL = 1 , KNSELS(IPRE)
    IY  = IY + 1
    PCOREL(IY,IX,1) = FRHTZ(PDSELS(IPRE,JSEL),ZH2Z)
  ENDDO
  IPRE = JPPYT
  DO JSEL = 1 , KNSELS(IPRE)
    IY  = IY + 1
    PCOREL(IY,IX,1) = FRHTT(PDSELS(IPRE,JSEL),ZH2Z)
  ENDDO
  IPRE = JPPYU
  DO JSEL = 1 , KNSELS(IPRE)
    IY  = IY + 1
    PCOREL(IY,IX,1) = FRHTU(PDSELS(IPRE,JSEL),ZH2Z,ZNU2,ZMU,&
     & ZSINPY(IPRE,JSEL))  
  ENDDO
  IPRE = JPPYV
  DO JSEL = 1 , KNSELS(IPRE)
    IY  = IY + 1
    PCOREL(IY,IX,1) = FRHTV(PDSELS(IPRE,JSEL),ZH2Z,ZNU2,ZMU,&
     & ZCOSPY(IPRE,JSEL))  
  ENDDO
  IPRE = JPPYDZ
  DO JSEL = 1 , KNSELS(IPRE)
    IY  = IY + 1
    PCOREL(IY,IX,1) = FRHTZ(PDSELS(IPRE,JSEL),ZH2Z)
  ENDDO
  IY = IY + KNSELS(JPPYHU)+KNSELS(JPPYST)+KNSELS(JPPYSN)
  IPRE = JPPYT2
  DO JSEL = 1 , KNSELS(IPRE)
    IY  = IY + 1
    PCOREL(IY,IX,1) = FRHT2T2(PDSELS(IPRE,JSEL),ZH2T2)
  ENDDO
ENDIF

!  - 2.3 -  predictant U et predicteurs

IF ( LDFLAI(JPPXU) ) THEN
  IX = IX + 1
  IY = 0
  IPRE = JPPYZ
  DO JSEL = 1 , KNSELS(IPRE)
    IY  = IY + 1
    PCOREL(IY,IX,1) = FRHUZ(PDSELS(IPRE,JSEL),ZH2Z,ZNU2,ZMU,&
     & ZSINPX(IPRE,JSEL))  
  ENDDO
  IPRE = JPPYT
  DO JSEL = 1 , KNSELS(IPRE)
    IY  = IY + 1
    PCOREL(IY,IX,1) = FRHUT(PDSELS(IPRE,JSEL),ZH2Z,ZNU2,ZMU,&
     & ZSINPX(IPRE,JSEL))  
  ENDDO
  IPRE = JPPYU
  DO JSEL = 1 , KNSELS(IPRE)
    IY  = IY + 1
    PCOREL(IY,IX,1) = FRHUU(PDSELS(IPRE,JSEL),ZH2Z,ZH2DIV,ZNU2,&
     & ZCOSPX(IPRE,JSEL),ZCOSPY(IPRE,JSEL),&
     & ZSINPX(IPRE,JSEL),ZSINPY(IPRE,JSEL))  
  ENDDO
  IPRE = JPPYV
  DO JSEL = 1 , KNSELS(IPRE)
    IY  = IY + 1
    PCOREL(IY,IX,1) = FRHUV(PDSELS(IPRE,JSEL),ZH2Z,ZH2DIV,ZNU2,&
     & ZCOSPX(IPRE,JSEL),ZCOSPY(IPRE,JSEL),&
     & ZSINPX(IPRE,JSEL),ZSINPY(IPRE,JSEL))  
  ENDDO
  IPRE = JPPYDZ
  DO JSEL = 1 , KNSELS(IPRE)
    IY  = IY + 1
    PCOREL(IY,IX,1) = FRHUZ(PDSELS(IPRE,JSEL),ZH2Z,ZNU2,ZMU,&
     & ZSINPX(IPRE,JSEL))  
  ENDDO
  IY = IY + KNSELS(JPPYHU)+KNSELS(JPPYST)+KNSELS(JPPYSN)&
   & +KNSELS(JPPYT2)+KNSELS(JPPYH2)  
  IPRE = JPPYU1
  DO JSEL = 1 , KNSELS(IPRE)
    IY  = IY + 1
    PCOREL(IY,IX,1) = FRHU1U1(PDSELS(IPRE,JSEL),ZH2VORBL,ZH2DIVBL,&
     & ZNU2BL,ZCOSPX(IPRE,JSEL),ZCOSPY(IPRE,JSEL),&
     & ZSINPX(IPRE,JSEL),ZSINPY(IPRE,JSEL))  
  ENDDO
  IPRE = JPPYV1
  DO JSEL = 1 , KNSELS(IPRE)
    IY  = IY + 1
    PCOREL(IY,IX,1) = FRHU1V1(PDSELS(IPRE,JSEL),ZH2VORBL,ZH2DIVBL,&
     & ZNU2BL,ZCOSPX(IPRE,JSEL),ZCOSPY(IPRE,JSEL),&
     & ZSINPX(IPRE,JSEL),ZSINPY(IPRE,JSEL))  
  ENDDO
ENDIF

!  - 2.4 -  predictant V et predicteurs

IF ( LDFLAI(JPPXV) ) THEN
  IX = IX + 1
  IY = 0
  IPRE = JPPYZ
  DO JSEL = 1 , KNSELS(IPRE)
    IY  = IY + 1
    PCOREL(IY,IX,1) = FRHVZ(PDSELS(IPRE,JSEL),ZH2Z,ZNU2,ZMU,&
     & ZCOSPX(IPRE,JSEL))  
  ENDDO
  IPRE = JPPYT
  DO JSEL = 1 , KNSELS(IPRE)
    IY  = IY + 1
    PCOREL(IY,IX,1) = FRHVT(PDSELS(IPRE,JSEL),ZH2Z,ZNU2,ZMU,&
     & ZCOSPX(IPRE,JSEL))  
  ENDDO
  IPRE = JPPYU
  DO JSEL = 1 , KNSELS(IPRE)
    IY  = IY + 1
    PCOREL(IY,IX,1) = FRHVU(PDSELS(IPRE,JSEL),ZH2Z,ZH2DIV,ZNU2,&
     & ZCOSPX(IPRE,JSEL),ZCOSPY(IPRE,JSEL),&
     & ZSINPX(IPRE,JSEL),ZSINPY(IPRE,JSEL))  
  ENDDO
  IPRE = JPPYV
  DO JSEL = 1 , KNSELS(IPRE)
    IY  = IY + 1
    PCOREL(IY,IX,1) = FRHVV(PDSELS(IPRE,JSEL),ZH2Z,ZH2DIV,ZNU2,&
     & ZCOSPX(IPRE,JSEL),ZCOSPY(IPRE,JSEL),&
     & ZSINPX(IPRE,JSEL),ZSINPY(IPRE,JSEL))  
  ENDDO
  IPRE = JPPYDZ
  DO JSEL = 1 , KNSELS(IPRE)
    IY = IY + 1
    PCOREL(IY,IX,1) = FRHVZ(PDSELS(IPRE,JSEL),ZH2Z,ZNU2,ZMU,&
     & ZCOSPX(IPRE,JSEL))  
  ENDDO
  IY = IY + KNSELS(JPPYHU)+KNSELS(JPPYST)+KNSELS(JPPYSN)&
   & +KNSELS(JPPYT2)+KNSELS(JPPYH2)  
  IPRE = JPPYU1
  DO JSEL = 1 , KNSELS(IPRE)
    IY  = IY + 1
    PCOREL(IY,IX,1) = FRHV1U1(PDSELS(IPRE,JSEL),ZH2VORBL,ZH2DIVBL,&
     & ZNU2BL, ZCOSPX(IPRE,JSEL),ZCOSPY(IPRE,JSEL),&
     & ZSINPX(IPRE,JSEL),ZSINPY(IPRE,JSEL))  
  ENDDO
  IPRE = JPPYV1
  DO JSEL = 1 , KNSELS(IPRE)
    IY  = IY + 1
    PCOREL(IY,IX,1) = FRHV1V1(PDSELS(IPRE,JSEL),ZH2VORBL,ZH2DIVBL,&
     & ZNU2BL, ZCOSPX(IPRE,JSEL),ZCOSPY(IPRE,JSEL),&
     & ZSINPX(IPRE,JSEL),ZSINPY(IPRE,JSEL))  
  ENDDO
ENDIF

!  - 2.5 -  predictant Hu et predicteurs

IF ( LDFLAI(JPPXHU) ) THEN
  IX = IX + 1
  IY = KNSELS(JPPYZ)+KNSELS(JPPYT)+KNSELS(JPPYU)&
   & +KNSELS(JPPYV)+KNSELS(JPPYDZ)  
  IPRE = JPPYHU
  DO JSEL = 1 , KNSELS(IPRE)
    IY    = IY + 1
    PCOREL(IY,IX,1) = FRHHH(PDSELS(IPRE,JSEL),ZH2HU)
  ENDDO
  IY = IY + KNSELS(JPPYST)+KNSELS(JPPYSN)+KNSELS(JPPYT2)
  IPRE = JPPYH2
  DO JSEL = 1 , KNSELS(IPRE)
    IY  = IY + 1
    PCOREL(IY,IX,1) = FRHH2H2(PDSELS(IPRE,JSEL),ZH2H2)
  ENDDO
ENDIF

!  - 2.6 -  predictant SST et predicteurs

IF ( LDFLAI(JPPXST) ) THEN
  IX = IX + 1
  IY = KNSELS(JPPYZ)+KNSELS(JPPYT)+KNSELS(JPPYU)&
   & +KNSELS(JPPYV)+KNSELS(JPPYDZ)+KNSELS(JPPYHU)  
  IPRE = JPPYST
  DO JSEL = 1 , KNSELS(IPRE)
    IY  = IY + 1
    PCOREL(IY,IX,1) = FRHSTST(PDSELS(IPRE,JSEL),ZH2SST)
  ENDDO
ENDIF

!  - 2.7 -  predictant SN et predicteurs

IF ( LDFLAI(JPPXSN) ) THEN
  IX = IX + 1
  IY = KNSELS(JPPYZ)+KNSELS(JPPYT)+KNSELS(JPPYU)&
   & +KNSELS(JPPYV)+KNSELS(JPPYDZ)+KNSELS(JPPYHU)&
   & +KNSELS(JPPYST)  
  IPRE = JPPYSN
  DO JSEL = 1 , KNSELS(IPRE)
    IY  = IY + 1
    IAD = KASELS(IPRE,JSEL)
    ZDISTP2 = ( PRESS(KNBPV) - ROBODY(IAD,MDBRBPIO) ) ** 2
    PCOREL(IY,IX,1) = FRHSNSN(PDSELS(IPRE,JSEL),ZH2SN)*FRHPSNSN(ZDISTP2,ZV2P2SN)
  ENDDO
ENDIF

!  - 2.8 -  predictant T2m et predicteurs

IF ( .NOT. LCORRF ) THEN
  IF ( LDFLAI(JPPXT2) ) THEN
    IX = IX + 1
    IY = KNSELS(JPPYZ)+KNSELS(JPPYT)+KNSELS(JPPYU)&
     & +KNSELS(JPPYV)+KNSELS(JPPYDZ)+KNSELS(JPPYHU)&
     & +KNSELS(JPPYST)+KNSELS(JPPYSN)  
    IPRE = JPPYT2
    DO JSEL = 1 , KNSELS(IPRE)
      IY  = IY + 1
      PCOREL(IY,IX,1) = FRHT2T2(PDSELS(IPRE,JSEL),ZH2T2)
    ENDDO
  ENDIF
ELSE
  IF ( LDFLAI(JPPXT2) ) THEN
    IX = IX + 1
    IY = KNSELS(JPPYZ)+KNSELS(JPPYT)+KNSELS(JPPYU)&
     & +KNSELS(JPPYV)+KNSELS(JPPYDZ)+KNSELS(JPPYHU)&
     & +KNSELS(JPPYST)+KNSELS(JPPYSN)  
    IPRE = JPPYT2
    DO JSEL = 1 , KNSELS(IPRE)
      IY  = IY + 1
      PCOREL(IY,IX,1) = FRHT2T2(SQRT(PDSELS(IPRE,JSEL)),SQRT(ZH2T2))
    ENDDO
  ENDIF
ENDIF

!  - 2.9 -  predictant H2m et predicteurs

IF ( .NOT. LCORRF ) THEN
  IF ( LDFLAI(JPPXH2) ) THEN
    IX = IX + 1
    IY =  KNSELS(JPPYZ)+KNSELS(JPPYT)+KNSELS(JPPYU)&
     & +KNSELS(JPPYV)+KNSELS(JPPYDZ)+KNSELS(JPPYHU)&
     & +KNSELS(JPPYST)+KNSELS(JPPYSN)+KNSELS(JPPYT2)  
    IPRE = JPPYH2
    DO JSEL = 1 , KNSELS(IPRE)
      IY  = IY + 1
      PCOREL(IY,IX,1) = FRHH2H2(PDSELS(IPRE,JSEL),ZH2H2)
    ENDDO
  ENDIF
ELSE
  IF ( LDFLAI(JPPXH2) ) THEN
    IX = IX + 1
    IY =  KNSELS(JPPYZ)+KNSELS(JPPYT)+KNSELS(JPPYU)&
     & +KNSELS(JPPYV)+KNSELS(JPPYDZ)+KNSELS(JPPYHU)&
     & +KNSELS(JPPYST)+KNSELS(JPPYSN)+KNSELS(JPPYT2)  
    IPRE = JPPYH2
    DO JSEL = 1 , KNSELS(IPRE)
      IY  = IY + 1
      PCOREL(IY,IX,1) = FRHH2H2(SQRT(PDSELS(IPRE,JSEL)),SQRT(ZH2H2))
    ENDDO
  ENDIF
ENDIF

!  - 2.10 - predictant U10m et predicteurs

IF ( LDFLAI(JPPXU1) ) THEN
  IX = IX + 1
  IY = KNSELS(JPPYZ)+KNSELS(JPPYT)+KNSELS(JPPYU)&
   & +KNSELS(JPPYV)+KNSELS(JPPYDZ)+KNSELS(JPPYHU)&
   & +KNSELS(JPPYST)+KNSELS(JPPYSN)+KNSELS(JPPYT2)&
   & +KNSELS(JPPYH2)  
  IPRE = JPPYU1
  DO JSEL = 1 , KNSELS(IPRE)
    IY  = IY + 1
    PCOREL(IY,IX,1) = FRHU1U1(PDSELS(IPRE,JSEL),ZH2VORBL,ZH2DIVBL,&
     & ZNU2BL,ZCOSPX(IPRE,JSEL),ZCOSPY(IPRE,JSEL),&
     & ZSINPX(IPRE,JSEL),ZSINPY(IPRE,JSEL))  
  ENDDO
  IPRE = JPPYV1
  DO JSEL = 1 , KNSELS(IPRE)
    IY  = IY + 1
    PCOREL(IY,IX,1) = FRHU1V1(PDSELS(IPRE,JSEL),ZH2VORBL,ZH2DIVBL,&
     & ZNU2BL,ZCOSPX(IPRE,JSEL),ZCOSPY(IPRE,JSEL),&
     & ZSINPX(IPRE,JSEL),ZSINPY(IPRE,JSEL))  
  ENDDO
ENDIF

! -  2.11 - predictant V10m et predicteurs

IF ( LDFLAI(JPPXV1) ) THEN
  IX = IX + 1
  IY = KNSELS(JPPYZ)+KNSELS(JPPYT)+KNSELS(JPPYU)&
   & +KNSELS(JPPYV)+KNSELS(JPPYDZ)+KNSELS(JPPYHU)&
   & +KNSELS(JPPYST)+KNSELS(JPPYSN)+KNSELS(JPPYT2)&
   & +KNSELS(JPPYH2)  
  IPRE = JPPYU1
  DO JSEL = 1 , KNSELS(IPRE)
    IY  = IY + 1
    PCOREL(IY,IX,1) = FRHV1U1(PDSELS(IPRE,JSEL),ZH2VORBL,ZH2DIVBL,&
     & ZNU2BL,ZCOSPX(IPRE,JSEL),ZCOSPY(IPRE,JSEL),&
     & ZSINPX(IPRE,JSEL),ZSINPY(IPRE,JSEL))  
  ENDDO
  IPRE = JPPYV1
  DO JSEL = 1 , KNSELS(IPRE)
    IY  = IY + 1
    PCOREL(IY,IX,1) = FRHV1V1(PDSELS(IPRE,JSEL),ZH2VORBL,ZH2DIVBL,&
     & ZNU2BL,ZCOSPX(IPRE,JSEL),ZCOSPY(IPRE,JSEL),&
     & ZSINPX(IPRE,JSEL),ZSINPY(IPRE,JSEL))  
  ENDDO
ENDIF

!----------------------------------------------------------------------------
!  - 3 -  Calcul des correlations : apport partie verticale
!         -------------------------------------------------

DO JV = 2 , KNBPV
  DO JX = 1 , KNLX
    DO JY = 1 , KNIN
      PCOREL(JY,JX,JV) = PCOREL(JY,JX,1)
    ENDDO
  ENDDO
ENDDO

! Boucle sur les differents niveaux
!CDIR SHORTLOOP
DO JIP = 1 , KNBPV

  ZKZ = QPOVZ(JIP,KTASK)
  ZKH = QPOVH(JIP,KTASK)
  IX = 0
  ZPRESS = PRESS(JIP)

! ce calcul de ZLIMB et ZLIMH assure que la correlation est nulle si la
! difference de pression entre obs et predictand est trop grande
! les valeurs conduisent aux intervales suivant :
!        ZPRESS   1000   700   500   200   100    50    10
!        ZLIMH     840   390   190    40    30    10    -6!
!        ZLIMB    1500! 1200! 1000   700   600   325   105

  ZZPPRRSS = EXP(ZPRESS)
  IF (ZZPPRRSS  >  10000._JPRB) THEN
    ZLIMH  = (ZZPPRRSS * 1.E-5_JPRB - 0.2_JPRB) * ZZPPRRSS +  4000._JPRB
    ZLIMB  =                            ZZPPRRSS + 50000._JPRB
  ELSE
    ZLIMH  = 0.4_JPRB * ZZPPRRSS - 1000._JPRB
    ZLIMB  = 5.5_JPRB * ZZPPRRSS + 5000._JPRB
  ENDIF
  IF (ZLIMH > 0) ZLIMH = LOG(ZLIMH)
  IF (ZLIMB > 0) ZLIMB = LOG(ZLIMB)

!  - 3.1 -  predictant Z et predicteurs

  IF ( LDFLAI(JPPXZ) ) THEN
    IX = IX + 1
    IY = 0
    IPRE = JPPYZ
    DO JSEL = 1 , KNSELS(IPRE)
      IY    = IY + 1
      IAD   = KASELS(IPRE,JSEL)
      IF ( ROBODY(IAD,MDBRBPIO) <= ZLIMB .AND. &
         & ROBODY(IAD,MDBRBPIO) >= ZLIMH )     THEN  
        PCOREL(IY,IX,JIP) = PCOREL(IY,IX,JIP) *&
         & FRVZZ(ZPRESS,ROBODY(IAD,MDBRBPIO),ZKZ)  
      ELSE
        PCOREL(IY,IX,JIP) = 0.0_JPRB
      ENDIF
    ENDDO
    IPRE = JPPYT
    DO JSEL = 1 , KNSELS(IPRE)
      IY    = IY + 1
      IAD   = KASELS(IPRE,JSEL)
      IF ( ROBODY(IAD,MDBRBPIO) <= ZLIMB .AND. &
         & ROBODY(IAD,MDBRBPIO) >= ZLIMH )     THEN  
        PCOREL(IY,IX,JIP) = PCOREL(IY,IX,JIP) *&
         & FRVZT(ZPRESS,ROBODY(IAD,MDBRBPIO),ZKZ)  
      ELSE
        PCOREL(IY,IX,JIP) = 0.0_JPRB
      ENDIF
    ENDDO
    IPRE = JPPYU
    DO JSEL = 1 , KNSELS(IPRE)
      IY    = IY + 1
      IAD   = KASELS(IPRE,JSEL)
      IF ( ROBODY(IAD,MDBRBPIO) <= ZLIMB .AND. &
         & ROBODY(IAD,MDBRBPIO) >= ZLIMH )     THEN  
        PCOREL(IY,IX,JIP) = PCOREL(IY,IX,JIP) *&
         & FRVZU(ZPRESS,ROBODY(IAD,MDBRBPIO),ZKZ)  
      ELSE
        PCOREL(IY,IX,JIP) = 0.0_JPRB
      ENDIF
    ENDDO
    IPRE = JPPYV
    DO JSEL = 1 , KNSELS(IPRE)
      IY    = IY + 1
      IAD   = KASELS(IPRE,JSEL)
      IF ( ROBODY(IAD,MDBRBPIO) <= ZLIMB .AND. &
         & ROBODY(IAD,MDBRBPIO) >= ZLIMH )     THEN  
        PCOREL(IY,IX,JIP) = PCOREL(IY,IX,JIP) *&
         & FRVZV(ZPRESS,ROBODY(IAD,MDBRBPIO),ZKZ)  
      ELSE
        PCOREL(IY,IX,JIP) = 0.0_JPRB
      ENDIF
    ENDDO
    IPRE = JPPYDZ
    DO JSEL = 1 , KNSELS(IPRE)
      IY    = IY + 1
      IAD   = KASELS(IPRE,JSEL)
      IF ( ROBODY(IAD,MDBRBPIO) <= ZLIMB .AND. &
         & ROBODY(IAD,MDBRBPIO) >= ZLIMH )     THEN  
        PCOREL(IY,IX,JIP) = PCOREL(IY,IX,JIP) * FRVZDZ(ZPRESS,&
         & ROBODY(IAD,MDBRBPIO),ROBODY(IAD,MDBPRL),&
         & ROBODY(IAD,MDBFGE),ROBODY(IAD,MDBRBOE),ZKZ)  
      ELSE
        PCOREL(IY,IX,JIP) = 0.0_JPRB
      ENDIF
    ENDDO
  ENDIF

!  - 3.2 -  predictant T et predicteurs

  IF ( LDFLAI(JPPXT) ) THEN
    IX = IX + 1
    IY = 0
    IPRE = JPPYZ
    DO JSEL = 1 , KNSELS(IPRE)
      IY    = IY + 1
      IAD   = KASELS(IPRE,JSEL)
      IF ( ROBODY(IAD,MDBRBPIO) <= ZLIMB .AND. &
         & ROBODY(IAD,MDBRBPIO) >= ZLIMH )     THEN  
        PCOREL(IY,IX,JIP) = PCOREL(IY,IX,JIP) *&
         & FRVTZ(ZPRESS,ROBODY(IAD,MDBRBPIO),ZKZ)  
      ELSE
        PCOREL(IY,IX,JIP) = 0.0_JPRB
      ENDIF
    ENDDO
    IPRE = JPPYT
    DO JSEL = 1 , KNSELS(IPRE)
      IY    = IY + 1
      IAD   = KASELS(IPRE,JSEL)
      IF ( ROBODY(IAD,MDBRBPIO) <= ZLIMB .AND. &
         & ROBODY(IAD,MDBRBPIO) >= ZLIMH )     THEN  
        PCOREL(IY,IX,JIP) = PCOREL(IY,IX,JIP) *&
         & MAX(0.0_JPRB,FRVTT(ZPRESS,ROBODY(IAD,MDBRBPIO),ZKZ))  
      ELSE
        PCOREL(IY,IX,JIP) = 0.0_JPRB
      ENDIF
    ENDDO
    IPRE = JPPYU
    DO JSEL = 1 , KNSELS(IPRE)
      IY    = IY + 1
      IAD   = KASELS(IPRE,JSEL)
      IF ( ROBODY(IAD,MDBRBPIO) <= ZLIMB .AND. &
         & ROBODY(IAD,MDBRBPIO) >= ZLIMH )     THEN  
        PCOREL(IY,IX,JIP) = PCOREL(IY,IX,JIP) *&
         & FRVTU(ZPRESS,ROBODY(IAD,MDBRBPIO),ZKZ)  
      ELSE
        PCOREL(IY,IX,JIP) = 0.0_JPRB
      ENDIF
    ENDDO
    IPRE = JPPYV
    DO JSEL = 1 , KNSELS(IPRE)
      IY    = IY + 1
      IAD   = KASELS(IPRE,JSEL)
      IF ( ROBODY(IAD,MDBRBPIO) <= ZLIMB .AND. &
         & ROBODY(IAD,MDBRBPIO) >= ZLIMH )     THEN  
        PCOREL(IY,IX,JIP) = PCOREL(IY,IX,JIP) *&
         & FRVTV(ZPRESS,ROBODY(IAD,MDBRBPIO),ZKZ)  
      ELSE
        PCOREL(IY,IX,JIP) = 0.0_JPRB
      ENDIF
    ENDDO
    IPRE = JPPYDZ
    DO JSEL = 1 , KNSELS(IPRE)
      IY    = IY + 1
      IAD   = KASELS(IPRE,JSEL)
      IF ( ROBODY(IAD,MDBRBPIO) <= ZLIMB .AND. &
         & ROBODY(IAD,MDBRBPIO) >= ZLIMH )     THEN  
        PCOREL(IY,IX,JIP) = PCOREL(IY,IX,JIP)*MAX(0.0_JPRB,FRVTDZ(ZPRESS,&
         & ROBODY(IAD,MDBRBPIO),ROBODY(IAD,MDBPRL),&
         & ROBODY(IAD,MDBFGE),ROBODY(IAD,MDBRBOE),ZKZ))  
      ELSE
        PCOREL(IY,IX,JIP) = 0.0_JPRB
      ENDIF
    ENDDO
    IY = IY + KNSELS(JPPYHU)+KNSELS(JPPYST)+KNSELS(JPPYSN)
    IPRE = JPPYT2
    DO JSEL = 1 , KNSELS(IPRE)
      IY    = IY + 1
      PCOREL(IY,IX,JIP) = PCOREL(IY,IX,JIP) *&
       & FRVBLBL(ZPRESS,PRESS(KNBPV),ZKPBL)  
    ENDDO
  ENDIF

!  - 3.3 -  predictant U et predicteurs

  IF ( LDFLAI(JPPXU) ) THEN
    IX = IX + 1
    IY = 0
    IPRE = JPPYZ
    DO JSEL = 1 , KNSELS(IPRE)
      IY    = IY + 1
      IAD   = KASELS(IPRE,JSEL)
      IF ( ROBODY(IAD,MDBRBPIO) <= ZLIMB .AND. &
         & ROBODY(IAD,MDBRBPIO) >= ZLIMH )     THEN  
        PCOREL(IY,IX,JIP) = PCOREL(IY,IX,JIP) *&
         & FRVUZ(ZPRESS,ROBODY(IAD,MDBRBPIO),ZKZ)  
      ELSE
        PCOREL(IY,IX,JIP) = 0.0_JPRB
      ENDIF
    ENDDO
    IPRE = JPPYT
    DO JSEL = 1 , KNSELS(IPRE)
      IY    = IY + 1
      IAD   = KASELS(IPRE,JSEL)
      IF ( ROBODY(IAD,MDBRBPIO) <= ZLIMB .AND. &
         & ROBODY(IAD,MDBRBPIO) >= ZLIMH )     THEN  
        PCOREL(IY,IX,JIP) = PCOREL(IY,IX,JIP) *&
         & FRVUT(ZPRESS,ROBODY(IAD,MDBRBPIO),ZKZ)  
      ELSE
        PCOREL(IY,IX,JIP) = 0.0_JPRB
      ENDIF
    ENDDO
    IPRE = JPPYU
    DO JSEL = 1 , KNSELS(IPRE)
      IY    = IY + 1
      IAD   = KASELS(IPRE,JSEL)
      IF ( ROBODY(IAD,MDBRBPIO) <= ZLIMB .AND. &
         & ROBODY(IAD,MDBRBPIO) >= ZLIMH )     THEN  
        PCOREL(IY,IX,JIP) = PCOREL(IY,IX,JIP) *&
         & FRVUU(ZPRESS,ROBODY(IAD,MDBRBPIO),ZKZ)  
      ELSE
        PCOREL(IY,IX,JIP) = 0.0_JPRB
      ENDIF
    ENDDO
    IPRE = JPPYV
    DO JSEL = 1 , KNSELS(IPRE)
      IY    = IY + 1
      IAD   = KASELS(IPRE,JSEL)
      IF ( ROBODY(IAD,MDBRBPIO) <= ZLIMB .AND. &
         & ROBODY(IAD,MDBRBPIO) >= ZLIMH )     THEN  
        PCOREL(IY,IX,JIP) = PCOREL(IY,IX,JIP) *&
         & FRVUV(ZPRESS,ROBODY(IAD,MDBRBPIO),ZKZ)  
      ELSE
        PCOREL(IY,IX,JIP) = 0.0_JPRB
      ENDIF
    ENDDO
    IPRE = JPPYDZ
    DO JSEL = 1 , KNSELS(IPRE)
      IY    = IY + 1
      IAD   = KASELS(IPRE,JSEL)
      IF ( ROBODY(IAD,MDBRBPIO) <= ZLIMB .AND. &
         & ROBODY(IAD,MDBRBPIO) >= ZLIMH )     THEN  
        PCOREL(IY,IX,JIP) = PCOREL(IY,IX,JIP) * FRVUDZ(ZPRESS,&
         & ROBODY(IAD,MDBRBPIO),ROBODY(IAD,MDBPRL),&
         & ROBODY(IAD,MDBFGE),ROBODY(IAD,MDBRBOE),ZKZ)  
      ELSE
        PCOREL(IY,IX,JIP) = 0.0_JPRB
      ENDIF
    ENDDO
    IY = IY + KNSELS(JPPYHU)+KNSELS(JPPYST)+KNSELS(JPPYSN)&
     & +KNSELS(JPPYT2)+KNSELS(JPPYH2)  
    IPRE = JPPYU1
    DO JSEL = 1 , KNSELS(IPRE)
      IY    = IY + 1
      PCOREL(IY,IX,JIP) = PCOREL(IY,IX,JIP) *&
       & FRVBLBL(ZPRESS,PRESS(KNBPV),ZKPBL)  
    ENDDO
    IPRE = JPPYV1
    DO JSEL = 1 , KNSELS(IPRE)
      IY    = IY + 1
      PCOREL(IY,IX,JIP) = PCOREL(IY,IX,JIP) *&
       & FRVBLBL(ZPRESS,PRESS(KNBPV),ZKPBL)  
    ENDDO
  ENDIF

!  - 3.4 -  predictant V et predicteurs

  IF ( LDFLAI(JPPXV) ) THEN
    IX = IX + 1
    IY = 0
    IPRE = JPPYZ
    DO JSEL = 1 , KNSELS(IPRE)
      IY    = IY + 1
      IAD   = KASELS(IPRE,JSEL)
      IF ( ROBODY(IAD,MDBRBPIO) <= ZLIMB .AND. &
         & ROBODY(IAD,MDBRBPIO) >= ZLIMH )     THEN  
        PCOREL(IY,IX,JIP) = PCOREL(IY,IX,JIP) *&
         & FRVVZ(ZPRESS,ROBODY(IAD,MDBRBPIO),ZKZ)  
      ELSE
        PCOREL(IY,IX,JIP) = 0.0_JPRB
      ENDIF
    ENDDO
    IPRE = JPPYT
    DO JSEL = 1 , KNSELS(IPRE)
      IY    = IY + 1
      IAD   = KASELS(IPRE,JSEL)
      IF ( ROBODY(IAD,MDBRBPIO) <= ZLIMB .AND. &
         & ROBODY(IAD,MDBRBPIO) >= ZLIMH )     THEN  
        PCOREL(IY,IX,JIP) = PCOREL(IY,IX,JIP) *&
         & FRVVT(ZPRESS,ROBODY(IAD,MDBRBPIO),ZKZ)  
      ELSE
        PCOREL(IY,IX,JIP) = 0.0_JPRB
      ENDIF
    ENDDO
    IPRE = JPPYU
    DO JSEL = 1 , KNSELS(IPRE)
      IY    = IY + 1
      IAD   = KASELS(IPRE,JSEL)
      IF ( ROBODY(IAD,MDBRBPIO) <= ZLIMB .AND. &
         & ROBODY(IAD,MDBRBPIO) >= ZLIMH )     THEN  
        PCOREL(IY,IX,JIP) = PCOREL(IY,IX,JIP) *&
         & FRVVU(ZPRESS,ROBODY(IAD,MDBRBPIO),ZKZ)  
      ELSE
        PCOREL(IY,IX,JIP) = 0.0_JPRB
      ENDIF
    ENDDO
    IPRE = JPPYV
    DO JSEL = 1 , KNSELS(IPRE)
      IY    = IY + 1
      IAD   = KASELS(IPRE,JSEL)
      IF ( ROBODY(IAD,MDBRBPIO) <= ZLIMB .AND. &
         & ROBODY(IAD,MDBRBPIO) >= ZLIMH )     THEN  
        PCOREL(IY,IX,JIP) = PCOREL(IY,IX,JIP) *&
         & FRVVV(ZPRESS,ROBODY(IAD,MDBRBPIO),ZKZ)  
      ELSE
        PCOREL(IY,IX,JIP) = 0.0_JPRB
      ENDIF
    ENDDO
    IPRE = JPPYDZ
    DO JSEL = 1 , KNSELS(IPRE)
      IY    = IY + 1
      IAD   = KASELS(IPRE,JSEL)
      IF ( ROBODY(IAD,MDBRBPIO) <= ZLIMB .AND. &
         & ROBODY(IAD,MDBRBPIO) >= ZLIMH )     THEN  
        PCOREL(IY,IX,JIP) = PCOREL(IY,IX,JIP) * FRVVDZ(ZPRESS,&
         & ROBODY(IAD,MDBRBPIO),ROBODY(IAD,MDBPRL),&
         & ROBODY(IAD,MDBFGE),ROBODY(IAD,MDBRBOE),ZKZ)  
      ELSE
        PCOREL(IY,IX,JIP) = 0.0_JPRB
      ENDIF
    ENDDO
    IY = IY + KNSELS(JPPYHU)+KNSELS(JPPYST)+KNSELS(JPPYSN)&
     & +KNSELS(JPPYT2)+KNSELS(JPPYH2)  
    IPRE = JPPYU1
    DO JSEL = 1 , KNSELS(IPRE)
      IY    = IY + 1
      PCOREL(IY,IX,JIP) = PCOREL(IY,IX,JIP) *&
       & FRVBLBL(ZPRESS,PRESS(KNBPV),ZKPBL)  
    ENDDO
    IPRE = JPPYV1
    DO JSEL = 1 , KNSELS(IPRE)
      IY    = IY + 1
      PCOREL(IY,IX,JIP) = PCOREL(IY,IX,JIP) *&
       & FRVBLBL(ZPRESS,PRESS(KNBPV),ZKPBL)  
    ENDDO
  ENDIF

!  - 3.5 -  predictant Hu et predicteurs

  IF ( LDFLAI(JPPXHU) ) THEN
    IX = IX + 1
    IY = KNSELS(JPPYZ)+KNSELS(JPPYT)+KNSELS(JPPYU)&
     & +KNSELS(JPPYV)+KNSELS(JPPYDZ)  
    IPRE = JPPYHU
    DO JSEL = 1 , KNSELS(IPRE)
      IY    = IY + 1
      IAD   = KASELS(IPRE,JSEL)
      IF ( ROBODY(IAD,MDBRBPIO) <=  ZLIMB .AND. &
         & ROBODY(IAD,MDBRBPIO) >=  ZLIMH )     THEN  
        PCOREL(IY,IX,JIP) = PCOREL(IY,IX,JIP) *&
         & FRVHH(ZPRESS,ROBODY(IAD,MDBRBPIO),ZKH)  
      ELSE
        PCOREL(IY,IX,JIP) = 0.0_JPRB
      ENDIF
    ENDDO
    IY = IY +KNSELS(JPPYST)+KNSELS(JPPYSN)+KNSELS(JPPYT2)
    IPRE = JPPYH2
    DO JSEL = 1 , KNSELS(IPRE)
      IY    = IY + 1
      PCOREL(IY,IX,JIP) = PCOREL(IY,IX,JIP) *&
       & FRVBLBL(ZPRESS,PRESS(KNBPV),ZKPBL)  
    ENDDO
  ENDIF

! On ne fait rien sur la verticale pour le champ de SST bien sur !!!
! ni pour les champs de couche limite !
! on analyse sur la surface sol ou sur la surface 2m/10m

! Fin boucle niveaux
ENDDO

!----------------------------------------------------------------------------
!  - 4 -  Calcul des covariances normees par l'ecart-type d'erreur du
!         guess au point d'observation et des valeurs absolues des
!         correlations
!         -----------------------------------------------------------

DO JIP = 1 , KNBPV
  IX = 0
  DO JX = 1 , JPNVX
    IF ( LDFLAI(JX) ) THEN
      IX = IX + 1
      IY = 0
      DO JIPRE = 1 , JPNVY
        DO JSEL = 1 , KNSELS(JIPRE)
          IY  = IY + 1
          IAD = KASELS(JIPRE,JSEL)
          PCOVAR(IY,IX,JIP) = PCOREL(IY,IX,JIP)*PSIG(JX,JIP)
          PCOREL(IY,IX,JIP) = ABS(PCOREL(IY,IX,JIP)) /&
           & SQRT(1.0_JPRB+(ROBODY(IAD,MDBOER)/ROBODY(IAD,MDBFGE))**2)  
        ENDDO
      ENDDO
    ENDIF
  ENDDO
ENDDO

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