SUBROUTINE SUFPC(CDPATH)

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

USE YOMLUN   , ONLY : NULOUT   ,NULNAM   ,NULERR   ,NINISH
USE PARFPOS  , ONLY : JPOSDOM  ,JPOSLEN  ,JPOS3DF  ,JPOS2DF  ,JPOSPHY  , &
 & JPOSCFU  ,JPOSXFU  ,JPOS3P   ,JPOS3H   ,JPOS3TH  ,JPOS3PV  , &
 & JPOS3S   ,JPOSDYN  ,JPOSSGP  
USE YOMFPC   , ONLY : CFPDIR   ,CFPFMT   ,CFPIDEN  ,CFPDOM   ,&
 & CFP3DF   ,CFP2DF   ,CFPPHY   ,CFPCFU   ,CFPXFU   ,&
 & CFP3DFS  ,CFP3DFP  ,CFP3DFT  ,CFP3DFH  ,CFP3DFV  ,&
 & C1FP3DF  ,C1FP2DF  ,C1FPPHY  ,C1FPCFU  ,C1FPXFU  ,&
 & C1FP3DFS ,C1FP3DFP ,C1FP3DFT ,C1FP3DFH ,C1FP3DFV ,&
 & C1FPDOM  ,MFP2DF   ,MFPPHY   ,NFPXLEV  ,NFPDPHY  ,&
 & MFP3DFS  ,MFP3DFP  ,MFP3DFH  ,MFP3DFT  ,MFP3DFV  ,&
 & RFP3P    ,RFP3H    ,RFP3TH   ,RFP3PV   ,&
 & NRFP3S   ,NFPDOM   ,NFP3DF   ,NFP2DF   ,NFPPHY   ,&
 & NFP3DFS  ,NFP3DFP  ,NFP3DFH  ,NFP3DFT  ,NFP3DFV  ,&
 & NFPCFU   ,NFPXFU   ,NFP3P    ,NFP3H    ,NFP3TH   ,&
 & NFP3PV   ,NFP3S    ,NFPGRIB  ,NFPCLI   ,NFPLNPR  ,&
 & MFP3DYN  ,MFP2DYN  ,FPBL     ,LFPLOSP  ,NFPMASK  ,&
 & RFPCORR  ,RFPVCAP  ,LFITP    ,&
 & LFITT    ,LFITV    ,LFPQ     ,LPUTZS   ,&
 & LFPNHPD  ,LFPNHVD  ,LFPNHVW  ,RFPCSAB  ,RFPCD2   ,&
 & LFPMOIS  ,LMOCONVAR ,RENTRA   ,&
 & NFPINCR  ,NFPCAPE  ,LTRACEFP ,LFPCNT   ,LASQ     ,&
 & NFPINDYN ,NFPINPHY ,LFPRH100 ,NFPLAKE  ,NFPSURFEX
USE YOMAFN   , ONLY : GFP_PHYDS ,TFP_FIS  ,GFP_GFIS ,GFP_ST   ,GFP_RDST   , &
 & GFP_STL1   ,GFP_SSW   ,GFP_SWL1 ,GFP_CLSS ,GFP_CCSF ,GFP_CTO3   , &
 & GFP_CLSG   ,GFP_CCSG  ,GFP_CLSH   ,GFP_CCSH  , &
 & GFP_CIRU   ,GFP_CETP  ,GFP_CTP  ,GFP_X10U ,GFP_X10V ,GFP_X2T    , &
 & GFP_X2SH   ,GFP_X2RH  ,GFP_XX2T ,GFP_XN2T ,GFP_XLSS ,GFP_XCSF   , &
 & GFP_XLSG   ,GFP_XCSG  ,GFP_XLSH   ,GFP_XCSH  ,&
 & GFP_XX2HU  ,GFP_XN2HU ,TFP_PD   ,TFP_VD   ,TFP_VW   ,GFP_IVEG   , &
 & GFP_RSMIN  ,GFP_ARG   ,GFP_SAB  ,GFP_D2   ,GFP_LAI  ,TFP_DYNDS  
USE YOMPHY   , ONLY : LMPHYS   ,LNEIGE   ,LHMTO    ,LOZONE   ,LSOLV
USE YOEPHY   , ONLY : LEPHYS
USE YOMCST   , ONLY : RG
USE YOMCT0   , ONLY : CNPPATH  ,CFDIRLST ,LELAM    ,LFPOS    ,&
 & LARPEGEF ,CNMEXP   ,LNHDYN   ,N3DINI, LFPSPEC  ,NSTOP ,LWROUTLAST
USE YOMCT0B  , ONLY : LECMWF
USE YOMCT3   , ONLY : NSTEP
USE YOMARG   , ONLY : NUFLEV
USE YOMDIM   , ONLY : NFLEVG
USE YOMFPCT0 , ONLY : NFPCT0
USE YOMFA    , ONLY : NVGRIB
USE YOM_YGFL , ONLY : YO3
USE YOMARPHY , ONLY : LMSE

!**** *SUFPC*  - INITIALIZE FULL POST PROCESSING (scientif. and techn. options)

!     PURPOSE.
!     --------
!        SETS DEFAULT VALUES, THEN READS NAMELIST NAMFPC AND CHECKS IT.

!**   INTERFACE.
!     ----------
!       *CALL* *SUFPC(CDPATH)

!        EXPLICIT ARGUMENTS     CDPATH - CHARACTER VARIABLE
!        --------------------   CONTAINING PATH NAME OF NAMELIST FILE
!                               IF CDPATH=' ', FILE NULNAM IS READ

!        IMPLICIT ARGUMENTS
!        --------------------
!        PARDIM
!        PARFPOS
!        YOMFPC
!        NAMFPC

!     METHOD.
!     -------
!        SEE DOCUMENTATION

!     EXTERNALS.
!     ----------

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

!     AUTHOR.
!     -------
!        RYAD EL KHATIB *METEO-FRANCE*

