!WRF:MEDIATION_LAYER:SOLVER

#define BENCH_START(A)
#define BENCH_END(A)

MODULE module_first_rk_step_part1

CONTAINS

  SUBROUTINE first_rk_step_part1 (   grid , config_flags              &
                             , moist , moist_tend               &
                             , chem  , chem_tend                &
                             , scalar , scalar_tend             &
                             , fdda3d, fdda2d                   &
                             , ru_tendf, rv_tendf               &
                             , rw_tendf, t_tendf                &
                             , ph_tendf, mu_tendf               &
                             , tke_tend                         &
                             , adapt_step_flag , curr_secs      &
                             , psim , psih , wspd , gz1oz0 , br , chklowq &
                             , cu_act_flag , hol , th_phy        &
                             , pi_phy , p_phy , t_phy , u_phy , v_phy     &
                             , dz8w , p8w , t8w , rho_phy , rho           &
                             , z_at_w , mu_3d                   &
                             , ids, ide, jds, jde, kds, kde     &
                             , ims, ime, jms, jme, kms, kme     &
                             , ips, ipe, jps, jpe, kps, kpe     &
                             , k_start , k_end                  &
                            )
    USE module_state_description
    USE module_model_constants
    USE module_domain, ONLY : domain
    USE module_configure, ONLY : grid_config_rec_type, model_config_rec
!!!!****MARS MARS
!!!!****MARS MARS
!    USE module_radiation_driver, ONLY : pre_radiation_driver, radiation_driver
!    USE module_surface_driver, ONLY : surface_driver
!    USE module_cumulus_driver, ONLY : cumulus_driver
!    USE module_pbl_driver, ONLY : pbl_driver
!    USE module_fddagd_driver, ONLY : fddagd_driver
    USE module_em, ONLY : init_zero_tendency
!!MARS
    USE module_lmd_driver
!!MARS
    USE module_big_step_utilities_em, ONLY : phy_prep
    USE module_dm
    IMPLICIT NONE

    TYPE ( domain ), INTENT(INOUT) :: grid
    TYPE ( grid_config_rec_type ), INTENT(IN) :: config_flags

    INTEGER, INTENT(IN) :: ids, ide, jds, jde, kds, kde,     &
                           ims, ime, jms, jme, kms, kme,     &
                           ips, ipe, jps, jpe, kps, kpe

    LOGICAL ,INTENT(IN)                        :: adapt_step_flag
    REAL, INTENT(IN)                           :: curr_secs

    REAL    ,DIMENSION(ims:ime,kms:kme,jms:jme,num_moist),INTENT(INOUT)   :: moist
    REAL    ,DIMENSION(ims:ime,kms:kme,jms:jme,num_moist),INTENT(INOUT)   :: moist_tend
    REAL    ,DIMENSION(ims:ime,kms:kme,jms:jme,num_moist),INTENT(INOUT)   :: chem
    REAL    ,DIMENSION(ims:ime,kms:kme,jms:jme,num_moist),INTENT(INOUT)   :: chem_tend
    REAL    ,DIMENSION(ims:ime,kms:kme,jms:jme,num_moist),INTENT(INOUT)   :: scalar
    REAL    ,DIMENSION(ims:ime,kms:kme,jms:jme,num_moist),INTENT(INOUT)   :: scalar_tend
    REAL    ,DIMENSION(ims:ime,kms:kme,jms:jme,num_fdda3d),INTENT(INOUT)  :: fdda3d
    REAL    ,DIMENSION(ims:ime,1:1,jms:jme,num_fdda2d),INTENT(INOUT)      :: fdda2d
    REAL    ,DIMENSION(ims:ime,jms:jme), INTENT(INOUT)         :: psim
    REAL    ,DIMENSION(ims:ime,jms:jme), INTENT(INOUT)         :: psih
    REAL    ,DIMENSION(ims:ime,jms:jme), INTENT(INOUT)         :: wspd
    REAL    ,DIMENSION(ims:ime,jms:jme), INTENT(INOUT)         :: gz1oz0
    REAL    ,DIMENSION(ims:ime,jms:jme), INTENT(INOUT)         :: br
    REAL    ,DIMENSION(ims:ime,jms:jme), INTENT(INOUT)         :: chklowq
    LOGICAL ,DIMENSION(ims:ime,jms:jme), INTENT(INOUT)         :: cu_act_flag
    REAL    ,DIMENSION(ims:ime,jms:jme), INTENT(INOUT)         :: hol

    REAL    ,DIMENSION(ims:ime,kms:kme,jms:jme), INTENT(INOUT) :: th_phy
    REAL    ,DIMENSION(ims:ime,kms:kme,jms:jme), INTENT(INOUT) :: pi_phy
    REAL    ,DIMENSION(ims:ime,kms:kme,jms:jme), INTENT(INOUT) :: p_phy
    REAL    ,DIMENSION(ims:ime,kms:kme,jms:jme), INTENT(INOUT) :: t_phy
    REAL    ,DIMENSION(ims:ime,kms:kme,jms:jme), INTENT(INOUT) :: u_phy
    REAL    ,DIMENSION(ims:ime,kms:kme,jms:jme), INTENT(INOUT) :: v_phy
    REAL    ,DIMENSION(ims:ime,kms:kme,jms:jme) :: w_phy  !!MARS aymeric var loc
    REAL    ,DIMENSION(ims:ime,kms:kme,jms:jme), INTENT(INOUT) :: dz8w
    REAL    ,DIMENSION(ims:ime,kms:kme,jms:jme), INTENT(INOUT) :: p8w
    REAL    ,DIMENSION(ims:ime,kms:kme,jms:jme), INTENT(INOUT) :: t8w
    REAL    ,DIMENSION(ims:ime,kms:kme,jms:jme), INTENT(INOUT) :: rho_phy
    REAL    ,DIMENSION(ims:ime,kms:kme,jms:jme), INTENT(INOUT) :: rho
    REAL    ,DIMENSION(ims:ime,kms:kme,jms:jme), INTENT(INOUT) :: z_at_w
    REAL    ,DIMENSION(ims:ime,kms:kme,jms:jme), INTENT(INOUT) :: mu_3d

    REAL    ,DIMENSION(ims:ime,kms:kme,jms:jme), INTENT(INOUT) :: ru_tendf
    REAL    ,DIMENSION(ims:ime,kms:kme,jms:jme), INTENT(INOUT) :: rv_tendf
    REAL    ,DIMENSION(ims:ime,kms:kme,jms:jme), INTENT(INOUT) :: rw_tendf
    REAL    ,DIMENSION(ims:ime,kms:kme,jms:jme), INTENT(INOUT) :: ph_tendf
    REAL    ,DIMENSION(ims:ime,kms:kme,jms:jme), INTENT(INOUT) :: t_tendf
    REAL    ,DIMENSION(ims:ime,kms:kme,jms:jme), INTENT(INOUT) :: tke_tend

    REAL    ,DIMENSION(ims:ime,jms:jme), INTENT(INOUT) :: mu_tendf

    INTEGER , INTENT(IN)                          ::  k_start, k_end

