SUBROUTINE SCAN2MTL(CDCONF)

!**** *SCAN2MTL* - Interface to computations in grid-point space

!     Purpose. Interface to computations in grid-point space
!     --------

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

!        Explicit arguments :  CDCONF - configuration of work (see doc.)
!        --------------------  

!        Implicit arguments :  None.
!        --------------------

!     Method.
!     -------

!     Externals.   See includes below.
!     ----------

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

!     Author.
!     -------
!        Mats Hamrud   *ECMWF*

!     Modifications.
!     --------------
!        Original 91-04-01 Mats Hamrud
!        Modified 93-04-13 L.Labbe (Interface for SC2CGAP)
!        Modified 93-11-19 M.Hamrud (Use only one Fourier file)
!        Modified 93-11-19 M.Hamrud (Use only one Fourier file)
!        Modified 94-04-06 R. El Khatib (ISTRIDE instead of LLDERR)
!                            as argument to SC2RDF
!        Modified 94-05-18 J.N.Thepaut : Humidity control in var. job
!        Modified 94-09-12 R. El Khatib : Remove call to POS
!        Modified 94-06-18 J.N.Thepaut : Introduction of obs handling in the TL
!        Modified 94-06-20 by M.Hamrud : upper air grid-point file
!        Modified 93-11-10 by R. EL Khatib (Non hydrostatic variables)
!        Modified 95-10-30 by M.Hamrud (Changed CDCONF def.)
!        Modified 95-12-05 F. Bouttier : call obs operators for trajectory
!        Modified 96-02-20 L. Isaksen  : Message passing option added
!        Modified 97-04-04 M. Janiskova : spectral transforms for rad.coef.
!        Modified 97-06-05 G. Mozdzynski : New semi-lagrangian communication
!        Modified 97-11-17 E.Andersson : Introduce O3 and CIW to obs points
!        Modified 97-12-18 E. Holm: Ozone included in Eulerian model
!                                   for data assimilation
!        Modified 98-02-04 E.Andersson : Sigma_b and BgQC for radiances
!        Modified 97-12-02 F. Taillefer :  add ESIG in COBS calls
!        Modified 98-01-21 K. YESSAD: merge of some FULL-POS and SL routines
!           relative to the halo.
!        Modified 98-06-16 C. Temperton: TL of semi-Lagrangian
!        Modified 98-10-27 G. Mozdzynski : load grid-point trajectory
!        Modified 98-08-10 by K. YESSAD: removal of LRPOLE option.
!        - removal of LRPOLE in YOMCT0 and code under LRPOLE.
!        Modified 99-02-01 M. Charron non-hydrostatic
!        Modified 99-02-17 by K. YESSAD: options LRETCFOU, LWRTCFOU.
!        Modified 99-03-10 C. Temperton: Add code for the case
!                                        (LMESSP.AND.LSLAG)
!        Modified 99-08    D.Salmond   : Remove NSLBCT for LMESSP=.TRUE.
!        Modified 99-08-23 C. Temperton: TL of semi-Lagrangian (3D model)
!        Modified 00-08-11 Y. Tremolet : use module TRAJECTORY
!        Modified 00-10-25 M.Hamrud    : Transform package
!        Modified 01-01-29 C. Temperton: Case LSPRT=.TRUE.
!        C. Fischer   01-03-06: Merge LAM version into global code
!        Modified 01-06-20 D.Salmond   : Introduce GP_MODEL_TL
!        Modified 01-08-24 E. Holm     : Imported modified JGNR/I and
!                                        unmodified EJGNRGG/I from SCAN2M
!                                        because of new control variable for humidity
!        Modified 02-09-30 P. Smolikova : Interface to SC2CGAP for d4 in NH
!        C. Fischer 03-06-03 : use igpcomp/ngptot_cap in call to cobs for LAM/Jo
!        M.Hamrud      01-Oct-2003 CY28 Cleaning
!        C.Fischer&Z.Sahlaoui 30-Nov-2003:Allocate G.T1 arrays if not (for GP Sigma_b)
!        Y.Tremolet    01-Aug-2005 Number sections consistently with SCAN2M
!        E. Holm   06-07-11 Move NSTEP=0 to CVARGPTL
!        K. Yessad Dec 2008: merge the different (E)SLEXTPOL.. -> (E)SLEXTPOL.
!        H. Hersbach Dec 2009: reset surface perts (moved from ec_phys_tl),
!                              ZPARITY determined in COBS/TL.
!    -------------------------------------------------------------------