!     MODIFICATIONS.
!     --------------
!        ORIGINAL : 94-04-08
!       Nils Wedi : 95-12-10  LECMWF options added
!      G. Radnoti : 95-01-19  no gaussian output grid for aladin
!     R. ElKhatib : 95-11-08  initialisation of NFPXFLD moved to SUFPIOS
!      G. Radnoti : 96-12-06  separate switches for gp. and sp. compactage
!     P. Le Moigne: 97-01-02  move NDOMFP from yomfpd to yomfpc
!    R. El Khatib : 97-06-02  3 NH fields
!    C. Madeira   : 97-07-29  ISBA CHECK
!        K. YESSAD (APRIL 1997): add variable NKORR2.
!        K. YESSAD and J. NICOLAU (97-09-04): cleaning for cy18, modifications
!          due to the removal of the 'EQUIVALENCE' instructions in YOMFPC,
!          removal of the useless variables M1FP3DF,M1FP2DF,M1FPPHY,M1FPCFU,
!          M1FPXFU. 
!    R. El Khatib : 98-02-26  LFPMOIS
!    R. El Khatib : 98-04-06  Tunable spectral packing
!    D.Dent       : 98-10-30  Optional path for namelist file added
!    R. El Khatib : 98-04-06  Test (LMPHYS or LEPHYS with NFPPHY)
!    R. El Khatib : 98-09-17 Remove NKORR2
!    R. El Khatib : 98-12-11 Cleanup pp of liquid water
!    R. El Khatib : 98-12-17 NFPINCR for pp. aladin to arpege
!    R. El Khatib : 98-12-30 NFPGRIB depending of LFPART2 and LFPSPEC
!    R. El Khatib : 99-03-09 Simplify fullpos control
!    R. El Khatib : 99-04-01 LFPRUBC
!    D.Dent       : 99-05-06  allow differing field code lists
!    D. Giard     : 99-07-26 NFPINDYN, NFPINPHY for 4/12 points interpolations
!    R. El Khatib : 99-04-01 LFPLOSP, LFPRH100
!    D.Dent       : 00-01-10 make reading of NAMDIM conditional 
!    D.Dent       : 00-04-05 add RFPVCAP to NAMFPC 
!                            and allow NGRBMONT,NGRBPRES
!    J. Boutahar  :2000-03-01 (NFPINDYN=0 , NFPINPHY=0; for
!        the search of the nearst point instead of the interpolation)
!    R. El Khatib : 00-08-18 derived type for dynamic fields
!    R. El Khatib : 01-05-07 control HUn,HUx
!    R. El Khatib : 01-06-14 LFPLAKE => NFPLAKE
!    R. El Khatib : 01-08-07 Pruning options
!    R. El Khatib : 02-21-20 Fullpos B-level distribution + remove IO scheme
!    R. El Khatib : 03-08-25 gfl
!    O.Spaniel    : 03-04-15 cleaning - a same named entity from modules
!    R. El Khatib : 03-04-17 Fullpos improvments
!    R. El Khatib : 03-09-03 LTRACEFP active per default if not LECMWF
!        M.Hamrud      01-Oct-2003 CY28 Cleaning
!      D. Paradis & R. El Khatib : 04-07-22 GRIBEX
!    G. Hello     : 05-04-25 lground specificities (Arome + ee927)
!    R. El Khatib : 05-03-23 NFPSURFEX NFPMASK
!        S. Serrar    : 05-06-23 GFP_PHYDS include parameters from
!                       table 210
!    Y. Seity     : 06-07-10 LMSE = T in case NFPSURFEX=1
!    R. El Ouaraini : 03-Oct-2006 NFPGRIB= -1,0,1,2,3 (Before: NFPGRIB=0,1,2,3)
!    Y. Seity     : 07-03-06 Tests if LNEIGE for Graupel and Hail.
!    F. Bouyssel  : 08-02-15 LPUTZS
!    P. Marquet   : 09-01-16 (RENTR->RENTRA by ??) ; allow NFPCAPE=5 ;
!                            print the final value for RENTRA
!     ------------------------------------------------------------------

IMPLICIT NONE

! * DUMMY:
CHARACTER(LEN=*)  ,INTENT(IN)    :: CDPATH 
!     ------------------------------------------------------------------

! * LOCAL EXTERNAL INTEGER FUNCTIONS:
INTEGER(KIND=JPIM), EXTERNAL :: ISRCHEQ

CHARACTER :: CLSHELL*500, CLFNISH*50, CLLEC*16

INTEGER(KIND=JPIM) :: IBL, ICNARG, ICND2, ICNIVEG, ICNLAI,&
 & ICNRSMIN, ICNSAB, IERR, ILEND, ILENP, INBARI, &
 & IND, IPD, IPOSEX, IREP, IUNTIN, IVD, &
 & IVW, IWARN, J, JFLD, JJ  

LOGICAL :: LLEXIST, LLISBA, LLNH
REAL(KIND=JPRB) :: ZHOOK_HANDLE

#include "abor1.intfb.h"
#include "posnam.intfb.h"
#include "sufpdim.intfb.h"

!     ------------------------------------------------------------------
#include "namfpc.h"
!     ------------------------------------------------------------------

!*       1. SET DEFAULT VALUES
!           ------------------

IF (LHOOK) CALL DR_HOOK('SUFPC',0,ZHOOK_HANDLE)
CFPDIR='PF'
CFPIDEN='FULLPOS'
LTRACEFP=.NOT.LECMWF
IF (LECMWF) THEN
  NFPGRIB=2
ELSE
  NFPGRIB=NVGRIB
ENDIF
LFPMOIS=.FALSE.
NFPINCR=0
IF (LELAM) THEN
  CFPFMT='LELAM'
ELSE
  CFPFMT='GAUSS'
ENDIF

CFPDOM(1)='000'
DO JJ=2, JPOSDOM
  CFPDOM(JJ)=' '
ENDDO
DO JJ=1, JPOSDOM
  C1FPDOM(JPOSLEN*(JJ-1)+1:JPOSLEN*JJ) = CFPDOM(JJ)(1:JPOSLEN)
ENDDO

CFP3DF(:)=' '
DO JJ=1, JPOS3DF
  C1FP3DF(12*(JJ-1)+1:12*JJ) = CFP3DF(JJ)(1:12)
ENDDO

CFP3DFS(:)=' '
DO JJ=1, JPOS3DF
  C1FP3DFS(12*(JJ-1)+1:12*JJ) = CFP3DFS(JJ)(1:12)
ENDDO

CFP3DFP(:)=' '
DO JJ=1, JPOS3DF
  C1FP3DFP(12*(JJ-1)+1:12*JJ) = CFP3DFP(JJ)(1:12)
ENDDO

CFP3DFH(:)=' '
DO JJ=1, JPOS3DF
  C1FP3DFH(12*(JJ-1)+1:12*JJ) = CFP3DFH(JJ)(1:12)
ENDDO

CFP3DFT(:)=' '
DO JJ=1, JPOS3DF
  C1FP3DFT(12*(JJ-1)+1:12*JJ) = CFP3DFT(JJ)(1:12)
ENDDO

CFP3DFV(:)=' '
DO JJ=1, JPOS3DF
  C1FP3DFV(12*(JJ-1)+1:12*JJ) = CFP3DFV(JJ)(1:12)
ENDDO

CFP2DF(:)=' '
DO JJ=1, JPOS2DF
  C1FP2DF(16*(JJ-1)+1:16*JJ) = CFP2DF(JJ)(1:16)
ENDDO

CFPPHY(:)=' '
DO JJ=1, JPOSSGP
  C1FPPHY(16*(JJ-1)+1:16*JJ) = CFPPHY(JJ)(1:16)
ENDDO

CFPCFU(:)=' '
DO JJ=1, JPOSCFU
  C1FPCFU(16*(JJ-1)+1:16*JJ) = CFPCFU(JJ)(1:16)
ENDDO

CFPXFU(:)=' '
DO JJ=1, JPOSXFU
  C1FPXFU(16*(JJ-1)+1:16*JJ) = CFPXFU(JJ)(1:16)
ENDDO

DO J=1,JPOS3P
  RFP3P(J)=-9._JPRB
ENDDO
DO J=1,JPOS3H
  RFP3H(J)=-9._JPRB
ENDDO
DO J=1,JPOS3TH
  RFP3TH(J)=-9._JPRB
ENDDO
DO J=1,JPOS3PV
  RFP3PV(J)=9999*1.E6_JPRB
ENDDO
DO J=1,JPOS3S
  NRFP3S(J)=-9
ENDDO

NFPCLI=0
LFPQ=.FALSE.
LFPRH100=LECMWF
LFPLOSP=.FALSE.
LASQ=.FALSE.
FPBL=17500._JPRB
RFPCORR=300._JPRB*RG
RFPCSAB=0.01_JPRB
RFPCD2=0.001_JPRB

RENTRA=0.0_JPRB

