!
! $Id: conf_phys.F90 1668 2012-10-12 10:47:37Z idelkadi $
!
!
!
MODULE conf_phys_m

  USE clesphys_mod_h
  IMPLICIT NONE

  ! Récupéré de physiq_mod mars 2026. Faire le tri de ce qui doit être réintégré dans
  ! des modules spécifiques
  LOGICAL, SAVE, PROTECTED :: ok_journe, ok_mensuel, ok_instan, ok_hf, ok_LES
  !$OMP THREADPRIVATE(ok_journe, ok_mensuel, ok_instan, ok_hf, ok_LES)
  LOGICAL, SAVE, PROTECTED :: ok_volcan ! pour activer les diagnostics volcaniques
  !$OMP THREADPRIVATE(ok_volcan)
  INTEGER, SAVE, PROTECTED :: flag_volc_surfstrat ! pour imposer le cool/heat rate à la surf/strato
  !$OMP THREADPRIVATE(flag_volc_surfstrat)
  INTEGER, SAVE, PROTECTED :: iflag_radia     ! active ou non le rayonnement (MPL)
  !$OMP THREADPRIVATE(iflag_radia)
  REAL, SAVE, PROTECTED :: facttemps, fact_cldcon
  !$OMP THREADPRIVATE(facttemps,fact_cldcon)
  INTEGER, SAVE, PROTECTED :: iflag_cld_th
  !$OMP THREADPRIVATE(iflag_cld_th)
  LOGICAL ok_ade, ok_aie    ! Apply aerosol (in)direct effects or not
  LOGICAL ok_alw            ! Apply aerosol LW effect or not
  LOGICAL ok_cdnc ! ok cloud droplet number concentration (O. Boucher 01-2013)
  REAL bl95_b0, bl95_b1   ! Parameter in Boucher and Lohmann (1995)
  SAVE ok_ade, ok_aie, ok_alw, ok_cdnc, bl95_b0, bl95_b1
  !$OMP THREADPRIVATE(ok_ade, ok_aie, ok_alw, ok_cdnc, bl95_b0, bl95_b1)
  LOGICAL, SAVE :: aerosol_couple ! true  : calcul des aerosols dans INCA
  ! false : lecture des aerosol dans un fichier
  !$OMP THREADPRIVATE(aerosol_couple)
  LOGICAL, SAVE :: chemistry_couple ! true  : use INCA chemistry O3
  ! false : use offline chemistry O3
  !$OMP THREADPRIVATE(chemistry_couple)
  INTEGER, SAVE :: flag_aerosol
  !$OMP THREADPRIVATE(flag_aerosol)
  LOGICAL, SAVE :: flag_bc_internal_mixture
  !$OMP THREADPRIVATE(flag_bc_internal_mixture)
  !
  !--STRAT AEROSOL
  INTEGER, SAVE :: flag_aerosol_strat
  !$OMP THREADPRIVATE(flag_aerosol_strat)
  !
  !--INTERACTIVE AEROSOL FEEDBACK ON RADIATION
  LOGICAL, SAVE :: flag_aer_feedback
  !$OMP THREADPRIVATE(flag_aer_feedback)

  REAL,SAVE ::  solarlong0
  !$OMP THREADPRIVATE(solarlong0)

  REAL, SAVE :: alp_offset
  !$OMP THREADPRIVATE(alp_offset)

  INTEGER, SAVE, protected:: read_climoz = 0 ! read ozone climatology
  !     Allowed values are 0, 1 and 2
  !     0: do not read an ozone climatology
  !     1: read a single ozone climatology that will be used day and night
  !     2: read two ozone climatologies, the average day and night
  !     climatology and the daylight climatology
  !$OMP THREADPRIVATE(read_climoz)

  LOGICAL, SAVE, protected:: ok_daily_climoz
  ! TRUE  => daily interpolation
  ! FALSE => no interpolation (14 months)
  ! calendar dependent number of days
  !$OMP THREADPRIVATE(ok_daily_climoz)

  LOGICAL, SAVE, protected:: adjust_tropopause
  ! tropopause adjustement required
  !$OMP THREADPRIVATE(adjust_tropopause)

  !=====================================================================
  ! Specifique de Ale/Alp :
  !=====================================================================
  ! dans alealp_th, thermcell_alp, physiq_mod, conf_phys
  INTEGER, SAVE, protected :: iflag_trig_bl, iflag_clos_bl, iflag_strig
  INTEGER, SAVE, protected :: tau_trig_shallow, tau_trig_deep
  REAL, SAVE, protected :: s_trig, h_trig
  ! thermcell_alp et convection ...
  INTEGER, SAVE, protected :: iflag_coupl, iflag_clos, iflag_wake
  ! thermcell_alp
  REAL, SAVE, protected :: alp_bl_k
  !$OMP THREADPRIVATE(iflag_trig_bl, iflag_clos_bl, tau_trig_shallow, tau_trig_deep, iflag_strig)
  !$OMP THREADPRIVATE(alp_bl_k, s_trig, h_trig, iflag_coupl, iflag_clos, iflag_wake)