USE PARKIND1  ,ONLY : JPIM     ,JPRB
USE YOMHOOK   ,ONLY : LHOOK,   DR_HOOK
USE YOMDIM   , ONLY : NFLEVG   ,NPROMA   ,&
 & NGPBLKS  ,NDGLG    ,NDLON    ,NDGSAG   ,NDGENG   ,&
 & NDGENL   ,NDGSAL  
USE YOMCT0   , ONLY :   LOBS   , LELAM    ,LSPRT  , NSTOP
USE YOMCT3   , ONLY : NSTEP
USE YOMSC2   , ONLY : NSLWIDE  ,NFLDOBB1
USE YOMGEM   , ONLY :    &
 & NGPTOT   ,NGPTOT_CAP,NLOENG  
USE YOMGC    , ONLY : RCORI    ,GELAM    ,&
 & GELAT    ,GM       ,GNORDL   ,&
 & GNORDM   ,OROG     ,&
 & NUNIQUEGP  
USE YOMVRTL  , ONLY : LOBSTL
USE YOMMP    , ONLY : NASLB1   ,NSLSTA   ,NSLONL   ,NSLOFF   ,NFRSTLOFF,MYFRSTACTLAT,MYLSTACTLAT
USE YOMVAR   , ONLY : NSIM4D, NSIM4DL, LMODERR
USE QASSET   , ONLY : ESIG
USE YOMTNEWT , ONLY : LIDMODEL
USE YOMMASK  , ONLY : NFIXSFLD ,LSLONDEM_ACTIVE, MASK_SL2
USE TRAJECTORY_MOD, ONLY: LTRAJGP, GET_TRAJ_GRID
USE YOMLCZ   , ONLY : LFORCEWR ,GPFORCEU ,GPFORCEV ,&
 & GPFORCET,GPFORCEQ ,GPFORCESP  
USE TESTVAR_MIX, ONLY: LTESTINC
USE RANDOM_NUMBERS_MIX, ONLY : GAUSSIAN_DISTRIBUTION
USE YOMGMV , ONLY : GMV,GMVS,GMV5,GMV5S,GMVT1,GMVT1S,GMV_DEPART,GMVS_DEPART,&
 & YT0,YT1,YT5  
USE YOMGFL     , ONLY : GFL,GFL5,GFLT1,GFL_DEPART
USE YOM_YGFL , ONLY : YGFL,YQ,YO3,YGFLC,YGHG
USE YOMHCP,  ONLY : LAVALOC
USE YOMRANDOM_STREAMS, ONLY : YD_RANDOM_STREAM_SCAN2MTL
USE YOMMODEL_ERROR, ONLY: NTYPE_MODERR, LFGMODERR, GPMODERR, GPFGMODERR

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

IMPLICIT NONE

CHARACTER(LEN=9), INTENT(IN) :: CDCONF

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

REAL(KIND=JPRB), ALLOCATABLE :: ZPERTTSG(:), ZPERTTS(:)
REAL(KIND=JPRB), ALLOCATABLE :: ZOBBUF1(:,:)
REAL(KIND=JPRB), ALLOCATABLE :: ZOBBUF5(:,:)
REAL(KIND=JPRB) :: ZPARITY1(NFLDOBB1),ZPARITY5(NFLDOBB1)
INTEGER(KIND=JPIM) :: IBL, ICEND, ICSTA, IOFF, JKGLO, JLEV, JL, &
                    & ICENDE, IGPCOMP, JGFL