LFITP=.TRUE.
LFITT=.TRUE.
LFITV=.TRUE.
LMOCONVAR=.FALSE.
LPUTZS=.TRUE.

IF (LECMWF) THEN
  NFP3DF=0
  NFP3DFS=0
  NFP3DFP=0
  NFP3DFH=0
  NFP3DFT=0
  NFP3DFV=0
  NFP2DF=0
  NFPPHY=0
  NFPXFU=0
  NFPCFU=0
  MFP3DYN=7
  RFPVCAP=8900._JPRB
  IF(YO3%LGP) THEN
    MFP3DYN=MFP3DYN+1
  ENDIF

  MFP2DYN=2
  MFPPHY(:)=-9999
ELSE
  RFPVCAP=15000._JPRB
ENDIF

NFPINDYN=12
NFPINPHY=12
NFPMASK=1

NFPLAKE=0
NFPSURFEX=0
NFPCAPE=2

!*       2. READ NAMELIST
!           -------------

!        2.1   Check for PP listing file

IF(CDPATH == ' ') THEN
  IF(CNPPATH /= ' ') THEN
    IF(CFDIRLST == ' ') THEN
      CFDIRLST='dirlst'
    ENDIF
    INQUIRE(FILE=CFDIRLST,EXIST=LLEXIST)
    IF(.NOT.LLEXIST) THEN
      IBL=INDEX(CNPPATH,' ') -1
      IF(IBL == 0) IBL=120
      CLSHELL='/bin/ls '//CNPPATH(1:IBL)//'/* > '//CFDIRLST
      CALL SYSTEM(CLSHELL)
    ENDIF
    LFPCNT=.TRUE.
    CALL POSNAM(NULNAM,'NAMFPC')
    READ(NULNAM,NAMFPC)
  ELSEIF(CFDIRLST /= ' ') THEN
    INQUIRE(FILE=CFDIRLST,EXIST=LLEXIST)
    IF(.NOT.LLEXIST) THEN
      WRITE(UNIT=NULOUT,&
       & FMT='(''THE FILE '',A,&
       & '' DOES NOT EXIST AND CNPPATH HAS NOT BEEN SUPPLIED'')')&
       & CFDIRLST  
      CALL ABOR1(' ERROR CONTROL SUFPC ')
    ENDIF
    LFPCNT=.TRUE.
  ELSE
    CALL POSNAM(NULNAM,'NAMFPC')
    READ(NULNAM,NAMFPC)
    LFPCNT=.FALSE.
  ENDIF
ELSE
! CDPATH has been supplied
  CLOSE(NULNAM)
  IF ((NSTEP /= NSTOP).OR.((NSTEP == NSTOP).AND.LWROUTLAST)) THEN
    OPEN(NULNAM,FILE=CDPATH)
    READ(NULNAM,NAMFPC)
    CLOSE(NULNAM)
  ELSE
    WRITE(NULOUT,*) 'NO FIELDS WRITTEN OUT FOR LAST TIME STEP'
  ENDIF
  LFPCNT=.TRUE.
ENDIF

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

!*       3. COMPUTE INTERNAL VARIABLES
!           --------------------------

DO JJ=1, JPOSDOM
  C1FPDOM(JPOSLEN*(JJ-1)+1:JPOSLEN*JJ) = CFPDOM(JJ)(1:JPOSLEN)
ENDDO
DO JJ=1, JPOS3DF
  C1FP3DF(12*(JJ-1)+1:12*JJ) = CFP3DF(JJ)(1:12)
ENDDO
DO JJ=1, JPOS2DF
  C1FP2DF(16*(JJ-1)+1:16*JJ) = CFP2DF(JJ)(1:16)
ENDDO
DO JJ=1, JPOSSGP
  C1FPPHY(16*(JJ-1)+1:16*JJ) = CFPPHY(JJ)(1:16)
ENDDO
DO JJ=1, JPOSCFU
  C1FPCFU(16*(JJ-1)+1:16*JJ) = CFPCFU(JJ)(1:16)
ENDDO
DO JJ=1, JPOSXFU
  C1FPXFU(16*(JJ-1)+1:16*JJ) = CFPXFU(JJ)(1:16)
ENDDO

!     Control the "bogussing" : 
IF (LELAM) THEN
  IF (CFPFMT == 'GAUSS') THEN
!         NFPINCR=1
  ELSEIF(CFPFMT == 'MODEL') THEN
    NFPINCR=0
  ELSE
    NFPINCR=MAX(0,MIN(1,NFPINCR))
  ENDIF
ELSE
  NFPINCR=0
ENDIF

!     Case "927" : 
IF (LFPSPEC) THEN
  IF (NFPCT0 /= 0) THEN
!         Correct initialization of internal variable NFPCT0/first part :
    IF (NFPINCR == 0) THEN
      NFPCT0=-1
    ELSE
      NFPCT0=-2
    ENDIF
!         Special initialization for the first part : 
    IF (NFPSURFEX==1) THEN
       NFPMASK=2
       LMSE=.TRUE.
    ENDIF

    NFPGRIB=0
    IF (.NOT.LECMWF) THEN
      LFPLOSP=.FALSE.
    ENDIF
!   Trick to emulate the post-processing ... will be cleaned one of these days
    NRFP3S(1)=1
    DO J=2, JPOS3S
      NRFP3S(J)=-9
    ENDDO
  ELSE
!         Special initialization for the second part : 
    CFPFMT='MODEL'
    NFPCLI=0
    NFPLAKE=0
    NFPSURFEX=0
    IF (.NOT.LECMWF) THEN
      LFPLOSP=.TRUE.
    ENDIF
  ENDIF
ELSE
! Correct initialization of internal variable NFPCT0/standart post-processing :
  IF (NFPINCR == 0) THEN
    NFPCT0=1
  ELSE
    NFPCT0=2
  ENDIF
ENDIF

DO J=1, JPOSDOM
  IF (CFPDOM(J) == ' ') EXIT
ENDDO
NFPDOM=J-1

IF (.NOT.LECMWF) THEN

  DO J=1, JPOS3DF
    IF (CFP3DF(J) == ' ') EXIT
  ENDDO
  NFP3DF=J-1

  MFP3DYN=NFP3DF-1

  IF (NFPCT0 < 0) THEN