! Local

    REAL, DIMENSION( ims:ime, jms:jme ) :: ht_loc
    INTEGER, DIMENSION( ims:ime, jms:jme ) :: shadowmask 
    INTEGER                             :: ij
    INTEGER  num_roof_layers
    INTEGER  num_wall_layers
    INTEGER  num_road_layers
    INTEGER  iswater
    INTEGER  rk_step 

 ! initialize all tendencies to zero in order to update physics
 ! tendencies first (separate from dry dynamics).

    rk_step = 1

BENCH_START(init_zero_tend_tim)
       !$OMP PARALLEL DO   &
       !$OMP PRIVATE ( ij )

       DO ij = 1 , grid%num_tiles

         CALL wrf_debug ( 200 , ' call init_zero_tendency' )
         CALL init_zero_tendency ( ru_tendf, rv_tendf, rw_tendf,     &
                                   ph_tendf, t_tendf, tke_tend,      &
                                   mu_tendf,                         &
                                   moist_tend,chem_tend,scalar_tend, &
                                   num_moist,num_chem,num_scalar,       &
                                   rk_step,                          &
                                   ids, ide, jds, jde, kds, kde,     &
                                   ims, ime, jms, jme, kms, kme,     &
                                   grid%i_start(ij), grid%i_end(ij), &
                                   grid%j_start(ij), grid%j_end(ij), &
                                   k_start, k_end                   )

       END DO
       !$OMP END PARALLEL DO
BENCH_END(init_zero_tend_tim)

#ifdef DM_PARALLEL
#     include "HALO_EM_PHYS_A.inc"
#endif

      !$OMP PARALLEL DO   &
      !$OMP PRIVATE ( ij )
      DO ij = 1 , grid%num_tiles

        CALL wrf_debug ( 200 , ' call phy_prep' )
        CALL phy_prep ( config_flags,                           &
                        grid%mut, grid%muu, grid%muv, grid%u_2, &
                        grid%v_2, grid%w_2, grid%p, grid%pb, grid%alt,              &
                        grid%ph_2, grid%phb, grid%t_2, grid%tsk, moist, num_moist,   &
                        mu_3d, rho,                             &
                        th_phy, p_phy, pi_phy, u_phy, v_phy, w_phy,   &
                        p8w, t_phy, t8w, grid%z, z_at_w,             &
                        dz8w, grid%fnm, grid%fnp,                         &    
                        grid%rthraten,                               &
                        grid%rthblten, grid%rublten, grid%rvblten,             &
                        grid%rqvblten, grid%rqcblten, grid%rqiblten,           &
                        grid%rthcuten, grid%rqvcuten, grid%rqccuten,           &
                        grid%rqrcuten, grid%rqicuten, grid%rqscuten,           &
                        grid%rthften,  grid%rqvften,                      &
                        grid%RUNDGDTEN, grid%RVNDGDTEN, grid%RTHNDGDTEN,       &
                        grid%RQVNDGDTEN, grid%RMUNDGDTEN,                 &
                        ids, ide, jds, jde, kds, kde,           &
                        ims, ime, jms, jme, kms, kme,           &
                        grid%i_start(ij), grid%i_end(ij),       &
                        grid%j_start(ij), grid%j_end(ij),       &
                        k_start, k_end                         )
      ENDDO
      !$OMP END PARALLEL DO

BENCH_END(phy_prep_tim)

!!!!****MARS MARS
!!!!****MARS MARS