LOGICAL :: LLMODEL

REAL(KIND=JPRB) :: ZHOOK_HANDLE

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

#include "abor1.intfb.h"
#include "cobs.intfb.h"
#include "cobslag.intfb.h"
#include "cobstl.intfb.h"
#include "ctvtottl.intfb.h"
#include "gp_model_tl.intfb.h"
#include "reset_spert.intfb.h"
#include "lcnorggtl.intfb.h"
#include "lcnoravar.intfb.h"
#include "slextpol.intfb.h"
#include "vec2gp.intfb.h"
#include "save_test4dinc.intfb.h"
#include "add_modbias_tl.intfb.h"

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

!    -------------------------------------------------------------------
!*       1.    INITIAL SETUP, MAIN LOOP CONTROL.
!    -------------------------------------------------------------------

IF(.NOT.ALLOCATED(GMVT1))  ALLOCATE(GMVT1(NPROMA,NFLEVG,YT1%NDIM,NGPBLKS))
IF(.NOT.ALLOCATED(GMVT1S)) ALLOCATE(GMVT1S(NPROMA,YT1%NDIMS,NGPBLKS))
IF(.NOT.ALLOCATED(GFLT1))  ALLOCATE(GFLT1(NPROMA,NFLEVG,YGFL%NDIM1,NGPBLKS))

! Try to guess when we are in an actual model time step...
LLMODEL =       (CDCONF(2:2)=='A') &
        & .AND. (CDCONF(3:3)=='A') &
        & .AND. (CDCONF(4:4)=='0' .OR. CDCONF(4:4)=='A') &
        & .AND. (CDCONF(5:5)=='0') &
        & .AND. (CDCONF(6:6)=='0' .OR. CDCONF(6:6)=='V')

! Total number of grid points - ndglg*ndlon in global / ndguxg*ndlon in LAM
! used for model computations
IF(.NOT.LELAM) THEN
  IGPCOMP=NGPTOT
ELSE
  IGPCOMP=MIN(NGPTOT,NGPTOT_CAP)
ENDIF

!    -------------------------------------------------------------------
!*       2.   TRAJECTORY HANDLING
!    -------------------------------------------------------------------

IF(CDCONF(5:5) /= 'L') THEN
  IF( LTRAJGP )THEN
!             retrieve grid-point trajectory
    IF (.NOT.ALLOCATED(GMV5)) ALLOCATE (GMV5(NPROMA,NFLEVG,YT5%NDIM,NGPBLKS))
    IF (.NOT.ALLOCATED(GMV5S)) ALLOCATE (GMV5S(NPROMA,YT5%NDIMS,NGPBLKS))
    IF (.NOT.ALLOCATED(GFL5)) ALLOCATE (GFL5(NPROMA,NFLEVG,YGFL%NDIM5,NGPBLKS))
    CALL GSTATS(16,0)
    CALL GET_TRAJ_GRID(GMV5,GMV5S,GFL5,KSTEP=NSTEP)
    CALL GSTATS(16,1)
  ELSE
    IF(.NOT.ALLOCATED(GMV5)) CALL ABOR1('SCAN2MTL:GMV5 NOT ALLOCATED')
  ENDIF
ENDIF

!    -------------------------------------------------------------------
!*       3.    INITIAL GRIDPOINT COMPUTATIONS
!    -------------------------------------------------------------------

!*       3.2 CONVERSION OF TTx ARRAY FROM 'TV' TO T

! If LSPRT=.t. both Trajectory and model state contain Tv
IF (LSPRT) THEN
!$OMP PARALLEL DO SCHEDULE(STATIC) PRIVATE(JKGLO,IBL,ICEND)
  DO JKGLO=1,NGPTOT,NPROMA
    ICEND=MIN(NPROMA,NGPTOT-JKGLO+1)
    IBL=(JKGLO-1)/NPROMA+1
    CALL CTVTOTTL(1,ICEND,&
     & GMV(1,1,YT0%MT,IBL),GFL(1,1,YQ%MP,IBL),&
     & GMV5(1,1,YT5%MT,IBL),GFL5(1,1,YQ%MP5,IBL))
  ENDDO