!         Prepare for vertical interpolation in part 2 of CPREP4
    IPD=INDEX(C1FP3DF,TFP_PD%CLNAME(1:12)) 
    IVD=INDEX(C1FP3DF,TFP_VD%CLNAME(1:12))
    IVW=INDEX(C1FP3DF,TFP_VW%CLNAME(1:12))
    LLNH=IPD > 0.OR.IVD > 0.OR.IVW > 0
    IF (IPD == 0.AND.LLNH) THEN
      NFP3DF=NFP3DF+1
      CFP3DF(NFP3DF)=TFP_PD%CLNAME(1:12)
      C1FP3DF(12*(NFP3DF-1)+1:12*NFP3DF) = CFP3DF(NFP3DF)(1:12)
    ENDIF
    IF (IVD == 0.AND.LLNH) THEN
      NFP3DF=NFP3DF+1
      CFP3DF(NFP3DF)=TFP_VD%CLNAME(1:12)
      C1FP3DF(12*(NFP3DF-1)+1:12*NFP3DF) = CFP3DF(NFP3DF)(1:12)
    ENDIF
  ENDIF

  DO J=1, JPOS2DF
    IF (CFP2DF(J) == ' ') EXIT
  ENDDO
  NFP2DF=J-1

  NFP3DFS=NFP3DF
  CFP3DFS(1:NFP3DFS)=CFP3DF(1:NFP3DF)
  C1FP3DFS(1:12*NFP3DFS)=C1FP3DF(1:12*NFP3DF)
  NFP3DFP=NFP3DF
  CFP3DFP(1:NFP3DFP)=CFP3DF(1:NFP3DF)
  C1FP3DFP(1:12*NFP3DFP)=C1FP3DF(1:12*NFP3DF)
  NFP3DFH=NFP3DF
  CFP3DFH(1:NFP3DFH)=CFP3DF(1:NFP3DF)
  C1FP3DFH(1:12*NFP3DFH)=C1FP3DF(1:12*NFP3DF)
  NFP3DFT=NFP3DF
  CFP3DFT(1:NFP3DFT)=CFP3DF(1:NFP3DF)
  C1FP3DFT(1:12*NFP3DFT)=C1FP3DF(1:12*NFP3DF)
  NFP3DFV=NFP3DF
  CFP3DFV(1:NFP3DFV)=CFP3DF(1:NFP3DF)
  C1FP3DFV(1:12*NFP3DFV)=C1FP3DF(1:12*NFP3DF)

  MFP2DYN=NFP2DF

  DO J=1, JPOSSGP
    IF (CFPPHY(J) == ' ') EXIT
  ENDDO
  NFPPHY=J-1

  IF (NFPCT0 < 0) THEN
!   Prepare for vertical interpolation in part 2 of CPREP4
!   Output surface geopotential : 
    NFPPHY=NFPPHY+1
    CFPPHY(NFPPHY)=GFP_GFIS%CLNAME
    C1FPPHY(16*(NFPPHY-1)+1:16*NFPPHY) = CFPPHY(NFPPHY)(1:16)
    IF (LMPHYS.OR.LEPHYS) THEN
!     Output surface temperature :
      IF (INDEX(C1FPPHY,GFP_ST%CLNAME) == 0) THEN
        NFPPHY=NFPPHY+1
        CFPPHY(NFPPHY)=GFP_ST%CLNAME
        C1FPPHY(16*(NFPPHY-1)+1:16*NFPPHY) = CFPPHY(NFPPHY)(1:16)
      ENDIF
!     Interpolated surface temperature :
      NFPPHY=NFPPHY+1
      CFPPHY(NFPPHY)=GFP_RDST%CLNAME
      C1FPPHY(16*(NFPPHY-1)+1:16*NFPPHY) = CFPPHY(NFPPHY)(1:16)
    ENDIF
  ENDIF

  DO J=1, JPOSCFU
    IF (CFPCFU(J) == ' ') EXIT
  ENDDO
  NFPCFU=J-1

  DO J=1, JPOSXFU
    IF (CFPXFU(J) == ' ') EXIT
  ENDDO
  NFPXFU=J-1

ELSE
  DO J=1, NFP3DFS
    IND=ISRCHEQ(JPOSDYN,TFP_DYNDS%IGRIB,1,MFP3DFS(J))
    IF (IND <= JPOSDYN) THEN
      CFP3DFS(J)=TFP_DYNDS(IND)%CLNAME(1:12)
      C1FP3DFS(12*(J-1)+1:12*J) = CFP3DFS(J)(1:12)
      C1FP3DF (12*(J-1)+1:12*J) = CFP3DFS(J)(1:12)
    ELSE
      WRITE(NULOUT,*) 'WARNING: GRIBCODE UNKNOWN ',MFP3DFS(J)
    ENDIF
  ENDDO
  DO J=1, NFP3DFP
    IND=ISRCHEQ(JPOSDYN,TFP_DYNDS%IGRIB,1,MFP3DFP(J))
    IF (IND <= JPOSDYN) THEN
      CFP3DFP(J)=TFP_DYNDS(IND)%CLNAME(1:12)
      C1FP3DFP(12*(J-1)+1:12*J) = CFP3DFP(J)(1:12)
    ELSE
      WRITE(NULOUT,*) 'WARNING: GRIBCODE UNKNOWN ',MFP3DFP(J)
    ENDIF
  ENDDO
  DO J=1, NFP3DFH
    IND=ISRCHEQ(JPOSDYN,TFP_DYNDS%IGRIB,1,MFP3DFH(J))
    IF (IND <= JPOSDYN) THEN
      CFP3DFH(J)=TFP_DYNDS(IND)%CLNAME(1:12)
      C1FP3DFH(12*(J-1)+1:12*J) = CFP3DFH(J)(1:12)
    ELSE
      WRITE(NULOUT,*) 'WARNING: GRIBCODE UNKNOWN ',MFP3DFH(J)
    ENDIF
  ENDDO
  DO J=1, NFP3DFT
    IND=ISRCHEQ(JPOSDYN,TFP_DYNDS%IGRIB,1,MFP3DFT(J))
    IF (IND <= JPOSDYN) THEN
      CFP3DFT(J)=TFP_DYNDS(IND)%CLNAME(1:12)
      C1FP3DFT(12*(J-1)+1:12*J) = CFP3DFT(J)(1:12)
    ELSE
      WRITE(NULOUT,*) 'WARNING: GRIBCODE UNKNOWN ',MFP3DFT(J)
    ENDIF
  ENDDO
  DO J=1, NFP3DFV
    IND=ISRCHEQ(JPOSDYN,TFP_DYNDS%IGRIB,1,MFP3DFV(J))
    IF (IND <= JPOSDYN) THEN
      CFP3DFV(J)=TFP_DYNDS(IND)%CLNAME(1:12)
      C1FP3DFV(12*(J-1)+1:12*J) = CFP3DFV(J)(1:12)
    ELSE
      WRITE(NULOUT,*) 'WARNING: GRIBCODE UNKNOWN ',MFP3DFV(J)
    ENDIF
  ENDDO

  DO J=1, NFP2DF
    IND=ISRCHEQ(JPOSDYN,TFP_DYNDS%IGRIB,1,MFP2DF(J))
    IF (IND <= JPOSDYN) THEN
      CFP2DF(J)=TFP_DYNDS(IND)%CLNAME(1:16)
      C1FP2DF(16*(J-1)+1:16*J) = CFP2DF(J)(1:16)
    ELSE
      WRITE(NULOUT,*) 'WARNING: GRIBCODE UNKNOWN ',MFP2DF(J)
    ENDIF
  ENDDO

  DO J=1, NFPPHY
    IND=ISRCHEQ(JPOSPHY,GFP_PHYDS%IGRIB,1,MFPPHY(J))
    IF (IND <= JPOSPHY) THEN
!     Replace surface temperature and soil wetness by level 1 variables
      IF ( GFP_PHYDS(IND)%IGRIB == GFP_ST%IGRIB ) THEN
        CFPPHY(J)=GFP_STL1%CLNAME
      ELSEIF ( GFP_PHYDS(IND)%IGRIB == GFP_SSW%IGRIB ) THEN
        CFPPHY(J)=GFP_SWL1%CLNAME
      ELSE
        CFPPHY(J)=GFP_PHYDS(IND)%CLNAME
      ENDIF
      C1FPPHY(16*(J-1)+1:16*J) = CFPPHY(J)(1:16)
    ELSE
      WRITE(NULOUT,*) 'WARNING: GRIBCODE UNKNOWN ',MFPPHY(J)
    ENDIF
    IF(GFP_PHYDS(IND)%IGRIB < 1 .OR. MOD(GFP_PHYDS(IND)%IGRIB,1000) > 255) THEN
      WRITE(NULOUT,*) 'SUFPC: ILLEGAL GRIB CODE FOR PHYSICS FIELD NO',&
       & J,GFP_PHYDS(IND)%IGRIB  
      WRITE(NULERR,*) 'SUFPC: ILLEGAL GRIB CODE FOR PHYSICS FIELD NO',&
       & J,GFP_PHYDS(IND)%IGRIB  
      CALL ABOR1('SUFPC: ILLEGAL GRIB CODE FOR PHYSICS FIELD')
    ENDIF
  ENDDO

  IF (NFPCT0 < 0) THEN