!! radiation
!
!! this driver is only needed to handle non-local shadowing effects
!      CALL pre_radiation_driver ( grid, config_flags                        & 
!     &        ,itimestep=grid%itimestep, ra_call_offset=grid%ra_call_offset    & 
!     &        ,XLAT=grid%xlat, XLONG=grid%xlong, GMT=grid%gmt                  &
!     &        ,julian=grid%julian, xtime=grid%xtime, RADT=grid%radt            &
!     &        ,STEPRA=grid%stepra                                              & 
!     &        ,ht=grid%ht,dx=grid%dx,dy=grid%dy,sina=grid%sina,cosa=grid%cosa  &
!     &        ,shadowmask=shadowmask,slope_rad=config_flags%slope_rad          &
!     &        ,topo_shading=config_flags%topo_shading                          & 
!     &        ,shadlen=config_flags%shadlen,ht_shad=grid%ht_shad,ht_loc=ht_loc & 
!     &        ,ht_shad_bxs=grid%ht_shad_bxs, ht_shad_bxe=grid%ht_shad_bxe      &
!     &        ,ht_shad_bys=grid%ht_shad_bys, ht_shad_bye=grid%ht_shad_bye      &
!     &        ,nested=config_flags%nested, min_ptchsz=grid%min_ptchsz          & 
!     &        ,spec_bdy_width=config_flags%spec_bdy_width                      &
!            ! indexes
!     &        ,IDS=ids,IDE=ide, JDS=jds,JDE=jde, KDS=kds,KDE=kde          &
!     &        ,IMS=ims,IME=ime, JMS=jms,JME=jme, KMS=kms,KME=kme          &
!     &        ,IPS=ips,IPE=ipe, JPS=jps,JPE=jpe, KPS=kps,KPE=kpe          &
!     &        ,i_start=grid%i_start,i_end=min(grid%i_end, ide-1)          &
!     &        ,j_start=grid%j_start,j_end=min(grid%j_end, jde-1)          &
!     &        ,kts=k_start, kte=min(k_end,kde-1)                          &
!     &        ,num_tiles=grid%num_tiles                                   )
!
!      CALL wrf_debug ( 200 , ' call radiation_driver' )
!BENCH_START(rad_driver_tim)
!
!      CALL radiation_driver(                                                  &
!     &         ACFRCV=grid%acfrcv      ,ACFRST=grid%acfrst      ,ALBEDO=grid%albedo  &
!     &        ,CFRACH=grid%cfrach      ,CFRACL=grid%cfracl      ,CFRACM=grid%cfracm  &
!     &        ,CUPPT=grid%cuppt        ,CZMEAN=grid%czmean      ,DT=grid%dt          &
!     &        ,DZ8W=dz8w               ,EMISS=grid%emiss        ,GLW=grid%glw        &
!     &        ,GMT=grid%gmt            ,GSW=grid%gsw            ,HBOT=grid%hbot      &
!     &        ,HTOP=grid%htop          ,HBOTR=grid%hbotr        ,HTOPR=grid%htopr    &
!     &        ,ICLOUD=config_flags%icloud                                            &
!     &        ,ITIMESTEP=grid%itimestep,JULDAY=grid%julday      , JULIAN=grid%julian &
!     &        ,JULYR=grid%julyr        ,LW_PHYSICS=config_flags%ra_lw_physics        &
!     &        ,NCFRCV=grid%ncfrcv      ,NCFRST=grid%ncfrst      ,NPHS=1              &
!     &        ,P8W=p8w                 ,P=p_phy                 ,PI=pi_phy           &
!     &        ,RADT=grid%radt          ,RA_CALL_OFFSET=grid%ra_call_offset           &
!     &        ,RHO=rho                 ,RLWTOA=grid%rlwtoa                           &
!     &        ,RSWTOA=grid%rswtoa      ,RTHRATEN=grid%rthraten                       &
!     &        ,RTHRATENLW=grid%rthratenlw       ,RTHRATENSW=grid%rthratensw          &
!     &        ,SNOW=grid%snow          ,STEPRA=grid%stepra      ,SWDOWN=grid%swdown  &
!     &        ,SWDOWNC=grid%swdownc    ,SW_PHYSICS=config_flags%ra_sw_physics        &
!     &        ,T8W=t8w                 ,T=t_phy                 ,TAUCLDC=grid%taucldc &
!     &        ,TAUCLDI=grid%taucldi    ,TSK=grid%tsk            ,VEGFRA=grid%vegfra  &
!     &        ,WARM_RAIN=grid%warm_rain ,XICE=grid%xice         ,XLAND=grid%xland    &
!     &        ,XLAT=grid%xlat          ,XLONG=grid%xlong        &
!!Optional urban
!     &        ,DECLIN_URB=grid%declin_urb        ,COSZ_URB2D=grid%cosz_urb2d   &
!     &        ,OMG_URB2D=grid%omg_urb2d                                        &
!!
!     &        ,Z=grid%z                                                   &
!     &        ,LEVSIZ=grid%levsiz, N_OZMIXM=num_ozmixm                    &
!     &        ,N_AEROSOLC=num_aerosolc                                    &
!     &        ,PAERLEV=grid%paerlev                                       &
!     &        ,CAM_ABS_DIM1=grid%cam_abs_dim1, CAM_ABS_DIM2=grid%cam_abs_dim2 &
!     &        ,CAM_ABS_FREQ_S=grid%cam_abs_freq_s                         &
!     &        ,XTIME=grid%xtime                                                &
!              ,CURR_SECS=curr_secs, ADAPT_STEP_FLAG=adapt_step_flag       &
!            ! indexes
!     &        ,IDS=ids,IDE=ide, JDS=jds,JDE=jde, KDS=kds,KDE=kde          &
!     &        ,IMS=ims,IME=ime, JMS=jms,JME=jme, KMS=kms,KME=kme          &
!     &        ,i_start=grid%i_start,i_end=min(grid%i_end, ide-1)          &
!     &        ,j_start=grid%j_start,j_end=min(grid%j_end, jde-1)          &
!     &        ,kts=k_start, kte=min(k_end,kde-1)                          &
!     &        ,num_tiles=grid%num_tiles                                   &
!            ! Optional                          
!     &        , CLDFRA=grid%cldfra                                        &
!     &        , PB=grid%pb                                                     &
!     &        , F_ICE_PHY=grid%f_ice_phy,F_RAIN_PHY=grid%f_rain_phy                 &
!     &        , QV=moist(ims,kms,jms,P_QV), F_QV=F_QV                     &
!     &        , QC=moist(ims,kms,jms,P_QC), F_QC=F_QC                     &
!     &        , QR=moist(ims,kms,jms,P_QR), F_QR=F_QR                     &
!     &        , QI=moist(ims,kms,jms,P_QI), F_QI=F_QI                     &
!     &        , QS=moist(ims,kms,jms,P_QS), F_QS=F_QS                     &
!     &        , QG=moist(ims,kms,jms,P_QG), F_QG=F_QG                     &
!     &        , QNDROP=scalar(ims,kms,jms,P_QNDROP), F_QNDROP=F_QNDROP    &
!#ifdef ACFLUX
!     &        ,ACSWUPT=acswupt    ,ACSWUPTC=acswuptc                      &
!     &        ,ACSWDNT=acswdnt    ,ACSWDNTC=acswdntc                      &
!     &        ,ACSWUPB=acswupb    ,ACSWUPBC=acswupbc                      &
!     &        ,ACSWDNB=acswdnb    ,ACSWDNBC=acswdnbc                      &
!     &        ,ACLWUPT=aclwupt    ,ACLWUPTC=aclwuptc                      &
!     &        ,ACLWDNT=aclwdnt    ,ACLWDNTC=aclwdntc                      &
!     &        ,ACLWUPB=aclwupb    ,ACLWUPBC=aclwupbc                      &
!     &        ,ACLWDNB=aclwdnb    ,ACLWDNBC=aclwdnbc                      &
!     &        ,SWUPT=swupt    ,SWUPTC=swuptc                              &
!     &        ,SWDNT=swdnt    ,SWDNTC=swdntc                              &
!     &        ,SWUPB=swupb    ,SWUPBC=swupbc                              &
!     &        ,SWDNB=swdnb    ,SWDNBC=swdnbc                              &
!     &        ,LWUPT=lwupt    ,LWUPTC=lwuptc                              &
!     &        ,LWDNT=lwdnt    ,LWDNTC=lwdntc                              &
!     &        ,LWUPB=lwupb    ,LWUPBC=lwupbc                              &
!     &        ,LWDNB=lwdnb    ,LWDNBC=lwdnbc                              &
!#endif
!     &        ,LWCF=grid%lwcf                                                  &
!     &        ,SWCF=grid%swcf                                                  &
!     &        ,OLR=grid%olr                                                    &
!     &        ,OZMIXM=grid%ozmixm, PIN=grid%pin                                     &
!     &        ,M_PS_1=grid%m_ps_1, M_PS_2=grid%m_ps_2, AEROSOLC_1=grid%aerosolc_1        &
!     &        ,AEROSOLC_2=grid%aerosolc_2, M_HYBI0=grid%m_hybi                      &
!     &        ,ABSTOT=grid%abstot, ABSNXT=grid%absnxt, EMSTOT=grid%emstot                &
!#ifdef WRF_CHEM
!     &        ,CU_RAD_FEEDBACK=config_flags%cu_rad_feedback                &
!     &        ,AER_RA_FEEDBACK=config_flags%aer_ra_feedback                &
!     &        ,QC_ADJUST=grid%GD_CLOUD_B , QI_ADJUST=grid%GD_CLOUD2_B         &
!     &        ,PM2_5_DRY=grid%pm2_5_dry, PM2_5_WATER=grid%pm2_5_water               &
!     &        ,PM2_5_DRY_EC=grid%pm2_5_dry_ec                                  &
!     &        ,TAUAER300=grid%tauaer1, TAUAER400=grid%tauaer2 & ! jcb
!     &        ,TAUAER600=grid%tauaer3, TAUAER999=grid%tauaer4 & ! jcb
!     &        ,GAER300=grid%gaer1, GAER400=grid%gaer2, GAER600=grid%gaer3, GAER999=grid%gaer4 & ! jcb
!     &        ,WAER300=grid%waer1, WAER400=grid%waer2, WAER600=grid%waer3, WAER999=grid%waer4 & ! jcb
!#endif
!     &         ,slope_rad=config_flags%slope_rad,topo_shading=config_flags%topo_shading     &
!     &         ,shadowmask=shadowmask,ht=grid%ht,dx=grid%dx,dy=grid%dy,sina=grid%sina,cosa=grid%cosa    )
!
!BENCH_END(rad_driver_tim)
!
!!********* Surface driver
!! surface
!
!BENCH_START(surf_driver_tim)
!
!!-----------------------------------------------------------------
!! urban related variable are added to arguments of surface_driver
!!-----------------------------------------------------------------
!      num_roof_layers = grid%num_soil_layers !urban
!      num_wall_layers = grid%num_soil_layers !urban
!      num_road_layers = grid%num_soil_layers !urban
!      CALL nl_get_iswater(grid%id, iswater)
!
!      CALL wrf_debug ( 200 , ' call surface_driver' )
!
!      CALL surface_driver(                                                &
!     &         ACSNOM=grid%acsnom      ,ACSNOW=grid%acsnow      ,AKHS=grid%akhs          &
!     &        ,AKMS=grid%akms          ,ALBBCK=grid%albbck      ,ALBEDO=grid%albedo      &
!     &        ,EMBCK=grid%embck                                                          &
!     &        ,BR=br              ,CANWAT=grid%canwat      ,CHKLOWQ=chklowq    &
!     &        ,CT=grid%ct              ,DT=grid%dt         ,DX=grid%dx         &
!     &        ,DZ8W=dz8w          ,DZS=grid%dzs            ,FLHC=grid%flhc          &
!     &        ,FLQC=grid%flqc          ,GLW=grid%glw            ,GRDFLX=grid%grdflx      &
!     &        ,GSW=grid%gsw    ,SWDOWN=grid%swdown        ,GZ1OZ0=gz1oz0      ,HFX=grid%hfx              &
!     &        ,HT=grid%ht              ,IFSNOW=config_flags%ifsnow      ,ISFFLX=config_flags%isfflx      &
!     &        ,ISLTYP=grid%isltyp      ,ITIMESTEP=grid%itimestep                    &
!     &        ,IVGTYP=grid%ivgtyp      ,LH=grid%lh              ,LOWLYR=grid%lowlyr      &
!     &        ,MAVAIL=grid%mavail      ,NUM_SOIL_LAYERS=config_flags%num_soil_layers        &
!     &        ,P8W=p8w            ,PBLH=grid%pblh          ,PI_PHY=pi_phy      &
!     &        ,PSFC=grid%psfc          ,PSHLTR=grid%pshltr      ,PSIH=psih          &
!     &        ,BLDT=grid%bldt     ,CURR_SECS=curr_secs, ADAPT_STEP_FLAG=adapt_step_flag  &
!     &        ,PSIM=psim          ,P_PHY=p_phy        ,Q10=grid%q10            &
!     &        ,Q2=grid%q2              ,QFX=grid%qfx            ,QSFC=grid%qsfc          &
!     &        ,QSHLTR=grid%qshltr      ,QZ0=grid%qz0            ,RAINCV=grid%raincv      &
!     &        ,RA_LW_PHYSICS=config_flags%ra_lw_physics            ,RHO=rho            &
!     &        ,RMOL=grid%rmol          ,SFCEVP=grid%sfcevp      ,SFCEXC=grid%sfcexc      &
!     &        ,SFCRUNOFF=grid%sfcrunoff                                        &
!     &        ,SF_SFCLAY_PHYSICS=config_flags%sf_sfclay_physics                        &
!     &        ,SF_SURFACE_PHYSICS=config_flags%sf_surface_physics  ,SH2O=grid%sh2o          &
!     &        ,SHDMAX=grid%shdmax      ,SHDMIN=grid%shdmin      ,SMOIS=grid%smois        &
!     &        ,SMSTAV=grid%smstav      ,SMSTOT=grid%smstot      ,SNOALB=grid%snoalb      &
!     &        ,SNOW=grid%snow          ,SNOWC=grid%snowc        ,SNOWH=grid%snowh        &
!     &        ,SST=grid%sst            ,SST_UPDATE=grid%sst_update                  &
!     &        ,STEPBL=grid%stepbl      ,TH10=grid%th10          ,TH2=grid%th2            &
!     &        ,THZ0=grid%thz0          ,TH_PHY=th_phy      ,TKE_MYJ=grid%tke_myj    &
!     &        ,TMN=grid%tmn            ,TSHLTR=grid%tshltr      ,TSK=grid%tsk            &
!     &        ,TSLB=grid%tslb          ,T_PHY=t_phy        ,U10=grid%u10            &
!     &        ,URATX=grid%uratx        ,VRATX=grid%vratx   ,TRATX=grid%tratx        &
!     &        ,UDRUNOFF=grid%udrunoff  ,UST=grid%ust       ,UZ0=grid%uz0            &
!     &        ,U_FRAME=grid%u_frame    ,U_PHY=u_phy        ,V10=grid%v10            &
!     &        ,VEGFRA=grid%vegfra      ,VZ0=grid%vz0       ,V_FRAME=grid%v_frame    &
!     &        ,V_PHY=v_phy             ,WARM_RAIN=grid%warm_rain                    &
!     &        ,WSPD=wspd               ,XICE=grid%xice     ,XLAND=grid%xland        &
!     &        ,Z0=grid%z0              ,Z=grid%z        ,ZNT=grid%znt            &
!     &        ,ZS=grid%zs              ,XICEM=grid%xicem   ,ISICE=grid%landuse_isice&
!     &        ,USTM=grid%ustm          ,CK=grid%ck         ,CKA=grid%cka            &
!     &                                 ,CD=grid%cd         ,CDA=grid%cda            &
!     &        ,ISFTCFLX=config_flags%isftcflx                                       &
!     &        ,OMLCALL=config_flags%omlcall ,OML_HML0=config_flags%oml_hml0 ,OML_GAMMA=config_flags%oml_gamma &
!     &        ,TML=grid%tml, T0ML=grid%t0ml, HML=grid%hml, H0ML=grid%h0ml, HUML=grid%huml, HVML=grid%hvml, F=grid%f &
!     &        ,ISWATER=iswater &
!     &        ,DECLIN_URB=grid%declin_urb  ,COSZ_URB2D=grid%cosz_urb2d    & !I urban
!     &        ,OMG_URB2D=grid%omg_urb2d    ,xlat_urb2d=grid%XLAT          & !I urban
!     &        ,NUM_ROOF_LAYERS=num_roof_layers                            & !I urban
!     &        ,NUM_WALL_LAYERS=num_wall_layers                            & !I urban
!     &        ,NUM_ROAD_LAYERS=num_road_layers                            &
!     &        ,DZR=grid%dzr ,DZB=grid%dzb ,DZG=grid%dzg                   & !I urban
!     &        ,TR_URB2D=grid%tr_urb2d ,TB_URB2D=grid%tb_urb2d             &
!     &        ,TG_URB2D=grid%tg_urb2d                                     & !H urban
!     &        ,TC_URB2D=grid%tc_urb2d ,QC_URB2D=grid%qc_urb2d             & !H urban
!     &        ,UC_URB2D=grid%uc_urb2d                                     & !H urban
!     &        ,XXXR_URB2D=grid%xxxr_urb2d                                 &
!     &        ,XXXB_URB2D=grid%xxxb_urb2d                                 & !H urban
!     &        ,XXXG_URB2D=grid%xxxg_urb2d                                 &
!     &        ,XXXC_URB2D=grid%xxxc_urb2d                                 & !H urban
!     &        ,TRL_URB3D=grid%trl_urb3d   ,TBL_URB3D=grid%tbl_urb3d       & !H urban
!     &        ,TGL_URB3D=grid%tgl_urb3d                                   & !H urban
!     &        ,SH_URB2D=grid%sh_urb2d     ,LH_URB2D=grid%lh_urb2d         &
!     &        ,G_URB2D=grid%g_urb2d                                       & !H urban
!     &        ,RN_URB2D=grid%rn_urb2d     , TS_URB2D=grid%ts_urb2d        & !H urban 
!     &        ,FRC_URB2D=grid%frc_urb2d                                   & !H urban
!     &        ,UTYPE_URB2D=grid%utype_urb2d                               & !H urban
!     &        ,ucmcall=grid%ucmcall                                       & !H urban
!           ! P-X LSM Variables
!     &        ,LANDUSEF=grid%landusef, SOILCTOP=grid%soilctop             &   ! P-X LSM
!     &        ,SOILCBOT=grid%soilcbot                                     &   ! P-X LSM
!     &        ,RA=grid%ra, RS=grid%rs, LAI=grid%lai                       &   ! P-X LSM
!     &        ,NLCAT=grid%num_land_cat,  NSCAT=grid%num_soil_cat          &   ! P-X LSM
!     &        ,VEGF_PX=grid%vegf_px, SNOWNCV=grid%snowncv                 &   ! P-X LSM
!     &        ,ANAL_INTERVAL=config_flags%interval_seconds                &   ! P-X LSM
!     &        ,PXLSM_SMOIS_INIT=config_flags%pxlsm_smois_init             &   ! P-X LSM
!     &        ,PXLSM_SOIL_NUDGE=config_flags%grid_fdda                    &   ! P-X LSM
!           ! Optional PX LSM nudging
!     &        ,t2_ndg_old=fdda2d(ims,1,jms,P_t2_ndg_old)                  &
!     &        ,q2_ndg_old=fdda2d(ims,1,jms,P_q2_ndg_old)                  &
!     &        ,t2_ndg_new=fdda2d(ims,1,jms,P_t2_ndg_new)                  &
!     &        ,q2_ndg_new=fdda2d(ims,1,jms,P_q2_ndg_new)                  &
!     &        ,sn_ndg_old=fdda2d(ims,1,jms,P_sn_ndg_old)                  &
!     &        ,sn_ndg_new=fdda2d(ims,1,jms,P_sn_ndg_new)                  &
!           ! Indexes
!     &        ,IDS=ids,IDE=ide, JDS=jds,JDE=jde, KDS=kds,KDE=kde          &
!     &        ,IMS=ims,IME=ime, JMS=jms,JME=jme, KMS=kms,KME=kme          &
!     &        , I_START=grid%i_start,I_END=min(grid%i_end, ide-1)         &
!     &        , J_START=grid%j_start,J_END=min(grid%j_end, jde-1)         &
!     &        , KTS=k_start, KTE=min(k_end,kde-1)                         &
!     &        , NUM_TILES=grid%num_tiles                                  &
!           ! Optional
!     &        ,QV_CURR=moist(ims,kms,jms,P_QV), F_QV=F_QV                 &
!     &        ,QC_CURR=moist(ims,kms,jms,P_QC), F_QC=F_QC                 &
!     &        ,QR_CURR=moist(ims,kms,jms,P_QR), F_QR=F_QR                 &
!     &        ,QI_CURR=moist(ims,kms,jms,P_QI), F_QI=F_QI                 &
!     &        ,QS_CURR=moist(ims,kms,jms,P_QS), F_QS=F_QS                 &
!     &        ,QG_CURR=moist(ims,kms,jms,P_QG), F_QG=F_QG                 &
!     &        ,CAPG=grid%capg, EMISS=grid%emiss, HOL=hol,MOL=grid%mol                    &
!     &        ,T2OBS=grid%t2obs, Q2OBS=grid%q2obs                         &
!     &        ,RAINBL=grid%rainbl,SR=grid%sr                                              &
!     &        ,RAINNCV=grid%rainncv,REGIME=grid%regime,T2=grid%t2,THC=grid%thc                &
!     &        ,QSG=grid%qsg,QVG=grid%qvg,QCG=grid%qcg,SOILT1=grid%soilt1,TSNAV=grid%tsnav          & ! ruc lsm
!     &        ,SMFR3D=grid%smfr3d,KEEPFR3DFLAG=grid%keepfr3dflag                    & ! ruc lsm
!     &        ,POTEVP=grid%POTEVP, SNOPCX=grid%SNOPCX, SOILTB=grid%SOILTB                & ! ruc lsm
!     &                                                              )
!BENCH_END(surf_driver_tim)
!
!!*********
!! pbl
!
!      CALL wrf_debug ( 200 , ' call pbl_driver' )
!BENCH_START(pbl_driver_tim)
!      CALL pbl_driver(                                                    &
!     &         AKHS=grid%akhs          ,AKMS=grid%akms                              &
!     &        ,BL_PBL_PHYSICS=config_flags%bl_pbl_physics                 &
!     &        ,BLDT=grid%bldt, CURR_SECS=curr_secs, ADAPT_STEP_FLAG=adapt_step_flag &
!     &        ,BR=br              ,CHKLOWQ=chklowq    ,CT=grid%ct         &
!     &        ,DT=grid%dt              ,DX=grid%dx              ,DZ8W=dz8w          &
!     &        ,EL_MYJ=grid%el_myj      ,EXCH_H=grid%exch_h      ,GRDFLX=grid%grdflx      &
!     &        ,GZ1OZ0=gz1oz0      ,HFX=grid%hfx            ,HT=grid%ht              &
!     &        ,ITIMESTEP=grid%itimestep                    ,KPBL=grid%kpbl          &
!     &        ,LH=grid%lh              ,LOWLYR=grid%lowlyr      ,P8W=p8w            &
!     &        ,PBLH=grid%pblh          ,PI_PHY=pi_phy      ,PSIH=psih          &
!     &        ,PSIM=psim          ,P_PHY=p_phy        ,QFX=grid%qfx            &
!     &        ,QSFC=grid%qsfc          ,QZ0=grid%qz0                                &
!     &        ,RA_LW_PHYSICS=config_flags%ra_lw_physics                   &
!     &        ,RHO=rho            ,RQCBLTEN=grid%rqcblten  ,RQIBLTEN=grid%rqiblten  &
!     &        ,RQVBLTEN=grid%rqvblten  ,RTHBLTEN=grid%rthblten  ,RUBLTEN=grid%rublten    &
!     &        ,RVBLTEN=grid%rvblten    ,SNOW=grid%snow          ,STEPBL=grid%stepbl      &
!     &        ,THZ0=grid%thz0          ,TH_PHY=th_phy      ,TKE_MYJ=grid%tke_myj    &
!     &        ,TSK=grid%tsk            ,T_PHY=t_phy        ,UST=grid%ust            &
!     &        ,U10=grid%u10 ,UZ0=grid%uz0      ,U_FRAME=grid%u_frame    ,U_PHY=u_phy        &
!     &        ,V10=grid%v10 ,VZ0=grid%vz0      ,V_FRAME=grid%v_frame    ,V_PHY=v_phy        &
!     &        ,WARM_RAIN=grid%warm_rain                    ,WSPD=wspd          &
!     &        ,XICE=grid%xice          ,XLAND=grid%xland        ,Z=grid%z                &
!     &        ,ZNT=grid%znt                                                    &
!     &        ,IDS=ids,IDE=ide, JDS=jds,JDE=jde, KDS=kds,KDE=kde          &
!     &        ,IMS=ims,IME=ime, JMS=jms,JME=jme, KMS=kms,KME=kme          &
!     &        ,I_START=grid%i_start,I_END=min(grid%i_end, ide-1)          &
!     &        ,J_START=grid%j_start,J_END=min(grid%j_end, jde-1)          &
!     &        ,KTS=k_start, KTE=min(k_end,kde-1)                          &
!     &        ,NUM_TILES=grid%num_tiles                                   &
!          ! Variables Required by ACM PBL  - jp
!     &        ,ZNU=grid%znu,ZNW=grid%znw,MUT=grid%mut,P_TOP=grid%p_top    &
!          ! optional
!     &        ,QV_CURR=moist(ims,kms,jms,P_QV), F_QV=F_QV                 &
!     &        ,QC_CURR=moist(ims,kms,jms,P_QC), F_QC=F_QC                 &
!     &        ,QR_CURR=moist(ims,kms,jms,P_QR), F_QR=F_QR                 &
!     &        ,QI_CURR=moist(ims,kms,jms,P_QI), F_QI=F_QI                 &
!     &        ,QS_CURR=moist(ims,kms,jms,P_QS), F_QS=F_QS                 &
!     &        ,QG_CURR=moist(ims,kms,jms,P_QG), F_QG=F_QG                 &
!     &        ,HOL=HOL, MOL=grid%mol, REGIME=grid%REGIME                  &
!     &                                                          )
!
!BENCH_END(pbl_driver_tim)
!
!! cumulus para.
!
!      CALL wrf_debug ( 200 , ' call cumulus_driver' )
!
!
!BENCH_START(cu_driver_tim)
!      CALL cumulus_driver(grid                                             &
!                 ! Prognostic variables
!     &             ,U=u_phy   ,V=v_phy   ,TH=th_phy  ,T=t_phy             &
!     &             ,W=grid%w_2     ,P=p_phy   ,PI=pi_phy  ,RHO=rho             &
!                 ! Other arguments
!     &             ,ITIMESTEP=grid%itimestep ,DT=grid%dt      ,DX=grid%dx                &
!     &             ,CUDT=grid%cudt,CURR_SECS=curr_secs,ADAPT_STEP_FLAG=adapt_step_flag &
!     &             ,RAINC=grid%rainc   ,RAINCV=grid%raincv   ,PRATEC=grid%pratec         &
!     &             , NCA=grid%nca                                         &
!     &             ,HTOP=grid%cutop     ,HBOT=grid%cubot       ,KPBL=grid%kpbl             &
!     &             ,DZ8W=dz8w     ,P8W=p8w                                &
!     &             ,W0AVG=grid%w0avg   ,STEPCU=grid%stepcu                          &
!     &             ,CLDEFI=grid%cldefi ,LOWLYR=grid%lowlyr ,XLAND=grid%xland             &
!     &             ,APR_GR=grid%apr_gr ,APR_W=grid%apr_w   ,APR_MC=grid%apr_mc           &
!     &             ,APR_ST=grid%apr_st ,APR_AS=grid%apr_as ,APR_CAPMA=grid%apr_capma     &
!     &             ,APR_CAPME=grid%apr_capme          ,APR_CAPMI=grid%apr_capmi     &
!     &             ,MASS_FLUX=grid%mass_flux          ,XF_ENS=grid%xf_ens           &
!     &             ,PR_ENS=grid%pr_ens ,HT=grid%ht,EDT_OUT=grid%edt_out             &
!     &             ,imomentum=grid%imomentum,clos_choice=grid%clos_choice       &
!     &             ,cugd_tten=grid%cugd_tten,cugd_qvten=grid%cugd_qvten,cugd_qcten=grid%cugd_qcten   &
!     &             ,cugd_ttens=grid%cugd_ttens,cugd_qvtens=grid%cugd_qvtens   &
!     &             ,ENSDIM=config_flags%ensdim ,MAXIENS=config_flags%maxiens ,MAXENS=config_flags%maxens         &
!     &             ,MAXENS2=config_flags%maxens2                ,MAXENS3=config_flags%maxens3       &
!     &             ,CU_ACT_FLAG=cu_act_flag   ,WARM_RAIN=grid%warm_rain        &
!     &             ,GSW=grid%gsw,cugd_avedx=config_flags%cugd_avedx &
!     &             ,PERIODIC_X=(config_flags%polar .OR. config_flags%periodic_x)  &
!     &             ,PERIODIC_Y=config_flags%periodic_y  &
!                 ! Selection flag
!     &             ,CU_PHYSICS=config_flags%cu_physics                    &
!                 ! Dimension arguments
!     &             ,IDS=ids,IDE=ide, JDS=jds,JDE=jde, KDS=kds,KDE=kde     &
!     &             ,IMS=ims,IME=ime, JMS=jms,JME=jme, KMS=kms,KME=kme     &
!     &             ,IPS=ips,IPE=ipe, JPS=jps,JPE=jpe, KPS=kps,KPE=kpe     &
!     &             ,I_START=grid%i_start,I_END=min(grid%i_end, ide-1)     &
!     &             ,J_START=grid%j_start,J_END=min(grid%j_end, jde-1)     &
!     &             ,KTS=k_start, KTE=min(k_end,kde-1)                     &
!     &             ,NUM_TILES=grid%num_tiles                              &
!                 ! Moisture tendency arguments
!     &             ,RQVCUTEN=grid%rqvcuten , RQCCUTEN=grid%rqccuten                 &
!     &             ,RQSCUTEN=grid%rqscuten , RQICUTEN=grid%rqicuten                 &
!     &             ,RQRCUTEN=grid%rqrcuten , RQVBLTEN=grid%rqvblten                 &
!     &             ,RQVFTEN=grid%rqvften                                       &
!                 ! Other tendency arguments
!     &             ,RTHRATEN=grid%rthraten , RTHBLTEN=grid%rthblten                 &
!     &             ,RTHCUTEN=grid%rthcuten , RTHFTEN=grid%rthften                   &
!                 ! Moisture tracer arguments
!     &             ,QV_CURR=moist(ims,kms,jms,P_QV), F_QV=F_QV            &
!     &             ,QC_CURR=moist(ims,kms,jms,P_QC), F_QC=F_QC            &
!     &             ,QR_CURR=moist(ims,kms,jms,P_QR), F_QR=F_QR            &
!     &             ,QI_CURR=moist(ims,kms,jms,P_QI), F_QI=F_QI            &
!     &             ,QS_CURR=moist(ims,kms,jms,P_QS), F_QS=F_QS            &
!     &             ,QG_CURR=moist(ims,kms,jms,P_QG), F_QG=F_QG            &
!#ifdef WRF_CHEM
!     &             ,GD_CLOUD=grid%GD_CLOUD,GD_CLOUD2=grid%GD_CLOUD2                          &
!#endif
!     &                                                          )
!BENCH_END(cu_driver_tim)
!
!      CALL wrf_debug ( 200 , ' call fddagd_driver' )
!
!BENCH_START(fdda_driver_tim)
!      CALL fddagd_driver(itimestep=grid%itimestep,dt=grid%dt,xtime=grid%XTIME,   &
!                  id=grid%id,      &
!                  RUNDGDTEN=grid%rundgdten,RVNDGDTEN=grid%rvndgdten,             &
!                  RTHNDGDTEN=grid%rthndgdten,RQVNDGDTEN=grid%rqvndgdten,         &
!                  RMUNDGDTEN=grid%rmundgdten,                                    &
!                  u_ndg_old=fdda3d(ims,kms,jms,P_u_ndg_old),              &
!                  v_ndg_old=fdda3d(ims,kms,jms,P_v_ndg_old),              &
!                  t_ndg_old=fdda3d(ims,kms,jms,P_t_ndg_old),              &
!                  q_ndg_old=fdda3d(ims,kms,jms,P_q_ndg_old),              &
!                  mu_ndg_old=fdda2d(ims,1,jms,P_mu_ndg_old),              &
!                  u_ndg_new=fdda3d(ims,kms,jms,P_u_ndg_new),              &
!                  v_ndg_new=fdda3d(ims,kms,jms,P_v_ndg_new),              &
!                  t_ndg_new=fdda3d(ims,kms,jms,P_t_ndg_new),              &
!                  q_ndg_new=fdda3d(ims,kms,jms,P_q_ndg_new),              &
!                  mu_ndg_new=fdda2d(ims,1,jms,P_mu_ndg_new),              &
!                  u3d=grid%u_2,v3d=grid%v_2,th_phy=th_phy,rho=rho,moist=moist,      &
!                  p_phy=p_phy,pi_phy=pi_phy,p8w=p8w,t_phy=t_phy,          &
!                  dz8w=dz8w,z=grid%z,z_at_w=z_at_w,                            &
!                  config_flags=config_flags,dx=grid%DX,n_moist=num_moist,  &
!                  STEPFG=grid%STEPFG,                                          &
!                  pblh=grid%pblh,ht=grid%ht,                                        &
!                    IDS=ids,IDE=ide, JDS=jds,JDE=jde, KDS=kds,KDE=kde     &
!                   ,IMS=ims,IME=ime, JMS=jms,JME=jme, KMS=kms,KME=kme     &
!                   ,I_START=grid%i_start,I_END=min(grid%i_end, ide-1)     &
!                   ,J_START=grid%j_start,J_END=min(grid%j_end, jde-1)     &
!                   ,KTS=k_start, KTE=min(k_end,kde-1)                     &
!                   , num_tiles=grid%num_tiles                             )
!BENCH_END(fdda_driver_tim)