CONTAINS

  SUBROUTINE conf_phys

    USE compbl_mod_h
    USE ioipsl_getin_p_mod, ONLY : getin_p
    USE yomcst_mod_h
    USE IOIPSL
    USE surface_data
    USE phys_cal_mod
    USE carbon_cycle_mod,  ONLY: carbon_cycle_tr, carbon_cycle_cpl, carbon_cycle_rad, level_coupling_esm
    ! << PC
    USE carbon_cycle_mod,  ONLY: read_daily_co2ff
    USE carbon_cycle_mod,  ONLY: carbon_cycle_conc_driven
    ! >> PC
    USE carbon_cycle_mod,  ONLY: read_fco2_ocean_cor,var_fco2_ocean_cor
    USE carbon_cycle_mod,  ONLY: read_fco2_land_cor,var_fco2_land_cor
    USE carbon_cycle_mod,  ONLY: read_fco2_ocean_cor_2d, read_fco2_land_cor_2d
    USE chemistry_cycle_mod, ONLY: dms_cycle_cpl, n2o_cycle_cpl, ndp_cycle_cpl, nh3_cycle_cpl
    USE mod_grid_phy_lmdz, ONLY: klon_glo
    USE print_control_mod, ONLY: lunout
    use config_ocean_skin_m, only: config_ocean_skin
    USE infotrac_phy, ONLY: type_trac
    USE lmdz_cppkeys_wrapper, ONLY: CPPKEY_STRATAER
    USE comsoil_mod_h
    USE ch4n2o_correction_mod, ONLY: ok_CH4_eff_ppb, ok_N2O_eff_ppb


    !
    ! Configuration de la "physique" de LMDZ a l'aide de la fonction
    ! GETIN de IOIPSL
    !
    ! LF 05/2001
    !
    ! type_ocean:      type d'ocean (force, slab, couple)
    ! version_ocean:   version d'ocean (opa8/nemo pour type_ocean=couple ou 
    !                                   sicOBS,sicINT,sicNO pour type_ocean=slab)
    ! ok_veget:   type de modele de vegetation
    ! ok_journe:  sorties journalieres
    ! ok_hf:  sorties haute frequence
    ! ok_mensuel: sorties mensuelles
    ! ok_instan:  sorties instantanees
    ! ok_ade, ok_aie: apply or not aerosol direct and indirect effects
    ! ok_alw: activate aerosol LW effect
    ! ok_cdnc, ok cloud droplet number concentration
    ! flag_aerosol_strat : flag pour les aerosols stratos
    ! flag_bc_internal_mixture : use BC internal mixture if true
    ! bl95_b*: parameters in the formula to link CDNC to aerosol mass conc 
    ! ok_volcan: activate volcanic diags (SW heat & LW cool rate, SW & LW flux)
    ! flag_volc_surfstrat: VolMIP flag, activate forcing surface cooling rate (=1), strato heating rate (=2) or nothing (=0, default)
    !

    ! Sortie:

    REAL                :: ratio_z0hz0m_land, ratio_z0hz0m_ocean, ratio_z0hz0m_landice, ratio_z0hz0m_seaice

    !
    !rajout de choix_bulk et nit_bulk par Olivier Torres
    ! PC
    ! Per-gas routing switches (Concentration "effective")

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

    CHARACTER (len = 6) :: ocean
    REAL co2_ppm_per
    print*,'CONFPHYS ENTREE'
    !
    type_ocean = 'force '
    CALL getin_p('type_ocean', type_ocean)
    !
    !
    version_ocean = 'xxxxxx'
    CALL getin_p('version_ocean', version_ocean)

    !
    ocean = 'yyyyyy'
    CALL getin_p('OCEAN', ocean)
    IF (ocean /= 'yyyyyy') THEN
       WRITE(lunout,*)'ERROR! Old variable name OCEAN used in parmeter file.'
       WRITE(lunout,*)'Variable OCEAN has been replaced by the variable type_ocean.'
       WRITE(lunout,*)'You have to update your parameter file physiq.def to succed running'
       CALL abort_physic('conf_phys','Variable OCEAN no longer existing, use variable name type_ocean',1)
    ENDIF

    !
    t_coupl = 86400.
    CALL getin_p('t_coupl', t_coupl)
    IF (t_coupl == 0) THEN
       WRITE(lunout,*)'ERROR! Timestep of coupling between atmosphere and ocean'
       WRITE(lunout,*)'cannot be zero.'
       CALL abort_physic('conf_phys','t_coupl = 0.',1)
    ENDIF

    !
    !
    ok_all_xml = .FALSE.
    CALL getin_p('ok_all_xml', ok_all_xml)

    !
    !
    ok_lwoff = .FALSE.
    CALL getin_p('ok_lwoff', ok_lwoff)
    !

    !
    !
    type_veget ='orchidee'
    CALL getin_p('VEGET', type_veget)
    !

    ! INLANDSIS
    !==================================================================
    ! Martin et Etienne
    landice_opt = 0
    CALL getin_p('landice_opt', landice_opt)
    ! Martin et Etienne

    !Etienne
    iflag_temp_inlandsis = 0
    CALL getin_p('iflag_temp_inlandsis', iflag_temp_inlandsis)

    !Etienne
    iflag_tsurf_inlandsis = 1
    CALL getin_p('iflag_tsurf_inlandsis', iflag_tsurf_inlandsis)


    !Etienne
    iflag_albcalc = 0
    CALL getin_p('iflag_albcalc', iflag_albcalc)


    !Etienne
    SnoMod = .TRUE.
    CALL getin_p('SnoMod', SnoMod)

    !Etienne
    BloMod = .FALSE.
    CALL getin_p('BloMod', BloMod)

    !Etienne
    ok_outfor = .FALSE.
    CALL getin_p('ok_outfor', ok_outfor)


    !Etienne
    ok_zsn_ii = .TRUE.
    CALL getin_p('ok_zsn_ii', ok_zsn_ii)


    !Etienne
    discret_xf = .TRUE.
    CALL getin_p('discret_xf', discret_xf)


    !Etienne
    is_ok_slush = .TRUE.
    CALL getin_p('is_ok_slush', is_ok_slush)

    !Etienne
    opt_runoff_ac = .TRUE.
    CALL getin_p('opt_runoff_ac', opt_runoff_ac)

    !Etienne
    is_ok_z0h_rn = .TRUE.
    CALL getin_p('is_ok_z0h_rn', is_ok_z0h_rn)


    !Etienne
    is_ok_density_kotlyakov = .FALSE.
    CALL getin_p('is_ok_density_kotlyakov', is_ok_density_kotlyakov)


    !Etienne
    prescribed_z0m_snow = 0.005
    CALL getin_p('prescribed_z0m_snow', prescribed_z0m_snow)


    !Etienne
    iflag_z0m_snow = 0
    CALL getin_p('iflag_z0m_snow', iflag_z0m_snow)


    !Etienne
    correc_alb=1.01
    CALL getin_p('correc_alb', correc_alb)


    !Etienne
    buf_sph_pol=99.
    CALL getin_p('buf_sph_pol', buf_sph_pol)

    !Etienne
    buf_siz_pol=4.
    CALL getin_p('buf_siz_pol', buf_siz_pol)

    !==================================================================

    !              journalieres 
    !
    ok_journe = .FALSE.
    CALL getin_p('OK_journe', ok_journe)
    !
    !              haute frequence ( 3h ou 6h)
    !
    ok_hf = .FALSE.
    CALL getin_p('ok_hf', ok_hf)
    !
    !              mensuelles 
    !
    ok_mensuel = .TRUE.
    CALL getin_p('OK_mensuel', ok_mensuel)
    !
    !              instantanees 
    !
    ok_instan = .FALSE.
    CALL getin_p('OK_instan', ok_instan)
    !
    !
    ok_ade = .FALSE.
    CALL getin_p('ok_ade', ok_ade)

    !
    ok_alw = .FALSE.
    CALL getin_p('ok_alw', ok_alw)

    !
    !
    ok_aie = .FALSE.
    CALL getin_p('ok_aie', ok_aie)

    !
    !
    ok_cdnc = .FALSE.
    CALL getin_p('ok_cdnc', ok_cdnc)

    !
    !
    ok_volcan = .FALSE.
    CALL getin_p('ok_volcan', ok_volcan)

    !
    !              heating rate in the strato (=2), or nothing (=0)
    !
    flag_volc_surfstrat = 0 ! NL: SURFSTRAT
    CALL getin_p('flag_volc_surfstrat', flag_volc_surfstrat) 

    !
    !
    aerosol_couple = .FALSE.
    CALL getin_p('aerosol_couple',aerosol_couple)
    !
    !
    chemistry_couple = .FALSE.
    CALL getin_p('chemistry_couple',chemistry_couple)
    !
    !
    ! - flag_aerosol=0 => no aerosol
    ! - flag_aerosol=1 => so4 only (defaut) 
    ! - flag_aerosol=2 => bc  only 
    ! - flag_aerosol=3 => pom only
    ! - flag_aerosol=4 => seasalt only 
    ! - flag_aerosol=5 => dust only
    ! - flag_aerosol=6 => all aerosol
    ! - flag_aerosol=7 => natural aerosol + MACv2SP
    ! - (in this case aerosols.1980.nc should point to aerosols.nat.nc)

    flag_aerosol = 0
    CALL getin_p('flag_aerosol',flag_aerosol)

    !
    ! - n = external mixture
    ! - y = internal mixture
    !
    flag_bc_internal_mixture = .FALSE.
    CALL getin_p('flag_bc_internal_mixture',flag_bc_internal_mixture)

    ! 
    ! 
    aer_type = 'scenario' 
    CALL getin_p('aer_type', aer_type) 

    !
    !
    bl95_b0 = 2.
    CALL getin_p('bl95_b0', bl95_b0)

    !
    bl95_b1 = 0.2
    CALL getin_p('bl95_b1', bl95_b1)

    !              par defaut 10800, i.e. 3 heures 
    !
    freq_ISCCP = 10800.
    CALL getin_p('freq_ISCCP', freq_ISCCP)
    !
    !              par defaut 1., i.e. 1 jour
    !
    !
    ecrit_ISCCP = 1.
    CALL getin_p('ecrit_ISCCP', ecrit_ISCCP)

    !              par defaut 10800, i.e. 3 heures
    !
    freq_COSP = 10800.
    CALL getin_p('freq_COSP', freq_COSP)

    !              par defaut 10800, i.e. 3 heures
    !
    freq_AIRS = 10800.
    CALL getin_p('freq_AIRS', freq_AIRS)

    !
    !               
    ip_ebil_phy = 0
    CALL getin_p('ip_ebil_phy', ip_ebil_phy)
    IF (ip_ebil_phy/=0) THEN
       CALL abort_physic('conf_phys','ip_ebil_phy doit etre 0 sur cette version',1)
    ENDIF

    !
    !
    ! Constante solaire & Parametres orbitaux & taux gaz effet de serre BEG
    !
    !               
    !valeur AMIP II
    R_ecc = 0.016715
    CALL getin_p('R_ecc', R_ecc)
    !
    !               
    !
    !valeur AMIP II
    R_peri = 102.7
    CALL getin_p('R_peri', R_peri)
    !
    !               
    !
    !valeur AMIP II
    R_incl = 23.441
    CALL getin_p('R_incl', R_incl)
    !
    !               
    !
    !valeur AMIP II
    solaire = 1365.
    CALL getin_p('solaire', solaire)
    !
    !               
    !valeur AMIP II
    co2_ppm = 348.
    CALL getin_p('co2_ppm', co2_ppm)
    !
    !conversion en rapport de mélange massique
    RCO2 = co2_ppm * 1.0e-06 * RMCO2 / RMD

    !
    !              où cette concentration de figure pas dans l'état de redémarrage de la physique
    !               
    co2_ppm0 = 284.32
    CALL getin_p('co2_ppm0', co2_ppm0)
    !
    !               
    CH4_ppb = 1650.
    CALL getin_p('CH4_ppb', CH4_ppb)
    !conversion en rapport de mélange massique
    RCH4 = CH4_ppb * 1.0E-09 * RMCH4 / RMD
    !
    !               
    N2O_ppb = 306.
    CALL getin_p('N2O_ppb', N2O_ppb)
    !conversion en rapport de mélange massique
    RN2O = N2O_ppb * 1.0E-09 * RMN2O / RMD
    !
    ok_CH4_eff_ppb = .FALSE.
    CALL getin_p('ok_CH4_eff_ppb', ok_CH4_eff_ppb)

    ok_N2O_eff_ppb = .FALSE.
    CALL getin_p('ok_N2O_eff_ppb', ok_N2O_eff_ppb)
    !
    !
    CFC11_ppt = 280.
    CALL getin_p('CFC11_ppt',CFC11_ppt)
    !conversion en rapport de mélange massique
    RCFC11=CFC11_ppt* 1.0E-12 * RMCFC11 / RMD
    !
    !               
    CFC12_ppt = 484.
    CALL getin_p('CFC12_ppt',CFC12_ppt)
    !conversion en rapport de mélange massique
    RCFC12 = CFC12_ppt * 1.0E-12 * RMCFC12 / RMD

    !
    !               
    co2_ppm_per = co2_ppm
    CALL getin_p('co2_ppm_per', co2_ppm_per)
    !conversion en rapport de mélange massique
    RCO2_per = co2_ppm_per * 1.0e-06 * RMCO2 / RMD

    !               
    CH4_ppb_per = CH4_ppb
    CALL getin_p('CH4_ppb_per', CH4_ppb_per)
    !conversion en rapport de mélange massique
    RCH4_per = CH4_ppb_per * 1.0E-09 * RMCH4 / RMD
    !
    !               
    N2O_ppb_per = N2O_ppb
    CALL getin_p('N2O_ppb_per', N2O_ppb_per)
    !conversion en rapport de mélange massique
    RN2O_per = N2O_ppb_per * 1.0E-09 * RMN2O / RMD
    !
    !               
    CFC11_ppt_per = CFC11_ppt
    CALL getin_p('CFC11_ppt_per',CFC11_ppt_per)
    !conversion en rapport de mélange massique
    RCFC11_per=CFC11_ppt_per* 1.0E-12 * RMCFC11 / RMD
    !
    !               
    CFC12_ppt_per = CFC12_ppt
    CALL getin_p('CFC12_ppt_per',CFC12_ppt_per)
    !conversion en rapport de mélange massique
    RCFC12_per = CFC12_ppt_per * 1.0E-12 * RMCFC12 / RMD

    !
    ! FH 2008/05/09 On elimine toutes les clefs physiques dans la dynamique
    ! Constantes precedemment dans dyn3d/conf_gcm

    iflag_cycle_diurne = 1
    CALL getin_p('iflag_cycle_diurne',iflag_cycle_diurne)

    soil_model = .TRUE.
    CALL getin_p('soil_model',soil_model)

    liqice_in_radocond = .TRUE.
    ! old name of the flag (new_oliq)
    CALL getin_p('new_oliq',liqice_in_radocond)
    CALL getin_p('liqice_in_radocond',liqice_in_radocond)

    !GG
    iflag_seaice = 0
    CALL getin_p('iflag_seaice',iflag_seaice)

    iflag_seaice_alb = 0
    CALL getin_p('iflag_seaice_alb',iflag_seaice_alb)

    sic_hice_fixed = 1.0
    CALL getin_p('sic_hice_fixed',sic_hice_fixed)


    iflag_leads = 0
    CALL getin_p('iflag_leads',iflag_leads)

    sice_cond = 2.17
    CALL getin_p('sice_cond', sice_cond)

    sisno_cond = 0.31
    CALL getin_p('sno_cond', sisno_cond)

    sisno_den = 300
    CALL getin_p('sisno_den', sisno_den)

    sisno_min = 0.05
    CALL getin_p('sisno_min', sisno_min)

    sithick_min = 0.10
    CALL getin_p('sithick_min', sithick_min)

    sisno_wfact = 0.4
    CALL getin_p('sisno_wfact', sisno_wfact)

    amax_n = 0.997
    CALL getin_p('amax_n', amax_n)

    !amax_s = 0.95
    ! by default, set amax_s (south) = amax_n (north) for consistency in LAM simulations
    amax_s = amax_n
    CALL getin_p('amax_s', amax_s)

    rn_alb_sdry = 0.85
    CALL getin_p('rn_alb_sdry', rn_alb_sdry)

    rn_alb_smlt = 0.55
    CALL getin_p('rn_alb_smlt', rn_alb_smlt)

    rn_alb_idry = 0.75
    CALL getin_p('rn_alb_idry', rn_alb_idry)

    rn_alb_imlt = 0.66
    CALL getin_p('rn_alb_imlt', rn_alb_imlt)

    si_pen_frac = 0.3
    CALL getin_p('si_pen_frac', si_pen_frac)

    si_pen_ext =1.5 
    CALL getin_p('si_pen_ext', si_pen_ext)

    fseaN =2.0
    CALL getin_p('fseaN', fseaN)

    fseaS =4.0
    CALL getin_p('fseaS', fseaS)




    ok_limitvrai = .FALSE.
    CALL getin_p('ok_limitvrai',ok_limitvrai)

    nbapp_rad = 12
    CALL getin_p('nbapp_rad',nbapp_rad)

    !rajout Olivier Torres
    choix_bulk = 0
    CALL getin_p('choix_bulk',choix_bulk)

    nit_bulk = 1
    CALL getin_p('nit_bulk',nit_bulk)

    kz0 = 0
    CALL getin_p('kz0',kz0)


    iflag_con = 2
    CALL getin_p('iflag_con',iflag_con)

    nbapp_cv = 0
    CALL getin_p('nbapp_cv',nbapp_cv)

    nbapp_wk = 0
    CALL getin_p('nbapp_wk',nbapp_wk)

    iflag_ener_conserv = -1
    CALL getin_p('iflag_ener_conserv',iflag_ener_conserv)

    ok_conserv_q = .FALSE.
    CALL getin_p('ok_conserv_q',ok_conserv_q)



    ok_mass_dtcon = .TRUE.
    CALL getin_p('ok_mass_dtcon',ok_mass_dtcon)

    ok_mass_dqcon = .TRUE.
    CALL getin_p('ok_mass_dqcon',ok_mass_dqcon)

    ok_mass_duvcon = .TRUE.
    CALL getin_p('ok_mass_duvcon',ok_mass_duvcon)


    !
    !
    !
    ! Constante solaire & Parametres orbitaux & taux gaz effet de serre END
    !
    ! KE
    !
    cvl_corr = 1.00
    CALL getin_p('cvl_corr', cvl_corr)


    !
    !
    iflag_radia = 1
    CALL getin_p('iflag_radia',iflag_radia)

    !
    !
    iflag_rrtm = 0
    CALL getin_p('iflag_rrtm',iflag_rrtm)

    !
    !
    NSW = 2
    CALL getin_p('NSW',NSW)
    !albedo SB >>>
    iflag_albedo = 0
    CALL getin_p('iflag_albedo',iflag_albedo)

    ok_chlorophyll=.FALSE.
    CALL getin_p('ok_chlorophyll',ok_chlorophyll)
    !albedo SB <<<
    !
    !
    !
    !valeur AMIP II
    ok_suntime_rrtm = .FALSE.
    IF (iflag_rrtm==1) THEN
       CALL getin_p('ok_suntime_rrtm',ok_suntime_rrtm)
    ENDIF

    ! - 0 = no stratospheric aerosols 
    ! - 1 = stratospheric aerosols scaled from 550 nm AOD 
    ! - 2 = stratospheric aerosol properties from CMIP6
    !Option 2 is only available with RRTM, this is tested later on 
    !
    flag_aerosol_strat = 0
    CALL getin_p('flag_aerosol_strat',flag_aerosol_strat)

    ! - F = no aerosol radiative feedback
    ! - T = aerosol radiative feedback
    !
    flag_aer_feedback = .TRUE. 
    IF (iflag_rrtm==1) THEN
       CALL getin_p('flag_aer_feedback',flag_aer_feedback)
    ENDIF

    !
    iflag_cld_th = 1
    ! On lit deux fois avec l'ancien et le nouveau nom 
    ! pour assurer une retrocompatiblite.
    ! A abandonner un jour
    CALL getin_p('iflag_cldcon',iflag_cld_th)
    CALL getin_p('iflag_cld_th',iflag_cld_th)
    !
    fact_cldcon = 0.375
    CALL getin_p('fact_cldcon',fact_cldcon)

    !
    !
    facttemps = 1.e-4
    CALL getin_p('facttemps',facttemps)

    !
    !-----------------------------------------------------------------------
    ! Longitude solaire pour le calcul de l'ensoleillement en degre
    ! si on veut imposer la saison. Sinon, solarlong0=-999.999
    !
    solarlong0 = -999.999
    CALL getin_p('solarlong0',solarlong0)
    !
    !-----------------------------------------------------------------------
    !  Valeur imposee pour configuration idealisees
    ! Default value -1 to activate the full computation
    qsol0 = -1.
    CALL getin_p('qsol0',qsol0)
    evap0 = -1.
    CALL getin_p('evap0',evap0)
    albsno0 = -1.
    CALL getin_p('albsno0',albsno0)
    !
    !-----------------------------------------------------------------------
    !
    !
    iflag_sic = 0
    CALL getin_p('iflag_sic',iflag_sic)
    !
    !
    iflag_inertie = 0
    CALL getin_p('iflag_inertie',iflag_inertie)
    !
    !
    inertie_sic = 2000.
    CALL getin_p('inertie_sic',inertie_sic)
    !
    !
    inertie_lic = 2000.
    CALL getin_p('inertie_lic',inertie_lic)
    !
    !
    inertie_sno = 2000.
    CALL getin_p('inertie_sno',inertie_sno)
    !
    !
    inertie_sol = 2000.
    CALL getin_p('inertie_sol',inertie_sol)


    !
    iflag_ice_thermo = 0
    CALL getin_p('iflag_ice_thermo',iflag_ice_thermo)

    !
    !
    ok_ice_supersat = .FALSE.
    CALL getin_p('ok_ice_supersat',ok_ice_supersat)

    !
    ok_plane_h2o = .FALSE.
    CALL getin_p('ok_plane_h2o',ok_plane_h2o)

    !
    ok_plane_contrail = .FALSE.
    CALL getin_p('ok_plane_contrail',ok_plane_contrail)

    !
    !
    top_height = 3
    CALL getin_p('top_height',top_height)

    !
    !
    overlap = 3
    CALL getin_p('overlap',overlap)

    !
    !
    cdmmax = 1.3E-3
    CALL getin_p('cdmmax',cdmmax)

    !
    !
    cdhmax = 1.1E-3
    CALL getin_p('cdhmax',cdhmax)

    !261103
    !
    !
    ksta = 1.0e-10
    CALL getin_p('ksta',ksta)

    !
    !
    ksta_ter = 1.0e-10
    CALL getin_p('ksta_ter',ksta_ter)

    !
    f_ri_cd_min = 0.1
    CALL getin_p('f_ri_cd_min',f_ri_cd_min)

    !
    !
    ok_kzmin = .TRUE.
    CALL getin_p('ok_kzmin',ok_kzmin)

    !
    !
    fmagic = 1.
    CALL getin_p('fmagic',fmagic)

    !
    !
    pmagic = 0.
    CALL getin_p('pmagic',pmagic)


    ok_lic_melt = .FALSE.
    CALL getin_p('ok_lic_melt', ok_lic_melt)



    forc_ts_melt = .FALSE.
    CALL getin_p('forc_ts_melt', forc_ts_melt)


    ok_lic_cond = .FALSE.
    CALL getin_p('ok_lic_cond', ok_lic_cond)

    !
    ! PARAMETER FOR THE PLANETARY BOUNDARY LAYER
    !

    !
    iflag_pbl = 1
    CALL getin_p('iflag_pbl',iflag_pbl)

    iflag_physiq = 0 ! 0: std, 1: with physiqex output, 2: for physiqex
    CALL getin_p('iflag_physiq',iflag_physiq)

    !FC
    !
    ifl_pbltree = 0
    CALL getin_p('ifl_pbltree',ifl_pbltree)
    !FC
    !
    Cd_frein = 7.5E-02
    CALL getin_p('Cd_frein',Cd_frein)
    !AM
    !
    iflag_hetero_surf = 0
    CALL getin_p('iflag_hetero_surf',iflag_hetero_surf)
    !
    !
    iflag_pbl_split = 0
    call getin_p('iflag_pbl_split',iflag_pbl_split)
    !
    !
    iflag_order2_sollw = 0
    CALL getin_p('iflag_order2_sollw',iflag_order2_sollw)
    !
    !
    iflag_thermals = 0
    CALL getin_p('iflag_thermals',iflag_thermals)
    !
    !
    nsplit_thermals = 1
    CALL getin_p('nsplit_thermals',nsplit_thermals)
    !
    alp_bl_k = 1.
    CALL getin_p('alp_bl_k',alp_bl_k)

    ! nrlmd le 10/04/2012

    !
    iflag_trig_bl = 0
    CALL getin_p('iflag_trig_bl',iflag_trig_bl)

    !
    iflag_strig = 0
    CALL getin_p('iflag_strig',iflag_strig)

    !
    s_trig = 2e7
    CALL getin_p('s_trig',s_trig)

    !
    h_trig = 6000.
    CALL getin_p('h_trig',h_trig)

    !
    tau_trig_shallow = 600
    CALL getin_p('tau_trig_shallow',tau_trig_shallow)

    !
    tau_trig_deep = 1800
    CALL getin_p('tau_trig_deep',tau_trig_deep)

    !
    iflag_clos_bl = 0
    CALL getin_p('iflag_clos_bl',iflag_clos_bl)

    ! fin nrlmd le 10/04/2012

    !
    !
    tau_thermals = 0.
    CALL getin_p('tau_thermals',tau_thermals)

    !
    !
    iflag_coupl = 0
    CALL getin_p('iflag_coupl',iflag_coupl)

    !
    !
    iflag_clos = 1
    CALL getin_p('iflag_clos',iflag_clos)
    !
    !
    !
    iflag_wake = 0
    CALL getin_p('iflag_wake',iflag_wake)

    !
    alp_offset = 0.
    CALL getin_p('alp_offset',alp_offset)

    !
    !
    lev_histhf = 1
    CALL getin_p('lev_histhf',lev_histhf)

    !
    !
    lev_histday = 1
    CALL getin_p('lev_histday',lev_histday)

    !
    !
    lev_histmth = 2
    CALL getin_p('lev_histmth',lev_histmth)
    !
    !
    lev_histins = 1
    CALL getin_p('lev_histins',lev_histins)
    !
    !
    lev_histLES = 1
    CALL getin_p('lev_histLES',lev_histLES)
    ! 
    !
    type_run = 'AMIP'
    CALL getin_p('type_run',type_run)

    !
    !
    ok_cosp = .FALSE.
    CALL getin_p('ok_cosp',ok_cosp)

    !
    !
    ok_airs = .FALSE.
    CALL getin_p('ok_airs',ok_airs)

    !
    !
    ok_mensuelCOSP = .TRUE.
    CALL getin_p('ok_mensuelCOSP',ok_mensuelCOSP)

    !
    !
    ok_journeCOSP = .TRUE.
    CALL getin_p('ok_journeCOSP',ok_journeCOSP)

    !
    !
    ok_hfCOSP = .FALSE.
    CALL getin_p('ok_hfCOSP',ok_hfCOSP)

    !
    ! coordonnees (lonmin_ins, lonmax_ins, latmin_ins, latmax_ins) pour la zone 
    ! avec sorties instantannees tous les pas de temps de la physique => "histbilKP_ins.nc"
    !
    !
    lonmin_ins = 100.
    CALL getin_p('lonmin_ins',lonmin_ins)
    !
    !
    lonmax_ins = 130.
    CALL getin_p('lonmax_ins',lonmax_ins)
    !
    !
    latmin_ins = -20.
    CALL getin_p('latmin_ins',latmin_ins)
    !
    !
    latmax_ins = 20.
    CALL getin_p('latmax_ins',latmax_ins)
    !
    !
    ecrit_hf = 1./8.
    CALL getin_p('ecrit_hf',ecrit_hf)
    !
    !
    ecrit_ins = 1./48.
    CALL getin_p('ecrit_ins',ecrit_ins)
    !
    !
    ecrit_day = 1.0
    CALL getin_p('ecrit_day',ecrit_day)
    !
    !
    ecrit_mth = 30.
    CALL getin_p('ecrit_mth',ecrit_mth)
    !
    !
    ecrit_tra = 0.
    CALL getin_p('ecrit_tra',ecrit_tra)
    !
    !
    ecrit_reg = 0.25   !4 fois par jour
    CALL getin_p('ecrit_reg',ecrit_reg)
    !
    !
    print*,'CONFPHYS OOK avant drag_ter'
    !
    ! PARAMETRES CDRAG
    !
    f_cdrag_ter = 0.8
    CALL getin_p('f_cdrag_ter',f_cdrag_ter)
    !
    f_cdrag_oce = 0.8
    CALL getin_p('f_cdrag_oce',f_cdrag_oce)
    !

    ! Gustiness flags
    f_z0qh_oce = 1.
    CALL getin_p('f_z0qh_oce',f_z0qh_oce)
    !
    f_qsat_oce = 1.
    CALL getin_p('f_qsat_oce',f_qsat_oce)
    !
    f_gust_bl = 0.
    CALL getin_p('f_gust_bl',f_gust_bl)
    !
    f_gust_wk = 0.
    CALL getin_p('f_gust_wk',f_gust_wk)
    !
    !
    iflag_z0_oce=0
    CALL getin_p('iflag_z0_oce',iflag_z0_oce)

    iflag_z0_ter=0
    CALL getin_p('iflag_z0_ter',iflag_z0_ter)

    !
    iflag_gusts=0
    CALL getin_p('iflag_gusts',iflag_gusts)
    !
    min_wind_speed = 1.
    CALL getin_p('min_wind_speed',min_wind_speed)

    f_rugoro = 0.
    CALL getin_p('f_rugoro',f_rugoro)

    z0min = 0.000015
    CALL getin_p('z0min',z0min)



    z0m_seaice = 0.002
    CALL getin_p('z0m_seaice',z0m_seaice)
    ratio_z0hz0m_seaice =  1.
    CALL getin_p('ratio_z0hz0m_seaice',ratio_z0hz0m_seaice)
    z0h_seaice = z0m_seaice * ratio_z0hz0m_seaice
    CALL getin_p('z0h_seaice',z0h_seaice)

    z0m_landice = 0.001
    CALL getin_p('z0m_landice',z0m_landice)
    ratio_z0hz0m_landice =  1.
    CALL getin_p('ratio_z0hz0m_landice',ratio_z0hz0m_landice)
    z0h_landice = z0m_landice * ratio_z0hz0m_landice
    CALL getin_p('z0h_landice',z0h_landice)

    z0m_ocean = z0min
    CALL getin_p('z0m_ocean',z0m_ocean)
    ratio_z0hz0m_ocean =  1.
    CALL getin_p('ratio_z0hz0m_ocean',ratio_z0hz0m_ocean)
    z0h_ocean = z0m_ocean * ratio_z0hz0m_ocean
    CALL getin_p('z0h_ocean',z0h_ocean)

    z0m_land = z0min
    CALL getin_p('z0m_land',z0m_land)
    ratio_z0hz0m_land =  1.
    CALL getin_p('ratio_z0hz0m_land',ratio_z0hz0m_land)
    z0h_land = z0m_land * ratio_z0hz0m_land
    CALL getin_p('z0h_land',z0h_land)


    ! PARAMETERS FOR SNOW AND ICE MELTING
    chasno_tun=0.15
    CALL getin_p('chasno_tun',chasno_tun)
    !
    !
    !

    !               Et la sponge layer (Runs Stratospheriques)

    ok_strato=.FALSE.
    CALL getin_p('ok_strato',ok_strato)


    !               de l'humidite due a oxydation+photolyse du methane strato

    ok_qch4=.FALSE.
    CALL getin_p('ok_qch4',ok_qch4)

    !              LES                                                  
    !                                                                   
    ok_LES = .FALSE.                                              
    CALL getin_p('OK_LES', ok_LES)                                  

    !              par defaut 1., i.e. 1 jour
    !
    adjust_tropopause = .FALSE.
    CALL getin_p('adjust_tropopause', adjust_tropopause)
    !
    !              tropopause so that it matches the one of LMDZ.
    !
    !
    ok_daily_climoz = .FALSE.
    CALL getin_p('ok_daily_climoz', ok_daily_climoz)
    !
    !              .TRUE. if backward compatibility is needed.
    !  and lighter monthly climoz files, inetrpolated in time at gcm run time.

    ok_new_lscp = .FALSE.
    CALL getin_p('ok_new_lscp', ok_new_lscp)
    !


    ok_advtke = .FALSE.
    CALL getin_p('ok_advtke', ok_advtke)
    !

    ok_bs = .FALSE.
    CALL getin_p('ok_bs', ok_bs)
    !


    ok_rad_bs = .FALSE.
    CALL getin_p('ok_rad_bs', ok_rad_bs)
    !

    ecrit_LES = 1./8.
    CALL getin_p('ecrit_LES', ecrit_LES)
    !
    CALL getin_p('read_climoz', read_climoz)

    carbon_cycle_tr=.FALSE.
    CALL getin_p('carbon_cycle_tr',carbon_cycle_tr)

    carbon_cycle_cpl=.FALSE.
    CALL getin_p('carbon_cycle_cpl',carbon_cycle_cpl)

    carbon_cycle_rad=.FALSE.
    CALL getin_p('carbon_cycle_rad',carbon_cycle_rad)

    !Patricia
    read_daily_co2ff = .FALSE.
    CALL getin_p('read_daily_co2ff', read_daily_co2ff)

    var_fco2_ocean_cor=0. ! default value
    CALL getin_p('var_fco2_ocean_cor',var_fco2_ocean_cor)

    read_fco2_land_cor=.FALSE.
    CALL getin_p('read_fco2_land_cor',read_fco2_land_cor)

    var_fco2_land_cor=0. ! default value
    CALL getin_p('var_fco2_land_cor',var_fco2_land_cor)

    read_fco2_ocean_cor_2d=.FALSE.
    CALL getin_p('read_fco2_ocean_cor_2d',read_fco2_ocean_cor_2d)

    read_fco2_land_cor_2d=.FALSE.
    CALL getin_p('read_fco2_land_cor_2d',read_fco2_land_cor_2d)

    ! level_coupling_esm : level of coupling of the biogeochemical fields between LMDZ, ORCHIDEE and NEMO
    ! Definitions of level_coupling_esm in physiq.def
    ! level_coupling_esm = 0  ! No field exchange between LMDZ and ORCHIDEE models
    !                         ! No field exchange between LMDZ and NEMO
    ! level_coupling_esm = 1  ! Field exchange between LMDZ and ORCHIDEE models
    !                         ! No field exchange between LMDZ and NEMO models
    ! level_coupling_esm = 2  ! No field exchange between LMDZ and ORCHIDEE models
    !                         ! Field exchange between LMDZ and NEMO models
    ! level_coupling_esm = 3  ! Field exchange between LMDZ and ORCHIDEE models
    !                         ! Field exchange between LMDZ and NEMO models
    level_coupling_esm=0 ! default value
    CALL getin_p('level_coupling_esm',level_coupling_esm)

    ! Patricia
    carbon_cycle_conc_driven=.FALSE.
    CALL getin_p('carbon_cycle_conc_driven', carbon_cycle_conc_driven)

    ! Check: If concentration-driven, ensure co2_ppm is valid
    IF (carbon_cycle_conc_driven) THEN
       IF (co2_ppm <= 0.0) THEN
          co2_ppm = co2_ppm0
          WRITE(lunout,*) 'conf_phys: WARNING: co2_ppm was <= 0 in concentration-driven mode'
          WRITE(lunout,*) '           Resetting to initial value co2_ppm0 = ', co2_ppm
       END IF
       WRITE(lunout,*) 'conf_phys: Carbon Cycle is CONCENTRATION-DRIVEN'
       WRITE(lunout,*) '           Atmosphere forced by co2_ppm'
    ELSE
       WRITE(lunout,*) 'conf_phys: Carbon Cycle is EMISSION-DRIVEN (Interactive)'
    END IF


    dms_cycle_cpl=.FALSE.
    CALL getin_p('transm_dms_oa',dms_cycle_cpl)

    !

    n2o_cycle_cpl=.FALSE.
    CALL getin_p('transm_n2o_oa',n2o_cycle_cpl)
    !

    ndp_cycle_cpl=.FALSE.
    CALL getin_p('transm_ndp_ao',ndp_cycle_cpl)
    !


    nh3_cycle_cpl=.FALSE.
    CALL getin_p('transm_nh3_oa',nh3_cycle_cpl)
    !

    !$OMP BARRIER

    RCO2_act = RCO2
    RCH4_act = RCH4
    RN2O_act = RN2O
    RCFC11_act = RCFC11
    RCFC12_act = RCFC12
    ! PC



    !FC
    !AM



    ok_veget=.TRUE.
    IF (type_veget=='n' .or. type_veget=='bucket' .or. type_veget=='betaclim') THEN
       ok_veget=.FALSE.
    ENDIF
    ! INLANDSIS
    !=================================================
    !=================================================
    ! nrlmd le 10/04/2012
    ! fin nrlmd le 10/04/2012





    !rajout Olivier Torres

    ! Test of coherence between type_ocean and version_ocean
    IF (type_ocean=='couple' .AND. (version_ocean/='opa8' .AND. version_ocean/='nemo') ) THEN
       WRITE(lunout,*)' ERROR version_ocean=',version_ocean,' not valid in coupled configuration'
       CALL abort_physic('conf_phys','version_ocean not valid',1)
    ENDIF

    IF (type_ocean=='slab' .AND. version_ocean=='xxxxxx') THEN
       version_ocean='sicOBS'
    ELSE IF (type_ocean=='slab' .AND. version_ocean/='sicOBS' &
         .AND. version_ocean/='sicINT' .AND. version_ocean/='sicNO') THEN
       WRITE(lunout,*)' ERROR version_ocean=',version_ocean,' not valid with slab ocean'
       CALL abort_physic('conf_phys','version_ocean not valid',1)
    ENDIF

    !--test on radiative scheme 
    IF (iflag_rrtm .EQ. 0) THEN 
       IF (NSW.NE.2) THEN
          WRITE(lunout,*) 'conf_phys :  ERROR iflag_rrtm=0 and NSW<>2 not possible'
          CALL abort_physic('conf_phys','choice NSW not valid',1)
       ENDIF
    ELSE IF (iflag_rrtm .EQ. 1) THEN
       IF (NSW.NE.2.AND.NSW.NE.4.AND.NSW.NE.6) THEN
          WRITE(lunout,*) 'conf_phys :  ERROR iflag_rrtm=1 and NSW<>2,4,6 not possible'
          CALL abort_physic('conf_phys','choice NSW not valid',1)
       ENDIF
    ELSE IF (iflag_rrtm .EQ. 2) THEN
       IF (NSW.NE.2.AND.NSW.NE.4.AND.NSW.NE.6) THEN
          WRITE(lunout,*) 'conf_phys :  ERROR iflag_rrtm=1 and NSW<>2,4,6 not possible'
          CALL abort_physic('conf_phys','choice NSW not valid',1)
       ENDIF
    ELSE 
       WRITE(lunout,*) 'conf_phys :  ERROR iflag_rrtm<>0,1'
       CALL abort_physic('conf_phys','choice iflag_rrtm not valid',1)
    ENDIF
    !--here we test that solaire has not been changed if ok_suntime_rrtm is activated
    !       WRITE(lunout,*) 'conf_phys :  ERROR ok_suntime_rrtm=y and solaire is provided in def file'
    !       CALL abort_physic('conf_phys','ok_suntime_rrtm=y and solaire is provided',1)
    !    ENDIF
    IF (CPPKEY_STRATAER) THEN
       IF (iflag_rrtm .NE. 1) THEN
          WRITE(lunout,*) 'conf_phys :  ERROR iflag_rrtm<>1 but StratAer activated'
          CALL abort_physic('conf_phys','iflag_rrtm not valid for StratAer',1)
       ENDIF
       IF (NSW .NE. 6) THEN
          WRITE(lunout,*) 'conf_phys :  ERROR NSW<>6 but StratAer activated'
          CALL abort_physic('conf_phys','NSW not valid for StratAer',1)
       ENDIF
    END IF

    !--test on ocean surface albedo
    IF (iflag_albedo.LT.0.OR.iflag_albedo.GT.2) THEN
       WRITE(lunout,*) 'conf_phys :  ERROR iflag_albedo<>0,1'
       CALL abort_physic('conf_phys','choice iflag_albedo not valid',1)
    ENDIF

    ! Flag_aerosol cannot be set to zero if aerosol direct effect (ade) or aerosol indirect effect (aie) are activated
    IF (ok_ade .OR. ok_aie) THEN 
       IF ( flag_aerosol .EQ. 0 ) THEN
          CALL abort_physic('conf_phys','flag_aerosol=0 not compatible avec ok_ade ou ok_aie=.TRUE.',1)
       ENDIF
    ENDIF

    ! Flag_aerosol cannot be set to zero if we are in coupled mode for aerosol
    IF (aerosol_couple .AND. flag_aerosol .EQ. 0 ) THEN
       CALL abort_physic('conf_phys', 'flag_aerosol cannot be to zero if aerosol_couple=y ', 1)
    ENDIF

    ! Read_climoz needs to be set zero if we are in couple mode for chemistry 
    IF (chemistry_couple .AND. read_climoz .ne. 0) THEN 
       CALL abort_physic('conf_phys', 'read_climoz need to be to zero if chemistry_couple=y ', 1) 
    ENDIF

    ! flag_aerosol need to be different to zero if ok_cdnc is activated
    !IF (ok_cdnc .AND. flag_aerosol .EQ. 0) THEN
    !   CALL abort_physic('conf_phys', 'flag_aerosol cannot be to zero if ok_cdnc is activated ', 1)
    !ENDIF

    ! ok_cdnc must be set to y if ok_aie is activated
    IF (ok_aie .AND. .NOT. ok_cdnc) THEN
       CALL abort_physic('conf_phys', 'ok_cdnc must be set to y if ok_aie is activated',1)
    ENDIF

    ! flag_aerosol=7 => MACv2SP climatology 
    IF (flag_aerosol.EQ.7.AND. iflag_rrtm.NE.1) THEN
       CALL abort_physic('conf_phys', 'flag_aerosol=7 (MACv2SP) can only be activated with RRTM',1)
    ENDIF
    IF (flag_aerosol.EQ.7.AND. NSW.NE.6) THEN
       CALL abort_physic('conf_phys', 'flag_aerosol=7 (MACv2SP) can only be activated with NSW=6',1)
    ENDIF

    ! BC internal mixture is only possible with RRTM & NSW=6 & flag_aerosol=6 or aerosol_couple
    IF (flag_bc_internal_mixture .AND. NSW.NE.6) THEN 
       CALL abort_physic('conf_phys', 'flag_bc_internal_mixture can only be activated with NSW=6',1)
    ENDIF
    IF (flag_bc_internal_mixture .AND. iflag_rrtm.NE.1) THEN 
       CALL abort_physic('conf_phys', 'flag_bc_internal_mixture can only be activated with RRTM',1)
    ENDIF
    IF (flag_bc_internal_mixture .AND. flag_aerosol.NE.6) THEN 
       CALL abort_physic('conf_phys', 'flag_bc_internal_mixture can only be activated with flag_aerosol=6',1)
    ENDIF

    ! test sur flag_volc_surfstrat
    IF (flag_volc_surfstrat.LT.0.OR.flag_volc_surfstrat.GT.2) THEN
       CALL abort_physic('conf_phys', 'flag_volc_surfstrat can only be 0 1 or 2',1)
    ENDIF
    IF ((.NOT.ok_volcan.OR..NOT.ok_ade.OR..NOT.ok_aie).AND.flag_volc_surfstrat.GT.0) THEN
       CALL abort_physic('conf_phys', 'ok_ade, ok_aie, ok_volcan need to be activated if flag_volc_surfstrat is 1 or 2',1)
    ENDIF

    ! Test on carbon cycle
    IF (carbon_cycle_tr .AND. .NOT. carbon_cycle_cpl) THEN
       CALL abort_physic('conf_phys', 'carbon_cycle_cpl has to be TRUE if carbon_cycle_tr is on',1)
    ENDIF
    IF (carbon_cycle_rad .AND. .NOT. carbon_cycle_cpl) THEN
       CALL abort_physic('conf_phys', 'carbon_cycle_cpl has to be TRUE if carbon_cycle_rad is on',1)
    ENDIF

    ! << PC
    ! Consistency checks for CO2 driving philosophy
    ! If CO2 is concentration-driven for the surface components, the radiation
    ! should not use the drifting tracer CO2 (avoid inconsistent forcing)
    IF (carbon_cycle_conc_driven .AND. carbon_cycle_rad) THEN
       !CALL abort_physic('conf_phys', &
       !     'carbon_cycle_rad must be FALSE when carbon_cycle_conc_driven is TRUE', 1)
       WRITE(lunout,*) 'CO2 concentration-driven: radiation uses prescribed co2_ppm: atmospheric tracer is diagnostic only.'
    ENDIF
    ! >> PC

    ! Test on chemistry cycle 
    IF ((type_trac .ne. "inca" .AND. type_trac .ne. "inco") .AND. ( dms_cycle_cpl .OR. n2o_cycle_cpl .OR. ndp_cycle_cpl .OR. nh3_cycle_cpl )  ) THEN 
       CALL abort_physic('conf_phys', 'transm_dms_oa, transm_n2o_oa, transm_ndp_ao or transm_nh3_oa can be TRUE only with INCA coupling model',1)
    ENDIF

    ! ORCHIDEE must be activated for ifl_pbltree=1
    IF (.NOT. ok_veget .AND. ifl_pbltree==1) THEN
       WRITE(lunout,*)'Warning: ORCHIDEE must be activated for ifl_pbltree=1'
       WRITE(lunout,*)'ifl_pbltree is now changed to zero'
       ifl_pbltree=0
    ENDIF


    WRITE(lunout,*) 'conf_phys :  ##############################################'
    WRITE(lunout,*) 'conf_phys :  Configuration des parametres de la physique: '
    WRITE(lunout,*) 'conf_phys :  Type ocean = ', type_ocean
    WRITE(lunout,*) 'conf_phys :  Version ocean = ', version_ocean
    WRITE(lunout,*) 'conf_phys :  Config veget = ', ok_veget,type_veget
    WRITE(lunout,*) 'conf_phys :  Snow model landice : landice_opt = ', landice_opt
    WRITE(lunout,*) 'conf_phys :  Config xml pour XIOS : ok_all_xml = ', ok_all_xml
    WRITE(lunout,*) 'conf_phys :  Sortie journaliere = ', ok_journe
    WRITE(lunout,*) 'conf_phys :  Sortie haute frequence = ', ok_hf
    WRITE(lunout,*) 'conf_phys :  Sortie mensuelle = ', ok_mensuel
    WRITE(lunout,*) 'conf_phys :  Sortie instantanee = ', ok_instan
    WRITE(lunout,*) 'conf_phys :  Frequence appel simulateur ISCCP, freq_ISCCP =', freq_ISCCP
    WRITE(lunout,*) 'conf_phys :  Frequence appel simulateur ISCCP, ecrit_ISCCP =', ecrit_ISCCP
    WRITE(lunout,*) 'conf_phys :  Frequence appel simulateur COSP, freq_COSP =', freq_COSP
    WRITE(lunout,*) 'conf_phys :  Frequence appel simulateur AIRS, freq_AIRS =', freq_AIRS
    WRITE(lunout,*) 'conf_phys :  Sortie bilan d''energie, ip_ebil_phy =', ip_ebil_phy
    WRITE(lunout,*) 'conf_phys :  Excentricite = ',R_ecc
    WRITE(lunout,*) 'conf_phys :  Equinoxe = ',R_peri
    WRITE(lunout,*) 'conf_phys :  Inclinaison =',R_incl
    WRITE(lunout,*) 'conf_phys :  Constante solaire =',solaire
    WRITE(lunout,*) 'conf_phys :  ok_suntime_rrtm =',ok_suntime_rrtm
    WRITE(lunout,*) 'conf_phys :  co2_ppm =',co2_ppm
    WRITE(lunout,*) 'conf_phys :  co2_ppm0 =',co2_ppm0
    WRITE(lunout,*) 'conf_phys :  RCO2_act = ',RCO2_act
    WRITE(lunout,*) 'conf_phys :  CH4_ppb =',CH4_ppb,' RCH4_act = ',RCH4_act
    WRITE(lunout,*) 'conf_phys :  N2O_ppb =',N2O_ppb,' RN2O_act=  ',RN2O_act
    WRITE(lunout,*) 'conf_phys :  ok_CH4_eff_ppb =',ok_CH4_eff_ppb, 'ok_N2O_eff_ppb= ',ok_N2O_eff_ppb
    WRITE(lunout,*) 'conf_phys :  CFC11_ppt=',CFC11_ppt,' RCFC11_act=  ',RCFC11_act
    WRITE(lunout,*) 'conf_phys :  CFC12_ppt=',CFC12_ppt,' RCFC12_act=  ',RCFC12_act
    WRITE(lunout,*) 'conf_phys :  RCO2_per = ',RCO2_per,' RCH4_per = ', RCH4_per
    WRITE(lunout,*) 'conf_phys :  RN2O_per = ',RN2O_per,' RCFC11_per = ', RCFC11_per
    WRITE(lunout,*) 'conf_phys :  RCFC12_per = ',RCFC12_per
    WRITE(lunout,*) 'conf_phys :  cvl_corr=', cvl_corr
    WRITE(lunout,*) 'conf_phys :  ok_lic_melt=', ok_lic_melt
    WRITE(lunout,*) 'conf_phys :  ok_lic_cond=', ok_lic_cond
    WRITE(lunout,*) 'conf_phys :  forc_ts_melt=', forc_ts_melt
    WRITE(lunout,*) 'conf_phys :  iflag_cycle_diurne=',iflag_cycle_diurne
    WRITE(lunout,*) 'conf_phys :  soil_model=',soil_model
    WRITE(lunout,*) 'conf_phys :  liqice_in_radocond=',liqice_in_radocond
    WRITE(lunout,*) 'conf_phys :  ok_limitvrai=',ok_limitvrai
    WRITE(lunout,*) 'conf_phys :  nbapp_rad=',nbapp_rad
    WRITE(lunout,*) 'conf_phys :  iflag_con=',iflag_con
    WRITE(lunout,*) 'conf_phys :  nbapp_cv=',nbapp_cv
    WRITE(lunout,*) 'conf_phys :  nbapp_wk=',nbapp_wk
    WRITE(lunout,*) 'conf_phys :  iflag_ener_conserv=',iflag_ener_conserv
    WRITE(lunout,*) 'conf_phys :  ok_conserv_q=',ok_conserv_q
    WRITE(lunout,*) 'conf_phys :  ok_mass_dtcon=',ok_mass_dtcon
    WRITE(lunout,*) 'conf_phys :  ok_mass_dqcon=',ok_mass_dqcon
    WRITE(lunout,*) 'conf_phys :  ok_mass_duvcon=',ok_mass_duvcon
    WRITE(lunout,*) 'conf_phys :  iflag_cld_th = ', iflag_cld_th
    WRITE(lunout,*) 'conf_phys :  iflag_radia = ', iflag_radia
    WRITE(lunout,*) 'conf_phys :  iflag_rrtm = ', iflag_rrtm
    WRITE(lunout,*) 'conf_phys :  NSW = ', NSW
    WRITE(lunout,*) 'conf_phys :  iflag_albedo = ', iflag_albedo !albedo SB
    WRITE(lunout,*) 'conf_phys :  ok_chlorophyll =',ok_chlorophyll ! albedo SB
    WRITE(lunout,*) 'conf_phys :  fact_cldcon = ', fact_cldcon
    WRITE(lunout,*) 'conf_phys :  facttemps = ', facttemps
    WRITE(lunout,*) 'conf_phys :  top_height = ',top_height 
    WRITE(lunout,*) 'conf_phys :  iflag_ice_thermo = ',iflag_ice_thermo
    WRITE(lunout,*) 'conf_phys :  ok_ice_supersat = ',ok_ice_supersat
    WRITE(lunout,*) 'conf_phys :  ok_plane_h2o = ',ok_plane_h2o
    WRITE(lunout,*) 'conf_phys :  ok_plane_contrail = ',ok_plane_contrail
    WRITE(lunout,*) 'conf_phys :  overlap = ',overlap 
    WRITE(lunout,*) 'conf_phys :  cdmmax = ',cdmmax 
    WRITE(lunout,*) 'conf_phys :  cdhmax = ',cdhmax 
    WRITE(lunout,*) 'conf_phys :  ksta = ',ksta 
    WRITE(lunout,*) 'conf_phys :  ksta_ter = ',ksta_ter 
    WRITE(lunout,*) 'conf_phys :  f_ri_cd_min = ',f_ri_cd_min 
    WRITE(lunout,*) 'conf_phys :  ok_kzmin = ',ok_kzmin 
    WRITE(lunout,*) 'conf_phys :  fmagic = ',fmagic
    WRITE(lunout,*) 'conf_phys :  pmagic = ',pmagic
    WRITE(lunout,*) 'conf_phys :  ok_ade = ',ok_ade
    WRITE(lunout,*) 'conf_phys :  ok_volcan = ',ok_volcan
    WRITE(lunout,*) 'conf_phys :  flag_volc_surfstrat = ',flag_volc_surfstrat
    WRITE(lunout,*) 'conf_phys :  ok_aie = ',ok_aie
    WRITE(lunout,*) 'conf_phys :  ok_alw = ',ok_alw
    WRITE(lunout,*) 'conf_phys :  aerosol_couple = ', aerosol_couple
    WRITE(lunout,*) 'conf_phys :  chemistry_couple = ', chemistry_couple
    WRITE(lunout,*) 'conf_phys :  flag_aerosol = ', flag_aerosol
    WRITE(lunout,*) 'conf_phys :  flag_aerosol_strat= ', flag_aerosol_strat
    WRITE(lunout,*) 'conf_phys :  flag_aer_feedback= ', flag_aer_feedback
    WRITE(lunout,*) 'conf_phys :  aer_type = ',aer_type
    WRITE(lunout,*) 'conf_phys :  bl95_b0 = ',bl95_b0
    WRITE(lunout,*) 'conf_phys :  bl95_b1 = ',bl95_b1
    WRITE(lunout,*) 'conf_phys :  lev_histhf = ',lev_histhf 
    WRITE(lunout,*) 'conf_phys :  lev_histday = ',lev_histday 
    WRITE(lunout,*) 'conf_phys :  lev_histmth = ',lev_histmth 
    WRITE(lunout,*) 'conf_phys :  lev_histins = ',lev_histins
    WRITE(lunout,*) 'conf_phys :  lev_histLES = ',lev_histLES
    WRITE(lunout,*) 'conf_phys :  iflag_pbl = ', iflag_pbl
    WRITE(lunout,*) 'conf_phys :  iflag_physiq = ', iflag_physiq
    !FC
    WRITE(lunout,*) 'conf_phys :  ifl_pbltree = ', ifl_pbltree
    WRITE(lunout,*) 'conf_phys :  Cd_frein = ', Cd_frein
    !AM
    WRITE(lunout,*) 'conf_phys :  iflag_hetero_surf = ', iflag_hetero_surf
    WRITE(lunout,*) 'conf_phys :  iflag_pbl_split = ', iflag_pbl_split
    WRITE(lunout,*) 'conf_phys :  iflag_order2_sollw = ', iflag_order2_sollw
    WRITE(lunout,*) 'conf_phys :  iflag_thermals = ', iflag_thermals
    WRITE(lunout,*) 'conf_phys :  iflag_clos = ', iflag_clos
    WRITE(lunout,*) 'conf_phys :  type_run = ',type_run 
    WRITE(lunout,*) 'conf_phys :  ok_cosp = ',ok_cosp
    WRITE(lunout,*) 'conf_phys :  ok_airs = ',ok_airs

    WRITE(lunout,*) 'conf_phys :  ok_mensuelCOSP = ',ok_mensuelCOSP
    WRITE(lunout,*) 'conf_phys :  ok_journeCOSP = ',ok_journeCOSP
    WRITE(lunout,*) 'conf_phys :  ok_hfCOSP =',ok_hfCOSP
    WRITE(lunout,*) 'conf_phys :  solarlong0 = ', solarlong0
    WRITE(lunout,*) 'conf_phys :  qsol0 = ', qsol0
    WRITE(lunout,*) 'conf_phys :  evap0 = ', evap0
    WRITE(lunout,*) 'conf_phys :  albsno0 = ', albsno0
    WRITE(lunout,*) 'conf_phys :  iflag_sic = ', iflag_sic
    WRITE(lunout,*) 'conf_phys :  iflag_inertie = ', iflag_inertie
    WRITE(lunout,*) 'conf_phys :  chasno_tun = ', chasno_tun
    WRITE(lunout,*) 'conf_phys :  inertie_sol = ', inertie_sol
    WRITE(lunout,*) 'conf_phys :  inertie_sic = ', inertie_sic
    WRITE(lunout,*) 'conf_phys :  inertie_lic = ', inertie_lic
    WRITE(lunout,*) 'conf_phys :  inertie_sno = ', inertie_sno
    WRITE(lunout,*) 'conf_phys :  ok_advtke = ', ok_advtke
    WRITE(lunout,*) 'conf_phys :  ok_bs = ', ok_bs
    WRITE(lunout,*) 'conf_phys :  ok_rad_bs = ', ok_rad_bs
    WRITE(lunout,*) 'conf_phys :  f_cdrag_ter = ',f_cdrag_ter
    WRITE(lunout,*) 'conf_phys :  f_cdrag_oce = ',f_cdrag_oce
    WRITE(lunout,*) 'conf_phys :  f_rugoro = ',f_rugoro
    WRITE(lunout,*) 'conf_phys :  z0min = ',z0min
    WRITE(lunout,*) 'conf_phys :  z0m_landice = ',z0m_landice
    WRITE(lunout,*) 'conf_phys :  z0h_landice = ',z0h_landice
    WRITE(lunout,*) 'conf_phys :  z0m_seaice = ',z0m_seaice
    WRITE(lunout,*) 'conf_phys :  z0h_seaice = ',z0h_seaice
    WRITE(lunout,*) 'conf_phys :  z0m_ocean = ',z0m_ocean
    WRITE(lunout,*) 'conf_phys :  z0h_ocean = ',z0h_ocean
    WRITE(lunout,*) 'conf_phys :  z0m_land = ',z0m_land
    WRITE(lunout,*) 'conf_phys :  z0h_land = ',z0h_land
    WRITE(lunout,*) 'conf_phys :  iflag_wake = ', iflag_wake
    WRITE(lunout,*) 'conf_phys :  alp_offset = ', alp_offset
    ! nrlmd le 10/04/2012
    WRITE(lunout,*) 'conf_phys :  iflag_trig_bl = ', iflag_trig_bl
    WRITE(lunout,*) 'conf_phys :  iflag_strig = ', iflag_strig
    WRITE(lunout,*) 'conf_phys :  s_trig = ', s_trig
    WRITE(lunout,*) 'conf_phys :  h_trig = ', h_trig
    WRITE(lunout,*) 'conf_phys :  tau_trig_shallow = ', tau_trig_shallow
    WRITE(lunout,*) 'conf_phys :  tau_trig_deep = ', tau_trig_deep
    WRITE(lunout,*) 'conf_phys :  iflag_clos_bl = ', iflag_clos_bl
    ! fin nrlmd le 10/04/2012

    WRITE(lunout,*) 'conf_phys :  lonmin lonmax latmin latmax bilKP_ins =',&
         lonmin_ins, lonmax_ins, latmin_ins, latmax_ins
    WRITE(lunout,*) 'conf_phys :  ecrit_ hf, ins, day, mth, reg, tra, ISCCP, LES',&
         ecrit_hf, ecrit_ins, ecrit_day, ecrit_mth, ecrit_reg, ecrit_tra, ecrit_ISCCP, ecrit_LES

    WRITE(lunout,*) 'conf_phys :  ok_strato = ', ok_strato
    WRITE(lunout,*) 'conf_phys :  ok_qch4 = ',  ok_qch4
    WRITE(lunout,*) 'conf_phys :  adjust_tropopause = ', adjust_tropopause
    WRITE(lunout,*) 'conf_phys :  ok_daily_climoz = ',ok_daily_climoz
    WRITE(lunout,*) 'conf_phys :  ok_new_lscp = ', ok_new_lscp
    WRITE(lunout,*) 'conf_phys :  read_climoz = ', read_climoz
    WRITE(lunout,*) 'conf_phys :  carbon_cycle_tr = ', carbon_cycle_tr
    WRITE(lunout,*) 'conf_phys :  carbon_cycle_cpl = ', carbon_cycle_cpl
    WRITE(lunout,*) 'conf_phys :  carbon_cycle_rad = ', carbon_cycle_rad
    WRITE(lunout,*) 'conf_phys :  level_coupling_esm = ', level_coupling_esm
    WRITE(lunout,*) 'conf_phys :  carbon_cycle_conc_driven = ', carbon_cycle_conc_driven
    WRITE(lunout,*) 'conf_phys :  read_daily_co2ff = ', read_daily_co2ff
    WRITE(lunout,*) 'conf_phys :  read_fco2_ocean_cor_2d = ', read_fco2_ocean_cor_2d    
    WRITE(lunout,*) 'conf_phys :  read_fco2_land_cor_2d = ', read_fco2_land_cor_2d
    WRITE(lunout,*) 'conf_phys :  read_fco2_ocean_cor = ', read_fco2_ocean_cor
    WRITE(lunout,*) 'conf_phys :  var_fco2_ocean_cor = ', var_fco2_ocean_cor
    WRITE(lunout,*) 'conf_phys :  read_fco2_land_cor = ', read_fco2_land_cor
    WRITE(lunout,*) 'conf_phys :  var_fco2_land_cor = ', var_fco2_land_cor
    WRITE(lunout,*) 'conf_phys :  dms_cycle_cpl = ', dms_cycle_cpl
    WRITE(lunout,*) 'conf_phys :  iflag_seaice = ', iflag_seaice
    WRITE(lunout,*) 'conf_phys :  iflag_seaice_alb = ', iflag_seaice_alb
    WRITE(lunout,*) 'conf_phys :  iflag_leads = ', iflag_leads
    WRITE(lunout,*) 'conf_phys :  sic_hice_fixed = ', sic_hice_fixed
    WRITE(lunout,*) 'conf_phys :  sice_cond = ', sice_cond 
    WRITE(lunout,*) 'conf_phys :  sisno_cond = ', sisno_cond 
    WRITE(lunout,*) 'conf_phys :  sisno_den = ', sisno_den
    WRITE(lunout,*) 'conf_phys :  sisno_min = ', sisno_min
    WRITE(lunout,*) 'conf_phys :  sithick_min = ', sithick_min
    WRITE(lunout,*) 'conf_phys :  sisno_wfact = ', sisno_wfact
    WRITE(lunout,*) 'conf_phys :  amax_n = ', amax_n
    WRITE(lunout,*) 'conf_phys :  amax_s = ', amax_s
    WRITE(lunout,*) 'conf_phys :  rn_alb_sdry = ', rn_alb_sdry
    WRITE(lunout,*) 'conf_phys :  rn_alb_smlt = ', rn_alb_smlt
    WRITE(lunout,*) 'conf_phys :  rn_alb_idry = ', rn_alb_idry
    WRITE(lunout,*) 'conf_phys :  rn_alb_imlt = ', rn_alb_imlt
    WRITE(lunout,*) 'conf_phys :  si_pen_frac = ', si_pen_frac
    WRITE(lunout,*) 'conf_phys :  si_pen_ext = ', si_pen_ext
    WRITE(lunout,*) 'conf_phys :  fseaN = ', fseaN
    WRITE(lunout,*) 'conf_phys :  fseaS = ', fseaS

    WRITE(lunout,*) 'conf_phys :  n2o_cycle_cpl = ', n2o_cycle_cpl
    WRITE(lunout,*) 'conf_phys :  ndp_cycle_cpl = ', ndp_cycle_cpl
    WRITE(lunout,*) 'conf_phys :  nh3_cycle_cpl = ', nh3_cycle_cpl
    WRITE(lunout,*) 'conf_phys :  iflag_tsurf_inlandsis = ', iflag_tsurf_inlandsis
    WRITE(lunout,*) 'conf_phys :  iflag_temp_inlandsis = ', iflag_temp_inlandsis
    WRITE(lunout,*) 'conf_phys :  iflag_albcalc = ', iflag_albcalc
    WRITE(lunout,*) 'conf_phys :  SnoMod = ', SnoMod
    WRITE(lunout,*) 'conf_phys :  BloMod = ', BloMod
    WRITE(lunout,*) 'conf_phys :  ok_outfor = ', ok_outfor
    WRITE(lunout,*) 'conf_phys :  is_ok_slush = ', is_ok_slush
    WRITE(lunout,*) 'conf_phys :  opt_runoff_ac = ', opt_runoff_ac
    WRITE(lunout,*) 'conf_phys :  is_ok_z0h_rn = ', is_ok_z0h_rn
    WRITE(lunout,*) 'conf_phys :  is_ok_density_kotlyakov = ', is_ok_density_kotlyakov
    WRITE(lunout,*) 'conf_phys :  prescribed_z0m_snow = ', prescribed_z0m_snow
    WRITE(lunout,*) 'conf_phys :  iflag_z0m_snow = ', iflag_z0m_snow
    WRITE(lunout,*) 'conf_phys :  ok_zsn_ii = ', ok_zsn_ii
    WRITE(lunout,*) 'conf_phys :  discret_xf = ', discret_xf
    WRITE(lunout,*) 'conf_phys :  correc_alb= ', correc_alb
    WRITE(lunout,*) 'conf_phys :  buf_sph_pol = ', buf_sph_pol
    WRITE(lunout,*) 'conf_phys :  buf_siz_pol= ', buf_siz_pol
    !rajout Olivier Torres
    WRITE(lunout,*) 'conf_phys :  choix_bulk = ', choix_bulk
    WRITE(lunout,*) 'conf_phys :  nit_bulk = ', nit_bulk
    WRITE(lunout,*) 'conf_phys :  kz0 = ', kz0
    WRITE(lunout,*) 'conf_phys :  V1'

    call config_ocean_skin

  END SUBROUTINE conf_phys

END MODULE conf_phys_m
!
!#################################################################
!

SUBROUTINE conf_interface(tau_calv)
  USE ioipsl_getin_p_mod, ONLY : getin_p

  USE IOIPSL
  USE print_control_mod, ONLY: lunout
  IMPLICIT NONE
  ! Configuration de l'interace atm/surf
  !
  ! tau_calv:    temps de relaxation pour la fonte des glaciers
  !
  REAL          :: tau_calv
  !
  !
  tau_calv = 360.*10.
  CALL getin_p('tau_calv',tau_calv)
  !$OMP BARRIER
  !
  !
  WRITE(lunout,*)' ##############################################'
  WRITE(lunout,*)' Configuration de l''interface atm/surfaces  : '
  WRITE(lunout,*)' tau_calv = ',tau_calv
  !
  RETURN

END SUBROUTINE conf_interface