!   Prepare for vertical interpolation in part 2 of CPREP4
!   check that orographies and surface temperature are post-processed

!   Interpolated orography :
    IF((ISRCHEQ(NFP2DF,MFP2DF,1,TFP_FIS%IGRIB) > NFP2DF).OR.NFP2DF == 0) THEN
      NFP2DF=NFP2DF+1
      MFP2DF(NFP2DF)=TFP_FIS%IGRIB
      CFP2DF(NFP2DF)=TFP_FIS%CLNAME
      C1FP2DF(16*(NFP2DF-1)+1:16*NFP2DF) = CFP2DF(NFP2DF)(1:16)
    ENDIF
!   Surface temperature :
    IF(((ISRCHEQ(NFPPHY,MFPPHY,1,GFP_STL1%IGRIB) > NFPPHY).OR.NFPPHY == 0)&
       & .AND.(LMPHYS.OR.LEPHYS) ) THEN   
      NFPPHY=NFPPHY+1
      MFPPHY(NFPPHY)=GFP_STL1%IGRIB
      CFPPHY(NFPPHY)=GFP_STL1%CLNAME
      C1FPPHY(16*(NFPPHY-1)+1:16*NFPPHY) = CFPPHY(NFPPHY)(1:16)
    ENDIF
!   Output orography :
    NFPPHY=NFPPHY+1
    CFPPHY(NFPPHY)=GFP_GFIS%CLNAME
    MFPPHY(NFPPHY)=GFP_GFIS%IGRIB
    C1FPPHY(16*(NFPPHY-1)+1:16*NFPPHY) = CFPPHY(NFPPHY)(1:16)
  ENDIF

ENDIF

LFPNHPD=INDEX(C1FP3DF,TFP_PD%CLNAME(1:12)) > 0
LFPNHVD=INDEX(C1FP3DF,TFP_VD%CLNAME(1:12)) > 0
LFPNHVW=INDEX(C1FP3DF,TFP_VW%CLNAME(1:12)) > 0

DO J=1, JPOS3P
  IF (RFP3P(J) < 0.0_JPRB) EXIT
ENDDO
NFP3P=(J-1)*MIN(1,NFP3DFP)

DO J=1, JPOS3H
  IF (RFP3H(J) < 0.0_JPRB) EXIT
ENDDO
NFP3H=(J-1)*MIN(1,NFP3DFH)

DO J=1, JPOS3TH
  IF (RFP3TH(J) < 0.0_JPRB) EXIT
ENDDO
NFP3TH=(J-1)*MIN(1,NFP3DFT)

DO J=1, JPOS3PV
  IF (RFP3PV(J) >= 100000._JPRB) EXIT
ENDDO
NFP3PV=(J-1)*MIN(1,NFP3DFV)

!    first value flagged -99 means: generate all model levels
IF (NRFP3S(1) == -99 ) THEN
  DO J=1,NUFLEV
    NRFP3S(J) = J
  ENDDO
ENDIF
DO J=1, JPOS3S
  IF (NRFP3S(J) < 0) EXIT
ENDDO
NFP3S=(J-1)*MIN(1,NFP3DFS)

NFPXLEV=MAX(NFP3P,NFP3H,NFP3TH,NFP3PV,NFP3S,NFLEVG)

NFPDPHY=NFPPHY+NFPCFU+NFPXFU

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

!*       4. CHECK NAMELIST VALUES
!           ---------------------

!*       4.1 Fatal errors

IF (LECMWF) THEN

  IERR=0
  DO J=1, NFP2DF
    IND=ISRCHEQ(JPOSDYN,TFP_DYNDS%IGRIB,1,MFP2DF(J))
    IF (IND > JPOSDYN) THEN
      WRITE(NULOUT,'('' UNKNOWN FIELD CODE '',I6.6)') MFP2DF(J)
      IERR=IERR+1
    ENDIF
  ENDDO

ELSE

  IERR=0
  DO J=1, NFP3DF
    DO JFLD=1,JPOSDYN
      IF (CFP3DF(J) == TFP_DYNDS(JFLD)%CLNAME(1:12)) EXIT
    ENDDO
    IF (JFLD > JPOSDYN) THEN
      WRITE(NULOUT,'('' UNKNOWN FIELD '',A12)') CFP3DF(J)
      IERR=IERR+1
    ENDIF
  ENDDO
  DO J=1, NFP2DF
    DO JFLD=1,JPOSDYN
      IF (CFP2DF(J) == TFP_DYNDS(JFLD)%CLNAME(1:16)) EXIT
    ENDDO
    IF (JFLD > JPOSDYN) THEN    
      WRITE(NULOUT,'('' UNKNOWN FIELD '',A16)') CFP2DF(J)
      IERR=IERR+1
    ENDIF
  ENDDO

ENDIF

IF (.NOT.LMPHYS.AND..NOT.LEPHYS.AND.NFPPHY+NFPCFU+NFPXFU > 0) THEN
  IF (NFPCFU > 0 .OR. NFPXFU > 0 .OR. NFPPHY > 1 .OR. &
    & CFPPHY(1) /= GFP_GFIS%CLNAME) THEN
    IERR=IERR+1
    WRITE(NULOUT,*)&
     & 'PHYS.FIELDS/FLUXES ARE NOT AVAILABLE IN THE ADIABATIC MODEL'  
  ENDIF
ENDIF

IF (CFPFMT == 'GAUSS'.OR.CFPFMT == 'LELAM'.OR.CFPFMT == 'MODEL') THEN
  IF (NFPDOM > 1) THEN
    WRITE(NULOUT,*) ' GAUSS OR LELAM OR MODEL >>> NFPDOM=1 '
    NFPDOM=1
  ENDIF
ELSEIF (CFPFMT /= 'LALON') THEN
  IERR=IERR+1
  WRITE(NULOUT,*) 'UNRECOGNIZED VARIABLE CFPFMT'
ENDIF

IF (NFPCLI /= 0 .AND. NFPCLI /= 1 .AND. NFPCLI /= 3) THEN
  IERR=IERR+1
  WRITE(NULOUT,*) 'ILLEGAL VALUE NFPCLI'
ENDIF
IF (NFPCAPE < 0.OR.NFPCAPE > 5) THEN
  IERR=IERR+1
  WRITE(NULOUT,*) 'ILLEGAL VALUE NFPCAPE'
ENDIF
IF (NFPGRIB < -1 .OR.NFPGRIB > 3) THEN
  IERR=IERR+1
  WRITE(NULOUT,*) 'ILLEGAL VALUE NFPGRIB'
ENDIF
IF (NFPGRIB == 3) THEN
  WRITE(NULOUT,*) &
   & 'WARNING : GRIBEX TABLES ARE STILL HARD-CODED FOR FULL-POS FIELDS'
