#ifdef RS6K
@PROCESS NOCHECK
#endif
SUBROUTINE CPG(&
 !---------------------------------------------------------------------
 ! - INPUT .
 & CDCONF,LDRETCFOU,LDWRTCFOU0,KGPCOMP, &
 & KBLKS,LDCPG_SPLIT,&
 !---------------------------------------------------------------------
 ! - INPUT/OUTPUT .
 & PGMV,PGMVS, &
 !---------------------------------------------------------------------
 ! - OUTPUT .
 & PB1, PB2, PGMVT1,PGMVT1S,PGFLT1,PEXTRA)

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

USE YOMDIM   , ONLY : NFLEVG   ,NPROMA   ,NPROMM   ,NPROMNH  ,NPROMVC  , &
 & NPROMDLW ,NPROMDLR ,NFGPPC   ,NGPBLKS  ,NDGENL   ,NFLSA    ,NFLEN
USE YOMSLPHY , ONLY : LSLPHY   ,SAVTEND
USE YOMCT0   , ONLY : LSLAG    ,LTWOTL   ,LSPRT    ,LALLOPR  , &
 &          LPC_FULL ,LPC_CHEAP
USE YOMCT3   , ONLY : NSTEP
USE YOMDYN   , ONLY : TSTEP    ,TDT      ,NCURRENT_ITER  ,NSITER   , &
 &          SLHDA    ,SLHDD0
USE YOMDYNA  , ONLY : LSLDIA
USE YOMGC    , ONLY : RCORI    ,GAW      ,GEMU     ,GSQM2    ,GELAM    ,&
 &          GECLO    ,GESLO    ,GM       ,GOMVRL   ,GOMVRM   ,&
 &          GNORDL   ,GNORDM   ,OROG     ,OROGL    ,OROGM    ,&
 &          OROGLL   ,OROGMM   ,OROGLM   ,&
 &          NGPLAT   ,RCORIC   ,GNORDLCL ,GNORDMCL ,GNORDMCM  
USE YOMGEM   , ONLY : NGPTOT   ,RATATH   ,RATATX   ,RCOLON
USE YOMLUN   , ONLY : NULOUT
USE YOMMP    , ONLY : NSLCORE  ,NFRSTLOFF,NASLB1
USE YOMSC2   , ONLY : NFLDSLB1 ,NFLDSLB2
USE YOM_YGFL , ONLY : YGFL     ,YQ       ,YL       ,YI       ,YCPF     , &
 &          YSPF     ,YS       ,YR       ,YG       ,YH       ,YA       , &
 &          YSRC     ,YTKE     ,YEXT     ,YCVGQ    ,YQVA     ,YSDSAT   , &
 &          YCVV     ,YFORC    ,YEZDIAG  ,YDAL     ,YDOM     ,YUEN     , &
 &          YUAL     ,YUOM     ,YUNEBH
USE YOMGFL   , ONLY : GFL      ,GFLSLP   ,GFLPT    ,GFLPC
USE YOMPHY   , ONLY : LMPHYS
USE YOMSIMPHL, ONLY : LSIMPH   
USE YOEPHY   , ONLY : LEPHYS   ,LAGPHY   
USE YOMDPHY  , ONLY : NVEXTRDYN,NVCLIS   ,NTSSG
USE YOMLDDH  , ONLY : LSDDH

USE YOMMDDH  , ONLY : NDHCVSUN 
USE YOMXFU   , ONLY : LRESET
USE SURFACE_FIELDS_MIX  , ONLY :  &
 &          SP_SB    ,YSP_SB   ,YSP_SBD  ,SP_RR    ,YSP_RR   ,SP_SG    , &
 &          YSP_SG   ,SD_VF    ,YSD_VF   ,SD_VP    ,SD_VV    ,SD_VH    , &
 &          SD_VA    ,SD_VC
USE YOMRADF  , ONLY : EMTD     ,EMTU     ,TRSW     ,RMOON 
USE PTRSLB1  , ONLY : MSLB1UP9 ,MSLB1VP9 ,MSLB1TP9 ,MSLB1GFLP9         , &
 &          MSLB1SP9 ,MSLB1GFL9,MSLB1T9  ,MSLB1V9  ,MSLB1U9
USE PTRSLB2  , ONLY : MSLB2VVEL
USE YOMGMV   , ONLY : YT0      ,YT9      ,YT1      ,NDIMGMV  ,NDIMGMVS
USE OML_MOD, ONLY : OML_MY_THREAD
USE YOMARAR  , ONLY : NGPAR
USE YOMCOAPHY, ONLY : NPHYINT
USE PAR_RDLR , ONLY : JP_DIMR9 ,JP_DIMR0

!**** *CPG* - Grid point calculations.

!     Purpose.
!     --------
!           Grid point calculations.

!           The current stage of CPG is rewritten in order to be
!           put in the future routine "GP_MODEL", which will directly
!           call CPG_GP, MF_PHYS, etc...
!           The unlagged physics is now in a separate "jkglo"-loop.

!           Abbreviation "vwv" stands for "vertical wind variable".

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

!        Explicit arguments :
!        --------------------

!     INPUT:
!     ------
!        CDCONF       : configuration of work
!        LDRETCFOU    : .T. -> CPPFTTCINV is called under MF_PHYS.
!        LDWRTCFOU0   : .T. -> CPPFTTCDIR is called under MF_PHYS.
!        KGPCOMP      : total number of grid points:
!                       ndglg*ndlon in global / ndguxg*ndlon in LAM
!                       used for model computations.
!        KBLKS        : ???
!        LDCPG_SPLIT  : see LCPG_SPLIT in YOMCPG.

!     INPUT/OUTPUT:
!     -------------
!        PGMV         : upper air GMV variables at t and t-dt.
!        PGMVS        : surface GMV variables at t and t-dt.

!     OUTPUT:
!     -------
!        PB1          : "SLBUF1" buffer for interpolations in SL scheme.
!        PB2          : "SLBUF2" buffer.
!        PGMVT1       : upper air GMV variables buffer.
!        PGMVT1S      : surface GMV variables buffer.
!        PGFLT1       : GFL variables buffer.
!        PEXTRA       : additional quantity for diagnostics.

!        Implicit arguments :
!        --------------------

!     Method.
!     -------
!        See documentation

!     Externals.
!     ----------

!     Reference.
!     ----------
!        ARPEGE documentation vol 2 ch 1 and vol 3 ch 6

!     Author.
!     -------
!        Philippe Courtier  *DMN*