!$OMP END PARALLEL DO
ENDIF

!*       3.4 Save linear fields for inner/outer loop tests
IF (LTESTINC .AND. NSIM4D==NSIM4DL) THEN
  CALL SAVE_TEST4DINC(NSTEP)
ENDIF

!*       3.x IDENTITY MODEL
IF (CDCONF(3:3) == 'A'.OR.CDCONF(3:3) == 'B'.OR.CDCONF(3:3) == 'P') THEN
  IF (LIDMODEL .AND. CDCONF(6:6)=='V') THEN
    GMV_DEPART(:,:,1:YT0%NDIM,:) = GMV(:,:,1:YT0%NDIM,:)
    GMVS_DEPART(:,1:YT0%NDIMS,:) = GMVS(:,1:YT0%NDIMS,:)
    GFL_DEPART(:,:,1:YGFL%NDIM0,:) = GFL(:,:,1:YGFL%NDIM0,:)
  ENDIF
ENDIF

CALL GSTATS(34,0)

!     ------------------------------------------------------------------
!*       4.0   INITIALIZE TANGENT-LINEAR SURFACE FIELDS
!     ------------------------------------------------------------------

IF (NSTEP == 0) CALL RESET_SPERT(NSTEP)

!     ------------------------------------------------------------------
!*       4.    COMPARISON WITH OBSERVATIONS
!     ------------------------------------------------------------------

IF (CDCONF(6:6) == 'V') THEN

  IF (LIDMODEL) THEN
    GMV(:,:,1:YT0%NDIM,:) = GMV_DEPART(:,:,1:YT0%NDIM,:)
    GMVS(:,1:YT0%NDIMS,:) = GMVS_DEPART(:,1:YT0%NDIMS,:)
    GFL(:,:,1:YGFL%NDIM0,:) = GFL_DEPART(:,:,1:YGFL%NDIM0,:)
  ENDIF

!*       4.1 NON-LAGGED PART OF COMPUTATIONS

  IF (LOBS) THEN
    IF (.NOT. ALLOCATED(ZOBBUF1))   ALLOCATE (ZOBBUF1(NASLB1,NFLDOBB1))
    IF (.NOT. ALLOCATED(ZOBBUF5))   ALLOCATE (ZOBBUF5(NASLB1,NFLDOBB1))

    CALL GSTATS(1041,0)
!$OMP PARALLEL DO SCHEDULE(DYNAMIC,1)&
!$OMP&PRIVATE(JKGLO,ICEND,ICENDE,IBL,IOFF)
    DO JKGLO=1,IGPCOMP,NPROMA
      ICEND=MIN(NPROMA,IGPCOMP-JKGLO+1)
      ICENDE=MIN(NPROMA,NGPTOT-JKGLO+1)
      IBL=(JKGLO-1)/NPROMA+1
      IOFF=JKGLO
      IF(LOBSTL)THEN
!                 Grab & fill trajectory buffers first
!                 Only needs to be done once when GOM5 arrys kept
        IF (NSIM4D == 0) THEN
          CALL COBS(1,ICEND,JKGLO,ICENDE,&
           & GNORDL(IOFF),GNORDM(IOFF),&
           & ESIG(1,IOFF),&
           & GM(IOFF),OROG(IOFF),RCORI(IOFF),&
           & GMV5(1,1,1,IBL),GMV5S(1,1,IBL),GFL5(1,1,1,IBL),ZPARITY5,ZOBBUF5)  

          IF (LMODERR.AND.LFGMODERR.AND.NTYPE_MODERR==3) THEN
            CALL ADD_MODBIAS_TL(ICEND,IBL,JKGLO,ZOBBUF5,GPFGMODERR(1))
          ENDIF
        ENDIF