ENDIF
IF (CFPFMT == 'MODEL'.AND.NFPCLI /= 0) THEN
  IERR=IERR+1
  WRITE(NULOUT,*) 'CFPFMT=MODEL NOT COMPATIBLE WITH NFPCLI'
ENDIF
IF (NFPSURFEX < 0 .OR. NFPSURFEX > 1) THEN
  IERR=IERR+1
  WRITE(NULOUT,*) 'ILLEGAL VALUE NFPSURFEX'
ENDIF
IF (NFPMASK < 0 .OR. NFPMASK > 2) THEN
  IERR=IERR+1
  WRITE(NULOUT,*) 'ILLEGAL VALUE NFPMASK'
ENDIF
IF (ABS(NFPLAKE) > 1) THEN
  IERR=IERR+1
  WRITE(NULOUT,*) 'ILLEGAL VALUE NFPLAKE'
ENDIF
IF (NFPLAKE == 1 .AND. NFPCLI <= 1) THEN
  IERR=IERR+1
  WRITE(NULOUT,*) 'NFPLAKE = 1 NEEDS NFPCLI > 1'
ENDIF
IF (NFPLAKE /= 0 .AND. NFPMASK == 0) THEN
  IERR=IERR+1
  WRITE(NULOUT,*) 'NFPLAKE /= 0 NEEDS NFPMASK > 0'
ENDIF
IF (NFPMASK >= 2 .AND. NFPCLI >= 2) THEN
  IERR=IERR+1
  WRITE(NULOUT,*) 'NFPMASK >= 2 NEEDS NFPCLI <= 1'
ENDIF


!      Case of ISBA fields    

IF (NFPCLI == 3) THEN
  IF (LMPHYS.AND..NOT.LSOLV.AND..NOT.LMSE) THEN
    IERR=IERR+1
    WRITE(NULOUT,FMT='('' POST-PROCESSING OF ISBA FIELDS '',&
     & ''IS NOT ALLOWED WITHOUT ISBA FILE'')')   
  ENDIF
ENDIF

IF (LFPOS.AND.NFPCT0 /= 0.AND.LARPEGEF.AND.(NFPCLI == 3)) THEN
  CLLEC='CADRE LECTURE   '
  INBARI=0
  CLFNISH='ICMSH'//CNMEXP(1:4)//'INIT'
  IUNTIN=NINISH
  CALL FAITOU(IREP,IUNTIN,.TRUE.,CLFNISH,'OLD',.TRUE.,&
   & .TRUE.,1,1,INBARI,CLLEC)  
  CALL LFIMST(IREP,IUNTIN,.FALSE.)
  ICNIVEG=0
  CALL LFINFO(IREP,IUNTIN,GFP_IVEG%CLNAME, ICNIVEG, IPOSEX)
  ICNRSMIN=0
  CALL LFINFO(IREP,IUNTIN,GFP_RSMIN%CLNAME,ICNRSMIN,IPOSEX)
  ICNARG=0
  CALL LFINFO(IREP,IUNTIN,GFP_ARG%CLNAME,  ICNARG,  IPOSEX)
  ICNSAB=0
  CALL LFINFO(IREP,IUNTIN,GFP_SAB%CLNAME,  ICNSAB,  IPOSEX)
  ICND2=0
  CALL LFINFO(IREP,IUNTIN,GFP_D2%CLNAME,   ICND2,   IPOSEX)
  ICNLAI=0
  CALL LFINFO(IREP,IUNTIN,GFP_LAI%CLNAME,  ICNLAI,  IPOSEX)
  LLISBA=(ICNIVEG+ICNRSMIN+ICNARG+ICNSAB+ICND2+ICNLAI) > 0
  IF (.NOT.LLISBA) THEN
    CALL LFILAF(IREP,IUNTIN,.FALSE.)
    IERR=IERR+1
    WRITE(NULOUT,*) 'NON-ISBA FILE !'
  ENDIF
  CALL FAIRME(IREP,IUNTIN,'UNKNOWN')
ENDIF

IF (IERR > 0) THEN
  CALL ABOR1(' SUFPC: ABOR1 CALLED')
ENDIF

!*       4.2 Warnings

IF (LMPHYS.AND..NOT.LNEIGE) THEN
  IWARN=0
  DO JFLD=1,NFPXFU
    IF (CFPXFU(JFLD)==GFP_XLSS%CLNAME.OR.CFPXFU(JFLD)==GFP_XCSF%CLNAME.OR. &
        & CFPXFU(JFLD)==GFP_XLSG%CLNAME.OR.CFPXFU(JFLD)==GFP_XCSG%CLNAME.OR. &
        & CFPXFU(JFLD)==GFP_XLSH%CLNAME.OR.CFPXFU(JFLD)==GFP_XCSH%CLNAME) THEN
      IWARN=IWARN+1
    ENDIF
  ENDDO
  DO JFLD=1,NFPCFU
  IF (CFPCFU(JFLD)==GFP_CLSS%CLNAME.OR.CFPCFU(JFLD)==GFP_CCSF%CLNAME.OR. &
        & CFPCFU(JFLD)==GFP_CLSG%CLNAME.OR.CFPCFU(JFLD)==GFP_CCSG%CLNAME.OR. &
        & CFPCFU(JFLD)==GFP_CLSH%CLNAME.OR.CFPCFU(JFLD)==GFP_CCSH%CLNAME) THEN
      IWARN=IWARN+1
    ENDIF
  ENDDO
  IF (IWARN /= 0) THEN
    WRITE(NULOUT,*) 'FULL-POS WARNING : LNEIGE IS FALSE'
  ENDIF
ENDIF
IF (LMPHYS.AND..NOT.LHMTO ) THEN
  IWARN=0
  DO JFLD=1,NFPXFU
    IF (CFPXFU(JFLD)==GFP_X10U%CLNAME  .OR. CFPXFU(JFLD)==GFP_X10V%CLNAME .OR.&
       & CFPXFU(JFLD)==GFP_X2T%CLNAME  .OR. CFPXFU(JFLD)==GFP_X2SH%CLNAME .OR.&
       & CFPXFU(JFLD)==GFP_X2RH%CLNAME .OR. CFPXFU(JFLD)==GFP_XX2T%CLNAME .OR.&
       & CFPXFU(JFLD)==GFP_XX2HU%CLNAME.OR. CFPXFU(JFLD)==GFP_XN2HU%CLNAME.OR.&
       & CFPXFU(JFLD)==GFP_XN2T%CLNAME ) THEN  
      IWARN=IWARN+1
    ENDIF
  ENDDO
  IF (IWARN /= 0) THEN
    WRITE(NULOUT,*) 'FULL-POS WARNING : LHMTO IS FALSE'
  ENDIF
ENDIF
IF (LMPHYS.AND..NOT.LOZONE) THEN
  IWARN=0
  DO JFLD=1,NFPCFU
    IF (CFPCFU(JFLD) == GFP_CTO3%CLNAME) THEN
      IWARN=IWARN+1
    ENDIF
  ENDDO
  IF (IWARN /= 0) THEN
    WRITE(NULOUT,*) 'FULL-POS WARNING : LOZONE IS FALSE'
  ENDIF
