SUBROUTINE PPFIDH (PDHNOM,PDDHCV,PDDHCS,KNUM,PDDHCV_TOT,PDDHCS_TOT,KDIMDOM)
!-----------------------------------------------------------------------
!**** PPFIDH * ECRITURE DES RESULTATS POUR UN DOMAINE SUR UN FICHIER
!              DIAGNOSTICS PAR DOMAINES HORIZONTAUX
!              Write results for one domain on a DDH file.
!-----------------------------------------------------------------------
!     BUT
!     ---
!      TRANSFERT DES RESULTATS OBTENUS POUR UN DOMAINE IDENTIFIE
!     PAR PDHNOM SUR UN FICHIER LFA

!     ARGUMENTS D'ENTREE
!     ------------------
!      PDHNOM(11) : IDENTIFICATION DU DOMAINE
!                  PDHNOM(11) EST LE TYPE DE DOMAINE
!      PDDHCV(0:NFLEVG,NDHCV+NDHVV) : PROFILS VERTICAUX
!                  LA STRUCTURE DU TABLEAU EST RESUMEE DANS
!                  PPSYDH, SINON VOIR YOMTDDH ET CPDYDDH/CPPHDDH
!      PDDHCS(NDHCV+NDHVV) : SOL
!      KNUM : NUMERO DU DOMAINE DANS UNE SERIE
!             (PAR EXEMPLE ENSEMBLE DES BANDES DE LATITUDE)
!      KDIMDOM : NOMBRE DE DOMAINES

!     ARGUMENTS DE SORTIE
!     -------------------
!     FICHIER LFA

!     ORIGINAL
!     --------
!     91-02-01, Alain Joly.

!     MODIFICATIONS
!     -------------
!     91-12-11, J.M. Piriou: ajout du terme flux d'enthalpie du aux
!               precipitations, dans le cas masse variable (NDPSFI=1).
!     92-03-01, M. Janousek: diagnostic de l'entropie.
!     92-06-01, M. Janousek: diagnostic du moment cinetique.
!     92-06-01, J.M. Piriou: humidite relative et cumul du champ de masse.
!     97-06-16. P.Viterbo : new style for surface DDH
!     00-05-15. C.Jakob   : new surface DDH after introduction of tiles
!        M.Hamrud      01-Oct-2003 CY28 Cleaning
!     05-06-20, F. Bouyssel: Lopez's prognostic scheme
!   2005-04-16, T. Kovacic: AROME DDH.
!     06-01-25, F. Bouyssel: Change name of Lopez's water fluxes
!   2006-08-22, J.M. Piriou: write DDH on LFA files.
!   01-oct-08 O.Riviere introduction of new ddh dataflow in Arome
!                       removal of old one
!     K. Yessad (Dec 2008): cleanings, remove tabulations.
!   2008-01-05, J.M. Piriou: cleaning: suppress use of NPHY, correct LHDQLN bug.
!-----------------------------------------------------------------------

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

USE YOMCT0B  , ONLY : LECMWF
USE YOMDIM   , ONLY : NFLEVG
USE YOMLUN   , ONLY : NULOUT   ,NPODDH
USE YOMCT0   , ONLY : NPRINTLEV
USE YOMLDDH  , ONLY : LHDLFA   ,LHDHKS   ,LHDMCI   ,LHDENT   ,LHDLIST,LFLEXDIA
USE YOMMDDH  , ONLY : NDHCS    ,NDHCV    ,NDHCVSU  ,NDHCSSU  ,&
 & NDHVV    ,NDHFVD   ,NDHVS    ,NDHFSD   ,NDHFSP   ,&
 & NDHFFS   ,NDHVFS   ,NDHVHK   ,NDHVMC   ,NDHAVD   ,&
 & NDHAVP   ,NDHAHKD  ,NDHBHKD  ,NDHAHKP  ,NDHBHKP  ,&
 & NDHVTLS  ,NDHFTLS  ,NDHVTSS  ,NDHFTSS  ,NDHVTTS  ,&
 & NDHFTTS  ,NDHVTIS  ,NDHFTIS  ,NDHVSSS  ,NDHFSSS  ,&
 & NDHVIIS  ,NDHFIIS  ,NDHVWLS  ,NDHFWLS  ,&
 & NDHAMCD  ,NDHBMCD  ,NDHBMCP
USE YOMSDDH  , ONLY : NHDQLNVA ,NHDPASVA ,LHDQLN   ,LHDADD   ,LHDPAS
USE YOMCDDH  , ONLY : CADHTLS  ,CADHTSS  ,CADHTTS  ,CADHTIS  ,&
 & CADHSSS  ,CADHIIS ,CADHWLS  ,CADHFSS
USE YOMDPHY   , ONLY : NCSI     ,NCSNEC   ,NTILES
USE SURFACE_FIELDS_MIX  , ONLY : YSP_SBD
USE YOMPHY   , ONLY : LCONDWT  ,LPROCLD
USE DDH_MIX, ONLY: NTOTFIELD,RDDH_DESCR

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

IMPLICIT NONE

INTEGER(KIND=JPIM),INTENT(IN)    :: KNUM, KDIMDOM
REAL(KIND=JPRB),INTENT(IN)       :: PDHNOM(11)
REAL(KIND=JPRB),INTENT(IN)       :: PDDHCV(0:NFLEVG,NDHCVSU+NDHVV)
REAL(KIND=JPRB),INTENT(IN)       :: PDDHCS(NDHCSSU+NDHVS)
REAL(KIND=JPRB),INTENT(IN)       :: PDDHCV_TOT((NFLEVG+1)*KDIMDOM*(NDHCVSU+NDHVV))
REAL(KIND=JPRB),INTENT(IN)       :: PDDHCS_TOT(KDIMDOM*(NDHCSSU+NDHVS))

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

INTEGER(KIND=JPIM) :: JVAR, JFLX, JFIELD
REAL(KIND=JPRB) :: ZEROV(NFLEVG)
REAL(KIND=JPRB) :: ZEROF(0:NFLEVG)
REAL(KIND=JPRB) :: ZMAR0 , ZMAR1
CHARACTER :: CLNOMA*16
CHARACTER :: CL0*10, CL1*10, CL2*2, CLDIVOR*10, CLFLUVD*10
CHARACTER :: CLFLUPL*10
INTEGER(KIND=JPIM) :: IDHCS, IDHCV, INBCUMS, JJPASS, JLEV, IPOINT,IVAR
REAL(KIND=JPRB) :: ZHOOK_HANDLE

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

#include "addpgr.intfb.h"
#include "wrifdh.intfb.h"

!-----------------------------------------------------------------------
IF (LHOOK) CALL DR_HOOK('PPFIDH',0,ZHOOK_HANDLE)
!-----------------------------------------------------------------------

CLNOMA = ' '
CL0     = '0         '
CL1     = '1         '
CLDIVOR = 'DIVFLUHOR '
CLFLUVD = 'FLUVERTDYN'
CLFLUPL = 'FLUDUAPLUI'

DO JLEV=1,NFLEVG
  ZEROV(JLEV)=0.0_JPRB
ENDDO
DO JLEV=0,NFLEVG
  ZEROF(JLEV)=0.0_JPRB
ENDDO

ZMAR0=0._JPRB
DO JLEV=0, NFLEVG
  ZMAR0=ZMAR0+ PDDHCV(JLEV,1)
ENDDO

ZMAR1=0._JPRB
DO JLEV=0, NFLEVG
  ZMAR1=ZMAR1+ PDDHCV(JLEV,NDHCV+1)
ENDDO


!     ------------------------------------------------------------------
!*    1.- ARTICLE DOCUMENTAIRE
IF (NPRINTLEV >= 1) THEN
  WRITE (NULOUT,*) ' DDH * PPFIDH KNUM = ',KNUM,' NPODDH = ',NPODDH
ENDIF

IF(LHDLFA) THEN
  ! ON ECRIT SUR FICHIER LFA UN ARTICLE DOCD PAR DOMAINE.
  WRITE (CLNOMA,'(''DOCD'',I3.3)') KNUM
  CALL LFAECRR(NPODDH,CLNOMA,PDHNOM,11)