!                 fill perturbation buffers later
        CALL COBSTL(1,ICEND,JKGLO,ICENDE,&
         & GNORDL(IOFF),GNORDM(IOFF),&
         & GM(IOFF),OROG(IOFF),RCORI(IOFF),&
         & GMV(1,1,1,IBL),GMVS(1,1,IBL),GFL(1,1,1,IBL),ZPARITY1,ZOBBUF1)  

        IF (LMODERR.AND.NTYPE_MODERR==3) THEN
          CALL ADD_MODBIAS_TL(ICEND,IBL,JKGLO,ZOBBUF1,GPMODERR(1))
        ENDIF

      ELSE
        IF (CDCONF(4:4)=='0') THEN
          GMV(:,:,1:YT0%NDIM,IBL) = GMV(:,:,1:YT0%NDIM,IBL)+&
           & GMV5(:,:,1:YT5%NDIM,IBL)  
          GMVS(:,1:YT0%NDIMS,IBL) = GMVS(:,1:YT0%NDIMS,IBL)+&
           & GMV5S(:,1:YT5%NDIMS,IBL)  
          GFL(:,:,1:YGFL%NDIM0,IBL) = GFL(:,:,1:YGFL%NDIM0,IBL)+&
           & GFL5(:,:,1:YGFL%NDIM5,IBL)  
        ENDIF
!                 Do COBS on X5+X0 arrays = X+dX
        CALL COBS(1,ICEND,JKGLO,ICENDE,&
         & GNORDL(IOFF),GNORDM(IOFF),&
         & ESIG(1,IOFF),&
         & GM(IOFF),OROG(IOFF),RCORI(IOFF),&
         & GMV(1,1,1,IBL),GMVS(1,1,IBL),GFL(1,1,1,IBL),ZPARITY1,ZOBBUF1)  

        IF (LMODERR.AND.NTYPE_MODERR==3) THEN
          CALL ABOR1('SCAN2MTL: no bias without LOBSTL')
        ENDIF
      ENDIF
    ENDDO
!$OMP END PARALLEL DO
    CALL GSTATS(1041,1)

!*       4.2 DISTRIBUTED MEMORY : COMMUNICATION BETWEEN PROCESSORS

    LSLONDEM_ACTIVE=.TRUE.

    NFIXSFLD(1)=1
    NFIXSFLD(2)=0

    IF(.NOT.ALLOCATED(MASK_SL2))THEN
      ALLOCATE(MASK_SL2(NASLB1+4))
    ELSE
      DEALLOCATE(MASK_SL2)
      ALLOCATE(MASK_SL2(NASLB1+4))
    ENDIF
    CALL SLEXTPOL(NSLWIDE,NSLWIDE,&
     & NASLB1,NDGSAG,NDGENG,NDGSAL,NDGENL,NFLDOBB1,NSLSTA,NSLONL,NSLOFF,&
     & NDGLG,NLOENG,NFRSTLOFF,MYFRSTACTLAT,MYLSTACTLAT,NFIXSFLD,3,&
     & ZPARITY1,ZOBBUF1,KMASK2=MASK_SL2)  

    IF (LOBSTL.AND.NSIM4D == 0) THEN

      CALL SLEXTPOL(NSLWIDE,NSLWIDE,&
       & NASLB1,NDGSAG,NDGENG,NDGSAL,NDGENL,NFLDOBB1,NSLSTA,NSLONL,NSLOFF,&
       & NDGLG,NLOENG,NFRSTLOFF,MYFRSTACTLAT,MYLSTACTLAT,NFIXSFLD,3,&
       & ZPARITY5,ZOBBUF5,KMASK2=MASK_SL2)  
      
    ENDIF

!*       4.3 LAGGED PART OF COMPUTATIONS.

    IF(LOBSTL)THEN
!               Interpolate trajectory into GOMU5 arrays first, keep buffers
      IF (NSIM4D == 0) THEN
        CALL COBSLAG(NASLB1,.TRUE.,ZPARITY5,ZOBBUF5)
      ENDIF

