Changeset 5872 for LMDZ6/branches


Ignore:
Timestamp:
Nov 18, 2025, 3:41:00 PM (4 days ago)
Author:
evignon
Message:

on prepare le terrain pour les iso dans la neige soufflee

Location:
LMDZ6/branches/lmdz-snow/libf
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • LMDZ6/branches/lmdz-snow/libf/phylmd/lmdz_blowing_snow_sublim_sedim.f90

    r5871 r5872  
    2525!=====
    2626
    27 integer, intent(in)                     :: ngrid,nlay
    28 real, intent(in)                        :: dtime
    29 real, intent(in), dimension(ngrid)      :: ustar
    30 real, intent(in), dimension(ngrid,nlay) :: temp
    31 real, intent(in), dimension(ngrid,nlay) :: qv
    32 real, intent(in), dimension(ngrid,nlay) :: qb
    33 real, intent(in), dimension(ngrid,nlay) :: pplay
    34 real, intent(in), dimension(ngrid,nlay+1) :: paprs
     27integer, intent(in)                     :: ngrid ! number of horizontal grid points
     28integer, intent(in)                     :: nlay  ! number of vertical layers
     29real, intent(in)                        :: dtime ! physics time step [s]
     30real, intent(in), dimension(ngrid)      :: ustar ! surface friction velocity [m/s]
     31real, intent(in), dimension(ngrid,nlay) :: temp  ! temperature of the air [K]
     32real, intent(in), dimension(ngrid,nlay) :: qv    ! specific content of water [kg/kg]
     33real, intent(in), dimension(ngrid,nlay) :: qb    ! specific content of blowing snow [kg/kg]
     34real, intent(in), dimension(ngrid,nlay) :: pplay ! pressure at the middle of layers [Pa]
     35real, intent(in), dimension(ngrid,nlay+1) :: paprs ! pressure at the layer bottom interface [Pa]
    3536
    3637
     
    4041
    4142
    42 real, intent(out), dimension(ngrid,nlay) :: dtemp_bs
    43 real, intent(out), dimension(ngrid,nlay) :: dqv_bs
    44 real, intent(out), dimension(ngrid,nlay) :: dqb_bs
    45 real, intent(out), dimension(ngrid,nlay+1) :: bsfl
    46 real, intent(out), dimension(ngrid)      :: precip_bs
     43real, intent(out), dimension(ngrid,nlay) :: dtemp_bs ! temperature tendency [K/s]
     44real, intent(out), dimension(ngrid,nlay) :: dqv_bs   ! water vapor tendency [kg/kg/s]
     45real, intent(out), dimension(ngrid,nlay) :: dqb_bs   ! blowing snow mass tendancy [kg/kg/s]
     46real, intent(out), dimension(ngrid,nlay+1) :: bsfl   ! vertical profile of blowing snow vertical flux [kg/m2/s]
     47real, intent(out), dimension(ngrid)      :: precip_bs ! surface sedimentation flux of blowing snow [kg/s/m2]
    4748
    4849
     
    293294
    294295! 3D variables
     296! tendencies of qb, qv and temperature
    295297DO k=1,nlay
    296298   DO i=1,ngrid
  • LMDZ6/branches/lmdz-snow/libf/phylmdiso/physiq_mod.F90

    r5842 r5872  
    1 !
     1
    22! $Id: physiq_mod.F90 3908 2021-05-20 07:11:13Z idelkadi $
    33!
     
    1818! For clarity, the "USE" section is now arranged in alphabetical order,
    1919! with a separate section for CPP keys
    20 ! PLEASE try to follow this rule 
     20! PLEASE try to follow this rule
    2121
    2222    USE ACAMA_GWD_rando_m, only: ACAMA_GWD_rando
     
    4646    USE ioipsl_getin_p_mod, ONLY : getin_p
    4747    USE indice_sol_mod
    48     USE infotrac_phy, ONLY: nqtot, nbtr, nqo, tracers, type_trac,addPhase, ivap, iliq, isol, ibs, icf, irvc
     48    USE infotrac_phy, ONLY: nqtot, nbtr, nqo, nqtke, tracers, type_trac, addPhase, ivap, iliq, isol, ibs, icf, irvc, itke
    4949    USE strings_mod,  ONLY: strIdx
    5050    USE iophy
     
    102102    USE calltherm_mod, ONLY : calltherm
    103103    USE lmdz_thermcell_dtke, ONLY : thermcell_dtke
    104     USE lmdz_blowing_snow_ini, ONLY : blowing_snow_ini , qbst_bs 
     104    USE lmdz_blowing_snow_ini, ONLY : blowing_snow_ini , qbst_bs
    105105    USE lmdz_lscp_ini, ONLY : lscp_ini
    106106    USE lmdz_ratqs_main, ONLY : ratqs_main
     
    116116!  &      fl_ebil, fl_cor_ebil
    117117
    118 !!!!!!!!!!!!!!!!!! "USE" section for CPP keys !!!!!!!!!!!!!!!!!!!!!!!!
    119 !
    120 !
     118
    121119    USE phytracr_spl_mod, ONLY: phytracr_spl, phytracr_spl_out_init
    122120    USE phys_output_write_spl_mod, ONLY: phys_output_write_spl
     
    207205       t_seri,q_seri,ql_seri,qs_seri,qbs_seri, &
    208206       u_seri,v_seri,cf_seri,rvc_seri,tr_seri, &
    209        rhcl, &       
     207       rhcl, &
    210208       qx_seri, & ! CR
    211209       rhcl, &       
    212210       ! Dynamic tendencies (diagnostics)
    213211       d_t_dyn,d_q_dyn,d_ql_dyn,d_qs_dyn,d_qbs_dyn, &
    214        d_u_dyn,d_v_dyn,d_cf_dyn,d_rvc_dyn,d_tr_dyn, &
     212       d_u_dyn,d_v_dyn,d_cf_dyn,d_rvc_dyn,d_tke_dyn,d_tr_dyn, &
    215213       d_q_dyn2d,d_ql_dyn2d,d_qs_dyn2d,d_qbs_dyn2d, &
    216214       ! Physic tendencies
    217        d_t_con,d_q_con,d_q_con_zmasse,d_u_con,d_v_con, &
     215       d_t_con,d_q_con,d_u_con,d_v_con, &
     216       d_t_con_zmasse,d_q_con_zmasse,d_u_con_zmasse,d_v_con_zmasse, &       
    218217       d_tr, &                              !! to be removed?? (jyg)
    219218       d_t_wake,d_q_wake, &
     
    286285       topswai_aerop, solswai_aerop,   &
    287286       topswad0_aerop, solswad0_aerop, &
    288        topsw_aerop, topsw0_aerop,      & 
     287       topsw_aerop, topsw0_aerop,      &
    289288       solsw_aerop, solsw0_aerop,      &
    290289       topswcf_aerop, solswcf_aerop,   &
     
    340339       !
    341340       wake_k, &
    342        alp_wake, & 
     341       alp_wake, &
    343342       wake_h, wake_omg, &
    344343                       ! tendencies of delta T and delta q:
     
    352351!!!       d_s_vdf, d_dens_a_vdf, d_dens_vdf, & ! due to vertical diffusion
    353352!!!       d_s_the, d_dens_a_the, d_dens_the, & ! due to thermals
    354        !                                 
     353       !
    355354       ptconv, ratqsc, &
    356355       wbeff, convoccur, zmax_th, &
     
    383382       !
    384383       rneblsvol, &
    385        pfraclr, pfracld, cldfraliq, sigma2_icefracturb, mean_icefracturb,  &
     384       pfraclr, pfracld, &
     385       cldfraliq, sigma2_icefracturb, mean_icefracturb,  &
    386386       cldfraliqth, sigma2_icefracturbth, mean_icefracturbth,  &
    387387       distcltop, temp_cltop,  &
     
    405405       t2m, fluxlat,  &
    406406       fsollw, evap_pot,  &
    407        fsolsw, wfbils, wfevap, & 
     407       fsolsw, wfbils, wfevap, &
    408408       prfl, psfl,bsfl, fraca, Vprecip,  &
    409409       zw2,  &
     
    415415       wwriteSTD, phiwriteSTD, &              !pour calcul_STDlev.h
    416416       qwriteSTD, twriteSTD, rhwriteSTD, &    !pour calcul_STDlev.h
    417        ! 
     417       !
    418418       beta_prec,  &
    419419       rneb,  &
     
    462462       USE conema3_mod_h
    463463       USE alpale_mod
    464     USE yoethf_mod_h
    465     USE calcul_divers_mod_h, ONLY: calcul_divers
    466     USE compbl_mod_h
    467     USE nuage_params_mod_h
    468     USE dimpft_mod_h, ONLY: nvm_lmdz
    469     USE radepsi_mod_h
    470     USE radopt_mod_h
    471     USE regdim_mod_h
     464       USE yoethf_mod_h
     465       USE calcul_divers_mod_h, ONLY: calcul_divers
     466       USE compbl_mod_h
     467       USE nuage_params_mod_h
     468       USE dimpft_mod_h, ONLY: nvm_lmdz
     469       USE radepsi_mod_h
     470       USE radopt_mod_h
     471       USE regdim_mod_h
    472472    IMPLICIT NONE
    473473    !>======================================================================
     
    479479    !!AA                  -  uniformisation des parametrisations ds phytrac
    480480    !!AA                  -  stockage des moyennes des champs necessaires
    481     !!AA                     en mode traceur off-line 
     481    !!AA                     en mode traceur off-line
    482482    !!======================================================================
    483483    !!   CLEFS CPP POUR LES IO
     
    543543    ! Clef iflag_cycle_diurne controlant l'activation du cycle diurne:
    544544    ! en attente du codage des cles par Fred
    545     ! iflag_cycle_diurne est initialise par conf_phys et se trouve 
     545    ! iflag_cycle_diurne est initialise par conf_phys et se trouve
    546546    ! dans clesphys.h (IM)
    547547    !======================================================================
     
    568568    !$OMP THREADPRIVATE(ok_instan)
    569569    !
    570     LOGICAL ok_LES ! sortir le fichier LES 
    571     SAVE ok_LES                           
    572     !$OMP THREADPRIVATE(ok_LES)                 
    573     !
    574     LOGICAL callstats ! sortir le fichier stats 
    575     SAVE callstats                           
    576     !$OMP THREADPRIVATE(callstats)                 
     570    LOGICAL ok_LES ! sortir le fichier LES
     571    SAVE ok_LES
     572    !$OMP THREADPRIVATE(ok_LES)
     573    !
     574    LOGICAL callstats ! sortir le fichier stats
     575    SAVE callstats
     576    !$OMP THREADPRIVATE(callstats)
    577577    !
    578578    LOGICAL ok_region ! sortir le fichier regional
     
    582582    SAVE seuil_inversion
    583583    !$OMP THREADPRIVATE(seuil_inversion)
    584    
    585    
    586    
     584
     585
     586
    587587    real facteur
    588588
     
    643643!!    real wght_cvfd(klon,klev)
    644644!!    ! Variables pour le lessivage convectif
    645 !!    ! RomP >>> 
     645!!    ! RomP >>>
    646646!!    real phi2(klon,klev,klev)
    647647!!    real d1a(klon,klev),dam(klon,klev)
     
    659659    INTEGER n
    660660    !ym      INTEGER npoints
    661     !ym      PARAMETER(npoints=klon) 
     661    !ym      PARAMETER(npoints=klon)
    662662    !
    663663    INTEGER nregISCtot
    664     PARAMETER(nregISCtot=1) 
     664    PARAMETER(nregISCtot=1)
    665665    !
    666666    ! imin_debut, nbpti, jmin_debut, nbptj : parametres pour sorties
     
    671671    ! direction j (latitude)
    672672!JLD    INTEGER imin_debut, nbpti
    673 !JLD    INTEGER jmin_debut, nbptj 
     673!JLD    INTEGER jmin_debut, nbptj
    674674    !IM: region='3d' <==> sorties en global
    675675    CHARACTER*3 region
     
    783783    !
    784784!!!    INTEGER, SAVE, DIMENSION(klon)   :: wake_k
    785 !!!    !$OMP THREADPRIVATE(wake_k) 
     785!!!    !$OMP THREADPRIVATE(wake_k)
    786786#ifdef ISO
    787787    REAL xt_x(ntraciso,klon,klev)
     
    790790    !
    791791    !jyg<
    792     !cc      REAL wake_pe(klon)              ! Wake potential energy - WAPE 
     792    !cc      REAL wake_pe(klon)              ! Wake potential energy - WAPE
    793793    !>jyg
    794794
     
    807807    REAL d_q_adjwk(klon,klev)                !jyg
    808808    LOGICAL,SAVE :: ok_adjwk=.FALSE.
    809     !$OMP THREADPRIVATE(ok_adjwk) 
     809    !$OMP THREADPRIVATE(ok_adjwk)
    810810    INTEGER,SAVE :: iflag_adjwk=0            !jyg
    811811    !$OMP THREADPRIVATE(iflag_adjwk)         !jyg
    812812    REAL,SAVE :: oliqmax=999.,oicemax=999.
    813     !$OMP THREADPRIVATE(oliqmax,oicemax) 
     813    !$OMP THREADPRIVATE(oliqmax,oicemax)
    814814    REAL, SAVE :: alp_offset
    815815    !$OMP THREADPRIVATE(alp_offset)
     
    830830    REAL ztv(klon,klev),ztva(klon,klev)
    831831    REAL zpspsk(klon,klev)
    832     REAL ztla(klon,klev),zqla(klon,klev) 
     832    REAL ztla(klon,klev),zqla(klon,klev)
    833833    REAL zthl(klon,klev)
    834834
     
    836836
    837837    !--------Stochastic Boundary Layer Triggering: ALE_BL--------
    838     !---Propri\'et\'es du thermiques au LCL 
     838    !---Propri\'et\'es du thermiques au LCL
    839839!    real zlcl_th(klon)          ! Altitude du LCL calcul\'e
    840840    ! continument (pcon dans
     
    844844    real w_conv(klon)           ! Vitesse verticale de grande \'echelle au LCL
    845845    real tke0(klon,klev+1)      ! TKE au d\'ebut du pas de temps
    846     real therm_tke_max0(klon)   ! TKE dans les thermiques au LCL 
    847     real env_tke_max0(klon)     ! TKE dans l'environnement au LCL 
     846    real therm_tke_max0(klon)   ! TKE dans les thermiques au LCL
     847    real env_tke_max0(klon)     ! TKE dans l'environnement au LCL
    848848    INTEGER, SAVE :: iflag_thermcell_tke ! transtport TKE by thermals
    849849    !$OMP THREADPRIVATE(iflag_thermcell_tke)
     
    853853
    854854    REAL,SAVE :: random_notrig_max=1.
    855     !$OMP THREADPRIVATE(random_notrig_max) 
     855    !$OMP THREADPRIVATE(random_notrig_max)
    856856
    857857    !--------Statistical Boundary Layer Closure: ALP_BL--------
     
    862862    !-------Activer les tendances de TKE due a l'orograp??ie---------
    863863     INTEGER, SAVE :: addtkeoro
    864     !$OMP THREADPRIVATE(addtkeoro) 
     864    !$OMP THREADPRIVATE(addtkeoro)
    865865     REAL, SAVE :: alphatkeoro
    866     !$OMP THREADPRIVATE(alphatkeoro) 
     866    !$OMP THREADPRIVATE(alphatkeoro)
    867867     LOGICAL, SAVE :: smallscales_tkeoro
    868     !$OMP THREADPRIVATE(smallscales_tkeoro) 
     868    !$OMP THREADPRIVATE(smallscales_tkeoro)
    869869
    870870
     
    881881    !
    882882    !AA
    883     !AA  Pour phytrac 
     883    !AA  Pour phytrac
    884884    REAL u1(klon)             ! vents dans la premiere couche U
    885885    REAL v1(klon)             ! vents dans la premiere couche V
     
    890890    REAL frac_impa(klon,klev) ! fractions d'aerosols lessivees (impaction)
    891891    REAL frac_nucl(klon,klev) ! idem (nucleation)
    892     ! RomP >>> 
     892    ! RomP >>>
    893893    REAL beta_prec_fisrt(klon,klev) ! taux de conv de l'eau cond (fisrt)
    894894    ! RomP <<<
     
    917917    INTEGER lmt_pas
    918918    SAVE lmt_pas                ! frequence de mise a jour
    919     !$OMP THREADPRIVATE(lmt_pas) 
    920     real zmasse(klon, nbp_lev),exner(klon, nbp_lev) 
     919    !$OMP THREADPRIVATE(lmt_pas)
     920    real zmasse(klon, nbp_lev),exner(klon, nbp_lev)
    921921    !     (column-density of mass of air in a cell, in kg m-2)
    922922    real, parameter:: dobson_u = 2.1415e-05 ! Dobson unit, in kg m-2
     
    963963    REAL radocond(klon,klev)  ! eau condensee nuageuse
    964964    !
    965     !XXX PB 
     965    !XXX PB
    966966    REAL fluxq(klon,klev, nbsrf)   ! flux turbulent d'humidite
    967967    REAL fluxqbs(klon,klev, nbsrf)   ! flux turbulent de neige soufflee
     
    10281028    ! La convection n'est pas calculee tous les pas, il faut donc
    10291029    !                      sauvegarder les sorties de la convection
    1030     !ym      SAVE 
    1031     !ym      SAVE 
    1032     !ym      SAVE 
     1030    !ym      SAVE
     1031    !ym      SAVE
     1032    !ym      SAVE
    10331033    !
    10341034    INTEGER itapcv, itapwk
     
    10761076#endif
    10771077    !
    1078     ! Flag pour pouvoir ne pas ajouter les tendances. 
     1078    ! Flag pour pouvoir ne pas ajouter les tendances.
    10791079    ! Par defaut, les tendances doivente etre ajoutees et
    10801080    ! flag_inhib_tend = 0
    1081     ! flag_inhib_tend > 0 : tendances non ajoutees, avec un nombre 
     1081    ! flag_inhib_tend > 0 : tendances non ajoutees, avec un nombre
    10821082    ! croissant de print quand la valeur du flag augmente
    10831083    !!! attention, ce flag doit etre change avec prudence !!!
     
    10851085!!    INTEGER :: flag_inhib_tend = 2
    10861086    !
    1087     ! Logical switch to a bug : reseting to 0 convective variables at the 
     1087    ! Logical switch to a bug : reseting to 0 convective variables at the
    10881088    ! begining of physiq.
    10891089    LOGICAL, SAVE :: ok_bug_cv_trac = .TRUE.
     
    10951095    !$OMP THREADPRIVATE(ok_bug_split_th)
    10961096
    1097     ! Logical switch to a bug : modifying directly wake_deltat  by adding 
     1097    ! Logical switch to a bug : modifying directly wake_deltat  by adding
    10981098    ! the (w) dry adjustment tendency to wake_deltat
    10991099    LOGICAL, SAVE :: ok_bug_ajs_cv = .TRUE.
    11001100    !$OMP THREADPRIVATE(ok_bug_ajs_cv)
     1101
    11011102    !
    11021103    !********************************************************
     
    11751176    !
    11761177    REAL zx_tmp_fi2d(klon)      ! variable temporaire grille physique
    1177     REAL zx_tmp_fi3d(klon,klev) ! variable temporaire pour champs 3D 
     1178    REAL zx_tmp_fi3d(klon,klev) ! variable temporaire pour champs 3D
    11781179!JLD    REAL zx_tmp_2d(nbp_lon,nbp_lat)
    11791180!JLD    REAL zx_lon(nbp_lon,nbp_lat)
     
    12061207    LOGICAL, SAVE ::  ok_sync, ok_sync_omp
    12071208    !$OMP THREADPRIVATE(ok_sync)
     1209    ! ok_sync_omp should not be in a THREADPRIVATE statement
    12081210    REAL date0
    12091211
    12101212    ! essai writephys
    12111213    INTEGER fid_day, fid_mth, fid_ins
    1212     PARAMETER (fid_ins = 1, fid_day = 2, fid_mth = 3) 
     1214    PARAMETER (fid_ins = 1, fid_day = 2, fid_mth = 3)
    12131215    INTEGER prof2d_on, prof3d_on, prof2d_av, prof3d_av
    12141216    PARAMETER (prof2d_on = 1, prof3d_on = 2, prof2d_av = 3, prof3d_av = 4)
     
    12291231    INTEGER :: naero
    12301232    ! Aerosol optical properties
    1231     CHARACTER*4, DIMENSION(naero_grp) :: rfname 
     1233    CHARACTER*4, DIMENSION(naero_grp) :: rfname
    12321234    REAL, DIMENSION(klon,klev)     :: mass_solu_aero ! total mass
    12331235    ! concentration
     
    12471249    LOGICAL, SAVE :: aerosol_couple ! true  : calcul des aerosols dans INCA
    12481250    ! false : lecture des aerosol dans un fichier
    1249     !$OMP THREADPRIVATE(aerosol_couple)   
    1250     LOGICAL, SAVE :: chemistry_couple ! true  : use INCA chemistry O3 
     1251    !$OMP THREADPRIVATE(aerosol_couple)
     1252    LOGICAL, SAVE :: chemistry_couple ! true  : use INCA chemistry O3
    12511253    ! false : use offline chemistry O3
    1252     !$OMP THREADPRIVATE(chemistry_couple)   
    1253     INTEGER, SAVE :: flag_aerosol 
    1254     !$OMP THREADPRIVATE(flag_aerosol) 
     1254    !$OMP THREADPRIVATE(chemistry_couple)
     1255    INTEGER, SAVE :: flag_aerosol
     1256    !$OMP THREADPRIVATE(flag_aerosol)
    12551257    LOGICAL, SAVE :: flag_bc_internal_mixture
    12561258    !$OMP THREADPRIVATE(flag_bc_internal_mixture)
     
    12841286    REAL, ALLOCATABLE, SAVE :: press_edg_climoz(:) ! Edges of pressure intervals
    12851287    REAL, ALLOCATABLE, SAVE :: time_climoz(:)      ! Time vector
     1288
    12861289    CHARACTER(LEN=13), PARAMETER :: vars_climoz(2) &
    12871290                                  = ["tro3         ","tro3_daylight"]
     
    12921295
    12931296    include "FCTTRE.h"
    1294 
     1297    !IM 100106 END : pouvoir sortir les ctes de la physique
     1298    !
    12951299    ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    12961300    ! Declarations pour Simulateur COSP
     
    13061310    INTEGER, ALLOCATABLE, SAVE :: tabCFMIP(:)
    13071311    REAL, ALLOCATABLE, SAVE :: lonCFMIP(:), latCFMIP(:)
    1308     !$OMP THREADPRIVATE(tabCFMIP, lonCFMIP, latCFMIP) 
     1312    !$OMP THREADPRIVATE(tabCFMIP, lonCFMIP, latCFMIP)
    13091313    INTEGER, ALLOCATABLE, SAVE :: tabijGCM(:)
    13101314    REAL, ALLOCATABLE, SAVE :: lonGCM(:), latGCM(:)
     
    13451349
    13461350    !lwoff=y : offset LW CRE for radiation code and other schemes
    1347     REAL, SAVE :: betalwoff 
    1348     !OMP THREADPRIVATE(betalwoff)
     1351    REAL, SAVE :: betalwoff
     1352    !$OMP THREADPRIVATE(betalwoff)
    13491353!
    13501354    INTEGER :: nbtr_tmp ! Number of tracer inside concvl
     
    13881392    CHARACTER(len=512) :: namelist_ecrad_file
    13891393
     1394
    13901395    ! Subgrid scale wind :
    13911396    ! Need to be allocatable/save because the number of bin is not known (provided by surf_wind_ini)
    1392     integer, save :: nsurfwind=1 
     1397    integer, save :: nsurfwind=1
    13931398    real, dimension(:,:), allocatable, save :: surf_wind_value, surf_wind_proba ! module and probability of sugrdi wind wind sample
    13941399    !$OMP THREADPRIVATE(nsurfwind,surf_wind_value, surf_wind_proba)
     1400
    13951401
    13961402    !======================================================================!
     
    14031409       call getin_p('iflag_physiq', iflag_physiq)                          !
    14041410    endif                                                                  !
    1405     if ( iflag_physiq == 2 ) then
     1411    if ( iflag_physiq == 2 ) then                                          !
    14061412#ifdef ISO
    14071413       abort_message='isotopes pas encore dans physiqex'
     
    14231429    ! set-up call to alerte function
    14241430    call_alert = (alert_first_call .AND. is_master)
    1425    
     1431
    14261432    ! Ehouarn: set value of jjmp1 since it is no longer a "fixed parameter"
    14271433    jjmp1=nbp_lat
     
    14361442
    14371443    IF (using_xios) THEN
    1438       ! switch to XIOS LMDZ physics context 
     1444      ! switch to XIOS LMDZ physics context
    14391445      IF (.NOT. debut .AND. is_omp_master) THEN
    14401446        CALL wxios_set_context()
     
    14561462            'nlon,klev,nqtot,debut,lafin, jD_cur, jH_cur,pdtphys'
    14571463       write(lunout,*) &
    1458             nlon,klev,nqtot,debut,lafin, jD_cur, jH_cur,pdtphys 
     1464            nlon,klev,nqtot,debut,lafin, jD_cur, jH_cur,pdtphys
    14591465
    14601466       write(lunout,*) 'paprs, play, phi, u, v, t'
     
    14731479            "physiq_mod paprs bad order")
    14741480
    1475     IF (first) THEN 
     1481    IF (first) THEN
    14761482!       CALL init_etat0_limit_unstruct
    14771483       IF (.NOT. create_etat0_limit) CALL init_limit_read(days_elapsed)
     
    15021508       CALL phys_state_var_init(read_climoz)
    15031509       CALL phys_output_var_init
    1504        IF (read_climoz>=1 .AND. create_etat0_limit .AND. grid_type==unstructured) & 
     1510       IF (read_climoz>=1 .AND. create_etat0_limit .AND. grid_type==unstructured) &
    15051511          CALL regr_horiz_time_climoz(read_climoz,ok_daily_climoz)
    15061512
     
    15531559
    15541560        IF (ok_bs) THEN
    1555 #ifdef ISO
    1556           abort_message='blowing snow cannot be activated with water isotopes yet'
    1557           CALL abort_physic(modname,abort_message, 1)
    1558 #endif
    1559          IF ((ok_ice_supersat.AND.nqo .LT.6).OR.(.NOT.ok_ice_supersat.AND.nqo.LT.5)) THEN
     1561         IF ((ok_ice_supersat.AND.nqo .LT.6).OR.(.NOT.ok_ice_supersat.AND.nqo.LT.4)) THEN
    15601562             WRITE (lunout, *) 'activation of blowing snow needs a specific H2O tracer', &
    15611563                               'but nqo=', nqo
     
    15641566         ENDIF
    15651567        ENDIF
     1568
     1569        IF (ok_advtke) THEN
     1570         IF (nqtke .LT. 1) THEN
     1571             WRITE (lunout, *) 'activation of TKE advection need a specific TKE tracer', &
     1572                               'but nqtke=', nqtke
     1573             abort_message='see above'
     1574             CALL abort_physic(modname,abort_message, 1)
     1575         ENDIF
     1576        ENDIF
     1577
    15661578
    15671579       Ncvpaseq1 = 0
     
    15791591    ENDIF  ! first
    15801592
    1581     !ym => necessaire pour iflag_con != 2   
     1593    !ym => necessaire pour iflag_con != 2
    15821594    pmfd(:,:) = 0.
    15831595    pen_u(:,:) = 0.
     
    16091621       call getin_p('iflag_thermcell_tke', iflag_thermcell_tke)                          !
    16101622
    1611        CALL getin_p('iflag_alp_wk_cond', iflag_alp_wk_cond) 
     1623       CALL getin_p('iflag_alp_wk_cond', iflag_alp_wk_cond)
    16121624       CALL getin_p('random_notrig_max',random_notrig_max)
    1613        CALL getin_p('ok_adjwk',ok_adjwk) 
     1625       CALL getin_p('ok_adjwk',ok_adjwk)
    16141626       IF (ok_adjwk) iflag_adjwk=2  ! for compatibility with older versions
    16151627       ! iflag_adjwk: ! 0 = Default: no convective adjustment of w-region
     
    16521664       WRITE(lunout,*) 'ok_adjwk=',           ok_adjwk
    16531665       WRITE(lunout,*) 'iflag_adjwk=',        iflag_adjwk
    1654        WRITE(lunout,*) 'qtcon_multistep_max=',dtcon_multistep_max 
    1655        WRITE(lunout,*) 'qdcon_multistep_max=',dqcon_multistep_max 
     1666       WRITE(lunout,*) 'qtcon_multistep_max=',dtcon_multistep_max
     1667       WRITE(lunout,*) 'qdcon_multistep_max=',dqcon_multistep_max
    16561668       WRITE(lunout,*) 'ratqsp0=',            ratqsp0
    1657        WRITE(lunout,*) 'ratqsdp=',            ratqsdp 
     1669       WRITE(lunout,*) 'ratqsdp=',            ratqsdp
    16581670       WRITE(lunout,*) 'iflag_wake_tend=',    iflag_wake_tend
    1659        WRITE(lunout,*) 'ok_bad_ecmwf_thermo=',ok_bad_ecmwf_thermo 
    1660        WRITE(lunout,*) 'ok_bug_cv_trac=',     ok_bug_cv_trac 
     1671       WRITE(lunout,*) 'ok_bad_ecmwf_thermo=',ok_bad_ecmwf_thermo
     1672       WRITE(lunout,*) 'ok_bug_cv_trac=',     ok_bug_cv_trac
    16611673       WRITE(lunout,*) 'ok_bug_split_th=',    ok_bug_split_th
    16621674       WRITE(lunout,*) 'fl_ebil=',            fl_ebil
     
    16941706       !des caracteristiques du thermique
    16951707       wght_th(:,:)=1.
    1696        lalim_conv(:)=1 
     1708       lalim_conv(:)=1
    16971709       !RC
    16981710       ustar(:,:)=0.
     
    17201732          CALL getin_p('config_inca',config_inca)
    17211733
    1722        ELSE 
     1734       ELSE
    17231735          config_inca='none' ! default
    17241736       ENDIF
     
    18001812
    18011813       IF (iflag_pbl>1) THEN
    1802           PRINT*, "Using method MELLOR&YAMADA" 
     1814          PRINT*, "Using method MELLOR&YAMADA"
    18031815       ENDIF
    18041816
     
    18181830       IF (MOD(NINT(86400./phys_tstep),nbapp_rad).EQ.0) THEN
    18191831          radpas = NINT( 86400./phys_tstep)/nbapp_rad
    1820        ELSE 
     1832       ELSE
    18211833          WRITE(lunout,*) 'le nombre de pas de temps physique doit etre un ', &
    18221834               'multiple de nbapp_rad'
     
    18341846          cvpas = cvpas_0
    18351847       print *,'physiq, cvpas ',cvpas
    1836        ELSE 
     1848       ELSE
    18371849          WRITE(lunout,*) 'le nombre de pas de temps physique doit etre un ', &
    18381850               'multiple de nbapp_cv'
     
    18461858          wkpas = NINT( 86400./phys_tstep)/nbapp_wk
    18471859!       print *,'physiq, wkpas ',wkpas
    1848        ELSE 
     1860       ELSE
    18491861          WRITE(lunout,*) 'le nombre de pas de temps physique doit etre un ', &
    18501862               'multiple de nbapp_wk'
     
    18821894             ALLOCATE(iGCM(nCFMIP), jGCM(nCFMIP))
    18831895             !
    1884              ! lecture des nCFMIP stations CFMIP, de leur numero 
     1896             ! lecture des nCFMIP stations CFMIP, de leur numero
    18851897             ! et des coordonnees geographiques lonCFMIP, latCFMIP
    18861898             !
     
    19301942!       WRITE(lunout,*)'OK freq_outNMC(3)=',freq_outNMC(3)
    19311943
    1932 
    19331944#ifndef CPP_XIOS
    19341945       CALL ini_paramLMDZ_phy(phys_tstep,nid_ctesGCM)
     
    19391950
    19401951       !XXXPB Positionner date0 pour initialisation de ORCHIDEE
    1941        date0 = jD_ref 
     1952       date0 = jD_ref
    19421953       WRITE(*,*) 'physiq date0 : ',date0
    19431954       !
     
    20002011       CALL iniradia(klon,klev,paprs(1,1:klev+1))
    20012012
    2002 
     2013       
    20032014!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    20042015       CALL surf_wind_ini(klon,lunout)
    20052016       CALL getin_p('nsurfwind',nsurfwind)
    20062017       allocate(surf_wind_value(klon,nsurfwind),surf_wind_proba(klon,nsurfwind))
    2007 
     2018!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
     2019       ! initialisation des variables tkeoro
     2020       addtkeoro=0
     2021       CALL getin_p('addtkeoro',addtkeoro)
     2022
     2023       alphatkeoro=1.
     2024       CALL getin_p('alphatkeoro',alphatkeoro)
     2025       alphatkeoro=min(max(0.,alphatkeoro),1.)
     2026
     2027       smallscales_tkeoro=.FALSE.
     2028       CALL getin_p('smallscales_tkeoro',smallscales_tkeoro)
     2029       
    20082030!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    20092031       CALL wake_ini(iflag_wake,rg,rd,rv,prt_level)
     
    20252047             IF (ok_cdnc.AND.NRADLP.NE.3) THEN
    20262048             abort_message='RRTM choix incoherent NRADLP doit etre egal a 3 ' &
    2027                   // 'pour ok_cdnc' 
     2049                  // 'pour ok_cdnc'
    20282050             CALL abort_physic(modname,abort_message,1)
    20292051             ENDIF
     
    20342056#endif
    20352057          ENDIF
    2036        ENDIF   
     2058       ENDIF
    20372059       CALL cloud_optics_prop_ini(klon, klev, prt_level, lunout, flag_aerosol, &
    20382060                                  & ok_cdnc, bl95_b0, &
     
    20592081                                flag_aerosol, flag_aerosol_strat, ok_cdnc)
    20602082ELSE
    2061        ! phys_output_write écrit des variables traceurs seulement si iflag_phytrac == 1 
     2083       ! phys_output_write écrit des variables traceurs seulement si iflag_phytrac == 1
    20622084       ! donc seulement dans ce cas on doit appeler phytrac_init()
    20632085       IF (iflag_phytrac == 1 ) THEN
     
    20762098         IF (is_omp_master) CALL xios_update_calendar(1)
    20772099       ENDIF
    2078        
     2100
    20792101       IF(read_climoz>=1 .AND. create_etat0_limit) CALL regr_horiz_time_climoz(read_climoz,ok_daily_climoz)
    20802102       CALL create_etat0_limit_unstruct
     
    21382160       ENDIF
    21392161       !
    2140        IF (phys_tstep*REAL(radpas).GT.21600..AND.iflag_cycle_diurne.GE.1) THEN 
     2162       IF (phys_tstep*REAL(radpas).GT.21600..AND.iflag_cycle_diurne.GE.1) THEN
    21412163          WRITE(lunout,*)'Nbre d appels au rayonnement insuffisant'
    21422164          WRITE(lunout,*)"Au minimum 4 appels par jour si cycle diurne"
     
    22672289       !=============================================================
    22682290
    2269        IF (using_xios) THEN   
     2291       IF (using_xios) THEN
    22702292         ! Get "missing_val" value from XML files (from temperature variable)
    22712293         IF (is_omp_master) CALL xios_get_field_attr("temp",default_value=missing_val)
     
    22732295       ENDIF
    22742296
    2275        IF (using_xios) THEN   
     2297       IF (using_xios) THEN
    22762298         ! Need to put this initialisation after phyetat0 as in the coupled model the XIOS context is only
    22772299         ! initialised at that moment
     
    22792301         IF (is_omp_master) CALL xios_get_field_attr("temp",default_value=missing_val)
    22802302         CALL bcast_omp(missing_val)
    2281        ! 
     2303       !
    22822304       ! Now we activate some double radiation call flags only if some
    22832305       ! diagnostics are requested, otherwise there is no point in doing this
    22842306         IF (is_master) THEN
    2285            !--setting up swaero_diag to TRUE in XIOS case 
    2286            IF (xios_field_is_active("topswad").OR.xios_field_is_active("topswad0").OR. & 
    2287               xios_field_is_active("solswad").OR.xios_field_is_active("solswad0").OR. & 
    2288               xios_field_is_active("topswai").OR.xios_field_is_active("solswai").OR.  & 
     2307           !--setting up swaero_diag to TRUE in XIOS case
     2308           IF (xios_field_is_active("topswad").OR.xios_field_is_active("topswad0").OR. &
     2309              xios_field_is_active("solswad").OR.xios_field_is_active("solswad0").OR. &
     2310              xios_field_is_active("topswai").OR.xios_field_is_active("solswai").OR.  &
    22892311                (iflag_rrtm==1.AND.(xios_field_is_active("toplwad").OR.xios_field_is_active("toplwad0").OR. &
    22902312                                    xios_field_is_active("sollwad").OR.xios_field_is_active("sollwad0"))))  &
    2291               !!!--for now these fields are not in the XML files so they are omitted
    2292               !!!  xios_field_is_active("toplwai").OR.xios_field_is_active("sollwai") !))) &
    2293               swaero_diag=.TRUE.
    2294  
     2313              !!!--for now these fields are not in the XML files so they are omitted
     2314              !!!  xios_field_is_active("toplwai").OR.xios_field_is_active("sollwai") !))) &
     2315              swaero_diag=.TRUE.
    22952316           !--setting up swaerofree_diag to TRUE in XIOS case
    22962317           IF (xios_field_is_active("SWdnSFCcleanclr").OR.xios_field_is_active("SWupSFCcleanclr").OR. &
     
    22982319              xios_field_is_active("rsdcsaf") .OR. xios_field_is_active("LWdnSFCcleanclr").OR. &
    22992320              xios_field_is_active("LWupTOAcleanclr")) &
    2300               swaerofree_diag=.TRUE. 
    2301  
    2302            !--setting up dryaod_diag to TRUE in XIOS case 
     2321              swaerofree_diag=.TRUE.
     2322
     2323           !--setting up dryaod_diag to TRUE in XIOS case
    23032324           DO naero = 1, naero_tot-1
    2304              IF (xios_field_is_active("dryod550_"//name_aero_tau(naero))) dryaod_diag=.TRUE. 
     2325             IF (xios_field_is_active("dryod550_"//name_aero_tau(naero))) dryaod_diag=.TRUE.
    23052326           ENDDO
    23062327           !
    2307           !--setting up ok_4xCO2atm to TRUE in XIOS case 
    2308            IF (xios_field_is_active("rsut4co2").OR.xios_field_is_active("rlut4co2").OR. & 
     2328          !--setting up ok_4xCO2atm to TRUE in XIOS case
     2329           IF (xios_field_is_active("rsut4co2").OR.xios_field_is_active("rlut4co2").OR. &
    23092330              xios_field_is_active("rsutcs4co2").OR.xios_field_is_active("rlutcs4co2").OR. &
    23102331              xios_field_is_active("rsu4co2").OR.xios_field_is_active("rsucs4co2").OR. &
     
    23122333              xios_field_is_active("rlu4co2").OR.xios_field_is_active("rlucs4co2").OR. &
    23132334              xios_field_is_active("rld4co2").OR.xios_field_is_active("rldcs4co2")) &
    2314               ok_4xCO2atm=.TRUE. 
     2335              ok_4xCO2atm=.TRUE.
    23152336           ENDIF
    23162337           !$OMP BARRIER
     
    24942515      ENDIF
    24952516      WRITE(*,*)'ok_lwoff=',ok_lwoff
    2496       ! 
     2517      !
    24972518      !lwoff=y to begin only sollw and sollwdown are set up to CS values
    24982519      sollw = sollw + betalwoff * (sollw0 - sollw)
     
    25222543    !
    25232544    !
    2524     ! Update fraction of the sub-surfaces (pctsrf) and 
    2525     ! initialize, where a new fraction has appeared, all variables depending 
     2545    ! Update fraction of the sub-surfaces (pctsrf) and
     2546    ! initialize, where a new fraction has appeared, all variables depending
    25262547    ! on the surface fraction.
    25272548    !
     
    25832604    beta_prec(:,:)=0.
    25842605    !
    2585     !   Output variables from the convective scheme should not be set to 0 
     2606    !   Output variables from the convective scheme should not be set to 0
    25862607    !   since convection is not always called at every time step.
    25872608    IF (ok_bug_cv_trac) THEN
     
    26312652    ENDDO
    26322653
     2654    ! in case of TKE advection, we interpolate vertically
     2655    ! since TKE is defined at the bottom interface of layers but
     2656    ! it is interpolated onto middle layers for advection
     2657
     2658    IF (ok_advtke) THEN
     2659      DO k=2,klev
     2660        DO i=1,klon
     2661           pbl_tke(i,k,:)=(qx(i,k-1,itke)*zmasse(i,k-1)+qx(i,k,itke)*zmasse(i,k))/(zmasse(i,k-1)+zmasse(i,k))
     2662        ENDDO
     2663      ENDDO
     2664    ENDIF
     2665
     2666    tke0(:,:)=pbl_tke(:,:,is_ave)
     2667
     2668
    26332669    ! C Risi: dispatcher les isotopes dans les xt_seri
    26342670#ifdef ISO
     
    26952731    !--fin mass fixer
    26962732
    2697     tke0(:,:)=pbl_tke(:,:,is_ave)
    2698     IF (nqtot > nqo) THEN
     2733    IF (nqtot > (nqo+nqtke)) THEN
    26992734       ! water isotopes are not included in tr_seri
    27002735       itr = 0
     
    27212756         IF(.NOT.tracers(iq)%isInPhysics) CYCLE
    27222757         itr = itr+1
    2723          tr_ancien(:,:,itr)=tr_seri(:,:,itr)       
     2758         tr_ancien(:,:,itr)=tr_seri(:,:,itr)
    27242759       enddo
    27252760    ENDIF
     
    27942829       d_cf_dyn(:,:) = (cf_seri(:,:)-cf_ancien(:,:))/phys_tstep
    27952830       d_rvc_dyn(:,:)= (rvc_seri(:,:)-rvc_ancien(:,:))/phys_tstep
     2831       d_tke_dyn(:,:)= (pbl_tke(:,:,is_ave)-tke_ancien(:,:))/phys_tstep
    27962832       CALL water_int(klon,klev,q_seri,zmasse,zx_tmp_fi2d)
    27972833       d_q_dyn2d(:)=(zx_tmp_fi2d(:)-prw_ancien(:))/phys_tstep
     
    28032839       d_qbs_dyn2d(:)=(zx_tmp_fi2d(:)-prbsw_ancien(:))/phys_tstep
    28042840       ! !! RomP >>>   td dyn traceur
    2805        IF (nqtot > nqo) d_tr_dyn(:,:,:)=(tr_seri(:,:,:)-tr_ancien(:,:,:))/phys_tstep
     2841       IF (nqtot > (nqo+nqtke)) d_tr_dyn(:,:,:)=(tr_seri(:,:,:)-tr_ancien(:,:,:))/phys_tstep
    28062842       ! !! RomP <<<
    28072843
     
    28892925       d_cf_dyn(:,:) = 0.0
    28902926       d_rvc_dyn(:,:)= 0.0
     2927       d_tke_dyn(:,:)= 0.0
    28912928       d_q_dyn2d(:)  = 0.0
    28922929       d_ql_dyn2d(:) = 0.0
     
    29132950
    29142951       ! !! RomP >>>   td dyn traceur
    2915        IF (nqtot > nqo) d_tr_dyn(:,:,:)= 0.0
     2952       IF (nqtot > (nqo+nqtke)) d_tr_dyn(:,:,:)= 0.0
    29162953       ! !! RomP <<<
    29172954       ancien_ok = .TRUE.
     
    31453182    day_since_equinox = (jD_cur + jH_cur) - jD_eq
    31463183    !
    3147     !   choix entre calcul de la longitude solaire vraie ou valeur fixee a 
     3184    !   choix entre calcul de la longitude solaire vraie ou valeur fixee a
    31483185    !   solarlong0
    31493186    IF (solarlong0<-999.) THEN
     
    31573194    ELSE
    31583195       zlongi=solarlong0  ! longitude solaire vraie
    3159        dist=1.            ! distance au soleil / moyenne 
     3196       dist=1.            ! distance au soleil / moyenne
    31603197    ENDIF
    31613198
     
    31793216       ! recode par Olivier Boucher en sept 2015
    31803217       SELECT CASE (iflag_cycle_diurne)
    3181        CASE(0) 
     3218       CASE(0)
    31823219          !  Sans cycle diurne
    31833220          CALL angle(zlongi, latitude_deg, fract, rmu0)
     
    31853222          JrNt = 1.0
    31863223          zrmu0 = rmu0
    3187        CASE(1) 
     3224       CASE(1)
    31883225          !  Avec cycle diurne sans application des poids
    31893226          !  bit comparable a l ancienne formulation cycle_diurne=true
     
    31973234          JrNt = 0.0
    31983235          WHERE (fract.GT.0.0) JrNt = 1.0
    3199        CASE(2) 
     3236       CASE(2)
    32003237          !  Avec cycle diurne sans application des poids
    32013238          !  On integre entre gmtime-pdtphys et gmtime+pdtphys*(radpas-1)
     
    32063243          !  premier pas de temps de la physique pendant lequel
    32073244          !  itaprad=0
    3208           zdtime1=phys_tstep*REAL(-MOD(itaprad,radpas)-1)     
    3209           zdtime2=phys_tstep*REAL(radpas-MOD(itaprad,radpas)-1) 
     3245          zdtime1=phys_tstep*REAL(-MOD(itaprad,radpas)-1)
     3246          zdtime2=phys_tstep*REAL(radpas-MOD(itaprad,radpas)-1)
    32103247          CALL zenang(zlongi,jH_cur,zdtime1,zdtime2, &
    32113248               latitude_deg,longitude_deg,rmu0,fract)
     
    32223259          ! Calcul du flag jour-nuit
    32233260          JrNt = 0.0
    3224           WHERE (zfract.GT.0.0) JrNt = 1.0 
     3261          WHERE (zfract.GT.0.0) JrNt = 1.0
    32253262       END SELECT
    32263263    ENDIF
     
    32383275    ! Cela implique tous les interactions des sous-surfaces et la
    32393276    ! partie diffusion turbulent du couche limit.
    3240     ! 
    3241     ! Certains varibales de sorties de pbl_surface sont utiliser que pour 
     3277    !
     3278    ! Certains varibales de sorties de pbl_surface sont utiliser que pour
    32423279    ! ecriture des fihiers hist_XXXX.nc, ces sont :
    32433280    !   qsol,      zq2m,      s_pblh,  s_lcl,
     
    32513288    !   wfbils,    fluxt,   fluxu, fluxv,
    32523289    !
    3253     ! Certains ne sont pas utiliser du tout : 
     3290    ! Certains ne sont pas utiliser du tout :
    32543291    !   dsens, devap, zxsnow, zxfluxt, zxfluxq, q2m, fluxq
    32553292    !
     
    32973334       !ym : Warning gustiness non inialized for iflag_gusts=2 & iflag_gusts=3
    32983335       gustiness=0  !ym missing init
    3299        
     3336
    33003337       IF (iflag_gusts==0) THEN
    33013338          gustiness(1:klon)=0
     
    33443381            cdragh,    cdragm,  u1,    v1,            &
    33453382            beta_aridity, &
    3346                                 !albedo SB >>>
    3347                                 ! albsol1,   albsol2,   sens,    evap,      &
    3348             albsol_dir,   albsol_dif,   sens,    evap, snowerosion, icesub_lic, & 
    3349                                 !albedo SB <<<
     3383            albsol_dir,   albsol_dif,   sens,    evap, snowerosion, icesub_lic, &
    33503384            albsol3_lic,runoff,   snowhgt,   qsnow, to_ice, sissnow, &
    33513385            zxtsol,    zxfluxlat, zt2m,    qsat2m,  zn2mout, &
     
    33733407            z0m, z0h,     agesno,    fsollw,  fsolsw, &
    33743408            d_ts,      fevap,     fluxlat, t2m, &
    3375             wfbils, wfevap, & 
     3409            wfbils, wfevap, &
    33763410            fluxt,   fluxu,  fluxv, &
    33773411            dsens,     devap,     zxsnow, &
     
    35753609    IF (ok_bs) THEN
    35763610
    3577      CALL call_blowing_snow_sublim_sedim(klon,klev,phys_tstep,t_seri,q_seri,qbs_seri,pplay,paprs, &
     3611     CALL call_blowing_snow_sublim_sedim(klon,klev,phys_tstep,zustar,t_seri,q_seri,qbs_seri,pplay,paprs, &
    35783612                                        d_t_bsss,d_q_bsss,d_qbs_bsss,bsfl,bs_fall)
    35793613
    35803614     CALL add_phys_tend &
    35813615               (du0,dv0,d_t_bsss,d_q_bsss,dql0,dqi0,d_qbs_bsss,paprs,&
    3582                'bs',abortphy,flag_inhib_tend,itap,0  &
     3616               'bsss',abortphy,flag_inhib_tend,itap,0  &
    35833617#ifdef ISO                                       
    35843618       &    ,dxt0,dxtl0,dxti0 &                   
     
    38913925       !>jyg
    38923926       !
    3893        
     3927
    38943928!!      print *,'physiq. q_w(1,k), q_x(1,k) ', &
    38953929!!             (k, q_w(1,k), q_x(1,k),k=1,25)
     
    40934127          !
    40944128          !jyg<
    4095           ! If convective tendencies are too large, then call convection 
     4129          ! If convective tendencies are too large, then call convection
    40964130          !  every time step
    40974131          cvpas = cvpas_0
     
    42484282    ENDIF
    42494283
    4250     !--saving d_q_con * zmass for next timestep if convection is not called every timestep
    4251     IF (ok_conserv_d_q_con) THEN
     4284    !--saving d_X_con * zmass for next timestep if convection is not called every timestep
     4285    IF (ok_mass_dqcon) THEN
    42524286      d_q_con_zmasse(:,:) = d_q_con(:,:) * zmasse(:,:)
    42534287    ENDIF
     4288
     4289    IF (ok_mass_dtcon) THEN
     4290      d_t_con_zmasse(:,:) = d_t_con(:,:) * zmasse(:,:)
     4291    ENDIF
     4292
     4293    IF (ok_mass_duvcon) THEN
     4294      d_u_con_zmasse(:,:) = d_u_con(:,:) * zmasse(:,:)
     4295      d_v_con_zmasse(:,:) = d_v_con(:,:) * zmasse(:,:)
     4296    ENDIF
     4297
    42544298
    42554299    !     CALL homogene(paprs, q_seri, d_q_con, u_seri,v_seri,
     
    42714315    ENDIF
    42724316
    4273 !!!jyg  Appel diagnostique a add_phys_tend pour tester la conservation de 
     4317!!!jyg  Appel diagnostique a add_phys_tend pour tester la conservation de
    42744318!!!     l'energie dans les courants satures.
    42754319!!    d_t_con_sat(:,:) = d_t_con(:,:) - ftd(:,:)*dtime
     
    42774321!!    dql_sat(:,:) = (wdtrainA(:,:)+wdtrainM(:,:))*dtime/zmasse(:,:)
    42784322!!    CALL add_phys_tend(d_u_con, d_v_con, d_t_con_sat, d_q_con_sat, dql_sat,   &
    4279 !!                     dqi0, paprs, 'convection_sat', abortphy, flag_inhib_tend,& 
     4323!!                     dqi0, paprs, 'convection_sat', abortphy, flag_inhib_tend,&
    42804324!!                     itap, 1)
    42814325!!    call prt_enerbil('convection_sat',itap)
     
    42834327!!
    42844328
    4285     !--recompute d_q_con with zmasse from new timestep
    4286     IF (ok_conserv_d_q_con) THEN
     4329    !--recompute d_X_con with zmasse from new timestep
     4330    IF (ok_mass_dqcon) THEN
    42874331      d_q_con(:,:)=d_q_con_zmasse(:,:)/zmasse(:,:)
    42884332    ENDIF
     4333
     4334    IF (ok_mass_dtcon) THEN
     4335      d_t_con(:,:)=d_t_con_zmasse(:,:)/zmasse(:,:)
     4336    ENDIF
     4337
     4338    IF (ok_mass_duvcon) THEN
     4339      d_u_con(:,:)=d_u_con_zmasse(:,:)/zmasse(:,:)
     4340      d_v_con(:,:)=d_v_con_zmasse(:,:)/zmasse(:,:)
     4341    ENDIF
     4342
     4343
     4344
    42894345
    42904346    CALL add_phys_tend(d_u_con, d_v_con, d_t_con, d_q_con, dql0, dqi0, dqbs0, paprs, &
     
    43944450    !
    43954451    !==========================================================================
    4396     !RR:Evolution de la poche froide: on ne fait pas de separation wake/env 
     4452    !RR:Evolution de la poche froide: on ne fait pas de separation wake/env
    43974453    !pour la couche limite diffuse pour l instant
    43984454    !
     
    44114467          DO k=1,klev
    44124468             DO i=1,klon
    4413                 dt_dwn(i,k)  = ftd(i,k) 
    4414                 dq_dwn(i,k)  = fqd(i,k) 
     4469                dt_dwn(i,k)  = ftd(i,k)
     4470                dq_dwn(i,k)  = fqd(i,k)
    44154471                M_dwn(i,k)   = dnwd0(i,k)
    44164472                M_up(i,k)    = upwd(i,k)
    4417                 dt_a(i,k)    = d_t_con(i,k)/phys_tstep - ftd(i,k) 
     4473                dt_a(i,k)    = d_t_con(i,k)/phys_tstep - ftd(i,k)
    44184474                dq_a(i,k)    = d_q_con(i,k)/phys_tstep - fqd(i,k)
    44194475#ifdef ISO
     
    44254481             ENDDO
    44264482          ENDDO
    4427          
     4483
    44284484          IF (iflag_wake==2) THEN
    44294485             ok_wk_lsp(:)=max(sign(1.,wake_s(:)-wake_s_min_lsp),0.)
     
    44624518             ENDDO
    44634519          ENDIF
    4464          
     4520
    44654521#ifdef ISOVERIF
    44664522        write(*,*) 'physiq 3977: verif des inputs de calwake'
     
    47334789          !jyg<
    47344790!!       IF (mod(iflag_pbl_split/2,2) .EQ. 1) THEN
    4735        IF (mod(iflag_pbl_split/10,10) .GE. 1) THEN
     4791          IF (mod(iflag_pbl_split/10,10) .GE. 1) THEN
    47364792             !  Appel des thermiques avec les profils exterieurs aux poches
    47374793             DO k=1,klev
     
    48234879             DO k=1,klev
    48244880                DO i=1,klon
    4825                    !
    48264881                   d_deltat_the(i,k) = - d_t_ajs(i,k)
    48274882                   d_deltaq_the(i,k) = - d_q_ajs(i,k)
    4828                    !
    48294883                   d_u_ajs(i,k) = d_u_ajs(i,k)*(1.-wake_s(i))
    48304884                   d_v_ajs(i,k) = d_v_ajs(i,k)*(1.-wake_s(i))
     
    48874941             !           zmax_th(i)=pphi(i,lmax_th(i))/rg
    48884942             !CR:04/05/12:correction calcul zmax
    4889              zmax_th(i)=zmax0(i) 
     4943             zmax_th(i)=zmax0(i)
    48904944          ENDDO
    48914945
     
    49104964          ! Attention : le call ajsec_convV2 n'est maintenu que momentanneement
    49114965          ! pour des test de convergence numerique.
    4912           ! Le nouveau ajsec est a priori mieux, meme pour le cas 
     4966          ! Le nouveau ajsec est a priori mieux, meme pour le cas
    49134967          ! iflag_thermals = 0 (l'ancienne version peut faire des tendances
    49144968          ! non nulles numeriquement pour des mailles non concernees.
     
    49945048
    49955049    ENDIF
    4996 
    49975050    !
    49985051    !===================================================================
     
    50005053    ! Developed for dust lifting. Could be extended to coupling with ocean and others
    50015054    ! by default : 1 bin equal to the mean wind
    5002        
     5055
    50035056     call surf_wind(klon,nsurfwind,zu10m,zv10m,wake_s,wake_Cstar,zustar,ale_bl,surf_wind_value,surf_wind_proba)
    5004    
    5005 
    5006     !
     5057
    50075058    !===================================================================
    5008     ! Computation of ratqs, the width (normalized) of the subrid scale 
     5059    ! Computation of ratqs, the width (normalized) of the subrid scale
    50095060    ! water distribution
    50105061
     
    52745325                radocond(i,k)=radocond(i,k)+qbs_seri(i,k)
    52755326                picefra(i,k)=(radocond(i,k)*picefra(i,k)+qbs_seri(i,k))/(radocond(i,k))
    5276                 qbsfra=min(qbs_seri(i,k)/qbst_bs,1.0) 
     5327                qbsfra=min(qbs_seri(i,k)/qbst_bs,1.0)
    52775328                cldfra(i,k)=max(cldfra(i,k),qbsfra)
    52785329             ENDDO
     
    55095560             ! profonde.
    55105561
    5511              !IM/FH: 2011/02/23 
     5562             !IM/FH: 2011/02/23
    55125563             ! definition des points sur lesquels ls thermiques sont actifs
    55135564
     
    56595710    ENDDO
    56605711
    5661     !IM Calcul temp.potentielle a 2m (tpot) et temp. potentielle 
     5712    !IM Calcul temp.potentielle a 2m (tpot) et temp. potentielle
    56625713    !   equivalente a 2m (tpote) pour diagnostique
    56635714    !
     
    57955846
    57965847                   !
    5797                 ELSE IF (NSW.EQ.2) THEN 
     5848                ELSE IF (NSW.EQ.2) THEN
    57985849                   !--for now we use the old aerosol properties
    57995850                   !
     
    58955946          ENDIF
    58965947       ELSE
    5897           tausum_aero(:,:,id_STRAT_phy) = 0. 
     5948          tausum_aero(:,:,id_STRAT_phy) = 0.
    58985949       ENDIF
    58995950!
     
    59115962#endif
    59125963       !--fin STRAT AEROSOL
    5913        !     
     5964       !
    59145965
    59155966       ! Calculer les parametres optiques des nuages et quelques
    59165967       ! parametres pour diagnostiques:
    59175968       !
    5918        IF (aerosol_couple.AND.config_inca=='aero') THEN 
    5919           mass_solu_aero(:,:)    = ccm(:,:,1) 
    5920           mass_solu_aero_pi(:,:) = ccm(:,:,2) 
     5969       IF (aerosol_couple.AND.config_inca=='aero') THEN
     5970          mass_solu_aero(:,:)    = ccm(:,:,1)
     5971          mass_solu_aero_pi(:,:) = ccm(:,:,2)
    59215972       ENDIF
    59225973
     
    59295980               cldtaupi, distcltop, temp_cltop, re, fl, ref_liq, ref_ice, &
    59305981               ref_liq_pi, ref_ice_pi, scdnc, cldncl, reffclwtop, lcc, reffclws, &
    5931                reffclwc, cldnvi, lcc3d, lcc3dcon, lcc3dstra, icc3dcon, icc3dstra,  & 
     5982               reffclwc, cldnvi, lcc3d, lcc3dcon, lcc3dstra, icc3dcon, icc3dstra,  &
    59325983               zfice, dNovrN, ptconv, rnebcon, clwcon)
    59335984
     
    59966047       ENDIF
    59976048
    5998        !lecture de la chlorophylle pour le nouvel albedo de Sunghye Baek 
     6049       !lecture de la chlorophylle pour le nouvel albedo de Sunghye Baek
    59996050       IF (ok_chlorophyll) THEN
    60006051          print*,"-- reading chlorophyll"
     
    60026053       ENDIF
    60036054
    6004 !--if ok_suntime_rrtm we use ancillay data for RSUN 
     6055!--if ok_suntime_rrtm we use ancillay data for RSUN
    60056056!--previous values are therefore overwritten
    60066057!--this is needed for CMIP6 runs
    60076058!--and only possible for new radiation scheme
    6008        IF (iflag_rrtm.EQ.1.AND.ok_suntime_rrtm) THEN 
     6059       IF (iflag_rrtm.EQ.1.AND.ok_suntime_rrtm) THEN
    60096060#ifdef CPP_RRTM
    60106061         CALL read_rsun_rrtm(debut)
     
    60286079       ENDIF
    60296080
    6030        IF (aerosol_couple.AND.config_inca=='aero') THEN 
     6081       IF (aerosol_couple.AND.config_inca=='aero') THEN
    60316082IF (CPPKEY_INCA) THEN
    60326083          CALL radlwsw_inca  &
     
    60596110          RCFC11 = RCFC11_act
    60606111          RCFC12 = RCFC12_act
    6061           ! 
     6112          !
    60626113          !--interactive CO2 in ppm from carbon cycle
    60636114          IF (carbon_cycle_rad) RCO2=RCO2_glo
     
    60816132               flag_aerosol, flag_aerosol_strat, flag_aer_feedback, &
    60826133               tau_aero, piz_aero, cg_aero, &
    6083                tau_aero_sw_rrtm, piz_aero_sw_rrtm, cg_aero_sw_rrtm, & 
     6134               tau_aero_sw_rrtm, piz_aero_sw_rrtm, cg_aero_sw_rrtm, &
    60846135               ! Rajoute par OB pour RRTM
    6085                tau_aero_lw_rrtm, & 
     6136               tau_aero_lw_rrtm, &
    60866137               cldtaupirad, m_allaer, &
    60876138!              zqsat, flwcrad, fiwcrad, &
     
    61226173                        sollwdown(:))
    61236174          cool = cool + betalwoff * (cool0 - cool)
    6124  
     6175
    61256176          IF (.NOT. using_xios) THEN
    61266177            !
     
    61336184                RN2O_per.NE.RN2O_act.OR. &
    61346185                RCFC11_per.NE.RCFC11_act.OR. &
    6135                 RCFC12_per.NE.RCFC12_act) ok_4xCO2atm =.TRUE. 
     6186                RCFC12_per.NE.RCFC12_act) ok_4xCO2atm =.TRUE.
    61366187          ENDIF
    6137    ! 
     6188   !
    61386189          IF (ok_4xCO2atm) THEN
    61396190                !
     
    61556206                                !albedo SB >>>
    61566207                                !      paprs, pplay,zxtsol,albsol1, albsol2,  &
    6157                      paprs, pplay,zxtsol,SFRWL,albsol_dir, albsol_dif, & 
     6208                     paprs, pplay,zxtsol,SFRWL,albsol_dir, albsol_dif, &
    61586209                                !albedo SB <<<
    61596210                     t_seri,q_seri,wo, &
     
    62016252#ifdef CPP_ECRAD
    62026253          IF (ok_3Deffect) then
    6203 !                print*,'ok_3Deffect = ',ok_3Deffect 
     6254!                print*,'ok_3Deffect = ',ok_3Deffect
    62046255                namelist_ecrad_file='namelist_ecrad_s2'
    62056256                CALL radlwsw &
     
    62176268                     ref_liq, ref_ice, ref_liq_pi, ref_ice_pi, &
    62186269                     namelist_ecrad_file, &
    6219 ! A modifier             
     6270! A modifier
    62206271                     heat_s2,heat0_s2,cool_s2,cool0_s2,albpla_s2, &
    62216272                     heat_volc,cool_volc, &
     
    63386389    ! a l'echelle sous-maille:
    63396390    !
    6340    
    6341     ! calculation of nm_oro 
     6391
     6392    ! calculation of nm_oro
    63426393    DO i=1,klon
    63436394          ! nm_oro is a proxy for the number of subgrid scale mountains
     
    63476398          ! nm_oro_t=0.
    63486399          nm_oro(i)=zsig(i)*sqrt(cell_area(i)*(pctsrf(i,is_ter)+pctsrf(i,is_lic)))/(4.*MAX(zstd(i),1.e-8))-1.
    6349     END DO
     6400    ENDDO
    63506401
    63516402    IF (prt_level .GE.10) THEN
    63526403       print *,' call orography ? ', ok_orodr
    63536404    ENDIF
    6354 
     6405    !
    63556406    IF (ok_orodr) THEN
    63566407       !
     
    65466597    !IM calcul composantes axiales du moment angulaire et couple des montagnes
    65476598    !
    6548     IF (is_sequential .and. ok_orodr) THEN 
     6599    IF (is_sequential .and. ok_orodr) THEN
    65496600       CALL aaam_bud (27,klon,klev,jD_cur-jD_ref,jH_cur, &
    65506601            ra,rg,romega, &
     
    66396690!            Additional tendency of TKE due to orography
    66406691!===============================================================
    6641 !
    6642 ! Inititialization
    6643 !------------------
    6644 
    6645        addtkeoro=0   
    6646        CALL getin_p('addtkeoro',addtkeoro)
    6647      
    6648        IF (prt_level.ge.5) &
    6649             print*,'addtkeoro', addtkeoro
    6650            
    6651        alphatkeoro=1.   
    6652        CALL getin_p('alphatkeoro',alphatkeoro)
    6653        alphatkeoro=min(max(0.,alphatkeoro),1.)
    6654 
    6655        smallscales_tkeoro=.FALSE.   
    6656        CALL getin_p('smallscales_tkeoro',smallscales_tkeoro)
    6657 
    66586692
    66596693       dtadd(:,:)=0.
     
    66626696
    66636697! Choices for addtkeoro:
    6664 !      ** 0 no TKE tendency from orography   
     6698!      ** 0 no TKE tendency from orography
    66656699!      ** 1 we include a fraction alphatkeoro of the whole tendency duoro
    66666700!      ** 2 we include a fraction alphatkeoro of the gravity wave part of duoro
     
    66876721! Etienne: ici je prends en compte plus de relief que la routine drag_noro_strato
    66886722! car on peut s'attendre a ce que les petites echelles produisent aussi de la TKE
    6689 ! Mais attention, cela ne va pas dans le sens de la conservation de l'energie! 
     6723! Mais attention, cela ne va pas dans le sens de la conservation de l'energie!
    66906724          IF ((zstd(i).GT.1.0) .AND.(nm_oro(i).GT.nm_oro_t)) THEN
    66916725             itest(i)=1
     
    66956729       ENDDO
    66966730
    6697      ELSE 
     6731     ELSE
    66986732
    66996733       igwd=0
     
    67916825
    67926826    IF (ok_cosp) THEN
    6793        ! adeclarer 
     6827       ! adeclarer
    67946828IF (CPPKEY_COSP) THEN
    67956829       IF (itap.eq.1.or.MOD(itap,NINT(freq_cosp/phys_tstep)).EQ.0) THEN
     
    69596993    ELSE
    69606994       sh_in(:,:) = qx(:,:,ivap)
    6961        IF (nqo >= 3) THEN 
     6995       IF (nqo >= 3) THEN
    69626996          ch_in(:,:) = qx(:,:,iliq) + qx(:,:,isol)
    6963        ELSE 
     6997       ELSE
    69646998          ch_in(:,:) = qx(:,:,iliq)
    69656999       ENDIF
     
    71197153       ENDDO
    71207154    ENDIF
    7121    
     7155
    71227156    DO i = 1, klon
    71237157      !--compute ratio of what q+ql should be with conservation to what it is
    71247158      IF (ok_bs) THEN
    7125         corrqql=(qql1(i)+(evap(i)-rain_fall(i)-snow_fall(i)-bs_fall(i))*pdtphys)/qql2(i)
     7159        corrqql=(qql1(i)+(evap(i)-snowerosion(i)-rain_fall(i)-snow_fall(i)-bs_fall(i))*pdtphys)/qql2(i)
    71267160      ELSE
    71277161        corrqql=(qql1(i)+(evap(i)-rain_fall(i)-snow_fall(i))*pdtphys)/qql2(i)
     
    71427176
    71437177    !cc prw  = eau precipitable
    7144     !   prlw = colonne eau liquide 
     7178    !   prlw = colonne eau liquide
    71457179    !   prlw = colonne eau solide
    71467180    !   prbsw = colonne neige soufflee
     
    72557289       ENDDO
    72567290    ENDDO
     7291
     7292    ! in case of advection of TKE
     7293    IF (ok_advtke) THEN
     7294      DO k=1,klev
     7295         DO i=1,klon
     7296           d_qx(i,k,itke)=((pbl_tke(i,k,is_ave)+pbl_tke(i,k+1,is_ave))/2. - qx(i,k,itke)) / phys_tstep
     7297         ENDDO
     7298      ENDDO
     7299    ENDIF
     7300    !
    72577301   
    72587302    ! Lea Raillard qs_ini for cloud phase param.
     
    73037347    cf_ancien(:,:) = cf_seri(:,:)
    73047348    rvc_ancien(:,:)= rvc_seri(:,:)
    7305 #ifdef ISO
     7349    tke_ancien(:,:)= pbl_tke(:,:,is_ave)
     7350
     7351
     7352    #ifdef ISO
    73067353    xt_ancien(:,:,:)=xt_seri(:,:,:)
    73077354    xtl_ancien(:,:,:)=xtl_seri(:,:,:)
     
    73897436
    73907437    ! Recupere des varibles calcule dans differents modules
    7391     ! pour ecriture dans histxxx.nc 
     7438    ! pour ecriture dans histxxx.nc
    73927439
    73937440    ! Get some variables from module fonte_neige_mod
     
    74407487    CALL phys_output_write(itap, pdtphys, paprs, pphis,  &
    74417488         pplay, lmax_th, aerosol_couple,                 &
    7442          ok_ade, ok_aie, ok_volcan, ivap, iliq, isol, ibs,   & 
     7489         ok_ade, ok_aie, ok_volcan, ivap, iliq, isol, ibs,   &
    74437490         ok_sync, ptconv, read_climoz, clevSTD,          &
    74447491         ptconvth, d_u, d_t, qx, d_qx, zmasse,           &
     
    74987545    alert_first_call = .FALSE.
    74997546
    7500    
     7547
    75017548    IF (lafin) THEN
    75027549       itau_phy = itau_phy + itap
     
    75057552       !         write(97) u_seri,v_seri,t_seri,q_seri
    75067553       !         close(97)
    7507      
     7554
    75087555       IF (is_omp_master) THEN
    7509        
     7556
    75107557         IF (read_climoz >= 1) THEN
    75117558           IF (is_mpi_root) CALL nf95_close(ncid_climoz)
     
    75137560            DEALLOCATE(press_cen_climoz)
    75147561         ENDIF
    7515        
     7562
    75167563       ENDIF
    75177564
     
    75317578
    75327579       WRITE(lunout,*) ' physiq fin, nombre de steps ou cvpas = 1 : ', Ncvpaseq1
    7533        
     7580
    75347581    ENDIF
    75357582
Note: See TracChangeset for help on using the changeset viewer.