! Modifications
! -------------
!   Original : 90-03-19
!   Alain Joly, pour l introduction de l'interface physique
!   Modified 91-02-28 by Michel Deque (Relaxation of deep soil values)
!   Modified 91-03-15 by Michel Deque (Ozone parameterization)
!   P. Marquet (91-04-01) : ACUMTND1 and ACUMTND2.
!   Modified 91-04-01 by Michel Deque (pseudo-historical cloudiness)
!   Implantation des cumuls diagnostics DDH, A.Joly, 1-3/91
!   Modified 91-06-05 by Michel Deque (Loops 121 and 941)
!   Modified 91-05-21 by A.Lasserre-Bigorry (scalar variables)
!   Modified 91-06-10 by A.Lasserre-Bigorry (middle atmosphere model)
!   Modified 91-06-25 by A.Lasserre-Bigorry (ozone chemistry)
!   Modified 91-10-01 by Michel Deque (Anisotropic orography variance)
!   Modified 91-11-01 by F Rabier (U V Formulation)
!   Modified 91-11-12 by J.J. Morcrette (ECMWF Physics)
!   Modified 92-01-03 by E.Bazile ( CPTEND and CPUTQY )
!   Modified 92-02-01 by M.H. Hamrud (IO scheme)
!   Modified 92-03-01 by M. Janousek (entropy diagnosis).
!   Modified 92-03-25 by V. Ducrocq and L. Spacek (Cpdyn calls)
!   Modified 92-02-01 by J.M. Piriou (relative humidity diagnosis).
!   Modified 92-04-08 by L. Labbe (ajout de ZQICE).
!   Modified 92-05-02 by H. Giordani P Lemoigne W Maurel
!   Soil and vegetation parametrization.
!   Modified 92-05-10 by M. Deque : update of ozone and cloudiness to cycle 9
!   Modified 92-05-05 by J.M. Piriou (internal areas DDH).
!   Modified 92-05-25 by C. Dreveton (diagnostics)
!   Modified 92-06-01 by M. Janousek (angular momentum diagnosis).
!   Modified 92-05-22 by D. Giard (NNMI for semi-lag. scheme)
!   Modified 92-05-25 by D. Giard (NNMI with deltam, acc. of diab. tend.)
!   Modified 06/92 by O.Clary (ACCUMULATED AND INSTANTANEOUS FLUX)
!   Modified 92-06-18 by C. Dreveton (call of subroutine for diagnostic)
!   Modified 92-07-08 by V. Ducrocq (introduction of a new curvature term
!    and modification of the calls to CPDYN and CPDYDDH)
!   Modified 92-09-16 by D. Giard (NNMI with dm, with physics skipped now)
!   Modified 92-10-28 by D. Giard (no cumul of flux diagnostics during NNMI)
!   Modified 92-10-30 by D. Giard (CDCONF='M' for the last NNMI iteration
!      with the diabatic EMERAUDE scheme --> total tendencies are computed )
!   Modified 92-11-19 by J.J. Morcrette (ECMWF Physics Diagnostics)
!   K. Yessad: 18/12/1992. Non interpolating vertical semi-lag scheme.
!   Modified 92-12-23 by D. Giard (correction of CDCONF='M',time-step)
!   Modified 93-04-08 by D. Giard (time-step for dynamical tendencies)
!   Modified 93-03-29 by C. Dreveton (call ZODIFI and CPCFU)
!   Modified 93-05-10 BY R. EL Khatib : Spectral "brake"
!   Modified 93-05-17 by D. Giard (LLDIAB,LLADNMI)
!   Modified 93-05-24 by D. Giard (ACUMTNDx --> CPACTNDx)
!   Modified 93-06-01 by M. Hortal (prep. for extra diffusion in
!                                   Eulerian model)
!   Modified 93-05-24 by M. Deque (subgrid surface temperature and fluxes)
!   Modified 94-02-14 by E.Bazile ( Surface Fluxes CPCFU )
!   Modified 93-11-17 by Ph. Dandin : FMR scheme with MF physics
!   Modified 94-01-24 by D.Giard (conditions for zonal diagnostics)
!   Modified 93-12-14 by K. YESSAD: interpolations at medium point for
!                                   semi-lagrangian temperature equation.
!   Modified by K. YESSAD  93-12-31 (adding map factor and CFL in ZDI).
!   Modified 93-12-21 by C. Temperton: interpolations at medium point for
!                                   semi-lagrangian moisture equation.
!   Modified 94-03-23 by M. Hortal: interpolations at medium point for
!                                   semi-lagrangian momentum equations.
!   Modified by K. YESSAD and R. EL KHATIB: 18/02/1994:
!                    Harmonisation of enhanced diffusions (LFREIN).
!   Modified 94-07-08 by M. Deque (additional diagnostics for sea-ice)
!   Modified 94-09-05 by M. Deque (aerosols and thermal roughness)
!   Modified 94-10-17 by M. Deque (4-layer soil temperature)
!   Modified 94-05-11 by C. Temperton: spectral RT option
!   Modified 94-06-20 by M.Hamrud : upper air grid-point file
!   Modified 93-09-04 by E. Bazile (Liquid Water )
!   Modified 93-11-10 by R. EL Khatib (Non hydrostatic variables)
!   Modified 94-10-16 by M. Tolstykh: CUD-5 interpolation
!   Modified 94-10-07 by EB and DG (Surface Fluxes CPXFU )
!   K. YESSAD (JAN 1995):
!         - Modification in call to LACUDL for optimisations.
!   Modified 95-01-18 by M.Hamrud (cleaning and splitting)
!   Modified 95-02-06 by C. Temperton: two-time-level scheme
!   Modified 95-03-07 by E. Bazile : Cleaning and the call to CPFHPFS
!                                    and CPUTQY
!   Modified 95-06-06 by D. Giard : time-step for semi-lag. tendencies
!   Modified 95-10-12 by C. Temperton: treatment of orography
!                                      in continuity equation
!   Modified OCT 1995 by K. YESSAD:
!     - Update dimension of Z(X)NLT9 and dummy arguments of LACDYN
!       for accurate 2TL SL scheme and Tanguay/Ritchie modification.
!   Modified 95-11-23 by M. Deque : double call to APLPAR for land/sea.
!   Modified 95-12-07 by M. Janiskova: call for simplified phys.param.
!   Modified 96-03 by A. Untch : grid-point prognostic ozone (EC)
!   Modified APRIL 1996 by K. YESSAD: call to INIPEX.
!   Modified 96-05-29 by D. Giard : CDCONF='X' for initial fluxes
!   Modified 96-06-01 by Th. Lagarde : double physics for land/sea (update)
!   Modified 96-07-03 by M. Deque :  nudging for surface variables
!   Modified 96-11    by M. Janiskova: transmission coef. for simpl.
!                                      radiation scheme
!   Modified 97-02    by J.M. Piriou: soil inertia to diagnostics.
!   Modified 97-03-10 by JPh. Piedelievre : call to CPCFU
!   Modified 97-05-10 by M. Deque : frozen FMR
!   Modified 97-07-11 by P. Le Moigne :
!     - Dimensioning of OROGLL, OROGLM and OROGMM to NPROMNH
!   Modified 97-08    by J.M. Piriou: APLPAR's arguments lock.
!   Modified 97-11-19 By E. Bazile: Soil freezing (LFGEL IF LSOLV)
!   Modified 97-11-07 by R. EL Khatib (RT+derivatives computed in GPRT)
!   Modified 98-01-05 by E. Holm: Ozone in Eulerian model (for assimilation)
!   Modified 98-01-07 by M. Deque : nudging and PRCORI to APLPAR
!   Modified 98-05-26 by E. Holm: Order of ozone in call to LACDYN changed
!   Modified 98-07-31 by K. YESSAD: cleanings.
!     - Bug correction in CALL CPUTQY for liquid water/ice in SL.
!     - Removal of 2TLSL options requiring an anterior point.
!     - Removal of the useless dummy argument PSQM2.
!     - No longer third dimension to 'NLT9' arrays (removal of VESLA).
!   Modified 98-08-10 by K. YESSAD: removal of LRPOLE option.
!    - LRPOLE removed from YOMCT0 and 'CALL INIPEX'.
!   Modified 98-09-01 by N. Wedi: split physics in semi-lagrangian mode
!   Modified 98-09-01 by P. Le Moigne : LAM case, land sea mask value
!                        in the extension zone (op only).
!   Modified 99-02-21 by M. Janiskova: reading and writting radiation
!                        coefficients in the level of cpg
!   Modified 98-10-21 by Z. Bencetic Klaic: control on NTOZ1D
!   Modified 98-12-04 by K. YESSAD: option 'lradvtoro'.
!   Modified 99-01-04 By E. Bazile: Surface Soil freezing.
!   Modified 99-01-04 by P. Le Moigne : LAM case, land sea mask value
!                        in the extension zone (op only).
!   Modified 99-08-20 by C. Temperton: write semi-Lagrangian trajectory
!   Modified 99-09-17 by C. Temperton: change CPDYN call to enable
!                        the combination Eulerian + LIMPF
!   Modified 99-10-06 by C. Temperton: VDIFLCZ for semi-Lagrangian
!   Modified 99-02-01 by M. Charron : non-hydrostatic
!   Modified 99-02-17 by K. YESSAD: options LRETCFOU, LWRTCFOU.
!   Modified 99-03-31 by P. SMOLIKOVA: option LRDAORG (double averaging).
!   Modified 99-04-19 by J.M. Piriou: Moon radiation.
!   Modified 99-06-04 by J.Vivoda: Sponge for 2D plane model (LEPONGE)
!   Modified 99-07-19 by D. Giard : LINITER moved from YOMNMIA to YOMINI
!   Modified 00-02-14 by C. Temperton: LSLAG for NCONF=601
!   Modified 99-11-15 by K. YESSAD: cleanings.
!    - 'lrubc' and 'delta m=1' cases rewritten in a more consistent manner.
!    - avoid duplication of the same calculation of divergence integral
!      in "gpcty" and "lattes".
!   Modified 2000-04-03 E. Bazile & R. El Khatib - CAPE etc.
!   Modified 2000-08-16 K.YESSAD: relaxation of thin layer hypothesis in
!    the Eulerian hydrostatic model (adiabatic part) and in the DDH.
!   Modified 2000-06-13 R. El Khatib - Height of PBL & gusts
!   Modified 2000-07-07 E. Bazile (j'ai signe !) and R. El Khatib - MOCON
!   Modified 2000-10-02 C. Fischer : call gnhsim (moved from scan2m)
!   Modified 2000-10-10 R. El Khatib No large scale precip. contrib. for mocon.
!   Modified 00-10-10 by C. Temperton: LSLAG for NCONF=801
!   Modified 2000-12-04 F. Bouyssel & J.M. Piriou: move away APLPAR from CPG
!   Modified 01-01-16 R. El Khatib Interface for CPXFU
!   Modified 2001-02-08 K. YESSAD and F. BOUYSSEL: debug code for SL2TL.
!   Modified 2001-02-08 K. YESSAD and F. BOUYSSEL: debug code for SL2TL.
!   Modified 2001-08-20 K. YESSAD: complete rewriting and cleaning.
!   Modified 01-09-24 R. El Khatib : no loop index while calling mf_phys
!   Modified 01-06-22 by K. YESSAD:
!    - relaxation of thin layer hypothesis for SL3TL.
!   Modified 01-08-30 by K. YESSAD: pruning and some other cleanings.
!   Modified 2001-08-07 R. El Khatib - pruning options
!   Modified 15-10-01 D.Salmond FULLIMP mods
!   Modified 03-2002  J.Vivoda : PC schemes for NH dynamics (LPC_XXXX keys)
!   Modified 10-2002  C.Moussy : Allocation under the key LTENC
!   Modified 30-09-02  P.Smolikova : variable d4 in NH
!   Modified 12-10-2002 J.Masek: PC bugfix, removed YOMPONG
!   Modified 08-2002 C. Smith : use "w" as prognostic variable in the
!    semi-lag advection of vertical divergence in the NH model.
!   Modified 31-01-03  P.Smolikova : variable d4 in 2tl PC NH
!   Modified 2003-02-16 J. Hague - Single Parallel Loop Option
!   Modified 2003-03-16 M.Hamrud - Revised data flow (GFL)
!   Modified 2003-07-16 C. Fischer - gppaux goes into gmv and pb2aux
!   Modified 2003-08-25 F. Vana - SL diffusion
!   Modified 2003-08    P. Smolikova - option LRDBBC
!   Modified 2003-10-06 Y. Bouteloup - modifications for SCM extraction
!    (call mf_phys)
!   Modified 2003-10-17 M. Tudor - YCPF and YSPF from GFL
!   Modified 2003-10-31 M. Tudor - GFLPT and call cpg_pt
!   01-Oct-2003 M. Hamrud  CY28 Cleaning
!   2003-11-25 M. Hortal - include extra-fields coming from the dynamics
!   12-Dec-2003 F. Vinit   new input for cpg_dia: output of APLPAR: 
!                          PALB, PGZ0, PGZ0H.
!   12-Jan-2004 K. YESSAD  remove ZSPT0.., ZZSPT9.., use GMVS instead.
!   09-Jun-2004 J. Masek   NH cleaning (LPC_NOTR, LFULLIMP)
!   01-Jul-2004 K. Yessad  Make clearer the tests for PC scheme.
!   06-Jul-2004 K. Yessad  Pointers of PTRGPPC are now computed in SUDIM2.
!   26-Mar-2004 Y. Bouteloup  Introduction of MTS radiance
!   28-Oct-2004 A. Trojakova phasing CY29 
!   20-Feb-2005 J. Vivoda  3TL PC Eulerian scheme, GWADV scheme for PC_FULL 
!   2004-11-19 Y. Seity - new argument for AROME physics. W computation.
!   12-Jan-2005 K. Yessad: GNHPDVD replaced by GP./GNH. routines in CPG_GP.
!   22-Nov-2005 D.Salmond & M.Hortal  Mods for coarser/finer physics
!   28-Sep-2005 Y. Seity : add YEXT to mf_phys and cpg_pt
!   05-APR-2006 T. Kovacic: added ZGPAR in CPG_DIA
!   07-Mar-2006 R. Zaaboul: new arguments for MF_PHYS (IBL,IGPCOMP) for 
!                           ARO_GROUND_PARAM
!   05-Oct-2005 A. Alias : ZDRNSHF added (JF Royer)
!   25-Jan-2006 F. Bouyssel: New ZFPEVPL/N Remove ZFPEVPP,ZFADVP,ZFHMLTS,ZFHEVPP
!   01-Jun-2006 B. Sass:  New pseudo-prognostic field YQVA in GFL.
!   08-Jun-2006 F. Vana two new arguments to CPG_DYN
!   06-03-2006  A. Alias : YSDSAT and YCVV fields added in MF_PHYS (JF GUEREMY)
!   04-Oct-2006 M. Bellus : added YDAL, YDOM, YUEN, YUAL, YUOM and
!                           YUNEBH (for L.Gerard's MAC scheme)
!   01-Jul-2006 M.Hamrud : Revised surface fields
!   24-Feb-2007 R. Brozkova: autoconversion and prec. evaporation fluxes split
!                            to resolved and convective contributions.
!   04-Apr-2007 M.Janousek: OMP bf.
!   10-Apr-2007 S.Ivatek-S: NEC Intialisation size of ZGPAR and ZGPNH 
!   13-Apr-2007 S.Ivatek-S: Bf. initalisation of ZVMX
!   17-Apr-2007 S.Ivatek-S: Over dimensioning of ZGPAR to NGPAR+1 and ZGPNH to 
!                           NFGPNH+1, boundary checking problem if NGPAR=0 bf
!   31-May-2007 T.Kovacic:  ZFCQRNG, ZFCQSNG, ZFEPFP, ZFCMPCQ, ZFCMPSN, ZFCMPSL
!   N. Wedi and K. Yessad (Jan 2008): different dev for NH model and PC scheme
!   18-Dec-2007 Y.Seity  :  add Hail (YH GFL) for AROME  
!    4-Mar-2008 Y. Seity : Cleaning IR and WV similated sat pictures
!                            (replaced by Fullpos Calculations)
!   K. Yessad (Sep 2008): prune enhanced diffusion (lfrein).
!   18-Nov-2008 R.Brozkova: OpenMP bugfix 
!   K. Yessad (Dec 2008): remove dummy CDLOCK + cleanings
! End Modifications
!------------------------------------------------------------------------------

IMPLICIT NONE

CHARACTER(LEN=1)  ,INTENT(IN)    :: CDCONF 
LOGICAL           ,INTENT(IN)    :: LDRETCFOU 
LOGICAL           ,INTENT(IN)    :: LDWRTCFOU0 
INTEGER(KIND=JPIM),INTENT(IN)    :: KGPCOMP 
INTEGER(KIND=JPIM),INTENT(IN)    :: KBLKS 
LOGICAL           ,INTENT(IN)    :: LDCPG_SPLIT 
REAL(KIND=JPRB)   ,INTENT(INOUT) :: PGMV(NPROMA,NFLEVG,NDIMGMV,NGPBLKS) 
REAL(KIND=JPRB)   ,INTENT(INOUT) :: PGMVS(NPROMA,NDIMGMVS,NGPBLKS) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PB1(NASLB1,NFLDSLB1) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PB2(NPROMA,NFLDSLB2,NGPBLKS) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PGMVT1(NPROMA,NFLEVG,YT1%NDIM,NGPBLKS) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PGMVT1S(NPROMA,YT1%NDIMS,NGPBLKS) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PGFLT1(NPROMA,NFLEVG,YGFL%NDIM1,NGPBLKS) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PEXTRA(NPROMA,NFLEVG,NVEXTRDYN,NGPBLKS)

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

! - semi-reduced derivatives of orography.
REAL(KIND=JPRB) :: ZOROGL(NPROMA,KBLKS)              ! cf. POROGL in CPG_GP
REAL(KIND=JPRB) :: ZOROGM(NPROMA,KBLKS)              ! cf. POROGM in CPG_GP
! - other auxiliary quantities at time 0.
REAL(KIND=JPRB) :: ZPRE0(NPROMA,0:NFLEVG,KBLKS)      ! cf. PRE0 in CPG_GP
REAL(KIND=JPRB) :: ZPRE0F(NPROMA,NFLEVG,KBLKS)       ! cf. PRE0F in CPG_GP
REAL(KIND=JPRB) :: ZPRE0L(NPROMA,KBLKS)              ! cf. PRE0L in CPG_GP
REAL(KIND=JPRB) :: ZPRE0M(NPROMA,KBLKS)              ! cf. PRE0M in CPG_GP
REAL(KIND=JPRB) :: ZNHPRE0F(NPROMNH,NFLEVG,KBLKS)    ! cf. PNHPRE0F in CPG_GP
REAL(KIND=JPRB) :: ZNHPRE0H(NPROMNH,0:NFLEVG,KBLKS)  ! cf. PNHPRE0H in CPG_GP
REAL(KIND=JPRB) :: ZPRE0_PHY(NPROMA,0:NFLEVG,KBLKS)  ! true pressure for physics
                                                     ! /= ZPRE0 in NH, = in H  
REAL(KIND=JPRB) :: ZPRE0F_PHY(NPROMA,NFLEVG,KBLKS)   ! true pressure for physics
                                                     ! /= ZPRE0F in NH, = in H  
REAL(KIND=JPRB) :: ZRT0L(NPROMA,NFLEVG,KBLKS)        ! cf. PRT0L in CPG_GP
REAL(KIND=JPRB) :: ZRT0M(NPROMA,NFLEVG,KBLKS)        ! cf. PRT0M in CPG_GP
REAL(KIND=JPRB) :: ZDELP0(NPROMA,0:NFLEVG+1,KBLKS)   ! cf. PDELP0 in CPG_GP
REAL(KIND=JPRB) :: ZRDELP0(NPROMA,NFLEVG,KBLKS)      ! cf. PRDELP0 in CPG_GP
REAL(KIND=JPRB) :: ZLNPR0(NPROMA,NFLEVG,KBLKS)       ! cf. PLNPR0 in CPG_GP
REAL(KIND=JPRB) :: ZALPH0(NPROMA,NFLEVG,KBLKS)       ! cf. PALPH0 in CPG_GP
REAL(KIND=JPRB) :: ZRTGR0(NPROMA,NFLEVG,KBLKS)       ! cf. PRTGR0 in CPG_GP
REAL(KIND=JPRB) :: ZWW0(NPROMA,NFLEVG,KBLKS)         ! cf. PWW0 in CPG_GP
REAL(KIND=JPRB) :: ZRRED0(NPROMNH,NFLEVG,KBLKS)      ! cf. PRRED0 in CPG_GP
REAL(KIND=JPRB) :: ZSGRTL(NPROMA,NFLEVG,KBLKS)       ! cf. PSGRTL in CPG_GP
REAL(KIND=JPRB) :: ZSGRTM(NPROMA,NFLEVG,KBLKS)       ! cf. PSGRTM in CPG_GP
REAL(KIND=JPRB) :: ZGPHL(NPROMA,0:NFLEVG,KBLKS)      ! cf. PGPHL in CPG_GP
REAL(KIND=JPRB) :: ZGPHM(NPROMA,0:NFLEVG,KBLKS)      ! cf. PGPHM in CPG_GP
REAL(KIND=JPRB) :: ZLHU0(NPROMA,0:NFLEVG,KBLKS)      ! cf. PLHU0 in CPG_GP
REAL(KIND=JPRB) :: ZLHV0(NPROMA,0:NFLEVG,KBLKS)      ! cf. PLHV0 in CPG_GP
REAL(KIND=JPRB) :: ZR0(NPROMA,NFLEVG,KBLKS)          ! cf. PR0 in CPG_GP
REAL(KIND=JPRB) :: ZCP0(NPROMA,NFLEVG,KBLKS)         ! cf. PCP0 in CPG_GP
REAL(KIND=JPRB) :: ZKAP0(NPROMA,NFLEVG,KBLKS)        ! cf. PKAP0 in CPG_GP
REAL(KIND=JPRB) :: ZPHI0(NPROMA,0:NFLEVG,KBLKS)      ! cf. PHI0 in CPG_GP
REAL(KIND=JPRB) :: ZPHIF0(NPROMA,NFLEVG,KBLKS)       ! cf. PHIF0 in CPG_GP
REAL(KIND=JPRB) :: ZPHI0FL(NPROMA,NFLEVG,KBLKS)      ! cf. PHI0FL in CPG_GP
REAL(KIND=JPRB) :: ZPHI0FM(NPROMA,NFLEVG,KBLKS)      ! cf. PHI0FM in CPG_GP
REAL(KIND=JPRB) :: ZEVEL0(NPROMA,0:NFLEVG,KBLKS)     ! cf. PEVEL0 in CPG_GP
REAL(KIND=JPRB) :: ZSDIV0(NPROMA,0:NFLEVG,KBLKS)     ! cf. PSDIV0 in CPG_GP
REAL(KIND=JPRB) :: ZSDVBC0(NPROMA,0:NFLEVG,KBLKS)    ! cf. PSDVBC0 in CPG_GP
REAL(KIND=JPRB) :: ZVVEL0(NPROMA,NFLEVG,KBLKS)       ! cf. PVVEL0 in CPG_GP
REAL(KIND=JPRB) :: ZGWFT0(NPROMA,NFLEVG,KBLKS)       ! cf. PGWFT0 in CPG_GP
REAL(KIND=JPRB) :: ZSDFI0(NPROMA,0:NFLEVG,KBLKS)     ! cf. PSDFI0 in CPG_GP
REAL(KIND=JPRB) :: ZDIVP0(NPROMA,NFLEVG,KBLKS)       ! cf. PDIVP0 in CPG_GP
REAL(KIND=JPRB) :: ZKENE0(NPROMA,NFLEVG,KBLKS)       ! cf. PKENE0 in CPG_GP
REAL(KIND=JPRB) :: ZVCTS0F(NPROMVC,NFLEVG,KBLKS)     ! cf. PVCTS0F in CPG_GP
REAL(KIND=JPRB) :: ZVCRSSA0F(NPROMVC,NFLEVG,KBLKS)   ! cf. PVCRSSA0F in CPG_GP
REAL(KIND=JPRB) :: ZVCRSSA0H(NPROMVC,0:NFLEVG,KBLKS) ! cf. PVCRSSA0H in CPG_GP
REAL(KIND=JPRB) :: ZVCASRS0F(NPROMVC,NFLEVG,KBLKS)   ! cf. PVCASRS0F in CPG_GP
REAL(KIND=JPRB) :: ZVCASRS0H(NPROMVC,0:NFLEVG,KBLKS) ! cf. PVCASRS0H in CPG_GP
REAL(KIND=JPRB) :: ZVCRSSA0FL(NPROMVC,NFLEVG,KBLKS)  ! cf. PVCASRS0FL in CPG_GP
REAL(KIND=JPRB) :: ZVCRSSA0FM(NPROMVC,NFLEVG,KBLKS)  ! cf. PVCASRS0FM in CPG_GP
REAL(KIND=JPRB) :: ZVCMUS0F(NPROMVC,NFLEVG,KBLKS)    ! cf. PVCMUS0F in CPG_GP
REAL(KIND=JPRB) :: ZVCW0F(NPROMVC,NFLEVG,KBLKS)      ! cf. PVCW0F in CPG_GP
REAL(KIND=JPRB) :: ZWDLW0F(NPROMDLW,NFLEVG,KBLKS)    ! cf. PWDLW0F in CPG_GP
REAL(KIND=JPRB) :: ZRDLR0(NPROMDLR,0:NFLEVG,JP_DIMR0,KBLKS)
REAL(KIND=JPRB) :: ZRDLR9(NPROMDLR,0:NFLEVG,JP_DIMR9,KBLKS)
REAL(KIND=JPRB) :: ZW0(NPROMA,NFLEVG,KBLKS)          ! for AROME Physics
REAL(KIND=JPRB) :: ZTNDPD(NPROMNH,NFLEVG,KBLKS)      ! cf. PTNDPD in CPG_GP
REAL(KIND=JPRB) :: ZTNDVD(NPROMNH,NFLEVG,KBLKS)      ! cf. PTNDVD in CPG_GP
REAL(KIND=JPRB) :: ZTNDGW(NPROMNH,NFLEVG,KBLKS)      ! cf. PTNDGW in CPG_GP
REAL(KIND=JPRB) :: Z3DIVG(NPROMNH,NFLEVG,KBLKS)      ! cf. P3DIVG in CPG_GP
REAL(KIND=JPRB) :: ZD3Y0(NPROMNH,NFLEVG,KBLKS)       ! cf. PD3Y0 in CPG_GP
REAL(KIND=JPRB) :: ZNHX0(NPROMA,NFLEVG,KBLKS)        ! cf. PNHXT0 in CPG_GP
REAL(KIND=JPRB) :: ZQCHA0L(NPROMNH,NFLEVG,KBLKS)     ! cf. PQCHA0L in CPG_GP
REAL(KIND=JPRB) :: ZQCHA0M(NPROMNH,NFLEVG,KBLKS)     ! cf. PQCHA0M in CPG_GP
REAL(KIND=JPRB) :: ZDBBC(NPROMNH,KBLKS)              ! cf. PDBBC in CPG_GP
REAL(KIND=JPRB) :: ZRDPHI(NPROMNH,NFLEVG,KBLKS)      ! cf. PRDPHI in CPG_GP
REAL(KIND=JPRB) :: ZGWT0(NPROMNH,NFLEVG,KBLKS)       ! cf. PGWT0 in CPG_GP
REAL(KIND=JPRB) :: ZGWS(NPROMNH,KBLKS)               ! cf. PGWS in CPG_GP
REAL(KIND=JPRB) :: ZPREHYD0F_PHY(NPROMA,NFLEVG,KBLKS)
REAL(KIND=JPRB) :: ZPREHYD0_PHY(NPROMA,0:NFLEVG,KBLKS)
REAL(KIND=JPRB) :: ZDELP0_PHY(NPROMA,0:NFLEVG+1,KBLKS)
REAL(KIND=JPRB) :: ZRDELP0_PHY(NPROMA,NFLEVG,KBLKS)
REAL(KIND=JPRB) :: ZLNPR0_PHY(NPROMA,NFLEVG,KBLKS)
REAL(KIND=JPRB) :: ZALPH0_PHY(NPROMA,NFLEVG,KBLKS)
! - miscellaneous.
REAL(KIND=JPRB) :: ZKOZO(NPROMA,NFLEVG*NVCLIS+1,KBLKS) ! cf. PKOZO in CPG_GP
REAL(KIND=JPRB) :: ZNEB(NPROMA,NFLEVG)                 ! cf. PNEB in MF_PHYS
REAL(KIND=JPRB) :: ZQLI(NPROMA,NFLEVG,KBLKS)           ! cf. PQLI in CPG_GP
REAL(KIND=JPRB) :: ZQICE(NPROMA,NFLEVG,KBLKS)          ! cf. PQICE in CPG_GP
! - quantities for physics.
REAL(KIND=JPRB) :: ZDIFCQ(NPROMM,0:NFLEVG)           ! cf. PDIFCQ in MF_PHYS
REAL(KIND=JPRB) :: ZDIFCQL(NPROMM,0:NFLEVG)          ! cf. PDIFCQL in MF_PHYS
REAL(KIND=JPRB) :: ZDIFCQN(NPROMM,0:NFLEVG)          ! cf. PDIFCQN in MF_PHYS
REAL(KIND=JPRB) :: ZDIFCS(NPROMM,0:NFLEVG)           ! cf. PDIFCS in MF_PHYS
REAL(KIND=JPRB) :: ZDIFTQ(NPROMM,0:NFLEVG)           ! cf. PDIFTQ in MF_PHYS
REAL(KIND=JPRB) :: ZDIFTQL(NPROMM,0:NFLEVG)          ! cf. PDIFTQL in MF_PHYS
REAL(KIND=JPRB) :: ZDIFTQN(NPROMM,0:NFLEVG)          ! cf. PDIFTQN in MF_PHYS
REAL(KIND=JPRB) :: ZDIFTS(NPROMM,0:NFLEVG)           ! cf. PDIFTS in MF_PHYS
REAL(KIND=JPRB) :: ZFCCQL(NPROMM,0:NFLEVG)           ! cf. PFCCQL in MF_PHYS
REAL(KIND=JPRB) :: ZFCCQN(NPROMM,0:NFLEVG)           ! cf. PFCCQN in MF_PHYS
REAL(KIND=JPRB) :: ZFCSQL(NPROMM,0:NFLEVG)           ! cf. PFCSQL in MF_PHYS
REAL(KIND=JPRB) :: ZFCSQN(NPROMM,0:NFLEVG)           ! cf. PFCSQN in MF_PHYS
REAL(KIND=JPRB) :: ZFCQLNG(NPROMM,0:NFLEVG)          ! cf. PFCQLNG in MF_PHYS
REAL(KIND=JPRB) :: ZFCQNNG(NPROMM,0:NFLEVG)          ! cf. PFCQNNG in MF_PHYS
REAL(KIND=JPRB) :: ZFCQNG(NPROMM,0:NFLEVG)           ! cf. PFCQNG in MF_PHYS
REAL(KIND=JPRB) :: ZFPLCL(NPROMM,0:NFLEVG)           ! cf. PFPLCL in MF_PHYS
REAL(KIND=JPRB) :: ZFPLCN(NPROMM,0:NFLEVG)           ! cf. PFPLCN in MF_PHYS
REAL(KIND=JPRB) :: ZFPLCG(NPROMM,0:NFLEVG)           ! cf. PFPLCG in MF_PHYS
REAL(KIND=JPRB) :: ZFPLCH(NPROMM,0:NFLEVG)           ! cf. PFPLCH in MF_PHYS
REAL(KIND=JPRB) :: ZFPLSL(NPROMM,0:NFLEVG)           ! cf. PFPLSL in MF_PHYS
REAL(KIND=JPRB) :: ZFPLSN(NPROMM,0:NFLEVG)           ! cf. PFPLSN in MF_PHYS
REAL(KIND=JPRB) :: ZFPLSG(NPROMM,0:NFLEVG)           ! cf. PFPLSG in MF_PHYS
REAL(KIND=JPRB) :: ZFPLSH(NPROMM,0:NFLEVG)           ! cf. PFPLSH in MF_PHYS
REAL(KIND=JPRB) :: ZFPFPSL(NPROMM,0:NFLEVG)          ! cf. PFPFPSL in MF_PHYS.
REAL(KIND=JPRB) :: ZFPFPSN(NPROMM,0:NFLEVG)          ! cf. PFPFPSN in MF_PHYS.
REAL(KIND=JPRB) :: ZFPFPCL(NPROMM,0:NFLEVG)          ! cf. PFPFPCL in MF_PHYS.
REAL(KIND=JPRB) :: ZFPFPCN(NPROMM,0:NFLEVG)          ! cf. PFPFPCN in MF_PHYS.
REAL(KIND=JPRB) :: ZFPEVPSL(NPROMM,0:NFLEVG)         ! cf. PFPEVPSL in MF_PHYS.
REAL(KIND=JPRB) :: ZFPEVPSN(NPROMM,0:NFLEVG)         ! cf. PFPEVPSN in MF_PHYS.
REAL(KIND=JPRB) :: ZFPEVPCL(NPROMM,0:NFLEVG)         ! cf. PFPEVPCL in MF_PHYS.
REAL(KIND=JPRB) :: ZFPEVPCN(NPROMM,0:NFLEVG)         ! cf. PFPEVPCN in MF_PHYS.
REAL(KIND=JPRB) :: ZFRSO(NPROMM,0:NFLEVG,NTSSG+1)    ! cf. PFRSO in MF_PHYS
REAL(KIND=JPRB) :: ZFRTH(NPROMM,0:NFLEVG,NTSSG+1)    ! cf. PFRTH in MF_PHYS
REAL(KIND=JPRB) :: ZSTRCU(NPROMM,0:NFLEVG)           ! cf. PSTRCU in MF_PHYS
REAL(KIND=JPRB) :: ZSTRCV(NPROMM,0:NFLEVG)           ! cf. PSTRCV in MF_PHYS
REAL(KIND=JPRB) :: ZSTRDU(NPROMM,0:NFLEVG)           ! cf. PSTRDU in MF_PHYS
REAL(KIND=JPRB) :: ZSTRDV(NPROMM,0:NFLEVG)           ! cf. PSTRDV in MF_PHYS
REAL(KIND=JPRB) :: ZSTRTU(NPROMM,0:NFLEVG)           ! cf. PSTRTU in MF_PHYS
REAL(KIND=JPRB) :: ZSTRTV(NPROMM,0:NFLEVG)           ! cf. PSTRTV in MF_PHYS
REAL(KIND=JPRB) :: ZSTRMU(NPROMM,0:NFLEVG)           ! cf. PSTRMU in MF_PHYS
REAL(KIND=JPRB) :: ZSTRMV(NPROMM,0:NFLEVG)           ! cf. PSTRMV in MF_PHYS
REAL(KIND=JPRB) :: ZFRMH(NPROMM,0:NFLEVG)            ! cf. PFRMH in MF_PHYS
REAL(KIND=JPRB) :: ZFCHOZ(NPROMM,0:NFLEVG)           ! cf. PFCHOZ in MF_PHYS
REAL(KIND=JPRB) :: ZFDIS (NPROMM,0:NFLEVG)           ! cf. PFDIS in MF_PHYS
REAL(KIND=JPRB) :: ZFHPSL(NPROMM,0:NFLEVG)           ! cf. PFHPSL in MF_PHYS
REAL(KIND=JPRB) :: ZFHPSN(NPROMM,0:NFLEVG)           ! cf. PFHPSN in MF_PHYS
REAL(KIND=JPRB) :: ZFHPCL(NPROMM,0:NFLEVG)           ! cf. PFHPCL in MF_PHYS
REAL(KIND=JPRB) :: ZFHPCN(NPROMM,0:NFLEVG)           ! cf. PFHPCN in MF_PHYS
REAL(KIND=JPRB) :: ZFHSCL(NPROMM,0:NFLEVG)           ! cf. PFHSCL in MF_PHYS
REAL(KIND=JPRB) :: ZFHSCN(NPROMM,0:NFLEVG)           ! cf. PFHSCN in MF_PHYS
REAL(KIND=JPRB) :: ZFHSSL(NPROMM,0:NFLEVG)           ! cf. PFHSSL in MF_PHYS
REAL(KIND=JPRB) :: ZFHSSN(NPROMM,0:NFLEVG)           ! cf. PFHSSN in MF_PHYS
REAL(KIND=JPRB) :: ZFEPFP(NPROMM,0:NFLEVG)           ! cf. PFEPFP  in MF_PHYS
REAL(KIND=JPRB) :: ZFCMPCQ(NPROMM,0:NFLEVG)          ! cf. PFCMPCQ in MF_PHYS
REAL(KIND=JPRB) :: ZFCMPSN(NPROMM,0:NFLEVG)          ! cf. PFCMPSN in MF_PHYS
REAL(KIND=JPRB) :: ZFCMPSL(NPROMM,0:NFLEVG)          ! cf. PFCMPSL in MF_PHYS
REAL(KIND=JPRB) :: ZRH(NPROMA,NFLEVG)                ! cf. PRH in MF_PHYS
REAL(KIND=JPRB) :: ZFRSOC(NPROMM,0:1)                ! cf. PFRSOC in MF_PHYS
REAL(KIND=JPRB) :: ZFRTHC(NPROMM,0:1)                ! cf. PFRTHC in MF_PHYS
REAL(KIND=JPRB) :: ZFCHSP(NPROMM,YSP_SBD%NLEVS)      ! cf. PFCHSP in MF_PHYS
REAL(KIND=JPRB) :: ZFCLL(NPROMM,NTSSG+1)             ! cf. PFCLL in MF_PHYS
REAL(KIND=JPRB) :: ZFCLN(NPROMM,NTSSG+1)             ! cf. PFCLN in MF_PHYS
REAL(KIND=JPRB) :: ZFCS(NPROMM,NTSSG+1)              ! cf. PFCS in MF_PHYS
REAL(KIND=JPRB) :: ZFEVL(NPROMM,NTSSG+1)             ! cf. PFEVL in MF_PHYS
REAL(KIND=JPRB) :: ZFEVN(NPROMM,NTSSG+1)             ! cf. PFEVN in MF_PHYS
REAL(KIND=JPRB) :: ZFEVV(NPROMM)                     ! cf. PFEVV in MF_PHYS
REAL(KIND=JPRB) :: ZFLWSP(NPROMM)                    ! cf. PFLWSP in MF_PHYS
REAL(KIND=JPRB) :: ZFTR(NPROMM)                      ! cf. PFTR in MF_PHYS
REAL(KIND=JPRB) :: ZFRSODS(NPROMM)                   ! cf. PFRSODS in MF_PHYS
REAL(KIND=JPRB) :: ZFRSOPS(NPROMM)                   ! cf. PFRSOPS in MF_PHYS
REAL(KIND=JPRB) :: ZFRTHDS(NPROMM)                   ! cf. PFRTHDS in MF_PHYS
REAL(KIND=JPRB) :: ZFONTE(NPROMM)                    ! cf. PFONTE in MF_PHYS
REAL(KIND=JPRB) :: ZFGEL(NPROMM)                     ! cf. PFGEL in MF_PHYS
REAL(KIND=JPRB) :: ZFGELS(NPROMM)                    ! cf. PFGELS in MF_PHYS
REAL(KIND=JPRB) :: ZALB(NPROMM)                      ! cf. PALB in MF_PHYS
REAL(KIND=JPRB) :: ZGZ0(NPROMM)                      ! cf. PGZ0 in MF_PHYS
REAL(KIND=JPRB) :: ZGZ0H(NPROMM)                     ! cf. PGZ0H in MF_PHYS
REAL(KIND=JPRB) :: ZRUISL(NPROMM)                    ! cf. PRUISL in MF_PHYS
REAL(KIND=JPRB) :: ZRUISP(NPROMM)                    ! cf. PRUISP in MF_PHYS
REAL(KIND=JPRB) :: ZRUISS(NPROMM)                    ! cf. PRUISS in MF_PHYS
REAL(KIND=JPRB) :: ZFRSOPT(NPROMM)                   ! cf. PFRSOPT in MF_PHYS
REAL(KIND=JPRB) :: ZFRSOLU(NPROMM)                   ! cf. PFRSOLU in MF_PHYS
REAL(KIND=JPRB) :: ZQS(NPROMA,KBLKS)                 ! cf. PQS in MF_PHYS
REAL(KIND=JPRB) :: ZQCLS(NPROMM)                     ! cf. PQCLS in MF_PHYS
REAL(KIND=JPRB) :: ZTCLS(NPROMM)                     ! cf. PTCLS in MF_PHYS
REAL(KIND=JPRB) :: ZUCLS(NPROMM)                     ! cf. PUCLS in MF_PHYS
REAL(KIND=JPRB) :: ZVCLS(NPROMM)                     ! cf. PVCLS in MF_PHYS
REAL(KIND=JPRB) :: ZRHCLS(NPROMM)                    ! cf. PRHCLS in MF_PHYS
REAL(KIND=JPRB) :: ZCLCT(NPROMA)                     ! cf. PCLCT in MF_PHYS
REAL(KIND=JPRB) :: ZCLCH(NPROMM)                     ! cf. PCLCH in MF_PHYS
REAL(KIND=JPRB) :: ZCLCM(NPROMM)                     ! cf. PCLCM in MF_PHYS
REAL(KIND=JPRB) :: ZCLCL(NPROMM)                     ! cf. PCLCL in MF_PHYS
REAL(KIND=JPRB) :: ZCLCC(NPROMM)                     ! cf. PCLCC in MF_PHYS
REAL(KIND=JPRB) :: ZCLPH(NPROMM)                     ! cf. PCLPH in MF_PHYS
REAL(KIND=JPRB) :: ZDRNSHF(NPROMM)                   ! cf. PDERNSHF in MF_PHYS
REAL(KIND=JPRB) :: ZCAPE(NPROMM)                     ! cf. PCAPE in MF_PHYS
REAL(KIND=JPRB) :: ZMOCON(NPROMM)                    ! cf. PMOCON in MF_PHYS
REAL(KIND=JPRB) :: ZUGST(NPROMM)                     ! cf. PUGST in MF_PHYS
REAL(KIND=JPRB) :: ZVGST(NPROMM)                     ! cf. PVGST in MF_PHYS
REAL(KIND=JPRB) :: ZCT(NPROMA)                       ! cf. PCT in MF_PHYS
REAL(KIND=JPRB) :: ZQSOL(NPROMA,KBLKS)               ! cf. PQSOL in MF_PHYS
REAL(KIND=JPRB) :: ZDHSF(NPROMA)                     ! cf. PDHSF in CPG_DIA
REAL(KIND=JPRB) :: ZDHCV(NPROMA,0:NFLEVG,NDHCVSUN)   ! cf. PDHCV in CPG_DIA
REAL(KIND=JPRB) :: ZTENDU(NPROMM,NFLEVG)             ! cf. PTENDU in MF_PHYS
REAL(KIND=JPRB) :: ZTENDV(NPROMM,NFLEVG)             ! cf. PTENDV in MF_PHYS
REAL(KIND=JPRB) :: ZFCQRNG(NPROMM,0:NFLEVG)          ! cf. PFCQRNG in MF_PHYS
REAL(KIND=JPRB) :: ZFCQSNG(NPROMM,0:NFLEVG)          ! cf. PFCQSNG in MF_PHYS
! - quantities at time 9 (could become 'allocatable' later).
REAL(KIND=JPRB) :: ZW9(NPROMA,NFLEVG,KBLKS)          ! for AROME Physics
! - other auxiliary quantities at time 9.
REAL(KIND=JPRB),ALLOCATABLE :: ZPRE9(:,:,:)          ! cf. PRE9 in CPG_GP
REAL(KIND=JPRB),ALLOCATABLE :: ZPRE9F(:,:,:)         ! cf. PRE9F in CPG_GP
REAL(KIND=JPRB),ALLOCATABLE :: ZNHPRE9F(:,:,:)       ! cf. PNHPRE9F in CPG_GP
REAL(KIND=JPRB),ALLOCATABLE :: ZNHPRE9H(:,:,:)       ! cf. PNHPRE9H in CPG_GP
REAL(KIND=JPRB),ALLOCATABLE :: ZPRE9_PHY(:,:,:)      ! true pressure for physics
                                                     ! /= ZPRE9 in NH, = in H  
REAL(KIND=JPRB),ALLOCATABLE :: ZPRE9F_PHY(:,:,:)     ! true pressure for physics
                                                     ! /= ZPRE9F in NH, = in H 
REAL(KIND=JPRB),ALLOCATABLE :: ZDELP9(:,:,:)         ! cf. PDELP9 in CPG_GP
REAL(KIND=JPRB),ALLOCATABLE :: ZRDELP9(:,:,:)        ! cf. PRDELP9 in CPG_GP
REAL(KIND=JPRB),ALLOCATABLE :: ZLNPR9(:,:,:)         ! cf. PLNPR9 in CPG_GP
REAL(KIND=JPRB),ALLOCATABLE :: ZALPH9(:,:,:)         ! cf. PALPH9 in CPG_GP
REAL(KIND=JPRB),ALLOCATABLE :: ZR9(:,:,:)            ! cf. PR9 in CPG_GP
REAL(KIND=JPRB),ALLOCATABLE :: ZCP9(:,:,:)           ! cf. PCP9 in CPG_GP
REAL(KIND=JPRB),ALLOCATABLE :: ZPHI9(:,:,:)          ! cf. PHI9 in CPG_GP
REAL(KIND=JPRB),ALLOCATABLE :: ZPHIF9(:,:,:)         ! cf. PHIF9 in CPG_GP
REAL(KIND=JPRB),ALLOCATABLE :: ZGWFT9(:,:,:)         ! cf. PGWFT9 in CPG_GP
REAL(KIND=JPRB),ALLOCATABLE :: ZGWT9(:,:,:)          ! cf. PGWT9 in CPG_GP
REAL(KIND=JPRB),ALLOCATABLE :: ZVCRSSA9F(:,:,:)      ! cf. PVCRSSA9F in CPG_GP
REAL(KIND=JPRB),ALLOCATABLE :: ZD3Y9(:,:,:)          ! cf. PD3Y9 in CPG_GP
REAL(KIND=JPRB),ALLOCATABLE :: ZNHX9(:,:,:)          ! cf. PNHXT9 in CPG_GP
REAL(KIND=JPRB),ALLOCATABLE :: ZPREHYD9F_PHY(:,:,:)
REAL(KIND=JPRB),ALLOCATABLE :: ZPREHYD9_PHY(:,:,:)
REAL(KIND=JPRB),ALLOCATABLE :: ZDELP9_PHY(:,:,:)
REAL(KIND=JPRB),ALLOCATABLE :: ZRDELP9_PHY(:,:,:)
REAL(KIND=JPRB),ALLOCATABLE :: ZLNPR9_PHY(:,:,:)
REAL(KIND=JPRB),ALLOCATABLE :: ZALPH9_PHY(:,:,:)
! - other quantities.
REAL(KIND=JPRB),ALLOCATABLE :: ZGPAR (:,:,:)         ! cf. PGPAR in CPG_GP.
REAL(KIND=JPRB),ALLOCATABLE :: ZGPPC(:,:,:)          ! cf. PGPPC in CPG_GP
REAL(KIND=JPRB),ALLOCATABLE :: ZSLBUF1AU(:,:,:)      ! local version of SLBUF1

REAL(KIND=JPRB) :: ZDT, ZDTPHY, ZTE
REAL(KIND=JPRB) :: ZDUMARR(1)

INTEGER(KIND=JPIM) :: IDDHI(NPROMA)                  ! cf. KDDHI in CPG_GP

INTEGER(KIND=JPIM) :: JROF, JKGLO, JFLD
INTEGER(KIND=JPIM) :: IEND, IENDC, IST, ISTC
INTEGER(KIND=JPIM) :: IBL
INTEGER(KIND=JPIM) :: ICEND, ICENDE
INTEGER(KIND=JPIM) :: IGL1, IGL2, IGL3, IGL4
INTEGER(KIND=JPIM) :: IGPCOMP
INTEGER(KIND=JPIM) :: IOFF
INTEGER(KIND=JPIM) :: ISTGLO
INTEGER(KIND=JPIM) :: ILL, ILP, JSPLIT

LOGICAL :: LLADNMI, LLDIAB, LLFSTEP, LLRESET, LLSLPHY, LLUSEPB1, LLCT, LLCTC
LOGICAL :: LLGET
LOGICAL :: LLALLOC_PRE9FPHY,LLALLOC_PRE9PHY
REAL(KIND=JPRB) :: ZHOOK_HANDLE

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

#include "abor1.intfb.h"
#include "cpdysldia.intfb.h"
#include "cpg_dia.intfb.h"
#include "cpg_dyn.intfb.h"
#include "cpg_end.intfb.h"
#include "cpg_gp.intfb.h"
#include "cpg_pt.intfb.h"
#include "ec_phys_lslphy.intfb.h"
#include "gpiniddh.intfb.h"
#include "mf_phys_prep.intfb.h"
#include "mf_phys.intfb.h"

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

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

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

!*       1.    PRELIMINARY INITIALISATION OF SOME SCALARS.
!              -------------------------------------------

LLCT =LPC_FULL.AND.(NCURRENT_ITER > 0)
LLCTC=LPC_CHEAP.AND.(NCURRENT_ITER > 0)
IF(NSTEP > 0) THEN
  LLFSTEP=.FALSE.
ELSE
  LLFSTEP=.TRUE.
ENDIF
! Physics is called in CPG
LLDIAB= (LMPHYS.OR.LEPHYS) .AND. .NOT.LAGPHY .AND. (NCURRENT_ITER == 0)
! Adiabatic NNMI iteration
LLADNMI= CDCONF == 'E' .OR. CDCONF == 'F'
LLSLPHY = LSLPHY.AND.LSLAG.AND..NOT.LLADNMI.AND.(.NOT.LLCTC)
! NNMI iteration or initial fluxes
IF (LLADNMI .OR. CDCONF == 'X' ) THEN
  LLFSTEP=.TRUE.
ENDIF
LLRESET=LLFSTEP.OR.LRESET

IF (LSLAG .AND. ((NCURRENT_ITER == 0).OR.(LLCT.AND.(.NOT.LLCTC))) ) THEN 
  LLUSEPB1=.TRUE.
ELSE
  LLUSEPB1=.FALSE.
ENDIF

IF (CDCONF == 'A'.OR.CDCONF == 'B'.OR.CDCONF == 'X'.OR.CDCONF == 'S') THEN
! usual time-step
  ZDT=TDT
  ZDTPHY=TDT
  ZTE=1.0_JPRB
ELSEIF (LLADNMI) THEN
! dynamical tendencies (adiabatic NNMI iteration : CDCONF='E' or 'F')
  ZDT=TSTEP
  ZDTPHY=0.0_JPRB
  IF (LSPRT) THEN
    ZTE=1.0_JPRB
  ELSE
    ZTE=0.0_JPRB
  ENDIF
ELSE
  ZTE=0
  WRITE(NULOUT,*)'*********ERROR ON CDCONF'
  CALL ABOR1('CPG: ABOR1 CALLED')
ENDIF

IGPCOMP=KGPCOMP

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

!*       2.    PRELIMINARY ALLOCATIONS AND MEMORY TRANSFERS.
!              ---------------------------------------------

! * Allocate some "9" variables (leap-frog scheme only).

IF ((LTWOTL.AND.LPC_FULL).OR.(.NOT.LTWOTL)) THEN
  IF (.NOT.ALLOCATED(ZPRE9)) ALLOCATE(ZPRE9(NPROMA,0:NFLEVG,KBLKS))
  IF (LALLOPR) WRITE(NULOUT,9990) 'ZPRE9    ',SIZE(ZPRE9),SHAPE(ZPRE9)
ENDIF

IF (.NOT.LTWOTL) THEN
  IF (.NOT.ALLOCATED(ZPRE9F)) ALLOCATE(ZPRE9F(NPROMA,NFLEVG,KBLKS))
  IF (LALLOPR) WRITE(NULOUT,9990) 'ZPRE9F   ',SIZE(ZPRE9F),SHAPE(ZPRE9F)
  IF (.NOT.ALLOCATED(ZNHPRE9F)) ALLOCATE(ZNHPRE9F(NPROMNH,NFLEVG,KBLKS))
  IF (LALLOPR) WRITE(NULOUT,9990) 'ZNHPRE9F ',SIZE(ZNHPRE9F),SHAPE(ZNHPRE9F)
  IF (.NOT.ALLOCATED(ZNHPRE9H)) ALLOCATE(ZNHPRE9H(NPROMNH,0:NFLEVG,KBLKS))
  IF (LALLOPR) WRITE(NULOUT,9990) 'ZNHPRE9H ',SIZE(ZNHPRE9H),SHAPE(ZNHPRE9H)
  IF (.NOT.ALLOCATED(ZDELP9)) ALLOCATE(ZDELP9(NPROMA,0:NFLEVG+1,KBLKS))
  IF (LALLOPR) WRITE(NULOUT,9990) 'ZDELP9   ',SIZE(ZDELP9),SHAPE(ZDELP9)
  IF (.NOT.ALLOCATED(ZRDELP9)) ALLOCATE(ZRDELP9(NPROMA,NFLEVG,KBLKS))
  IF (LALLOPR) WRITE(NULOUT,9990) 'ZRDELP9  ',SIZE(ZRDELP9),SHAPE(ZRDELP9)
  IF (.NOT.ALLOCATED(ZLNPR9)) ALLOCATE(ZLNPR9(NPROMA,NFLEVG,KBLKS))
  IF (LALLOPR) WRITE(NULOUT,9990) 'ZLNPR9   ',SIZE(ZLNPR9),SHAPE(ZLNPR9)
  IF (.NOT.ALLOCATED(ZALPH9)) ALLOCATE(ZALPH9(NPROMA,NFLEVG,KBLKS))
  IF (LALLOPR) WRITE(NULOUT,9990) 'ZALPH9   ',SIZE(ZALPH9),SHAPE(ZALPH9)
  IF (.NOT.ALLOCATED(ZR9)) ALLOCATE(ZR9(NPROMA,NFLEVG,KBLKS))
  IF (LALLOPR) WRITE(NULOUT,9990) 'ZR9      ',SIZE(ZR9),SHAPE(ZR9)
  IF (.NOT.ALLOCATED(ZCP9)) ALLOCATE(ZCP9(NPROMA,NFLEVG,KBLKS))
  IF (LALLOPR) WRITE(NULOUT,9990) 'ZCP9     ',SIZE(ZCP9),SHAPE(ZCP9)
  IF (.NOT.ALLOCATED(ZGWFT9)) ALLOCATE(ZGWFT9(NPROMA,NFLEVG,KBLKS))
  IF (LALLOPR) WRITE(NULOUT,9990) 'ZGWFT9   ',SIZE(ZGWFT9),SHAPE(ZGWFT9)
  IF (.NOT.ALLOCATED(ZGWT9)) ALLOCATE(ZGWT9(NPROMNH,NFLEVG,KBLKS))
  IF (LALLOPR) WRITE(NULOUT,9990) 'ZGWT9    ',SIZE(ZGWT9),SHAPE(ZGWT9)
  IF (.NOT.ALLOCATED(ZD3Y9)) ALLOCATE(ZD3Y9(NPROMNH,NFLEVG,KBLKS))
  IF (LALLOPR) WRITE(NULOUT,9990) 'ZD3Y9    ',SIZE(ZD3Y9),SHAPE(ZD3Y9)
  IF (.NOT.ALLOCATED(ZNHX9)) ALLOCATE(ZNHX9(NPROMA,NFLEVG,KBLKS))
  IF (LALLOPR) WRITE(NULOUT,9990) 'ZNHX9    ',SIZE(ZNHX9),SHAPE(ZNHX9)
  ! input arrays for MF physics
  IF (.NOT.ALLOCATED(ZPRE9F_PHY)) ALLOCATE(ZPRE9F_PHY(NPROMA,NFLEVG,KBLKS))
  IF (LALLOPR) WRITE(NULOUT,9990) &
   & 'ZPRE9F_PHY',SIZE(ZPRE9F_PHY),SHAPE(ZPRE9F_PHY)
  IF (.NOT.ALLOCATED(ZPRE9_PHY)) ALLOCATE(ZPRE9_PHY(NPROMA,0:NFLEVG,KBLKS))
  IF (LALLOPR) WRITE(NULOUT,9990) 'ZPRE9_PHY ',SIZE(ZPRE9_PHY),SHAPE(ZPRE9_PHY)
  IF (.NOT.ALLOCATED(ZPREHYD9F_PHY)) ALLOCATE(ZPREHYD9F_PHY(NPROMA,NFLEVG,KBLKS))
  IF (LALLOPR) WRITE(NULOUT,9992) &
   & 'ZPREHYD9F_PHY',SIZE(ZPREHYD9F_PHY),SHAPE(ZPREHYD9F_PHY)
  IF (.NOT.ALLOCATED(ZPREHYD9_PHY)) ALLOCATE(ZPREHYD9_PHY(NPROMA,0:NFLEVG,KBLKS))
  IF (LALLOPR) WRITE(NULOUT,9992) &
   & 'ZPREHYD9_PHY ',SIZE(ZPREHYD9_PHY),SHAPE(ZPREHYD9_PHY)
  IF (.NOT.ALLOCATED(ZDELP9_PHY)) ALLOCATE(ZDELP9_PHY(NPROMA,0:NFLEVG+1,KBLKS))
  IF (LALLOPR) WRITE(NULOUT,9992) &
   & 'ZDELP9_PHY   ',SIZE(ZDELP9_PHY),SHAPE(ZDELP9_PHY)
  IF (.NOT.ALLOCATED(ZRDELP9_PHY)) ALLOCATE(ZRDELP9_PHY(NPROMA,NFLEVG,KBLKS))
  IF (LALLOPR) WRITE(NULOUT,9992) &
   & 'ZRDELP9_PHY  ',SIZE(ZRDELP9_PHY),SHAPE(ZRDELP9_PHY)
  IF (.NOT.ALLOCATED(ZLNPR9_PHY)) ALLOCATE(ZLNPR9_PHY(NPROMA,NFLEVG,KBLKS))
  IF (LALLOPR) WRITE(NULOUT,9992) &
   & 'ZLNPR9_PHY   ',SIZE(ZLNPR9_PHY),SHAPE(ZLNPR9_PHY)
  IF (.NOT.ALLOCATED(ZALPH9_PHY)) ALLOCATE(ZALPH9_PHY(NPROMA,NFLEVG,KBLKS))
  IF (LALLOPR) WRITE(NULOUT,9992) &
   & 'ZALPH9_PHY   ',SIZE(ZALPH9_PHY),SHAPE(ZALPH9_PHY)
ENDIF

IF ((.NOT.LTWOTL).AND.(LLDIAB.OR.LSIMPH)) THEN
  IF (.NOT.ALLOCATED(ZPHI9)) ALLOCATE(ZPHI9(NPROMA,0:NFLEVG,KBLKS))
  IF (LALLOPR) WRITE(NULOUT,9990) 'ZPHI9    ',SIZE(ZPHI9),SHAPE(ZPHI9)
  IF (.NOT.ALLOCATED(ZPHIF9)) ALLOCATE(ZPHIF9(NPROMA,NFLEVG,KBLKS))
  IF (LALLOPR) WRITE(NULOUT,9990) 'ZPHIF9   ',SIZE(ZPHIF9),SHAPE(ZPHIF9)
ENDIF

IF ((.NOT.LTWOTL).AND.LSLAG) THEN
  IF (.NOT.ALLOCATED(ZVCRSSA9F)) ALLOCATE(ZVCRSSA9F(NPROMVC,NFLEVG,KBLKS))
  IF (LALLOPR) WRITE(NULOUT,9990) 'ZVCRSSA9F',SIZE(ZVCRSSA9F),SHAPE(ZVCRSSA9F)
ENDIF

! * Allocate some other arrays.

IF (.NOT.ALLOCATED(ZGPAR)) ALLOCATE(ZGPAR(NPROMA,NGPAR+1,KBLKS))
IF (LALLOPR) WRITE(NULOUT,9990) 'ZGPAR      ',SIZE(ZGPAR),SHAPE(ZGPAR)
ZGPAR(:,:,:)=0.0_JPRB

IF (.NOT.ALLOCATED(ZGPPC)) ALLOCATE(ZGPPC(NPROMA,NFGPPC+1,KBLKS))
IF (LALLOPR) WRITE(NULOUT,9990) 'ZGPPC    ',SIZE(ZGPPC),SHAPE(ZGPPC)
ZGPPC(:,:,:)=0.0_JPRB

IF(ALLOCATED(ZSLBUF1AU))DEALLOCATE(ZSLBUF1AU)
IF (.NOT.ALLOCATED(ZSLBUF1AU)) ALLOCATE(ZSLBUF1AU(NPROMA,NFLDSLB1,KBLKS))
IF (LALLOPR) WRITE(NULOUT,9990) 'ZSLBUF1AU',SIZE(ZSLBUF1AU),SHAPE(ZSLBUF1AU)

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

!  SET UP OUTER LOOP JSPLIT

!  IF LDCPG_SPLIT FALSE: 1 PASS TRHU "PARALLEL DO"
!  IF LDCPG_SPLIT TRUE:  3 PASSES THRU "PARALLEL DO".  SETUP, PHYSICS, AND
!                        DYNAMICS DONE IN CONSECUTIVE PASSES

IF(LDCPG_SPLIT) THEN
  ILP=3
ELSE
  ILP=1
ENDIF

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

!*       3.    READ BUFFERS, COMPUTE AUXILIARY QUANTITIES.
!              -------------------------------------------

DO JSPLIT=1,ILP

  IGL1=1
  IGL2=NDGENL
  IST=1
  ISTC=1

  IF(LDCPG_SPLIT) THEN
    IF(JSPLIT == 1) CALL GSTATS(1025,0)
    IF(JSPLIT == 2) CALL GSTATS(1026,0)
    IF(JSPLIT == 3) CALL GSTATS(1027,0)
  ELSE
    CALL GSTATS(1025,0)
  ENDIF

!$OMP PARALLEL DO SCHEDULE(DYNAMIC,1) &
!$OMP& PRIVATE (JKGLO,IOFF,ISTGLO,IBL,ICEND,ICENDE,IEND,IENDC) &
!$OMP& PRIVATE (JROF,JFLD) &
!$OMP& PRIVATE (IGL3,IGL4,ILL) &
!$OMP& PRIVATE (ZDHSF) &
!$OMP& PRIVATE (ZALB,ZCAPE,ZCLCC,ZCLCH,ZCLCL,ZCLCM,ZCLCT,ZCLPH,ZCT) &
!$OMP& PRIVATE (ZDIFCQ,ZDIFCQN,ZDIFCQL,ZDIFCS,ZDIFTQ,ZDIFTQN,ZDIFTQL,ZDIFTS) &
!$OMP& PRIVATE (ZFCCQL,ZFCCQN,ZFCHOZ,ZFCHSP,ZFCLL,ZFCLN,ZFCQNNG,ZFCQLNG)&
!$OMP& PRIVATE (ZFCQNG)&
!$OMP& PRIVATE (ZFCS) &
!$OMP& PRIVATE (ZFCSQL,ZFCSQN,ZFEVL,ZFEVN,ZFEVV,ZFGEL,ZFGELS,ZFLWSP,ZFONTE) &
!$OMP& PRIVATE (ZFPLCL,ZFPLCN,ZFPLCG,ZFPLCH,ZFPLSL,ZFPLSN,ZFPLSG,ZFPLSH) &
!$OMP& PRIVATE (ZFRSOLU,ZFRMH,ZFRSO,ZFRSOC,ZFRSODS)&
!$OMP& PRIVATE (ZFPFPSL,ZFPFPSN,ZFPFPCL,ZFPFPCN)&
!$OMP& PRIVATE (ZFPEVPSL,ZFPEVPSN,ZFPEVPCL,ZFPEVPCN,ZDRNSHF)&
!$OMP& PRIVATE (ZFRSOPS,ZFRSOPT,ZFRTH,ZFRTHC,ZFRTHDS,ZFTR,ZGZ0,ZGZ0H,ZNEB) &
!$OMP& PRIVATE (ZQCLS) &
!$OMP& PRIVATE (ZRH,ZRHCLS,ZRUISL,ZRUISP,ZRUISS) &
!$OMP& PRIVATE (ZSTRCU,ZSTRCV,ZSTRDU,ZSTRDV,ZSTRMU,ZSTRMV,ZSTRTU,ZSTRTV) &
!$OMP& PRIVATE (ZUCLS,ZVCLS,ZTCLS,ZUGST,ZVGST) &
!$OMP& PRIVATE (ZMOCON,ZFDIS) &
!$OMP& PRIVATE (ZFHPCL,ZFHPCN,ZFHPSL,ZFHPSN,ZFHSCL,ZFHSCN,ZFHSSL,ZFHSSN) &
!$OMP& PRIVATE (ZFEPFP, ZFCMPCQ, ZFCMPSN, ZFCMPSL, ZFCQRNG, ZFCQSNG) &
!$OMP& PRIVATE (ZTENDU,ZTENDV)  &
!$OMP& PRIVATE (ZDHCV,IDDHI)

  DO JKGLO=1,IGPCOMP,NPROMA

    IOFF=JKGLO
    ISTGLO=JKGLO
    IBL=(JKGLO-1)/NPROMA+1
    ICEND=MIN(NPROMA,IGPCOMP-JKGLO+1)
    ICENDE=MIN(NPROMA,NGPTOT-JKGLO+1)
    IEND=ICEND
    IENDC=ICENDE

    IF(LDCPG_SPLIT) THEN
      ILL=IBL
    ELSE
      ILL=OML_MY_THREAD()
    ENDIF

    IF(.NOT.LDCPG_SPLIT .OR. JSPLIT == 1) THEN

      CALL CPG_GP(&
       !---------------------------------------------------------------------
       ! - INPUT .
       & IST,IEND,ISTC,IENDC,IBL,ISTGLO, &
       & LLFSTEP,LLDIAB,LLADNMI, &
       & ZTE, &
       & GM(IOFF),GNORDL(IOFF),GNORDM(IOFF),RCORI(IOFF),RCORIC(IOFF), &
       & GNORDLCL(IOFF),GNORDMCL(IOFF),GNORDMCM(IOFF), &
       & RATATX(IOFF),RATATH(IOFF),OROG(IOFF), &
       & OROGL(IOFF),OROGM(IOFF),OROGLL(IOFF),OROGMM(IOFF),OROGLM(IOFF), &
       !---------------------------------------------------------------------
       ! - INPUT/OUTPUT .
       & GFL(1,1,1,IBL), &
       & PGMV(1,1,1,IBL),PGMVS(1,1,IBL), &
       !---------------------------------------------------------------------
       ! - OUTPUT .
       & ZOROGL(1,ILL),ZOROGM(1,ILL), &
       & ZPRE0(1,0,ILL),ZPRE0L(1,ILL),ZPRE0M(1,ILL),ZPRE0F(1,1,ILL), &
       & ZNHPRE0F(1,1,ILL),ZNHPRE0H(1,0,ILL), &
       & ZDELP0(1,0,ILL),ZRDELP0(1,1,ILL),ZLNPR0(1,1,ILL),ZALPH0(1,1,ILL), &
       & ZLHU0(1,0,ILL),ZLHV0(1,0,ILL), &
       & ZPHI0(1,0,ILL),ZPHIF0(1,1,ILL),ZPHI0FL(1,1,ILL),ZPHI0FM(1,1,ILL), &
       & ZCP0(1,1,ILL),ZR0(1,1,ILL),ZRTGR0(1,1,ILL), &
       & ZKAP0(1,1,ILL),ZRRED0(1,1,ILL), &
       & ZEVEL0(1,0,ILL),ZVVEL0(1,1,ILL),ZGWFT0(1,1,ILL), &
       & ZSDVBC0(1,0,ILL),ZKENE0(1,1,ILL), &
       & ZSGRTL(1,1,ILL),ZSGRTM(1,1,ILL),ZGPHL(1,0,ILL),ZGPHM(1,0,ILL), &
       & ZSDIV0(1,0,ILL),ZDIVP0(1,1,ILL),ZSDFI0(1,0,ILL), &
       & ZRT0L(1,1,ILL),ZRT0M(1,1,ILL),ZWW0(1,1,ILL), &
       & ZVCRSSA0F(1,1,ILL),ZVCRSSA0FL(1,1,ILL),ZVCRSSA0FM(1,1,ILL), &
       & ZVCRSSA0H(1,0,ILL), ZVCASRS0F(1,1,ILL),ZVCASRS0H(1,0,ILL), &
       & ZVCTS0F(1,1,ILL),ZVCMUS0F(1,1,ILL),ZVCW0F(1,1,ILL),ZWDLW0F(1,1,ILL), &
       & ZRDLR0(1,0,1,ILL),ZRDLR9(1,0,1,ILL), &
       & ZPRE9(1,0,ILL),ZPRE9F(1,1,ILL), &
       & ZNHPRE9F(1,1,ILL),ZNHPRE9H(1,0,ILL), &
       & ZDELP9(1,0,ILL),ZRDELP9(1,1,ILL),ZLNPR9(1,1,ILL),ZALPH9(1,1,ILL), &
       & ZPHI9(1,0,ILL),ZPHIF9(1,1,ILL),ZCP9(1,1,ILL),ZR9(1,1,ILL), &
       & ZGWFT9(1,1,ILL), &
       & ZVCRSSA9F(1,1,ILL), &
       & ZGPAR(1,1,ILL), &
       & ZGPPC(1,1,ILL),&
       & PB2(1,1,IBL),&
       & PGMVT1(1,1,1,IBL),PGMVT1S(1,1,IBL),PGFLT1(1,1,1,IBL), &
       & ZKOZO(1,1,ILL), &
       & ZQS(1,ILL),ZQICE(1,1,ILL),ZQLI(1,1,ILL), &
       & ZTNDPD(1,1,ILL),ZTNDVD(1,1,ILL),ZTNDGW(1,1,ILL),Z3DIVG(1,1,ILL), &
       & ZD3Y0(1,1,ILL),ZD3Y9(1,1,ILL), &
       & ZDBBC(1,ILL),ZRDPHI(1,1,ILL),ZGWT0(1,1,ILL),ZGWT9(1,1,ILL),&
       & ZGWS(1,ILL),ZNHX0(1,1,ILL),ZNHX9(1,1,ILL),&
       & ZQCHA0L(1,1,ILL),ZQCHA0M(1,1,ILL))

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

!*       4.    PHYSICS + DIAGNOSTICS
!              ---------------------

    IF(.NOT.LDCPG_SPLIT .OR. JSPLIT == 2) THEN

      ! * IGL3: first DM-local lat index of the current NPROMA-packet.
      IGL3=NGPLAT(IOFF)-NFRSTLOFF
      ! * IGL4: last DM-local lat index of the current NPROMA-packet.
      IGL4=NGPLAT(ICEND+JKGLO-1)-NFRSTLOFF

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

!*       4.1    Fill ZSLBUF1AU.

      IF (LLUSEPB1) THEN
        DO JFLD=1,NFLDSLB1
          DO JROF=ISTGLO,MIN(ISTGLO-1+NPROMA,IGPCOMP)
            ZSLBUF1AU(JROF-ISTGLO+1,JFLD,ILL)= 0.0_JPRB
          ENDDO
        ENDDO
      ENDIF

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

!*       4.2    Sets-up some quantities for DDH.
!               A subset of these quantities may be modified by the MF-physics.

      IF (LSDDH.AND. NCURRENT_ITER == 0 .AND. NPHYINT == 0) THEN
        CALL GPINIDDH(IST,IEND,&
         & IDDHI,ZDHSF,ZDHCV,ZNEB,ZCLCT,&
         & ISTGLO)  
      ENDIF

!     ------------------------------------------------------------------
! -- need probably a test on LEPHYS here.

!*       4.3    ECMWF-PHYSICS.

!*       4.3.1   Call ECMWF unlagged physics.

!   CALL EC_PHYS(...) to plug here.

!*       4.3.2   Call ECMWF split physics.

      IF (LLSLPHY) THEN
        CALL EC_PHYS_LSLPHY(&
         & IST,IEND,LLFSTEP,ZDTPHY, &
         & ZSLBUF1AU(1,MSLB1UP9,ILL),ZSLBUF1AU(1,MSLB1VP9,ILL), &
         & ZSLBUF1AU(1,MSLB1TP9,ILL),ZSLBUF1AU(1,MSLB1GFLP9,ILL), &
         & SAVTEND(1,1,1,IBL),GFLSLP(1,1,1,IBL))
      ENDIF

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

!*       4.4    MF-PHYSICS.

      IF( (LMPHYS.OR.LSIMPH) .AND. (NCURRENT_ITER == 0) ) THEN  

!*       4.4.1   Call MF unlagged physics (predictor only if PC scheme).

        LLALLOC_PRE9FPHY=ALLOCATED(ZPRE9F_PHY)
        LLALLOC_PRE9PHY=ALLOCATED(ZPRE9_PHY)
        CALL MF_PHYS_PREP( &
         & IST,IEND,LLALLOC_PRE9FPHY,LLALLOC_PRE9PHY,OROG(IOFF), &
         & PGMV(1,1,1,IBL),ZR0(1,1,ILL),ZR9(1,1,ILL), &
         & ZGWFT0(1,1,ILL),ZGWFT9(1,1,ILL), &
         & ZNHPRE0F(1,1,ILL),ZNHPRE9F(1,1,ILL), &
         & ZNHPRE0H(1,0,ILL),ZNHPRE9H(1,0,ILL), &
         & ZPRE0F(1,1,ILL),ZPRE9F(1,1,ILL),ZPRE0(1,0,ILL),ZPRE9(1,0,ILL), &
         & ZDELP0(1,0,ILL),ZDELP9(1,0,ILL),ZRDELP0(1,1,ILL),ZRDELP9(1,1,ILL), &
         & ZLNPR0(1,1,ILL),ZLNPR9(1,1,ILL),ZALPH0(1,1,ILL),ZALPH9(1,1,ILL), &
         & ZW0(1,1,ILL),ZW9(1,1,ILL),ZPRE0F_PHY(1,1,ILL),ZPRE9F_PHY(1,1,ILL), &
         & ZPRE0_PHY(1,0,ILL),ZPRE9_PHY(1,0,ILL),ZPREHYD0F_PHY(1,1,ILL), &
         & ZPREHYD9F_PHY(1,1,ILL),ZPREHYD0_PHY(1,0,ILL),ZPREHYD9_PHY(1,0,ILL), &
         & ZDELP0_PHY(1,0,ILL),ZDELP9_PHY(1,0,ILL), &
         & ZRDELP0_PHY(1,1,ILL),ZRDELP9_PHY(1,1,ILL), &
         & ZLNPR0_PHY(1,1,ILL),ZLNPR9_PHY(1,1,ILL), &
         & ZALPH0_PHY(1,1,ILL),ZALPH9_PHY(1,1,ILL))

        CALL MF_PHYS &
         & (CDCONF,IBL,IGPCOMP,IST,IEND,IGL1,IGL2,IGL3,IGL4,IOFF,ISTGLO, &
         & LDRETCFOU,LDWRTCFOU0,LLADNMI,YI%LADV,YL%LADV,YS%LADV,YR%LADV, &
         & YG%LADV,YH%LADV,YTKE%LADV,YEXT(1)%LADV, &
         & ZDTPHY, &
         & GAW(IOFF),&
         & GECLO(IOFF),GESLO(IOFF),GELAM(IOFF),GEMU(IOFF), &
         & GM(IOFF),OROG(IOFF),RCORI(IOFF), &
         & PGMV(1,1,YT0%MU,IBL),PGMV(1,1,YT0%MV,IBL),&
         & ZW0(1,1,ILL),PGMV(1,1,YT0%MT,IBL), &
         & GFL(1,1,YQ%MP,IBL),GFL(1,1,YQ%MPL,IBL),GFL(1,1,YQ%MPM,IBL),&
         & GFL(1,1,YL%MP,IBL),GFL(1,1,YI%MP,IBL),ZDUMARR, &
         & GFL(1,1,YS%MP,IBL),GFL(1,1,YR%MP,IBL),GFL(1,1,YG%MP,IBL),&
         & GFL(1,1,YH%MP,IBL),&
         & GFL(1,1,YTKE%MP,IBL),GFL(1,1,YA%MP,IBL),GFL(1,1,YSRC%MP,IBL),&
         & GFL(1,1,YSDSAT%MP,IBL),GFL(1,1,YCVV%MP,IBL),&
         & GFL(1,1,YQVA%MP,IBL),GFL(1,1,YEXT(1)%MP,IBL),&
         & PGMV(1,1,YT0%MDIV,IBL),PGMV(1,1,YT0%MVOR,IBL), &
         & ZCP0(1,1,ILL),ZR0(1,1,ILL),ZDELP0_PHY(1,0,ILL),ZRDELP0_PHY(1,1,ILL), &
         & ZPHI0(1,0,ILL),ZPHIF0(1,1,ILL), &
         & ZPREHYD0_PHY(1,0,ILL),ZPREHYD0F_PHY(1,1,ILL), &
         & ZPRE0_PHY(1,0,ILL),ZPRE0F_PHY(1,1,ILL), &
         & ZALPH0_PHY(1,1,ILL),ZLNPR0_PHY(1,1,ILL), &
         & ZVCASRS0H(1,0,ILL), &
         & GFL(1,1,YDAL%MP,IBL),GFL(1,1,YDOM%MP,IBL),&
         & GFL(1,1,YUEN%MP,IBL), &
         & GFL(1,1,YUAL%MP,IBL),GFL(1,1,YUOM%MP,IBL), &
         & GFL(1,1,YUNEBH%MP,IBL), &
         & PGMV(1,1,YT9%MU,IBL),PGMV(1,1,YT9%MV,IBL),ZW9(1,1,ILL),&
         & PGMV(1,1,YT9%MT,IBL),GFL(1,1,YQ%MP9,IBL),GFL(1,1,YL%MP9,IBL), &
         & GFL(1,1,YI%MP9,IBL),GFL(1,1,YS%MP9,IBL),GFL(1,1,YR%MP9,IBL), &
         & GFL(1,1,YG%MP9,IBL),GFL(1,1,YH%MP9,IBL),GFL(1,1,YTKE%MP9,IBL),&
         & GFL(1,1,YSRC%MP9,IBL),&
         & GFL(1,1,YSDSAT%MP9,IBL),GFL(1,1,YCVV%MP9,IBL),&
         & ZDUMARR,GFL(1,1,YEXT(1)%MP9,IBL),PGMVS(1,YT9%MSP,IBL),&
         & ZCP9(1,1,ILL),ZR9(1,1,ILL),ZDELP9_PHY(1,0,ILL), &
         & ZRDELP9_PHY(1,1,ILL),ZPHI9(1,0,ILL),ZPHIF9(1,1,ILL), &
         & ZPREHYD9_PHY(1,0,ILL),ZPREHYD9F_PHY(1,1,ILL), &
         & ZPRE9_PHY(1,0,ILL),ZPRE9F_PHY(1,1,ILL), &
         & ZALPH9_PHY(1,1,ILL),ZLNPR9_PHY(1,1,ILL), &
         & ZKOZO(1,1,ILL),GFL(1,1,YCPF%MP,IBL),GFL(1,1,YSPF%MP,IBL), &
         & GFL(1,1,YCVGQ%MP,IBL),GFL(1,1,YCVGQ%MPL,IBL),GFL(1,1,YCVGQ%MPM,IBL),&
         ! - Modification for SCM model extraction ----------------------------
         & ZOROGL(1,ILL), ZOROGM(1,ILL),RATATH(IOFF),RATATX(IOFF), &
         & PGMVS(1,YT0%MSP,IBL),PGMVS(1,YT0%MSPL,IBL),PGMVS(1,YT0%MSPM,IBL), &
         & PGMV(1,1,YT0%MTL,IBL),PGMV(1,1,YT0%MTM,IBL) , &
         & PGMV(1,1,YT9%MVOR,IBL),&
         ! --------------------------------------------------------------------
         & ZEVEL0(1,0,ILL),ZVVEL0(1,1,ILL), &
         & ZSDFI0(1,0,ILL),ZSDVBC0(1,0,ILL), &
         & ZSLBUF1AU(1,1,ILL),&
         & PGMVT1(1,1,1,IBL),PGMVT1S(1,1,IBL),PGFLT1(1,1,1,IBL), &
         & SP_SB(1,1,1,IBL),SP_SG(1,1,IBL),SP_RR(1,1,IBL),&
         & SD_VF(1,1,IBL),SD_VP(1,1,IBL),SD_VV(1,1,IBL),SD_VH(1,1,IBL), &
         & SD_VA(1,1,IBL),SD_VC(1,1,IBL),&
         & EMTD(1,1,IBL), EMTU(1,1,IBL), TRSW(1,1,IBL),RMOON(1,IBL),&
         & ZGPAR(1,1,ILL) , &
         & PGFLT1(1,1,YA%MP,IBL),PGFLT1(1,1,YSRC%MP,IBL),ZDHSF, &
         & ZALB,ZCAPE,ZCLCC,ZCLCH,ZCLCL,ZCLCM,ZCLCT,ZCLPH,ZCT, &
         & ZDIFCQ,ZDIFCQN,ZDIFCQL,ZDIFCS,ZDIFTQ,ZDIFTQN,ZDIFTQL,ZDIFTS, &
         & ZFCCQL,ZFCCQN,ZFCHOZ,ZFCHSP,ZFCLL,ZFCLN,ZFCQNNG,ZFCQLNG,ZFCQNG, &
         & ZFCS,ZFCSQL,ZFCSQN,ZFEVL,ZFEVN,ZFEVV,ZFGEL,ZFGELS,ZFLWSP,ZFONTE, &
         & ZFPLCL,ZFPLCN,ZFPLCG,ZFPLCH,ZFPLSL,ZFPLSN,ZFPLSG,ZFPLSH,&
         & ZFRMH,ZFRSO,ZFRSOC,ZFRSODS,ZFRSOLU, &
         & ZFRSOPS,ZFRSOPT,ZFRTH,ZFRTHC,ZFRTHDS,ZFTR,ZGZ0,ZGZ0H,ZNEB, &
         & ZQCLS,ZQICE(1,1,ILL),ZQLI(1,1,ILL),ZQS(1,ILL), &
         & ZRH,ZRHCLS,ZRUISL,ZRUISP,ZRUISS, &
         & ZSTRCU,ZSTRCV,ZSTRDU,ZSTRDV,ZSTRMU,ZSTRMV,ZSTRTU,ZSTRTV, &
         & ZUCLS,ZVCLS,ZTCLS,ZUGST,ZVGST, &
         & ZMOCON,ZFDIS, &
         & ZFHPCL,ZFHPCN,ZFHPSL,ZFHPSN,ZFHSCL,ZFHSCN,ZFHSSL,ZFHSSN, &
         & ZFEPFP, ZFCMPCQ, ZFCMPSN, ZFCMPSL,&
         & ZTENDU,ZTENDV, &
         & ZQSOL(1,ILL), &
         & ZFPFPSL,ZFPFPSN,ZFPFPCL,ZFPFPCN,ZFPEVPSL,ZFPEVPSN, &
         & ZFPEVPCL,ZFPEVPCN,ZDRNSHF, &
         & ZFCQRNG, ZFCQSNG, &
         & GFL(1,1,YEZDIAG(1)%MP,IBL))

      ENDIF

!*       4.4.2   Store phy. tends.

      IF ( LPC_FULL.AND.(.NOT.LPC_CHEAP).AND.LSLAG.AND.(LMPHYS.OR.LSIMPH) ) THEN

        ! * currently valid only for SL2TL advection scheme.
        !   Remarks KY:
        !   - PC scheme with Eulerian scheme: physics is passed differently
        !     from predictor to corrector step, and no call of CPG_PT is done.
        !   - LPC_CHEAP: physics is passed differently from predictor to
        !     corrector step (in LAPINEB), and no call of CPG_PT is done.
        !   - SL2TL: this call of CPG_PT assumes, for a GFL which has a physical
        !     tendency passed from predictor to corrector, that this GFL
        !     SHOULD be advected. Case where attributes LPT=T and LADV=F is
        !     not yet coded.
        LLGET=(NCURRENT_ITER > 0)
        CALL CPG_PT( &
         & IST,IEND,LLGET,NFLSA,NFLEN, &
         & PTENDU=ZSLBUF1AU(1,MSLB1U9+1-NFLSA,ILL), &
         & PTENDV=ZSLBUF1AU(1,MSLB1V9+1-NFLSA,ILL), &
         & PTENDT=ZSLBUF1AU(1,MSLB1T9+1-NFLSA,ILL), &
         & PTENDQ=ZSLBUF1AU(1,MSLB1GFL9+YQ%MP_SLX+1-NFLSA,ILL), &
         & PTENDL=ZSLBUF1AU(1,MSLB1GFL9+YL%MP_SLX+1-NFLSA,ILL), &
         & PTENDI=ZSLBUF1AU(1,MSLB1GFL9+YI%MP_SLX+1-NFLSA,ILL), &
         & PTENDS=ZSLBUF1AU(1,MSLB1GFL9+YS%MP_SLX+1-NFLSA,ILL), &
         & PTENDR=ZSLBUF1AU(1,MSLB1GFL9+YR%MP_SLX+1-NFLSA,ILL), &
         & PTENDG=ZSLBUF1AU(1,MSLB1GFL9+YG%MP_SLX+1-NFLSA,ILL), &
         & PTENDH=ZSLBUF1AU(1,MSLB1GFL9+YH%MP_SLX+1-NFLSA,ILL), &
         & PTENDTKE=ZSLBUF1AU(1,MSLB1GFL9+YTKE%MP_SLX+1-NFLSA,ILL),&
         & PTENDEXT=ZSLBUF1AU(1,MSLB1GFL9+YEXT(1)%MP_SLX,ILL),&
         & PTENDSP=ZSLBUF1AU(1,MSLB1SP9,ILL), &
         & PGFLPT=GFLPT(1,1,1,IBL),&
         & PGFLT1=PGFLT1(1,1,1,IBL),PGFL=GFL(1,1,1,IBL),&
         & PGMV=PGMV(1,1,1,IBL),PGMVS=PGMVS(1,1,IBL))

      ENDIF

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

!*       4.5    DIAGNOSTICS.
!*              - for dynamics, uses outputs of CPG_GP (MF and ECMWF).
!*              - for physics, uses outputs of MF_PHYS (MF only).

      IF (NCURRENT_ITER == 0 .AND. NPHYINT == 0) THEN
        CALL CPG_DIA( &
         & CDCONF, &
         & IST,IEND,ISTC,IENDC,ISTGLO,IDDHI, &
         & LLDIAB,LLADNMI,LLFSTEP,LLRESET, &
         & GM(IOFF),GEMU(IOFF),GSQM2(IOFF),GELAM(IOFF), &
         & GNORDL(IOFF),GNORDM(IOFF), &
         & RCORI(IOFF),RCORIC(IOFF),RATATX(IOFF),RATATH(IOFF), &
         & ZOROGL(1,ILL),ZOROGM(1,ILL), &
         & PGMV(1,1,YT0%MU,IBL),PGMV(1,1,YT0%MV,IBL),PGMV(1,1,YT0%MT,IBL), &
         & GFL(1,1,1,IBL), &
         & PGMV(1,1,YT0%MDIV,IBL),PGMV(1,1,YT0%MVOR,IBL), &
         & PGMV(1,1,YT0%MUL,IBL),PGMV(1,1,YT0%MVL,IBL), &
         & PGMV(1,1,YT0%MTL,IBL),PGMV(1,1,YT0%MTM,IBL), &
         & ZPRE0(1,0,ILL),ZPRE0F(1,1,ILL),ZDELP0(1,0,ILL),ZRDELP0(1,1,ILL), &
         & ZLNPR0(1,1,ILL),ZRTGR0(1,1,ILL), &
         & ZPHI0(1,0,ILL),ZPHIF0(1,1,ILL),ZPHI0FL(1,1,ILL),ZPHI0FM(1,1,ILL), &
         & ZCP0(1,1,ILL),ZR0(1,1,ILL), &
         & ZEVEL0(1,0,ILL),ZVVEL0(1,1,ILL), &
         & PB2(1,MSLB2VVEL,IBL),ZKENE0(1,1,ILL), &
         & ZSDIV0(1,0,ILL),ZDIVP0(1,1,ILL), &
         & ZRT0L(1,1,ILL),ZRT0M(1,1,ILL),ZPRE0L(1,ILL),ZPRE0M(1,ILL), &
         & ZSGRTL(1,1,ILL),ZSGRTM(1,1,ILL), &
         & Z3DIVG(1,1,ILL),ZNHPRE0F(1,1,ILL),ZNHPRE0H(1,0,ILL), &
         & ZQCHA0L(1,1,ILL),ZQCHA0M(1,1,ILL), &
         & ZVCRSSA0F(1,1,ILL),ZVCRSSA0FL(1,1,ILL),ZVCRSSA0FM(1,1,ILL), &
         & ZVCRSSA0H(1,0,ILL), ZVCASRS0F(1,1,ILL),ZVCASRS0H(1,0,ILL), &
         & ZVCW0F(1,1,ILL),ZVCMUS0F(1,1,ILL),ZWDLW0F(1,1,ILL), &
         & ZRDLR0(1,0,1,ILL), &
         & SD_VF(1,YSD_VF%YLSM%MP,IBL),SP_SG(1,YSP_SG%YF%MP0,IBL),&
         & SP_SB(1,1,YSP_SB%YT%MP0,IBL),SP_RR(1,YSP_RR%YT%MP0,IBL),&
         & SP_SB(1,1,YSP_SB%YQ%MP0,IBL),SP_RR(1,YSP_RR%YW%MP0,IBL),&
         & ZDHSF, &
         & ZALB,ZCAPE,ZCLCC,ZCLCH,ZCLCL,ZCLCM,ZCLCT,ZCLPH,ZCT, &
         & ZDIFCQ,ZDIFCQN,ZDIFCQL,ZDIFCS,ZDIFTQ,ZDIFTQN,ZDIFTQL,ZDIFTS, &
         & ZFCCQL,ZFCCQN,ZFCHSP,ZFCLL,ZFCLN,ZFCQNNG,ZFCQLNG,ZFCQNG,ZFCS, &
         & ZFCSQL,ZFCSQN,ZFEVL,ZFEVN,ZFEVV,ZFGEL,ZFGELS,ZFLWSP,ZFONTE, &
         & ZFPLCL,ZFPLCN,ZFPLCG,ZFPLCH,ZFPLSL,ZFPLSN,ZFPLSG,ZFPLSH,&
         & ZFRMH,ZFRSO,ZFRSOC,ZFRSODS,ZFRSOLU, &
         & ZFRSOPS,ZFRSOPT,ZFRTH,ZFRTHC,ZFRTHDS,ZFTR,ZGZ0,ZGZ0H,ZNEB, &
         & ZQICE(1,1,ILL),ZQLI(1,1,ILL),ZQS(1,ILL), &
         & ZRH,ZRHCLS,ZRUISL,ZRUISP,ZRUISS, &
         & ZSTRCU,ZSTRCV,ZSTRDU,ZSTRDV,ZSTRTU,ZSTRTV, &
         & ZUCLS,ZVCLS,ZTCLS,ZQCLS,ZUGST,ZVGST, &
         & ZMOCON,ZFDIS, &
         & ZFHPCL,ZFHPCN,ZFHPSL,ZFHPSN,ZFHSCL,ZFHSCN,ZFHSSL,ZFHSSN, &
         & ZFEPFP, ZFCMPCQ, ZFCMPSN, ZFCMPSL, &
         & ZFPFPSL,ZFPFPSN,ZFPFPCL,ZFPFPCN,ZFPEVPSL,ZFPEVPSN, &
         & ZFPEVPCL,ZFPEVPCN,ZGPAR(1,1,ILL), &
         & ZFCQRNG, ZFCQSNG, &
         & ZDHCV, ZDRNSHF)
      ENDIF

      IF (LSLDIA .AND. (NCURRENT_ITER == NSITER) .AND. NPHYINT == 0 ) THEN
        ! * Calculate and print SL dynamics diagnostics.
        CALL CPDYSLDIA(NPROMA,LLFSTEP,IST,IEND,NFLEVG, &
         & GEMU(IOFF),GSQM2(IOFF),RCOLON(IOFF), & 
         & PGMVS(1,YT0%MSP,IBL),ZDELP0(1,1,ILL),ZPRE0F(1,1,ILL), &
         & PGMV(1,1,YT0%MT,IBL),GFL(1,1,1,IBL),PEXTRA(1,1,1,IBL))
      ENDIF

    ENDIF

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

    IF(.NOT.LDCPG_SPLIT .OR. JSPLIT == 3) THEN

!*       5.    DYNAMICS.
!              ---------

!*       5.1   Call dynamics.

      CALL CPG_DYN( &
       !---------------------------------------------------------------------
       ! - INPUT .
       & CDCONF, &
       & IST,IEND,ISTGLO, &
       & LLADNMI, &
       & ZDT, &
       & SLHDA(IOFF),SLHDD0(IOFF), &
       & GM(IOFF),GNORDL(IOFF),GNORDM(IOFF),RCORI(IOFF),RCORIC(IOFF), &
       & GOMVRL(IOFF),GOMVRM(IOFF),RATATX(IOFF),RATATH(IOFF), &
       & OROG(IOFF), &
       & ZOROGL(1,ILL),ZOROGM(1,ILL), &
       & ZPRE0(1,0,ILL), &
       & ZRDELP0(1,1,ILL),ZLNPR0(1,1,ILL), &
       & ZLHU0(1,0,ILL),ZLHV0(1,0,ILL), &
       & ZPHI0(1,0,ILL),ZPHIF0(1,1,ILL),ZCP0(1,1,ILL),ZR0(1,1,ILL), &
       & ZKAP0(1,1,ILL), &
       & ZEVEL0(1,0,ILL),ZVVEL0(1,1,ILL),ZSDVBC0(1,0,ILL),ZKENE0(1,1,ILL), &
       & ZSGRTL(1,1,ILL),ZSGRTM(1,1,ILL), &
       & ZVCRSSA0F(1,1,ILL),ZVCASRS0F(1,1,ILL),ZVCASRS0H(1,0,ILL), &
       & ZVCW0F(1,1,ILL),ZWDLW0F(1,1,ILL), &
       & ZVCRSSA9F(1,1,ILL), &
       & ZRDLR0(1,0,1,ILL),ZRDLR9(1,0,1,ILL), &
       & SD_VF(1,YSD_VF%YLSM%MP,IBL),SP_RR(1,YSP_RR%YT%MP0,IBL),ZQSOL(1,ILL), &
       & GFL(1,1,1,IBL), &
       & ZTNDPD(1,1,ILL),ZTNDVD(1,1,ILL),ZTNDGW(1,1,ILL),Z3DIVG(1,1,ILL), &
       & ZD3Y9(1,1,ILL), &
       & ZDBBC(1,ILL),ZRDPHI(1,1,ILL),ZGWT0(1,1,ILL),ZGWT9(1,1,ILL),&
       & ZNHX0(1,1,ILL),ZNHX9(1,1,ILL),&
       !---------------------------------------------------------------------
       ! - INPUT/OUTPUT .
       & GFLPC(1,1,1,IBL),&
       & ZGWS(1,ILL),&
       & PGMV(1,1,1,IBL),PGMVS(1,1,IBL), &
       & ZGPPC(1,1,ILL),ZSLBUF1AU(1,1,ILL),PB2(1,1,IBL), &
       & PGMVT1(1,1,1,IBL),PGMVT1S(1,1,IBL), &
       & PGFLT1(1,1,1,IBL), &
       & ZD3Y0(1,1,ILL))
    
!*       5.2   Update PB1.

      IF (LLUSEPB1) THEN
        DO JFLD=1,NFLDSLB1
          DO JROF=ISTGLO,MIN(ISTGLO-1+NPROMA,IGPCOMP)
            PB1(NSLCORE(JROF),JFLD)=ZSLBUF1AU(JROF-ISTGLO+1,JFLD,ILL)
          ENDDO
        ENDDO
      ENDIF

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

!*       6.    FINAL PART OF NON-LAGGED GRID-POINT COMPUTATIONS.
!              -------------------------------------------------

      CALL CPG_END( &
       !---------------------------------------------------------------------
       ! - INPUT .
       & CDCONF, &
       & IST,IEND,ISTC,IENDC,IBL,ISTGLO, &
       & LLADNMI,LLDIAB, &
       & GM(IOFF), &
       & ZD3Y0(1,1,ILL),ZRRED0(1,1,ILL), &
       & ZGPHL(1,0,ILL),ZGPHM(1,0,ILL), &
       & ZWW0(1,1,ILL), &
       & ZQS(1,ILL), &
       !---------------------------------------------------------------------
       ! - INPUT/OUTPUT .
       & GFL(1,1,1,IBL), &
       & ZGPAR(1,1,ILL),ZGPPC(1,1,ILL), &
       & PGMV(1,1,1,IBL),PGMVS(1,1,IBL))

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

    ENDIF

  ENDDO

!$OMP END PARALLEL DO



  IF(LDCPG_SPLIT) THEN
    IF(JSPLIT == 1) CALL GSTATS(1025,1)
    IF(JSPLIT == 2) CALL GSTATS(1026,1)
    IF(JSPLIT == 3) CALL GSTATS(1027,1)
  ELSE
    CALL GSTATS(1025,1)
  ENDIF

ENDDO

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

!*       8.    FINAL DEALLOCATIONS.
!              --------------------

! * Deallocate "T9" arrays.

IF (ALLOCATED(ZPRE9)) THEN
  DEALLOCATE(ZPRE9)
  IF (LALLOPR) WRITE(NULOUT,9991) 'ZPRE9    '
ENDIF
IF (ALLOCATED(ZPRE9_PHY)) THEN
  DEALLOCATE(ZPRE9_PHY)
  IF (LALLOPR) WRITE(NULOUT,9991) 'ZPRE9_PHY'
ENDIF
IF (ALLOCATED(ZPRE9F)) THEN
  DEALLOCATE(ZPRE9F)
  IF (LALLOPR) WRITE(NULOUT,9991) 'ZPRE9F   '
ENDIF
IF (ALLOCATED(ZNHPRE9F)) THEN
  DEALLOCATE(ZNHPRE9F)
  IF (LALLOPR) WRITE(NULOUT,9991) 'ZNHPRE9F '
ENDIF
IF (ALLOCATED(ZNHPRE9H)) THEN
  DEALLOCATE(ZNHPRE9H)
  IF (LALLOPR) WRITE(NULOUT,9991) 'ZNHPRE9H '
ENDIF
IF (ALLOCATED(ZPRE9F_PHY)) THEN
  DEALLOCATE(ZPRE9F_PHY)
  IF (LALLOPR) WRITE(NULOUT,9991) 'ZPRE9F_PHY'
ENDIF
IF (ALLOCATED(ZDELP9)) THEN
  DEALLOCATE(ZDELP9)
  IF (LALLOPR) WRITE(NULOUT,9991) 'ZDELP9   '
ENDIF
IF (ALLOCATED(ZRDELP9)) THEN
  DEALLOCATE(ZRDELP9)
  IF (LALLOPR) WRITE(NULOUT,9991) 'ZRDELP9  '
ENDIF
IF (ALLOCATED(ZLNPR9)) THEN
  DEALLOCATE(ZLNPR9)
  IF (LALLOPR) WRITE(NULOUT,9991) 'ZLNPR9   '
ENDIF
IF (ALLOCATED(ZALPH9)) THEN
  DEALLOCATE(ZALPH9)
  IF (LALLOPR) WRITE(NULOUT,9991) 'ZALPH9   '
ENDIF
IF (ALLOCATED(ZR9)) THEN
  DEALLOCATE(ZR9)
  IF (LALLOPR) WRITE(NULOUT,9991) 'ZR9      '
ENDIF
IF (ALLOCATED(ZCP9)) THEN
  DEALLOCATE(ZCP9)
  IF (LALLOPR) WRITE(NULOUT,9991) 'ZCP9     '
ENDIF
IF (ALLOCATED(ZGWFT9)) THEN
  DEALLOCATE(ZGWFT9)
  IF (LALLOPR) WRITE(NULOUT,9991) 'ZGWFT9   '
ENDIF
IF (ALLOCATED(ZGWT9)) THEN
  DEALLOCATE(ZGWT9)
  IF (LALLOPR) WRITE(NULOUT,9991) 'ZGWT9    '
ENDIF
IF (ALLOCATED(ZD3Y9)) THEN
  DEALLOCATE(ZD3Y9)
  IF (LALLOPR) WRITE(NULOUT,9991) 'ZD3Y9    '
ENDIF
IF (ALLOCATED(ZNHX9)) THEN
  DEALLOCATE(ZNHX9)
  IF (LALLOPR) WRITE(NULOUT,9991) 'ZNHX9    '
ENDIF
IF (ALLOCATED(ZPHI9)) THEN
  DEALLOCATE(ZPHI9)
  IF (LALLOPR) WRITE(NULOUT,9991) 'ZPHI9    '
ENDIF
IF (ALLOCATED(ZPHIF9)) THEN
  DEALLOCATE(ZPHIF9)
  IF (LALLOPR) WRITE(NULOUT,9991) 'ZPHIF9   '
ENDIF
IF (ALLOCATED(ZVCRSSA9F)) THEN
  DEALLOCATE(ZVCRSSA9F)
  IF (LALLOPR) WRITE(NULOUT,9991) 'ZVCRSSA9F'
ENDIF
IF (ALLOCATED(ZPREHYD9F_PHY)) THEN
  DEALLOCATE(ZPREHYD9F_PHY)
  IF (LALLOPR) WRITE(NULOUT,9993) 'ZPREHYD9F_PHY'
ENDIF
IF (ALLOCATED(ZPREHYD9_PHY)) THEN
  DEALLOCATE(ZPREHYD9_PHY)
  IF (LALLOPR) WRITE(NULOUT,9993) 'ZPREHYD9_PHY '
ENDIF
IF (ALLOCATED(ZDELP9_PHY)) THEN
  DEALLOCATE(ZDELP9_PHY)
  IF (LALLOPR) WRITE(NULOUT,9993) 'ZDELP9_PHY   '
ENDIF
IF (ALLOCATED(ZRDELP9_PHY)) THEN
  DEALLOCATE(ZRDELP9_PHY)
  IF (LALLOPR) WRITE(NULOUT,9993) 'ZRDELP9_PHY  '
ENDIF
IF (ALLOCATED(ZLNPR9_PHY)) THEN
  DEALLOCATE(ZLNPR9_PHY)
  IF (LALLOPR) WRITE(NULOUT,9993) 'ZLNPR9_PHY   '
ENDIF
IF (ALLOCATED(ZALPH9_PHY)) THEN
  DEALLOCATE(ZALPH9_PHY)
  IF (LALLOPR) WRITE(NULOUT,9993) 'ZALPH9_PHY   '
ENDIF

! * Deallocate the other variables.

IF (ALLOCATED(ZGPAR)) THEN
  DEALLOCATE(ZGPAR)
  IF (LALLOPR) WRITE(NULOUT,9991) 'ZGPAR    '
ENDIF
IF (ALLOCATED(ZGPPC)) THEN
  DEALLOCATE(ZGPPC)
  IF (LALLOPR) WRITE(NULOUT,9991) 'ZGPPC    '
ENDIF
IF (ALLOCATED(ZSLBUF1AU)) THEN
  DEALLOCATE(ZSLBUF1AU)
ENDIF

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

9990 FORMAT(1X,'ARRAY ',A10,' ALLOCATED ',8I8)
9991 FORMAT(1X,'ARRAY ',A10,' DEALLOCATED ')
9992 FORMAT(1X,'ARRAY ',A13,' ALLOCATED ',8I8)
9993 FORMAT(1X,'ARRAY ',A13,' DEALLOCATED ')

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