ENDIF
IF (LMPHYS.AND..NOT.LSOLV) THEN
  IWARN=0
  DO JFLD=1,NFPCFU
    IF (CFPCFU(JFLD) == GFP_CIRU%CLNAME.OR.CFPCFU(JFLD) == GFP_CETP%CLNAME.OR.&
       & CFPCFU(JFLD) == GFP_CTP%CLNAME) THEN  
      IWARN=IWARN+1
    ENDIF
  ENDDO
  IF (IWARN /= 0) THEN
    WRITE(NULOUT,*) 'FULL-POS WARNING : LSOLV IS FALSE'
  ENDIF
ENDIF

IF (LFPOS.AND.NFPCT0 /= 0.AND.LARPEGEF.AND.(N3DINI==0)) THEN
  CLLEC='CADRE LECTURE   '
  INBARI=0
  CLFNISH='ICMSH'//CNMEXP(1:4)//'INIT'
  IUNTIN=NINISH
  CALL FAITOU(IREP,IUNTIN,.TRUE.,CLFNISH,'OLD',.TRUE.,&
   & .TRUE.,1,1,INBARI,CLLEC)  
  CALL LFIMST(IREP,IUNTIN,.FALSE.)
  CALL LFINFO(IREP,IUNTIN,'S001'//TFP_PD%CLNAME(1:12),ILENP,IPOSEX)
  CALL LFINFO(IREP,IUNTIN,'S001'//TFP_VD%CLNAME(1:12),ILEND,IPOSEX)
  IF ( ((ILENP > 0).OR.(ILEND > 0)).AND..NOT.LNHDYN) THEN
    CALL LFILAF(IREP,IUNTIN,.FALSE.)
    WRITE(NULOUT,*) 'WARNING : INPUT FILE CONTAINS NH FIELDS !'
    WRITE(NULERR,*) 'WARNING : INPUT FILE CONTAINS NH FIELDS !'
  ENDIF
  CALL FAIRME(IREP,IUNTIN,'UNKNOWN')
ENDIF

IWARN=0
IF (NFPINDYN /= 0 .AND. NFPINDYN /= 4 .AND. NFPINDYN /= 12) THEN
  NFPINDYN=12
  IWARN=IWARN+1
ENDIF
IF (NFPINPHY /= 0 .AND. NFPINPHY /= 4 .AND. NFPINPHY /= 12) THEN
  NFPINPHY=12
  IWARN=IWARN+1
ENDIF
IF (IWARN /= 0) WRITE(NULOUT,*)&
 & 'FULL-POS WARNING : UNKNOWN INTERPOLATION TYPE, RESET TO 12 POINTS'  

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

!*       5. PRINT OUT FINAL VALUES
!           ----------------------

IF(LTRACEFP) THEN
  WRITE(UNIT=NULOUT,FMT='('' COMMON YOMFPC'')')
  WRITE(UNIT=NULOUT,FMT='('' CFPDIR = '',A180)') CFPDIR
  WRITE(UNIT=NULOUT,FMT='('' CFPIDEN = '',A8,'' CFPFMT = '',A7)')&
   & CFPIDEN, CFPFMT  
  WRITE(UNIT=NULOUT,FMT='('' LTRACEFP = '',L2,&
   & '' LFPCNT = '',L2,'' LFPMOIS = '',L2,&
   & '' NFPGRIB = '',I2,&
   & '' LFPNHPD = '',L2,'' LFPNHVD = '',L2,'' LFPNHVW = '',L2)')&
   & LTRACEFP,LFPCNT,LFPMOIS,NFPGRIB,&
   & LFPNHPD,LFPNHVD,LFPNHVW  
  WRITE(UNIT=NULOUT,FMT='('' LFPSPEC = '',L2,'' LFITP = '',L2,              &
   & '' LFITT = '',L2,'' LFITV = '',L2,'' NFPLAKE = '',I2,'' NFPCLI = '',I1,&
   & '' NFPINCR = '',I3,'' NFPCAPE = '',I3,&
   & '' NFPMASK = '',I3)') LFPSPEC,LFITP, LFITT, LFITV, NFPLAKE, NFPCLI,&
   & NFPINCR, NFPCAPE, NFPMASK 
  WRITE(UNIT=NULOUT,FMT='('' LPUTZS = '',L2,'' NFPSURFEX = '',I3)')&
   & LPUTZS, NFPSURFEX
  WRITE(UNIT=NULOUT,FMT='('' LFPQ = '',L2,'' LFPLOSP = '',L2&
   & ,'' LFPRH100 = '',L2,'' RFPCSAB = '',F9.6,'' RFPCD2  = '',F9.4 &
   & ,'' FPBL = '',F9.2,'' RFPCORR = '',F9.2)')&
   & LFPQ, LFPLOSP, LFPRH100,RFPCSAB,RFPCD2,FPBL, RFPCORR  
  WRITE(UNIT=NULOUT,FMT='('' NFPDOM = '',I2,'' NFP3DF = '',I2 &
   & ,'' NFP2DF = '',I2,'' NFPPHY = '',I2,'' NFPCFU = '',I2 &
   & ,'' NFPXFU = '',I2)')&
   & NFPDOM, NFP3DF, NFP2DF, NFPPHY, NFPCFU, NFPXFU  
  WRITE(UNIT=NULOUT,FMT='('' NFP3P = '',I2,'' NFP3H = '',I2 &
   & ,'' NFP3TH = '',I2,'' NFP3PV = '',I2,'' NFP3S = '',I3)')&
   & NFP3P,NFP3H,NFP3TH,NFP3PV,NFP3S  
  WRITE(UNIT=NULOUT,FMT='('' NFPXLEV = '',I4, '' NFPDPHY = '',I4)') NFPXLEV, &
   & NFPDPHY  
  WRITE(UNIT=NULOUT,FMT='('' RENTRA  = '',E13.6 )') &
   & RENTRA

  IF (NFPDOM > 0) THEN
    WRITE(UNIT=NULOUT,FMT='('' (JDOM CFPDOM)'')')
    WRITE(UNIT=NULOUT,FMT='(10('' ('',I2,1X,A7,'')''))')&
     & (J,CFPDOM(J), J=1,NFPDOM)  
  ENDIF
ENDIF
IF (NFP3DF > 0) THEN
  IF (.NOT.LECMWF) THEN
    WRITE(UNIT=NULOUT,FMT='('' (JF CFP3DF )'')')
    WRITE(UNIT=NULOUT,FMT='(7('' ('',I2,1X,A12,'')''))')&
     & (J,CFP3DF(J), J=1,NFP3DF)  
  ENDIF
ENDIF
IF (NFP3DFS > 0) THEN
  IF (LECMWF) THEN
    WRITE(NULOUT,'('' THE FOLLOWING '',I6,&
     & '' 3DYN. FIELDS'','' WILL BE WRITTEN OUT ON MODEL LEVELS''&
     & )')NFP3DFS  
    WRITE(NULOUT,'(20(1X,I6))') (MFP3DFS(J),J=1,NFP3DFS)
    WRITE(UNIT=NULOUT,FMT='('' (JF CFP3DFS )'')')
    WRITE(UNIT=NULOUT,FMT='(7('' ('',I2,1X,A12,'')''))')&
     & (J,CFP3DFS(J), J=1,NFP3DFS)         
  ENDIF
ENDIF
IF (NFP3DFH > 0) THEN
  IF (LECMWF) THEN
    WRITE(NULOUT,'('' THE FOLLOWING '',I6,&
     & '' 3DYN. FIELDS'','' WILL BE WRITTEN OUT ON H LEVELS''&
     & )')NFP3DFH  
    WRITE(NULOUT,'(20(1X,I3))') (MFP3DFH(J),J=1,NFP3DFH)
    WRITE(UNIT=NULOUT,FMT='('' (JF CFP3DFH )'')')
    WRITE(UNIT=NULOUT,FMT='(7('' ('',I2,1X,A12,'')''))')&
     & (J,CFP3DFH(J), J=1,NFP3DFH)         
  ENDIF
ENDIF
IF (NFP3DFP > 0) THEN
  IF (LECMWF) THEN
    WRITE(NULOUT,'('' THE FOLLOWING '',I6,&
     & '' 3DYN. FIELDS'','' WILL BE WRITTEN OUT ON PRESSURE LEVELS''&
     & )')NFP3DFP  
    WRITE(NULOUT,'(20(1X,I6))') (MFP3DFP(J),J=1,NFP3DFP)
    WRITE(UNIT=NULOUT,FMT='('' (JF CFP3DFP )'')')
    WRITE(UNIT=NULOUT,FMT='(7('' ('',I2,1X,A12,'')''))')&
     & (J,CFP3DFP(J), J=1,NFP3DFP)         
  ENDIF
ENDIF
IF (NFP3DFT > 0) THEN
  IF (LECMWF) THEN
    WRITE(NULOUT,'('' THE FOLLOWING '',I6,&
     & '' 3DYN. FIELDS'','' WILL BE WRITTEN OUT ON THETA LEVELS''&
     & )')NFP3DFT  
    WRITE(NULOUT,'(20(1X,I3))') (MFP3DFT(J),J=1,NFP3DFT)
    WRITE(UNIT=NULOUT,FMT='('' (JF CFP3DFT )'')')
    WRITE(UNIT=NULOUT,FMT='(7('' ('',I2,1X,A12,'')''))')&
     & (J,CFP3DFT(J), J=1,NFP3DFT)         
  ENDIF
ENDIF
IF (NFP3DFV > 0) THEN
  IF (LECMWF) THEN
    WRITE(NULOUT,'('' THE FOLLOWING '',I6,&
     & '' 3DYN. FIELDS'','' WILL BE WRITTEN OUT ON PV LEVELS''&
     & )')NFP3DFV  
    WRITE(NULOUT,'(20(1X,I3))') (MFP3DFV(J),J=1,NFP3DFV)
    WRITE(UNIT=NULOUT,FMT='('' (JF CFP3DFV )'')')
    WRITE(UNIT=NULOUT,FMT='(7('' ('',I2,1X,A12,'')''))')&
     & (J,CFP3DFV(J), J=1,NFP3DFV)         
  ENDIF
ENDIF
IF (NFP2DF > 0) THEN
  IF (LECMWF) THEN
    WRITE(NULOUT,'('' THE FOLLOWING '',I3,&
     & '' DYN.SURFACE FIELDS'','' WILL BE WRITTEN OUT '')')NFP2DF  
    WRITE(NULOUT,'(20(1X,I3))') (MFP2DF(J),J=1,NFP2DF)
    WRITE(UNIT=NULOUT,FMT='('' (JF CFP2DF )'')')
    WRITE(UNIT=NULOUT,FMT='(6('' ('',I2,1X,A16,'')''))')&
     & (J,CFP2DF(J), J=1,NFP2DF)  
  ELSE
    WRITE(UNIT=NULOUT,FMT='('' (JF CFP2DF )'')')
    WRITE(UNIT=NULOUT,FMT='(6('' ('',I2,1X,A16,'')''))')&
     & (J,CFP2DF(J), J=1,NFP2DF)  
  ENDIF
ENDIF
IF (NFPPHY > 0) THEN
  IF (LECMWF) THEN
    WRITE(NULOUT,'('' THE FOLLOWING '',I6,&
     & '' PHY.SURFACE FIELDS'','' WILL BE WRITTEN OUT '')')NFPPHY  
    WRITE(NULOUT,'(20(1X,I6))') (MFPPHY(J),J=1,NFPPHY)
    WRITE(UNIT=NULOUT,FMT='('' (JF CFPPHY )'')')
    WRITE(UNIT=NULOUT,FMT='(6('' ('',I2,1X,A16,'')''))')&
     & (J,CFPPHY(J), J=1,NFPPHY)  
  ELSE
    WRITE(UNIT=NULOUT,FMT='('' (JF CFPPHY )'')')
    WRITE(UNIT=NULOUT,FMT='(6('' ('',I2,1X,A16,'')''))')&
     & (J,CFPPHY(J), J=1,NFPPHY)  
  ENDIF
ENDIF
IF (NFPCFU > 0) THEN
  IF (.NOT.LECMWF) THEN
    WRITE(UNIT=NULOUT,FMT='('' (JF CFPCFU )'')')
    WRITE(UNIT=NULOUT,FMT='(6('' ('',I2,1X,A16,'')''))')&
     & (J,CFPCFU(J), J=1,NFPCFU)  
  ENDIF
ENDIF
IF (NFPXFU > 0) THEN
  IF (.NOT.LECMWF) THEN
    WRITE(UNIT=NULOUT,FMT='('' (JF CFPXFU )'')')
    WRITE(UNIT=NULOUT,FMT='(6('' ('',I2,1X,A16,'')''))')&
     & (J,CFPXFU(J), J=1,NFPXFU)  
  ENDIF
ENDIF

IF (NFP3P > 0) THEN
  WRITE(UNIT=NULOUT,FMT='('' (JL RFP3P)'')')
  WRITE(UNIT=NULOUT,FMT='(10('' ('',I2,1X,F7.0,'')''))')&
   & (J,RFP3P(J), J=1,NFP3P)  
ENDIF
IF (NFP3H > 0) THEN
  WRITE(UNIT=NULOUT,FMT='('' (JL RFP3H)'')')
  WRITE(UNIT=NULOUT,FMT='(10('' ('',I2,1X,F7.0,'')''))')&
   & (J,RFP3H(J), J=1,NFP3H)  
ENDIF
IF (NFP3TH > 0) THEN
  WRITE(UNIT=NULOUT,FMT='('' (JL RFP3TH)'')')
  WRITE(UNIT=NULOUT,FMT='(10('' ('',I2,1X,F7.0,'')''))')&
   & (J,RFP3TH(J), J=1,NFP3TH)  
ENDIF
IF (NFP3PV > 0) THEN
  WRITE(UNIT=NULOUT,FMT='('' (JL RFP3PV)'')')
  WRITE(UNIT=NULOUT,FMT='(7('' ('',I2,1X,E13.6,'')''))')&
   & (J,RFP3PV(J), J=1,NFP3PV)  
ENDIF
IF (NFP3S > 0) THEN
  WRITE(UNIT=NULOUT,FMT='('' (JL NRFP3S)'')')
  WRITE(UNIT=NULOUT,FMT='(13('' ('',I3,1X,I3,'')''))')&
   & (J,NRFP3S(J), J=1,NFP3S)  
ENDIF

IF(LTRACEFP) THEN
  WRITE(UNIT=NULOUT,FMT='(I3,'' POINTS INTERP. FOR DYN. FIELDS'')')&
   & NFPINDYN  
  WRITE(UNIT=NULOUT,FMT='(I3,'' POINTS INTERP. FOR PHY. FIELDS'')')&
   & NFPINPHY  
ENDIF

CALL SUFPDIM
!     ------------------------------------------------------------------

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