ELSE
  CALL ADDPGR('DOCD',KNUM,PDHNOM,11)
ENDIF
! ON N'ECRIT SUR FICHIER LFA QU'UN ARTICLE SCIENTIFIQUE
! POUR TOUS LES DOMAINES. ON N'ECRIT DONC CI-DESSOUS
! L'ARTICLE SCIENTIFIQUE QUE SI LE DOMAINE COURANT EST LE DERNIER.

IF (LFLEXDIA) THEN 


  IF(.NOT.LHDLFA .OR. KNUM == KDIMDOM) THEN
    IVAR=0
    DO JFIELD=1,NTOTFIELD
      IPOINT=JFIELD
      SELECT CASE(RDDH_DESCR(JFIELD)%CFLUX)
      CASE('V')
        WRITE (CLNOMA,4000) KNUM,RDDH_DESCR(JFIELD)%CNAME,CL1    
        CALL WRIFDH( PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
         & (1+NFLEVG)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(1,IPOINT),-999)
       
        WRITE (CLNOMA,4000) KNUM,RDDH_DESCR(JFIELD)%CNAME,CL0 
        IVAR=IVAR+1
        IPOINT=IVAR+NTOTFIELD
        CALL WRIFDH( PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
         & (1+NFLEVG)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(1,IPOINT),-999)

      CASE('T')
        WRITE (CLNOMA,6000) KNUM,RDDH_DESCR(JFIELD)%CNAME,' '    
        CALL WRIFDH( PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
         & (1+NFLEVG)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(1,IPOINT),-999)

      CASE('F')
        WRITE (CLNOMA,6000) KNUM,RDDH_DESCR(JFIELD)%CNAME,' '     
        CALL WRIFDH( PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
         & (1+NFLEVG)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(1,IPOINT),1+NFLEVG)

      END SELECT
    ENDDO
  ENDIF ! NOT LDHLFA OR KNUM==KDIMDOM


