Ignore:
Timestamp:
12/22/22 16:17:21 (19 months ago)
Author:
aclsce
Message:

IPSLCM7 : updated component revisions accordingly with ICOLMDZOR_v7 for DYNAMICO, ICOSA_LMDZ, ORCHIDEE and LMDZ.

Location:
CONFIG/UNIFORM/v7/IPSLCM7/SOURCES/LMDZ
Files:
2 deleted
2 edited

Legend:

Unmodified
Added
Removed
  • CONFIG/UNIFORM/v7/IPSLCM7/SOURCES/LMDZ/oasis.F90

    r5479 r6296  
    2424  USE mod_prism_get_proto 
    2525  USE mod_prism_put_proto 
     26#endif 
     27#ifdef CPP_CPLOCNINCA 
     28  USE incaoasis, ONLY : inforcv 
    2629#endif 
    2730#endif 
     
    5962  INTEGER, PARAMETER :: ids_qraiic = 28 
    6063  INTEGER, PARAMETER :: ids_qsnoic = 29 
    61   INTEGER, PARAMETER :: maxsend    = 29  ! Maximum number of fields to send 
     64  INTEGER, PARAMETER :: ids_delta_sst = 30, ids_delta_sal = 31 
     65   
     66  INTEGER, PARAMETER :: maxsend    = 31  ! Maximum number of fields to send 
    6267   
    6368  ! Id for fields received from ocean 
     69 
    6470  INTEGER, PARAMETER :: idr_sisutw = 1 
    6571  INTEGER, PARAMETER :: idr_icecov = 2 
     
    7076  INTEGER, PARAMETER :: idr_curenz = 7 
    7177  INTEGER, PARAMETER :: idr_oceco2 = 8 
    72   INTEGER, PARAMETER :: maxrecv    = 8  ! Maximum number of fields to receive 
    73    
     78 
     79  INTEGER, PARAMETER :: idr_sss = 9 
     80  ! bulk salinity of the surface layer of the ocean, in ppt 
     81 
     82  INTEGER, PARAMETER :: maxrecv    = 9  ! Maximum number of fields to receive 
     83   
     84#ifdef CPP_CPLOCNINCA 
     85  INTEGER, PARAMETER :: idr_ocedms = 1 
     86  INTEGER, PARAMETER :: maxrcv = 1 
     87#endif 
    7488 
    7589  TYPE, PUBLIC ::   FLD_CPL            ! Type for coupling field information 
     
    110124    USE geometry_mod, ONLY: ind_cell_glo                     
    111125    USE mod_phys_lmdz_mpi_data, ONLY: klon_mpi_para_nb 
    112      
    113  
     126    use config_ocean_skin_m, only: activate_ocean_skin 
    114127 
    115128! Local variables 
     
    127140    CHARACTER (len = 80)               :: abort_message  
    128141    LOGICAL, SAVE                      :: cpl_current_omp 
    129     INTEGER, DIMENSION(klon_mpi)           :: ind_cell_glo_mpi 
     142    INTEGER, DIMENSION(klon_mpi)       :: ind_cell_glo_mpi 
    130143 
    131144!*    1. Initializations 
     
    164177 
    165178!************************************************************************************ 
    166 ! Gather global index to be used for oasis decomposition  
     179! Gather global index to be used for oasis decomposition 
    167180!************************************************************************************ 
    168181    CALL gather_omp(ind_cell_glo,ind_cell_glo_mpi) 
     
    189202    infosend(ids_calvin)%action = .TRUE. ; infosend(ids_calvin)%name = 'COCALVIN' 
    190203     
     204    if (activate_ocean_skin == 2) then 
     205       infosend(ids_delta_sst)%action = .TRUE. 
     206       infosend(ids_delta_sst)%name = 'CODELSST' 
     207       infosend(ids_delta_sal)%action = .TRUE. 
     208       infosend(ids_delta_sal)%name = 'CODELSSS' 
     209    end if 
     210            
    191211    IF (version_ocean=='nemo') THEN 
    192212        infosend(ids_shftot)%action = .TRUE. ; infosend(ids_shftot)%name = 'COQSRMIX' 
     
    225245   inforecv(idr_icealw)%action = .TRUE. ; inforecv(idr_icealw)%name = 'SIICEALW' 
    226246   inforecv(idr_icetem)%action = .TRUE. ; inforecv(idr_icetem)%name = 'SIICTEMW' 
     247 
     248   if (activate_ocean_skin >= 1) then 
     249      inforecv(idr_sss)%action = .TRUE. 
     250      inforecv(idr_sss)%name = 'SISUSALW' 
     251   end if 
    227252    
    228253   IF (cpl_current ) THEN 
     
    235260       inforecv(idr_oceco2)%action = .TRUE. ; inforecv(idr_oceco2)%name = 'SICO2FLX' 
    236261   ENDIF 
     262#ifdef CPP_CPLOCNINCA 
     263       inforcv(idr_ocedms)%action = .TRUE. ; inforcv(idr_ocedms)%name = 'SIDMSFLX' 
     264#endif 
    237265 
    238266!************************************************************************************ 
     
    319347       ENDIF 
    320348    END DO 
    321      
     349 
     350! Now, if also coupling CPL with INCA, initialize here fields to be exchanged. 
     351#ifdef CPP_CPLOCNINCA 
     352    DO jf=1,maxrcv  
     353       IF (inforcv(jf)%action) THEN 
     354          CALL prism_def_var_proto(inforcv(jf)%nid, inforcv(jf)%name, il_part_id, & 
     355               il_var_nodims, PRISM_In, il_var_actual_shape, il_var_type, & 
     356               ierror) 
     357          IF (ierror .NE. PRISM_Ok) THEN 
     358             WRITE(lunout,*) 'inicma : Problem with prism_def_var_proto for field : ',& 
     359                  inforcv(jf)%name 
     360             abort_message=' Problem in call to prism_def_var_proto for fields to receive' 
     361             CALL abort_physic(modname,abort_message,1) 
     362          ENDIF 
     363       ENDIF 
     364    END DO 
     365#endif 
     366  
    322367!************************************************************************************ 
    323368! Atmospheric Fields to send 
  • CONFIG/UNIFORM/v7/IPSLCM7/SOURCES/LMDZ/physiq_mod.F90

    r5484 r6296  
    11! 
    2 ! $Id: physiq_mod.F90 3666 2020-04-20 10:13:34Z lfalletti $ 
     2! $Id: physiq_mod.F90 4298 2022-10-17 08:15:06Z pcadule $ 
    33! 
    44!#define IO_DEBUG 
     
    1616       d_u, d_v, d_t, d_qx, d_ps) 
    1717 
     18! For clarity, the "USE" section is now arranged in alphabetical order, 
     19! with a separate section for CPP keys 
     20! PLEASE try to follow this rule  
     21 
     22    USE ACAMA_GWD_rando_m, only: ACAMA_GWD_rando 
     23    USE aero_mod 
     24    USE add_phys_tend_mod, only : add_pbl_tend, add_phys_tend, diag_phys_tend, prt_enerbil, & 
     25  &      fl_ebil, fl_cor_ebil 
    1826    USE assert_m, only: assert 
     27    USE change_srf_frac_mod 
     28    USE conf_phys_m, only: conf_phys 
     29    USE carbon_cycle_mod, ONLY : infocfields_init, RCO2_glo, carbon_cycle_rad 
     30    USE CFMIP_point_locations   ! IM stations CFMIP 
     31    USE cmp_seri_mod 
     32    USE dimphy 
     33    USE etat0_limit_unstruct_mod 
     34    USE FLOTT_GWD_rando_m, only: FLOTT_GWD_rando 
     35    USE fonte_neige_mod, ONLY  : fonte_neige_get_vars 
     36    USE geometry_mod, ONLY: cell_area, latitude_deg, longitude_deg, longitude,latitude, & 
     37         boundslon,boundslat, dx, dy, ind_cell_glo 
    1938    USE ioipsl, only: histbeg, histvert, histdef, histend, histsync, & 
    2039         histwrite, ju2ymds, ymds2ju, getin 
    21     USE geometry_mod, ONLY: cell_area, latitude_deg, longitude_deg 
     40    USE ioipsl_getin_p_mod, ONLY : getin_p 
     41    USE indice_sol_mod 
     42    USE infotrac_phy, ONLY: nqtot, nbtr, nqo, tracers, types_trac, nqCO2 
     43    USE readTracFiles_mod, ONLY: addPhase 
     44    USE strings_mod,  ONLY: strIdx 
     45    USE iophy 
     46    USE limit_read_mod, ONLY : init_limit_read 
     47    USE mod_grid_phy_lmdz, ONLY: nbp_lon, nbp_lat, nbp_lev, klon_glo, grid1dTo2d_glo, grid_type, unstructured 
     48    USE mod_phys_lmdz_mpi_data, only: is_mpi_root 
     49    USE mod_phys_lmdz_para 
     50    USE netcdf95, only: nf95_close 
     51    USE netcdf, only: nf90_fill_real     ! IM for NMC files 
     52    USE open_climoz_m, only: open_climoz ! ozone climatology from a file 
     53    USE ozonecm_m, only: ozonecm ! ozone of J.-F. Royer 
     54    USE pbl_surface_mod, ONLY : pbl_surface 
     55    USE phyaqua_mod, only: zenang_an 
     56    USE phystokenc_mod, ONLY: offline, phystokenc 
    2257    USE phys_cal_mod, only: year_len, mth_len, days_elapsed, jh_1jan, & 
    23          year_cur, mth_cur,jD_cur, jH_cur, jD_ref, day_cur, hour 
     58         year_cur, mth_cur,jD_cur, jH_cur, jD_ref, day_cur, hour, calend 
     59!!  USE phys_local_var_mod, ONLY : a long list of variables 
     60!!              ==> see below, after "CPP Keys" section 
     61    USE phys_state_var_mod ! Variables sauvegardees de la physique 
     62    USE phys_output_mod 
     63    USE phys_output_ctrlout_mod 
     64    USE print_control_mod, ONLY: mydebug=>debug , lunout, prt_level, & 
     65         alert_first_call, call_alert, prt_alerte 
     66    USE readaerosol_mod, ONLY : init_aero_fromfile 
     67    USE readaerosolstrato_m, ONLY : init_readaerosolstrato 
     68    USE radlwsw_m, only: radlwsw 
     69    USE regr_horiz_time_climoz_m, ONLY: regr_horiz_time_climoz 
     70    USE regr_pr_time_av_m, only: regr_pr_time_av 
     71    USE surface_data,     ONLY : type_ocean, ok_veget, landice_opt 
     72    USE time_phylmdz_mod, only: annee_ref, current_time, day_ini, day_ref, & 
     73          day_step_phy, itau_phy, pdtphys, raz_date, start_time, update_time, ndays 
     74    USE tracinca_mod, ONLY: config_inca 
     75    USE tropopause_m,     ONLY: dyn_tropopause 
     76    USE ice_sursat_mod,  ONLY: flight_init, airplane 
     77    USE vampir 
     78    USE VERTICAL_LAYERS_MOD, ONLY: aps,bps, ap, bp 
    2479    USE write_field_phy 
    25     USE dimphy 
    26     USE infotrac_phy, ONLY: nqtot, nbtr, nqo, type_trac 
    27     USE mod_grid_phy_lmdz, ONLY: nbp_lon, nbp_lat, nbp_lev, klon_glo, grid1dTo2d_glo, grid_type, unstructured 
    28     USE mod_phys_lmdz_para 
    29     USE iophy 
    30     USE print_control_mod, ONLY: mydebug=>debug , lunout, prt_level 
    31     USE phystokenc_mod, ONLY: offline, phystokenc 
    32     USE time_phylmdz_mod, only: raz_date, day_step_phy, update_time,current_time 
    33     USE vampir 
    34     USE pbl_surface_mod, ONLY : pbl_surface 
    35     USE change_srf_frac_mod 
    36     USE surface_data,     ONLY : type_ocean, ok_veget, ok_snow 
    37     USE tropopause_m,     ONLY: dyn_tropopause 
     80#ifdef CPP_XIOS 
     81    USE wxios, ONLY: g_ctx, wxios_set_context 
     82#endif 
     83    USE lscp_mod, ONLY : lscp 
     84    USE wake_ini_mod, ONLY : wake_ini 
     85    USE thermcell_ini_mod, ONLY : thermcell_ini 
     86 
     87    !USE cmp_seri_mod 
     88!    USE add_phys_tend_mod, only : add_pbl_tend, add_phys_tend, diag_phys_tend, prt_enerbil, & 
     89!  &      fl_ebil, fl_cor_ebil 
     90 
     91!!!!!!!!!!!!!!!!!! "USE" section for CPP keys !!!!!!!!!!!!!!!!!!!!!!!! 
     92! 
     93! 
    3894#ifdef CPP_Dust 
    39     USE phytracr_spl_mod, ONLY: phytracr_spl 
     95    USE phytracr_spl_mod, ONLY: phytracr_spl, phytracr_spl_out_init 
     96    USE phys_output_write_spl_mod 
     97#else 
     98    USE phytrac_mod, ONLY : phytrac_init, phytrac 
     99    USE phys_output_write_mod 
    40100#endif 
     101 
     102 
     103#ifdef REPROBUS 
     104    USE CHEM_REP, ONLY : Init_chem_rep_xjour, & 
     105         d_q_rep,d_ql_rep,d_qi_rep,ptrop,ttrop, & 
     106         ztrop, gravit,itroprep, Z1,Z2,fac,B 
     107#endif 
     108 
     109 
     110#ifdef CPP_RRTM 
     111    USE YOERAD, ONLY : NRADLP 
     112    USE YOESW, ONLY : RSUN 
     113#endif 
     114 
     115 
    41116#ifdef CPP_StratAer 
    42117    USE strataer_mod, ONLY: strataer_init 
    43118#endif 
    44     USE phys_local_var_mod, ONLY: phys_local_var_init, phys_local_var_end, & 
     119 
     120 
     121#ifdef CPP_XIOS 
     122    USE xios, ONLY: xios_update_calendar, xios_context_finalize 
     123    USE xios, ONLY: xios_get_field_attr, xios_field_is_active, xios_context 
     124    USE xios, ONLY: xios_set_current_context 
     125    USE wxios, ONLY: missing_val, missing_val_omp 
     126#endif 
     127#ifndef CPP_XIOS 
     128    USE paramLMDZ_phy_mod 
     129#endif 
     130! 
     131! 
     132!!!!!!!!!!!!!!!!!!  END "USE" for CPP keys !!!!!!!!!!!!!!!!!!!!!! 
     133 
     134USE phys_local_var_mod, ONLY: phys_local_var_init, phys_local_var_end, & 
    45135       ! [Variables internes non sauvegardees de la physique] 
    46136       ! Variables locales pour effectuer les appels en serie 
    47        t_seri,q_seri,ql_seri,qs_seri,u_seri,v_seri,tr_seri, & 
     137       t_seri,q_seri,ql_seri,qs_seri,u_seri,v_seri,tr_seri,rneb_seri, & 
    48138       ! Dynamic tendencies (diagnostics) 
    49        d_t_dyn,d_q_dyn,d_ql_dyn,d_qs_dyn,d_u_dyn,d_v_dyn,d_tr_dyn, & 
     139       d_t_dyn,d_q_dyn,d_ql_dyn,d_qs_dyn,d_u_dyn,d_v_dyn,d_tr_dyn,d_rneb_dyn, & 
    50140       d_q_dyn2d,d_ql_dyn2d,d_qs_dyn2d, & 
    51141       ! Physic tendencies 
     
    66156       ! 
    67157       d_t_vdf,d_q_vdf,d_u_vdf,d_v_vdf,d_t_diss, & 
     158       d_t_vdf_x, d_t_vdf_w, & 
     159       d_q_vdf_x, d_q_vdf_w, & 
    68160       d_ts, & 
    69161       ! 
     
    119211       cdragm, cdragh,                   & 
    120212       zustar, zu10m, zv10m, rh2m, qsat2m, & 
    121        zq2m, zt2m, weak_inversion, & 
    122        zq2m_cor,zt2m_cor,zu10m_cor,zv10m_cor, & ! pour corriger d'un bug 
    123        zrh2m_cor,zqsat2m_cor, & 
     213       zq2m, zt2m, zn2mout, weak_inversion, & 
    124214       zt2m_min_mon, zt2m_max_mon,   &         ! pour calcul_divers.h 
    125215       t2m_min_mon, t2m_max_mon,  &            ! pour calcul_divers.h 
     
    134224       zxrunofflic,                            & 
    135225       zxtsol, snow_lsc, zxfqfonte, zxqsurf,   & 
     226       delta_qsurf,                            & 
    136227       rain_lsc, rain_num,                     & 
    137228       ! 
     
    139230       zxfluxlat_x, zxfluxlat_w, & 
    140231       ! 
    141        d_t_vdf_x, d_t_vdf_w, & 
    142        d_q_vdf_x, d_q_vdf_w, & 
    143        pbl_tke_input, & 
     232       pbl_tke_input, tke_dissip, l_mix, wprime,& 
    144233       t_therm, q_therm, u_therm, v_therm, & 
    145234       cdragh_x, cdragh_w, & 
     
    168257       alp_bl_stat, n2, s2,  & 
    169258       proba_notrig, random_notrig,  & 
    170        cv_gen,  & 
     259!!       cv_gen,  &  !moved to phys_state_var_mod 
    171260       ! 
    172261       dnwd0,  & 
     
    195284       ref_liq, ref_ice, theta,  & 
    196285       ref_liq_pi, ref_ice_pi,  & 
    197        zphi, zx_rh, & 
     286       zphi, zx_rh, zx_rhl, zx_rhi, & 
    198287       pmfd, pmfu,  & 
    199288       ! 
     
    216305       zxsnow,snowhgt,qsnow,to_ice,sissnow,runoff,albsol3_lic 
    217306       ! 
    218     USE phys_state_var_mod ! Variables sauvegardees de la physique 
    219 #ifdef CPP_Dust 
    220     USE phys_output_write_spl_mod 
    221 #else 
    222     USE phys_output_var_mod ! Variables pour les ecritures des sorties 
    223 #endif 
    224  
    225     USE phys_output_write_mod 
    226     USE fonte_neige_mod, ONLY  : fonte_neige_get_vars 
    227     USE phys_output_mod 
    228     USE phys_output_ctrlout_mod 
    229     USE open_climoz_m, only: open_climoz ! ozone climatology from a file 
    230     USE regr_pr_time_av_m, only: regr_pr_time_av 
    231     USE netcdf95, only: nf95_close 
    232     !IM for NMC files 
    233     USE netcdf, only: nf90_fill_real 
    234     USE mod_phys_lmdz_mpi_data, only: is_mpi_root 
    235     USE aero_mod 
    236     USE ozonecm_m, only: ozonecm ! ozone of J.-F. Royer 
    237     USE conf_phys_m, only: conf_phys 
    238     USE radlwsw_m, only: radlwsw 
    239     USE phyaqua_mod, only: zenang_an 
    240     USE time_phylmdz_mod, only: day_step_phy, annee_ref, day_ref, itau_phy, & 
    241          start_time, pdtphys, day_ini 
    242     USE tracinca_mod, ONLY: config_inca 
    243 #ifdef CPP_XIOS 
    244     USE wxios, ONLY: missing_val, missing_val_omp 
    245     USE xios, ONLY: xios_get_field_attr, xios_field_is_active 
    246 #endif 
    247 #ifdef REPROBUS 
    248     USE CHEM_REP, ONLY : Init_chem_rep_xjour, & 
    249          d_q_rep,d_ql_rep,d_qi_rep,ptrop,ttrop, & 
    250          ztrop, gravit,itroprep, Z1,Z2,fac,B 
    251 #endif 
    252     USE indice_sol_mod 
    253     USE phytrac_mod, ONLY : phytrac_init, phytrac 
    254     USE carbon_cycle_mod, ONLY : infocfields_init, RCO2_glo, carbon_cycle_rad 
    255  
    256 #ifdef CPP_RRTM 
    257     USE YOERAD, ONLY : NRADLP 
    258     USE YOESW, ONLY : RSUN 
    259 #endif 
    260     USE ioipsl_getin_p_mod, ONLY : getin_p 
    261  
    262 #ifndef CPP_XIOS 
    263     USE paramLMDZ_phy_mod 
    264 #endif 
    265  
    266     USE cmp_seri_mod 
    267     USE add_phys_tend_mod, only : add_pbl_tend, add_phys_tend, diag_phys_tend, prt_enerbil, & 
    268   &      fl_ebil, fl_cor_ebil 
    269  
    270     !IM stations CFMIP 
    271     USE CFMIP_point_locations 
    272     USE FLOTT_GWD_rando_m, only: FLOTT_GWD_rando 
    273     USE ACAMA_GWD_rando_m, only: ACAMA_GWD_rando 
    274     USE VERTICAL_LAYERS_MOD, ONLY: aps,bps, ap, bp 
    275     USE etat0_limit_unstruct_mod 
    276 #ifdef CPP_XIOS 
    277     USE xios, ONLY: xios_update_calendar, xios_context_finalize 
    278 #endif 
    279     USE limit_read_mod, ONLY : init_limit_read 
    280     USE regr_horiz_time_climoz_m, ONLY: regr_horiz_time_climoz 
    281     USE readaerosol_mod, ONLY : init_aero_fromfile 
    282     USE readaerosolstrato_m, ONLY : init_readaerosolstrato 
    283307 
    284308    IMPLICIT NONE 
     
    336360    include "dimsoil.h" 
    337361    include "clesphys.h" 
    338     include "thermcell.h" 
     362    include "alpale.h" 
    339363    include "dimpft.h" 
    340364    !====================================================================== 
    341365    LOGICAL, SAVE :: ok_volcan ! pour activer les diagnostics volcaniques 
    342366    !$OMP THREADPRIVATE(ok_volcan) 
     367    INTEGER, SAVE :: flag_volc_surfstrat ! pour imposer le cool/heat rate à la surf/strato 
     368    !$OMP THREADPRIVATE(flag_volc_surfstrat) 
    343369    LOGICAL ok_cvl  ! pour activer le nouveau driver pour convection KE 
    344370    PARAMETER (ok_cvl=.TRUE.) 
     
    421447    !====================================================================== 
    422448    ! 
    423     INTEGER ivap          ! indice de traceurs pour vapeur d'eau 
    424     PARAMETER (ivap=1) 
    425     INTEGER iliq          ! indice de traceurs pour eau liquide 
    426     PARAMETER (iliq=2) 
    427     !CR: on ajoute la phase glace 
    428     INTEGER isol          ! indice de traceurs pour eau glace 
    429     PARAMETER (isol=3) 
     449    ! indices de traceurs eau vapeur, liquide, glace, fraction nuageuse LS (optional) 
     450    INTEGER,SAVE :: ivap, iliq, isol, irneb 
     451!$OMP THREADPRIVATE(ivap, iliq, isol, irneb) 
    430452    ! 
    431453    ! 
     
    469491    REAL dtadd(klon,klev) 
    470492 
     493!#ifdef CPP_XIOS 
     494!    TYPE(xios_context), SAVE :: g_ctx 
     495!#endif 
     496 
    471497#ifndef CPP_XIOS 
    472498    REAL, SAVE :: missing_val=nf90_fill_real 
     
    602628                                                        ! gust-front in the grid cell. 
    603629    !$OMP THREADPRIVATE(iflag_alp_wk_cond) 
    604  
    605     INTEGER,  SAVE               :: iflag_bug_t2m_ipslcm61=1 ! 
    606     !$OMP THREADPRIVATE(iflag_bug_t2m_ipslcm61) 
    607     INTEGER,  SAVE               :: iflag_bug_t2m_stab_ipslcm61=-1 ! 
    608     !$OMP THREADPRIVATE(iflag_bug_t2m_stab_ipslcm61) 
    609630 
    610631    REAL t_w(klon,klev),q_w(klon,klev) ! temperature and moisture profiles in the wake region 
     
    842863    real zqsat(klon,klev) 
    843864    ! 
    844     INTEGER i, k, iq, j, nsrf, ll, l 
     865    INTEGER i, k, iq, j, nsrf, ll, l, itr 
    845866    ! 
    846867    REAL t_coup 
     
    949970    !IM cf. AM 081204 BEG 
    950971    LOGICAL ptconvth(klon,klev) 
     972 
     973    REAL picefra(klon,klev) 
    951974    !IM cf. AM 081204 END 
    952975    ! 
     
    10201043!JLD    REAL zstophy, zout 
    10211044 
    1022     CHARACTER*20 modname 
     1045    CHARACTER (LEN=20) :: modname='physiq_mod' 
    10231046    CHARACTER*80 abort_message 
    10241047    LOGICAL, SAVE ::  ok_sync, ok_sync_omp 
     
    11721195    integer iostat 
    11731196 
     1197    REAL, dimension(klon,klev+1) :: tke_dissip_ave, l_mix_ave, wprime_ave 
    11741198    REAL zzz 
    11751199    !albedo SB >>> 
     
    11861210    pi = 4. * ATAN(1.) 
    11871211 
     1212    ! set-up call to alerte function 
     1213    call_alert = (alert_first_call .AND. is_master) 
     1214     
    11881215    ! Ehouarn: set value of jjmp1 since it is no longer a "fixed parameter" 
    11891216    jjmp1=nbp_lat 
     
    11961223    phys_tstep=NINT(pdtphys) 
    11971224#ifdef CPP_XIOS 
    1198     IF (.NOT. debut .AND. is_omp_master) CALL xios_update_calendar(itap+1) 
     1225! switch to XIOS LMDZ physics context  
     1226!!!!$OMP MASTER 
     1227!!!!    WRITE(*,*)'PHYSICS XIOS Context :', g_ctx 
     1228!!!!    CALL wxios_set_context() 
     1229!!!!$OMP END MASTER 
     1230    IF (.NOT. debut .AND. is_omp_master) THEN 
     1231       CALL wxios_set_context() 
     1232       CALL xios_update_calendar(itap+1) 
     1233    ENDIF 
    11991234#endif 
    12001235 
     
    12301265 
    12311266    IF (first) THEN  
     1267       ivap = strIdx(tracers(:)%name, addPhase('H2O', 'g')) 
     1268       iliq = strIdx(tracers(:)%name, addPhase('H2O', 'l')) 
     1269       isol = strIdx(tracers(:)%name, addPhase('H2O', 's')) 
     1270       irneb= strIdx(tracers(:)%name, addPhase('H2O', 'r')) 
     1271!       CALL init_etat0_limit_unstruct 
     1272!       IF (.NOT. create_etat0_limit) CALL init_limit_read(days_elapsed) 
    12321273       !CR:nvelles variables convection/poches froides 
    12331274 
     
    12451286            fact_cldcon, facttemps,ok_newmicro,iflag_radia, & 
    12461287            iflag_cld_th,iflag_ratqs,ratqsbas,ratqshaut,tau_ratqs, & 
    1247             ok_ade, ok_aie, ok_alw, ok_cdnc, ok_volcan, aerosol_couple, & 
    1248             chemistry_couple, & 
    1249             flag_aerosol, flag_aerosol_strat, flag_aer_feedback, & 
     1288            ok_ade, ok_aie, ok_alw, ok_cdnc, ok_volcan, flag_volc_surfstrat, aerosol_couple, & 
     1289            chemistry_couple, flag_aerosol, flag_aerosol_strat, flag_aer_feedback, & 
    12501290            flag_bc_internal_mixture, bl95_b0, bl95_b1, & 
    12511291                                ! nv flags pour la convection et les 
     
    12641304#endif 
    12651305 
     1306       !!CALL flight_init 
     1307 
    12661308       print*, '=================================================' 
    12671309       ! 
     
    12691311       IF ((iflag_ice_thermo.gt.0).and.(nqo==2)) THEN 
    12701312          WRITE (lunout, *) ' iflag_ice_thermo==1 requires 3 H2O tracers ', & 
    1271                '(H2Ov, H2Ol, H2Oi) but nqo=', nqo, '. Might as well stop here.' 
     1313               '(H2O_g, H2O_l, H2O_s) but nqo=', nqo, '. Might as well stop here.' 
     1314          abort_message='see above' 
     1315          CALL abort_physic(modname,abort_message,1) 
     1316       ENDIF 
     1317 
     1318       IF (ok_ice_sursat.AND.(iflag_ice_thermo.EQ.0)) THEN 
     1319          WRITE (lunout, *) ' ok_ice_sursat=y requires iflag_ice_thermo=1 as well' 
     1320          abort_message='see above' 
     1321          CALL abort_physic(modname,abort_message,1) 
     1322       ENDIF 
     1323 
     1324       IF (ok_ice_sursat.AND.(nqo.NE.4)) THEN 
     1325          WRITE (lunout, *) ' ok_ice_sursat=y requires 4 H2O tracers ', & 
     1326               '(H2O_g, H2O_l, H2O_s, H2O_r) but nqo=', nqo, '. Might as well stop here.' 
     1327          abort_message='see above' 
     1328          CALL abort_physic(modname,abort_message,1) 
     1329       ENDIF 
     1330 
     1331       IF (ok_plane_h2o.AND..NOT.ok_ice_sursat) THEN 
     1332          WRITE (lunout, *) ' ok_plane_h2o=y requires ok_ice_sursat=y ' 
     1333          abort_message='see above' 
     1334          CALL abort_physic(modname,abort_message,1) 
     1335       ENDIF 
     1336 
     1337       IF (ok_plane_contrail.AND..NOT.ok_ice_sursat) THEN 
     1338          WRITE (lunout, *) ' ok_plane_contrail=y requires ok_ice_sursat=y ' 
    12721339          abort_message='see above' 
    12731340          CALL abort_physic(modname,abort_message,1) 
     
    13031370    forall (k=1: nbp_lev) zmasse(:, k) = (paprs(:, k)-paprs(:, k+1)) / rg 
    13041371 
    1305     modname = 'physiq' 
    13061372 
    13071373    IF (debut) THEN 
     
    13141380       tau_gl=86400.*tau_gl 
    13151381       WRITE(lunout,*) 'debut physiq_mod tau_gl=',tau_gl 
    1316  
    1317        iflag_bug_t2m_ipslcm61 = 1 
    1318        CALL getin_p('iflag_bug_t2m_ipslcm61', iflag_bug_t2m_ipslcm61) 
    1319        iflag_bug_t2m_stab_ipslcm61 = -1 
    1320        CALL getin_p('iflag_bug_t2m_stab_ipslcm61', iflag_bug_t2m_stab_ipslcm61) 
    13211382 
    13221383       CALL getin_p('iflag_alp_wk_cond', iflag_alp_wk_cond)  
     
    13471408       iflag_phytrac = 1 ! by default we do want to call phytrac 
    13481409       CALL getin_p('iflag_phytrac',iflag_phytrac) 
     1410#ifdef CPP_Dust 
     1411       IF (iflag_phytrac.EQ.0) THEN  
     1412         WRITE(lunout,*) 'In order to run with SPLA, iflag_phytrac will be forced to 1' 
     1413         iflag_phytrac = 1 
     1414       ENDIF 
     1415#endif 
    13491416       nvm_lmdz = 13 
    13501417       CALL getin_p('NVM',nvm_lmdz) 
     
    14041471       tau_overturning_th(:)=0. 
    14051472 
    1406        IF (type_trac == 'inca') THEN 
     1473       IF (ANY(types_trac == 'inca') .OR. ANY(types_trac == 'inco')) THEN 
    14071474          ! jg : initialisation jusqu'au ces variables sont dans restart 
    14081475          ccm(:,:,:) = 0. 
     
    16091676#ifdef CPP_COSP 
    16101677      IF (ok_cosp) THEN 
    1611            DO k = 1, klev 
    1612              DO i = 1, klon 
    1613                phicosp(i,k) = pphi(i,k) + pphis(i) 
    1614              ENDDO 
    1615            ENDDO 
     1678!           DO k = 1, klev 
     1679!             DO i = 1, klon 
     1680!               phicosp(i,k) = pphi(i,k) + pphis(i) 
     1681!             ENDDO 
     1682!           ENDDO 
    16161683        CALL phys_cosp(itap,phys_tstep,freq_cosp, & 
    16171684               ok_mensuelCOSP,ok_journeCOSP,ok_hfCOSP, & 
     
    16311698#ifdef CPP_COSP2 
    16321699        IF (ok_cosp) THEN 
    1633            DO k = 1, klev 
    1634              DO i = 1, klon 
    1635                phicosp(i,k) = pphi(i,k) + pphis(i) 
    1636              ENDDO 
    1637            ENDDO 
     1700!           DO k = 1, klev 
     1701!             DO i = 1, klon 
     1702!               phicosp(i,k) = pphi(i,k) + pphis(i) 
     1703!             ENDDO 
     1704!           ENDDO 
    16381705          CALL phys_cosp2(itap,phys_tstep,freq_cosp, & 
    16391706               ok_mensuelCOSP,ok_journeCOSP,ok_hfCOSP, & 
     
    16771744!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 
    16781745       ! Nouvelle initialisation pour le rayonnement RRTM 
    1679        ! 
    16801746!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 
    16811747 
    16821748       CALL iniradia(klon,klev,paprs(1,1:klev+1)) 
    1683        ! Initialisation des champs dans phytrac qui sont utilisés par phys_output_write 
     1749 
     1750!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 
     1751       CALL wake_ini(rg,rd,rv,prt_level) 
     1752       CALL thermcell_ini(iflag_thermals,prt_level,tau_thermals,lunout, & 
     1753   &    RG,RD,RCPD,RKAPPA,RLVTT,RETV) 
     1754 
     1755!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 
     1756 
     1757       ! 
     1758!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 
     1759       ! Initialisation des champs dans phytrac* qui sont utilises par phys_output_write* 
     1760       ! 
     1761!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 
     1762 
     1763#ifdef CPP_Dust 
     1764       ! Quand on utilise SPLA, on force iflag_phytrac=1 
     1765       CALL phytracr_spl_out_init() 
     1766       CALL phys_output_write_spl(itap, pdtphys, paprs, pphis,                  & 
     1767                                pplay, lmax_th, aerosol_couple,                 & 
     1768                                ok_ade, ok_aie, ivap, ok_sync,                  & 
     1769                                ptconv, read_climoz, clevSTD,                   & 
     1770                                ptconvth, d_t, qx, d_qx, d_tr_dyn, zmasse,      & 
     1771                                flag_aerosol, flag_aerosol_strat, ok_cdnc) 
     1772#else 
     1773       ! phys_output_write écrit des variables traceurs seulement si iflag_phytrac == 1  
     1774       ! donc seulement dans ce cas on doit appeler phytrac_init() 
    16841775       IF (iflag_phytrac == 1 ) THEN 
    16851776          CALL phytrac_init() 
    1686         ENDIF 
    1687  
     1777       ENDIF 
    16881778       CALL phys_output_write(itap, pdtphys, paprs, pphis,                    & 
    16891779                              pplay, lmax_th, aerosol_couple,                 & 
     
    16921782                              ptconvth, d_u, d_t, qx, d_qx, zmasse,           & 
    16931783                              flag_aerosol, flag_aerosol_strat, ok_cdnc) 
     1784#endif 
     1785 
    16941786 
    16951787#ifdef CPP_XIOS 
     
    17131805            ENDDO 
    17141806          ENDDO 
    1715         ELSE 
     1807       ELSE 
    17161808          pbl_tke(:,:,is_ave) = 0. !ym missing init : maybe must be initialized in the same way that for klon_glo==1 ?? 
    17171809!>jyg 
     
    17571849          CALL abort_physic(modname,abort_message,1) 
    17581850       ENDIF 
     1851 
     1852!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 
     1853       ! Initialisation pour la convection de K.E. et pour les poches froides 
     1854       ! 
     1855!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 
     1856 
    17591857       WRITE(lunout,*)"Clef pour la convection, iflag_con=", iflag_con 
    1760        WRITE(lunout,*)"Clef pour le driver de la convection, ok_cvl=", & 
    1761             ok_cvl 
     1858       WRITE(lunout,*)"Clef pour le driver de la convection, ok_cvl=", ok_cvl 
    17621859       ! 
    17631860       !KE43 
     
    18061903             d_s_wk(:) = 0. 
    18071904             d_dens_wk(:) = 0. 
    1808           ENDIF 
     1905          ENDIF  !  (iflag_wake>=1) 
    18091906 
    18101907          !        do i = 1,klon 
     
    18171914       !   ALLOCATE(lonGCM(0), latGCM(0)) 
    18181915       !   ALLOCATE(iGCM(0), jGCM(0)) 
    1819        ENDIF 
    1820  
     1916       ENDIF  !  (iflag_con.GE.3) 
     1917       ! 
    18211918       DO i=1,klon 
    18221919          rugoro(i) = f_rugoro * MAX(1.0e-05, zstd(i)*zsig(i)/2.0) 
     
    18871984       !$OMP BARRIER 
    18881985       missing_val=missing_val_omp 
     1986       !  
     1987       ! Now we activate some double radiation call flags only if some 
     1988       ! diagnostics are requested, otherwise there is no point in doing this 
     1989       IF (is_master) THEN 
     1990         !--setting up swaero_diag to TRUE in XIOS case  
     1991         IF (xios_field_is_active("topswad").OR.xios_field_is_active("topswad0").OR. &  
     1992            xios_field_is_active("solswad").OR.xios_field_is_active("solswad0").OR. &  
     1993            xios_field_is_active("topswai").OR.xios_field_is_active("solswai").OR.  &  
     1994              (iflag_rrtm==1.AND.(xios_field_is_active("toplwad").OR.xios_field_is_active("toplwad0").OR. &  
     1995                                  xios_field_is_active("sollwad").OR.xios_field_is_active("sollwad0"))))  &  
     1996            !!!--for now these fields are not in the XML files so they are omitted  
     1997            !!!  xios_field_is_active("toplwai").OR.xios_field_is_active("sollwai") !))) &  
     1998            swaero_diag=.TRUE.  
     1999  
     2000         !--setting up swaerofree_diag to TRUE in XIOS case  
     2001         IF (xios_field_is_active("SWdnSFCcleanclr").OR.xios_field_is_active("SWupSFCcleanclr").OR. & 
     2002            xios_field_is_active("SWupTOAcleanclr").OR.xios_field_is_active("rsucsaf").OR.   & 
     2003            xios_field_is_active("rsdcsaf") .OR. xios_field_is_active("LWdnSFCcleanclr").OR. & 
     2004            xios_field_is_active("LWupTOAcleanclr")) & 
     2005            swaerofree_diag=.TRUE.  
     2006  
     2007         !--setting up dryaod_diag to TRUE in XIOS case  
     2008         DO naero = 1, naero_tot-1 
     2009          IF (xios_field_is_active("dryod550_"//name_aero_tau(naero))) dryaod_diag=.TRUE.  
     2010         ENDDO 
     2011         ! 
     2012         !--setting up ok_4xCO2atm to TRUE in XIOS case  
     2013         IF (xios_field_is_active("rsut4co2").OR.xios_field_is_active("rlut4co2").OR. &  
     2014            xios_field_is_active("rsutcs4co2").OR.xios_field_is_active("rlutcs4co2").OR. & 
     2015            xios_field_is_active("rsu4co2").OR.xios_field_is_active("rsucs4co2").OR. & 
     2016            xios_field_is_active("rsd4co2").OR.xios_field_is_active("rsdcs4co2").OR. & 
     2017            xios_field_is_active("rlu4co2").OR.xios_field_is_active("rlucs4co2").OR. & 
     2018            xios_field_is_active("rld4co2").OR.xios_field_is_active("rldcs4co2")) & 
     2019            ok_4xCO2atm=.TRUE.  
     2020       ENDIF 
     2021       !$OMP BARRIER 
     2022       CALL bcast(swaero_diag) 
     2023       CALL bcast(swaerofree_diag) 
     2024       CALL bcast(dryaod_diag) 
     2025       CALL bcast(ok_4xCO2atm) 
    18892026#endif  
    1890  
    1891  
     2027       ! 
    18922028       CALL printflag( tabcntr0,radpas,ok_journe, & 
    18932029            ok_instan, ok_region ) 
    18942030       ! 
    18952031       ! 
    1896        ! 
    18972032       ! Prescrire l'ozone dans l'atmosphere 
    1898        ! 
    18992033       ! 
    19002034       !c         DO i = 1, klon 
     
    19042038       !c         ENDDO 
    19052039       ! 
    1906        IF (type_trac == 'inca') THEN 
     2040       IF (ANY(types_trac == 'inca') .OR. ANY(types_trac == 'inco')) THEN ! ModThL 
    19072041#ifdef INCA 
    19082042          CALL VTe(VTphysiq) 
     
    19112045          WRITE(lunout,*) 'initial time chemini', days_elapsed, calday 
    19122046 
    1913           CALL chemini(  & 
    1914                rg, & 
    1915                ra, & 
    1916                cell_area, & 
    1917                latitude_deg, & 
    1918                longitude_deg, & 
    1919                presnivs, & 
    1920                calday, & 
    1921                klon, & 
    1922                nqtot, & 
    1923                nqo, & 
    1924                pdtphys, & 
    1925                annee_ref, & 
    1926                year_cur, & 
    1927                day_ref,  & 
    1928                day_ini, & 
    1929                start_time, & 
    1930                itau_phy, & 
    1931                date0, & 
    1932                io_lon, & 
    1933                io_lat, & 
    1934                chemistry_couple, & 
    1935                init_source, & 
    1936                init_tauinca, & 
    1937                init_pizinca, & 
    1938                init_cginca, & 
    1939                init_ccminca) 
     2047          call init_const_lmdz( & 
     2048          ndays, nbsrf, is_oce,is_sic, is_ter,is_lic, calend, & 
     2049          config_inca) 
     2050 
     2051          CALL init_inca_geometry( &  
     2052               longitude, latitude, & 
     2053               boundslon, boundslat, & 
     2054               cell_area, ind_cell_glo)  
     2055 
     2056          if (grid_type==unstructured) THEN  
     2057             CALL chemini(  pplay, & 
     2058                  nbp_lon, nbp_lat, & 
     2059                  latitude_deg, & 
     2060                  longitude_deg, & 
     2061                  presnivs, & 
     2062                  calday, & 
     2063                  klon, & 
     2064                  nqtot, & 
     2065                  nqo+nqCO2, & 
     2066                  pdtphys, & 
     2067                  annee_ref, & 
     2068                  year_cur, & 
     2069                  day_ref,  & 
     2070                  day_ini, & 
     2071                  start_time, & 
     2072                  itau_phy, & 
     2073                  date0, & 
     2074                  chemistry_couple, & 
     2075                  init_source, & 
     2076                  init_tauinca, & 
     2077                  init_pizinca, & 
     2078                  init_cginca, & 
     2079                  init_ccminca) 
     2080          ELSE 
     2081             CALL chemini(  pplay, & 
     2082                  nbp_lon, nbp_lat, & 
     2083                  latitude_deg, & 
     2084                  longitude_deg, & 
     2085                  presnivs, & 
     2086                  calday, & 
     2087                  klon, & 
     2088                  nqtot, & 
     2089                  nqo+nqCO2, & 
     2090                  pdtphys, & 
     2091                  annee_ref, & 
     2092                  year_cur, & 
     2093                  day_ref,  & 
     2094                  day_ini, & 
     2095                  start_time, & 
     2096                  itau_phy, & 
     2097                  date0, & 
     2098                  chemistry_couple, & 
     2099                  init_source, & 
     2100                  init_tauinca, & 
     2101                  init_pizinca, & 
     2102                  init_cginca, & 
     2103                  init_ccminca, & 
     2104                  io_lon, & 
     2105                  io_lat) 
     2106          ENDIF 
    19402107 
    19412108 
     
    19522119#endif 
    19532120       ENDIF 
    1954        IF (type_trac == 'repr') THEN 
     2121       ! 
     2122       IF (ANY(types_trac == 'repr')) THEN 
    19552123#ifdef REPROBUS 
    19562124          CALL chemini_rep(  & 
     
    20002168          SFRWL(6)=3.02191470E-02 
    20012169       END SELECT 
    2002  
    2003  
    20042170       !albedo SB <<< 
    20052171 
     
    20402206 
    20412207 
     2208 
    20422209    ENDIF 
    20432210    ! 
     
    20552222      ENDIF 
    20562223    ENDIF 
     2224! switch to XIOS LMDZ physics context just in case 
     2225!$OMP MASTER 
     2226!!!!#ifdef CPP_XIOS 
     2227!!!!    WRITE(*,*)'PHYSICS XIOS Context :', g_ctx 
     2228!!!!    CALL xios_set_current_context(g_ctx) 
     2229!!!!#endif 
     2230!$OMP END MASTER 
     2231 
    20572232    ! 
    20582233    ! 
     
    20662241 
    20672242    ! Update time and other variables in Reprobus 
    2068     IF (type_trac == 'repr') THEN 
     2243    IF (ANY(types_trac == 'repr')) THEN 
    20692244#ifdef REPROBUS 
    20702245       CALL Init_chem_rep_xjour(jD_cur-jD_ref+day_ref) 
     
    21242299      ! RomP <<< 
    21252300    ENDIF 
    2126  
    21272301    ! 
    21282302    ! Ne pas affecter les valeurs entrees de u, v, h, et q 
     
    21362310          ql_seri(i,k) = qx(i,k,iliq) 
    21372311          !CR: ATTENTION, on rajoute la variable glace 
    2138           IF (nqo.eq.2) THEN 
     2312          IF (nqo.EQ.2) THEN             !--vapour and liquid only 
    21392313             qs_seri(i,k) = 0. 
    2140           ELSE IF (nqo.eq.3) THEN 
     2314             rneb_seri(i,k) = 0. 
     2315          ELSE IF (nqo.EQ.3) THEN        !--vapour, liquid and ice 
    21412316             qs_seri(i,k) = qx(i,k,isol) 
     2317             rneb_seri(i,k) = 0. 
     2318          ELSE IF (nqo.EQ.4) THEN        !--vapour, liquid, ice and rneb 
     2319             qs_seri(i,k) = qx(i,k,isol) 
     2320             rneb_seri(i,k) = qx(i,k,irneb) 
    21422321          ENDIF 
    21432322       ENDDO 
     
    21552334 
    21562335    tke0(:,:)=pbl_tke(:,:,is_ave) 
    2157     !CR:Nombre de traceurs de l'eau: nqo 
    2158     !  IF (nqtot.GE.3) THEN 
    2159     IF (nqtot.GE.(nqo+1)) THEN 
    2160        !     DO iq = 3, nqtot         
    2161        DO iq = nqo+1, nqtot   
     2336    IF (nqtot > nqo) THEN 
     2337       ! water isotopes are not included in tr_seri 
     2338       itr = 0 
     2339       DO iq = 1, nqtot 
     2340         IF(.NOT.tracers(iq)%isInPhysics) CYCLE 
     2341         itr = itr+1 
    21622342          DO  k = 1, klev 
    21632343             DO  i = 1, klon 
    2164                 !              tr_seri(i,k,iq-2) = qx(i,k,iq) 
    2165                 tr_seri(i,k,iq-nqo) = qx(i,k,iq) 
     2344                tr_seri(i,k,itr) = qx(i,k,iq) 
    21662345             ENDDO 
    21672346          ENDDO 
    21682347       ENDDO 
    21692348    ELSE 
    2170        DO k = 1, klev 
    2171           DO i = 1, klon 
    2172              tr_seri(i,k,1) = 0.0 
    2173           ENDDO 
    2174        ENDDO 
     2349! DC: make sure the final "1" index was meant for 1st H2O phase (vapor) !!! 
     2350       tr_seri(:,:,strIdx(tracers(:)%name,addPhase('H2O','g'))) = 0.0 
    21752351    ENDIF 
    21762352! 
     
    21792355    IF (debut) THEN 
    21802356      WRITE(lunout,*)' WARNING: tr_ancien initialised to tr_seri' 
    2181       DO iq = nqo+1, nqtot 
    2182            tr_ancien(:,:,iq-nqo)=tr_seri(:,:,iq-nqo) 
    2183       ENDDO 
     2357       itr = 0 
     2358       do iq = 1, nqtot 
     2359         IF(.NOT.tracers(iq)%isInPhysics) CYCLE 
     2360         itr = itr+1 
     2361         tr_ancien(:,:,itr)=tr_seri(:,:,itr)        
     2362       enddo 
    21842363    ENDIF 
    21852364    ! 
     
    22122391       d_qs_dyn2d(:)=(zx_tmp_fi2d(:)-prsw_ancien(:))/phys_tstep 
    22132392       ! !! RomP >>>   td dyn traceur 
    2214        IF (nqtot.GT.nqo) THEN     ! jyg 
    2215           DO iq = nqo+1, nqtot      ! jyg 
    2216               d_tr_dyn(:,:,iq-nqo)=(tr_seri(:,:,iq-nqo)-tr_ancien(:,:,iq-nqo))/phys_tstep ! jyg 
    2217           ENDDO 
    2218        ENDIF 
     2393       IF (nqtot > nqo) d_tr_dyn(:,:,:)=(tr_seri(:,:,:)-tr_ancien(:,:,:))/phys_tstep 
    22192394       ! !! RomP <<< 
     2395       !!d_rneb_dyn(:,:)=(rneb_seri(:,:)-rneb_ancien(:,:))/phys_tstep 
     2396       d_rneb_dyn(:,:)=0.0 
    22202397    ELSE 
    22212398       d_u_dyn(:,:)  = 0.0 
     
    22292406       d_qs_dyn2d(:) = 0.0 
    22302407       ! !! RomP >>>   td dyn traceur 
    2231        IF (nqtot.GT.nqo) THEN                                       ! jyg 
    2232           DO iq = nqo+1, nqtot                                      ! jyg 
    2233               d_tr_dyn(:,:,iq-nqo)= 0.0                             ! jyg 
    2234           ENDDO 
    2235        ENDIF 
     2408       IF (nqtot > nqo) d_tr_dyn(:,:,:)= 0.0 
    22362409       ! !! RomP <<< 
     2410       d_rneb_dyn(:,:)=0.0 
    22372411       ancien_ok = .TRUE. 
    22382412    ENDIF 
     
    24632637    !   s_therm,   s_trmb1,   s_trmb2, s_trmb3, 
    24642638    !   zu10m,     zv10m,   fder, 
    2465     !   zxqsurf,   rh2m,      zxfluxu, zxfluxv, 
     2639    !   zxqsurf,   delta_qsurf, 
     2640    !   rh2m,      zxfluxu, zxfluxv, 
    24662641    !   frugs,     agesno,    fsollw,  fsolsw, 
    24672642    !   d_ts,      fevap,     fluxlat, t2m, 
     
    25132688            debut,     lafin, & 
    25142689            longitude_deg, latitude_deg, rugoro,  zrmu0,      & 
    2515             zsig,      sollwdown, pphi,    cldt,      & 
    2516             rain_fall, snow_fall, solsw,   sollw,     & 
     2690            sollwdown,    cldt,      & 
     2691            rain_fall, snow_fall, solsw,   solswfdiff, sollw,     & 
    25172692            gustiness,                                & 
    25182693            t_seri,    q_seri,    u_seri,  v_seri,    & 
     
    25242699                                !albedo SB <<< 
    25252700            cdragh,    cdragm,  u1,    v1,            & 
     2701            beta_aridity, & 
    25262702                                !albedo SB >>> 
    25272703                                ! albsol1,   albsol2,   sens,    evap,      & 
     
    25292705                                !albedo SB <<< 
    25302706            albsol3_lic,runoff,   snowhgt,   qsnow, to_ice, sissnow, & 
    2531             zxtsol,    zxfluxlat, zt2m,    qsat2m,  & 
     2707            zxtsol,    zxfluxlat, zt2m,    qsat2m,  zn2mout, & 
    25322708            d_t_vdf,   d_q_vdf,   d_u_vdf, d_v_vdf, d_t_diss, & 
    25332709                                !nrlmd< 
     
    25502726            s_therm,   s_trmb1,   s_trmb2, s_trmb3, & 
    25512727            zustar, zu10m,     zv10m,   fder, & 
    2552             zxqsurf,   rh2m,      zxfluxu, zxfluxv, & 
     2728            zxqsurf, delta_qsurf,   rh2m,      zxfluxu, zxfluxv, & 
    25532729            z0m, z0h,     agesno,    fsollw,  fsolsw, & 
    25542730            d_ts,      fevap,     fluxlat, t2m, & 
     
    25762752!>jyg 
    25772753       ENDIF 
    2578  
    2579 !add limitation for t,q at and wind at 10m 
    2580         if ( iflag_bug_t2m_ipslcm61 == 0 ) THEN 
    2581           CALL borne_var_surf( klon,klev,nbsrf,                 & 
    2582             iflag_bug_t2m_stab_ipslcm61,                        & 
    2583             t_seri(:,1),q_seri(:,1),u_seri(:,1),v_seri(:,1),    & 
    2584             ftsol,zxqsurf,pctsrf,paprs,                         & 
    2585             t2m, q2m, u10m, v10m,                               & 
    2586             zt2m_cor, zq2m_cor, zu10m_cor, zv10m_cor,           & 
    2587             zrh2m_cor, zqsat2m_cor) 
    2588         ELSE 
    2589           zt2m_cor(:)=zt2m(:) 
    2590           zq2m_cor(:)=zq2m(:) 
    2591           zu10m_cor(:)=zu10m(:) 
    2592           zv10m_cor(:)=zv10m(:) 
    2593           zqsat2m_cor=999.999 
    2594         ENDIF 
    25952754 
    25962755       !--------------------------------------------------------------------- 
     
    27972956         ENDDO 
    27982957       ELSE 
    2799                t_w(:,:) = t_seri(:,:) 
     2958                t_w(:,:) = t_seri(:,:) 
    28002959                q_w(:,:) = q_seri(:,:) 
    28012960                t_x(:,:) = t_seri(:,:) 
     
    28733032          ! 
    28743033          !>jyg 
    2875           IF (type_trac == 'repr') THEN 
     3034          IF (ANY(types_trac == 'repr')) THEN 
    28763035             nbtr_tmp=ntra 
    28773036          ELSE 
     
    30133172 
    30143173       DO i = 1, klon 
    3015           ema_pcb(i)  = paprs(i,ibas_con(i)) 
     3174          ! C Risi modif: pour éviter pb de dépassement d'indice dans les cas 
     3175          ! où i n'est pas un point convectif et donc ibas_con(i)=0 
     3176          ! c'est un pb indépendant des isotopes 
     3177          if (ibas_con(i) > 0) then 
     3178             ema_pcb(i)  = paprs(i,ibas_con(i)) 
     3179          else 
     3180             ema_pcb(i)  = 0.0 
     3181          endif 
    30163182       ENDDO 
    30173183       DO i = 1, klon 
     
    34393605    ! Computation of ratqs, the width (normalized) of the subrid scale  
    34403606    ! water distribution 
     3607 
     3608    tke_dissip_ave(:,:)=0. 
     3609    l_mix_ave(:,:)=0. 
     3610    wprime_ave(:,:)=0. 
     3611 
     3612    DO nsrf = 1, nbsrf 
     3613       DO i = 1, klon 
     3614          tke_dissip_ave(i,:) = tke_dissip_ave(i,:) + tke_dissip(i,:,nsrf)*pctsrf(i,nsrf) 
     3615          l_mix_ave(i,:) = l_mix_ave(i,:) + l_mix(i,:,nsrf)*pctsrf(i,nsrf) 
     3616          wprime_ave(i,:) = wprime_ave(i,:) + wprime(i,:,nsrf)*pctsrf(i,nsrf) 
     3617       ENDDO 
     3618    ENDDO 
     3619 
    34413620    CALL  calcratqs(klon,klev,prt_level,lunout,        & 
    34423621         iflag_ratqs,iflag_con,iflag_cld_th,pdtphys,  & 
    34433622         ratqsbas,ratqshaut,ratqsp0, ratqsdp, & 
    3444          tau_ratqs,fact_cldcon,   & 
     3623         tau_ratqs,fact_cldcon,wake_s, wake_deltaq,   & 
    34453624         ptconv,ptconvth,clwcon0th, rnebcon0th,     & 
    3446          paprs,pplay,q_seri,zqsat,fm_therm, & 
    3447          ratqs,ratqsc) 
    3448  
     3625         paprs,pplay,t_seri,q_seri, qtc_cv, sigt_cv, zqsat, & 
     3626         pbl_tke(:,:,is_ave),tke_dissip_ave,l_mix_ave,wprime_ave,t2m,q2m,fm_therm, & 
     3627         ratqs,ratqsc,ratqs_inter) 
    34493628 
    34503629    ! 
     
    34563635    ENDIF 
    34573636    ! 
     3637 
     3638    picefra(:,:)=0. 
     3639 
     3640    IF (ok_new_lscp) THEN 
     3641 
     3642    !--mise à jour de flight_m et flight_h2o dans leur module 
     3643    IF (ok_plane_h2o .OR. ok_plane_contrail) THEN 
     3644      CALL airplane(debut,pphis,pplay,paprs,t_seri) 
     3645    ENDIF 
     3646 
     3647    CALL lscp(phys_tstep,missing_val,paprs,pplay, & 
     3648         t_seri, q_seri,ptconv,ratqs, & 
     3649         d_t_lsc, d_q_lsc, d_ql_lsc, d_qi_lsc, rneb, rneb_seri, &  
     3650         cldliq, picefra, rain_lsc, snow_lsc, & 
     3651         pfrac_impa, pfrac_nucl, pfrac_1nucl, & 
     3652         frac_impa, frac_nucl, beta_prec_fisrt, & 
     3653         prfl, psfl, rhcl,  & 
     3654         zqasc, fraca,ztv,zpspsk,ztla,zthl,iflag_cld_th, & 
     3655         iflag_ice_thermo, ok_ice_sursat) 
     3656 
     3657    ELSE 
     3658 
    34583659    CALL fisrtilp(phys_tstep,paprs,pplay, & 
    34593660         t_seri, q_seri,ptconv,ratqs, & 
     
    34653666         zqasc, fraca,ztv,zpspsk,ztla,zthl,iflag_cld_th, & 
    34663667         iflag_ice_thermo) 
     3668 
     3669    ENDIF 
    34673670    ! 
    34683671    WHERE (rain_lsc < 0) rain_lsc = 0. 
     
    34873690       ENDDO 
    34883691    ENDDO 
    3489     IF (nqo==3) THEN 
     3692    IF (nqo >= 3) THEN 
    34903693    DO k = 1, klev 
    34913694       DO i = 1, klon 
     
    37043907          ENDIF 
    37053908          zx_rh(i,k) = q_seri(i,k)/zx_qs 
     3909            IF (iflag_ice_thermo .GT. 0) THEN 
     3910          zx_rhl(i,k) = q_seri(i,k)/(qsatl(zx_t)/pplay(i,k)) 
     3911          zx_rhi(i,k) = q_seri(i,k)/(qsats(zx_t)/pplay(i,k)) 
     3912            ENDIF 
    37063913          zqsat(i,k)=zx_qs 
    37073914       ENDDO 
     
    37303937    ENDDO 
    37313938 
    3732     IF (type_trac == 'inca') THEN 
     3939    IF (ANY(types_trac == 'inca') .OR. ANY(types_trac == 'inco')) THEN ! ModThL 
    37333940#ifdef INCA 
    37343941       CALL VTe(VTphysiq) 
     
    37733980            nbp_lon, & 
    37743981            nbp_lat-1, & 
    3775             tr_seri, & 
     3982            tr_seri(:,:,1+nqCO2:nbtr), & 
    37763983            ftsol, & 
    37773984            paprs, & 
     
    37843991       CALL VTe(VTinca) 
    37853992       CALL VTb(VTphysiq) 
    3786 #endif  
    3787     ENDIF !type_trac = inca 
    3788     IF (type_trac == 'repr') THEN 
     3993#endif 
     3994    ENDIF !type_trac = inca or inco 
     3995    IF (ANY(types_trac == 'repr')) THEN 
    37893996#ifdef REPROBUS 
    37903997    !CALL chemtime_rep(itap+itau_phy-1, date0, dtime, itap) 
     
    39564163 
    39574164       IF (ok_newmicro) then 
    3958           IF (iflag_rrtm.NE.0) THEN  
     4165! AI          IF (iflag_rrtm.NE.0) THEN  
     4166          IF (iflag_rrtm.EQ.1) THEN 
    39594167#ifdef CPP_RRTM 
    39604168             IF (ok_cdnc.AND.NRADLP.NE.3) THEN 
     
    39704178          ENDIF 
    39714179          CALL newmicro (flag_aerosol, ok_cdnc, bl95_b0, bl95_b1, & 
    3972                paprs, pplay, t_seri, cldliq, cldfra, & 
     4180               paprs, pplay, t_seri, cldliq, picefra, cldfra, & 
    39734181               cldtau, cldemi, cldh, cldl, cldm, cldt, cldq, & 
    39744182               flwp, fiwp, flwc, fiwc, & 
    39754183               mass_solu_aero, mass_solu_aero_pi, & 
    3976                cldtaupi, re, fl, ref_liq, ref_ice, & 
     4184               cldtaupi, latitude_deg, re, fl, ref_liq, ref_ice, & 
    39774185               ref_liq_pi, ref_ice_pi) 
    39784186       ELSE 
    39794187          CALL nuage (paprs, pplay, & 
    3980                t_seri, cldliq, cldfra, cldtau, cldemi, & 
     4188               t_seri, cldliq, picefra, cldfra, cldtau, cldemi, & 
    39814189               cldh, cldl, cldm, cldt, cldq, & 
    39824190               ok_aie, & 
     
    41144322          !  
    41154323          !--interactive CO2 in ppm from carbon cycle 
    4116           IF (carbon_cycle_rad.AND..NOT.debut) THEN 
    4117             RCO2=RCO2_glo 
    4118           ENDIF 
     4324          IF (carbon_cycle_rad) RCO2=RCO2_glo 
    41194325          ! 
    41204326          IF (prt_level .GE.10) THEN 
     
    41304336               t_seri,q_seri,wo, & 
    41314337               cldfrarad, cldemirad, cldtaurad, & 
    4132                ok_ade.OR.flag_aerosol_strat.GT.0, ok_aie,  ok_volcan, & 
    4133                flag_aerosol, & 
    4134                flag_aerosol_strat, flag_aer_feedback, & 
     4338               ok_ade.OR.flag_aerosol_strat.GT.0, ok_aie,  ok_volcan, flag_volc_surfstrat, & 
     4339               flag_aerosol, flag_aerosol_strat, flag_aer_feedback, & 
    41354340               tau_aero, piz_aero, cg_aero, & 
    41364341               tau_aero_sw_rrtm, piz_aero_sw_rrtm, cg_aero_sw_rrtm, &  
     
    41434348               heat,heat0,cool,cool0,albpla, & 
    41444349               heat_volc,cool_volc, & 
    4145                topsw,toplw,solsw,sollw, & 
     4350               topsw,toplw,solsw,solswfdiff,sollw, & 
    41464351               sollwdown, & 
    41474352               topsw0,toplw0,solsw0,sollw0, & 
     
    42174422                     t_seri,q_seri,wo, & 
    42184423                     cldfrarad, cldemirad, cldtaurad, & 
    4219                      ok_ade.OR.flag_aerosol_strat.GT.0, ok_aie,  ok_volcan, & 
    4220                      flag_aerosol, & 
    4221                      flag_aerosol_strat, flag_aer_feedback, & 
     4424                     ok_ade.OR.flag_aerosol_strat.GT.0, ok_aie,  ok_volcan, flag_volc_surfstrat, & 
     4425                     flag_aerosol, flag_aerosol_strat, flag_aer_feedback, & 
    42224426                     tau_aero, piz_aero, cg_aero, & 
    42234427                     tau_aero_sw_rrtm, piz_aero_sw_rrtm, cg_aero_sw_rrtm, & 
     
    42304434                     heatp,heat0p,coolp,cool0p,albplap, & 
    42314435                     heat_volc,cool_volc, & 
    4232                      topswp,toplwp,solswp,sollwp, & 
     4436                     topswp,toplwp,solswp,solswfdiffp,sollwp, & 
    42334437                     sollwdownp, & 
    42344438                     topsw0p,toplw0p,solsw0p,sollw0p, & 
     
    42484452                     ZLWFT0_i, ZFLDN0, ZFLUP0, & 
    42494453                     ZSWFT0_i, ZFSDN0, ZFSUP0) 
    4250           endif !ok_4xCO2atm 
     4454          ENDIF !ok_4xCO2atm 
    42514455       ENDIF ! aerosol_couple 
    42524456       itaprad = 0 
     
    46294833 
    46304834    CALL tend_to_tke(pdtphys,paprs,exner,t_seri,u_seri,v_seri,dtadd,duadd,dvadd,pctsrf,pbl_tke) 
    4631  
     4835   ! 
     4836   ! Prevent pbl_tke_w from becoming negative 
     4837    wake_delta_pbl_tke(:,:,:) = max(wake_delta_pbl_tke(:,:,:), -pbl_tke(:,:,:)) 
     4838   ! 
    46324839 
    46334840       ENDIF 
     
    47004907#ifdef CPP_COSPV2 
    47014908       IF (itap.eq.1.or.MOD(itap,NINT(freq_cosp/phys_tstep)).EQ.0) THEN 
     4909!        IF (MOD(itap,NINT(freq_cosp/phys_tstep)).EQ.0) THEN 
    47024910 
    47034911          IF (prt_level .GE.10) THEN 
    47044912             print*,'freq_cosp',freq_cosp 
    47054913          ENDIF 
     4914           DO k = 1, klev 
     4915             DO i = 1, klon 
     4916               phicosp(i,k) = pphi(i,k) + pphis(i) 
     4917             ENDDO 
     4918           ENDDO 
    47064919          mr_ozone=wo(:, :, 1) * dobson_u * 1e3 / zmasse 
    47074920                 print*,'Dans physiq.F avant appel ' 
     
    47554968    ! 
    47564969 
    4757     IF (type_trac=='repr') THEN 
     4970    IF (ANY(types_trac=='repr')) THEN 
    47584971!MM pas d'impact, car on recupere q_seri,tr_seri,t_seri via phys_local_var_mod 
    47594972!MM                               dans Reprobus 
     
    47664979    ELSE 
    47674980       sh_in(:,:) = qx(:,:,ivap) 
    4768        ch_in(:,:) = qx(:,:,iliq) 
    4769     ENDIF 
    4770  
    4771     IF (iflag_phytrac == 1 ) THEN 
     4981       IF (nqo >= 3) THEN  
     4982          ch_in(:,:) = qx(:,:,iliq) + qx(:,:,isol) 
     4983       ELSE  
     4984          ch_in(:,:) = qx(:,:,iliq) 
     4985       ENDIF 
     4986    ENDIF 
    47724987 
    47734988#ifdef CPP_Dust 
    4774       CALL       phytracr_spl ( debut,lafin , jD_cur,jH_cur,iflag_con,       &  ! I 
     4989    !  Avec SPLA, iflag_phytrac est forcé =1  
     4990    CALL       phytracr_spl ( debut,lafin , jD_cur,jH_cur,iflag_con,       &  ! I 
    47754991                      pdtphys,ftsol,                                   &  ! I 
    47764992                      t,q_seri,paprs,pplay,RHcl,                  &  ! I 
     
    47885004 
    47895005#else 
    4790  
    4791     CALL phytrac ( & 
     5006    IF (iflag_phytrac == 1 ) THEN 
     5007      CALL phytrac ( & 
    47925008         itap,     days_elapsed+1,    jH_cur,   debut, & 
    47935009         lafin,    phys_tstep,     u, v,     t, & 
     
    48265042 
    48275043#endif 
     5044    ENDIF    ! (iflag_phytrac=1) 
    48285045 
    48295046#endif 
    4830     ENDIF    ! (iflag_phytrac=1) 
     5047    !ENDIF    ! (iflag_phytrac=1) 
    48315048 
    48325049    IF (offline) THEN 
     
    48495066    ! Calculer le transport de l'eau et de l'energie (diagnostique) 
    48505067    ! 
    4851     CALL transp (paprs,zxtsol, & 
    4852          t_seri, q_seri, ql_seri, qs_seri, u_seri, v_seri, zphi, & 
    4853          ve, vq, ue, uq, vwat, uwat) 
     5068    CALL transp (paprs,zxtsol, t_seri, q_seri, ql_seri, qs_seri, u_seri, v_seri, zphi, & 
     5069                 ue, ve, uq, vq, uwat, vwat) 
    48545070    ! 
    48555071    !IM global posePB BEG 
    48565072    IF(1.EQ.0) THEN 
    48575073       ! 
    4858        CALL transp_lay (paprs,zxtsol, & 
    4859             t_seri, q_seri, u_seri, v_seri, zphi, & 
     5074       CALL transp_lay (paprs,zxtsol, t_seri, q_seri, u_seri, v_seri, zphi, & 
    48605075            ve_lay, vq_lay, ue_lay, uq_lay) 
    48615076       ! 
    48625077    ENDIF !(1.EQ.0) THEN 
    48635078    !IM global posePB END 
     5079    ! 
    48645080    ! Accumuler les variables a stocker dans les fichiers histoire: 
    48655081    ! 
     
    48725088    d_t_ec(:,:)=0. 
    48735089    forall (k=1: nbp_lev) exner(:, k) = (pplay(:, k)/paprs(:,1))**RKAPPA 
    4874     CALL ener_conserv(klon,klev,pdtphys,u,v,t,qx(:,:,ivap),qx(:,:,iliq),qx(:,:,isol), & 
     5090    CALL ener_conserv(klon,klev,pdtphys,u,v,t,qx,ivap,iliq,isol, & 
    48755091         u_seri,v_seri,t_seri,q_seri,ql_seri,qs_seri,pbl_tke(:,:,is_ave)-tke0(:,:), & 
    48765092         zmasse,exner,d_t_ec) 
     
    49055121    ENDDO 
    49065122    ! 
    4907     IF (type_trac == 'inca') THEN 
     5123    IF (ANY(types_trac == 'inca') .OR. ANY(types_trac == 'inco')) THEN 
    49085124#ifdef INCA 
    49095125       CALL VTe(VTphysiq) 
     
    49145130            pplay, & 
    49155131            t_seri, & 
    4916             tr_seri, & 
     5132            tr_seri(:,:,1+nqCO2:nbtr), & 
    49175133            nbtr, & 
    49185134            paprs, & 
     
    49225138            pphis, & 
    49235139            zx_rh, & 
    4924             aps, bps, ap, bp) 
     5140            aps, bps, ap, bp, lafin) 
    49255141 
    49265142       CALL VTe(VTinca) 
     
    49295145    ENDIF 
    49305146 
     5147    IF (ANY(types_trac == 'repr')) THEN 
     5148#ifdef REPROBUS 
     5149        CALL coord_hyb_rep(paprs, pplay, aps, bps, ap, bp, cell_area) 
     5150#endif 
     5151    ENDIF 
    49315152 
    49325153    ! 
     
    49525173          d_qx(i,k,iliq) = ( ql_seri(i,k) - qx(i,k,iliq) ) / phys_tstep 
    49535174          !CR: on ajoute le contenu en glace 
    4954           IF (nqo.eq.3) THEN 
     5175          IF (nqo >= 3) THEN 
    49555176             d_qx(i,k,isol) = ( qs_seri(i,k) - qx(i,k,isol) ) / phys_tstep 
     5177          ENDIF 
     5178          !--ice_sursat: nqo=4, on ajoute rneb 
     5179          IF (nqo == 4) THEN 
     5180             d_qx(i,k,irneb) = ( rneb_seri(i,k) - qx(i,k,irneb) ) / phys_tstep 
    49565181          ENDIF 
    49575182       ENDDO 
    49585183    ENDDO 
    49595184    ! 
    4960     !CR: nb de traceurs eau: nqo 
    4961     !  IF (nqtot.GE.3) THEN 
    4962     IF (nqtot.GE.(nqo+1)) THEN 
    4963        !     DO iq = 3, nqtot 
    4964        DO iq = nqo+1, nqtot 
     5185    IF (nqtot > nqo) THEN 
     5186       itr = 0 
     5187       DO iq = 1, nqtot 
     5188          IF(.NOT.tracers(iq)%isInPhysics) CYCLE 
     5189          itr = itr+1 
    49655190          DO  k = 1, klev 
    49665191             DO  i = 1, klon 
    4967                 ! d_qx(i,k,iq) = ( tr_seri(i,k,iq-2) - qx(i,k,iq) ) / phys_tstep 
    4968                 d_qx(i,k,iq) = ( tr_seri(i,k,iq-nqo) - qx(i,k,iq) ) / phys_tstep 
     5192                d_qx(i,k,iq) = ( tr_seri(i,k,itr) - qx(i,k,iq) ) / phys_tstep 
    49695193             ENDDO 
    49705194          ENDDO 
     
    50035227    ql_ancien(:,:) = ql_seri(:,:) 
    50045228    qs_ancien(:,:) = qs_seri(:,:) 
     5229    rneb_ancien(:,:) = rneb_seri(:,:) 
    50055230    CALL water_int(klon,klev,q_ancien,zmasse,prw_ancien) 
    50065231    CALL water_int(klon,klev,ql_ancien,zmasse,prlw_ancien) 
    50075232    CALL water_int(klon,klev,qs_ancien,zmasse,prsw_ancien) 
    50085233    ! !! RomP >>> 
    5009     !CR: nb de traceurs eau: nqo 
    5010     IF (nqtot.GT.nqo) THEN 
    5011        DO iq = nqo+1, nqtot 
    5012           tr_ancien(:,:,iq-nqo) = tr_seri(:,:,iq-nqo) 
    5013        ENDDO 
    5014     ENDIF 
     5234    IF (nqtot > nqo) tr_ancien(:,:,:) = tr_seri(:,:,:) 
    50155235    ! !! RomP <<< 
    50165236    !========================================================================== 
     
    51285348  CALL phys_output_write_spl(itap, pdtphys, paprs, pphis,  & 
    51295349       pplay, lmax_th, aerosol_couple,                 & 
    5130        ok_ade, ok_aie, ivap, ok_sync,         & 
     5350       ok_ade, ok_aie, ivap, ok_sync,                  & 
    51315351       ptconv, read_climoz, clevSTD,                   & 
    51325352       ptconvth, d_t, qx, d_qx, d_tr_dyn, zmasse,      & 
     
    51475367#endif 
    51485368 
    5149 ! On remet des variables a .false. apres un premier appel 
    5150     IF (debut) THEN 
    5151 #ifdef CPP_XIOS 
    5152       swaero_diag=.FALSE. 
    5153       swaerofree_diag=.FALSE. 
    5154       dryaod_diag=.FALSE. 
    5155       ok_4xCO2atm= .FALSE. 
    5156 !      write (lunout,*)'ok_4xCO2atm= ',swaero_diag, swaerofree_diag, dryaod_diag, ok_4xCO2atm 
    5157  
    5158       IF (is_master) THEN 
    5159         !--setting up swaero_diag to TRUE in XIOS case  
    5160         IF (xios_field_is_active("topswad").OR.xios_field_is_active("topswad0").OR. &  
    5161            xios_field_is_active("solswad").OR.xios_field_is_active("solswad0").OR. &  
    5162            xios_field_is_active("topswai").OR.xios_field_is_active("solswai").OR.  &  
    5163              (iflag_rrtm==1.AND.(xios_field_is_active("toplwad").OR.xios_field_is_active("toplwad0").OR. &  
    5164                                  xios_field_is_active("sollwad").OR.xios_field_is_active("sollwad0"))))  &  
    5165            !!!--for now these fields are not in the XML files so they are omitted  
    5166            !!!  xios_field_is_active("toplwai").OR.xios_field_is_active("sollwai") !))) &  
    5167            swaero_diag=.TRUE.  
    5168  
    5169         !--setting up swaerofree_diag to TRUE in XIOS case  
    5170         IF (xios_field_is_active("SWdnSFCcleanclr").OR.xios_field_is_active("SWupSFCcleanclr").OR. & 
    5171            xios_field_is_active("SWupTOAcleanclr").OR.xios_field_is_active("rsucsaf").OR.   & 
    5172            xios_field_is_active("rsdcsaf") .OR. xios_field_is_active("LWdnSFCcleanclr").OR. & 
    5173            xios_field_is_active("LWupTOAcleanclr")) & 
    5174            swaerofree_diag=.TRUE.  
    5175  
    5176         !--setting up dryaod_diag to TRUE in XIOS case  
    5177         DO naero = 1, naero_tot-1 
    5178          IF (xios_field_is_active("dryod550_"//name_aero_tau(naero))) dryaod_diag=.TRUE.  
    5179         ENDDO 
    5180         ! 
    5181         !--setting up ok_4xCO2atm to TRUE in XIOS case  
    5182         IF (xios_field_is_active("rsut4co2").OR.xios_field_is_active("rlut4co2").OR. &  
    5183            xios_field_is_active("rsutcs4co2").OR.xios_field_is_active("rlutcs4co2").OR. & 
    5184            xios_field_is_active("rsu4co2").OR.xios_field_is_active("rsucs4co2").OR. & 
    5185            xios_field_is_active("rsd4co2").OR.xios_field_is_active("rsdcs4co2").OR. & 
    5186            xios_field_is_active("rlu4co2").OR.xios_field_is_active("rlucs4co2").OR. & 
    5187            xios_field_is_active("rld4co2").OR.xios_field_is_active("rldcs4co2")) & 
    5188            ok_4xCO2atm=.TRUE.  
    5189       ENDIF 
    5190       !$OMP BARRIER 
    5191       CALL bcast(swaero_diag) 
    5192       CALL bcast(swaerofree_diag) 
    5193       CALL bcast(dryaod_diag) 
    5194       CALL bcast(ok_4xCO2atm) 
    5195 !      write (lunout,*)'ok_4xCO2atm= ',swaero_diag, swaerofree_diag, dryaod_diag, ok_4xCO2atm 
    5196 #endif 
    5197     ENDIF 
    5198  
    51995369    !==================================================================== 
    52005370    ! Arret du modele apres hgardfou en cas de detection d'un 
     
    52145384    ! 
    52155385 
     5386    ! Disabling calls to the prt_alerte function 
     5387    alert_first_call = .FALSE. 
     5388     
    52165389    IF (lafin) THEN 
    52175390       itau_phy = itau_phy + itap 
     
    52325405#ifdef CPP_XIOS 
    52335406       IF (is_omp_master) CALL xios_context_finalize 
     5407 
     5408#ifdef INCA 
     5409       if (ANY(types_trac == 'inca' )) then  
     5410          IF (is_omp_master .and. grid_type==unstructured) THEN  
     5411             CALL finalize_inca 
     5412          ENDIF 
     5413       endif 
     5414#endif 
     5415 
    52345416#endif 
    52355417       WRITE(lunout,*) ' physiq fin, nombre de steps ou cvpas = 1 : ', Ncvpaseq1 
Note: See TracChangeset for help on using the changeset viewer.