!               Interpolate perturbation into GOMU arrays, release buffers
      CALL COBSLAG(NASLB1,.FALSE.,ZPARITY1,ZOBBUF1)

    ELSE
!               Interpolate X5+X0 into GOMU arrays, release buffers
      CALL COBSLAG(NASLB1,.FALSE.,ZPARITY1,ZOBBUF1)
    ENDIF

    IF (ALLOCATED(ZOBBUF1)) DEALLOCATE(ZOBBUF1)
    IF (ALLOCATED(ZOBBUF5)) DEALLOCATE(ZOBBUF5)

    LSLONDEM_ACTIVE = .FALSE.
  ENDIF

!*       4.4   GRID PONT CALCULATIONS FOR SIGMA_B OR SIGMA_A

ELSEIF (CDCONF(6:6) == 'A' .OR. CDCONF(6:6) == 'B') THEN

  ALLOCATE(ZPERTTSG(NDGLG*NDLON))
  ALLOCATE(ZPERTTS(NGPTOT))
  CALL GSTATS(1860,0)
  CALL GAUSSIAN_DISTRIBUTION (ZPERTTSG,YD_RANDOM_STREAM_SCAN2MTL)
  CALL GSTATS(1860,1)
  ZPERTTS(1:NGPTOT)=ZPERTTSG(NUNIQUEGP(1:NGPTOT))
  DEALLOCATE(ZPERTTSG)
  CALL GSTATS(1046,0)
!$OMP PARALLEL DO SCHEDULE(DYNAMIC,1)&
!$OMP&PRIVATE(JKGLO,ICEND,IBL,IOFF)
  DO JKGLO=1,NGPTOT,NPROMA
    ICEND=MIN(NPROMA,NGPTOT-JKGLO+1)
    IBL=(JKGLO-1)/NPROMA+1
    IOFF=JKGLO
    CALL VEC2GP (CDCONF(6:6),ICEND,JKGLO,&
     & GMV(1,1,YT0%MU,IBL),GMV(1,1,YT0%MV,IBL),&
     & GMV(1,1,YT0%MT,IBL),GFL(1,1,YQ%MP,IBL),&
     & GMV(1,1,YT0%MVOR,IBL),GFL(1,1,YO3%MP,IBL),&
     & GFL(1,1,1,IBL),GMVS(1,YT0%MSP,IBL),&
     & GMV5(1,1,YT5%MU,IBL),GMV5(1,1,YT5%MV,IBL),&
     & GMV5(1,1,YT5%MT,IBL),GFL5(1,1,YQ%MP5,IBL),&
     & GFL5(1,1,YO3%MP5,IBL),GFL5(1,1,1,IBL),&
     & GMV5S(1,YT5%MSP,IBL),OROG(IOFF),GELAT(IOFF),&
     & ZPERTTS(IOFF))  
  ENDDO
!$OMP END PARALLEL DO
  CALL GSTATS(1046,1)
  DEALLOCATE(ZPERTTS)

ENDIF

!     ------------------------------------------------------------------
!*       5.    GRIDPOINT MODEL (TANGENT LINEAR).
!     ------------------------------------------------------------------

IF (CDCONF(4:4) /= '0') THEN
  CALL GP_MODEL_TL(CDCONF)
ENDIF

!     ------------------------------------------------------------------
!*       6.    RESET SURFACE-FIELD PERTURBATIONS
!     ------------------------------------------------------------------

IF (NSTEP == NSTOP) CALL RESET_SPERT(NSTEP)

!    -------------------------------------------------------------------
!*    7. NORM LOCALIZATION
!    -------------------------------------------------------------------