!!****MARS
IF (config_flags%modif_wrf) THEN
!!!!!!!!!!!!!!!!!!!!!!!
! call to LMD physics !
!!!!!!!!!!!!!!!!!!!!!!!
         CALL wrf_debug ( 200 , ' call lmd_driver' )
         CALL lmd_driver(                                                 &
           ! structure
     &         id=grid%id,max_dom=grid%max_dom      &
     &        ,DT=grid%dt                   &
     &        ,ITIMESTEP=grid%itimestep                                   &
           ! position
     &        ,XLAT=grid%xlat,XLONG=grid%xlong                            &
     &        ,DX=grid%dx         ,DY=grid%dy                             &
     &        ,MSFT=grid%msftx,MSFU=grid%msfux,MSFV=grid%msfvx            &
!     &        ,MSFT=grid%msft,MSFU=grid%msfu,MSFV=grid%msfv               &
           ! indexes
     &        ,IDS=ids,IDE=ide, JDS=jds,JDE=jde, KDS=kds,KDE=kde          &
     &        ,IMS=ims,IME=ime, JMS=jms,JME=jme, KMS=kms,KME=kme          &
     &        ,i_start=grid%i_start,i_end=min(grid%i_end, ide-1)          &
     &        ,j_start=grid%j_start,j_end=min(grid%j_end, jde-1)          &
     &        ,kts=k_start, kte=min(k_end,kde-1)                          &
     &        ,num_tiles=grid%num_tiles                                   &
           ! time variables
     &        ,GMT=grid%gmt       ,JULYR=grid%julyr   ,JULDAY=grid%julday &
           ! output from phy_prep
     &        ,P8W=p8w            ,DZ8W=dz8w          ,T8W=t8w            &
           ! Prognostic variables at p points
!     &        ,Z=grid%em_z                                                &
     &        ,Z=grid%z                                                   &
                        ! z is the geopotential height at p points 
                        ! ... (cf phy_prep in module_big_step_utilities_em)
     &        ,HT=grid%ht                                                 &
     &        ,U=u_phy            ,V=v_phy             ,W=w_phy           &
     &        ,TH=th_phy          ,T=t_phy                                &
     &        ,P=p_phy            ,EXNER=pi_phy               ,RHO=rho    &
!!!!!ADDITION CAS IDEALISES
     &        ,PTOP=grid%p_top                                            &
           ! physics calls
     &        ,RADT=grid%radt                          &
     &        ,CUDT=grid%cudt                          &
           ! surface temperature and surface pressure
     &        ,TSK=grid%tsk,PSFC=grid%psfc                                &
           ! tendencies for the dynamics
     &        ,RTHBLTEN=grid%rthblten  ,RUBLTEN=grid%rublten,RVBLTEN=grid%rvblten    &
           ! scalars
!     &        ,NUM_3D_S=num_3d_s,SCALAR=grid%scalar                       &
     &        ,NUM_3D_S=num_scalar,SCALAR=grid%scalar                       &
     &        ,NUM_3D_M=num_moist,MOIST=grid%moist                      &
           ! mode
     &        ,MARS_MODE=config_flags%mars   &
#ifdef NEWPHYS
           ! planet
     &        ,planet_type=config_flags%planet   &
#endif
           ! added variables
     &        ,M_ALBEDO=grid%m_albedo,M_TI=grid%m_ti  &
     &        ,M_CO2ICE=grid%m_co2ice,M_EMISS=grid%m_emiss   &  
     &        ,M_H2OICE=grid%m_h2oice     &
     &        ,M_TSOIL=grid%m_tsoil       &
     &        ,M_Q2=grid%m_q2             &
     &        ,M_TSURF=grid%m_tsurf       &
#ifdef NEWPHYS
     &        ,M_FLUXRAD=grid%m_fluxrad   &
     &        ,M_WSTAR=grid%m_wstar       &
     &        ,M_ISOIL=grid%m_isoil       &
     &        ,M_DSOIL=grid%m_dsoil       &
     &        ,M_Z0=grid%m_z0             &
     &        ,CST_Z0=config_flags%init_Z0      &
#endif
     &        ,M_GW=grid%m_gw  &  
     &        ,NUM_SOIL_LAYERS=config_flags%num_soil_layers    &
           ! cst fields
     &        ,CST_AL=config_flags%init_AL  &
     &        ,CST_TI=config_flags%init_TI  &
     &        ,ISFFLX=config_flags%isfflx   &
     &        ,DIFF_OPT=config_flags%diff_opt     &
     &        ,KM_OPT=config_flags%km_opt         &
     &        ,HISTORY_INTERVAL=model_config_rec%history_interval(1)  &
          !------------------!
          ! OUTPUT VARIABLES !
          !------------------!
#ifdef NEWPHYS
     &       ,HR_SW=grid%HR_SW   &
     &       ,HR_LW=grid%HR_LW   &
     &       ,HR_DYN=grid%HR_DYN   &
     &       ,DDT=grid%DDT  &
     &       ,DT_RAD=grid%DT_RAD  &
     &       ,DT_VDF=grid%DT_VDF  &
     &       ,DT_AJS=grid%DT_AJS  &
     &       ,CLOUDFRAC=grid%CLOUDFRAC   &
     &       ,TOTCLOUDFRAC=grid%TOTCLOUDFRAC   &
     &       ,GRAIN=grid%GRAIN   &
     &       ,GSNOW=grid%GSNOW   &
     &       ,REEVAP=grid%REEVAP  &
     &       ,SURFRAIN=grid%SURFRAIN  &
     &       ,ALBEQ=grid%ALBEQ   &
     &       ,FLUXTOP_DN=grid%FLUXTOP_DN   &
     &       ,FLUXABS_SW=grid%FLUXABS_SW   &
     &       ,FLUXTOP_LW=grid%FLUXTOP_LW   &
     &       ,FLUXSURF_SW=grid%FLUXSURF_SW   &
     &       ,FLUXSURF_LW=grid%FLUXSURF_LW   &
     &       ,FLXGRD=grid%FLXGRD   &
     &       ,LSCEZ=grid%LSCEZ   &
     &       ,H2OICE_REFF=grid%H2OICE_REFF  &
     &       ,LATENT_HF=grid%LATENT_HF  &
     &       ,SWDOWNZ=grid%SWDOWNZ   &
     &       ,TAU_DUST=grid%TAU_DUST   &
     &       ,RDUST=grid%RDUST   &
     &       ,QSURFDUST=grid%QSURFDUST   &
     &       ,MTOT=grid%MTOT   &
     &       ,ICETOT=grid%ICETOT   &
     &       ,VMR_ICE=grid%VMR_ICE   &
     &       ,TAU_ICE=grid%TAU_ICE   &
     &       ,RICE=grid%RICE   &
     &       ,ZMAX=grid%ZMAX   &
     &       ,HFMAX=grid%HFMAX &
     &       ,USTM=grid%USTM   &
     &       ,HFX=grid%HFX &
#else 
#include "module_lmd_driver_output4.inc"
#endif
     &        ,SLPX=grid%slpx,SLPY=grid%slpy,RESTART=config_flags%restart)
ENDIF

!!!!!!!!!!!!!!!!!!!!!!!
! call to LMD physics !
!!!!!!!!!!!!!!!!!!!!!!!
!****MARS

  END SUBROUTINE first_rk_step_part1

END MODULE module_first_rk_step_part1