ELSE !LFLEXDIA


  IF(.NOT.LHDLFA .OR. KNUM == KDIMDOM) THEN

    !     ------------------------------------------------------------------
    !*    2.- ARTICLES DE VARIABLES

    IDHCV=0

    !     INSTANT INITIAL
    !     ---------------
    IF ( LHDHKS ) THEN
      IDHCV=0
      WRITE (CLNOMA,5000) KNUM,'V','PP',CL0
      IPOINT=IDHCV+1
      CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & NFLEVG*KDIMDOM,NPODDH,CLNOMA,PDDHCV(1,IPOINT),NFLEVG)

      WRITE (CLNOMA,5000) KNUM,'V','QV',CL0
      IPOINT=IDHCV+2
      CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & NFLEVG*KDIMDOM,NPODDH,CLNOMA,PDDHCV(1,IPOINT),NFLEVG)

      WRITE (CLNOMA,5000) KNUM,'V','UU',CL0
      IPOINT=IDHCV+3
      CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & NFLEVG*KDIMDOM,NPODDH,CLNOMA,PDDHCV(1,IPOINT),NFLEVG)

      WRITE (CLNOMA,5000) KNUM,'V','VV',CL0
      IPOINT=IDHCV+4
      CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & NFLEVG*KDIMDOM,NPODDH,CLNOMA,PDDHCV(1,IPOINT),NFLEVG)

      WRITE (CLNOMA,5000) KNUM,'V','KK',CL0
      IPOINT=IDHCV+5
      CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & NFLEVG*KDIMDOM,NPODDH,CLNOMA,PDDHCV(1,IPOINT),NFLEVG)

      WRITE (CLNOMA,5000) KNUM,'V','CT',CL0
      IPOINT=IDHCV+6
      CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & NFLEVG*KDIMDOM,NPODDH,CLNOMA,PDDHCV(1,IPOINT),NFLEVG)

      WRITE (CLNOMA,5000) KNUM,'V','EP',CL0
      IPOINT=IDHCV+7
      CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & NFLEVG*KDIMDOM,NPODDH,CLNOMA,PDDHCV(1,IPOINT),NFLEVG)

      WRITE (CLNOMA,5000) KNUM,'V','HR',CL0
      IPOINT=IDHCV+8
      CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & NFLEVG*KDIMDOM,NPODDH,CLNOMA,PDDHCV(1,IPOINT),NFLEVG)

      IF(LHDQLN) THEN
        WRITE (CLNOMA,5000) KNUM,'V','QL',CL0
        IPOINT=IDHCV+9
        CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
         & NFLEVG*KDIMDOM,NPODDH,CLNOMA,PDDHCV(1,IPOINT),NFLEVG)

        WRITE (CLNOMA,5000) KNUM,'V','QN',CL0
        IPOINT=IDHCV+10
        CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
         & NFLEVG*KDIMDOM,NPODDH,CLNOMA,PDDHCV(1,IPOINT),NFLEVG)
      ENDIF

      IF(LHDPAS) THEN
        DO JJPASS=1,NHDPASVA
          WRITE(CL2,'(I2.2)') JJPASS
          WRITE (CLNOMA,5000) KNUM,'V',CL2,CL0
          IPOINT=IDHCV+9+NHDQLNVA+JJPASS-1
          CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
           & NFLEVG*KDIMDOM,NPODDH,CLNOMA,PDDHCV(1,IPOINT),NFLEVG)
        ENDDO
      ENDIF

      WRITE (CLNOMA,5000) KNUM,'V','NT',CL0
      IPOINT=IDHCV+9+NHDQLNVA+NHDPASVA
      CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & NFLEVG*KDIMDOM,NPODDH,CLNOMA,PDDHCV(1,IPOINT),NFLEVG)

      WRITE (CLNOMA,5000) KNUM,'V','OM',CL0
      IPOINT=IDHCV+10+NHDQLNVA+NHDPASVA
      CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & NFLEVG*KDIMDOM,NPODDH,CLNOMA,PDDHCV(1,IPOINT),NFLEVG)

    ENDIF

    IF ( LHDMCI ) THEN
      IDHCV=NDHVHK
      WRITE (CLNOMA,5000) KNUM,'V','A1',CL0
      IPOINT=IDHCV+1
      CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & NFLEVG*KDIMDOM,NPODDH,CLNOMA,PDDHCV(1,IPOINT),NFLEVG)

      WRITE (CLNOMA,5000) KNUM,'V','A2',CL0
      IPOINT=IDHCV+2
      CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & NFLEVG*KDIMDOM,NPODDH,CLNOMA,PDDHCV(1,IPOINT),NFLEVG)

      WRITE (CLNOMA,5000) KNUM,'V','A3',CL0
      IPOINT=IDHCV+3
      CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & NFLEVG*KDIMDOM,NPODDH,CLNOMA,PDDHCV(1,IPOINT),NFLEVG)
    ENDIF

    IF ( LHDENT ) THEN
      IDHCV=NDHVHK+NDHVMC
      WRITE (CLNOMA,5000) KNUM,'V','SS',CL0
      IPOINT=IDHCV+1
      CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & NFLEVG*KDIMDOM,NPODDH,CLNOMA,PDDHCV(1,IPOINT),NFLEVG)
    ENDIF

    !     INSTANT FINAL
    !     -------------
    IF ( LHDHKS ) THEN

      IDHCV=NDHCV
      WRITE (CLNOMA,5000) KNUM,'V','PP',CL1
      IPOINT=IDHCV+1
      CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & NFLEVG*KDIMDOM,NPODDH,CLNOMA,PDDHCV(1,IPOINT),NFLEVG)

      WRITE (CLNOMA,5000) KNUM,'V','QV',CL1
      IPOINT=IDHCV+2
      CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & NFLEVG*KDIMDOM,NPODDH,CLNOMA,PDDHCV(1,IPOINT),NFLEVG)

      WRITE (CLNOMA,5000) KNUM,'V','UU',CL1
      IPOINT=IDHCV+3
      CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & NFLEVG*KDIMDOM,NPODDH,CLNOMA,PDDHCV(1,IPOINT),NFLEVG)

      WRITE (CLNOMA,5000) KNUM,'V','VV',CL1
      IPOINT=IDHCV+4
      CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & NFLEVG*KDIMDOM,NPODDH,CLNOMA,PDDHCV(1,IPOINT),NFLEVG)

      WRITE (CLNOMA,5000) KNUM,'V','KK',CL1
      IPOINT=IDHCV+5
      CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & NFLEVG*KDIMDOM,NPODDH,CLNOMA,PDDHCV(1,IPOINT),NFLEVG)

      WRITE (CLNOMA,5000) KNUM,'V','CT',CL1
      IPOINT=IDHCV+6
      CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & NFLEVG*KDIMDOM,NPODDH,CLNOMA,PDDHCV(1,IPOINT),NFLEVG)

      WRITE (CLNOMA,5000) KNUM,'V','EP',CL1
      IPOINT=IDHCV+7
      CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & NFLEVG*KDIMDOM,NPODDH,CLNOMA,PDDHCV(1,IPOINT),NFLEVG)

      WRITE (CLNOMA,5000) KNUM,'V','HR',CL1
      IPOINT=IDHCV+8
      CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & NFLEVG*KDIMDOM,NPODDH,CLNOMA,PDDHCV(1,IPOINT),NFLEVG)

      IF(LHDQLN) THEN
        WRITE (CLNOMA,5000) KNUM,'V','QL',CL1
        IPOINT=IDHCV+9
        CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
         & NFLEVG*KDIMDOM,NPODDH,CLNOMA,PDDHCV(1,IPOINT),NFLEVG)

        WRITE (CLNOMA,5000) KNUM,'V','QN',CL1
        IPOINT=IDHCV+10
        CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
         & NFLEVG*KDIMDOM,NPODDH,CLNOMA,PDDHCV(1,IPOINT),NFLEVG)
      ENDIF

      IF(LHDPAS) THEN
        DO JJPASS=1,NHDPASVA
          WRITE(CL2,'(I2.2)') JJPASS
          WRITE (CLNOMA,5000) KNUM,'V',CL2,CL1
          IPOINT=IDHCV+9+NHDQLNVA+JJPASS-1
          CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
           & NFLEVG*KDIMDOM,NPODDH,CLNOMA,PDDHCV(1,IPOINT),NFLEVG)
        ENDDO
      ENDIF

      WRITE (CLNOMA,5000) KNUM,'V','NT',CL1
      IPOINT=IDHCV+9+NHDQLNVA+NHDPASVA
      CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & NFLEVG*KDIMDOM,NPODDH,CLNOMA,PDDHCV(1,IPOINT),NFLEVG)

      WRITE (CLNOMA,5000) KNUM,'V','OM',CL1
      IPOINT=IDHCV+10+NHDQLNVA+NHDPASVA
      CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & NFLEVG*KDIMDOM,NPODDH,CLNOMA,PDDHCV(1,IPOINT),NFLEVG)

    ENDIF

    IF ( LHDMCI ) THEN
      IDHCV=NDHCV+NDHVHK
      WRITE (CLNOMA,5000) KNUM,'V','A1',CL1
      IPOINT=IDHCV+1
      CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & NFLEVG*KDIMDOM,NPODDH,CLNOMA,PDDHCV(1,IPOINT),NFLEVG)

      WRITE (CLNOMA,5000) KNUM,'V','A2',CL1
      IPOINT=IDHCV+2
      CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & NFLEVG*KDIMDOM,NPODDH,CLNOMA,PDDHCV(1,IPOINT),NFLEVG)

      WRITE (CLNOMA,5000) KNUM,'V','A3',CL1
      IPOINT=IDHCV+3
      CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & NFLEVG*KDIMDOM,NPODDH,CLNOMA,PDDHCV(1,IPOINT),NFLEVG)
    ENDIF

    IF ( LHDENT ) THEN
      IDHCV=NDHCV+NDHVHK+NDHVMC
      WRITE (CLNOMA,5000) KNUM,'V','SS',CL1
      IPOINT=IDHCV+1
      CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & NFLEVG*KDIMDOM,NPODDH,CLNOMA,PDDHCV(1,IPOINT),NFLEVG)
    ENDIF

    !     ------------------------------------------------------------------
    !*    3.- TENDANCES ET FLUX DYNAMIQUES

    IF ( LHDHKS ) THEN
      IDHCV=NDHVV
      WRITE (CLNOMA,5000) KNUM,'T','PP',CLDIVOR
      IPOINT=IDHCV+1
      CALL WRIFDH(PDDHCV_TOT(2+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(1,IPOINT),NFLEVG)

      WRITE (CLNOMA,5000) KNUM,'T','QV',CLDIVOR
      IPOINT=IDHCV+2
      CALL WRIFDH(PDDHCV_TOT(2+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(1,IPOINT),NFLEVG)

      WRITE (CLNOMA,5000) KNUM,'T','UU',CLDIVOR
      IPOINT=IDHCV+3
      CALL WRIFDH(PDDHCV_TOT(2+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(1,IPOINT),NFLEVG)

      WRITE (CLNOMA,5000) KNUM,'T','VV',CLDIVOR
      IPOINT=IDHCV+4
      CALL WRIFDH(PDDHCV_TOT(2+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(1,IPOINT),NFLEVG)

      WRITE (CLNOMA,5000) KNUM,'T','UU','FFVGADPSG '
      IPOINT=IDHCV+5
      CALL WRIFDH(PDDHCV_TOT(2+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(1,IPOINT),NFLEVG)

      WRITE (CLNOMA,5000) KNUM,'T','VV','FFUGADPSG '
      IPOINT=IDHCV+6
      CALL WRIFDH(PDDHCV_TOT(2+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(1,IPOINT),NFLEVG)

      WRITE (CLNOMA,5000) KNUM,'T','KK',CLDIVOR
      IPOINT=IDHCV+7
      CALL WRIFDH(PDDHCV_TOT(2+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(1,IPOINT),NFLEVG)

      WRITE (CLNOMA,5000) KNUM,'T','KK','CONVERSI1 '
      IPOINT=IDHCV+8
      CALL WRIFDH(PDDHCV_TOT(2+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(1,IPOINT),NFLEVG)

      WRITE (CLNOMA,5000) KNUM,'T','CT',CLDIVOR
      IPOINT=IDHCV+9
      CALL WRIFDH(PDDHCV_TOT(2+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(1,IPOINT),NFLEVG)

      WRITE (CLNOMA,5000) KNUM,'T','CT','CONVERSI2 '
      IPOINT=IDHCV+10
      CALL WRIFDH(PDDHCV_TOT(2+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(1,IPOINT),NFLEVG)

      WRITE (CLNOMA,5000) KNUM,'T','CT','CONVERSI3 '
      IPOINT=IDHCV+11
      CALL WRIFDH(PDDHCV_TOT(2+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(1,IPOINT),NFLEVG)

      WRITE (CLNOMA,5000) KNUM,'T','EP',CLDIVOR
      IPOINT=IDHCV+12
      CALL WRIFDH(PDDHCV_TOT(2+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(1,IPOINT),NFLEVG)

      WRITE (CLNOMA,5000) KNUM,'P','PP','          '
      IPOINT=IDHCV+13
      CALL WRIFDH(PDDHCV_TOT(2+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(1,IPOINT),NFLEVG)

      IF(LHDQLN) THEN
        WRITE (CLNOMA,5000) KNUM,'T','QL',CLDIVOR
        IPOINT=IDHCV+14
        CALL WRIFDH(PDDHCV_TOT(2+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
         & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(1,IPOINT),NFLEVG)

        WRITE (CLNOMA,5000) KNUM,'T','QN',CLDIVOR
        IPOINT=IDHCV+15
        CALL WRIFDH(PDDHCV_TOT(2+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
         & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(1,IPOINT),NFLEVG)
      ENDIF
    ENDIF

    IF ( LHDMCI ) THEN
      IDHCV=NDHVV+NDHAHKD
      WRITE (CLNOMA,5000) KNUM,'T','A1',CLDIVOR
      IPOINT=IDHCV+1
      CALL WRIFDH(PDDHCV_TOT(2+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(1,IPOINT),NFLEVG)

      WRITE (CLNOMA,5000) KNUM,'T','A2',CLDIVOR
      IPOINT=IDHCV+2
      CALL WRIFDH(PDDHCV_TOT(2+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(1,IPOINT),NFLEVG)

      WRITE (CLNOMA,5000) KNUM,'T','A3',CLDIVOR
      IPOINT=IDHCV+3
      CALL WRIFDH(PDDHCV_TOT(2+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(1,IPOINT),NFLEVG)

      WRITE (CLNOMA,5000) KNUM,'T','A1','ADJUST    '
      IPOINT=IDHCV+4
      CALL WRIFDH(PDDHCV_TOT(2+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(1,IPOINT),NFLEVG)

      WRITE (CLNOMA,5000) KNUM,'T','A2','ADJUST    '
      IPOINT=IDHCV+5
      CALL WRIFDH(PDDHCV_TOT(2+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(1,IPOINT),NFLEVG)

      WRITE (CLNOMA,5000) KNUM,'T','A3','ADJUST    '
      IPOINT=IDHCV+6
      CALL WRIFDH(PDDHCV_TOT(2+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(1,IPOINT),NFLEVG)

      WRITE (CLNOMA,5000) KNUM,'T','A1','NONAX     '
      IPOINT=IDHCV+7
      CALL WRIFDH(PDDHCV_TOT(2+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(1,IPOINT),NFLEVG)

      WRITE (CLNOMA,5000) KNUM,'T','A2','NONAX     '
      IPOINT=IDHCV+8
      CALL WRIFDH(PDDHCV_TOT(2+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(1,IPOINT),NFLEVG)
    ENDIF

    IF ( LHDENT ) THEN
      IDHCV=NDHVV+NDHAHKD+NDHAMCD
      WRITE (CLNOMA,5000) KNUM,'T','SS',CLDIVOR
      IPOINT=IDHCV+1
      CALL WRIFDH(PDDHCV_TOT(2+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(1,IPOINT),NFLEVG)

      WRITE (CLNOMA,5000) KNUM,'T','SS','PRECICT   '
      IPOINT=IDHCV+2
      CALL WRIFDH(PDDHCV_TOT(2+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(1,IPOINT),NFLEVG)
    ENDIF

    IF ( LHDHKS ) THEN
      IDHCV=NDHVV+NDHAVD
      WRITE (CLNOMA,5000) KNUM,'F','PP',CLFLUVD
      IPOINT=IDHCV+1
      CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(0,IPOINT),NFLEVG+1)

      WRITE (CLNOMA,5000) KNUM,'F','QV',CLFLUVD
      IPOINT=IDHCV+2
      CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(0,IPOINT),NFLEVG+1)

      WRITE (CLNOMA,5000) KNUM,'F','UU',CLFLUVD
      IPOINT=IDHCV+3
      CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(0,IPOINT),NFLEVG+1)

      WRITE (CLNOMA,5000) KNUM,'F','VV',CLFLUVD
      IPOINT=IDHCV+4
      CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(0,IPOINT),NFLEVG+1)

      WRITE (CLNOMA,5000) KNUM,'F','UU',CLFLUPL
      IPOINT=IDHCV+5
      CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(0,IPOINT),NFLEVG+1)

      WRITE (CLNOMA,5000) KNUM,'F','VV',CLFLUPL
      IPOINT=IDHCV+6
      CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(0,IPOINT),NFLEVG+1)

      WRITE (CLNOMA,5000) KNUM,'F','KK',CLFLUVD
      IPOINT=IDHCV+7
      CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(0,IPOINT),NFLEVG+1)

      WRITE (CLNOMA,5000) KNUM,'F','KK',CLFLUPL
      IPOINT=IDHCV+8
      CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(0,IPOINT),NFLEVG+1)

      WRITE (CLNOMA,5000) KNUM,'F','CT',CLFLUVD
      IPOINT=IDHCV+9
      CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(0,IPOINT),NFLEVG+1)

      WRITE (CLNOMA,5000) KNUM,'F','EP','CONVERSIFL'
      IPOINT=IDHCV+10
      CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(0,IPOINT),NFLEVG+1)

      IF(LHDQLN) THEN
        WRITE (CLNOMA,5000) KNUM,'F','QL',CLFLUVD
        IPOINT=IDHCV+11
        CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
         & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(0,IPOINT),NFLEVG+1)

        WRITE (CLNOMA,5000) KNUM,'F','QN',CLFLUVD
        IPOINT=IDHCV+12
        CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
         & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(0,IPOINT),NFLEVG+1)
      ENDIF
    ENDIF

    IF ( LHDMCI ) THEN
      IDHCV=NDHVV+NDHAVD+NDHBHKD
      WRITE (CLNOMA,5000) KNUM,'F','A1',CLFLUVD
      IPOINT=IDHCV+1
      CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(0,IPOINT),NFLEVG+1)

      WRITE (CLNOMA,5000) KNUM,'F','A2',CLFLUVD
      IPOINT=IDHCV+2
      CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(0,IPOINT),NFLEVG+1)

      WRITE (CLNOMA,5000) KNUM,'F','A3',CLFLUVD
      IPOINT=IDHCV+3
      CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(0,IPOINT),NFLEVG+1)

      WRITE (CLNOMA,5000) KNUM,'F','A1','GRAV      '
      IPOINT=IDHCV+4
      CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(0,IPOINT),NFLEVG+1)

      WRITE (CLNOMA,5000) KNUM,'F','A2','GRAV      '
      IPOINT=IDHCV+5
      CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(0,IPOINT),NFLEVG+1)

      WRITE (CLNOMA,5000) KNUM,'F','A3','GRAV      '
      IPOINT=IDHCV+6
      CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(0,IPOINT),NFLEVG+1)

      WRITE (CLNOMA,5000) KNUM,'F','A1',CLFLUPL
      IPOINT=IDHCV+7
      CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(0,IPOINT),NFLEVG+1)

      WRITE (CLNOMA,5000) KNUM,'F','A2',CLFLUPL
      IPOINT=IDHCV+8
      CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(0,IPOINT),NFLEVG+1)

      WRITE (CLNOMA,5000) KNUM,'F','A3',CLFLUPL
      IPOINT=IDHCV+9
      CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(0,IPOINT),NFLEVG+1)
    ENDIF

    IF ( LHDENT ) THEN
      IDHCV=NDHVV+NDHAVD+NDHBHKD+NDHBMCD
      WRITE (CLNOMA,5000) KNUM,'F','SS',CLFLUVD
      IPOINT=IDHCV+1
      CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(0,IPOINT),NFLEVG+1)

      WRITE (CLNOMA,5000) KNUM,'F','SS','PRECISS   '
      IPOINT=IDHCV+1
      CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(0,IPOINT),NFLEVG+1)
    ENDIF

    !     ------------------------------------------------------------------
    !*    4.- FLUX ET TENDANCES PHYSIQUES
    
    IF ( LHDHKS ) THEN
      IDHCV=NDHVV+NDHFVD
      WRITE (CLNOMA,5000) KNUM,'F','PP','SUMFPL    '
      IPOINT=IDHCV+1
      CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(0,IPOINT),NFLEVG+1)

      WRITE (CLNOMA,5000) KNUM,'F','QV','TUR       '
      IPOINT=IDHCV+2
      CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(0,IPOINT),NFLEVG+1)

      WRITE (CLNOMA,5000) KNUM,'F','QV','TURCONV   '
      IPOINT=IDHCV+3
      CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(0,IPOINT),NFLEVG+1)

      WRITE (CLNOMA,5000) KNUM,'F','QT','PRECISTL  '
      IPOINT=IDHCV+4
      CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(0,IPOINT),NFLEVG+1)

      WRITE (CLNOMA,5000) KNUM,'F','QT','PRECISTN  '
      IPOINT=IDHCV+5
      CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(0,IPOINT),NFLEVG+1)

      WRITE (CLNOMA,5000) KNUM,'F','QT','PRECICOL  '
      IPOINT=IDHCV+6
      CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(0,IPOINT),NFLEVG+1)

      WRITE (CLNOMA,5000) KNUM,'F','QT','PRECICON  '
      IPOINT=IDHCV+7
      CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(0,IPOINT),NFLEVG+1)

      WRITE (CLNOMA,5000) KNUM,'F','QV','TURQNEGAT '
      IPOINT=IDHCV+8
      CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(0,IPOINT),NFLEVG+1)

      WRITE (CLNOMA,5000) KNUM,'F','UU','TUR       '
      IPOINT=IDHCV+9
      CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(0,IPOINT),NFLEVG+1)

      WRITE (CLNOMA,5000) KNUM,'F','VV','TUR       '
      IPOINT=IDHCV+10
      CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(0,IPOINT),NFLEVG+1)

      WRITE (CLNOMA,5000) KNUM,'F','UU','TURCONV   '
      IPOINT=IDHCV+11
      CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(0,IPOINT),NFLEVG+1)

      WRITE (CLNOMA,5000) KNUM,'F','VV','TURCONV   '
      IPOINT=IDHCV+12
      CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(0,IPOINT),NFLEVG+1)

      WRITE (CLNOMA,5000) KNUM,'F','UU','ONDEGREL  '
      IPOINT=IDHCV+13
      CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(0,IPOINT),NFLEVG+1)

      WRITE (CLNOMA,5000) KNUM,'F','VV','ONDEGREL  '
      IPOINT=IDHCV+14
      CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(0,IPOINT),NFLEVG+1)

      WRITE (CLNOMA,5000) KNUM,'F','CT','TUR       '
      IPOINT=IDHCV+15
      CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(0,IPOINT),NFLEVG+1)

      WRITE (CLNOMA,5000) KNUM,'F','CT','TURCONV   '
      IPOINT=IDHCV+16
      CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(0,IPOINT),NFLEVG+1)

      WRITE (CLNOMA,5000) KNUM,'F','CT','RAYSOL1   '
      IPOINT=IDHCV+17
      CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(0,IPOINT),NFLEVG+1)

      WRITE (CLNOMA,5000) KNUM,'F','CT','RAYTER1   '
      IPOINT=IDHCV+18
      CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(0,IPOINT),NFLEVG+1)

      WRITE (CLNOMA,5000) KNUM,'F','CT','PRECISTL  '
      IPOINT=IDHCV+19
      CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(0,IPOINT),NFLEVG+1)

      WRITE (CLNOMA,5000) KNUM,'F','CT','PRECISTN  '
      IPOINT=IDHCV+20
      CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(0,IPOINT),NFLEVG+1)

      WRITE (CLNOMA,5000) KNUM,'F','CT','PRECICOL  '
      IPOINT=IDHCV+21
      CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(0,IPOINT),NFLEVG+1)

      WRITE (CLNOMA,5000) KNUM,'F','CT','PRECICON  '
      IPOINT=IDHCV+22
      CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(0,IPOINT),NFLEVG+1)

      WRITE (CLNOMA,5000) KNUM,'F','CT','PRECCSCOL '
      IPOINT=IDHCV+23
      CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(0,IPOINT),NFLEVG+1)

      WRITE (CLNOMA,5000) KNUM,'F','CT','PRECCSCON '
      IPOINT=IDHCV+24
      CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(0,IPOINT),NFLEVG+1)

      WRITE (CLNOMA,5000) KNUM,'F','CT','PRECCSSTL '
      IPOINT=IDHCV+25
      CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(0,IPOINT),NFLEVG+1)

      WRITE (CLNOMA,5000) KNUM,'F','CT','PRECCSSTN '
      IPOINT=IDHCV+26
      CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(0,IPOINT),NFLEVG+1)

      IF(LHDQLN) THEN

        WRITE (CLNOMA,5000) KNUM,'F','QL','TUR       '
        IPOINT=IDHCV+27
        CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
         & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(0,IPOINT),NFLEVG+1)

        WRITE (CLNOMA,5000) KNUM,'F','QN','TUR       '
        IPOINT=IDHCV+28
        CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
         & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(0,IPOINT),NFLEVG+1)

        WRITE (CLNOMA,5000) KNUM,'F','QL','TURCONV   '
        IPOINT=IDHCV+29
        CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
         & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(0,IPOINT),NFLEVG+1)

        WRITE (CLNOMA,5000) KNUM,'F','QN','TURCONV   '
        IPOINT=IDHCV+30
        CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
         & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(0,IPOINT),NFLEVG+1)

        WRITE (CLNOMA,5000) KNUM,'F','QL','TURQNEGAT '
        IPOINT=IDHCV+31
        CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
         & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(0,IPOINT),NFLEVG+1)

        WRITE (CLNOMA,5000) KNUM,'F','QN','TURQNEGAT '
        IPOINT=IDHCV+32
        CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
         & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(0,IPOINT),NFLEVG+1)

        WRITE (CLNOMA,5000) KNUM,'F','QT','CONDECOL  '
        IPOINT=IDHCV+33
        CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
         & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(0,IPOINT),NFLEVG+1)

        WRITE (CLNOMA,5000) KNUM,'F','QT','CONDECON  '
        IPOINT=IDHCV+34
        CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
         & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(0,IPOINT),NFLEVG+1)

        WRITE (CLNOMA,5000) KNUM,'F','QT','CONDESTL  '
        IPOINT=IDHCV+35
        CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
         & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(0,IPOINT),NFLEVG+1)

        WRITE (CLNOMA,5000) KNUM,'F','QT','CONDESTN  '
        IPOINT=IDHCV+36
        CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
         & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(0,IPOINT),NFLEVG+1)

        IF (LCONDWT.AND.LPROCLD) THEN
          WRITE (CLNOMA,5000) KNUM,'F','QV','EVPL      '
          IPOINT=IDHCV+37
          CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
           & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(0,IPOINT),NFLEVG+1)

          WRITE (CLNOMA,5000) KNUM,'F','QV','EVPN      '
          IPOINT=IDHCV+38
          CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
           & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(0,IPOINT),NFLEVG+1)

          WRITE (CLNOMA,5000) KNUM,'F','QL','FPL       '
          IPOINT=IDHCV+39
          CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
           & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(0,IPOINT),NFLEVG+1)

          WRITE (CLNOMA,5000) KNUM,'F','QN','FPN       '
          IPOINT=IDHCV+40
          CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
           & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(0,IPOINT),NFLEVG+1)
        ENDIF

      ENDIF
    ENDIF

    IF ( LHDMCI ) THEN
      IDHCV=NDHVV+NDHFVD+NDHAHKP
      WRITE (CLNOMA,5000) KNUM,'F','A1','TUR       '
      IPOINT=IDHCV+1
      CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(0,IPOINT),NFLEVG+1)

      WRITE (CLNOMA,5000) KNUM,'F','A2','TUR       '
      IPOINT=IDHCV+2
      CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(0,IPOINT),NFLEVG+1)

      WRITE (CLNOMA,5000) KNUM,'F','A3','TUR       '
      IPOINT=IDHCV+3
      CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(0,IPOINT),NFLEVG+1)

      WRITE (CLNOMA,5000) KNUM,'F','A1','TURCONV   '
      IPOINT=IDHCV+4
      CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(0,IPOINT),NFLEVG+1)

      WRITE (CLNOMA,5000) KNUM,'F','A2','TURCONV   '
      IPOINT=IDHCV+5
      CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(0,IPOINT),NFLEVG+1)

      WRITE (CLNOMA,5000) KNUM,'F','A3','TURCONV   '
      IPOINT=IDHCV+6
      CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(0,IPOINT),NFLEVG+1)

      WRITE (CLNOMA,5000) KNUM,'F','A1','ONDEGREL  '
      IPOINT=IDHCV+7
      CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(0,IPOINT),NFLEVG+1)

      WRITE (CLNOMA,5000) KNUM,'F','A2','ONDEGREL  '
      IPOINT=IDHCV+8
      CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(0,IPOINT),NFLEVG+1)

      WRITE (CLNOMA,5000) KNUM,'F','A3','ONDEGREL  '
      IPOINT=IDHCV+9
      CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(0,IPOINT),NFLEVG+1)
    ENDIF

    IF ( LHDHKS ) THEN
      IDHCV=NDHVV+NDHFVD+NDHAVP
      WRITE (CLNOMA,5000) KNUM,'T','KK','DISSIPTUR '
      IPOINT=IDHCV+1
      CALL WRIFDH(PDDHCV_TOT(2+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(1,IPOINT),NFLEVG)

      WRITE (CLNOMA,5000) KNUM,'T','KK','DISSIPCONV'
      IPOINT=IDHCV+2
      CALL WRIFDH(PDDHCV_TOT(2+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(1,IPOINT),NFLEVG)

      WRITE (CLNOMA,5000) KNUM,'T','KK','DISSIPGREL'
      IPOINT=IDHCV+3
      CALL WRIFDH(PDDHCV_TOT(2+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(1,IPOINT),NFLEVG)

      !IF LHDADD: IF
      IF(LHDADD) THEN
        WRITE (CLNOMA,5000) KNUM,'T','QV','FORMPSTL  '
        IPOINT=IDHCV+4
        CALL WRIFDH(PDDHCV_TOT(2+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
         & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(1,IPOINT),NFLEVG)

        WRITE (CLNOMA,5000) KNUM,'T','CT','FORMPSTL  '
        IPOINT=IDHCV+5
        CALL WRIFDH(PDDHCV_TOT(2+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
         & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(1,IPOINT),NFLEVG)

        WRITE (CLNOMA,5000) KNUM,'T','QV','EVAPPSTL  '
        IPOINT=IDHCV+6
        CALL WRIFDH(PDDHCV_TOT(2+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
         & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(1,IPOINT),NFLEVG)

        WRITE (CLNOMA,5000) KNUM,'T','CT','EVAPPSTL  '
        IPOINT=IDHCV+7
        CALL WRIFDH(PDDHCV_TOT(2+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
         & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(1,IPOINT),NFLEVG)

        WRITE (CLNOMA,5000) KNUM,'T','QV','FORMPSTN  '
        IPOINT=IDHCV+8
        CALL WRIFDH(PDDHCV_TOT(2+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
         & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(1,IPOINT),NFLEVG)

        WRITE (CLNOMA,5000) KNUM,'T','CT','FORMPSTN  '
        IPOINT=IDHCV+9
        CALL WRIFDH(PDDHCV_TOT(2+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
         & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(1,IPOINT),NFLEVG)

        WRITE (CLNOMA,5000) KNUM,'T','QV','EVAPPSTN  '
        IPOINT=IDHCV+10
        CALL WRIFDH(PDDHCV_TOT(2+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
         & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(1,IPOINT),NFLEVG)

        WRITE (CLNOMA,5000) KNUM,'T','CT','EVAPPSTN  '
        IPOINT=IDHCV+11
        CALL WRIFDH(PDDHCV_TOT(2+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
         & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(1,IPOINT),NFLEVG)

        WRITE (CLNOMA,5000) KNUM,'T','QV','FONTPST   '
        IPOINT=IDHCV+12
        CALL WRIFDH(PDDHCV_TOT(2+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
         & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(1,IPOINT),NFLEVG)

        WRITE (CLNOMA,5000) KNUM,'T','CT','FONTPST   '
        IPOINT=IDHCV+13
        CALL WRIFDH(PDDHCV_TOT(2+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
         & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(1,IPOINT),NFLEVG)

        WRITE (CLNOMA,5000) KNUM,'T','QV','FORMPCOL  '
        IPOINT=IDHCV+14
        CALL WRIFDH(PDDHCV_TOT(2+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
         & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(1,IPOINT),NFLEVG)

        WRITE (CLNOMA,5000) KNUM,'T','CT','FORMPCOL  '
        IPOINT=IDHCV+15
        CALL WRIFDH(PDDHCV_TOT(2+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
         & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(1,IPOINT),NFLEVG)

        WRITE (CLNOMA,5000) KNUM,'T','QV','EVAPPCOL  '
        IPOINT=IDHCV+16
        CALL WRIFDH(PDDHCV_TOT(2+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
         & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(1,IPOINT),NFLEVG)

        WRITE (CLNOMA,5000) KNUM,'T','CT','EVAPPCOL  '
        IPOINT=IDHCV+17
        CALL WRIFDH(PDDHCV_TOT(2+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
         & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(1,IPOINT),NFLEVG)

        WRITE (CLNOMA,5000) KNUM,'T','QV','FORMPCON  '
        IPOINT=IDHCV+18
        CALL WRIFDH(PDDHCV_TOT(2+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
         & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(1,IPOINT),NFLEVG)

        WRITE (CLNOMA,5000) KNUM,'T','CT','FORMPCON  '
        IPOINT=IDHCV+19
        CALL WRIFDH(PDDHCV_TOT(2+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
         & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(1,IPOINT),NFLEVG)

        WRITE (CLNOMA,5000) KNUM,'T','QV','EVAPPCON  '
        IPOINT=IDHCV+20
        CALL WRIFDH(PDDHCV_TOT(2+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
         & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(1,IPOINT),NFLEVG)

        WRITE (CLNOMA,5000) KNUM,'T','CT','EVAPPCON  '
        IPOINT=IDHCV+21
        CALL WRIFDH(PDDHCV_TOT(2+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
         & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(1,IPOINT),NFLEVG)

        WRITE (CLNOMA,5000) KNUM,'T','QV','FONTPCO   '
        IPOINT=IDHCV+22
        CALL WRIFDH(PDDHCV_TOT(2+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
         & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(1,IPOINT),NFLEVG)

        WRITE (CLNOMA,5000) KNUM,'T','CT','FONTPCO   '
        IPOINT=IDHCV+23
        CALL WRIFDH(PDDHCV_TOT(2+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
         & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(1,IPOINT),NFLEVG)
      !IF LHDADD: ENDIF
      ENDIF

    ENDIF

    IF ( LHDENT ) THEN
      IDHCV=NDHVV+NDHFVD+NDHAVP+NDHBHKP+NDHBMCP
      WRITE (CLNOMA,5000) KNUM,'T','SS','DISSIPTUR '
      IPOINT=IDHCV+1
      CALL WRIFDH(PDDHCV_TOT(2+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(1,IPOINT),NFLEVG)

      WRITE (CLNOMA,5000) KNUM,'T','SS','DISSIPCONV'
      IPOINT=IDHCV+2
      CALL WRIFDH(PDDHCV_TOT(2+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(1,IPOINT),NFLEVG)

      WRITE (CLNOMA,5000) KNUM,'T','SS','DISSIPGREL'
      IPOINT=IDHCV+3
      CALL WRIFDH(PDDHCV_TOT(2+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(1,IPOINT),NFLEVG)

      WRITE (CLNOMA,5000) KNUM,'T','SS','TURQVTOT  '
      IPOINT=IDHCV+4
      CALL WRIFDH(PDDHCV_TOT(2+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(1,IPOINT),NFLEVG)

      WRITE (CLNOMA,5000) KNUM,'T','SS','RAY1      '
      IPOINT=IDHCV+5
      CALL WRIFDH(PDDHCV_TOT(2+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(1,IPOINT),NFLEVG)

      WRITE (CLNOMA,5000) KNUM,'T','SS','TURCTTOT  '
      IPOINT=IDHCV+6
      CALL WRIFDH(PDDHCV_TOT(2+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
       & (NFLEVG+1)*KDIMDOM,NPODDH,CLNOMA,PDDHCV(1,IPOINT),NFLEVG)
    ENDIF

    !     ------------------------------------------------------------------
    !*    5.- SOL

    IDHCS = 0
    INBCUMS = NDHFSD + NDHFSP

    IF ( LHDHKS .AND. ((NDHVS /= 0) .OR. (NDHCS /= 0)) ) THEN

      IF(LECMWF) THEN

        ! Write initial values of all standard variables

        ! Tiles

        DO JVAR=1,NDHVTLS
          WRITE (CLNOMA,'(I3.3,A)') KNUM,TRIM(CADHTLS(JVAR))//'0'
          CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
           & NFLEVG*KDIMDOM,NPODDH,CLNOMA,PDDHCS(IDHCS+1),NTILES)
          IDHCS=IDHCS+NTILES
        ENDDO

        IDHCS=NDHVTLS*NTILES

        ! Snow energy budget

        DO JVAR=1,NDHVTSS
          WRITE (CLNOMA,'(I3.3,A)') KNUM,TRIM(CADHTSS(JVAR))//'0'
          CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
           & NFLEVG*KDIMDOM,NPODDH,CLNOMA,PDDHCS(IDHCS+1),NCSNEC)
          IDHCS=IDHCS+NCSNEC
        ENDDO

        IDHCS=NDHVTLS*NTILES+NDHVTSS*NCSNEC

        ! Soil energy budget

        DO JVAR=1,NDHVTTS
          WRITE (CLNOMA,'(I3.3,A)') KNUM,TRIM(CADHTTS(JVAR))//'0'
          CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
           & NFLEVG*KDIMDOM,NPODDH,CLNOMA,PDDHCS(IDHCS+1),YSP_SBD%NLEVS)
          IDHCS=IDHCS+YSP_SBD%NLEVS
        ENDDO

        IDHCS=NDHVTLS*NTILES+NDHVTSS*NCSNEC+NDHVTTS*YSP_SBD%NLEVS

        ! Sea-ice energy budget

        DO JVAR=1,NDHVTIS
          WRITE (CLNOMA,'(I3.3,A)') KNUM,TRIM(CADHTIS(JVAR))//'0'
          CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
           & NFLEVG*KDIMDOM,NPODDH,CLNOMA,PDDHCS(IDHCS+1),NCSI)
          IDHCS=IDHCS+NCSI
        ENDDO

        IDHCS=NDHVTLS*NTILES+NDHVTSS*NCSNEC+NDHVTTS*YSP_SBD%NLEVS+&
         & NDHVTIS*NCSI

        ! Snow water budget

        DO JVAR=1,NDHVSSS
          WRITE (CLNOMA,'(I3.3,A)') KNUM,TRIM(CADHSSS(JVAR))//'0'
          CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
           & NFLEVG*KDIMDOM,NPODDH,CLNOMA,PDDHCS(IDHCS+1),NCSNEC)
          IDHCS=IDHCS+NCSNEC
        ENDDO

        IDHCS=NDHVTLS*NTILES+NDHVTSS*NCSNEC+NDHVTTS*YSP_SBD%NLEVS+&
         & NDHVTIS*NCSI+NDHVSSS*NCSNEC

        ! Interception layer water budget

        DO JVAR=1,NDHVIIS
          WRITE (CLNOMA,'(I3.3,A)') KNUM,TRIM(CADHIIS(JVAR))//'0'
          CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
           & NFLEVG*KDIMDOM,NPODDH,CLNOMA,PDDHCS(IDHCS+1),1)
          IDHCS=IDHCS+1
        ENDDO

        IDHCS=NDHVTLS*NTILES+NDHVTSS*NCSNEC+NDHVTTS*YSP_SBD%NLEVS+&
         & NDHVTIS*NCSI+NDHVSSS*NCSNEC+NDHVIIS

        ! Soil water budget

        DO JVAR=1,NDHVWLS
          WRITE (CLNOMA,'(I3.3,A)') KNUM,TRIM(CADHWLS(JVAR))//'0'
          CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
           & NFLEVG*KDIMDOM,NPODDH,CLNOMA,PDDHCS(IDHCS+1),YSP_SBD%NLEVS)
          IDHCS=IDHCS+YSP_SBD%NLEVS
        ENDDO

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

        ! Write current values of all standard variables

        ! set pointer

        IDHCS = NDHCS

        ! Tiles

        DO JVAR=1,NDHVTLS
          WRITE (CLNOMA,'(I3.3,A)') KNUM,TRIM(CADHTLS(JVAR))//'1'
          CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
           & NFLEVG*KDIMDOM,NPODDH,CLNOMA,PDDHCS(IDHCS+1),NTILES)
          IDHCS=IDHCS+NTILES
        ENDDO

        IDHCS=NDHCS+NDHVTLS*NTILES

        ! Snow energy budget

        DO JVAR=1,NDHVTSS
          WRITE (CLNOMA,'(I3.3,A)') KNUM,TRIM(CADHTSS(JVAR))//'1'
          CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
           & NFLEVG*KDIMDOM,NPODDH,CLNOMA,PDDHCS(IDHCS+1),NCSNEC)
          IDHCS=IDHCS+NCSNEC
        ENDDO

        IDHCS=NDHCS+NDHVTLS*NTILES+NDHVTSS*NCSNEC

        ! Soil energy budget

        DO JVAR=1,NDHVTTS
          WRITE (CLNOMA,'(I3.3,A)') KNUM,TRIM(CADHTTS(JVAR))//'1'
          CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
           & NFLEVG*KDIMDOM,NPODDH,CLNOMA,PDDHCS(IDHCS+1),YSP_SBD%NLEVS)
          IDHCS=IDHCS+YSP_SBD%NLEVS
        ENDDO

        IDHCS=NDHCS+NDHVTLS*NTILES+NDHVTSS*NCSNEC+NDHVTTS*YSP_SBD%NLEVS

        ! Sea-ice energy budget

        DO JVAR=1,NDHVTIS
          WRITE (CLNOMA,'(I3.3,A)') KNUM,TRIM(CADHTIS(JVAR))//'1'
          CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
           & NFLEVG*KDIMDOM,NPODDH,CLNOMA,PDDHCS(IDHCS+1),NCSI)
          IDHCS=IDHCS+NCSI
        ENDDO

        IDHCS=NDHCS+NDHVTLS*NTILES+NDHVTSS*NCSNEC+NDHVTTS*YSP_SBD%NLEVS+&
         & NDHVTIS*NCSI

        ! Snow water budget

        DO JVAR=1,NDHVSSS
          WRITE (CLNOMA,'(I3.3,A)') KNUM,TRIM(CADHSSS(JVAR))//'1'
          CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
           & NFLEVG*KDIMDOM,NPODDH,CLNOMA,PDDHCS(IDHCS+1),NCSNEC)
          IDHCS=IDHCS+NCSNEC
        ENDDO

        IDHCS=NDHCS+NDHVTLS*NTILES+NDHVTSS*NCSNEC+NDHVTTS*YSP_SBD%NLEVS+&
         & NDHVTIS*NCSI+NDHVSSS*NCSNEC

        ! Interception layer water budget

        DO JVAR=1,NDHVIIS
          WRITE (CLNOMA,'(I3.3,A)') KNUM,TRIM(CADHIIS(JVAR))//'1'
          CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
           & NFLEVG*KDIMDOM,NPODDH,CLNOMA,PDDHCS(IDHCS+1),1)
          IDHCS=IDHCS+1
        ENDDO

        IDHCS=NDHCS+NDHVTLS*NTILES+NDHVTSS*NCSNEC+NDHVTTS*YSP_SBD%NLEVS+&
         & NDHVTIS*NCSI+NDHVSSS*NCSNEC+NDHVIIS

        ! Soil water budget

        DO JVAR=1,NDHVWLS
          WRITE (CLNOMA,'(I3.3,A)') KNUM,TRIM(CADHWLS(JVAR))//'1'
          CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
           & NFLEVG*KDIMDOM,NPODDH,CLNOMA,PDDHCS(IDHCS+1),YSP_SBD%NLEVS)
          IDHCS=IDHCS+YSP_SBD%NLEVS
        ENDDO

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

        ! Write free-style variables

        IF (NDHVFS /= 0) THEN

          ! Set pointer

          IDHCS = NDHVS

          ! Write

          DO JVAR=1,NDHVFS
            WRITE (CLNOMA,'(I3.3,A)') KNUM,TRIM(CADHFSS(JVAR))
            CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
             & NFLEVG*KDIMDOM,NPODDH,CLNOMA,PDDHCS(IDHCS+1),1)
            IDHCS=IDHCS+1
          ENDDO

        ENDIF
        !-------------------------------------------------------------------------

        ! Write standard fluxes

        ! Set pointer

        IDHCS = NDHVS + NDHVFS

        ! Tiles

        DO JFLX=NDHVTLS+1,NDHVTLS+NDHFTLS
          WRITE (CLNOMA,'(I3.3,A)') KNUM,TRIM(CADHTLS(JFLX))
          CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
           & NFLEVG*KDIMDOM,NPODDH,CLNOMA,PDDHCS(IDHCS+1),NTILES)
          IDHCS=IDHCS+NTILES
        ENDDO

        IDHCS=NDHVS+NDHVFS+NDHFTLS*NTILES

        ! Snow energy budget

        DO JFLX=NDHVTSS+1,NDHVTSS+NDHFTSS
          WRITE (CLNOMA,'(I3.3,A)') KNUM,TRIM(CADHTSS(JFLX))
          CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
           & NFLEVG*KDIMDOM,NPODDH,CLNOMA,PDDHCS(IDHCS+1),NCSNEC)
          IDHCS=IDHCS+NCSNEC
        ENDDO

        IDHCS=NDHVS+NDHVFS+NDHFTLS*NTILES+NDHFTSS*NCSNEC

        ! Soil energy budget

        DO JFLX=NDHVTTS+1,NDHVTTS+NDHFTTS
          WRITE (CLNOMA,'(I3.3,A)') KNUM,TRIM(CADHTTS(JFLX))
          CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
           & NFLEVG*KDIMDOM,NPODDH,CLNOMA,PDDHCS(IDHCS+1),YSP_SBD%NLEVS)
          IDHCS=IDHCS+YSP_SBD%NLEVS
        ENDDO

        IDHCS=NDHVS+NDHVFS+NDHFTLS*NTILES+NDHFTSS*NCSNEC+NDHFTTS*YSP_SBD%NLEVS

        ! Sea-ice energy budget

        DO JFLX=NDHVTIS+1,NDHVTIS+NDHFTIS
          WRITE (CLNOMA,'(I3.3,A)') KNUM,TRIM(CADHTIS(JFLX))
          CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
           & NFLEVG*KDIMDOM,NPODDH,CLNOMA,PDDHCS(IDHCS+1),NCSI)
          IDHCS=IDHCS+NCSI
        ENDDO

        IDHCS=NDHVS+NDHVFS+NDHFTLS*NTILES+NDHFTSS*NCSNEC+NDHFTTS*YSP_SBD%NLEVS+&
         & NDHFTIS*NCSI

        ! Snow water budget

        DO JFLX=NDHVSSS+1,NDHVSSS+NDHFSSS
          WRITE (CLNOMA,'(I3.3,A)') KNUM,TRIM(CADHSSS(JFLX))
          CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
           & NFLEVG*KDIMDOM,NPODDH,CLNOMA,PDDHCS(IDHCS+1),NCSNEC)
          IDHCS=IDHCS+NCSNEC
        ENDDO

        IDHCS=NDHVS+NDHVFS+NDHFTLS*NTILES+NDHFTSS*NCSNEC+NDHFTTS*YSP_SBD%NLEVS+&
         & NDHFTIS*NCSI+NDHFSSS*NCSNEC

        ! Interception layer water budget

        DO JFLX=NDHVIIS+1,NDHVIIS+NDHFIIS
          WRITE (CLNOMA,'(I3.3,A)') KNUM,TRIM(CADHIIS(JFLX))
          CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
           & NFLEVG*KDIMDOM,NPODDH,CLNOMA,PDDHCS(IDHCS+1),1)
          IDHCS=IDHCS+1
        ENDDO

        IDHCS=NDHVS+NDHVFS+NDHFTLS*NTILES+NDHFTSS*NCSNEC+NDHFTTS*YSP_SBD%NLEVS+&
         & NDHFTIS*NCSI+NDHFSSS*NCSNEC+NDHFIIS

        ! Soil water budget

        DO JFLX=NDHVWLS+1,NDHVWLS+NDHFWLS
          WRITE (CLNOMA,'(I3.3,A)') KNUM,TRIM(CADHWLS(JFLX))
          CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
           & NFLEVG*KDIMDOM,NPODDH,CLNOMA,PDDHCS(IDHCS+1),YSP_SBD%NLEVS)
          IDHCS=IDHCS+YSP_SBD%NLEVS
        ENDDO

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

        ! Write free-style fluxes

        IF (NDHFFS /= 0) THEN

          ! Set pointer

          IDHCS = NDHVS + NDHVFS + NDHFSD + NDHFSP

          ! Write

          DO JFLX=NDHVFS+1,NDHVFS+NDHFFS
            WRITE (CLNOMA,'(I3.3,A)') KNUM,TRIM(CADHFSS(JFLX))
            CALL WRIFDH(PDDHCV_TOT(1+(NFLEVG+1)*KDIMDOM*(IPOINT-1)), &
             & NFLEVG*KDIMDOM,NPODDH,CLNOMA,PDDHCS(IDHCS+1),1)
            IDHCS=IDHCS+1
          ENDDO

        ENDIF

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

      ELSE ! Case .NOT.LECMWF

        IDHCS = 0

        !       ENSEMBLE DES VARIABLES INITIALES
        DO JVAR=1,NDHVS
          WRITE (CLNOMA,FMT='(I3.3,A,I2.2,A)') KNUM,'S',JVAR,'_0'
          IPOINT=IDHCS+JVAR
          CALL WRIFDH(PDDHCS_TOT(1+KDIMDOM*(IPOINT-1)), &
           & KDIMDOM,NPODDH,CLNOMA,PDDHCS(IPOINT),NDHVS)
        ENDDO

        !       ENSEMBLE DES VARIABLES COURANTES
        IDHCS = NDHCS
        DO JVAR=1,NDHVS
          WRITE (CLNOMA,FMT='(I3.3,A,I2.2,A)') KNUM,'S',JVAR,'_1'
          IPOINT=IDHCS+JVAR
          CALL WRIFDH(PDDHCS_TOT(1+KDIMDOM*(IPOINT-1)), &
           & KDIMDOM,NPODDH,CLNOMA,PDDHCS(IPOINT),NDHVS)
        ENDDO

        !       ENSEMBLE DES CUMULS
        IDHCS = NDHVS + NDHVFS
        DO JVAR=1,INBCUMS
          WRITE (CLNOMA,FMT='(I3.3,A,I2.2)') KNUM,'G',JVAR
          IPOINT=IDHCS+JVAR
          CALL WRIFDH(PDDHCS_TOT(1+KDIMDOM*(IPOINT-1)), &
           & KDIMDOM,NPODDH,CLNOMA,PDDHCS(IPOINT),INBCUMS)
        ENDDO

        !       Set of free-style surface variables
        IF (NDHVFS /= 0) THEN
          IDHCS = NDHVS
          DO JVAR=1,NDHVFS
            WRITE (CLNOMA,FMT='(I3.3,A,I2.2)') KNUM,'SVGFS',JVAR
            IPOINT=IDHCS+JVAR
            CALL WRIFDH(PDDHCS_TOT(1+KDIMDOM*(IPOINT-1)), &
             & KDIMDOM,NPODDH,CLNOMA,PDDHCS(IPOINT),NDHVFS)
          ENDDO
        ENDIF

        !       Set of free-style surface fluxes
        IF (NDHFFS /= 0) THEN
          IDHCS = NDHVS + NDHVFS + NDHFSD + NDHFSP
          DO JVAR=1,NDHFFS
            WRITE (CLNOMA,FMT='(I3.3,A,I2.2)') KNUM,'SFGFS',JVAR
            IPOINT=IDHCS+JVAR
            CALL WRIFDH(PDDHCS_TOT(1+KDIMDOM*(IPOINT-1)), &
             & KDIMDOM,NPODDH,CLNOMA,PDDHCS(IPOINT),NDHFFS)
          ENDDO
        ENDIF

      ENDIF ! LECMWF

    ENDIF ! ( LHDHKS .AND. ((NDHVS /= 0) .OR. (NDHCS /= 0)) )

    IF ( LHDLIST ) THEN
      WRITE (NULOUT,*) ' DDH * PPFIDH FINI IDHCV=',IDHCV,&
       & ' IDHCS = ',IDHCS,' INBCUMS = ',INBCUMS
    ENDIF

  ENDIF ! (.NOT.LHDLFA .OR. KNUM == KDIMDOM)

ENDIF !LFLEXDIA

4000 FORMAT (I3.3,A3,A9)
5000 FORMAT (I3.3,A1,A2,A10)
6000 FORMAT (I3.3,A11,A2)

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