IF(CDCONF(5:5) == 'L')THEN

  IF(.NOT.ALLOCATED(GMVT1))  ALLOCATE(GMVT1(NPROMA,NFLEVG,YT1%NDIM,NGPBLKS))
  IF(.NOT.ALLOCATED(GMVT1S)) ALLOCATE(GMVT1S(NPROMA,YT1%NDIMS,NGPBLKS))
  IF(.NOT.ALLOCATED(GFLT1))  ALLOCATE(GFLT1(NPROMA,NFLEVG,YGFL%NDIM1,NGPBLKS))
  ICSTA=1

  CALL GSTATS(1896,0)
!cjfe!$OMP PARALLEL PRIVATE(JKGLO,ICEND,IBL,IOFF,JLEV,JL,ILEV)
!cjfe!$OMP DO SCHEDULE(DYNAMIC,1)
  DO JKGLO=1,NGPTOT,NPROMA
    ICEND=MIN(NPROMA,NGPTOT-JKGLO+1)
    IBL=(JKGLO-1)/NPROMA+1
    IOFF=JKGLO

    IF(LFORCEWR) THEN
      DO JLEV=1,NFLEVG
        DO JL=ICSTA,ICEND
          GPFORCEU(JL,JLEV,IBL,0)=GMV(JL,JLEV,YT0%MU,IBL)
          GPFORCEV(JL,JLEV,IBL,0)=GMV(JL,JLEV,YT0%MV,IBL)
          GPFORCET(JL,JLEV,IBL,0)=GMV(JL,JLEV,YT0%MT,IBL)
          GPFORCEQ(JL,JLEV,IBL,0)=GFL(JL,JLEV,YQ%MP,IBL)
          GPFORCESP(JL,IBL,0)    =GMVS(JL,YT0%MSP,IBL)
        ENDDO
      ENDDO
    ENDIF

    IF (.NOT. LAVALOC) THEN
      CALL LCNORGGTL (ICSTA,ICEND,&
       & GELAM(IOFF),GELAT(IOFF),GM(IOFF),&
       & GMV(1,1,YT0%MU,IBL) ,GMV(1,1,YT0%MV,IBL) ,GMV(1,1,YT0%MT,IBL),&
       & GFL(1,1,YQ%MP,IBL) ,GMVS(1,YT0%MSP,IBL),&
       & GMVT1(1,1,YT1%MU,IBL) ,GMVT1(1,1,YT1%MV,IBL) ,GMVT1(1,1,YT1%MT,IBL),&
       & GFLT1(1,1,YQ%MP1,IBL) ,GMVT1S(1,YT1%MSP,IBL))  
    ELSE
      CALL LCNORAVAR (ICSTA,ICEND,&
       & GELAM(IOFF),GELAT(IOFF),GM(IOFF),&
       & GMV(1,1,YT0%MU,IBL) ,GMV(1,1,YT0%MV,IBL) ,GMV(1,1,YT0%MT,IBL),&
       & GFL(1,1,YQ%MP,IBL) ,GMVS(1,YT0%MSP,IBL),&
       & GMVT1(1,1,YT1%MU,IBL) ,GMVT1(1,1,YT1%MV,IBL) ,GMVT1(1,1,YT1%MT,IBL),&
       & GFLT1(1,1,YQ%MP1,IBL) ,GMVT1S(1,YT1%MSP,IBL))  
    ENDIF
  ENDDO
!cjfe!$OMP END DO
!cjfe!$OMP END PARALLEL
  CALL GSTATS(1896,1)
ENDIF
CALL GSTATS(34,1)

!     ------------------------------------------------------------------
!*       8.    "TIME-STEPPING" FOR GRID-POINT GFL FIELDS
!     ------------------------------------------------------------------

IF (CDCONF(7:7) /= '0') THEN
  DO JGFL=1,YGFL%NUMFLDS
    IF(YGFLC(JGFL)%LGP.AND.YGFLC(JGFL)%LT1) THEN
      IF (YGFLC(JGFL)%NCOUPLING==0) THEN
        GFL(:,:,YGFLC(JGFL)%MP,:) = GFLT1(:,:,YGFLC(JGFL)%MP1,:)
      ENDIF
    ENDIF
  ENDDO
ENDIF

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