Index: CONFIG/UNIFORM/v6/IPSLCM6.3/SOURCES/LMDZ/chemistry_cycle_mod.F90
===================================================================
--- CONFIG/UNIFORM/v6/IPSLCM6.3/SOURCES/LMDZ/chemistry_cycle_mod.F90	(revision 6571)
+++ CONFIG/UNIFORM/v6/IPSLCM6.3/SOURCES/LMDZ/chemistry_cycle_mod.F90	(revision 6571)
@@ -0,0 +1,22 @@
+MODULE chemistry_cycle_mod
+
+!=======================================================================
+!   Authors: Anne Cozic and Thibaut Lurton
+!
+!  Purpose and description:
+!  -----------------------
+! Control module for the chemistry  tracers :
+!   - Definition of fluxes to be exchanged with Pisces and Inca 
+!
+!=======================================================================
+
+
+  IMPLICIT NONE
+
+! Variables read from parmeter file physiq.def
+  LOGICAL, SAVE, PUBLIC :: dms_cycle_cpl       ! Coupling of CO2 fluxes between LMDZ/ORCHIDEE and LMDZ/OCEAN(PISCES) 
+!$OMP THREADPRIVATE(dms_cycle_cpl)   
+
+
+  
+END MODULE chemistry_cycle_mod
Index: CONFIG/UNIFORM/v6/IPSLCM6.3/SOURCES/LMDZ/conf_phys_m.F90
===================================================================
--- CONFIG/UNIFORM/v6/IPSLCM6.3/SOURCES/LMDZ/conf_phys_m.F90	(revision 6571)
+++ CONFIG/UNIFORM/v6/IPSLCM6.3/SOURCES/LMDZ/conf_phys_m.F90	(revision 6571)
@@ -0,0 +1,3116 @@
+!
+! $Id: conf_phys.F90 1668 2012-10-12 10:47:37Z idelkadi $
+!
+!
+!
+MODULE conf_phys_m
+
+  IMPLICIT NONE
+
+CONTAINS
+
+  SUBROUTINE conf_phys(ok_journe, ok_mensuel, ok_instan, ok_hf, &
+       ok_LES,&
+       callstats,&
+       solarlong0,seuil_inversion, &
+       fact_cldcon, facttemps,ok_newmicro,iflag_radia,&
+       iflag_cld_th, &
+       iflag_ratqs,ratqsbas,ratqshaut,tau_ratqs, &
+       ok_ade, ok_aie, ok_alw, ok_cdnc, ok_volcan, flag_volc_surfstrat, aerosol_couple, & 
+       chemistry_couple, flag_aerosol, flag_aerosol_strat, flag_aer_feedback, &
+       flag_bc_internal_mixture, bl95_b0, bl95_b1,&
+       read_climoz, &
+       alp_offset)
+
+    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
+    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 chemistry_cycle_mod, ONLY: dms_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 phys_state_var_mod, ONLY: phys_tstep
+
+    INCLUDE "conema3.h"
+    INCLUDE "fisrtilp.h"
+    INCLUDE "nuage.h"
+    INCLUDE "YOMCST.h"
+    INCLUDE "YOMCST2.h"
+    INCLUDE "alpale.h"
+
+    !IM : on inclut/initialise les taux de CH4, N2O, CFC11 et CFC12
+    INCLUDE "clesphys.h"
+    INCLUDE "compbl.h"
+    INCLUDE "comsoil.h"
+    INCLUDE "YOEGWD.h"
+    !
+    ! 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:
+    LOGICAL              :: ok_newmicro
+    INTEGER              :: iflag_radia
+    LOGICAL              :: ok_journe, ok_mensuel, ok_instan, ok_hf
+    LOGICAL              :: ok_LES
+    LOGICAL              :: callstats
+    LOGICAL              :: ok_ade, ok_aie, ok_alw, ok_cdnc, ok_volcan
+    LOGICAL              :: aerosol_couple, chemistry_couple
+    INTEGER              :: flag_aerosol
+    INTEGER              :: flag_aerosol_strat
+    INTEGER              :: flag_volc_surfstrat
+    LOGICAL              :: flag_aer_feedback
+    LOGICAL              :: flag_bc_internal_mixture
+    REAL                 :: bl95_b0, bl95_b1
+    REAL                 :: fact_cldcon, facttemps,ratqsbas,ratqshaut,tau_ratqs
+    INTEGER              :: iflag_cld_th
+    INTEGER              :: iflag_ratqs
+
+    CHARACTER (len = 6), SAVE  :: type_ocean_omp, version_ocean_omp, ocean_omp
+    CHARACTER (len = 10),SAVE  :: type_veget_omp
+    CHARACTER (len = 8), SAVE  :: aer_type_omp
+    INTEGER, SAVE       :: landice_opt_omp
+    INTEGER, SAVE       :: iflag_tsurf_inlandsis_omp,iflag_temp_inlandsis_omp
+    INTEGER, SAVE       :: iflag_albcalc_omp,iflag_z0m_snow_omp   
+    LOGICAL, SAVE       :: SnoMod_omp,BloMod_omp,ok_outfor_omp,ok_zsn_ii_omp
+    LOGICAL, SAVE       :: discret_xf_omp,opt_runoff_ac_omp  
+    LOGICAL, SAVE       :: is_ok_slush_omp,is_ok_z0h_rn_omp,is_ok_density_kotlyakov_omp
+    REAL, SAVE          :: prescribed_z0m_snow_omp,correc_alb_omp
+    REAL, SAVE          :: buf_sph_pol_omp,buf_siz_pol_omp
+    LOGICAL, SAVE       :: ok_newmicro_omp
+    LOGICAL, SAVE       :: ok_all_xml_omp
+    LOGICAL, SAVE       :: ok_lwoff_omp
+    LOGICAL, SAVE       :: ok_journe_omp, ok_mensuel_omp, ok_instan_omp, ok_hf_omp        
+    LOGICAL, SAVE       :: ok_LES_omp   
+    LOGICAL, SAVE       :: callstats_omp
+    LOGICAL, SAVE       :: ok_ade_omp, ok_aie_omp, ok_alw_omp, ok_cdnc_omp, ok_volcan_omp
+    LOGICAL, SAVE       :: aerosol_couple_omp, chemistry_couple_omp
+    INTEGER, SAVE       :: flag_aerosol_omp
+    INTEGER, SAVE       :: flag_aerosol_strat_omp
+    INTEGER, SAVE       :: flag_volc_surfstrat_omp
+    LOGICAL, SAVE       :: flag_aer_feedback_omp
+    LOGICAL, SAVE       :: flag_bc_internal_mixture_omp
+    REAL,SAVE           :: bl95_b0_omp, bl95_b1_omp
+    REAL,SAVE           :: freq_ISCCP_omp, ecrit_ISCCP_omp
+    REAL,SAVE           :: freq_COSP_omp, freq_AIRS_omp 
+    REAL,SAVE           :: fact_cldcon_omp, facttemps_omp,ratqsbas_omp
+    REAL,SAVE           :: tau_cld_cv_omp, coefw_cld_cv_omp
+    INTEGER, SAVE       :: iflag_cld_cv_omp
+
+    REAL, SAVE          :: ratqshaut_omp
+    REAL, SAVE          :: tau_ratqs_omp
+    REAL, SAVE          :: t_coupl_omp
+    INTEGER, SAVE       :: iflag_radia_omp
+    INTEGER, SAVE       :: iflag_rrtm_omp
+    INTEGER, SAVE       :: iflag_albedo_omp !albedo SB
+    LOGICAL, SAVE       :: ok_chlorophyll_omp ! albedo SB  
+    INTEGER, SAVE       :: NSW_omp
+    INTEGER, SAVE       :: iflag_cld_th_omp, ip_ebil_phy_omp
+    INTEGER, SAVE       :: iflag_ratqs_omp
+
+    REAL, SAVE          :: f_cdrag_ter_omp,f_cdrag_oce_omp
+    REAL, SAVE          :: f_rugoro_omp   , z0min_omp
+    REAL, SAVE          :: z0m_seaice_omp,z0h_seaice_omp
+    REAL, SAVE          :: z0m_landice_omp,z0h_landice_omp
+    REAL, SAVE          :: min_wind_speed_omp,f_gust_wk_omp,f_gust_bl_omp,f_qsat_oce_omp, f_z0qh_oce_omp
+    INTEGER, SAVE       :: iflag_gusts_omp,iflag_z0_oce_omp
+
+    REAL :: seuil_inversion
+    REAL,SAVE :: seuil_inversion_omp
+
+    INTEGER,SAVE :: iflag_thermals_omp,nsplit_thermals_omp
+    REAL,SAVE :: tau_thermals_omp,alp_bl_k_omp
+    ! nrlmd le 10/04/2012
+    INTEGER,SAVE :: iflag_trig_bl_omp,iflag_clos_bl_omp
+    INTEGER,SAVE :: tau_trig_shallow_omp,tau_trig_deep_omp
+    REAL,SAVE    :: s_trig_omp
+    ! fin nrlmd le 10/04/2012
+    REAL :: alp_offset
+    REAL, SAVE :: alp_offset_omp
+    INTEGER,SAVE :: iflag_coupl_omp,iflag_clos_omp,iflag_wake_omp
+    INTEGER,SAVE :: iflag_cvl_sigd_omp
+    REAL, SAVE :: coef_clos_ls_omp
+    REAL, SAVE :: supcrit1_omp, supcrit2_omp
+    INTEGER, SAVE :: iflag_mix_omp
+    INTEGER, SAVE :: iflag_mix_adiab_omp
+    REAL, SAVE :: scut_omp, qqa1_omp, qqa2_omp, gammas_omp, Fmax_omp, alphas_omp
+    REAL, SAVE :: tmax_fonte_cv_omp
+
+    REAL,SAVE :: R_ecc_omp,R_peri_omp,R_incl_omp,solaire_omp
+    REAL,SAVE :: solaire_omp_init
+    LOGICAL,SAVE :: ok_suntime_rrtm_omp
+    REAL,SAVE :: co2_ppm_omp, RCO2_omp, co2_ppm_per_omp, RCO2_per_omp
+    REAL,SAVE :: co2_ppm0_omp
+    REAL,SAVE :: CH4_ppb_omp, RCH4_omp, CH4_ppb_per_omp, RCH4_per_omp
+    REAL,SAVE :: N2O_ppb_omp, RN2O_omp, N2O_ppb_per_omp, RN2O_per_omp
+    REAL,SAVE :: CFC11_ppt_omp,RCFC11_omp,CFC11_ppt_per_omp,RCFC11_per_omp
+    REAL,SAVE :: CFC12_ppt_omp,RCFC12_omp,CFC12_ppt_per_omp,RCFC12_per_omp
+    REAL,SAVE :: epmax_omp
+    REAL,SAVE :: coef_epmax_cape_omp
+    LOGICAL,SAVE :: ok_adj_ema_omp
+    INTEGER,SAVE :: iflag_clw_omp
+    REAL,SAVE :: cld_lc_lsc_omp,cld_lc_con_omp,cld_tau_lsc_omp,cld_tau_con_omp
+    REAL,SAVE :: ffallv_lsc_omp, ffallv_con_omp,coef_eva_omp,coef_eva_i_omp
+    LOGICAL,SAVE :: reevap_ice_omp
+    INTEGER,SAVE :: iflag_pdf_omp
+    INTEGER,SAVE :: iflag_ice_thermo_omp
+    LOGICAL,SAVE :: ok_ice_sursat_omp
+    LOGICAL,SAVE :: ok_plane_h2o_omp, ok_plane_contrail_omp
+    INTEGER,SAVE :: iflag_t_glace_omp
+    INTEGER,SAVE :: iflag_cloudth_vert_omp
+    INTEGER,SAVE :: iflag_rain_incloud_vol_omp
+    INTEGER,SAVE :: iflag_vice_omp, iflag_rei_omp
+    REAL,SAVE :: rad_froid_omp, rad_chau1_omp, rad_chau2_omp
+    REAL,SAVE :: t_glace_min_omp, t_glace_max_omp
+    REAL,SAVE :: exposant_glace_omp
+    INTEGER,SAVE :: iflag_gammasat_omp
+    REAL,SAVE :: rei_min_omp, rei_max_omp
+    INTEGER,SAVE :: iflag_sic_omp, iflag_inertie_omp
+    REAL,SAVE :: inertie_sol_omp,inertie_sno_omp,inertie_sic_omp
+    REAL,SAVE :: inertie_lic_omp
+    REAL,SAVE :: qsol0_omp
+    REAL,SAVE :: evap0_omp
+    REAL,SAVE :: albsno0_omp
+    REAL      :: solarlong0
+    REAL,SAVE :: solarlong0_omp
+    INTEGER,SAVE :: top_height_omp,overlap_omp
+    REAL,SAVE :: cdmmax_omp,cdhmax_omp,ksta_omp,ksta_ter_omp,f_ri_cd_min_omp
+    LOGICAL,SAVE :: ok_kzmin_omp
+    REAL, SAVE ::  fmagic_omp, pmagic_omp
+    INTEGER,SAVE :: iflag_pbl_omp,lev_histhf_omp,lev_histday_omp,lev_histmth_omp
+    INTEGER,SAVE :: iflag_pbl_split_omp
+!FC
+    INTEGER,SAVE :: ifl_pbltree_omp
+    REAL,SAVE :: Cd_frein_omp
+!FC
+    INTEGER,SAVE :: iflag_order2_sollw_omp
+    INTEGER, SAVE :: lev_histins_omp, lev_histLES_omp 
+    INTEGER, SAVE :: lev_histdayNMC_omp
+    INTEGER, SAVE :: levout_histNMC_omp(3)
+    LOGICAL, SAVE :: ok_histNMC_omp(3)
+    REAL, SAVE    :: freq_outNMC_omp(3), freq_calNMC_omp(3)
+    CHARACTER*4, SAVE :: type_run_omp
+    LOGICAL, SAVE :: ok_cosp_omp, ok_airs_omp
+    LOGICAL, SAVE :: ok_mensuelCOSP_omp,ok_journeCOSP_omp,ok_hfCOSP_omp
+    REAL, SAVE    :: lonmin_ins_omp, lonmax_ins_omp, latmin_ins_omp, latmax_ins_omp
+    REAL, SAVE    :: ecrit_hf_omp, ecrit_day_omp, ecrit_mth_omp, ecrit_reg_omp
+    REAL, SAVE    :: ecrit_ins_omp
+    REAL, SAVE    :: ecrit_LES_omp
+    REAL, SAVE    :: ecrit_tra_omp
+    REAL, SAVE    :: cvl_comp_threshold_omp
+    REAL, SAVE    :: cvl_sig2feed_omp
+    REAL, SAVE    :: cvl_corr_omp
+    LOGICAL, SAVE :: ok_lic_melt_omp
+    LOGICAL, SAVE :: ok_lic_cond_omp
+    !
+    REAL, SAVE    :: zrel_oro_t_omp, zstd_orodr_t_omp
+    REAL, SAVE    :: zpmm_orodr_t_omp, zpmm_orolf_t_omp
+    INTEGER, SAVE :: iflag_cycle_diurne_omp
+    LOGICAL, SAVE :: soil_model_omp,new_oliq_omp
+    LOGICAL, SAVE :: ok_orodr_omp, ok_orolf_omp, ok_limitvrai_omp
+    INTEGER, SAVE :: nbapp_rad_omp, iflag_con_omp
+    INTEGER, SAVE :: nbapp_cv_omp, nbapp_wk_omp
+    INTEGER, SAVE :: iflag_ener_conserv_omp
+    LOGICAL, SAVE :: ok_conserv_q_omp
+    INTEGER, SAVE :: iflag_fisrtilp_qsat_omp
+    INTEGER, SAVE :: iflag_bergeron_omp
+    LOGICAL,SAVE  :: ok_strato_omp
+    LOGICAL,SAVE  :: ok_hines_omp, ok_gwd_rando_omp
+    REAL, SAVE    :: gwd_rando_ruwmax_omp, gwd_rando_sat_omp
+    REAL, SAVE    :: gwd_front_ruwmax_omp, gwd_front_sat_omp
+    REAL, SAVE    :: sso_gkdrag_omp,sso_grahil_omp,sso_grcrit_omp
+    REAL, SAVE    :: sso_gfrcri_omp,sso_gkwake_omp,sso_gklift_omp
+    LOGICAL, SAVE :: ok_qch4_omp
+    LOGICAL, SAVE :: carbon_cycle_tr_omp
+    LOGICAL, SAVE :: carbon_cycle_cpl_omp
+    LOGICAL, SAVE :: carbon_cycle_rad_omp
+    LOGICAL, SAVE :: dms_cycle_cpl_omp
+    INTEGER, SAVE :: level_coupling_esm_omp
+    LOGICAL, SAVE :: read_fco2_ocean_cor_omp
+    REAL, SAVE    :: var_fco2_ocean_cor_omp
+    LOGICAL, SAVE :: read_fco2_land_cor_omp
+    REAL, SAVE    :: var_fco2_land_cor_omp
+    LOGICAL, SAVE :: adjust_tropopause_omp
+    LOGICAL, SAVE :: ok_daily_climoz_omp
+    LOGICAL, SAVE :: ok_new_lscp_omp
+    LOGICAL, SAVE :: ok_icefra_lscp_omp
+
+
+    INTEGER, INTENT(OUT):: read_climoz ! read ozone climatology, OpenMP shared
+    ! 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
+
+    !-----------------------------------------------------------------
+
+    print*,'CONFPHYS ENTREE'
+    !$OMP MASTER 
+    !Config Key  = type_ocean 
+    !Config Desc = Type d'ocean
+    !Config Def  = force
+    !Config Help = Type d'ocean utilise: force, slab,couple
+    !
+    type_ocean_omp = 'force '
+    CALL getin('type_ocean', type_ocean_omp)
+    !
+    !Config Key  = version_ocean 
+    !Config Desc = Version d'ocean
+    !Config Def  = xxxxxx
+    !Config Help = Version d'ocean utilise: opa8/nemo/sicOBS/xxxxxx
+    !
+    version_ocean_omp = 'xxxxxx'
+    CALL getin('version_ocean', version_ocean_omp)
+
+    !Config Key  = OCEAN
+    !Config Desc = Old parameter name for type_ocean
+    !Config Def  = yyyyyy
+    !Config Help = This is only for testing purpose
+    !
+    ocean_omp = 'yyyyyy'
+    CALL getin('OCEAN', ocean_omp)
+    IF (ocean_omp /= '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
+
+    !Config Key  = t_coupl
+    !Config Desc = Pas de temps du couplage atm/oce en sec.
+    !Config Def  = 86400
+    !Config Help = This is only for testing purpose
+    !
+    t_coupl_omp = 86400.
+    CALL getin('t_coupl', t_coupl_omp)
+    IF (t_coupl_omp == 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
+
+    !
+    !Config Key  = ok_all_xml 
+    !Config Desc = utiliser les xml pourles dÃ©finitions des champs pour xios
+    !Config Def  = .FALSE.
+    !Config Help = 
+    !
+    ok_all_xml_omp = .FALSE.
+    CALL getin('ok_all_xml', ok_all_xml_omp)
+
+    !
+    !Config Key  = ok_lwoff
+    !Config Desc = inhiber l effet radiatif LW des nuages
+    !Config Def  = .FALSE.
+    !Config Help = 
+    !
+    ok_lwoff_omp = .FALSE.
+    CALL getin('ok_lwoff', ok_lwoff_omp)
+    !
+
+    !
+    !Config Key  = VEGET 
+    !Config Desc = Type de modele de vegetation
+    !Config Def  = .FALSE.
+    !Config Help = Type de modele de vegetation utilise
+    !
+    type_veget_omp ='orchidee'
+    CALL getin('VEGET', type_veget_omp)
+    !
+
+    ! INLANDSIS
+    !==================================================================
+    ! Martin et Etienne
+    !Config Key  = landice_opt
+    !Config Desc = which landice snow model (BULK, or INLANDSIS)
+    !Config Def  = 0
+    landice_opt_omp = 0
+    CALL getin('landice_opt', landice_opt_omp)
+    ! Martin et Etienne
+
+    !Etienne
+    !Config Key  = iflag_temp_inlandsis
+    !Config Desc = which method to calculate temp within the soil in INLANDSIS
+    !Config Def  = 0
+    iflag_temp_inlandsis_omp = 0
+    CALL getin('iflag_temp_inlandsis', iflag_temp_inlandsis_omp)
+
+    !Etienne
+    !Config Key  = iflag_tsurf_inlandsis
+    !Config Desc = which method to calculate tsurf in INLANDSIS
+    !Config Def  = 0
+    iflag_tsurf_inlandsis_omp = 1
+    CALL getin('iflag_tsurf_inlandsis', iflag_tsurf_inlandsis_omp)
+
+
+    !Etienne
+    !Config Key  = iflag_albcalc
+    !Config Desc = method to calculate snow albedo in INLANDSIS
+    !Config Def  = 0
+    iflag_albcalc_omp = 0
+    CALL getin('iflag_albcalc', iflag_albcalc_omp)
+
+
+    !Etienne
+    !Config Key  = SnoMod
+    !Config Desc = activation of snow modules in inlandsis
+    !Config Def  = .TRUE.
+    SnoMod_omp = .TRUE.
+    CALL getin('SnoMod', SnoMod_omp)
+
+    !Etienne
+    !Config Key  = BloMod
+    !Config Desc = activation of blowing snow in inlandsis
+    !Config Def  = .FALSE.
+    BloMod_omp = .FALSE.
+    CALL getin('BloMod', BloMod_omp)
+
+    !Etienne
+    !Config Key  = ok_outfor
+    !Config Desc = activation of output ascii file in inlandsis
+    !Config Def  = .FALSE.
+    ok_outfor_omp = .FALSE.
+    CALL getin('ok_outfor', ok_outfor_omp)
+
+
+    !Etienne
+    !Config Key  = ok_sn_ii
+    !Config Desc = activation of ice/snow detection
+    !Config Def  = .TRUE.
+    ok_zsn_ii_omp = .TRUE.
+    CALL getin('ok_zsn_ii', ok_zsn_ii_omp)
+
+
+    !Etienne
+    !Config Key  = discret_xf
+    !Config Desc = snow discretization following XF
+    !Config Def  = .TRUE.
+    discret_xf_omp = .TRUE.
+    CALL getin('discret_xf', discret_xf_omp)
+
+
+    !Etienne
+    !Config Key  = is_ok_slush
+    !Config Desc = activation of the slush option
+    !Config Def  = .TRUE.
+    is_ok_slush_omp = .TRUE.
+    CALL getin('is_ok_slush', is_ok_slush_omp)
+
+    !Etienne
+    !Config Key  = opt_runoff_ac
+    !Config Desc = option runoff AC
+    !Config Def  = .TRUE.
+    opt_runoff_ac_omp = .TRUE.
+    CALL getin('opt_runoff_ac', opt_runoff_ac_omp)
+
+    !Etienne
+    !Config Key  = is_ok_z0h_rn
+    !Config Desc = z0h calculation following RN method
+    !Config Def  = .TRUE.
+    is_ok_z0h_rn_omp = .TRUE.
+    CALL getin('is_ok_z0h_rn', is_ok_z0h_rn_omp)
+
+
+    !Etienne
+    !Config Key  = is_ok_density_kotlyakov
+    !Config Desc = snow density calculation following kotlyakov
+    !Config Def  = .FALSE.
+    is_ok_density_kotlyakov_omp = .FALSE.
+    CALL getin('is_ok_density_kotlyakov', is_ok_density_kotlyakov_omp)
+
+
+    !Etienne
+    !Config Key  = prescribed_z0m_snow
+    !Config Desc = prescribed snow z0m
+    !Config Def  = 0.005
+    prescribed_z0m_snow_omp = 0.005
+    CALL getin('prescribed_z0m_snow', prescribed_z0m_snow_omp)
+
+
+    !Etienne
+    !Config Key  = iflag_z0m_snow
+    !Config Desc = method to calculate snow z0m
+    !Config Def  = 0
+    iflag_z0m_snow_omp = 0
+    CALL getin('iflag_z0m_snow', iflag_z0m_snow_omp)
+
+
+    !Etienne
+    !Config Key  = correc_alb
+    !Config Desc = correction term for albedo
+    !Config Def  = 1.01
+    correc_alb_omp=1.01
+    CALL getin('correc_alb', correc_alb_omp)
+
+
+    !Etienne
+    !Config Key  = buf_sph_pol
+    !Config Desc = sphericity of buffer layer in polar regions
+    !Config Def  = 99.
+    buf_sph_pol_omp=99.
+    CALL getin('buf_sph_pol', buf_sph_pol_omp)
+
+    !Etienne
+    !Config Key  = buf_siz_pol
+    !Config Desc = grain size of buffer layer in polar regions in e-4m
+    !Config Def  = 4.
+    buf_siz_pol_omp=4.
+    CALL getin('buf_siz_pol', buf_siz_pol_omp)
+
+    !==================================================================
+    
+    !Config Key  = OK_journe
+    !Config Desc = Pour des sorties journalieres 
+    !Config Def  = .FALSE.
+    !Config Help = Pour creer le fichier histday contenant les sorties
+    !              journalieres 
+    !
+    ok_journe_omp = .FALSE.
+    CALL getin('OK_journe', ok_journe_omp)
+    !
+    !Config Key  = ok_hf
+    !Config Desc = Pour des sorties haute frequence
+    !Config Def  = .FALSE.
+    !Config Help = Pour creer le fichier histhf contenant les sorties
+    !              haute frequence ( 3h ou 6h)
+    !
+    ok_hf_omp = .FALSE.
+    CALL getin('ok_hf', ok_hf_omp)
+    !
+    !Config Key  = OK_mensuel
+    !Config Desc = Pour des sorties mensuelles 
+    !Config Def  = .TRUE.
+    !Config Help = Pour creer le fichier histmth contenant les sorties
+    !              mensuelles 
+    !
+    ok_mensuel_omp = .TRUE.
+    CALL getin('OK_mensuel', ok_mensuel_omp)
+    !
+    !Config Key  = OK_instan
+    !Config Desc = Pour des sorties instantanees 
+    !Config Def  = .FALSE.
+    !Config Help = Pour creer le fichier histins contenant les sorties
+    !              instantanees 
+    !
+    ok_instan_omp = .FALSE.
+    CALL getin('OK_instan', ok_instan_omp)
+    !
+    !Config Key  = ok_ade
+    !Config Desc = Aerosol direct effect or not?
+    !Config Def  = .FALSE.
+    !Config Help = Used in radlwsw.F
+    !
+    ok_ade_omp = .FALSE.
+    CALL getin('ok_ade', ok_ade_omp)
+
+    !Config Key  = ok_alw
+    !Config Desc = Aerosol longwave effect or not?
+    !Config Def  = .FALSE.
+    !Config Help = Used in radlwsw.F
+    !
+    ok_alw_omp = .FALSE.
+    CALL getin('ok_alw', ok_alw_omp)
+
+    !
+    !Config Key  = ok_aie
+    !Config Desc = Aerosol indirect effect or not?
+    !Config Def  = .FALSE.
+    !Config Help = Used in nuage.F and radlwsw.F
+    !
+    ok_aie_omp = .FALSE.
+    CALL getin('ok_aie', ok_aie_omp)
+
+    !
+    !Config Key  = ok_cdnc
+    !Config Desc = ok cloud droplet number concentration
+    !Config Def  = .FALSE.
+    !Config Help = Used in newmicro.F
+    !
+    ok_cdnc_omp = .FALSE.
+    CALL getin('ok_cdnc', ok_cdnc_omp)
+
+    !
+    !Config Key  = ok_volcan
+    !Config Desc = ok to generate volcanic diags
+    !Config Def  = .FALSE.
+    !Config Help = Used in radlwsw_m.F
+    !
+    ok_volcan_omp = .FALSE.
+    CALL getin('ok_volcan', ok_volcan_omp)
+
+    !
+    !Config Key  = flag_volc_surfstrat
+    !Config Desc = impose cooling rate at the surface (=1),
+    !              heating rate in the strato (=2), or nothing (=0)
+    !Config Def  = 0
+    !Config Help = Used in radlwsw_m.F
+    !
+    flag_volc_surfstrat_omp = 0 ! NL: SURFSTRAT
+    CALL getin('flag_volc_surfstrat', flag_volc_surfstrat_omp) 
+
+    !
+    !Config Key  = aerosol_couple
+    !Config Desc = read aerosol in file or calcul by inca
+    !Config Def  = .FALSE.
+    !Config Help = Used in physiq.F
+    !
+    aerosol_couple_omp = .FALSE.
+    CALL getin('aerosol_couple',aerosol_couple_omp)
+    !
+    !Config Key  = chemistry_couple
+    !Config Desc = read O3 chemistry in file or calcul by inca
+    !Config Def  = .FALSE.
+    !Config Help = Used in physiq.F
+    !
+    chemistry_couple_omp = .FALSE.
+    CALL getin('chemistry_couple',chemistry_couple_omp)
+    !
+    !Config Key  = flag_aerosol
+    !Config Desc = which aerosol is use for coupled model
+    !Config Def  = 1
+    !Config Help = Used in physiq.F
+    !
+    ! - 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_omp = 0
+    CALL getin('flag_aerosol',flag_aerosol_omp)
+
+    !
+    !Config Key  = flag_bc_internal_mixture
+    !Config Desc = state of mixture for BC aerosols
+    ! - n = external mixture
+    ! - y = internal mixture
+    !Config Def  = n
+    !Config Help = Used in physiq.F / aeropt
+    !
+    flag_bc_internal_mixture_omp = .FALSE.
+    CALL getin('flag_bc_internal_mixture',flag_bc_internal_mixture_omp)
+
+    ! 
+    !Config Key  = aer_type 
+    !Config Desc = Use a constant field for the aerosols 
+    !Config Def  = scenario 
+    !Config Help = Used in readaerosol.F90 
+    ! 
+    aer_type_omp = 'scenario' 
+    CALL getin('aer_type', aer_type_omp) 
+
+    !
+    !Config Key  = bl95_b0
+    !Config Desc = Parameter in CDNC-maer link (Boucher&Lohmann 1995)
+    !Config Def  = .FALSE.
+    !Config Help = Used in nuage.F
+    !
+    bl95_b0_omp = 2.
+    CALL getin('bl95_b0', bl95_b0_omp)
+
+    !Config Key  = bl95_b1
+    !Config Desc = Parameter in CDNC-maer link (Boucher&Lohmann 1995)
+    !Config Def  = .FALSE.
+    !Config Help = Used in nuage.F
+    !
+    bl95_b1_omp = 0.2
+    CALL getin('bl95_b1', bl95_b1_omp)
+
+    !Config Key  = freq_ISCCP
+    !Config Desc = Frequence d'appel du simulateur ISCCP en secondes;
+    !              par defaut 10800, i.e. 3 heures 
+    !Config Def  = 10800.
+    !Config Help = Used in ini_histISCCP.h
+    !
+    freq_ISCCP_omp = 10800.
+    CALL getin('freq_ISCCP', freq_ISCCP_omp)
+    !
+    !Config Key  = ecrit_ISCCP
+    !Config Desc = Frequence d'ecriture des resultats du simulateur ISCCP en nombre de jours;
+    !              par defaut 1., i.e. 1 jour
+    !Config Def  = 1.
+    !Config Help = Used in ini_histISCCP.h
+    !
+    !
+    ecrit_ISCCP_omp = 1.
+    CALL getin('ecrit_ISCCP', ecrit_ISCCP_omp)
+
+    !Config Key  = freq_COSP
+    !Config Desc = Frequence d'appel du simulateur COSP en secondes;
+    !              par defaut 10800, i.e. 3 heures
+    !Config Def  = 10800.
+    !Config Help = Used in ini_histdayCOSP.h
+    !
+    freq_COSP_omp = 10800.
+    CALL getin('freq_COSP', freq_COSP_omp)
+
+    !Config Key  = freq_AIRS
+    !Config Desc = Frequence d'appel du simulateur AIRS en secondes;
+    !              par defaut 10800, i.e. 3 heures
+    !Config Def  = 10800.
+    !Config Help = Used in ini_histdayAIRS.h
+    !
+    freq_AIRS_omp = 10800.
+    CALL getin('freq_AIRS', freq_AIRS_omp)
+
+    !
+    !Config Key  = ip_ebil_phy
+    !Config Desc = Niveau de sortie pour les diags bilan d'energie 
+    !Config Def  = 0
+    !Config Help = 
+    !               
+    ip_ebil_phy_omp = 0
+    CALL getin('ip_ebil_phy', ip_ebil_phy_omp)
+    IF (ip_ebil_phy_omp/=0) THEN
+       CALL abort_physic('conf_phys','ip_ebil_phy_omp doit etre 0 sur cette version',1)
+    ENDIF
+
+    !
+    !Config Key  = seuil_inversion
+    !Config Desc = Seuil ur dTh pour le choix entre les schemas de CL
+    !Config Def  = -0.1
+    !Config Help = 
+    !               
+    seuil_inversion_omp = -0.1
+    CALL getin('seuil_inversion', seuil_inversion_omp)
+
+    !
+    ! Constante solaire & Parametres orbitaux & taux gaz effet de serre BEG
+    !
+    !Config Key  = R_ecc
+    !Config Desc = Excentricite
+    !Config Def  = 0.016715
+    !Config Help = 
+    !               
+    !valeur AMIP II
+    R_ecc_omp = 0.016715
+    CALL getin('R_ecc', R_ecc_omp)
+    !
+    !Config Key  = R_peri
+    !Config Desc = Equinoxe
+    !Config Def  = 
+    !Config Help = 
+    !               
+    !
+    !valeur AMIP II
+    R_peri_omp = 102.7
+    CALL getin('R_peri', R_peri_omp)
+    !
+    !Config Key  = R_incl
+    !Config Desc = Inclinaison
+    !Config Def  = 
+    !Config Help = 
+    !               
+    !
+    !valeur AMIP II
+    R_incl_omp = 23.441
+    CALL getin('R_incl', R_incl_omp)
+    !
+    !Config Key  = solaire
+    !Config Desc = Constante solaire en W/m2
+    !Config Def  = 1365.
+    !Config Help = 
+    !               
+    !
+    !valeur AMIP II
+    solaire_omp = 1365.
+    solaire_omp_init = solaire_omp     !--we keep track of the default value
+    CALL getin('solaire', solaire_omp)
+    !
+    !Config Key  = co2_ppm
+    !Config Desc = concentration du CO2 en ppmv
+    !Config Def  = 348.
+    !Config Help = 
+    !               
+    !valeur AMIP II
+    co2_ppm_omp = 348.
+    CALL getin('co2_ppm', co2_ppm_omp)
+    !
+    !conversion en rapport de mÃ©lange massique
+    RCO2_omp = co2_ppm_omp * 1.0e-06 * RMCO2 / RMD
+
+    !
+    !Config Key  = co2_ppm0
+    !Config Desc = concentration initiale du CO2 en ppmv pour la version ESM avec CO2 interactif dans le cas 
+    !              oÃ¹ cette concentration de figure pas dans l'Ã©tat de redÃ©marrage de la physique
+    !Config Def  = 284.32
+    !Config Help = 
+    !               
+    co2_ppm0_omp = 284.32
+    CALL getin('co2_ppm0', co2_ppm0_omp)
+    !
+    !Config Key  = RCH4
+    !Config Desc = Concentration du CH4
+    !Config Def  = 1.65E-06* 16.043/28.97
+    !Config Help = 
+    !               
+    CH4_ppb_omp = 1650.
+    CALL getin('CH4_ppb', CH4_ppb_omp)
+    !conversion en rapport de mÃ©lange massique
+    RCH4_omp = CH4_ppb_omp * 1.0E-09 * RMCH4 / RMD
+    !
+    !Config Key  = RN2O
+    !Config Desc = Concentration du N2O
+    !Config Def  = 306.E-09* 44.013/28.97
+    !Config Help = 
+    !               
+    N2O_ppb_omp = 306.
+    CALL getin('N2O_ppb', N2O_ppb_omp)
+    !conversion en rapport de mÃ©lange massique
+    RN2O_omp = N2O_ppb_omp * 1.0E-09 * RMN2O / RMD
+    !
+    !Config Key  = RCFC11
+    !Config Desc = Concentration du CFC11
+    !Config Def  = 280.E-12* 137.3686/28.97
+    !Config Help = 
+    !               
+    CFC11_ppt_omp = 280.
+    CALL getin('CFC11_ppt',CFC11_ppt_omp)
+    !conversion en rapport de mÃ©lange massique
+    RCFC11_omp=CFC11_ppt_omp* 1.0E-12 * RMCFC11 / RMD
+    !
+    !Config Key  = RCFC12
+    !Config Desc = Concentration du CFC12
+    !Config Def  = 484.E-12* 120.9140/28.97
+    !Config Help = 
+    !               
+    CFC12_ppt_omp = 484.
+    CALL getin('CFC12_ppt',CFC12_ppt_omp)
+    !conversion en rapport de mÃ©lange massique
+    RCFC12_omp = CFC12_ppt_omp * 1.0E-12 * RMCFC12 / RMD
+
+    !
+    !Config Key  = co2_ppm_per
+    !Config Desc = concentration du CO2 perturbÃ© en ppmv (CFMIP)
+    !Config Def  = 348.
+    !Config Help = 
+    !               
+    co2_ppm_per_omp = co2_ppm_omp
+    CALL getin('co2_ppm_per', co2_ppm_per_omp)
+    !conversion en rapport de mÃ©lange massique
+    RCO2_per_omp = co2_ppm_per_omp * 1.0e-06 * RMCO2 / RMD
+
+    !Config Key  = RCH4_per
+    !Config Desc = Concentration du CH4_per
+    !Config Def  = 1.65E-06* 16.043/28.97
+    !Config Help = 
+    !               
+    CH4_ppb_per_omp = CH4_ppb_omp
+    CALL getin('CH4_ppb_per', CH4_ppb_per_omp)
+    !conversion en rapport de mÃ©lange massique
+    RCH4_per_omp = CH4_ppb_per_omp * 1.0E-09 * RMCH4 / RMD
+    !
+    !Config Key  = RN2O_per
+    !Config Desc = Concentration du N2O_per
+    !Config Def  = 306.E-09* 44.013/28.97
+    !Config Help = 
+    !               
+    N2O_ppb_per_omp = N2O_ppb_omp
+    CALL getin('N2O_ppb_per', N2O_ppb_per_omp)
+    !conversion en rapport de mÃ©lange massique
+    RN2O_per_omp = N2O_ppb_per_omp * 1.0E-09 * RMN2O / RMD
+    !
+    !Config Key  = RCFC11_per
+    !Config Desc = Concentration du CFC11_per
+    !Config Def  = 280.E-12* 137.3686/28.97
+    !Config Help = 
+    !               
+    CFC11_ppt_per_omp = CFC11_ppt_omp
+    CALL getin('CFC11_ppt_per',CFC11_ppt_per_omp)
+    !conversion en rapport de mÃ©lange massique
+    RCFC11_per_omp=CFC11_ppt_per_omp* 1.0E-12 * RMCFC11 / RMD
+    !
+    !Config Key  = RCFC12_per
+    !Config Desc = Concentration du CFC12_per
+    !Config Def  = 484.E-12* 120.9140/28.97
+    !Config Help = 
+    !               
+    CFC12_ppt_per_omp = CFC12_ppt_omp
+    CALL getin('CFC12_ppt_per',CFC12_ppt_per_omp)
+    !conversion en rapport de mÃ©lange massique
+    RCFC12_per_omp = CFC12_ppt_per_omp * 1.0E-12 * RMCFC12 / RMD
+
+    !
+    ! FH 2008/05/09 On elimine toutes les clefs physiques dans la dynamique
+    ! Constantes precedemment dans dyn3d/conf_gcm
+
+    !Config  Key  = iflag_cycle_diurne
+    !Config  Desc = Cycle diurne
+    !Config  Def  = 1
+    !Config  Help = Cette option permet d'eteidre le cycle diurne.
+    !Config         Peut etre util pour accelerer le code !
+    iflag_cycle_diurne_omp = 1
+    CALL getin('iflag_cycle_diurne',iflag_cycle_diurne_omp)
+
+    !Config  Key  = soil_model
+    !Config  Desc = Modele de sol
+    !Config  Def  = y
+    !Config  Help = Choix du modele de sol (Thermique ?)
+    !Config         Option qui pourait un string afin de pouvoir
+    !Config         plus de choix ! Ou meme une liste d'options !
+    soil_model_omp = .TRUE.
+    CALL getin('soil_model',soil_model_omp)
+
+    !Config  Key  = new_oliq
+    !Config  Desc = Nouvelle eau liquide
+    !Config  Def  = y
+    !Config  Help = Permet de mettre en route la
+    !Config         nouvelle parametrisation de l'eau liquide !
+    new_oliq_omp = .TRUE.
+    CALL getin('new_oliq',new_oliq_omp)
+
+    !Config  Key  = ok_orodr
+    !Config  Desc = Orodr ???
+    !Config  Def  = y
+    !Config  Help = Y en a pas comprendre !
+    !Config         
+    ok_orodr_omp = .TRUE.
+    CALL getin('ok_orodr',ok_orodr_omp)
+
+    !Config  Key  =  ok_orolf
+    !Config  Desc = Orolf ??
+    !Config  Def  = y
+    !Config  Help = Connais pas !
+    ok_orolf_omp = .TRUE.
+    CALL getin('ok_orolf', ok_orolf_omp)
+
+
+    !Config  Key  =  zrel_oro_t
+    !Config  Desc = zrel_oro_t
+    !Config  Def  = 9999.
+    !Config  Help = Connais pas !
+    zrel_oro_t_omp = 9999.
+    CALL getin('zrel_oro_t', zrel_oro_t_omp)
+
+    !Config  Key  =  zstd_orodr_t
+    !Config  Desc = zstd_orodr_t
+    !Config  Def  = 0.
+    !Config  Help = Connais pas !
+    zstd_orodr_t_omp = 10.
+    CALL getin('zstd_orodr_t', zstd_orodr_t_omp)
+
+
+    !Config  Key  =  zpmm_orodr_t
+    !Config  Desc = zpmm_orodr_t
+    !Config  Def  = 0.
+    !Config  Help = Connais pas !
+    zpmm_orodr_t_omp = 100.
+    CALL getin('zpmm_orodr_t', zpmm_orodr_t_omp)
+
+
+    !Config  Key  =  zpmm_orolf_t
+    !Config  Desc = zpmm_orolf_t
+    !Config  Def  = 0.
+    !Config  Help = Connais pas !
+    zpmm_orolf_t_omp = 100.
+    CALL getin('zpmm_orolf_t', zpmm_orolf_t_omp)
+
+    !Config  Key  = ok_limitvrai
+    !Config  Desc = Force la lecture de la bonne annee
+    !Config  Def  = n
+    !Config  Help = On peut forcer le modele a lire le
+    !Config         fichier SST de la bonne annee. C'est une tres bonne
+    !Config         idee, pourquoi ne pas mettre toujours a y ???
+    ok_limitvrai_omp = .FALSE.
+    CALL getin('ok_limitvrai',ok_limitvrai_omp)
+
+    !Config  Key  = nbapp_rad
+    !Config  Desc = Frequence d'appel au rayonnement
+    !Config  Def  = 12
+    !Config  Help = Nombre  d'appels des routines de rayonnements
+    !Config         par jour.
+    nbapp_rad_omp = 12
+    CALL getin('nbapp_rad',nbapp_rad_omp)
+
+    !Config  Key  = iflag_con
+    !Config  Desc = Flag de convection
+    !Config  Def  = 2
+    !Config  Help = Flag  pour la convection les options suivantes existent :
+    !Config         1 pour LMD,
+    !Config         2 pour Tiedtke,
+    !Config         3 pour CCM(NCAR)  
+    iflag_con_omp = 2
+    CALL getin('iflag_con',iflag_con_omp)
+
+    !Config  Key  = nbapp_cv
+    !Config  Desc = Frequence d'appel a la convection
+    !Config  Def  = 0
+    !Config  Help = Nombre  d'appels des routines de convection
+    !Config         par jour. Si =0, appel a chaque pas de temps physique.
+    nbapp_cv_omp = 0
+    CALL getin('nbapp_cv',nbapp_cv_omp)
+
+    !Config  Key  = nbapp_wk
+    !Config  Desc = Frequence d'appel aux wakes
+    !Config  Def  = 0
+    !Config  Help = Nombre  d'appels des routines de wakes
+    !Config         par jour. Si =0, appel a chaque pas de temps physique.
+    nbapp_wk_omp = 0
+    CALL getin('nbapp_wk',nbapp_wk_omp)
+
+    !Config  Key  = iflag_ener_conserv
+    !Config  Desc = Flag de convection
+    !Config  Def  = 1
+    !Config  Help = Flag  pour la convection les options suivantes existent :
+    !Config         -1 pour Kinetic energy correction
+    !Config         1  conservation kinetic and enthalpy
+    iflag_ener_conserv_omp = -1
+    CALL getin('iflag_ener_conserv',iflag_ener_conserv_omp)
+
+    !Config  Key  = ok_conserv_q
+    !Config  Desc = Switch des corrections de conservation de l'eau
+    !Config  Def  = y
+    !Config  Help = Switch des corrections de conservation de l'eau
+    !Config         y -> corrections activees
+    !Config         n -> conformite avec versions anterieures au 1/4/2014
+    ok_conserv_q_omp = .FALSE.
+    CALL getin('ok_conserv_q',ok_conserv_q_omp)
+
+    !Config  Key  = iflag_fisrtilp_qsat
+    !Config  Desc = Flag de fisrtilp
+    !Config  Def  = 0
+    !Config  Help = Flag  pour la pluie grande-Ã©chelle les options suivantes existent :
+    !Config         >1 nb iterations pour converger dans le calcul de qsat
+    iflag_fisrtilp_qsat_omp = 0
+    CALL getin('iflag_fisrtilp_qsat',iflag_fisrtilp_qsat_omp)
+
+    !Config  Key  = iflag_bergeron
+    !Config  Desc = Flag de fisrtilp
+    !Config  Def  = 0
+    !Config  Help = Flag  pour la pluie grande-Ã©chelle les options suivantes existent :
+    !Config         0 pas d effet Bergeron
+    !Config         1 effet Bergeron pour T<0
+    iflag_bergeron_omp = 0
+    CALL getin('iflag_bergeron',iflag_bergeron_omp)
+
+    !
+    !
+    !
+    ! Constante solaire & Parametres orbitaux & taux gaz effet de serre END
+    !
+    ! KE
+    !
+
+    !Config key  = cvl_comp_threshold
+    !Config Desc = maximum fraction of convective points enabling compression
+    !Config Def  = 1.00
+    !Config Help = fields are compressed when less than a fraction cvl_comp_threshold
+    !Config Help = of the points is convective.
+    cvl_comp_threshold_omp = 1.00
+    CALL getin('cvl_comp_threshold', cvl_comp_threshold_omp)
+
+    !Config key  = cvl_sig2feed
+    !Config Desc = sigma coordinate at top of feeding layer
+    !Config Def  = 0.97
+    !Config Help = deep convection is fed by the layer extending from the surface (pressure ps)
+    !Config Help = and cvl_sig2feed*ps.
+    cvl_sig2feed_omp = 0.97
+    CALL getin('cvl_sig2feed', cvl_sig2feed_omp)
+
+    !Config key  = cvl_corr
+    !Config Desc = Facteur multiplication des precip convectives dans KE
+    !Config Def  = 1.00
+    !Config Help = 1.02 pour un moderne ou un pre-ind. A ajuster pour un glaciaire
+    cvl_corr_omp = 1.00
+    CALL getin('cvl_corr', cvl_corr_omp)
+
+
+    !Config Key  = epmax
+    !Config Desc = Efficacite precip
+    !Config Def  = 0.993
+    !Config Help = 
+    !
+    epmax_omp = .993
+    CALL getin('epmax', epmax_omp)
+
+    coef_epmax_cape_omp = 0.0   
+    CALL getin('coef_epmax_cape', coef_epmax_cape_omp)        
+    !
+    !Config Key  = ok_adj_ema
+    !Config Desc =  
+    !Config Def  = FALSE
+    !Config Help = 
+    !
+    ok_adj_ema_omp = .FALSE.
+    CALL getin('ok_adj_ema',ok_adj_ema_omp)
+    !
+    !Config Key  = iflag_clw
+    !Config Desc =  
+    !Config Def  = 0
+    !Config Help = 
+    !
+    iflag_clw_omp = 0
+    CALL getin('iflag_clw',iflag_clw_omp)
+    !
+    !Config Key  = cld_lc_lsc 
+    !Config Desc =  
+    !Config Def  = 2.6e-4
+    !Config Help = 
+    !
+    cld_lc_lsc_omp = 2.6e-4
+    CALL getin('cld_lc_lsc',cld_lc_lsc_omp)
+    !
+    !Config Key  = cld_lc_con
+    !Config Desc =  
+    !Config Def  = 2.6e-4
+    !Config Help = 
+    !
+    cld_lc_con_omp = 2.6e-4
+    CALL getin('cld_lc_con',cld_lc_con_omp)
+    !
+    !Config Key  = cld_tau_lsc
+    !Config Desc =  
+    !Config Def  = 3600.
+    !Config Help = 
+    !
+    cld_tau_lsc_omp = 3600.
+    CALL getin('cld_tau_lsc',cld_tau_lsc_omp)
+    !
+    !Config Key  = cld_tau_con
+    !Config Desc =  
+    !Config Def  = 3600.
+    !Config Help = 
+    !
+    cld_tau_con_omp = 3600.
+    CALL getin('cld_tau_con',cld_tau_con_omp)
+    !
+    !Config Key  = ffallv_lsc
+    !Config Desc =  
+    !Config Def  = 1.
+    !Config Help = 
+    !
+    ffallv_lsc_omp = 1.
+    CALL getin('ffallv_lsc',ffallv_lsc_omp)
+    !
+    !Config Key  = ffallv_con
+    !Config Desc =  
+    !Config Def  = 1.
+    !Config Help = 
+    !
+    ffallv_con_omp = 1.
+    CALL getin('ffallv_con',ffallv_con_omp)
+    !
+    !Config Key  = coef_eva
+    !Config Desc =  
+    !Config Def  = 2.e-5
+    !Config Help = 
+    !
+    coef_eva_omp = 2.e-5
+    CALL getin('coef_eva',coef_eva_omp)
+    !
+    !Config Key  = coef_eva_i
+    !Config Desc =  
+    !Config Def  = 2.e-5
+    !Config Help = 
+    !
+    coef_eva_i_omp = coef_eva_omp
+    CALL getin('coef_eva_i',coef_eva_i_omp)
+    !
+    !Config Key  = reevap_ice
+    !Config Desc =  
+    !Config Def  = .FALSE.
+    !Config Help = 
+    !
+    reevap_ice_omp = .FALSE.
+    CALL getin('reevap_ice',reevap_ice_omp)
+
+    !Config Key  = iflag_ratqs
+    !Config Desc =
+    !Config Def  = 1
+    !Config Help =
+    !
+    iflag_ratqs_omp = 1
+    CALL getin('iflag_ratqs',iflag_ratqs_omp)
+
+    !
+    !Config Key  = iflag_radia 
+    !Config Desc =  
+    !Config Def  = 1
+    !Config Help = 
+    !
+    iflag_radia_omp = 1
+    CALL getin('iflag_radia',iflag_radia_omp)
+
+    !
+    !Config Key  = iflag_rrtm 
+    !Config Desc =  
+    !Config Def  = 0
+    !Config Help = 
+    !
+    iflag_rrtm_omp = 0
+    CALL getin('iflag_rrtm',iflag_rrtm_omp)
+
+    !
+    !Config Key  = NSW 
+    !Config Desc =  
+    !Config Def  = 0
+    !Config Help = 
+    !
+    NSW_omp = 2
+    CALL getin('NSW',NSW_omp)
+    !albedo SB >>>
+    iflag_albedo_omp = 0
+    CALL getin('iflag_albedo',iflag_albedo_omp)
+
+    ok_chlorophyll_omp=.FALSE.
+    CALL getin('ok_chlorophyll',ok_chlorophyll_omp)
+    !albedo SB <<<
+    !
+    !Config Key  = ok_sun_time
+    !Config Desc = oui ou non variabilite solaire
+    !Config Def  = .FALSE.
+    !Config Help =
+    !
+    !
+    !valeur AMIP II
+    ok_suntime_rrtm_omp = .FALSE.
+    IF (iflag_rrtm_omp==1) THEN
+      CALL getin('ok_suntime_rrtm',ok_suntime_rrtm_omp)
+    ENDIF
+    
+    !Config Key  = flag_aerosol_strat
+    !Config Desc = use stratospheric aerosols 0, 1, 2
+    ! - 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 
+    !Config Def  = 0
+    !Config Help = Used in physiq.F
+    !
+    flag_aerosol_strat_omp = 0
+    CALL getin('flag_aerosol_strat',flag_aerosol_strat_omp)
+
+    !Config Key  = flag_aer_feedback
+    !Config Desc = (des)activate aerosol radiative feedback
+    ! - F = no aerosol radiative feedback
+    ! - T = aerosol radiative feedback
+    !Config Def  = T
+    !Config Help = Used in physiq.F
+    !
+    flag_aer_feedback_omp = .TRUE. 
+    IF (iflag_rrtm_omp==1) THEN
+       CALL getin('flag_aer_feedback',flag_aer_feedback_omp)
+    ENDIF
+
+    !Config Key  = iflag_cld_th 
+    !Config Desc =  
+    !Config Def  = 1
+    !Config Help = 
+    !
+    iflag_cld_th_omp = 1
+    ! On lit deux fois avec l'ancien et le nouveau nom 
+    ! pour assurer une retrocompatiblite.
+    ! A abandonner un jour
+    CALL getin('iflag_cldcon',iflag_cld_th_omp)
+    CALL getin('iflag_cld_th',iflag_cld_th_omp)
+    iflag_cld_cv_omp = 0 
+    CALL getin('iflag_cld_cv',iflag_cld_cv_omp)
+
+    !
+    !Config Key  = tau_cld_cv
+    !Config Desc =
+    !Config Def  = 10.
+    !Config Help =
+    !
+    tau_cld_cv_omp = 10.
+    CALL getin('tau_cld_cv',tau_cld_cv_omp)
+
+    !
+    !Config Key  = coefw_cld_cv
+    !Config Desc =
+    !Config Def  = 0.1
+    !Config Help =
+    !
+    coefw_cld_cv_omp = 0.1
+    CALL getin('coefw_cld_cv',coefw_cld_cv_omp)
+
+
+
+
+    !
+    !Config Key  = iflag_pdf 
+    !Config Desc =  
+    !Config Def  = 0
+    !Config Help = 
+    !
+    iflag_pdf_omp = 0
+    CALL getin('iflag_pdf',iflag_pdf_omp)
+    !
+    !Config Key  = fact_cldcon
+    !Config Desc =  
+    !Config Def  = 0.375
+    !Config Help = 
+    !
+    fact_cldcon_omp = 0.375
+    CALL getin('fact_cldcon',fact_cldcon_omp)
+
+    !
+    !Config Key  = facttemps
+    !Config Desc =  
+    !Config Def  = 1.e-4
+    !Config Help = 
+    !
+    facttemps_omp = 1.e-4
+    CALL getin('facttemps',facttemps_omp)
+
+    !
+    !Config Key  = ok_newmicro
+    !Config Desc =  
+    !Config Def  = .TRUE.
+    !Config Help = 
+    !
+    ok_newmicro_omp = .TRUE.
+    CALL getin('ok_newmicro',ok_newmicro_omp)
+    !
+    !Config Key  = ratqsbas
+    !Config Desc =  
+    !Config Def  = 0.01
+    !Config Help = 
+    !
+    ratqsbas_omp = 0.01
+    CALL getin('ratqsbas',ratqsbas_omp)
+    !
+    !Config Key  = ratqshaut
+    !Config Desc =  
+    !Config Def  = 0.3
+    !Config Help = 
+    !
+    ratqshaut_omp = 0.3
+    CALL getin('ratqshaut',ratqshaut_omp)
+
+    !Config Key  = tau_ratqs
+    !Config Desc =  
+    !Config Def  = 1800.
+    !Config Help = 
+    !
+    tau_ratqs_omp = 1800.
+    CALL getin('tau_ratqs',tau_ratqs_omp)
+
+    !
+    !-----------------------------------------------------------------------
+    ! Longitude solaire pour le calcul de l'ensoleillement en degre
+    ! si on veut imposer la saison. Sinon, solarlong0=-999.999
+    !Config Key  = solarlong0
+    !Config Desc =  
+    !Config Def  = -999.999 
+    !Config Help = 
+    !
+    solarlong0_omp = -999.999
+    CALL getin('solarlong0',solarlong0_omp)
+    !
+    !-----------------------------------------------------------------------
+    !  Valeur imposee pour configuration idealisees
+    !Config Key  = qsol0 pour le bucket, evap0 pour aquaplanetes, albsno0
+    ! Default value -1 to activate the full computation
+    qsol0_omp = -1.
+    CALL getin('qsol0',qsol0_omp)
+    evap0_omp = -1.
+    CALL getin('evap0',evap0_omp)
+    albsno0_omp = -1.
+    CALL getin('albsno0',albsno0_omp)
+    !
+    !-----------------------------------------------------------------------
+    !
+    !Config Key  = iflag_sic
+    !Config Desc =  
+    !Config Def  = 0
+    !Config Help = 
+    !
+    iflag_sic_omp = 0
+    CALL getin('iflag_sic',iflag_sic_omp)
+    !
+    !Config Key  = iflag_inertie
+    !Config Desc =
+    !Config Def  = 0
+    !Config Help =
+    !
+    iflag_inertie_omp = 0
+    CALL getin('iflag_inertie',iflag_inertie_omp)
+    !
+    !Config Key  = inertie_sic
+    !Config Desc =  
+    !Config Def  = 2000.
+    !Config Help = 
+    !
+    inertie_sic_omp = 2000.
+    CALL getin('inertie_sic',inertie_sic_omp)
+    !
+    !Config Key  = inertie_lic
+    !Config Desc =  
+    !Config Def  = 2000.
+    !Config Help = 
+    !
+    inertie_lic_omp = 2000.
+    CALL getin('inertie_lic',inertie_lic_omp)
+    !
+    !Config Key  = inertie_sno
+    !Config Desc =  
+    !Config Def  = 2000.
+    !Config Help = 
+    !
+    inertie_sno_omp = 2000.
+    CALL getin('inertie_sno',inertie_sno_omp)
+    !
+    !Config Key  = inertie_sol
+    !Config Desc =  
+    !Config Def  = 2000.
+    !Config Help = 
+    !
+    inertie_sol_omp = 2000.
+    CALL getin('inertie_sol',inertie_sol_omp)
+
+    !
+    !Config Key  = rad_froid
+    !Config Desc =  
+    !Config Def  = 35.0
+    !Config Help = 
+    !
+    rad_froid_omp = 35.0
+    CALL getin('rad_froid',rad_froid_omp)
+
+    !
+    !Config Key  = rad_chau1
+    !Config Desc =  
+    !Config Def  = 13.0
+    !Config Help = 
+    !
+    rad_chau1_omp = 13.0
+    CALL getin('rad_chau1',rad_chau1_omp)
+
+    !
+    !Config Key  = rad_chau2
+    !Config Desc =  
+    !Config Def  = 9.0
+    !Config Help = 
+    !
+    rad_chau2_omp = 9.0
+    CALL getin('rad_chau2',rad_chau2_omp)
+
+    !
+    !Config Key  = t_glace_min
+    !Config Desc =  
+    !Config Def  = 258.
+    !Config Help = 
+    !
+    t_glace_min_omp = 258.
+    CALL getin('t_glace_min',t_glace_min_omp)
+
+    !
+    !Config Key  = t_glace_max
+    !Config Desc =  
+    !Config Def  = 273.13
+    !Config Help = 
+    !
+    t_glace_max_omp = 273.13
+    CALL getin('t_glace_max',t_glace_max_omp)
+
+    !
+    !Config Key  = exposant_glace
+    !Config Desc =  
+    !Config Def  = 2.
+    !Config Help = 
+    !
+    exposant_glace_omp = 1.
+    CALL getin('exposant_glace',exposant_glace_omp)
+
+    !
+    !Config Key  = iflag_gammasat
+    !Config Desc =  
+    !Config Def  = 0
+    !Config Help = 
+    !
+    iflag_gammasat_omp=0
+    CALL getin('iflag_gammasat',iflag_gammasat_omp)
+
+
+    !
+    !Config Key  = iflag_t_glace
+    !Config Desc =  
+    !Config Def  = 0
+    !Config Help = 
+    !
+    iflag_t_glace_omp = 0
+    CALL getin('iflag_t_glace',iflag_t_glace_omp)
+
+    !
+    !Config Key  = iflag_cloudth_vert
+    !Config Desc =  
+    !Config Def  = 0
+    !Config Help = 
+    !
+    iflag_cloudth_vert_omp = 0
+    CALL getin('iflag_cloudth_vert',iflag_cloudth_vert_omp)
+
+    !
+    !Config Key  = iflag_rain_incloud_vol
+    !Config Desc =  
+    !Config Def  = 0
+    !Config Help = 
+    !
+    iflag_rain_incloud_vol_omp = 0
+    CALL getin('iflag_rain_incloud_vol',iflag_rain_incloud_vol_omp)
+
+    !
+    !Config Key  = iflag_vice
+    !Config Desc =  
+    !Config Def  = 0
+    !Config Help = 
+    !
+    iflag_vice_omp = 0
+    CALL getin('iflag_vice',iflag_vice_omp)
+
+    !Config Key  = iflag_rei
+    !Config Desc =  
+    !Config Def  = 0
+    !Config Help = 
+    !
+    iflag_rei_omp = 0
+    CALL getin('iflag_rei',iflag_rei_omp)
+
+
+    !
+    !Config Key  = iflag_ice_thermo
+    !Config Desc =  
+    !Config Def  = 0
+    !Config Help = 
+    !
+    iflag_ice_thermo_omp = 0
+    CALL getin('iflag_ice_thermo',iflag_ice_thermo_omp)
+
+    !
+    !Config Key  = ok_ice_sursat
+    !Config Desc =
+    !Config Def  = 0
+    !Config Help =
+    !
+    ok_ice_sursat_omp = 0
+    CALL getin('ok_ice_sursat',ok_ice_sursat_omp)
+
+    !Config Key  = ok_plane_h2o
+    !Config Desc =
+    !Config Def  = 0
+    !Config Help =
+    !
+    ok_plane_h2o_omp = .FALSE.
+    CALL getin('ok_plane_h2o',ok_plane_h2o_omp)
+
+    !Config Key  = ok_plane_contrail
+    !Config Desc =
+    !Config Def  = 0
+    !Config Help =
+    !
+    ok_plane_contrail_omp = .FALSE.
+    CALL getin('ok_plane_contrail',ok_plane_contrail_omp)
+
+    !
+    !Config Key  = rei_min
+    !Config Desc =  
+    !Config Def  = 3.5
+    !Config Help = 
+    !
+    rei_min_omp = 3.5
+    CALL getin('rei_min',rei_min_omp)
+
+    !
+    !Config Key  = rei_max
+    !Config Desc =  
+    !Config Def  = 61.29
+    !Config Help = 
+    !
+    rei_max_omp = 61.29
+    CALL getin('rei_max',rei_max_omp)
+
+    !
+    !Config Key  = top_height
+    !Config Desc =
+    !Config Def  = 3
+    !Config Help =
+    !
+    top_height_omp = 3
+    CALL getin('top_height',top_height_omp)
+
+    !
+    !Config Key  = overlap
+    !Config Desc =
+    !Config Def  = 3
+    !Config Help =
+    !
+    overlap_omp = 3
+    CALL getin('overlap',overlap_omp)
+
+    !
+    !Config Key  = cdmmax
+    !Config Desc =
+    !Config Def  = 1.3E-3
+    !Config Help =
+    !
+    cdmmax_omp = 1.3E-3
+    CALL getin('cdmmax',cdmmax_omp)
+
+    !
+    !Config Key  = cdhmax
+    !Config Desc =
+    !Config Def  = 1.1E-3
+    !Config Help =
+    !
+    cdhmax_omp = 1.1E-3
+    CALL getin('cdhmax',cdhmax_omp)
+
+    !261103
+    !
+    !Config Key  = ksta
+    !Config Desc =
+    !Config Def  = 1.0e-10
+    !Config Help =
+    !
+    ksta_omp = 1.0e-10
+    CALL getin('ksta',ksta_omp)
+
+    !
+    !Config Key  = ksta_ter
+    !Config Desc =
+    !Config Def  = 1.0e-10
+    !Config Help =
+    !
+    ksta_ter_omp = 1.0e-10
+    CALL getin('ksta_ter',ksta_ter_omp)
+
+    !Config Key  = f_ri_cd_min
+    !Config Desc =
+    !Config Def  = 0.1
+    !Config Help =
+    !
+    f_ri_cd_min_omp = 0.1
+    CALL getin('f_ri_cd_min',f_ri_cd_min_omp)
+
+    !
+    !Config Key  = ok_kzmin
+    !Config Desc =
+    !Config Def  = .TRUE.
+    !Config Help =
+    !
+    ok_kzmin_omp = .TRUE.
+    CALL getin('ok_kzmin',ok_kzmin_omp)
+
+    !
+    !Config Key  = fmagic
+    !Config Desc = additionnal multiplicator factor used for albedo
+    !Config Def  = 1.
+    !Config Help = additionnal multiplicator factor used in albedo.F
+    !
+    fmagic_omp = 1.
+    CALL getin('fmagic',fmagic_omp)
+
+    !
+    !Config Key  = pmagic
+    !Config Desc = additional factor used for albedo
+    !Config Def  = 0.
+    !Config Help = additional factor used in albedo.F
+    !
+    pmagic_omp = 0.
+    CALL getin('pmagic',pmagic_omp)
+
+
+    !Config Key = ok_lic_melt
+    !Config Desc = Prise en compte de la fonte de la calotte dans le bilan d'eau
+    !Config Def  = .FALSE.
+    !Config Help = mettre a .FALSE. pour assurer la conservation en eau
+    ok_lic_melt_omp = .FALSE.
+    CALL getin('ok_lic_melt', ok_lic_melt_omp)
+
+
+    !Config Key = ok_lic_cond
+    !Config Desc = Prise en compte depot de vapeur d'eau sur la calotte dans le bilan d'eau
+    !Config Def  = .FALSE.
+    !Config Help = mettre a .TRUE. pour assurer la conservation en eau
+    ok_lic_cond_omp = .FALSE.
+    CALL getin('ok_lic_cond', ok_lic_cond_omp)
+
+    !
+    ! PARAMETER FOR THE PLANETARY BOUNDARY LAYER
+    !
+
+    !Config Key  = iflag_pbl
+    !Config Desc =
+    !Config Def  = 1
+    !Config Help =
+    !
+    iflag_pbl_omp = 1
+    CALL getin('iflag_pbl',iflag_pbl_omp)
+
+!FC
+    !Config Key  = ifl_pbltree
+    !Config Desc = drag from trees 0 no activated
+    !Config Def  = 0
+    !Config Help =
+    !
+    ifl_pbltree_omp = 0
+    CALL getin('ifl_pbltree',ifl_pbltree_omp)
+!FC
+    !Config Key  = Cd_frein
+    !Config Desc = drag from trees 
+    !Config Def  = 7.5E-02 (valeur Masson mais fait planter avec des LAI eleves)
+    !Config Help =
+    !
+    Cd_frein_omp = 7.5E-02
+    CALL getin('Cd_frein',Cd_frein_omp)
+
+    !
+    !Config Key  = iflag_pbl_split
+    !Config Desc = decimal flag: least signif digit = split vdf; next digit = split thermals
+    !Config Def  = 0
+    !Config Help = 0-> no splitting; 1-> vdf splitting; 10-> thermals splitting; 11-> full splitting
+    !
+    iflag_pbl_split_omp = 0
+    call getin('iflag_pbl_split',iflag_pbl_split_omp)
+    !
+    !Config Key  = iflag_order2_sollw
+    !Config Desc =
+    !Config Def  = 0
+    !Config Help =
+    !
+    iflag_order2_sollw_omp = 0
+    CALL getin('iflag_order2_sollw',iflag_order2_sollw_omp)
+    !
+    !Config Key  = iflag_thermals
+    !Config Desc =
+    !Config Def  = 0
+    !Config Help =
+    !
+    iflag_thermals_omp = 0
+    CALL getin('iflag_thermals',iflag_thermals_omp)
+    !
+    !Config Key  = nsplit_thermals
+    !Config Desc =
+    !Config Def  = 0
+    !Config Help =
+    !
+    nsplit_thermals_omp = 1
+    CALL getin('nsplit_thermals',nsplit_thermals_omp)
+
+    !Config Key  = alp_bl_k
+    !Config Desc =
+    !Config Def  = 0.
+    !Config Help =
+    !
+    alp_bl_k_omp = 1.
+    CALL getin('alp_bl_k',alp_bl_k_omp)
+
+    ! nrlmd le 10/04/2012
+
+    !Config Key  = iflag_trig_bl
+    !Config Desc =  
+    !Config Def  = 0
+    !Config Help = 
+    !
+    iflag_trig_bl_omp = 0
+    CALL getin('iflag_trig_bl',iflag_trig_bl_omp)
+
+    !Config Key  = s_trig_bl
+    !Config Desc =  
+    !Config Def  = 0
+    !Config Help = 
+    !
+    s_trig_omp = 2e7
+    CALL getin('s_trig',s_trig_omp)
+
+    !Config Key  = tau_trig_shallow
+    !Config Desc =  
+    !Config Def  = 0
+    !Config Help = 
+    !
+    tau_trig_shallow_omp = 600
+    CALL getin('tau_trig_shallow',tau_trig_shallow_omp)
+
+    !Config Key  = tau_trig_deep
+    !Config Desc =  
+    !Config Def  = 0
+    !Config Help = 
+    !
+    tau_trig_deep_omp = 1800
+    CALL getin('tau_trig_deep',tau_trig_deep_omp)
+
+    !Config Key  = iflag_clos_bl
+    !Config Desc =  
+    !Config Def  = 0
+    !Config Help = 
+    !
+    iflag_clos_bl_omp = 0
+    CALL getin('iflag_clos_bl',iflag_clos_bl_omp)
+
+    ! fin nrlmd le 10/04/2012
+
+    !
+    !Config Key  = tau_thermals
+    !Config Desc =
+    !Config Def  = 0.
+    !Config Help =
+    !
+    tau_thermals_omp = 0.
+    CALL getin('tau_thermals',tau_thermals_omp)
+
+    !
+    !Config Key  = iflag_coupl
+    !Config Desc =
+    !Config Def  = 0
+    !Config Help =
+    !
+    iflag_coupl_omp = 0
+    CALL getin('iflag_coupl',iflag_coupl_omp)
+
+    !
+    !Config Key  = iflag_clos
+    !Config Desc =  
+    !Config Def  = 0
+    !Config Help = 
+    !
+    iflag_clos_omp = 1
+    CALL getin('iflag_clos',iflag_clos_omp)
+    !
+    !Config Key  = coef_clos_ls
+    !Config Desc =  
+    !Config Def  = 0
+    !Config Help = 
+    !
+    coef_clos_ls_omp = 0.
+    CALL getin('coef_clos_ls',coef_clos_ls_omp)
+
+    !
+    !Config Key  = iflag_cvl_sigd
+    !Config Desc =  
+    !Config Def  = 0
+    !Config Help = 
+    !
+    iflag_cvl_sigd_omp = 0
+    CALL getin('iflag_cvl_sigd',iflag_cvl_sigd_omp)
+
+    !Config Key  = iflag_wake
+    !Config Desc =  
+    !Config Def  = 0
+    !Config Help = 
+    !
+    iflag_wake_omp = 0
+    CALL getin('iflag_wake',iflag_wake_omp)
+
+    !Config Key  = alp_offset
+    !Config Desc =  
+    !Config Def  = 0
+    !Config Help = 
+    !
+    alp_offset_omp = 0.
+    CALL getin('alp_offset',alp_offset_omp)
+
+    !
+    !Config Key  = lev_histhf
+    !Config Desc =
+    !Config Def  = 1
+    !Config Help =
+    !
+    lev_histhf_omp = 1
+    CALL getin('lev_histhf',lev_histhf_omp)
+
+    !
+    !Config Key  = lev_histday
+    !Config Desc =
+    !Config Def  = 1
+    !Config Help =
+    !
+    lev_histday_omp = 1
+    CALL getin('lev_histday',lev_histday_omp)
+
+    !
+    !Config Key  = lev_histmth
+    !Config Desc =
+    !Config Def  = 2
+    !Config Help =
+    !
+    lev_histmth_omp = 2
+    CALL getin('lev_histmth',lev_histmth_omp)
+    !
+    !Config Key  = lev_histins
+    !Config Desc =
+    !Config Def  = 1
+    !Config Help =
+    !
+    lev_histins_omp = 1
+    CALL getin('lev_histins',lev_histins_omp)
+    !
+    !Config Key  = lev_histLES
+    !Config Desc =
+    !Config Def  = 1
+    !Config Help =
+    !
+    lev_histLES_omp = 1
+    CALL getin('lev_histLES',lev_histLES_omp)
+    ! 
+    !Config Key  = lev_histdayNMC
+    !Config Desc =
+    !Config Def  = 8
+    !Config Help =
+    !
+    lev_histdayNMC_omp = 8
+    CALL getin('lev_histdayNMC',lev_histdayNMC_omp)
+    !
+    !Config Key  = levout_histNMC
+    !Config Desc =
+    !Config Def  = 5
+    !Config Help =
+    !
+    levout_histNMC_omp(1) = 5
+    levout_histNMC_omp(2) = 5
+    levout_histNMC_omp(3) = 5
+    CALL getin('levout_histNMC',levout_histNMC_omp)
+    !
+    !histNMC BEG
+    !Config Key  = ok_histNMC
+    !Config Desc = ok_histNMC(1) = frequence de sortie fichiers histmthNMC
+    !Config Desc = ok_histNMC(2) = frequence de sortie fichiers histdayNMC
+    !Config Desc = ok_histNMC(3) = frequence de sortie fichiers histhfNMC
+    !Config Def  = n, n, n
+    !Config Help =
+    !
+    ok_histNMC_omp(1) = .FALSE.
+    ok_histNMC_omp(2) = .FALSE.
+    ok_histNMC_omp(3) = .FALSE.
+    CALL getin('ok_histNMC',ok_histNMC_omp)
+    !
+    !Config Key  = freq_outNMC
+    !Config Desc = freq_outNMC(1) = frequence de sortie fichiers histmthNMC
+    !Config Desc = freq_outNMC(2) = frequence de sortie fichiers histdayNMC
+    !Config Desc = freq_outNMC(3) = frequence de sortie fichiers histhfNMC
+    !Config Def  = 2592000., 86400., 21600. (1mois, 1jour, 6h) 
+    !Config Help =
+    !
+    freq_outNMC_omp(1) = mth_len
+    freq_outNMC_omp(2) = 1.
+    freq_outNMC_omp(3) = 1./4.
+    CALL getin('freq_outNMC',freq_outNMC_omp)
+    !
+    !Config Key  = freq_calNMC
+    !Config Desc = freq_calNMC(1) = frequence de calcul fichiers histmthNMC
+    !Config Desc = freq_calNMC(2) = frequence de calcul fichiers histdayNMC
+    !Config Desc = freq_calNMC(3) = frequence de calcul fichiers histhfNMC
+    !Config Def  = phys_tstep
+    !Config Help =
+    !
+    freq_calNMC_omp(1) = phys_tstep
+    freq_calNMC_omp(2) = phys_tstep
+    freq_calNMC_omp(3) = phys_tstep
+    CALL getin('freq_calNMC',freq_calNMC_omp)
+    !
+    !Config Key  = type_run
+    !Config Desc =
+    !Config Def  = 'AMIP'/'CFMIP'  ou 'CLIM'/'ENSP'
+    !Config Help =
+    !
+    type_run_omp = 'AMIP'
+    CALL getin('type_run',type_run_omp)
+
+    !
+    !Config Key  = ok_cosp
+    !Config Desc =
+    !Config Def  = .FALSE.
+    !Config Help =
+    !
+    ok_cosp_omp = .FALSE.
+    CALL getin('ok_cosp',ok_cosp_omp)
+
+    !
+    !Config Key  = ok_airs
+    !Config Desc =
+    !Config Def  = .FALSE.
+    !Config Help =
+    !
+    ok_airs_omp = .FALSE.
+    CALL getin('ok_airs',ok_airs_omp)
+
+    !
+    !Config Key  = ok_mensuelCOSP
+    !Config Desc =
+    !Config Def  = .TRUE.
+    !Config Help =
+    !
+    ok_mensuelCOSP_omp = .TRUE.
+    CALL getin('ok_mensuelCOSP',ok_mensuelCOSP_omp)
+
+    !
+    !Config Key  = ok_journeCOSP
+    !Config Desc =
+    !Config Def  = .TRUE.
+    !Config Help = 
+    !
+    ok_journeCOSP_omp = .TRUE.
+    CALL getin('ok_journeCOSP',ok_journeCOSP_omp)
+
+    !
+    !Config Key  = ok_hfCOSP
+    !Config Desc =
+    !Config Def  = .FALSE.
+    !Config Help =
+    !
+    ok_hfCOSP_omp = .FALSE.
+    CALL getin('ok_hfCOSP',ok_hfCOSP_omp)
+
+    !
+    ! 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"
+    !
+    !Config Key  = lonmin_ins
+    !Config Desc = 100.  
+    !Config Def  = longitude minimale sorties "bilKP_ins"
+    !Config Help = 
+    !
+    lonmin_ins_omp = 100.
+    CALL getin('lonmin_ins',lonmin_ins_omp)
+    !
+    !Config Key  = lonmax_ins
+    !Config Desc = 130. 
+    !Config Def  = longitude maximale sorties "bilKP_ins"
+    !Config Help =
+    !
+    lonmax_ins_omp = 130.
+    CALL getin('lonmax_ins',lonmax_ins_omp)
+    !
+    !Config Key  = latmin_ins
+    !Config Desc = -20.  
+    !Config Def  = latitude minimale sorties "bilKP_ins"
+    !Config Help = 
+    !
+    latmin_ins_omp = -20.
+    CALL getin('latmin_ins',latmin_ins_omp)
+    !
+    !Config Key  = latmax_ins
+    !Config Desc = 20. 
+    !Config Def  = latitude maximale sorties "bilKP_ins"
+    !Config Help =
+    !
+    latmax_ins_omp = 20.
+    CALL getin('latmax_ins',latmax_ins_omp)
+    !
+    !Config Key  = ecrit_hf
+    !Config Desc =
+    !Config Def  = 1./8. !toutes les 3h
+    !Config Help =
+    !
+    ecrit_hf_omp = 1./8.
+    CALL getin('ecrit_hf',ecrit_hf_omp)
+    !
+    !Config Key  = ecrit_ins
+    !Config Desc =
+    !Config Def  = 1./48. ! toutes les 1/2 h
+    !Config Help =
+    !
+    ecrit_ins_omp = 1./48.
+    CALL getin('ecrit_ins',ecrit_ins_omp)
+    !
+    !Config Key  = ecrit_day
+    !Config Desc =
+    !Config Def  = 1.0 !tous les jours
+    !Config Help = nombre de jours pour ecriture fichier histday.nc
+    !
+    ecrit_day_omp = 1.0
+    CALL getin('ecrit_day',ecrit_day_omp)
+    !
+    !Config Key  = ecrit_mth
+    !Config Desc =
+    !Config Def  = 30. !tous les 30jours (1 fois par mois)
+    !Config Help =
+    !
+    ecrit_mth_omp = 30.
+    CALL getin('ecrit_mth',ecrit_mth_omp)
+    !
+    !Config Key  = ecrit_tra
+    !Config Desc =
+    !Config Def  = 30. !tous les 30jours (1 fois par mois)
+    !Config Help =
+    !
+    ecrit_tra_omp = 0.
+    CALL getin('ecrit_tra',ecrit_tra_omp)
+    !
+    !Config Key  = ecrit_reg
+    !Config Desc =
+    !Config Def  = 0.25  !4 fois par jour
+    !Config Help =
+    !
+    ecrit_reg_omp = 0.25   !4 fois par jour
+    CALL getin('ecrit_reg',ecrit_reg_omp)
+    !
+    !
+    print*,'CONFPHYS OOK avant drag_ter'
+    !
+    ! PARAMETRES CDRAG
+    !
+    f_cdrag_ter_omp = 0.8
+    CALL getin('f_cdrag_ter',f_cdrag_ter_omp)
+    !
+    f_cdrag_oce_omp = 0.8
+    CALL getin('f_cdrag_oce',f_cdrag_oce_omp)
+    !
+
+    ! Gustiness flags
+    f_z0qh_oce_omp = 1.
+    CALL getin('f_z0qh_oce',f_z0qh_oce_omp)
+    !
+    f_qsat_oce_omp = 1.
+    CALL getin('f_qsat_oce',f_qsat_oce_omp)
+    !
+    f_gust_bl_omp = 0.
+    CALL getin('f_gust_bl',f_gust_bl_omp)
+    !
+    f_gust_wk_omp = 0.
+    CALL getin('f_gust_wk',f_gust_wk_omp)
+    !
+    !Config Key  = iflag_z0_oce
+    !Config Desc = 0 (z0h=z0m), 1 (diff. equ. for z0h and z0m), -1 (z0m=z0h=z0min)
+    !Config Def  = 0   ! z0h = z0m
+    !Config Help =
+    !
+    iflag_z0_oce_omp=0
+    CALL getin('iflag_z0_oce',iflag_z0_oce_omp)
+    !
+    iflag_gusts_omp=0
+    CALL getin('iflag_gusts',iflag_gusts_omp)
+    !
+    min_wind_speed_omp = 1.
+    CALL getin('min_wind_speed',min_wind_speed_omp)
+
+    z0m_seaice_omp = 0.002 ; CALL getin('z0m_seaice',z0m_seaice_omp)
+    z0h_seaice_omp = 0.002 ; CALL getin('z0h_seaice',z0h_seaice_omp)
+
+
+    z0m_landice_omp = 0.001 ; CALL getin('z0m_landice',z0m_landice_omp)
+    z0h_landice_omp = 0.001 ; CALL getin('z0h_landice',z0h_landice_omp)
+
+    f_rugoro_omp = 0.
+    CALL getin('f_rugoro',f_rugoro_omp)
+
+    z0min_omp = 0.000015
+    CALL getin('z0min',z0min_omp)
+
+
+    ! PARAMETERS FOR CONVECTIVE INHIBITION BY TROPOS. DRYNESS
+    !
+    !Config Key  = supcrit1
+    !Config Desc =
+    !Config Def  = .540
+    !Config Help =
+    !
+    supcrit1_omp = .540
+    CALL getin('supcrit1',supcrit1_omp)
+
+    !
+    !Config Key  = supcrit2
+    !Config Desc =
+    !Config Def  = .600
+    !Config Help =
+    !
+    supcrit2_omp = .600
+    CALL getin('supcrit2',supcrit2_omp)
+
+    !
+    ! PARAMETERS FOR THE MIXING DISTRIBUTION
+    ! iflag_mix: 0=OLD, 
+    !            1=NEW (JYG),            
+    !            2=NEW + conv. depth inhib. by tropos. dryness
+    ! '2' is NOT operationnal and should not be used.
+    !
+    !Config Key  = iflag_mix
+    !Config Desc =
+    !Config Def  = 1
+    !Config Help =
+    !
+    iflag_mix_omp = 1
+    CALL getin('iflag_mix',iflag_mix_omp)
+
+!
+    ! PARAMETERS FOR THE EROSION OF THE ADIABATIC ASCENTS
+    ! iflag_mix_adiab: 0=OLD, 
+    !                  1=NEW (CR),            
+    !            
+    !
+    !Config Key  = iflag_mix_adiab
+    !Config Desc =
+    !Config Def  = 1
+    !Config Help =
+    !
+    iflag_mix_adiab_omp = 0
+    CALL getin('iflag_mix_adiab',iflag_mix_adiab_omp)
+
+    !
+    !Config Key  = scut
+    !Config Desc =
+    !Config Def  = 0.95
+    !Config Help =
+    !
+    scut_omp = 0.95
+    CALL getin('scut',scut_omp)
+
+    !
+    !Config Key  = qqa1
+    !Config Desc =
+    !Config Def  = 1.0
+    !Config Help =
+    !
+    qqa1_omp = 1.0
+    CALL getin('qqa1',qqa1_omp)
+
+    !
+    !Config Key  = qqa2
+    !Config Desc =
+    !Config Def  = 0.0
+    !Config Help =
+    !
+    qqa2_omp = 0.0
+    CALL getin('qqa2',qqa2_omp)
+
+    !
+    !Config Key  = gammas
+    !Config Desc =
+    !Config Def  = 0.05
+    !Config Help =
+    !
+    gammas_omp = 0.05
+    CALL getin('gammas',gammas_omp)
+
+    !
+    !Config Key  = Fmax
+    !Config Desc =
+    !Config Def  = 0.65
+    !Config Help =
+    !
+    Fmax_omp = 0.65
+    CALL getin('Fmax',Fmax_omp)
+
+    !
+    !Config Key  = tmax_fonte_cv
+    !Config Desc =
+    !Config Def  = 275.15
+    !Config Help =
+    !
+    tmax_fonte_cv_omp = 275.15
+    CALL getin('tmax_fonte_cv',tmax_fonte_cv_omp)
+
+    !
+    !Config Key  = alphas  
+    !Config Desc =
+    !Config Def  = -5.
+    !Config Help =
+    !
+    alphas_omp = -5.
+    CALL getin('alphas',alphas_omp)
+
+    !Config key = ok_strato
+    !Config  Desc = activation de la version strato
+    !Config  Def  = .FALSE.
+    !Config  Help = active la version stratosph\'erique de LMDZ de F. Lott
+    !               Et la sponge layer (Runs Stratospheriques)
+
+    ok_strato_omp=.FALSE.
+    CALL getin('ok_strato',ok_strato_omp)
+
+    !Config  key = ok_hines
+    !Config  Desc = activation de la parametrisation de hines
+    !Config  Def  = .FALSE.
+    !Config  Help = Clefs controlant la parametrization de Hines
+
+    ok_hines_omp=.FALSE.
+    CALL getin('ok_hines',ok_hines_omp)
+
+    !  Parametres pour les ondes de gravite
+    !  
+    !  Subgrid Scale Orography (Lott Miller (1997), Lott (1999))
+
+    sso_gkdrag_omp = merge(0.1875, 0.2, ok_strato_omp)
+    CALL getin('sso_gkdrag', sso_gkdrag_omp)
+
+    sso_grahil_omp=merge(0.1,1.,ok_strato_omp)
+    CALL getin('sso_grahil', sso_grahil_omp)
+
+    sso_grcrit_omp =merge(1.,0.01,ok_strato_omp)
+    CALL getin('sso_grcrit', sso_grcrit_omp)
+
+    sso_gfrcri_omp = 1.
+    CALL getin('sso_gfrcri', sso_gfrcri_omp)
+
+    sso_gkwake_omp = 0.50
+    CALL getin('sso_gkwake', sso_gkwake_omp)
+
+    sso_gklift_omp = merge(0.25,0.50,ok_strato_omp)
+    CALL getin('sso_gklift', sso_gklift_omp)
+
+    ! Random gravity waves:
+
+    ok_gwd_rando_omp = .FALSE.
+    IF ( klon_glo == 1 ) THEN
+       print*,'La parametrisation des ondes de gravites non orographiques'
+       print*,'ne fonctionne pas en 1D'
+    ELSE
+       CALL getin('ok_gwd_rando', ok_gwd_rando_omp)
+    ENDIF
+
+    gwd_rando_ruwmax_omp = 2.00
+    CALL getin('gwd_rando_ruwmax', gwd_rando_ruwmax_omp)
+
+    gwd_rando_sat_omp = 0.25
+    CALL getin('gwd_rando_sat', gwd_rando_sat_omp)
+
+    gwd_front_ruwmax_omp = 2.50
+    CALL getin('gwd_front_ruwmax', gwd_front_ruwmax_omp)
+
+    gwd_front_sat_omp = 0.60
+    CALL getin('gwd_front_sat', gwd_front_sat_omp)
+
+
+    !Config  key = ok_qch4
+    !Config  Desc = activation de la parametrisation du methane
+    !Config  Def  = .FALSE.
+    !Config  Help = Clef controlant l'activation de la parametrisation
+    !               de l'humidite due a oxydation+photolyse du methane strato
+
+    ok_qch4_omp=.FALSE.
+    CALL getin('ok_qch4',ok_qch4_omp)
+
+    !Config Key  = OK_LES                                               
+    !Config Desc = Pour des sorties LES                                 
+    !Config Def  = .FALSE.                                              
+    !Config Help = Pour creer le fichier histLES contenant les sorties  
+    !              LES                                                  
+    !                                                                   
+    ok_LES_omp = .FALSE.                                              
+    CALL getin('OK_LES', ok_LES_omp)                                  
+
+    !Config Key  = callstats                                               
+    !Config Desc = Pour des sorties callstats                                 
+    !Config Def  = .FALSE.                                              
+    !Config Help = Pour creer le fichier stats contenant les sorties  
+    !              stats                                                  
+    !                                                                   
+    callstats_omp = .FALSE.                                              
+    CALL getin('callstats', callstats_omp)                                  
+    !
+    !Config Key  = ecrit_LES
+    !Config Desc = Frequence d'ecriture des resultats du LES en nombre de jours;
+    !              par defaut 1., i.e. 1 jour
+    !Config Def  = 1./8.
+    !Config Help = ... 
+    !
+    !
+    adjust_tropopause = .FALSE.
+    CALL getin('adjust_tropopause', adjust_tropopause_omp)
+    !
+    !Config Key  = adjust_tropopause
+    !Config Desc = Adjust the ozone field from the climoz file by stretching its
+    !              tropopause so that it matches the one of LMDZ.
+    !Config Def  = .FALSE.
+    !Config Help = Ensure tropospheric ozone column conservation.
+    !
+    !
+    ok_daily_climoz = .FALSE.
+    CALL getin('ok_daily_climoz', ok_daily_climoz_omp)
+    !
+    !Config Key  = ok_daily_climoz
+    !Config Desc = Interpolate in time the ozone forcings within ce0l.
+    !              .TRUE. if backward compatibility is needed.
+    !Config Def  = .TRUE.
+    !Config Help = .FALSE. ensure much fewer (no calendar dependency)
+    !  and lighter monthly climoz files, inetrpolated in time at gcm run time.
+    
+    ok_new_lscp_omp = .FALSE.
+    CALL getin('ok_new_lscp', ok_new_lscp_omp)
+    !
+    !Config Key  = ok_new_lscp_omp
+    !Config Desc = new cloud scheme ith ice and mixed phase (Etienne and JB)
+    !Config Def  = .FALSE.
+    !Config Help = ...
+
+
+
+    ok_icefra_lscp_omp = .FALSE.
+    CALL getin('ok_icefra_lscp', ok_icefra_lscp_omp)
+    !
+    !Config Key  = ok_icefra_lscp_omp
+    !Config Desc = ice fraction in radiation from lscp
+    !Config Def  = .FALSE.
+    !Config Help = ...
+
+
+    ecrit_LES_omp = 1./8.
+    CALL getin('ecrit_LES', ecrit_LES_omp)
+    !
+    read_climoz = 0 ! default value
+    CALL getin('read_climoz', read_climoz)
+
+    carbon_cycle_tr_omp=.FALSE.
+    CALL getin('carbon_cycle_tr',carbon_cycle_tr_omp)
+
+    carbon_cycle_cpl_omp=.FALSE.
+    CALL getin('carbon_cycle_cpl',carbon_cycle_cpl_omp)
+
+    carbon_cycle_rad_omp=.FALSE.
+    CALL getin('carbon_cycle_rad',carbon_cycle_rad_omp)
+
+    read_fco2_ocean_cor_omp=.FALSE.
+    CALL getin('read_fco2_ocean_cor',read_fco2_ocean_cor_omp)
+
+    var_fco2_ocean_cor_omp=0. ! default value
+    CALL getin('var_fco2_ocean_cor',var_fco2_ocean_cor_omp)
+
+    read_fco2_land_cor_omp=.FALSE.
+    CALL getin('read_fco2_land_cor',read_fco2_land_cor_omp)
+
+    var_fco2_land_cor_omp=0. ! default value
+    CALL getin('var_fco2_land_cor',var_fco2_land_cor_omp)
+
+    ! 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_omp=0 ! default value
+    CALL getin('level_coupling_esm',level_coupling_esm_omp)
+
+    dms_cycle_cpl_omp=.FALSE.
+    CALL getin('dms_cycle_cpl',dms_cycle_cpl_omp)
+
+
+    
+    !$OMP END MASTER
+    !$OMP BARRIER
+
+    R_ecc = R_ecc_omp
+    R_peri = R_peri_omp
+    R_incl = R_incl_omp
+    solaire = solaire_omp
+    ok_suntime_rrtm = ok_suntime_rrtm_omp
+    co2_ppm = co2_ppm_omp
+    co2_ppm0 = co2_ppm0_omp
+    RCO2 = RCO2_omp
+    CH4_ppb = CH4_ppb_omp
+    RCH4 = RCH4_omp
+    N2O_ppb = N2O_ppb_omp
+    RN2O = RN2O_omp
+    CFC11_ppt = CFC11_ppt_omp
+    RCFC11 = RCFC11_omp
+    CFC12_ppt = CFC12_ppt_omp
+    RCFC12 = RCFC12_omp
+    RCO2_act = RCO2
+    RCH4_act = RCH4
+    RN2O_act = RN2O
+    RCFC11_act = RCFC11
+    RCFC12_act = RCFC12
+    RCO2_per = RCO2_per_omp
+    RCH4_per = RCH4_per_omp
+    RN2O_per = RN2O_per_omp
+    RCFC11_per = RCFC11_per_omp
+    RCFC12_per = RCFC12_per_omp
+
+    iflag_cycle_diurne = iflag_cycle_diurne_omp
+    soil_model = soil_model_omp
+    new_oliq = new_oliq_omp
+    ok_orodr = ok_orodr_omp
+    ok_orolf = ok_orolf_omp
+    zrel_oro_t=zrel_oro_t_omp
+    zstd_orodr_t=zstd_orodr_t_omp
+    zpmm_orodr_t=zpmm_orodr_t_omp
+    zpmm_orolf_t=zpmm_orolf_t_omp
+    ok_limitvrai = ok_limitvrai_omp
+    nbapp_rad = nbapp_rad_omp
+    iflag_con = iflag_con_omp
+    nbapp_cv = nbapp_cv_omp
+    nbapp_wk = nbapp_wk_omp
+    iflag_ener_conserv = iflag_ener_conserv_omp
+    ok_conserv_q = ok_conserv_q_omp
+    iflag_fisrtilp_qsat = iflag_fisrtilp_qsat_omp
+    iflag_bergeron = iflag_bergeron_omp
+
+    epmax = epmax_omp
+    coef_epmax_cape = coef_epmax_cape_omp
+    ok_adj_ema = ok_adj_ema_omp
+    iflag_clw = iflag_clw_omp
+    cld_lc_lsc = cld_lc_lsc_omp
+    cld_lc_con = cld_lc_con_omp
+    cld_tau_lsc = cld_tau_lsc_omp
+    cld_tau_con = cld_tau_con_omp
+    ffallv_lsc = ffallv_lsc_omp
+    ffallv_con = ffallv_con_omp
+    coef_eva = coef_eva_omp
+    coef_eva_i = coef_eva_i_omp
+    reevap_ice = reevap_ice_omp
+    iflag_pdf = iflag_pdf_omp
+    solarlong0 = solarlong0_omp
+    qsol0 = qsol0_omp
+    evap0 = evap0_omp
+    albsno0 = albsno0_omp
+    iflag_sic = iflag_sic_omp
+    iflag_inertie = iflag_inertie_omp
+    inertie_sol = inertie_sol_omp
+    inertie_sic = inertie_sic_omp
+    inertie_lic = inertie_lic_omp
+    inertie_sno = inertie_sno_omp
+    rad_froid = rad_froid_omp
+    rad_chau1 = rad_chau1_omp
+    rad_chau2 = rad_chau2_omp
+    t_glace_min = t_glace_min_omp
+    t_glace_max = t_glace_max_omp
+    exposant_glace = exposant_glace_omp
+    iflag_gammasat=iflag_gammasat_omp
+    iflag_t_glace = iflag_t_glace_omp
+    iflag_cloudth_vert=iflag_cloudth_vert_omp
+    iflag_rain_incloud_vol=iflag_rain_incloud_vol_omp
+    iflag_vice=iflag_vice_omp
+    iflag_rei=iflag_rei_omp
+    iflag_ice_thermo = iflag_ice_thermo_omp
+    ok_ice_sursat = ok_ice_sursat_omp
+    ok_plane_h2o = ok_plane_h2o_omp
+    ok_plane_contrail = ok_plane_contrail_omp
+    rei_min = rei_min_omp
+    rei_max = rei_max_omp
+    top_height = top_height_omp
+    overlap = overlap_omp
+    cdmmax = cdmmax_omp
+    cdhmax = cdhmax_omp
+    ksta = ksta_omp
+    ksta_ter = ksta_ter_omp
+    f_ri_cd_min = f_ri_cd_min_omp
+    ok_kzmin = ok_kzmin_omp
+    fmagic = fmagic_omp
+    pmagic = pmagic_omp
+    iflag_pbl = iflag_pbl_omp
+    iflag_pbl_split = iflag_pbl_split_omp
+!FC
+    ifl_pbltree = ifl_pbltree_omp
+    Cd_frein    =Cd_frein_omp
+    iflag_order2_sollw = iflag_order2_sollw_omp
+    lev_histhf = lev_histhf_omp
+    lev_histday = lev_histday_omp
+    lev_histmth = lev_histmth_omp
+    lev_histins = lev_histins_omp
+    lev_histLES = lev_histLES_omp
+    lev_histdayNMC = lev_histdayNMC_omp
+    levout_histNMC = levout_histNMC_omp
+    ok_histNMC(:) = ok_histNMC_omp(:)
+    freq_outNMC(:) = freq_outNMC_omp(:)
+    freq_calNMC(:) = freq_calNMC_omp(:)
+
+    type_ocean = type_ocean_omp
+    version_ocean = version_ocean_omp
+    t_coupl = t_coupl_omp
+
+    ok_veget=.TRUE.
+    type_veget=type_veget_omp
+    IF (type_veget=='n' .or. type_veget=='bucket' .or. type_veget=='betaclim') THEN
+       ok_veget=.FALSE.
+    ENDIF
+    ! INLANDSIS
+    !=================================================
+    landice_opt = landice_opt_omp
+    iflag_tsurf_inlandsis = iflag_tsurf_inlandsis_omp
+    iflag_temp_inlandsis = iflag_temp_inlandsis_omp
+    iflag_albcalc = iflag_albcalc_omp
+    SnoMod=SnoMod_omp
+    BloMod=BloMod_omp
+    ok_outfor=ok_outfor_omp
+    is_ok_slush=is_ok_slush_omp
+    opt_runoff_ac=opt_runoff_ac_omp
+    is_ok_z0h_rn=is_ok_z0h_rn_omp
+    is_ok_density_kotlyakov=is_ok_density_kotlyakov_omp
+    prescribed_z0m_snow=prescribed_z0m_snow_omp
+    correc_alb=correc_alb_omp
+    iflag_z0m_snow=iflag_z0m_snow_omp
+    ok_zsn_ii=ok_zsn_ii_omp
+    discret_xf=discret_xf_omp
+    buf_sph_pol=buf_sph_pol_omp
+    buf_siz_pol=buf_siz_pol_omp
+    !=================================================
+    ok_all_xml = ok_all_xml_omp
+    ok_lwoff = ok_lwoff_omp
+    ok_newmicro = ok_newmicro_omp
+    ok_journe = ok_journe_omp
+    ok_hf = ok_hf_omp
+    ok_mensuel = ok_mensuel_omp
+    ok_instan = ok_instan_omp
+    freq_ISCCP = freq_ISCCP_omp
+    ecrit_ISCCP = ecrit_ISCCP_omp
+    freq_COSP = freq_COSP_omp
+    freq_AIRS = freq_AIRS_omp
+    ok_ade = ok_ade_omp
+    ok_aie = ok_aie_omp
+    ok_alw = ok_alw_omp
+    ok_cdnc = ok_cdnc_omp
+    ok_volcan = ok_volcan_omp
+    flag_volc_surfstrat = flag_volc_surfstrat_omp
+    aerosol_couple = aerosol_couple_omp
+    chemistry_couple = chemistry_couple_omp
+    flag_aerosol = flag_aerosol_omp
+    flag_aerosol_strat = flag_aerosol_strat_omp
+    flag_aer_feedback = flag_aer_feedback_omp
+    flag_bc_internal_mixture=flag_bc_internal_mixture_omp
+    aer_type = aer_type_omp
+    bl95_b0 = bl95_b0_omp
+    bl95_b1 = bl95_b1_omp
+    fact_cldcon = fact_cldcon_omp
+    facttemps = facttemps_omp
+    ratqsbas = ratqsbas_omp
+    ratqshaut = ratqshaut_omp
+    tau_ratqs = tau_ratqs_omp
+
+    iflag_radia = iflag_radia_omp
+    iflag_rrtm = iflag_rrtm_omp
+    iflag_albedo = iflag_albedo_omp
+    ok_chlorophyll = ok_chlorophyll_omp
+    NSW = NSW_omp
+    iflag_cld_th = iflag_cld_th_omp
+    iflag_cld_cv = iflag_cld_cv_omp
+    tau_cld_cv = tau_cld_cv_omp
+    coefw_cld_cv = coefw_cld_cv_omp
+    iflag_ratqs = iflag_ratqs_omp
+    ip_ebil_phy = ip_ebil_phy_omp
+    iflag_thermals = iflag_thermals_omp
+    nsplit_thermals = nsplit_thermals_omp
+    tau_thermals = tau_thermals_omp
+    alp_bl_k = alp_bl_k_omp
+    ! nrlmd le 10/04/2012
+    iflag_trig_bl = iflag_trig_bl_omp
+    s_trig = s_trig_omp
+    tau_trig_shallow = tau_trig_shallow_omp
+    tau_trig_deep = tau_trig_deep_omp
+    iflag_clos_bl = iflag_clos_bl_omp
+    ! fin nrlmd le 10/04/2012
+    iflag_coupl = iflag_coupl_omp
+    iflag_clos = iflag_clos_omp
+    iflag_wake = iflag_wake_omp
+    coef_clos_ls = coef_clos_ls_omp
+    alp_offset = alp_offset_omp
+    iflag_cvl_sigd = iflag_cvl_sigd_omp
+    type_run = type_run_omp
+    ok_cosp = ok_cosp_omp
+    ok_airs = ok_airs_omp
+
+    ok_mensuelCOSP = ok_mensuelCOSP_omp
+    ok_journeCOSP = ok_journeCOSP_omp
+    ok_hfCOSP = ok_hfCOSP_omp
+    seuil_inversion=seuil_inversion_omp
+    lonmin_ins = lonmin_ins_omp
+    lonmax_ins = lonmax_ins_omp
+    latmin_ins = latmin_ins_omp
+    latmax_ins = latmax_ins_omp
+    ecrit_hf   = ecrit_hf_omp
+    ecrit_ins   = ecrit_ins_omp
+    ecrit_day = ecrit_day_omp
+    ecrit_mth = ecrit_mth_omp
+    ecrit_tra = ecrit_tra_omp
+    ecrit_reg = ecrit_reg_omp
+    cvl_comp_threshold = cvl_comp_threshold_omp
+    cvl_sig2feed = cvl_sig2feed_omp
+    cvl_corr = cvl_corr_omp
+    ok_lic_melt = ok_lic_melt_omp
+    ok_lic_cond = ok_lic_cond_omp
+    f_cdrag_ter=f_cdrag_ter_omp
+    f_cdrag_oce=f_cdrag_oce_omp
+
+    f_gust_wk=f_gust_wk_omp
+    f_gust_bl=f_gust_bl_omp
+    f_qsat_oce=f_qsat_oce_omp
+    f_z0qh_oce=f_z0qh_oce_omp
+    min_wind_speed=min_wind_speed_omp
+    iflag_gusts=iflag_gusts_omp
+    iflag_z0_oce=iflag_z0_oce_omp
+
+    z0m_seaice=z0m_seaice_omp
+    z0h_seaice=z0h_seaice_omp
+    z0m_landice=z0m_landice_omp
+    z0h_landice=z0h_landice_omp
+
+    f_rugoro=f_rugoro_omp
+
+    z0min=z0min_omp
+    supcrit1 = supcrit1_omp
+    supcrit2 = supcrit2_omp
+    iflag_mix = iflag_mix_omp
+    iflag_mix_adiab = iflag_mix_adiab_omp
+    scut = scut_omp
+    qqa1 = qqa1_omp
+    qqa2 = qqa2_omp
+    gammas = gammas_omp
+    Fmax = Fmax_omp
+    tmax_fonte_cv = tmax_fonte_cv_omp
+    alphas = alphas_omp
+
+    gkdrag=sso_gkdrag_omp
+    grahilo=sso_grahil_omp
+    grcrit=sso_grcrit_omp
+    gfrcrit=sso_gfrcri_omp
+    gkwake=sso_gkwake_omp 
+    gklift=sso_gklift_omp 
+
+    ok_strato = ok_strato_omp
+    ok_hines = ok_hines_omp
+    ok_gwd_rando = ok_gwd_rando_omp
+    gwd_rando_ruwmax = gwd_rando_ruwmax_omp
+    gwd_rando_sat = gwd_rando_sat_omp
+    gwd_front_ruwmax = gwd_front_ruwmax_omp
+    gwd_front_sat = gwd_front_sat_omp
+    ok_qch4 = ok_qch4_omp
+    ok_LES = ok_LES_omp
+    callstats = callstats_omp
+    ecrit_LES = ecrit_LES_omp
+    adjust_tropopause = adjust_tropopause_omp
+    ok_daily_climoz = ok_daily_climoz_omp
+    carbon_cycle_tr = carbon_cycle_tr_omp
+    carbon_cycle_cpl = carbon_cycle_cpl_omp
+    carbon_cycle_rad = carbon_cycle_rad_omp
+    level_coupling_esm = level_coupling_esm_omp
+    ok_new_lscp = ok_new_lscp_omp
+    ok_icefra_lscp=ok_icefra_lscp_omp
+    read_fco2_ocean_cor = read_fco2_ocean_cor_omp
+    var_fco2_ocean_cor = var_fco2_ocean_cor_omp
+    read_fco2_land_cor = read_fco2_land_cor_omp
+    var_fco2_land_cor = var_fco2_land_cor_omp
+    dms_cycle_cpl = dms_cycle_cpl_omp
+
+    ! 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,*) ' 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,*) ' 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,*) ' 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,*) ' 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
+!    IF (ok_suntime_rrtm.AND.ABS(solaire-solaire_omp_init).GT.1.E-7) THEN 
+!       WRITE(lunout,*) ' 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
+#ifdef CPP_StratAer
+    IF (iflag_rrtm .NE. 1) THEN 
+       WRITE(lunout,*) ' 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,*) ' ERROR NSW<>6 but StratAer activated'
+       CALL abort_physic('conf_phys','NSW not valid for StratAer',1)
+    ENDIF
+#endif
+
+    !--test on ocean surface albedo
+    IF (iflag_albedo.LT.0.OR.iflag_albedo.GT.2) THEN
+       WRITE(lunout,*) ' 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
+
+    ! Test on chemistry cycle 
+    IF (type_trac .ne. inca .AND. dms_cycle_cpl ) THEN 
+       CALL abort_physic('conf_phys', 'dms_cycle_cpl has to 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
+
+    !$OMP MASTER
+
+    WRITE(lunout,*) ' ##############################################'
+    WRITE(lunout,*) ' Configuration des parametres de la physique: '
+    WRITE(lunout,*) ' Type ocean = ', type_ocean
+    WRITE(lunout,*) ' Version ocean = ', version_ocean
+    WRITE(lunout,*) ' Config veget = ', ok_veget,type_veget
+    WRITE(lunout,*) ' Snow model landice : landice_opt = ', landice_opt
+    WRITE(lunout,*) ' Config xml pour XIOS : ok_all_xml = ', ok_all_xml
+    WRITE(lunout,*) ' Sortie journaliere = ', ok_journe
+    WRITE(lunout,*) ' Sortie haute frequence = ', ok_hf
+    WRITE(lunout,*) ' Sortie mensuelle = ', ok_mensuel
+    WRITE(lunout,*) ' Sortie instantanee = ', ok_instan
+    WRITE(lunout,*) ' Frequence appel simulateur ISCCP, freq_ISCCP =', freq_ISCCP
+    WRITE(lunout,*) ' Frequence appel simulateur ISCCP, ecrit_ISCCP =', ecrit_ISCCP
+    WRITE(lunout,*) ' Frequence appel simulateur COSP, freq_COSP =', freq_COSP
+    WRITE(lunout,*) ' Frequence appel simulateur AIRS, freq_AIRS =', freq_AIRS
+    WRITE(lunout,*) ' Sortie bilan d''energie, ip_ebil_phy =', ip_ebil_phy
+    WRITE(lunout,*) ' Excentricite = ',R_ecc
+    WRITE(lunout,*) ' Equinoxe = ',R_peri
+    WRITE(lunout,*) ' Inclinaison =',R_incl
+    WRITE(lunout,*) ' Constante solaire =',solaire
+    WRITE(lunout,*) ' ok_suntime_rrtm =',ok_suntime_rrtm
+    WRITE(lunout,*) ' co2_ppm =',co2_ppm
+    WRITE(lunout,*) ' co2_ppm0 =',co2_ppm0
+    WRITE(lunout,*) ' RCO2_act = ',RCO2_act
+    WRITE(lunout,*) ' CH4_ppb =',CH4_ppb,' RCH4_act = ',RCH4_act
+    WRITE(lunout,*) ' N2O_ppb =',N2O_ppb,' RN2O_act=  ',RN2O_act
+    WRITE(lunout,*) ' CFC11_ppt=',CFC11_ppt,' RCFC11_act=  ',RCFC11_act
+    WRITE(lunout,*) ' CFC12_ppt=',CFC12_ppt,' RCFC12_act=  ',RCFC12_act
+    WRITE(lunout,*) ' RCO2_per = ',RCO2_per,' RCH4_per = ', RCH4_per
+    WRITE(lunout,*) ' RN2O_per = ',RN2O_per,' RCFC11_per = ', RCFC11_per
+    WRITE(lunout,*) ' RCFC12_per = ',RCFC12_per
+    WRITE(lunout,*) ' cvl_comp_threshold=', cvl_comp_threshold
+    WRITE(lunout,*) ' cvl_sig2feed=', cvl_sig2feed
+    WRITE(lunout,*) ' cvl_corr=', cvl_corr
+    WRITE(lunout,*) ' ok_lic_melt=', ok_lic_melt
+    WRITE(lunout,*) ' ok_lic_cond=', ok_lic_cond
+    WRITE(lunout,*) ' iflag_cycle_diurne=',iflag_cycle_diurne
+    WRITE(lunout,*) ' soil_model=',soil_model
+    WRITE(lunout,*) ' new_oliq=',new_oliq
+    WRITE(lunout,*) ' ok_orodr=',ok_orodr
+    WRITE(lunout,*) ' ok_orolf=',ok_orolf
+    WRITE(lunout,*) ' zrel_oro_t=',zrel_oro_t
+    WRITE(lunout,*) ' zstd_orodr_t=',zstd_orodr_t
+    WRITE(lunout,*) ' zpmm_orodr_t=',zpmm_orodr_t
+    WRITE(lunout,*) ' zpmm_orolf_t=',zpmm_orolf_t
+    WRITE(lunout,*) ' ok_limitvrai=',ok_limitvrai
+    WRITE(lunout,*) ' nbapp_rad=',nbapp_rad
+    WRITE(lunout,*) ' iflag_con=',iflag_con
+    WRITE(lunout,*) ' nbapp_cv=',nbapp_cv
+    WRITE(lunout,*) ' nbapp_wk=',nbapp_wk
+    WRITE(lunout,*) ' iflag_ener_conserv=',iflag_ener_conserv
+    WRITE(lunout,*) ' ok_conserv_q=',ok_conserv_q
+    WRITE(lunout,*) ' iflag_fisrtilp_qsat=',iflag_fisrtilp_qsat
+    WRITE(lunout,*) ' iflag_bergeron=',iflag_bergeron
+    WRITE(lunout,*) ' epmax = ', epmax
+    WRITE(lunout,*) ' coef_epmax_cape = ', coef_epmax_cape
+    WRITE(lunout,*) ' ok_adj_ema = ', ok_adj_ema
+    WRITE(lunout,*) ' iflag_clw = ', iflag_clw
+    WRITE(lunout,*) ' cld_lc_lsc = ', cld_lc_lsc
+    WRITE(lunout,*) ' cld_lc_con = ', cld_lc_con
+    WRITE(lunout,*) ' cld_tau_lsc = ', cld_tau_lsc
+    WRITE(lunout,*) ' cld_tau_con = ', cld_tau_con
+    WRITE(lunout,*) ' ffallv_lsc = ', ffallv_lsc
+    WRITE(lunout,*) ' ffallv_con = ', ffallv_con
+    WRITE(lunout,*) ' coef_eva = ', coef_eva
+    WRITE(lunout,*) ' coef_eva_i = ', coef_eva_i
+    WRITE(lunout,*) ' reevap_ice = ', reevap_ice
+    WRITE(lunout,*) ' iflag_pdf = ', iflag_pdf
+    WRITE(lunout,*) ' iflag_cld_th = ', iflag_cld_th
+    WRITE(lunout,*) ' iflag_cld_cv = ', iflag_cld_cv
+    WRITE(lunout,*) ' tau_cld_cv = ', tau_cld_cv
+    WRITE(lunout,*) ' coefw_cld_cv = ', coefw_cld_cv
+    WRITE(lunout,*) ' iflag_radia = ', iflag_radia
+    WRITE(lunout,*) ' iflag_rrtm = ', iflag_rrtm
+    WRITE(lunout,*) ' NSW = ', NSW
+    WRITE(lunout,*) ' iflag_albedo = ', iflag_albedo !albedo SB
+    WRITE(lunout,*) ' ok_chlorophyll =',ok_chlorophyll ! albedo SB
+    WRITE(lunout,*) ' iflag_ratqs = ', iflag_ratqs
+    WRITE(lunout,*) ' seuil_inversion = ', seuil_inversion
+    WRITE(lunout,*) ' fact_cldcon = ', fact_cldcon
+    WRITE(lunout,*) ' facttemps = ', facttemps
+    WRITE(lunout,*) ' ok_newmicro = ',ok_newmicro 
+    WRITE(lunout,*) ' ratqsbas = ',ratqsbas 
+    WRITE(lunout,*) ' ratqshaut = ',ratqshaut 
+    WRITE(lunout,*) ' tau_ratqs = ',tau_ratqs 
+    WRITE(lunout,*) ' top_height = ',top_height 
+    WRITE(lunout,*) ' rad_froid = ',rad_froid
+    WRITE(lunout,*) ' rad_chau1 = ',rad_chau1
+    WRITE(lunout,*) ' rad_chau2 = ',rad_chau2
+    WRITE(lunout,*) ' t_glace_min = ',t_glace_min
+    WRITE(lunout,*) ' t_glace_max = ',t_glace_max
+    WRITE(lunout,*) ' exposant_glace = ',exposant_glace
+    WRITE(lunout,*) ' iflag_gammasat = ',iflag_gammasat
+    WRITE(lunout,*) ' iflag_t_glace = ',iflag_t_glace
+    WRITE(lunout,*) ' iflag_cloudth_vert = ',iflag_cloudth_vert
+    WRITE(lunout,*) ' iflag_rain_incloud_vol = ',iflag_rain_incloud_vol
+    WRITE(lunout,*) ' iflag_vice = ',iflag_vice
+    WRITE(lunout,*) ' iflag_rei = ',iflag_rei
+    WRITE(lunout,*) ' iflag_ice_thermo = ',iflag_ice_thermo
+    WRITE(lunout,*) ' ok_ice_sursat = ',ok_ice_sursat
+    WRITE(lunout,*) ' ok_plane_h2o = ',ok_plane_h2o
+    WRITE(lunout,*) ' ok_plane_contrail = ',ok_plane_contrail
+    WRITE(lunout,*) ' rei_min = ',rei_min
+    WRITE(lunout,*) ' rei_max = ',rei_max
+    WRITE(lunout,*) ' overlap = ',overlap 
+    WRITE(lunout,*) ' cdmmax = ',cdmmax 
+    WRITE(lunout,*) ' cdhmax = ',cdhmax 
+    WRITE(lunout,*) ' ksta = ',ksta 
+    WRITE(lunout,*) ' ksta_ter = ',ksta_ter 
+    WRITE(lunout,*) ' f_ri_cd_min = ',f_ri_cd_min 
+    WRITE(lunout,*) ' ok_kzmin = ',ok_kzmin 
+    WRITE(lunout,*) ' fmagic = ',fmagic
+    WRITE(lunout,*) ' pmagic = ',pmagic
+    WRITE(lunout,*) ' ok_ade = ',ok_ade
+    WRITE(lunout,*) ' ok_volcan = ',ok_volcan
+    WRITE(lunout,*) ' flag_volc_surfstrat = ',flag_volc_surfstrat
+    WRITE(lunout,*) ' ok_aie = ',ok_aie
+    WRITE(lunout,*) ' ok_alw = ',ok_alw
+    WRITE(lunout,*) ' aerosol_couple = ', aerosol_couple
+    WRITE(lunout,*) ' chemistry_couple = ', chemistry_couple
+    WRITE(lunout,*) ' flag_aerosol = ', flag_aerosol
+    WRITE(lunout,*) ' flag_aerosol_strat= ', flag_aerosol_strat
+    WRITE(lunout,*) ' flag_aer_feedback= ', flag_aer_feedback
+    WRITE(lunout,*) ' aer_type = ',aer_type
+    WRITE(lunout,*) ' bl95_b0 = ',bl95_b0
+    WRITE(lunout,*) ' bl95_b1 = ',bl95_b1
+    WRITE(lunout,*) ' lev_histhf = ',lev_histhf 
+    WRITE(lunout,*) ' lev_histday = ',lev_histday 
+    WRITE(lunout,*) ' lev_histmth = ',lev_histmth 
+    WRITE(lunout,*) ' lev_histins = ',lev_histins
+    WRITE(lunout,*) ' lev_histLES = ',lev_histLES
+    WRITE(lunout,*) ' lev_histdayNMC = ',lev_histdayNMC
+    WRITE(lunout,*) ' levout_histNMC = ',levout_histNMC
+    WRITE(lunout,*) ' ok_histNMC = ',ok_histNMC
+    WRITE(lunout,*) ' freq_outNMC = ',freq_outNMC
+    WRITE(lunout,*) ' freq_calNMC = ',freq_calNMC
+    WRITE(lunout,*) ' iflag_pbl = ', iflag_pbl
+!FC
+    WRITE(lunout,*) ' ifl_pbltree = ', ifl_pbltree
+    WRITE(lunout,*) ' Cd_frein = ', Cd_frein
+    WRITE(lunout,*) ' iflag_pbl_split = ', iflag_pbl_split
+    WRITE(lunout,*) ' iflag_order2_sollw = ', iflag_order2_sollw
+    WRITE(lunout,*) ' iflag_thermals = ', iflag_thermals
+    WRITE(lunout,*) ' iflag_clos = ', iflag_clos
+    WRITE(lunout,*) ' coef_clos_ls = ', coef_clos_ls
+    WRITE(lunout,*) ' type_run = ',type_run 
+    WRITE(lunout,*) ' ok_cosp = ',ok_cosp
+    WRITE(lunout,*) ' ok_airs = ',ok_airs
+
+    WRITE(lunout,*) ' ok_mensuelCOSP = ',ok_mensuelCOSP
+    WRITE(lunout,*) ' ok_journeCOSP = ',ok_journeCOSP
+    WRITE(lunout,*) ' ok_hfCOSP =',ok_hfCOSP
+    WRITE(lunout,*) ' solarlong0 = ', solarlong0
+    WRITE(lunout,*) ' qsol0 = ', qsol0
+    WRITE(lunout,*) ' evap0 = ', evap0
+    WRITE(lunout,*) ' albsno0 = ', albsno0
+    WRITE(lunout,*) ' iflag_sic = ', iflag_sic
+    WRITE(lunout,*) ' iflag_inertie = ', iflag_inertie
+    WRITE(lunout,*) ' inertie_sol = ', inertie_sol
+    WRITE(lunout,*) ' inertie_sic = ', inertie_sic
+    WRITE(lunout,*) ' inertie_lic = ', inertie_lic
+    WRITE(lunout,*) ' inertie_sno = ', inertie_sno
+    WRITE(lunout,*) ' f_cdrag_ter = ',f_cdrag_ter
+    WRITE(lunout,*) ' f_cdrag_oce = ',f_cdrag_oce
+    WRITE(lunout,*) ' f_rugoro = ',f_rugoro
+    WRITE(lunout,*) ' z0min = ',z0min
+    WRITE(lunout,*) ' supcrit1 = ', supcrit1
+    WRITE(lunout,*) ' supcrit2 = ', supcrit2
+    WRITE(lunout,*) ' iflag_mix = ', iflag_mix
+    WRITE(lunout,*) ' iflag_mix_adiab = ', iflag_mix_adiab
+    WRITE(lunout,*) ' scut = ', scut
+    WRITE(lunout,*) ' qqa1 = ', qqa1
+    WRITE(lunout,*) ' qqa2 = ', qqa2
+    WRITE(lunout,*) ' gammas = ', gammas
+    WRITE(lunout,*) ' Fmax = ', Fmax
+    WRITE(lunout,*) ' tmax_fonte_cv = ', tmax_fonte_cv
+    WRITE(lunout,*) ' alphas = ', alphas
+    WRITE(lunout,*) ' iflag_wake = ', iflag_wake
+    WRITE(lunout,*) ' alp_offset = ', alp_offset
+    ! nrlmd le 10/04/2012
+    WRITE(lunout,*) ' iflag_trig_bl = ', iflag_trig_bl
+    WRITE(lunout,*) ' s_trig = ', s_trig
+    WRITE(lunout,*) ' tau_trig_shallow = ', tau_trig_shallow
+    WRITE(lunout,*) ' tau_trig_deep = ', tau_trig_deep
+    WRITE(lunout,*) ' iflag_clos_bl = ', iflag_clos_bl
+    ! fin nrlmd le 10/04/2012
+
+    WRITE(lunout,*) ' lonmin lonmax latmin latmax bilKP_ins =',&
+         lonmin_ins, lonmax_ins, latmin_ins, latmax_ins
+    WRITE(lunout,*) ' 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,*) ' ok_strato = ', ok_strato
+    WRITE(lunout,*) ' ok_hines = ',  ok_hines
+    WRITE(lunout,*) ' ok_gwd_rando = ',  ok_gwd_rando
+    WRITE(lunout,*) ' ok_qch4 = ',  ok_qch4
+    WRITE(lunout,*) ' gwd_rando_ruwmax = ', gwd_rando_ruwmax
+    WRITE(lunout,*) ' gwd_rando_sat = ', gwd_rando_sat
+    WRITE(lunout,*) ' gwd_front_ruwmax = ', gwd_front_ruwmax
+    WRITE(lunout,*) ' gwd_front_sat = ', gwd_front_sat
+    WRITE(lunout,*) ' SSO gkdrag =',gkdrag
+    WRITE(lunout,*) ' SSO grahilo=',grahilo
+    WRITE(lunout,*) ' SSO grcrit=',grcrit
+    WRITE(lunout,*) ' SSO gfrcrit=',gfrcrit
+    WRITE(lunout,*) ' SSO gkwake=',gkwake
+    WRITE(lunout,*) ' SSO gklift=',gklift
+    WRITE(lunout,*) ' adjust_tropopause = ', adjust_tropopause
+    WRITE(lunout,*) ' ok_daily_climoz = ',ok_daily_climoz
+    WRITE(lunout,*) ' ok_new_lscp = ', ok_new_lscp
+    WRITE(lunout,*) ' ok_icefra_lscp = ', ok_icefra_lscp
+    WRITE(lunout,*) ' read_climoz = ', read_climoz
+    WRITE(lunout,*) ' carbon_cycle_tr = ', carbon_cycle_tr
+    WRITE(lunout,*) ' carbon_cycle_cpl = ', carbon_cycle_cpl
+    WRITE(lunout,*) ' carbon_cycle_rad = ', carbon_cycle_rad
+    WRITE(lunout,*) ' level_coupling_esm = ', level_coupling_esm
+    WRITE(lunout,*) ' read_fco2_ocean_cor = ', read_fco2_ocean_cor
+    WRITE(lunout,*) ' var_fco2_ocean_cor = ', var_fco2_ocean_cor
+    WRITE(lunout,*) ' read_fco2_land_cor = ', read_fco2_land_cor
+    WRITE(lunout,*) ' var_fco2_land_cor = ', var_fco2_land_cor
+    WRITE(lunout,*) ' dms_cycle_cpl = ', dms_cycle_cpl
+    WRITE(lunout,*) ' iflag_tsurf_inlandsis = ', iflag_tsurf_inlandsis
+    WRITE(lunout,*) ' iflag_temp_inlandsis = ', iflag_temp_inlandsis
+    WRITE(lunout,*) ' iflag_albcalc = ', iflag_albcalc
+    WRITE(lunout,*) ' SnoMod = ', SnoMod
+    WRITE(lunout,*) ' BloMod = ', BloMod
+    WRITE(lunout,*) ' ok_outfor = ', ok_outfor
+    WRITE(lunout,*) ' is_ok_slush = ', is_ok_slush
+    WRITE(lunout,*) ' opt_runoff_ac = ', opt_runoff_ac
+    WRITE(lunout,*) ' is_ok_z0h_rn = ', is_ok_z0h_rn
+    WRITE(lunout,*) ' is_ok_density_kotlyakov = ', is_ok_density_kotlyakov
+    WRITE(lunout,*) ' prescribed_z0m_snow = ', prescribed_z0m_snow
+    WRITE(lunout,*) ' iflag_z0m_snow = ', iflag_z0m_snow
+    WRITE(lunout,*) ' ok_zsn_ii = ', ok_zsn_ii
+    WRITE(lunout,*) ' discret_xf = ', discret_xf
+    WRITE(lunout,*) ' correc_alb= ', correc_alb
+    WRITE(lunout,*) ' buf_sph_pol = ', buf_sph_pol
+    WRITE(lunout,*) ' buf_siz_pol= ', buf_siz_pol
+
+    !$OMP END MASTER
+    call config_ocean_skin
+
+  END SUBROUTINE conf_phys
+
+END MODULE conf_phys_m
+!
+!#################################################################
+!
+
+SUBROUTINE conf_interface(tau_calv)
+
+  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
+  REAL, SAVE    :: tau_calv_omp
+  !
+  !Config Key  = tau_calv
+  !Config Desc = temps de relaxation pour fonte des glaciers en jours
+  !Config Def  = 1 an 
+  !Config Help = 
+  !
+  tau_calv_omp = 360.*10.
+  !$OMP MASTER
+  CALL getin('tau_calv',tau_calv_omp)
+  !$OMP END MASTER
+  !$OMP BARRIER
+  !
+  tau_calv=tau_calv_omp
+  !
+  !$OMP MASTER
+  WRITE(lunout,*)' ##############################################'
+  WRITE(lunout,*)' Configuration de l''interface atm/surfaces  : '
+  WRITE(lunout,*)' tau_calv = ',tau_calv
+  !$OMP END MASTER
+  !
+  RETURN
+
+END SUBROUTINE conf_interface
Index: CONFIG/UNIFORM/v6/IPSLCM6.3/SOURCES/LMDZ/cpl_mod.F90
===================================================================
--- CONFIG/UNIFORM/v6/IPSLCM6.3/SOURCES/LMDZ/cpl_mod.F90	(revision 6571)
+++ CONFIG/UNIFORM/v6/IPSLCM6.3/SOURCES/LMDZ/cpl_mod.F90	(revision 6571)
@@ -0,0 +1,1671 @@
+!
+MODULE cpl_mod
+!
+! This module excahanges and transforms all fields that should be recieved or sent to 
+! coupler. The transformation of the fields are done from the grid 1D-array in phylmd 
+! to the regular 2D grid accepted by the coupler. Cumulation of the fields for each 
+! timestep is done in here. 
+!
+! Each type of surface that recevie fields from the coupler have a subroutine named 
+! cpl_receive_XXX_fields and each surface that have fields to be sent to the coupler 
+! have a subroutine named cpl_send_XXX_fields.
+!
+!*************************************************************************************
+
+! Use statements
+!*************************************************************************************
+  USE dimphy, ONLY : klon
+  USE mod_phys_lmdz_para
+  USE ioipsl
+  USE iophy
+
+! The module oasis is always used. Without the cpp key CPP_COUPLE only the parameters 
+! in the module are compiled and not the subroutines.
+  USE oasis
+  USE write_field_phy
+  USE time_phylmdz_mod, ONLY: day_step_phy
+  
+! Global attributes
+!*************************************************************************************
+  IMPLICIT NONE
+  PRIVATE
+
+  ! All subroutine are public except cpl_send_all
+  PUBLIC :: cpl_init, cpl_receive_frac, cpl_receive_ocean_fields, cpl_receive_seaice_fields, &
+       cpl_send_ocean_fields, cpl_send_seaice_fields, cpl_send_land_fields, &
+       cpl_send_landice_fields, gath2cpl
+  
+
+! Declaration of module variables
+!*************************************************************************************
+! variable for coupling period
+  INTEGER, SAVE :: nexca
+  !$OMP THREADPRIVATE(nexca)
+
+! variables for cumulating fields during a coupling periode :
+  REAL, ALLOCATABLE, DIMENSION(:,:), SAVE   :: cpl_sols, cpl_nsol, cpl_rain
+  !$OMP THREADPRIVATE(cpl_sols,cpl_nsol,cpl_rain)
+  REAL, ALLOCATABLE, DIMENSION(:,:), SAVE   :: cpl_snow, cpl_evap, cpl_tsol
+  !$OMP THREADPRIVATE(cpl_snow,cpl_evap,cpl_tsol)
+
+  REAL, ALLOCATABLE, SAVE:: cpl_delta_sst(:), cpl_delta_sal(:), cpl_dter(:), &
+       cpl_dser(:), cpl_dt_ds(:)
+  !$OMP THREADPRIVATE(cpl_delta_sst, cpl_delta_sal, cpl_dter, cpl_dser)
+  !$OMP THREADPRIVATE(cpl_dt_ds)
+  
+  REAL, ALLOCATABLE, DIMENSION(:,:), SAVE   :: cpl_fder, cpl_albe, cpl_taux, cpl_tauy
+  !$OMP THREADPRIVATE(cpl_fder,cpl_albe,cpl_taux,cpl_tauy)
+  REAL, ALLOCATABLE, DIMENSION(:,:), SAVE   :: cpl_windsp
+  !$OMP THREADPRIVATE(cpl_windsp)
+  REAL, ALLOCATABLE, DIMENSION(:,:), SAVE   :: cpl_sens_rain, cpl_sens_snow
+  !$OMP THREADPRIVATE(cpl_sens_rain, cpl_sens_snow)
+  REAL, ALLOCATABLE, DIMENSION(:,:), SAVE   :: cpl_taumod
+  !$OMP THREADPRIVATE(cpl_taumod)
+  REAL, ALLOCATABLE, DIMENSION(:,:), SAVE   :: cpl_atm_co2
+  !$OMP THREADPRIVATE(cpl_atm_co2)
+  REAL, ALLOCATABLE, DIMENSION(:,:), SAVE   :: cpl_rriv2D, cpl_rcoa2D, cpl_rlic2D
+  !$OMP THREADPRIVATE(cpl_rriv2D,cpl_rcoa2D,cpl_rlic2D)
+  REAL, ALLOCATABLE, DIMENSION(:,:), SAVE   :: rlic_in_frac2D  ! fraction for continental ice
+  !$OMP THREADPRIVATE(rlic_in_frac2D)
+
+! variables read from coupler :
+  REAL, ALLOCATABLE, DIMENSION(:,:), SAVE   :: read_sst     ! sea surface temperature
+  !$OMP THREADPRIVATE(read_sst)
+  REAL, ALLOCATABLE, DIMENSION(:,:), SAVE   :: read_sit     ! sea ice temperature
+  !$OMP THREADPRIVATE(read_sit)
+
+  REAL, ALLOCATABLE, SAVE:: read_sss(:, :)
+  ! bulk salinity of the surface layer of the ocean, in ppt
+  !$OMP THREADPRIVATE(read_sss)
+
+  REAL, ALLOCATABLE, DIMENSION(:,:), SAVE   :: read_sic     ! sea ice fraction
+  !$OMP THREADPRIVATE(read_sic)
+  REAL, ALLOCATABLE, DIMENSION(:,:), SAVE   :: read_alb_sic ! albedo at sea ice
+  !$OMP THREADPRIVATE(read_alb_sic)
+  REAL, ALLOCATABLE, DIMENSION(:,:), SAVE   :: read_u0, read_v0 ! ocean surface current
+  !$OMP THREADPRIVATE(read_u0,read_v0)
+  REAL, ALLOCATABLE, DIMENSION(:,:), SAVE   :: read_co2     ! ocean co2 flux 
+  !$OMP THREADPRIVATE(read_co2)
+  INTEGER, ALLOCATABLE, DIMENSION(:), SAVE  :: unity
+  !$OMP THREADPRIVATE(unity)
+  INTEGER, SAVE                             :: nidct, nidcs
+  !$OMP THREADPRIVATE(nidct,nidcs)
+
+! variables to be sent to the coupler
+  REAL, ALLOCATABLE, DIMENSION(:,:,:), SAVE :: cpl_sols2D, cpl_nsol2D, cpl_rain2D
+  !$OMP THREADPRIVATE(cpl_sols2D, cpl_nsol2D, cpl_rain2D)
+  REAL, ALLOCATABLE, DIMENSION(:,:,:), SAVE :: cpl_snow2D, cpl_evap2D, cpl_tsol2D
+  !$OMP THREADPRIVATE(cpl_snow2D, cpl_evap2D, cpl_tsol2D)
+
+  REAL, ALLOCATABLE, SAVE:: cpl_delta_sst_2D(:, :), cpl_delta_sal_2D(:, :), &
+       cpl_dter_2D(:, :), cpl_dser_2D(:, :), cpl_dt_ds_2D(:, :)
+  !$OMP THREADPRIVATE(cpl_delta_sst_2D, cpl_delta_sal_2D)
+  !$OMP THREADPRIVATE(cpl_dter_2D, cpl_dser_2D, cpl_dt_ds_2D)
+
+  REAL, ALLOCATABLE, DIMENSION(:,:,:), SAVE :: cpl_fder2D, cpl_albe2D
+  !$OMP THREADPRIVATE(cpl_fder2D, cpl_albe2D)
+  REAL, ALLOCATABLE, DIMENSION(:,:,:), SAVE :: cpl_taux2D, cpl_tauy2D
+  !$OMP THREADPRIVATE(cpl_taux2D, cpl_tauy2D)
+  REAL, ALLOCATABLE, DIMENSION(:,:,:), SAVE :: cpl_taumod2D
+  !$OMP THREADPRIVATE(cpl_taumod2D)
+  REAL, ALLOCATABLE, DIMENSION(:,:), SAVE   :: cpl_windsp2D
+  !$OMP THREADPRIVATE(cpl_windsp2D)
+  REAL, ALLOCATABLE, DIMENSION(:,:,:), SAVE   :: cpl_sens_rain2D, cpl_sens_snow2D
+  !$OMP THREADPRIVATE(cpl_sens_rain2D, cpl_sens_snow2D)
+  REAL, ALLOCATABLE, DIMENSION(:,:), SAVE   :: cpl_atm_co22D
+  !$OMP THREADPRIVATE(cpl_atm_co22D)
+
+!!!!!!!!!! variable for calving
+  INTEGER, PARAMETER :: nb_zone_calving = 3
+  REAL,ALLOCATABLE, DIMENSION(:,:,:),SAVE :: area_calving 
+  !$OMP THREADPRIVATE(area_calving)
+  REAL,ALLOCATABLE, DIMENSION(:,:),SAVE :: cell_area2D 
+  !$OMP THREADPRIVATE(cell_area2D)
+  INTEGER, SAVE :: ind_calving(nb_zone_calving) 
+  !$OMP THREADPRIVATE(ind_calving)
+
+  LOGICAL,SAVE :: cpl_old_calving
+  !$OMP THREADPRIVATE(cpl_old_calving)
+  
+CONTAINS
+!
+!************************************************************************************
+!
+  SUBROUTINE cpl_init(dtime, rlon, rlat)
+    USE carbon_cycle_mod, ONLY : carbon_cycle_cpl, fco2_ocn_day
+    USE surface_data
+    USE indice_sol_mod
+    USE mod_grid_phy_lmdz, ONLY : nbp_lon, nbp_lat, grid1dTo2d_glo, klon_glo, grid_type, unstructured, regular_lonlat
+    USE time_phylmdz_mod, ONLY: annee_ref, day_ini, itau_phy, itaufin_phy
+    USE print_control_mod, ONLY: lunout
+    USE geometry_mod, ONLY : longitude_deg, latitude_deg, ind_cell_glo, cell_area
+    USE ioipsl_getin_p_mod, ONLY: getin_p
+    use config_ocean_skin_m, only: activate_ocean_skin
+
+! Input arguments
+!*************************************************************************************
+    REAL, INTENT(IN)                  :: dtime
+    REAL, DIMENSION(klon), INTENT(IN) :: rlon, rlat
+
+! Local variables
+!*************************************************************************************
+    INTEGER                           :: error, sum_error, ig, i
+    INTEGER                           :: jf, nhoridct
+    INTEGER                           :: nhoridcs
+    INTEGER                           :: idtime
+    INTEGER                           :: idayref
+    INTEGER                           :: npas ! only for OASIS2
+    REAL                              :: zjulian
+    REAL, DIMENSION(nbp_lon,nbp_lat)  :: zx_lon, zx_lat
+    CHARACTER(len = 20)               :: modname = 'cpl_init'
+    CHARACTER(len = 80)               :: abort_message
+    CHARACTER(len=80)                 :: clintocplnam, clfromcplnam
+    REAL, DIMENSION(klon_mpi)         :: rlon_mpi, rlat_mpi, cell_area_mpi
+    INTEGER, DIMENSION(klon_mpi)           :: ind_cell_glo_mpi
+    REAL, DIMENSION(nbp_lon,jj_nb)         :: lon2D, lat2D
+    INTEGER :: mask_calving(nbp_lon,jj_nb,nb_zone_calving)
+    REAL :: pos
+
+!***************************************
+! Use old calving or not (default new calving method)
+! New calving method should be used with DYNAMICO and when using new coupling
+! weights.
+    cpl_old_calving=.FALSE.
+    CALL getin_p("cpl_old_calving",cpl_old_calving)
+    WRITE(lunout,*)' cpl_old_calving = ', cpl_old_calving
+
+
+!*************************************************************************************
+! Calculate coupling period
+!
+!*************************************************************************************
+     
+    npas = itaufin_phy
+!    nexca = 86400 / dtime
+    nexca = t_coupl / dtime
+    WRITE(lunout,*)' ##### Ocean couple #####'
+    WRITE(lunout,*)' Valeurs des pas de temps'
+    WRITE(lunout,*)' npas = ', npas
+    WRITE(lunout,*)' nexca = ', nexca
+    
+!*************************************************************************************
+! Allocate variables
+!
+!*************************************************************************************
+    error = 0
+    sum_error = 0
+
+    ALLOCATE(unity(klon), stat = error)
+    sum_error = sum_error + error
+    ALLOCATE(cpl_sols(klon,2), stat = error) 
+    sum_error = sum_error + error
+    ALLOCATE(cpl_nsol(klon,2), stat = error)
+    sum_error = sum_error + error
+    ALLOCATE(cpl_rain(klon,2), stat = error)
+    sum_error = sum_error + error
+    ALLOCATE(cpl_snow(klon,2), stat = error)
+    sum_error = sum_error + error
+    ALLOCATE(cpl_evap(klon,2), stat = error)
+    sum_error = sum_error + error
+    ALLOCATE(cpl_tsol(klon,2), stat = error)
+    sum_error = sum_error + error
+    ALLOCATE(cpl_fder(klon,2), stat = error)
+    sum_error = sum_error + error
+    ALLOCATE(cpl_albe(klon,2), stat = error)
+    sum_error = sum_error + error
+    ALLOCATE(cpl_taux(klon,2), stat = error)
+    sum_error = sum_error + error
+    ALLOCATE(cpl_tauy(klon,2), stat = error)
+    sum_error = sum_error + error
+    ALLOCATE(cpl_windsp(klon,2), stat = error)
+    sum_error = sum_error + error
+    ALLOCATE(cpl_taumod(klon,2), stat = error)
+    sum_error = sum_error + error
+    ALLOCATE(cpl_sens_rain(klon,2), stat = error)
+    sum_error = sum_error + error
+    ALLOCATE(cpl_sens_snow(klon,2), stat = error)
+    sum_error = sum_error + error
+    ALLOCATE(cpl_rriv2D(nbp_lon,jj_nb), stat=error)
+    sum_error = sum_error + error
+    ALLOCATE(cpl_rcoa2D(nbp_lon,jj_nb), stat=error)
+    sum_error = sum_error + error
+    ALLOCATE(cpl_rlic2D(nbp_lon,jj_nb), stat=error)
+    sum_error = sum_error + error
+    ALLOCATE(rlic_in_frac2D(nbp_lon,jj_nb), stat=error)
+    sum_error = sum_error + error
+    ALLOCATE(read_sst(nbp_lon, jj_nb), stat = error)
+    sum_error = sum_error + error
+    ALLOCATE(read_sic(nbp_lon, jj_nb), stat = error)
+    sum_error = sum_error + error
+    ALLOCATE(read_sit(nbp_lon, jj_nb), stat = error)
+    sum_error = sum_error + error
+
+    if (activate_ocean_skin >= 1) then
+       ALLOCATE(read_sss(nbp_lon, jj_nb), stat = error)
+       sum_error = sum_error + error
+    
+       if (activate_ocean_skin == 2) then
+          ALLOCATE(cpl_delta_sst(klon), cpl_delta_sal(klon), cpl_dter(klon), &
+               cpl_dser(klon), cpl_dt_ds(klon), stat = error)
+          sum_error = sum_error + error
+       end if
+    end if
+
+    ALLOCATE(read_alb_sic(nbp_lon, jj_nb), stat = error)
+    sum_error = sum_error + error
+    ALLOCATE(read_u0(nbp_lon, jj_nb), stat = error)
+    sum_error = sum_error + error
+    ALLOCATE(read_v0(nbp_lon, jj_nb), stat = error)
+    sum_error = sum_error + error
+
+    IF (carbon_cycle_cpl) THEN
+       ALLOCATE(read_co2(nbp_lon, jj_nb), stat = error)
+       sum_error = sum_error + error
+       ALLOCATE(cpl_atm_co2(klon,2), stat = error)
+       sum_error = sum_error + error
+
+! Allocate variable in carbon_cycle_mod
+       IF (.NOT.ALLOCATED(fco2_ocn_day)) ALLOCATE(fco2_ocn_day(klon), stat = error)
+       sum_error = sum_error + error
+    ENDIF
+
+! calving initialization
+    ALLOCATE(area_calving(nbp_lon, jj_nb, nb_zone_calving), stat = error)
+    sum_error = sum_error + error
+    ALLOCATE(cell_area2D(nbp_lon, jj_nb), stat = error)    
+    sum_error = sum_error + error
+
+    CALL gather_omp(longitude_deg,rlon_mpi)
+    CALL gather_omp(latitude_deg,rlat_mpi)
+    CALL gather_omp(ind_cell_glo,ind_cell_glo_mpi)
+    CALL gather_omp(cell_area,cell_area_mpi)
+      
+    IF (is_omp_master) THEN
+      CALL Grid1DTo2D_mpi(rlon_mpi,lon2D)
+      CALL Grid1DTo2D_mpi(rlat_mpi,lat2D)
+      CALL Grid1DTo2D_mpi(cell_area_mpi,cell_area2D)
+      !--the next line is required for lat-lon grid and should have no impact
+      !--for an unstructured grid for which nbp_lon=1
+      !--if north pole in process mpi then divide cell area of pole cell by number of replicates
+      IF (is_north_pole_dyn) cell_area2D(:,1)=cell_area2D(:,1)/FLOAT(nbp_lon)
+      !--if south pole in process mpi then divide cell area of pole cell by number of replicates
+      IF (is_south_pole_dyn) cell_area2D(:,jj_nb)=cell_area2D(:,jj_nb)/FLOAT(nbp_lon)
+      mask_calving(:,:,:) = 0 
+      WHERE ( lat2D >= 40) mask_calving(:,:,1) = 1
+      WHERE ( lat2D < 40 .AND. lat2D > -50) mask_calving(:,:,2) = 1
+      WHERE ( lat2D <= -50) mask_calving(:,:,3) = 1
+    
+    
+      DO i=1,nb_zone_calving
+        area_calving(:,:,i)=mask_calving(:,:,i)*cell_area2D(:,:)
+        pos=1
+        IF (i>1) pos = 1 + ((nbp_lon*nbp_lat-1)*(i-1))/(nb_zone_calving-1)
+      
+        ind_calving(i)=0
+        IF (grid_type==unstructured) THEN
+
+          DO ig=1,klon_mpi
+            IF (ind_cell_glo_mpi(ig)==pos) ind_calving(i)=ig
+          ENDDO
+
+        ELSE IF (grid_type==regular_lonlat) THEN
+          IF ((ij_begin<=pos .AND. ij_end>=pos) .OR. (ij_begin<=pos .AND. is_south_pole_dyn )) THEN
+            ind_calving(i)=pos-(jj_begin-1)*nbp_lon
+          ENDIF
+        ENDIF
+     
+      ENDDO
+    ENDIF
+    
+    IF (sum_error /= 0) THEN
+       abort_message='Pb allocation variables couplees'
+       CALL abort_physic(modname,abort_message,1)
+    ENDIF
+!*************************************************************************************
+! Initialize the allocated varaibles
+!
+!*************************************************************************************
+    DO ig = 1, klon
+       unity(ig) = ig
+    ENDDO
+
+!*************************************************************************************
+! Initialize coupling
+!
+!*************************************************************************************
+    idtime = INT(dtime)
+#ifdef CPP_COUPLE
+    CALL inicma
+#endif
+
+!*************************************************************************************
+! initialize NetCDF output
+!
+!*************************************************************************************
+    IF (is_sequential) THEN
+       idayref = day_ini
+       CALL ymds2ju(annee_ref, 1, idayref, 0.0, zjulian)
+       CALL grid1dTo2d_glo(rlon,zx_lon)
+       DO i = 1, nbp_lon
+          zx_lon(i,1) = rlon(i+1)
+          zx_lon(i,nbp_lat) = rlon(i+1)
+       ENDDO
+       CALL grid1dTo2d_glo(rlat,zx_lat)
+       clintocplnam="cpl_atm_tauflx"
+       CALL histbeg(clintocplnam,nbp_lon,zx_lon(:,1),nbp_lat,zx_lat(1,:),&
+            1,nbp_lon,1,nbp_lat, itau_phy,zjulian,dtime,nhoridct,nidct) 
+! no vertical axis
+       CALL histdef(nidct, 'tauxe','tauxe', &
+            "-",nbp_lon,nbp_lat, nhoridct, 1, 1, 1, -99, 32, "inst", dtime,dtime)
+       CALL histdef(nidct, 'tauyn','tauyn', &
+            "-",nbp_lon,nbp_lat, nhoridct, 1, 1, 1, -99, 32, "inst", dtime,dtime)
+       CALL histdef(nidct, 'tmp_lon','tmp_lon', &
+            "-",nbp_lon,nbp_lat, nhoridct, 1, 1, 1, -99, 32, "inst", dtime,dtime)
+       CALL histdef(nidct, 'tmp_lat','tmp_lat', &
+            "-",nbp_lon,nbp_lat, nhoridct, 1, 1, 1, -99, 32, "inst", dtime,dtime)
+       DO jf=1,maxsend
+         IF (infosend(i)%action) THEN
+             CALL histdef(nidct, infosend(i)%name ,infosend(i)%name , &
+                "-",nbp_lon,nbp_lat,nhoridct,1,1,1,-99,32,"inst",dtime,dtime)
+         ENDIF
+       ENDDO
+       CALL histend(nidct)
+       CALL histsync(nidct)
+       
+       clfromcplnam="cpl_atm_sst"
+       CALL histbeg(clfromcplnam,nbp_lon,zx_lon(:,1),nbp_lat,zx_lat(1,:),1,nbp_lon,1,nbp_lat, &
+            0,zjulian,dtime,nhoridcs,nidcs) 
+! no vertical axis
+       DO jf=1,maxrecv_phys
+         IF (inforecv(i)%action) THEN
+             CALL histdef(nidcs,inforecv(i)%name ,inforecv(i)%name , &
+                "-",nbp_lon,nbp_lat,nhoridcs,1,1,1,-99,32,"inst",dtime,dtime)
+         ENDIF
+       ENDDO
+       CALL histend(nidcs)
+       CALL histsync(nidcs)
+
+    ENDIF    ! is_sequential
+    
+!*************************************************************************************
+! compatibility test
+!
+!*************************************************************************************
+    IF (carbon_cycle_cpl .AND. version_ocean=='opa8') THEN
+       abort_message='carbon_cycle_cpl does not work with opa8'
+       CALL abort_physic(modname,abort_message,1)
+    ENDIF
+
+  END SUBROUTINE cpl_init
+  
+!
+!*************************************************************************************
+!
+ 
+  SUBROUTINE cpl_receive_frac(itime, dtime, pctsrf, is_modified)
+! This subroutine receives from coupler for both ocean and seaice
+! 4 fields : read_sst, read_sic, read_sit and read_alb_sic. 
+! The new sea-ice-land-landice fraction is returned. The others fields 
+! are stored in this module.
+    USE surface_data
+    USE geometry_mod, ONLY : longitude_deg, latitude_deg
+    USE carbon_cycle_mod, ONLY : carbon_cycle_cpl
+    USE indice_sol_mod
+    USE time_phylmdz_mod, ONLY: start_time, itau_phy
+    USE mod_grid_phy_lmdz, ONLY : nbp_lon, nbp_lat
+    use config_ocean_skin_m, only: activate_ocean_skin
+
+    INCLUDE "YOMCST.h"
+
+! Arguments
+!************************************************************************************
+    INTEGER, INTENT(IN)                        :: itime
+    REAL, INTENT(IN)                           :: dtime
+    REAL, DIMENSION(klon,nbsrf), INTENT(INOUT) :: pctsrf
+    LOGICAL, INTENT(OUT)                       :: is_modified
+
+! Local variables
+!************************************************************************************
+    INTEGER                                 :: j, i, time_sec
+    INTEGER                                 :: itau_w
+    INTEGER, DIMENSION(nbp_lon*nbp_lat)     :: ndexcs
+    CHARACTER(len = 20)                     :: modname = 'cpl_receive_frac'
+    CHARACTER(len = 80)                     :: abort_message
+    REAL, DIMENSION(klon)                   :: read_sic1D
+    REAL, DIMENSION(nbp_lon,jj_nb,maxrecv_phys)      :: tab_read_flds
+    REAL, DIMENSION(klon,nbsrf)             :: pctsrf_old
+    REAL, DIMENSION(klon_mpi)               :: rlon_mpi, rlat_mpi
+    REAL, DIMENSION(nbp_lon,jj_nb)             :: tmp_lon, tmp_lat
+    REAL, DIMENSION(nbp_lon,jj_nb)             :: tmp_r0
+
+!*************************************************************************************
+! Start calculation
+! Get fields from coupler
+!
+!*************************************************************************************
+
+    is_modified=.FALSE.
+
+! Check if right moment to receive from coupler
+    IF (MOD(itime, nexca) == 1) THEN
+       is_modified=.TRUE.
+ 
+       time_sec=(itime-1)*dtime
+#ifdef CPP_COUPLE
+!$OMP MASTER
+    CALL fromcpl(time_sec, tab_read_flds)
+!$OMP END MASTER
+#endif
+    
+! NetCDF output of received fields
+       IF (is_sequential) THEN
+          ndexcs(:) = 0
+          itau_w = itau_phy + itime + start_time * day_step_phy
+          DO i = 1, maxrecv_phys
+            IF (inforecv(i)%action) THEN
+                CALL histwrite(nidcs,inforecv(i)%name,itau_w,tab_read_flds(:,:,i),nbp_lon*(nbp_lat),ndexcs)
+            ENDIF
+          ENDDO
+       ENDIF
+
+
+! Save each field in a 2D array. 
+!$OMP MASTER
+       read_sst(:,:)     = tab_read_flds(:,:,idr_sisutw)  ! Sea surface temperature
+       read_sic(:,:)     = tab_read_flds(:,:,idr_icecov)  ! Sea ice concentration
+       read_alb_sic(:,:) = tab_read_flds(:,:,idr_icealw)  ! Albedo at sea ice
+       read_sit(:,:)     = tab_read_flds(:,:,idr_icetem)  ! Sea ice temperature
+       if (activate_ocean_skin >= 1) read_sss(:,:) = tab_read_flds(:,:,idr_sss)
+!$OMP END MASTER
+
+       IF (cpl_current) THEN
+
+! Transform the longitudes and latitudes on 2D arrays
+          CALL gather_omp(longitude_deg,rlon_mpi)
+          CALL gather_omp(latitude_deg,rlat_mpi)
+!$OMP MASTER
+          CALL Grid1DTo2D_mpi(rlon_mpi,tmp_lon)
+          CALL Grid1DTo2D_mpi(rlat_mpi,tmp_lat)
+
+! Transform the currents from cartesian to spheric coordinates
+! tmp_r0 should be zero
+          CALL geo2atm(nbp_lon, jj_nb, tab_read_flds(:,:,idr_curenx), &
+             tab_read_flds(:,:,idr_cureny), tab_read_flds(:,:,idr_curenz), &
+               tmp_lon, tmp_lat, &
+               read_u0(:,:), read_v0(:,:), tmp_r0(:,:))
+!$OMP END MASTER
+
+      ELSE
+          read_u0(:,:) = 0.
+          read_v0(:,:) = 0.
+      ENDIF
+
+       IF (carbon_cycle_cpl) THEN
+!$OMP MASTER
+           read_co2(:,:) = tab_read_flds(:,:,idr_oceco2) ! CO2 flux
+!$OMP END MASTER
+       ENDIF
+
+!*************************************************************************************
+!  Transform seaice fraction (read_sic : ocean-seaice mask) into global 
+!  fraction (pctsrf : ocean-seaice-land-landice mask)
+!
+!*************************************************************************************
+       CALL cpl2gath(read_sic, read_sic1D, klon, unity)
+
+       pctsrf_old(:,:) = pctsrf(:,:)
+       DO i = 1, klon
+          ! treatment only of points with ocean and/or seaice
+          ! old land-ocean mask can not be changed
+          IF (pctsrf_old(i,is_oce) + pctsrf_old(i,is_sic) > 0.) THEN
+             pctsrf(i,is_sic) = (pctsrf_old(i,is_oce) + pctsrf_old(i,is_sic)) &
+                  * read_sic1D(i)
+             pctsrf(i,is_oce) = (pctsrf_old(i,is_oce) + pctsrf_old(i,is_sic)) &
+                  - pctsrf(i,is_sic)
+          ENDIF
+       ENDDO
+
+    ENDIF ! if time to receive
+
+  END SUBROUTINE cpl_receive_frac
+
+!
+!*************************************************************************************
+!
+
+  SUBROUTINE cpl_receive_ocean_fields(knon, knindex, tsurf_new, u0_new, &
+       v0_new, sss)
+!
+! This routine returns the field for the ocean that has been read from the coupler
+! (done earlier with cpl_receive_frac). The field is the temperature.
+! The temperature is transformed into 1D array with valid points from index 1 to knon.
+!
+    USE carbon_cycle_mod, ONLY : carbon_cycle_cpl, fco2_ocn_day
+    USE indice_sol_mod
+    use config_ocean_skin_m, only: activate_ocean_skin
+
+! Input arguments
+!*************************************************************************************
+    INTEGER, INTENT(IN)                     :: knon
+    INTEGER, DIMENSION(klon), INTENT(IN)    :: knindex
+
+! Output arguments
+!*************************************************************************************
+    REAL, DIMENSION(klon), INTENT(OUT)      :: tsurf_new
+
+    REAL, INTENT(OUT):: sss(:) ! (klon)
+    ! bulk salinity of the surface layer of the ocean, in ppt
+
+    REAL, DIMENSION(klon), INTENT(OUT)      :: u0_new
+    REAL, DIMENSION(klon), INTENT(OUT)      :: v0_new
+
+! Local variables
+!*************************************************************************************
+    INTEGER                  :: i
+    INTEGER, DIMENSION(klon) :: index
+    REAL, DIMENSION(klon)    :: sic_new
+
+!*************************************************************************************
+! Transform read_sst into compressed 1D variable tsurf_new
+!
+!*************************************************************************************
+    CALL cpl2gath(read_sst, tsurf_new, knon, knindex)
+    if (activate_ocean_skin >= 1) CALL cpl2gath(read_sss, sss, knon, knindex)
+    CALL cpl2gath(read_sic, sic_new, knon, knindex)
+    CALL cpl2gath(read_u0, u0_new, knon, knindex)
+    CALL cpl2gath(read_v0, v0_new, knon, knindex)
+
+!*************************************************************************************
+! Transform read_co2 into uncompressed 1D variable fco2_ocn_day added directly in 
+! the module carbon_cycle_mod
+!
+!*************************************************************************************
+    IF (carbon_cycle_cpl) THEN
+       DO i=1,klon
+          index(i)=i
+       ENDDO
+       CALL cpl2gath(read_co2, fco2_ocn_day, klon, index)
+    ENDIF
+
+!*************************************************************************************
+! The fields received from the coupler have to be weighted with the fraction of ocean 
+! in relation to the total sea-ice+ocean
+!
+!*************************************************************************************
+    DO i=1, knon
+       tsurf_new(i) = tsurf_new(i)/(1. - sic_new(i))
+    ENDDO
+
+  END SUBROUTINE cpl_receive_ocean_fields
+
+!
+!*************************************************************************************
+!
+
+  SUBROUTINE cpl_receive_seaice_fields(knon, knindex, &
+       tsurf_new, alb_new, u0_new, v0_new)
+!
+! This routine returns the fields for the seaice that have been read from the coupler
+! (done earlier with cpl_receive_frac). These fields are the temperature and 
+! albedo at sea ice surface and fraction of sea ice.
+! The fields are transformed into 1D arrays with valid points from index 1 to knon. 
+!
+
+! Input arguments
+!*************************************************************************************
+    INTEGER, INTENT(IN)                     :: knon
+    INTEGER, DIMENSION(klon), INTENT(IN)    :: knindex
+
+! Output arguments
+!*************************************************************************************
+    REAL, DIMENSION(klon), INTENT(OUT)      :: tsurf_new
+    REAL, DIMENSION(klon), INTENT(OUT)      :: alb_new
+    REAL, DIMENSION(klon), INTENT(OUT)      :: u0_new
+    REAL, DIMENSION(klon), INTENT(OUT)      :: v0_new
+
+! Local variables
+!*************************************************************************************
+    INTEGER               :: i
+    REAL, DIMENSION(klon) :: sic_new
+
+!*************************************************************************************
+! Transform fields read from coupler from 2D into compressed 1D variables
+!
+!*************************************************************************************
+    CALL cpl2gath(read_sit, tsurf_new, knon, knindex)
+    CALL cpl2gath(read_alb_sic, alb_new, knon, knindex)
+    CALL cpl2gath(read_sic, sic_new, knon, knindex)
+    CALL cpl2gath(read_u0, u0_new, knon, knindex)
+    CALL cpl2gath(read_v0, v0_new, knon, knindex)
+
+!*************************************************************************************
+! The fields received from the coupler have to be weighted with the sea-ice 
+! concentration (in relation to the total sea-ice + ocean).
+!
+!*************************************************************************************
+    DO i= 1, knon
+       tsurf_new(i) = tsurf_new(i) / sic_new(i)
+       alb_new(i)   = alb_new(i)   / sic_new(i)
+    ENDDO
+
+  END SUBROUTINE cpl_receive_seaice_fields
+
+!
+!*************************************************************************************
+!
+
+  SUBROUTINE cpl_send_ocean_fields(itime, knon, knindex, &
+       swdown, lwdown, fluxlat, fluxsens, &
+       precip_rain, precip_snow, evap, tsurf, fder, albsol, taux, tauy, windsp,&
+       sens_prec_liq, sens_prec_sol, lat_prec_liq, lat_prec_sol, delta_sst, &
+       delta_sal, dTer, dSer, dt_ds)
+
+    ! This subroutine cumulates some fields for each time-step during
+    ! a coupling period. At last time-step in a coupling period the
+    ! fields are transformed to the grid accepted by the coupler. No
+    ! sending to the coupler will be done from here (it is done in
+    ! cpl_send_seaice_fields). Crucial hypothesis is that the surface
+    ! fractions do not change between coupling time-steps.
+
+    USE carbon_cycle_mod, ONLY : carbon_cycle_cpl, co2_send
+    USE indice_sol_mod
+    USE mod_grid_phy_lmdz, ONLY : nbp_lon, nbp_lat
+    use config_ocean_skin_m, only: activate_ocean_skin
+
+! Input arguments
+!*************************************************************************************
+    INTEGER, INTENT(IN)                     :: itime
+    INTEGER, INTENT(IN)                     :: knon
+    INTEGER, DIMENSION(klon), INTENT(IN)    :: knindex
+    REAL, DIMENSION(klon), INTENT(IN)       :: swdown, lwdown 
+    REAL, DIMENSION(klon), INTENT(IN)       :: fluxlat, fluxsens
+    REAL, DIMENSION(klon), INTENT(IN)       :: precip_rain, precip_snow
+    REAL, DIMENSION(klon), INTENT(IN)       :: evap, tsurf, fder, albsol
+    REAL, DIMENSION(klon), INTENT(IN)       :: taux, tauy, windsp
+    REAL, INTENT(IN):: sens_prec_liq(:), sens_prec_sol(:) ! (knon)
+    REAL, DIMENSION(klon), INTENT(IN)       :: lat_prec_liq, lat_prec_sol
+    
+    REAL, intent(in):: delta_sst(:) ! (knon)
+    ! Ocean-air interface temperature minus bulk SST, in
+    ! K. Defined only if activate_ocean_skin >= 1.
+
+    real, intent(in):: delta_sal(:) ! (knon)
+    ! Ocean-air interface salinity minus bulk salinity, in ppt.
+
+    REAL, intent(in):: dter(:) ! (knon)
+    ! Temperature variation in the diffusive microlayer, that is
+    ! ocean-air interface temperature minus subskin temperature. In
+    ! K.
+
+    REAL, intent(in):: dser(:) ! (knon)
+    ! Salinity variation in the diffusive microlayer, that is
+    ! ocean-air interface salinity minus subskin salinity. In ppt.
+
+    real, intent(in):: dt_ds(:) ! (knon)
+    ! (tks / tkt) * dTer, in K
+
+! Local variables
+!*************************************************************************************
+    INTEGER                                 :: cpl_index, ig 
+    INTEGER                                 :: error, sum_error
+    CHARACTER(len = 25)                     :: modname = 'cpl_send_ocean_fields'
+    CHARACTER(len = 80)                     :: abort_message
+
+!*************************************************************************************
+! Start calculation
+! The ocean points are saved with second array index=1
+!
+!*************************************************************************************
+    cpl_index = 1
+
+!*************************************************************************************
+! Reset fields to zero in the beginning of a new coupling period 
+!
+!*************************************************************************************
+    IF (MOD(itime, nexca) == 1) THEN
+       cpl_sols(1:knon,cpl_index) = 0.0
+       cpl_nsol(1:knon,cpl_index) = 0.0
+       cpl_rain(1:knon,cpl_index) = 0.0
+       cpl_snow(1:knon,cpl_index) = 0.0
+       cpl_evap(1:knon,cpl_index) = 0.0
+       cpl_tsol(1:knon,cpl_index) = 0.0
+       cpl_fder(1:knon,cpl_index) = 0.0
+       cpl_albe(1:knon,cpl_index) = 0.0
+       cpl_taux(1:knon,cpl_index) = 0.0
+       cpl_tauy(1:knon,cpl_index) = 0.0
+       cpl_windsp(1:knon,cpl_index) = 0.0
+       cpl_sens_rain(1:knon,cpl_index) = 0.0
+       cpl_sens_snow(1:knon,cpl_index) = 0.0
+       cpl_taumod(1:knon,cpl_index) = 0.0
+       IF (carbon_cycle_cpl) cpl_atm_co2(1:knon,cpl_index) = 0.0
+
+       if (activate_ocean_skin == 2) then
+          cpl_delta_sst = 0.
+          cpl_delta_sal = 0.
+          cpl_dter = 0.
+          cpl_dser = 0.
+          cpl_dt_ds = 0.
+       end if
+    ENDIF
+       
+!*************************************************************************************
+! Cumulate at each time-step
+!
+!*************************************************************************************    
+    DO ig = 1, knon
+       cpl_sols(ig,cpl_index) = cpl_sols(ig,cpl_index) + &
+            swdown(ig)      / REAL(nexca)
+       cpl_nsol(ig,cpl_index) = cpl_nsol(ig,cpl_index) + &
+            (lwdown(ig) + fluxlat(ig) +fluxsens(ig)) / REAL(nexca)
+       cpl_rain(ig,cpl_index) = cpl_rain(ig,cpl_index) + &
+            precip_rain(ig) / REAL(nexca)
+       cpl_snow(ig,cpl_index) = cpl_snow(ig,cpl_index) + &
+            precip_snow(ig) / REAL(nexca)
+       cpl_evap(ig,cpl_index) = cpl_evap(ig,cpl_index) + &
+            evap(ig)        / REAL(nexca)
+       cpl_tsol(ig,cpl_index) = cpl_tsol(ig,cpl_index) + &
+            tsurf(ig)       / REAL(nexca)
+       cpl_fder(ig,cpl_index) = cpl_fder(ig,cpl_index) + &
+            fder(ig)        / REAL(nexca)
+       cpl_albe(ig,cpl_index) = cpl_albe(ig,cpl_index) + &
+            albsol(ig)      / REAL(nexca)
+       cpl_taux(ig,cpl_index) = cpl_taux(ig,cpl_index) + &
+            taux(ig)        / REAL(nexca)
+       cpl_tauy(ig,cpl_index) = cpl_tauy(ig,cpl_index) + &
+            tauy(ig)        / REAL(nexca)      
+       cpl_windsp(ig,cpl_index) = cpl_windsp(ig,cpl_index) + &
+            windsp(ig)      / REAL(nexca)
+       cpl_sens_rain(ig,cpl_index) = cpl_sens_rain(ig,cpl_index) + &
+            sens_prec_liq(ig)      / REAL(nexca)
+       cpl_sens_snow(ig,cpl_index) = cpl_sens_snow(ig,cpl_index) + &
+            sens_prec_sol(ig)      / REAL(nexca)
+       cpl_taumod(ig,cpl_index) =   cpl_taumod(ig,cpl_index) + &
+          SQRT ( taux(ig)*taux(ig)+tauy(ig)*tauy(ig) ) / REAL (nexca)
+
+       IF (carbon_cycle_cpl) THEN
+          cpl_atm_co2(ig,cpl_index) = cpl_atm_co2(ig,cpl_index) + &
+               co2_send(knindex(ig))/ REAL(nexca) 
+!!---OB: this is correct but why knindex ??
+       ENDIF
+
+       if (activate_ocean_skin == 2) then
+          cpl_delta_sst(ig) = cpl_delta_sst(ig) + delta_sst(ig) / REAL(nexca)
+          cpl_delta_sal(ig) = cpl_delta_sal(ig) + delta_sal(ig) / REAL(nexca)
+          cpl_dter(ig) = cpl_dter(ig) + dter(ig) / REAL(nexca)
+          cpl_dser(ig) = cpl_dser(ig) + dser(ig) / REAL(nexca)
+          cpl_dt_ds(ig) = cpl_dt_ds(ig) + dt_ds(ig) / REAL(nexca)
+       end if
+     ENDDO
+
+!*************************************************************************************
+! If the time-step corresponds to the end of coupling period the 
+! fields are transformed to the 2D grid. 
+! No sending to the coupler (it is done from cpl_send_seaice_fields).
+!
+!*************************************************************************************
+    IF (MOD(itime, nexca) == 0) THEN
+
+       IF (.NOT. ALLOCATED(cpl_sols2D)) THEN
+          sum_error = 0
+          ALLOCATE(cpl_sols2D(nbp_lon,jj_nb,2), stat=error)
+          sum_error = sum_error + error
+          ALLOCATE(cpl_nsol2D(nbp_lon,jj_nb,2), stat=error)
+          sum_error = sum_error + error
+          ALLOCATE(cpl_rain2D(nbp_lon,jj_nb,2), stat=error)
+          sum_error = sum_error + error
+          ALLOCATE(cpl_snow2D(nbp_lon,jj_nb,2), stat=error)
+          sum_error = sum_error + error
+          ALLOCATE(cpl_evap2D(nbp_lon,jj_nb,2), stat=error)
+          sum_error = sum_error + error
+          ALLOCATE(cpl_tsol2D(nbp_lon,jj_nb,2), stat=error)
+          sum_error = sum_error + error
+          ALLOCATE(cpl_fder2D(nbp_lon,jj_nb,2), stat=error)
+          sum_error = sum_error + error
+          ALLOCATE(cpl_albe2D(nbp_lon,jj_nb,2), stat=error)
+          sum_error = sum_error + error
+          ALLOCATE(cpl_taux2D(nbp_lon,jj_nb,2), stat=error)
+          sum_error = sum_error + error
+          ALLOCATE(cpl_tauy2D(nbp_lon,jj_nb,2), stat=error)
+          sum_error = sum_error + error
+          ALLOCATE(cpl_windsp2D(nbp_lon,jj_nb), stat=error)
+          sum_error = sum_error + error
+          ALLOCATE(cpl_sens_rain2D(nbp_lon,jj_nb,2), stat=error)
+          sum_error = sum_error + error
+          ALLOCATE(cpl_sens_snow2D(nbp_lon,jj_nb,2), stat=error)
+          sum_error = sum_error + error
+          ALLOCATE(cpl_taumod2D(nbp_lon,jj_nb,2), stat=error)
+          sum_error = sum_error + error
+          
+          IF (carbon_cycle_cpl) THEN
+             ALLOCATE(cpl_atm_co22D(nbp_lon,jj_nb), stat=error)
+             sum_error = sum_error + error
+          ENDIF
+
+          if (activate_ocean_skin == 2) then
+             ALLOCATE(cpl_delta_sst_2D(nbp_lon, jj_nb), &
+                  cpl_delta_sal_2D(nbp_lon, jj_nb), &
+                  cpl_dter_2D(nbp_lon, jj_nb), cpl_dser_2D(nbp_lon, jj_nb), &
+                  cpl_dt_ds_2D(nbp_lon, jj_nb), stat = error)
+             sum_error = sum_error + error
+          end if
+
+          IF (sum_error /= 0) THEN
+             abort_message='Pb allocation variables couplees pour l''ecriture'
+             CALL abort_physic(modname,abort_message,1)
+          ENDIF
+       ENDIF
+       
+
+       CALL gath2cpl(cpl_sols(:,cpl_index), cpl_sols2D(:,:,cpl_index), &
+            knon, knindex)
+
+       CALL gath2cpl(cpl_nsol(:,cpl_index), cpl_nsol2D(:,:,cpl_index), &
+            knon, knindex)
+
+       CALL gath2cpl(cpl_rain(:,cpl_index), cpl_rain2D(:,:,cpl_index), &
+            knon, knindex)
+
+       CALL gath2cpl(cpl_snow(:,cpl_index), cpl_snow2D(:,:,cpl_index), &
+            knon, knindex)
+
+       CALL gath2cpl(cpl_evap(:,cpl_index), cpl_evap2D(:,:,cpl_index), &
+            knon, knindex)
+
+! cpl_tsol2D(:,:,:) not used!
+       CALL gath2cpl(cpl_tsol(:,cpl_index), cpl_tsol2D(:,:, cpl_index), &
+            knon, knindex)
+
+! cpl_fder2D(:,:,1) not used, only cpl_fder(:,:,2)!
+       CALL gath2cpl(cpl_fder(:,cpl_index), cpl_fder2D(:,:,cpl_index), &
+            knon, knindex)
+
+! cpl_albe2D(:,:,:) not used!
+       CALL gath2cpl(cpl_albe(:,cpl_index), cpl_albe2D(:,:,cpl_index), &
+            knon, knindex)
+
+       CALL gath2cpl(cpl_taux(:,cpl_index), cpl_taux2D(:,:,cpl_index), &
+            knon, knindex)
+
+       CALL gath2cpl(cpl_tauy(:,cpl_index), cpl_tauy2D(:,:,cpl_index), &
+            knon, knindex)
+
+       CALL gath2cpl(cpl_windsp(:,cpl_index), cpl_windsp2D(:,:), &
+            knon, knindex)
+
+       CALL gath2cpl(cpl_sens_rain(:,cpl_index), cpl_sens_rain2D(:,:,cpl_index), &
+            knon, knindex)
+
+       CALL gath2cpl(cpl_sens_snow(:,cpl_index), cpl_sens_snow2D(:,:,cpl_index), &
+            knon, knindex)
+
+       CALL gath2cpl(cpl_taumod(:,cpl_index), cpl_taumod2D(:,:,cpl_index), &
+            knon, knindex)
+
+       IF (carbon_cycle_cpl) &
+            CALL gath2cpl(cpl_atm_co2(:,cpl_index), cpl_atm_co22D(:,:), knon, knindex)
+       if (activate_ocean_skin == 2) then
+          CALL gath2cpl(cpl_delta_sst, cpl_delta_sst_2D, knon, knindex)
+          CALL gath2cpl(cpl_delta_sal, cpl_delta_sal_2D, knon, knindex)
+          CALL gath2cpl(cpl_dter, cpl_dter_2D, knon, knindex)
+          CALL gath2cpl(cpl_dser, cpl_dser_2D, knon, knindex)
+          CALL gath2cpl(cpl_dt_ds, cpl_dt_ds_2D, knon, knindex)
+       end if
+    ENDIF
+
+  END SUBROUTINE cpl_send_ocean_fields
+
+!
+!*************************************************************************************
+!
+
+  SUBROUTINE cpl_send_seaice_fields(itime, dtime, knon, knindex, &
+       pctsrf, lafin, rlon, rlat, &
+       swdown, lwdown, fluxlat, fluxsens, &
+       precip_rain, precip_snow, evap, tsurf, fder, albsol, taux, tauy,&
+       sens_prec_liq, sens_prec_sol, lat_prec_liq, lat_prec_sol)
+!
+! This subroutine cumulates some fields for each time-step during a coupling 
+! period. At last time-step in a coupling period the fields are transformed to the 
+! grid accepted by the coupler. All fields for all types of surfaces are sent to
+! the coupler.
+!
+    USE carbon_cycle_mod, ONLY : carbon_cycle_cpl
+    USE indice_sol_mod
+    USE mod_grid_phy_lmdz, ONLY : nbp_lon, nbp_lat
+
+! Input arguments
+!*************************************************************************************
+    INTEGER, INTENT(IN)                     :: itime
+    INTEGER, INTENT(IN)                     :: knon
+    INTEGER, DIMENSION(klon), INTENT(IN)    :: knindex
+    REAL, INTENT(IN)                        :: dtime
+    REAL, DIMENSION(klon), INTENT(IN)       :: rlon, rlat
+    REAL, DIMENSION(klon), INTENT(IN)       :: swdown, lwdown 
+    REAL, DIMENSION(klon), INTENT(IN)       :: fluxlat, fluxsens
+    REAL, DIMENSION(klon), INTENT(IN)       :: precip_rain, precip_snow
+    REAL, DIMENSION(klon), INTENT(IN)       :: evap, tsurf, fder
+    REAL, DIMENSION(klon), INTENT(IN)       :: albsol, taux, tauy
+    REAL, DIMENSION(klon,nbsrf), INTENT(IN) :: pctsrf
+    REAL, INTENT(IN):: sens_prec_liq(:), sens_prec_sol(:) ! (knon)
+    REAL, DIMENSION(klon), INTENT(IN)       :: lat_prec_liq, lat_prec_sol
+    LOGICAL, INTENT(IN)                     :: lafin
+
+! Local variables
+!*************************************************************************************
+    INTEGER                                 :: cpl_index, ig 
+    INTEGER                                 :: error, sum_error
+    CHARACTER(len = 25)                     :: modname = 'cpl_send_seaice_fields'
+    CHARACTER(len = 80)                     :: abort_message
+    REAL, DIMENSION(klon)                   :: cpl_fder_tmp
+
+!*************************************************************************************
+! Start calulation
+! The sea-ice points are saved with second array index=2
+!
+!*************************************************************************************
+    cpl_index = 2
+
+!*************************************************************************************
+! Reset fields to zero in the beginning of a new coupling period 
+!
+!*************************************************************************************
+    IF (MOD(itime, nexca) == 1) THEN
+       cpl_sols(1:knon,cpl_index) = 0.0
+       cpl_nsol(1:knon,cpl_index) = 0.0
+       cpl_rain(1:knon,cpl_index) = 0.0
+       cpl_snow(1:knon,cpl_index) = 0.0
+       cpl_evap(1:knon,cpl_index) = 0.0
+       cpl_tsol(1:knon,cpl_index) = 0.0
+       cpl_fder(1:knon,cpl_index) = 0.0
+       cpl_albe(1:knon,cpl_index) = 0.0
+       cpl_taux(1:knon,cpl_index) = 0.0
+       cpl_tauy(1:knon,cpl_index) = 0.0
+       cpl_sens_rain(1:knon,cpl_index) = 0.0
+       cpl_sens_snow(1:knon,cpl_index) = 0.0
+       cpl_taumod(1:knon,cpl_index) = 0.0
+    ENDIF
+       
+!*************************************************************************************
+! Cumulate at each time-step
+!
+!*************************************************************************************    
+    DO ig = 1, knon
+       cpl_sols(ig,cpl_index) = cpl_sols(ig,cpl_index) + &
+            swdown(ig)      / REAL(nexca)
+       cpl_nsol(ig,cpl_index) = cpl_nsol(ig,cpl_index) + &
+            (lwdown(ig) + fluxlat(ig) +fluxsens(ig)) / REAL(nexca)
+       cpl_rain(ig,cpl_index) = cpl_rain(ig,cpl_index) + &
+            precip_rain(ig) / REAL(nexca)
+       cpl_snow(ig,cpl_index) = cpl_snow(ig,cpl_index) + &
+            precip_snow(ig) / REAL(nexca)
+       cpl_evap(ig,cpl_index) = cpl_evap(ig,cpl_index) + &
+            evap(ig)        / REAL(nexca)
+       cpl_tsol(ig,cpl_index) = cpl_tsol(ig,cpl_index) + &
+            tsurf(ig)       / REAL(nexca)
+       cpl_fder(ig,cpl_index) = cpl_fder(ig,cpl_index) + &
+            fder(ig)        / REAL(nexca)
+       cpl_albe(ig,cpl_index) = cpl_albe(ig,cpl_index) + &
+            albsol(ig)      / REAL(nexca)
+       cpl_taux(ig,cpl_index) = cpl_taux(ig,cpl_index) + &
+            taux(ig)        / REAL(nexca)
+       cpl_tauy(ig,cpl_index) = cpl_tauy(ig,cpl_index) + &
+            tauy(ig)        / REAL(nexca)     
+       cpl_sens_rain(ig,cpl_index) = cpl_sens_rain(ig,cpl_index) + &
+            sens_prec_liq(ig)      / REAL(nexca)
+       cpl_sens_snow(ig,cpl_index) = cpl_sens_snow(ig,cpl_index) + &
+            sens_prec_sol(ig)      / REAL(nexca)
+       cpl_taumod(ig,cpl_index) = cpl_taumod(ig,cpl_index) + &
+            SQRT ( taux(ig)*taux(ig)+tauy(ig)*tauy(ig) ) / REAL(nexca) 
+    ENDDO
+
+!*************************************************************************************
+! If the time-step corresponds to the end of coupling period the 
+! fields are transformed to the 2D grid and all fields are sent to coupler.
+!
+!*************************************************************************************
+    IF (MOD(itime, nexca) == 0) THEN
+       IF (.NOT. ALLOCATED(cpl_sols2D)) THEN
+          sum_error = 0
+          ALLOCATE(cpl_sols2D(nbp_lon,jj_nb,2), stat=error)
+          sum_error = sum_error + error
+          ALLOCATE(cpl_nsol2D(nbp_lon,jj_nb,2), stat=error)
+          sum_error = sum_error + error
+          ALLOCATE(cpl_rain2D(nbp_lon,jj_nb,2), stat=error)
+          sum_error = sum_error + error
+          ALLOCATE(cpl_snow2D(nbp_lon,jj_nb,2), stat=error)
+          sum_error = sum_error + error
+          ALLOCATE(cpl_evap2D(nbp_lon,jj_nb,2), stat=error)
+          sum_error = sum_error + error
+          ALLOCATE(cpl_tsol2D(nbp_lon,jj_nb,2), stat=error)
+          sum_error = sum_error + error
+          ALLOCATE(cpl_fder2D(nbp_lon,jj_nb,2), stat=error)
+          sum_error = sum_error + error
+          ALLOCATE(cpl_albe2D(nbp_lon,jj_nb,2), stat=error)
+          sum_error = sum_error + error
+          ALLOCATE(cpl_taux2D(nbp_lon,jj_nb,2), stat=error)
+          sum_error = sum_error + error
+          ALLOCATE(cpl_tauy2D(nbp_lon,jj_nb,2), stat=error)
+          sum_error = sum_error + error
+          ALLOCATE(cpl_windsp2D(nbp_lon,jj_nb), stat=error)
+          sum_error = sum_error + error
+          ALLOCATE(cpl_sens_rain2D(nbp_lon,jj_nb,2), stat=error)
+          sum_error = sum_error + error
+          ALLOCATE(cpl_sens_snow2D(nbp_lon,jj_nb,2), stat=error)
+          sum_error = sum_error + error
+          ALLOCATE(cpl_taumod2D(nbp_lon,jj_nb,2), stat=error)
+          sum_error = sum_error + error
+
+          IF (carbon_cycle_cpl) THEN
+             ALLOCATE(cpl_atm_co22D(nbp_lon,jj_nb), stat=error)
+             sum_error = sum_error + error
+          ENDIF
+
+          IF (sum_error /= 0) THEN
+             abort_message='Pb allocation variables couplees pour l''ecriture'
+             CALL abort_physic(modname,abort_message,1)
+          ENDIF
+       ENDIF
+
+       CALL gath2cpl(cpl_sols(:,cpl_index), cpl_sols2D(:,:,cpl_index), &
+            knon, knindex)
+
+       CALL gath2cpl(cpl_nsol(:,cpl_index), cpl_nsol2D(:,:,cpl_index), &
+            knon, knindex)
+
+       CALL gath2cpl(cpl_rain(:,cpl_index), cpl_rain2D(:,:,cpl_index), &
+            knon, knindex)
+
+       CALL gath2cpl(cpl_snow(:,cpl_index), cpl_snow2D(:,:,cpl_index), &
+            knon, knindex)
+
+       CALL gath2cpl(cpl_evap(:,cpl_index), cpl_evap2D(:,:,cpl_index), &
+            knon, knindex)
+
+! cpl_tsol2D(:,:,:) not used!
+       CALL gath2cpl(cpl_tsol(:,cpl_index), cpl_tsol2D(:,:, cpl_index), &
+            knon, knindex)
+
+       ! Set default value and decompress before gath2cpl
+       cpl_fder_tmp(:) = -20.
+       DO ig = 1, knon
+          cpl_fder_tmp(knindex(ig))=cpl_fder(ig,cpl_index)
+       ENDDO
+       CALL gath2cpl(cpl_fder_tmp(:), cpl_fder2D(:,:,cpl_index), &
+            klon, unity)
+
+! cpl_albe2D(:,:,:) not used!
+       CALL gath2cpl(cpl_albe(:,cpl_index), cpl_albe2D(:,:,cpl_index), &
+            knon, knindex)
+
+       CALL gath2cpl(cpl_taux(:,cpl_index), cpl_taux2D(:,:,cpl_index), &
+            knon, knindex)
+
+       CALL gath2cpl(cpl_tauy(:,cpl_index), cpl_tauy2D(:,:,cpl_index), &
+            knon, knindex)
+
+       CALL gath2cpl(cpl_sens_rain(:,cpl_index), cpl_sens_rain2D(:,:,cpl_index), &
+            knon, knindex)
+
+       CALL gath2cpl(cpl_sens_snow(:,cpl_index), cpl_sens_snow2D(:,:,cpl_index), &
+            knon, knindex)
+
+       CALL gath2cpl(cpl_taumod(:,cpl_index), cpl_taumod2D(:,:,cpl_index), &
+            knon, knindex)
+
+       ! Send all fields
+       CALL cpl_send_all(itime, dtime, pctsrf, lafin, rlon, rlat)
+    ENDIF
+
+  END SUBROUTINE cpl_send_seaice_fields
+
+!
+!*************************************************************************************
+!
+
+  SUBROUTINE cpl_send_land_fields(itime, knon, knindex, rriv_in, rcoa_in)
+!
+! This subroutine cumulates some fields for each time-step during a coupling 
+! period. At last time-step in a coupling period the fields are transformed to the 
+! grid accepted by the coupler. No sending to the coupler will be done from here 
+! (it is done in cpl_send_seaice_fields).
+!
+    USE mod_grid_phy_lmdz, ONLY : nbp_lon, nbp_lat
+
+! Input arguments
+!*************************************************************************************
+    INTEGER, INTENT(IN)                       :: itime
+    INTEGER, INTENT(IN)                       :: knon
+    INTEGER, DIMENSION(klon), INTENT(IN)      :: knindex
+    REAL, DIMENSION(klon), INTENT(IN)         :: rriv_in
+    REAL, DIMENSION(klon), INTENT(IN)         :: rcoa_in
+
+! Local variables
+!*************************************************************************************
+    REAL, DIMENSION(nbp_lon,jj_nb)             :: rriv2D
+    REAL, DIMENSION(nbp_lon,jj_nb)             :: rcoa2D
+
+!*************************************************************************************
+! Rearrange fields in 2D variables 
+! First initialize to zero to avoid unvalid points causing problems
+!
+!*************************************************************************************
+!$OMP MASTER
+    rriv2D(:,:) = 0.0
+    rcoa2D(:,:) = 0.0
+!$OMP END MASTER
+    CALL gath2cpl(rriv_in, rriv2D, knon, knindex)
+    CALL gath2cpl(rcoa_in, rcoa2D, knon, knindex)
+
+!*************************************************************************************
+! Reset cumulated fields to zero in the beginning of a new coupling period 
+!
+!*************************************************************************************
+    IF (MOD(itime, nexca) == 1) THEN
+!$OMP MASTER
+       cpl_rriv2D(:,:) = 0.0
+       cpl_rcoa2D(:,:) = 0.0
+!$OMP END MASTER
+    ENDIF
+
+!*************************************************************************************
+! Cumulate : Following fields should be cumulated at each time-step
+!
+!*************************************************************************************    
+!$OMP MASTER
+    cpl_rriv2D(:,:) = cpl_rriv2D(:,:) + rriv2D(:,:) / REAL(nexca)
+    cpl_rcoa2D(:,:) = cpl_rcoa2D(:,:) + rcoa2D(:,:) / REAL(nexca)
+!$OMP END MASTER
+
+  END SUBROUTINE cpl_send_land_fields
+
+!
+!*************************************************************************************
+!
+
+  SUBROUTINE cpl_send_landice_fields(itime, knon, knindex, rlic_in, rlic_in_frac)
+! This subroutine cumulates the field for melting ice for each time-step 
+! during a coupling period. This routine will not send to coupler. Sending 
+! will be done in cpl_send_seaice_fields.
+!
+
+    USE mod_grid_phy_lmdz, ONLY : nbp_lon, nbp_lat
+
+! Input varibales
+!*************************************************************************************
+    INTEGER, INTENT(IN)                       :: itime
+    INTEGER, INTENT(IN)                       :: knon
+    INTEGER, DIMENSION(klon), INTENT(IN)      :: knindex
+    REAL, DIMENSION(klon), INTENT(IN)         :: rlic_in
+    REAL, DIMENSION(klon), INTENT(IN)         :: rlic_in_frac  ! Fraction for continental ice, can be equal to 
+                                                               ! pctsrf(:,is_lic) or not, depending on landice_opt
+    
+
+! Local varibales
+!*************************************************************************************
+    REAL, DIMENSION(nbp_lon,jj_nb)             :: rlic2D
+
+!*************************************************************************************
+! Rearrange field in a 2D variable 
+! First initialize to zero to avoid unvalid points causing problems
+!
+!*************************************************************************************
+!$OMP MASTER
+    rlic2D(:,:) = 0.0
+!$OMP END MASTER
+    CALL gath2cpl(rlic_in, rlic2D, knon, knindex)
+    CALL gath2cpl(rlic_in_frac(:), rlic_in_frac2D(:,:), knon, knindex) 
+!*************************************************************************************
+! Reset field to zero in the beginning of a new coupling period 
+!
+!*************************************************************************************
+    IF (MOD(itime, nexca) == 1) THEN
+!$OMP MASTER
+       cpl_rlic2D(:,:) = 0.0
+!$OMP END MASTER
+    ENDIF
+
+!*************************************************************************************
+! Cumulate : Melting ice should be cumulated at each time-step
+!
+!*************************************************************************************    
+!$OMP MASTER
+    cpl_rlic2D(:,:) = cpl_rlic2D(:,:) + rlic2D(:,:) / REAL(nexca)
+!$OMP END MASTER
+
+  END SUBROUTINE cpl_send_landice_fields
+
+!
+!*************************************************************************************
+!
+
+  SUBROUTINE cpl_send_all(itime, dtime, pctsrf, lafin, rlon, rlat)
+! This routine will send fields for all different surfaces to the coupler.
+! This subroutine should be executed after calculations by the last surface(sea-ice),
+! all calculations at the different surfaces have to be done before. 
+!    
+    USE surface_data
+    USE carbon_cycle_mod, ONLY : carbon_cycle_cpl
+    USE indice_sol_mod
+    USE mod_grid_phy_lmdz, ONLY : nbp_lon, nbp_lat
+    USE time_phylmdz_mod, ONLY: start_time, itau_phy
+    use config_ocean_skin_m, only: activate_ocean_skin
+! Some includes
+!    
+! Input arguments
+!*************************************************************************************
+    INTEGER, INTENT(IN)                                  :: itime
+    REAL, INTENT(IN)                                     :: dtime
+    REAL, DIMENSION(klon), INTENT(IN)                    :: rlon, rlat
+    REAL, DIMENSION(klon,nbsrf), INTENT(IN)              :: pctsrf
+    LOGICAL, INTENT(IN)                                  :: lafin
+    
+! Local variables
+!*************************************************************************************
+    INTEGER                                              :: error, sum_error, i,j,k
+    INTEGER                                              :: itau_w
+    INTEGER                                              :: time_sec
+    INTEGER, DIMENSION(nbp_lon*(nbp_lat))                      :: ndexct
+    REAL                                                 :: Up, Down
+    REAL, DIMENSION(nbp_lon, jj_nb)                          :: tmp_lon, tmp_lat
+    REAL, DIMENSION(nbp_lon, jj_nb, 4)                       :: pctsrf2D
+    REAL, DIMENSION(nbp_lon, jj_nb)                          :: deno
+    CHARACTER(len = 20)                                  :: modname = 'cpl_send_all'
+    CHARACTER(len = 80)                                  :: abort_message
+   
+! Variables with fields to coupler
+    REAL, DIMENSION(nbp_lon, jj_nb)                          :: tmp_taux
+    REAL, DIMENSION(nbp_lon, jj_nb)                          :: tmp_tauy
+    REAL, DIMENSION(nbp_lon, jj_nb)                          :: tmp_calv
+! Table with all fields to send to coupler
+    REAL, DIMENSION(nbp_lon, jj_nb, maxsend)                 :: tab_flds
+    REAL, DIMENSION(klon_mpi)                                :: rlon_mpi, rlat_mpi
+    REAL  :: calving(nb_zone_calving)
+    REAL  :: calving_glo(nb_zone_calving)
+    
+#ifdef CPP_MPI
+    INCLUDE 'mpif.h'
+    INTEGER, DIMENSION(MPI_STATUS_SIZE)                  :: status
+#endif
+
+! End definitions
+!*************************************************************************************
+    
+
+
+!*************************************************************************************
+! All fields are stored in a table tab_flds(:,:,:)
+! First store the fields which are already on the right format
+!
+!*************************************************************************************
+!$OMP MASTER
+    tab_flds(:,:,ids_windsp) = cpl_windsp2D(:,:)
+    tab_flds(:,:,ids_shfice) = cpl_sols2D(:,:,2)
+    tab_flds(:,:,ids_nsfice) = cpl_nsol2D(:,:,2)
+    tab_flds(:,:,ids_dflxdt) = cpl_fder2D(:,:,2)
+    tab_flds(:,:,ids_qraioc) = cpl_sens_rain2D(:,:,1)
+    tab_flds(:,:,ids_qsnooc) = cpl_sens_snow2D(:,:,1)
+    tab_flds(:,:,ids_qraiic) = cpl_sens_rain2D(:,:,2)
+    tab_flds(:,:,ids_qsnoic) = cpl_sens_snow2D(:,:,2)
+
+    if (activate_ocean_skin == 2) then
+       tab_flds(:, :, ids_delta_sst) = cpl_delta_sst_2D
+       tab_flds(:, :, ids_delta_sal) = cpl_delta_sal_2D
+       tab_flds(:, :, ids_dter) = cpl_dter_2D
+       tab_flds(:, :, ids_dser) = cpl_dser_2D
+       tab_flds(:, :, ids_dt_ds) = cpl_dt_ds_2D
+    end if
+    
+    IF (version_ocean=='nemo') THEN
+       tab_flds(:,:,ids_liqrun) = (cpl_rriv2D(:,:) + cpl_rcoa2D(:,:))
+       IF (carbon_cycle_cpl) tab_flds(:,:,ids_atmco2)=cpl_atm_co22D(:,:)
+    ELSE IF (version_ocean=='opa8') THEN
+       tab_flds(:,:,ids_shfoce) = cpl_sols2D(:,:,1)
+       tab_flds(:,:,ids_nsfoce) = cpl_nsol2D(:,:,1)
+       tab_flds(:,:,ids_icevap) = cpl_evap2D(:,:,2)
+       tab_flds(:,:,ids_ocevap) = cpl_evap2D(:,:,1)
+       tab_flds(:,:,ids_runcoa) = cpl_rcoa2D(:,:)
+       tab_flds(:,:,ids_rivflu) = cpl_rriv2D(:,:)
+    ENDIF
+
+!*************************************************************************************
+! Transform the fraction of sub-surfaces from 1D to 2D array
+!
+!*************************************************************************************
+    pctsrf2D(:,:,:) = 0.
+!$OMP END MASTER
+    CALL gath2cpl(pctsrf(:,is_oce), pctsrf2D(:,:,is_oce), klon, unity)
+    CALL gath2cpl(pctsrf(:,is_sic), pctsrf2D(:,:,is_sic), klon, unity)
+
+
+
+
+!*************************************************************************************
+! Calculate the average calving per latitude
+! Store calving in tab_flds(:,:,19)
+! 
+!*************************************************************************************      
+    IF (is_omp_root) THEN
+
+      IF (cpl_old_calving) THEN   ! use old calving
+
+        DO j = 1, jj_nb
+           tmp_calv(:,j) = DOT_PRODUCT (cpl_rlic2D(1:nbp_lon,j), &
+                rlic_in_frac2D(1:nbp_lon,j)) / REAL(nbp_lon)
+        ENDDO
+    
+    
+        IF (is_parallel) THEN
+           IF (.NOT. is_north_pole_dyn) THEN
+#ifdef CPP_MPI
+              CALL MPI_RECV(Up,1,MPI_REAL_LMDZ,mpi_rank-1,1234,COMM_LMDZ_PHY,status,error)
+              CALL MPI_SEND(tmp_calv(1,1),1,MPI_REAL_LMDZ,mpi_rank-1,1234,COMM_LMDZ_PHY,error)
+#endif
+           ENDIF
+       
+           IF (.NOT. is_south_pole_dyn) THEN
+#ifdef CPP_MPI
+              CALL MPI_SEND(tmp_calv(1,jj_nb),1,MPI_REAL_LMDZ,mpi_rank+1,1234,COMM_LMDZ_PHY,error)
+              CALL MPI_RECV(down,1,MPI_REAL_LMDZ,mpi_rank+1,1234,COMM_LMDZ_PHY,status,error)
+#endif
+           ENDIF
+         
+           IF (.NOT. is_north_pole_dyn .AND. ii_begin /=1) THEN
+              Up=Up+tmp_calv(nbp_lon,1)
+              tmp_calv(:,1)=Up
+           ENDIF
+           
+           IF (.NOT. is_south_pole_dyn .AND. ii_end /= nbp_lon) THEN
+              Down=Down+tmp_calv(1,jj_nb)
+              tmp_calv(:,jj_nb)=Down
+           ENDIF
+        ENDIF
+        tab_flds(:,:,ids_calvin) = tmp_calv(:,:)
+
+      ELSE
+         ! cpl_old_calving=FALSE
+         ! To be used with new method for calculation of coupling weights
+         DO k=1,nb_zone_calving
+            calving(k)=0
+            DO j = 1, jj_nb
+               calving(k)= calving(k)+DOT_PRODUCT(cpl_rlic2D(:,j)*area_calving(:,j,k),rlic_in_frac2D(:,j))
+            ENDDO
+         ENDDO
+         
+#ifdef CPP_MPI
+         CALL MPI_ALLREDUCE(calving, calving_glo, nb_zone_calving, MPI_REAL_LMDZ, MPI_SUM, COMM_LMDZ_PHY, error)
+#endif
+         
+         tab_flds(:,:,ids_calvin) = 0
+         DO k=1,nb_zone_calving
+            IF (ind_calving(k)>0 ) THEN
+               j=(ind_calving(k)-1)/nbp_lon + 1
+               i=MOD(ind_calving(k)-1,nbp_lon)+1
+               tab_flds(i,j,ids_calvin) = calving_glo(k)
+            ENDIF
+         ENDDO
+         
+      ENDIF
+      
+!*************************************************************************************
+! Calculate total flux for snow, rain and wind with weighted addition using the 
+! fractions of ocean and seaice.
+!
+!*************************************************************************************    
+       ! fraction oce+seaice
+       deno =  pctsrf2D(:,:,is_oce) + pctsrf2D(:,:,is_sic) 
+
+       IF (version_ocean=='nemo') THEN
+          tab_flds(:,:,ids_shftot)  = 0.0
+          tab_flds(:,:,ids_nsftot) = 0.0
+          tab_flds(:,:,ids_totrai) = 0.0
+          tab_flds(:,:,ids_totsno) = 0.0
+          tab_flds(:,:,ids_toteva) = 0.0
+          tab_flds(:,:,ids_taumod) = 0.0
+  
+          tmp_taux(:,:)    = 0.0
+          tmp_tauy(:,:)    = 0.0
+          ! For all valid grid cells containing some fraction of ocean or sea-ice
+          WHERE ( deno(:,:) /= 0 )
+             tmp_taux = cpl_taux2D(:,:,1) * pctsrf2D(:,:,is_oce) / deno(:,:) +    &
+                  cpl_taux2D(:,:,2) * pctsrf2D(:,:,is_sic) / deno(:,:)
+             tmp_tauy = cpl_tauy2D(:,:,1) * pctsrf2D(:,:,is_oce) / deno(:,:) +    &
+                  cpl_tauy2D(:,:,2) * pctsrf2D(:,:,is_sic) / deno(:,:)
+
+             tab_flds(:,:,ids_shftot) = cpl_sols2D(:,:,1) * pctsrf2D(:,:,is_oce) / deno(:,:) +    &
+                  cpl_sols2D(:,:,2) * pctsrf2D(:,:,is_sic) / deno(:,:)
+             tab_flds(:,:,ids_nsftot) = cpl_nsol2D(:,:,1) * pctsrf2D(:,:,is_oce) / deno(:,:) +    &
+                  cpl_nsol2D(:,:,2) * pctsrf2D(:,:,is_sic) / deno(:,:)
+             tab_flds(:,:,ids_totrai) = cpl_rain2D(:,:,1) * pctsrf2D(:,:,is_oce) / deno(:,:) +    &
+                  cpl_rain2D(:,:,2) * pctsrf2D(:,:,is_sic) / deno(:,:)
+             tab_flds(:,:,ids_totsno) = cpl_snow2D(:,:,1) * pctsrf2D(:,:,is_oce) / deno(:,:) +    &
+                  cpl_snow2D(:,:,2) * pctsrf2D(:,:,is_sic) / deno(:,:)
+             tab_flds(:,:,ids_toteva) = cpl_evap2D(:,:,1) * pctsrf2D(:,:,is_oce) / deno(:,:) +    &
+                  cpl_evap2D(:,:,2)  * pctsrf2D(:,:,is_sic) / deno(:,:)
+             tab_flds(:,:,ids_taumod) = cpl_taumod2D(:,:,1) * pctsrf2D(:,:,is_oce) / deno(:,:) +    &
+                  cpl_taumod2D(:,:,2) * pctsrf2D(:,:,is_sic) / deno(:,:)
+             
+         ENDWHERE
+
+          tab_flds(:,:,ids_icevap) = cpl_evap2D(:,:,2) 
+          
+       ELSE IF (version_ocean=='opa8') THEN
+          ! Store fields for rain and snow in tab_flds(:,:,15) and tab_flds(:,:,16)
+          tab_flds(:,:,ids_totrai) = 0.0
+          tab_flds(:,:,ids_totsno) = 0.0
+          tmp_taux(:,:)    = 0.0
+          tmp_tauy(:,:)    = 0.0
+          ! For all valid grid cells containing some fraction of ocean or sea-ice
+          WHERE ( deno(:,:) /= 0 )
+             tab_flds(:,:,ids_totrai) = cpl_rain2D(:,:,1) * pctsrf2D(:,:,is_oce) / deno(:,:) +    &
+                  cpl_rain2D(:,:,2) * pctsrf2D(:,:,is_sic) / deno(:,:)
+             tab_flds(:,:,ids_totsno) = cpl_snow2D(:,:,1) * pctsrf2D(:,:,is_oce) / deno(:,:) +    &
+                  cpl_snow2D(:,:,2) * pctsrf2D(:,:,is_sic) / deno(:,:)
+             
+             tmp_taux = cpl_taux2D(:,:,1) * pctsrf2D(:,:,is_oce) / deno(:,:) +    &
+                  cpl_taux2D(:,:,2) * pctsrf2D(:,:,is_sic) / deno(:,:)
+             tmp_tauy = cpl_tauy2D(:,:,1) * pctsrf2D(:,:,is_oce) / deno(:,:) +    &
+                  cpl_tauy2D(:,:,2) * pctsrf2D(:,:,is_sic) / deno(:,:)
+          ENDWHERE
+       ENDIF
+
+    ENDIF ! is_omp_root
+  
+!*************************************************************************************
+! Transform the wind components from local atmospheric 2D coordinates to geocentric 
+! 3D coordinates. 
+! Store the resulting wind components in tab_flds(:,:,1:6)
+!*************************************************************************************
+
+! Transform the longitudes and latitudes on 2D arrays
+    
+    CALL gather_omp(rlon,rlon_mpi)
+    CALL gather_omp(rlat,rlat_mpi)
+!$OMP MASTER
+    CALL Grid1DTo2D_mpi(rlon_mpi,tmp_lon)
+    CALL Grid1DTo2D_mpi(rlat_mpi,tmp_lat)
+!$OMP END MASTER    
+
+    IF (is_sequential) THEN
+       IF (is_north_pole_dyn) tmp_lon(:,1)     = tmp_lon(:,2)
+       IF (is_south_pole_dyn) tmp_lon(:,nbp_lat) = tmp_lon(:,nbp_lat-1)
+    ENDIF
+      
+! NetCDF output of the wind before transformation of coordinate system
+    IF (is_sequential) THEN
+       ndexct(:) = 0
+       itau_w = itau_phy + itime + start_time * day_step_phy
+       CALL histwrite(nidct,'tauxe',itau_w,tmp_taux,nbp_lon*(nbp_lat),ndexct)
+       CALL histwrite(nidct,'tauyn',itau_w,tmp_tauy,nbp_lon*(nbp_lat),ndexct)
+       CALL histwrite(nidct,'tmp_lon',itau_w,tmp_lon,nbp_lon*(nbp_lat),ndexct)
+       CALL histwrite(nidct,'tmp_lat',itau_w,tmp_lat,nbp_lon*(nbp_lat),ndexct)
+    ENDIF
+
+! Transform the wind from spherical atmospheric 2D coordinates to geocentric
+! cartesian 3D coordinates 
+!$OMP MASTER
+    CALL atm2geo (nbp_lon, jj_nb, tmp_taux, tmp_tauy, tmp_lon, tmp_lat, &
+         tab_flds(:,:,ids_tauxxu), tab_flds(:,:,ids_tauyyu), tab_flds(:,:,ids_tauzzu) )
+    
+    tab_flds(:,:,ids_tauxxv)  = tab_flds(:,:,ids_tauxxu)
+    tab_flds(:,:,ids_tauyyv)  = tab_flds(:,:,ids_tauyyu)
+    tab_flds(:,:,ids_tauzzv)  = tab_flds(:,:,ids_tauzzu)
+!$OMP END MASTER
+
+!*************************************************************************************
+! NetCDF output of all fields just before sending to coupler.
+!
+!*************************************************************************************
+    IF (is_sequential) THEN
+        DO j=1,maxsend
+          IF (infosend(j)%action) CALL histwrite(nidct,infosend(j)%name, itau_w, &
+             tab_flds(:,:,j),nbp_lon*(nbp_lat),ndexct)
+        ENDDO
+    ENDIF
+!*************************************************************************************
+! Send the table of all fields
+!
+!*************************************************************************************
+    time_sec=(itime-1)*dtime
+#ifdef CPP_COUPLE
+!$OMP MASTER
+    CALL intocpl(time_sec, lafin, tab_flds(:,:,:))
+!$OMP END MASTER
+#endif
+
+!*************************************************************************************
+! Finish with some dellocate
+!
+!*************************************************************************************  
+    sum_error=0
+    DEALLOCATE(cpl_sols2D, cpl_nsol2D, cpl_rain2D, cpl_snow2D, stat=error )
+    sum_error = sum_error + error
+    DEALLOCATE(cpl_evap2D, cpl_tsol2D, cpl_fder2D, cpl_albe2D, stat=error )
+    sum_error = sum_error + error
+    DEALLOCATE(cpl_taux2D, cpl_tauy2D, cpl_windsp2D, cpl_taumod2D, stat=error )
+    sum_error = sum_error + error
+    DEALLOCATE(cpl_sens_rain2D, cpl_sens_snow2D, stat=error)
+    sum_error = sum_error + error
+
+    
+    IF (carbon_cycle_cpl) THEN
+       DEALLOCATE(cpl_atm_co22D, stat=error )
+       sum_error = sum_error + error
+    ENDIF
+
+    if (activate_ocean_skin == 2) deallocate(cpl_delta_sst_2d, &
+         cpl_delta_sal_2d, cpl_dter_2d, cpl_dser_2d, cpl_dt_ds_2d)
+
+    IF (sum_error /= 0) THEN
+       abort_message='Pb in deallocation of cpl_xxxx2D coupling variables'
+       CALL abort_physic(modname,abort_message,1)
+    ENDIF
+    
+  END SUBROUTINE cpl_send_all
+!
+!*************************************************************************************
+!
+  SUBROUTINE cpl2gath(champ_in, champ_out, knon, knindex)
+  USE mod_phys_lmdz_para
+! Cette routine transforme un champs de la grille 2D recu du coupleur sur la grille 
+! 'gathered' (la grille physiq comprime).
+!
+! 
+! input:         
+!   champ_in     champ sur la grille 2D
+!   knon         nombre de points dans le domaine a traiter
+!   knindex      index des points de la surface a traiter
+!
+! output:
+!   champ_out    champ sur la grille 'gatherd'
+!
+    USE mod_grid_phy_lmdz, ONLY : nbp_lon, nbp_lat
+
+! Input
+    INTEGER, INTENT(IN)                       :: knon
+    REAL, DIMENSION(nbp_lon,jj_nb), INTENT(IN)    :: champ_in
+    INTEGER, DIMENSION(klon), INTENT(IN)      :: knindex
+
+! Output
+    REAL, DIMENSION(klon_mpi), INTENT(OUT)        :: champ_out
+
+! Local
+    INTEGER                                   :: i, ig
+    REAL, DIMENSION(klon_mpi)                 :: temp_mpi
+    REAL, DIMENSION(klon)                     :: temp_omp
+
+!*************************************************************************************
+!
+    
+
+! Transform from 2 dimensions (nbp_lon,jj_nb) to 1 dimension (klon)
+!$OMP MASTER 
+    CALL Grid2Dto1D_mpi(champ_in,temp_mpi)
+!$OMP END MASTER
+
+    CALL scatter_omp(temp_mpi,temp_omp)
+    
+! Compress from klon to knon
+    DO i = 1, knon
+       ig = knindex(i)
+       champ_out(i) = temp_omp(ig)
+    ENDDO
+
+  END SUBROUTINE cpl2gath
+!
+!*************************************************************************************
+!
+  SUBROUTINE gath2cpl(champ_in, champ_out, knon, knindex)
+  USE mod_phys_lmdz_para
+! Cette routine ecrit un champ 'gathered' sur la grille 2D pour le passer
+! au coupleur.
+!
+! input:         
+!   champ_in     champ sur la grille gathere        
+!   knon         nombre de points dans le domaine a traiter
+!   knindex      index des points de la surface a traiter
+!
+! output:
+!   champ_out    champ sur la grille 2D
+!
+    USE mod_grid_phy_lmdz, ONLY : nbp_lon, nbp_lat
+    
+! Input arguments
+!*************************************************************************************
+    INTEGER, INTENT(IN)                    :: knon
+    REAL, DIMENSION(klon), INTENT(IN)      :: champ_in
+    INTEGER, DIMENSION(klon), INTENT(IN)   :: knindex
+
+! Output arguments
+!*************************************************************************************
+    REAL, DIMENSION(nbp_lon,jj_nb), INTENT(OUT) :: champ_out
+
+! Local variables
+!*************************************************************************************
+    INTEGER                                :: i, ig
+    REAL, DIMENSION(klon)                  :: temp_omp
+    REAL, DIMENSION(klon_mpi)              :: temp_mpi
+!*************************************************************************************
+
+! Decompress from knon to klon
+    temp_omp = 0.
+    DO i = 1, knon
+       ig = knindex(i)
+       temp_omp(ig) = champ_in(i)
+    ENDDO
+
+! Transform from 1 dimension (klon) to 2 dimensions (nbp_lon,jj_nb)
+    CALL gather_omp(temp_omp,temp_mpi)
+
+!$OMP MASTER    
+    CALL Grid1Dto2D_mpi(temp_mpi,champ_out)
+    
+    IF (is_north_pole_dyn) champ_out(:,1)=temp_mpi(1)
+    IF (is_south_pole_dyn) champ_out(:,jj_nb)=temp_mpi(klon)
+!$OMP END MASTER
+    
+  END SUBROUTINE gath2cpl
+!
+!*************************************************************************************
+!
+END MODULE cpl_mod
+
Index: CONFIG/UNIFORM/v6/IPSLCM6.3/SOURCES/LMDZ/oasis.F90
===================================================================
--- CONFIG/UNIFORM/v6/IPSLCM6.3/SOURCES/LMDZ/oasis.F90	(revision 6571)
+++ CONFIG/UNIFORM/v6/IPSLCM6.3/SOURCES/LMDZ/oasis.F90	(revision 6571)
@@ -0,0 +1,583 @@
+!
+MODULE oasis
+!
+! This module contains subroutines for initialization, sending and receiving 
+! towards the coupler OASIS3. It also contains some parameters for the coupling.
+!
+! This module should always be compiled. With the coupler OASIS3 available the cpp key
+! CPP_COUPLE should be set and the entier of this file will then be compiled. 
+! In a forced mode CPP_COUPLE should not be defined and the compilation ends before 
+! the CONTAINS, without compiling the subroutines.
+!
+  USE dimphy 
+  USE mod_phys_lmdz_para
+  USE write_field_phy
+
+#ifdef CPP_COUPLE
+! Use of Oasis-MCT coupler 
+#if defined CPP_OMCT
+  USE mod_prism
+! Use of Oasis3 coupler 
+#else 
+  USE mod_prism_proto
+  USE mod_prism_def_partition_proto
+  USE mod_prism_get_proto
+  USE mod_prism_put_proto
+#endif
+!AC#ifdef CPP_CPLOCNINCA
+!AC  USE incaoasis, ONLY : inforcv
+!AC#endif
+#endif
+  
+  IMPLICIT NONE
+  
+  ! Id for fields sent to ocean
+  INTEGER, PARAMETER :: ids_tauxxu = 1
+  INTEGER, PARAMETER :: ids_tauyyu = 2
+  INTEGER, PARAMETER :: ids_tauzzu = 3
+  INTEGER, PARAMETER :: ids_tauxxv = 4
+  INTEGER, PARAMETER :: ids_tauyyv = 5
+  INTEGER, PARAMETER :: ids_tauzzv = 6
+  INTEGER, PARAMETER :: ids_windsp = 7
+  INTEGER, PARAMETER :: ids_shfice = 8
+  INTEGER, PARAMETER :: ids_shfoce = 9
+  INTEGER, PARAMETER :: ids_shftot = 10
+  INTEGER, PARAMETER :: ids_nsfice = 11
+  INTEGER, PARAMETER :: ids_nsfoce = 12
+  INTEGER, PARAMETER :: ids_nsftot = 13
+  INTEGER, PARAMETER :: ids_dflxdt = 14
+  INTEGER, PARAMETER :: ids_totrai = 15
+  INTEGER, PARAMETER :: ids_totsno = 16
+  INTEGER, PARAMETER :: ids_toteva = 17
+  INTEGER, PARAMETER :: ids_icevap = 18
+  INTEGER, PARAMETER :: ids_ocevap = 19
+  INTEGER, PARAMETER :: ids_calvin = 20
+  INTEGER, PARAMETER :: ids_liqrun = 21
+  INTEGER, PARAMETER :: ids_runcoa = 22
+  INTEGER, PARAMETER :: ids_rivflu = 23
+  INTEGER, PARAMETER :: ids_atmco2 = 24
+  INTEGER, PARAMETER :: ids_taumod = 25
+  INTEGER, PARAMETER :: ids_qraioc = 26
+  INTEGER, PARAMETER :: ids_qsnooc = 27
+  INTEGER, PARAMETER :: ids_qraiic = 28
+  INTEGER, PARAMETER :: ids_qsnoic = 29
+  INTEGER, PARAMETER :: ids_delta_sst = 30, ids_delta_sal = 31, ids_dter = 32, &
+       ids_dser = 33, ids_dt_ds = 34
+  
+  INTEGER, PARAMETER :: maxsend    = 34  ! Maximum number of fields to send
+  
+  ! Id for fields received from ocean
+
+  INTEGER, PARAMETER :: idr_sisutw = 1
+  INTEGER, PARAMETER :: idr_icecov = 2
+  INTEGER, PARAMETER :: idr_icealw = 3
+  INTEGER, PARAMETER :: idr_icetem = 4
+  INTEGER, PARAMETER :: idr_curenx = 5
+  INTEGER, PARAMETER :: idr_cureny = 6
+  INTEGER, PARAMETER :: idr_curenz = 7
+  INTEGER, PARAMETER :: idr_oceco2 = 8
+
+  INTEGER, PARAMETER :: idr_sss = 9
+  INTEGER, PARAMETER :: idr_ocedms = 10
+  ! bulk salinity of the surface layer of the ocean, in ppt
+
+!AC  INTEGER, PARAMETER :: maxrecv    = 9  ! Maximum number of fields to receive
+  INTEGER, PARAMETER :: maxrecv      = 10  ! Maximum number of fields to receive
+  INTEGER, PARAMETER :: maxrecv_phys = 9      ! Maximum number of fields to receive in physiq (without fields receive in inca model)
+  
+#ifdef CPP_CPLOCNINCA
+!AC  INTEGER, PARAMETER :: idr_ocedms = 1
+!AC  INTEGER, PARAMETER :: maxrcv = 1
+#endif
+
+  TYPE, PUBLIC ::   FLD_CPL            ! Type for coupling field information
+     CHARACTER(len = 8) ::   name      ! Name of the coupling field   
+     LOGICAL            ::   action    ! To be exchanged or not
+     INTEGER            ::   nid       ! Id of the field
+  END TYPE FLD_CPL
+
+  TYPE(FLD_CPL), DIMENSION(maxsend), SAVE, PUBLIC :: infosend   ! Information for sending coupling fields
+!$OMP THREADPRIVATE(infosend)
+  TYPE(FLD_CPL), DIMENSION(maxrecv), SAVE, PUBLIC :: inforecv   ! Information for receiving coupling fields
+!$OMP THREADPRIVATE(inforecv)
+  
+  LOGICAL,SAVE :: cpl_current
+!$OMP THREADPRIVATE(cpl_current)
+
+#ifdef CPP_COUPLE
+
+CONTAINS
+
+  SUBROUTINE inicma
+!************************************************************************************
+!**** *INICMA*  - Initialize coupled mode communication for atmosphere
+!                 and exchange some initial information with Oasis
+!
+!     Rewrite to take the PRISM/psmile library into account
+!     LF 09/2003
+!
+    USE IOIPSL
+    USE surface_data, ONLY : version_ocean
+    USE carbon_cycle_mod, ONLY : carbon_cycle_cpl
+    USE chemistry_cycle_mod, ONLY : dms_cycle_cpl
+#ifdef CPP_XIOS
+    USE wxios, ONLY : wxios_context_init 
+    USE xios  
+#endif
+    USE print_control_mod, ONLY: lunout
+    USE mod_grid_phy_lmdz, ONLY: nbp_lon, nbp_lat, grid_type, unstructured, regular_lonlat
+    USE geometry_mod, ONLY: ind_cell_glo                    
+    USE mod_phys_lmdz_mpi_data, ONLY: klon_mpi_para_nb
+    use config_ocean_skin_m, only: activate_ocean_skin
+
+! Local variables
+!************************************************************************************
+    INTEGER                            :: comp_id
+    INTEGER                            :: ierror, il_commlocal
+    INTEGER                            :: il_part_id
+    INTEGER, ALLOCATABLE               :: ig_paral(:)
+    INTEGER, DIMENSION(2)              :: il_var_nodims
+    INTEGER, DIMENSION(4)              :: il_var_actual_shape
+    INTEGER                            :: il_var_type
+    INTEGER                            :: jf
+    CHARACTER (len = 6)                :: clmodnam
+    CHARACTER (len = 20)               :: modname = 'inicma'
+    CHARACTER (len = 80)               :: abort_message 
+    LOGICAL, SAVE                      :: cpl_current_omp
+
+!*    1. Initializations
+!        ---------------
+!************************************************************************************
+    WRITE(lunout,*) ' '
+    WRITE(lunout,*) ' '
+    WRITE(lunout,*) ' ROUTINE INICMA'
+    WRITE(lunout,*) ' **************'
+    WRITE(lunout,*) ' '
+    WRITE(lunout,*) ' '
+
+!
+! Define the model name
+!
+    IF (grid_type==unstructured) THEN
+        clmodnam = 'icosa'                 ! as in $NBMODEL in Cpl/Nam/namcouple.tmp
+    ELSE IF (grid_type==regular_lonlat) THEN
+        clmodnam = 'LMDZ'                  ! as in $NBMODEL in Cpl/Nam/namcouple.tmp
+    ELSE
+	abort_message='Pb : type of grid unknown'
+	CALL abort_physic(modname,abort_message,1)
+    ENDIF
+
+
+!************************************************************************************
+! Define if coupling ocean currents or not
+!************************************************************************************
+!$OMP MASTER
+    cpl_current_omp = .FALSE.
+    CALL getin('cpl_current', cpl_current_omp)
+!$OMP END MASTER
+!$OMP BARRIER
+    cpl_current = cpl_current_omp
+    WRITE(lunout,*) 'Couple ocean currents, cpl_current = ',cpl_current 
+
+!************************************************************************************
+! Define coupling variables
+!************************************************************************************
+
+! Atmospheric variables to send
+
+!$OMP MASTER
+    infosend(:)%action = .FALSE.
+
+    infosend(ids_tauxxu)%action = .TRUE. ; infosend(ids_tauxxu)%name = 'COTAUXXU'
+    infosend(ids_tauyyu)%action = .TRUE. ; infosend(ids_tauyyu)%name = 'COTAUYYU'
+    infosend(ids_tauzzu)%action = .TRUE. ; infosend(ids_tauzzu)%name = 'COTAUZZU'
+    infosend(ids_tauxxv)%action = .TRUE. ; infosend(ids_tauxxv)%name = 'COTAUXXV'
+    infosend(ids_tauyyv)%action = .TRUE. ; infosend(ids_tauyyv)%name = 'COTAUYYV'
+    infosend(ids_tauzzv)%action = .TRUE. ; infosend(ids_tauzzv)%name = 'COTAUZZV'
+    infosend(ids_windsp)%action = .TRUE. ; infosend(ids_windsp)%name = 'COWINDSP'
+    infosend(ids_shfice)%action = .TRUE. ; infosend(ids_shfice)%name = 'COSHFICE'
+    infosend(ids_nsfice)%action = .TRUE. ; infosend(ids_nsfice)%name = 'CONSFICE'
+    infosend(ids_dflxdt)%action = .TRUE. ; infosend(ids_dflxdt)%name = 'CODFLXDT'
+    infosend(ids_calvin)%action = .TRUE. ; infosend(ids_calvin)%name = 'COCALVIN'
+    
+    if (activate_ocean_skin == 2) then
+       infosend(ids_delta_sst)%action = .TRUE.
+       infosend(ids_delta_sst)%name = 'CODELSST'
+       infosend(ids_delta_sal)%action = .TRUE.
+       infosend(ids_delta_sal)%name = 'CODELSSS'
+       infosend(ids_dter)%action = .TRUE.
+       infosend(ids_dter)%name = 'CODELTER'
+       infosend(ids_dser)%action = .TRUE.
+       infosend(ids_dser)%name = 'CODELSER'
+       infosend(ids_dt_ds)%action = .TRUE.
+       infosend(ids_dt_ds)%name = 'CODTDS'
+    end if
+           
+    IF (version_ocean=='nemo') THEN
+        infosend(ids_shftot)%action = .TRUE. ; infosend(ids_shftot)%name = 'COQSRMIX'
+        infosend(ids_nsftot)%action = .TRUE. ; infosend(ids_nsftot)%name = 'COQNSMIX'
+        infosend(ids_totrai)%action = .TRUE. ; infosend(ids_totrai)%name = 'COTOTRAI'
+        infosend(ids_totsno)%action = .TRUE. ; infosend(ids_totsno)%name = 'COTOTSNO'
+        infosend(ids_toteva)%action = .TRUE. ; infosend(ids_toteva)%name = 'COTOTEVA'
+        infosend(ids_icevap)%action = .TRUE. ; infosend(ids_icevap)%name = 'COICEVAP'
+        infosend(ids_liqrun)%action = .TRUE. ; infosend(ids_liqrun)%name = 'COLIQRUN'
+        infosend(ids_taumod)%action = .TRUE. ; infosend(ids_taumod)%name = 'COTAUMOD'
+        IF (carbon_cycle_cpl) THEN
+            infosend(ids_atmco2)%action = .TRUE. ; infosend(ids_atmco2)%name = 'COATMCO2'
+        ENDIF
+        infosend(ids_qraioc)%action = .TRUE. ; infosend(ids_qraioc)%name = 'COQRAIOC'
+        infosend(ids_qsnooc)%action = .TRUE. ; infosend(ids_qsnooc)%name = 'COQSNOOC'
+        infosend(ids_qraiic)%action = .TRUE. ; infosend(ids_qraiic)%name = 'COQRAIIC'
+        infosend(ids_qsnoic)%action = .TRUE. ; infosend(ids_qsnoic)%name = 'COQSNOIC'
+        
+    ELSE IF (version_ocean=='opa8') THEN
+        infosend(ids_shfoce)%action = .TRUE. ; infosend(ids_shfoce)%name = 'COSHFOCE'
+        infosend(ids_nsfoce)%action = .TRUE. ; infosend(ids_nsfoce)%name = 'CONSFOCE'
+        infosend(ids_icevap)%action = .TRUE. ; infosend(ids_icevap)%name = 'COTFSICE'
+        infosend(ids_ocevap)%action = .TRUE. ; infosend(ids_ocevap)%name = 'COTFSOCE'
+        infosend(ids_totrai)%action = .TRUE. ; infosend(ids_totrai)%name = 'COTOLPSU'
+        infosend(ids_totsno)%action = .TRUE. ; infosend(ids_totsno)%name = 'COTOSPSU'
+        infosend(ids_runcoa)%action = .TRUE. ; infosend(ids_runcoa)%name = 'CORUNCOA'
+        infosend(ids_rivflu)%action = .TRUE. ; infosend(ids_rivflu)%name = 'CORIVFLU'
+   ENDIF
+        
+! Oceanic variables to receive
+
+   inforecv(:)%action = .FALSE.
+
+   inforecv(idr_sisutw)%action = .TRUE. ; inforecv(idr_sisutw)%name = 'SISUTESW'
+   inforecv(idr_icecov)%action = .TRUE. ; inforecv(idr_icecov)%name = 'SIICECOV'
+   inforecv(idr_icealw)%action = .TRUE. ; inforecv(idr_icealw)%name = 'SIICEALW'
+   inforecv(idr_icetem)%action = .TRUE. ; inforecv(idr_icetem)%name = 'SIICTEMW'
+
+   if (activate_ocean_skin >= 1) then
+      inforecv(idr_sss)%action = .TRUE.
+      inforecv(idr_sss)%name = 'SISUSALW'
+   end if
+   
+   IF (cpl_current ) THEN
+       inforecv(idr_curenx)%action = .TRUE. ; inforecv(idr_curenx)%name = 'CURRENTX'
+       inforecv(idr_cureny)%action = .TRUE. ; inforecv(idr_cureny)%name = 'CURRENTY'
+       inforecv(idr_curenz)%action = .TRUE. ; inforecv(idr_curenz)%name = 'CURRENTZ'
+   ENDIF
+
+   IF (carbon_cycle_cpl ) THEN
+       inforecv(idr_oceco2)%action = .TRUE. ; inforecv(idr_oceco2)%name = 'SICO2FLX'
+   ENDIF
+   IF (dms_cycle_cpl) THEN 
+      inforecv(idr_ocedms)%action = .TRUE. ; inforecv(idr_ocedms)%name = 'SIDMSFLX'
+   ENDIF
+ 
+!AC#ifdef CPP_CPLOCNINCA
+!AC       inforcv(idr_ocedms)%action = .TRUE. ; inforcv(idr_ocedms)%name = 'SIDMSFLX'
+!AC#endif
+
+    
+!************************************************************************************
+! Here we go: psmile initialisation
+!************************************************************************************
+    IF (is_sequential) THEN
+       CALL prism_init_comp_proto (comp_id, clmodnam, ierror)
+       
+       IF (ierror .NE. PRISM_Ok) THEN
+          abort_message=' Probleme init dans prism_init_comp '
+          CALL abort_physic(modname,abort_message,1)
+       ELSE
+          WRITE(lunout,*) 'inicma : init psmile ok '
+       ENDIF
+    ENDIF
+
+    CALL prism_get_localcomm_proto (il_commlocal, ierror)
+!************************************************************************************
+! Domain decomposition
+!************************************************************************************
+    IF (grid_type==unstructured) THEN
+
+      ALLOCATE( ig_paral(klon_mpi_para_nb(mpi_rank) + 2) ) 
+
+      ig_paral(1) = 4                                      ! points partition for //
+      ig_paral(2) = klon_mpi_para_nb(mpi_rank)             ! nb of local cells
+
+      DO jf=1, klon_mpi_para_nb(mpi_rank)
+        ig_paral(2+jf) = ind_cell_glo(jf)
+      ENDDO
+
+    ELSE IF (grid_type==regular_lonlat) THEN
+
+      ALLOCATE( ig_paral(3) )
+
+      ig_paral(1) = 1                            ! apple partition for //
+      ig_paral(2) = (jj_begin-1)*nbp_lon+ii_begin-1  ! offset
+      ig_paral(3) = (jj_end*nbp_lon+ii_end) - (jj_begin*nbp_lon+ii_begin) + 1
+
+      IF (mpi_rank==mpi_size-1) ig_paral(3)=ig_paral(3)+nbp_lon-1
+    ELSE
+      abort_message='Pb : type of grid unknown'
+      CALL abort_physic(modname,abort_message,1)
+    ENDIF
+
+
+    WRITE(lunout,*) mpi_rank,'ig_paral--->',ig_paral(2),ig_paral(3)
+    
+    ierror=PRISM_Ok
+    CALL prism_def_partition_proto (il_part_id, ig_paral, ierror)
+
+    IF (ierror .NE. PRISM_Ok) THEN
+       abort_message=' Probleme dans prism_def_partition '
+       CALL abort_physic(modname,abort_message,1)
+    ELSE
+       WRITE(lunout,*) 'inicma : decomposition domaine psmile ok '
+    ENDIF
+
+    il_var_nodims(1) = 2                        ! rank of field array (1d or 2d)
+    il_var_nodims(2) = 1                        ! always 1 in current oasis version" doc oasis3mct p18
+
+    il_var_actual_shape(1) = 1                  ! min of 1st dimension (always 1)
+    il_var_actual_shape(2) = nbp_lon            ! max of 1st dimension
+    il_var_actual_shape(3) = 1                  ! min of 2nd dimension (always 1)
+    il_var_actual_shape(4) = nbp_lat            ! max of 2nd dimension
+   
+    il_var_type = PRISM_Real
+
+!************************************************************************************
+! Oceanic Fields to receive
+! Loop over all possible variables
+!************************************************************************************
+    DO jf=1, maxrecv
+       IF (inforecv(jf)%action) THEN
+          CALL prism_def_var_proto(inforecv(jf)%nid, inforecv(jf)%name, il_part_id, &
+               il_var_nodims, PRISM_In, il_var_actual_shape, il_var_type, &
+               ierror)
+          IF (ierror .NE. PRISM_Ok) THEN
+             WRITE(lunout,*) 'inicma : Problem with prism_def_var_proto for field : ',&
+                  inforecv(jf)%name
+             abort_message=' Problem in call to prism_def_var_proto for fields to receive'
+             CALL abort_physic(modname,abort_message,1)
+          ENDIF
+       ENDIF
+    END DO
+
+
+#ifdef INCA
+    if (dms_cycle_cpl) THEN
+       CALL init_inca_oasis(inforecv(idr_ocedms))
+#endif
+
+    
+!AC! Now, if also coupling CPL with INCA, initialize here fields to be exchanged.
+!AC#ifdef CPP_CPLOCNINCA
+!AC    DO jf=1,maxrcv 
+!AC       IF (inforcv(jf)%action) THEN
+!AC          CALL prism_def_var_proto(inforcv(jf)%nid, inforcv(jf)%name, il_part_id, &
+!AC               il_var_nodims, PRISM_In, il_var_actual_shape, il_var_type, &
+!AC               ierror)
+!AC          IF (ierror .NE. PRISM_Ok) THEN
+!AC             WRITE(lunout,*) 'inicma : Problem with prism_def_var_proto for field : ',&
+!AC                  inforcv(jf)%name
+!AC             abort_message=' Problem in call to prism_def_var_proto for fields to receive'
+!AC             CALL abort_physic(modname,abort_message,1)
+!AC          ENDIF
+!AC       ENDIF
+!AC    END DO
+!AC#endif
+ 
+!************************************************************************************
+! Atmospheric Fields to send
+! Loop over all possible variables
+!************************************************************************************
+    DO jf=1,maxsend
+       IF (infosend(jf)%action) THEN
+          CALL prism_def_var_proto(infosend(jf)%nid, infosend(jf)%name, il_part_id, &
+               il_var_nodims, PRISM_Out, il_var_actual_shape, il_var_type, &
+               ierror)
+          IF (ierror .NE. PRISM_Ok) THEN
+             WRITE(lunout,*) 'inicma : Problem with prism_def_var_proto for field : ',&
+                  infosend(jf)%name
+             abort_message=' Problem in call to prism_def_var_proto for fields to send'
+             CALL abort_physic(modname,abort_message,1)
+          ENDIF
+       ENDIF
+    END DO
+    
+!************************************************************************************
+! End definition
+!************************************************************************************
+#ifdef CPP_XIOS
+    CALL xios_oasis_enddef()
+#endif
+    CALL prism_enddef_proto(ierror)
+    IF (ierror .NE. PRISM_Ok) THEN
+       abort_message=' Problem in call to prism_endef_proto'
+       CALL abort_physic(modname,abort_message,1)
+    ELSE
+       WRITE(lunout,*) 'inicma : endef psmile ok '
+    ENDIF
+
+#ifdef CPP_XIOS
+!    CALL wxios_context_init()
+#endif
+
+!$OMP END MASTER
+    
+  END SUBROUTINE inicma
+
+!
+!************************************************************************************
+!
+
+  SUBROUTINE fromcpl(ktime, tab_get)
+! ======================================================================
+! L. Fairhead (09/2003) adapted From L.Z.X Li: this subroutine reads the SST 
+! and Sea-Ice provided by the coupler. Adaptation to psmile library
+!======================================================================
+!
+    USE print_control_mod, ONLY: lunout
+    USE mod_grid_phy_lmdz, ONLY: nbp_lon, nbp_lat
+! Input arguments
+!************************************************************************************
+    INTEGER, INTENT(IN)                               ::  ktime
+
+! Output arguments
+!************************************************************************************
+    REAL, DIMENSION(nbp_lon, jj_nb,maxrecv_phys), INTENT(OUT) :: tab_get
+
+! Local variables
+!************************************************************************************
+    INTEGER                       :: ierror, i
+    INTEGER                       :: istart,iend
+    CHARACTER (len = 20)          :: modname = 'fromcpl'
+    CHARACTER (len = 80)          :: abort_message 
+    REAL, DIMENSION(nbp_lon*jj_nb)    :: field
+
+!************************************************************************************
+    WRITE (lunout,*) ' '
+    WRITE (lunout,*) 'Fromcpl: Reading fields from CPL, ktime=',ktime
+    WRITE (lunout,*) ' '
+    
+    istart=ii_begin
+    IF (is_south_pole_dyn) THEN
+       iend=(jj_end-jj_begin)*nbp_lon+nbp_lon
+    ELSE
+       iend=(jj_end-jj_begin)*nbp_lon+ii_end
+    ENDIF
+    
+    DO i = 1, maxrecv_phys
+      IF (inforecv(i)%action .AND. inforecv(i)%nid .NE. -1) THEN
+          field(:) = -99999.
+          CALL prism_get_proto(inforecv(i)%nid, ktime, field(istart:iend), ierror)
+          tab_get(:,:,i) = RESHAPE(field(:),(/nbp_lon,jj_nb/))
+       
+          IF (ierror .NE. PRISM_Ok .AND. ierror.NE.PRISM_Recvd .AND. &
+             ierror.NE.PRISM_FromRest &
+             .AND. ierror.NE.PRISM_Input .AND. ierror.NE.PRISM_RecvOut &
+             .AND. ierror.NE.PRISM_FromRestOut) THEN
+              WRITE (lunout,*)  'Error with receiving filed : ', inforecv(i)%name, ktime   
+              abort_message=' Problem in prism_get_proto '
+              CALL abort_physic(modname,abort_message,1)
+          ENDIF
+      ENDIF
+    END DO
+    
+    
+  END SUBROUTINE fromcpl
+
+!
+!************************************************************************************
+! 
+
+  SUBROUTINE intocpl(ktime, last, tab_put) 
+! ======================================================================
+! L. Fairhead (09/2003) adapted From L.Z.X Li: this subroutine provides the 
+! atmospheric coupling fields to the coupler with the psmile library.
+! IF last time step, writes output fields to binary files.
+! ======================================================================
+!
+! 
+    USE print_control_mod, ONLY: lunout
+    USE mod_grid_phy_lmdz, ONLY: nbp_lon, nbp_lat
+! Input arguments
+!************************************************************************************
+    INTEGER, INTENT(IN)                              :: ktime
+    LOGICAL, INTENT(IN)                              :: last
+    REAL, DIMENSION(nbp_lon, jj_nb, maxsend), INTENT(IN) :: tab_put
+
+! Local variables
+!************************************************************************************
+    LOGICAL                          :: checkout
+    INTEGER                          :: istart,iend
+    INTEGER                          :: wstart,wend
+    INTEGER                          :: ierror, i
+    REAL, DIMENSION(nbp_lon*jj_nb)       :: field
+    CHARACTER (len = 20),PARAMETER   :: modname = 'intocpl'
+    CHARACTER (len = 80)             :: abort_message 
+
+!************************************************************************************
+    checkout=.FALSE.
+
+    WRITE(lunout,*) ' '
+    WRITE(lunout,*) 'Intocpl: sending fields to CPL, ktime= ', ktime
+    WRITE(lunout,*) 'last = ', last
+    WRITE(lunout,*)
+
+
+    istart=ii_begin
+    IF (is_south_pole_dyn) THEN
+       iend=(jj_end-jj_begin)*nbp_lon+nbp_lon
+    ELSE
+       iend=(jj_end-jj_begin)*nbp_lon+ii_end
+    ENDIF
+    
+    IF (checkout) THEN   
+       wstart=istart
+       wend=iend
+       IF (is_north_pole_dyn) wstart=istart+nbp_lon-1
+       IF (is_south_pole_dyn) wend=iend-nbp_lon+1
+       
+       DO i = 1, maxsend
+          IF (infosend(i)%action) THEN
+             field = RESHAPE(tab_put(:,:,i),(/nbp_lon*jj_nb/))
+             CALL writefield_phy(infosend(i)%name,field(wstart:wend),1)
+          END IF
+       END DO
+    END IF
+
+!************************************************************************************
+! PRISM_PUT
+!************************************************************************************
+
+    DO i = 1, maxsend
+      IF (infosend(i)%action .AND. infosend(i)%nid .NE. -1 ) THEN
+          field = RESHAPE(tab_put(:,:,i),(/nbp_lon*jj_nb/))
+          CALL prism_put_proto(infosend(i)%nid, ktime, field(istart:iend), ierror)
+          
+          IF (ierror .NE. PRISM_Ok .AND. ierror.NE.PRISM_Sent .AND. ierror.NE.PRISM_ToRest &
+             .AND. ierror.NE.PRISM_LocTrans .AND. ierror.NE.PRISM_Output .AND. &
+             ierror.NE.PRISM_SentOut .AND. ierror.NE.PRISM_ToRestOut) THEN
+              WRITE (lunout,*) 'Error with sending field :', infosend(i)%name, ktime   
+              abort_message=' Problem in prism_put_proto '
+              CALL abort_physic(modname,abort_message,1)
+          ENDIF
+      ENDIF
+    END DO
+   
+!************************************************************************************
+! Finalize PSMILE for the case is_sequential, if parallel finalization is done 
+! from Finalize_parallel in dyn3dpar/parallel.F90
+!************************************************************************************
+
+    IF (last) THEN
+       IF (is_sequential) THEN 
+          CALL prism_terminate_proto(ierror)
+          IF (ierror .NE. PRISM_Ok) THEN
+             abort_message=' Problem in prism_terminate_proto '
+             CALL abort_physic(modname,abort_message,1)
+          ENDIF
+       ENDIF
+    ENDIF
+    
+    
+  END SUBROUTINE intocpl
+
+#endif
+  
+END MODULE oasis
Index: CONFIG/UNIFORM/v6/IPSLCM6.3/SOURCES/ORCA1_LIM3_PISCES/sbccpl.F90
===================================================================
--- CONFIG/UNIFORM/v6/IPSLCM6.3/SOURCES/ORCA1_LIM3_PISCES/sbccpl.F90	(revision 6571)
+++ CONFIG/UNIFORM/v6/IPSLCM6.3/SOURCES/ORCA1_LIM3_PISCES/sbccpl.F90	(revision 6571)
@@ -0,0 +1,2205 @@
+MODULE sbccpl
+   !!======================================================================
+   !!                       ***  MODULE  sbccpl  ***
+   !! Surface Boundary Condition :  momentum, heat and freshwater fluxes in coupled mode
+   !!======================================================================
+   !! History :  2.0  ! 2007-06  (R. Redler, N. Keenlyside, W. Park) Original code split into flxmod & taumod
+   !!            3.0  ! 2008-02  (G. Madec, C Talandier)  surface module
+   !!            3.1  ! 2009_02  (G. Madec, S. Masson, E. Maisonave, A. Caubel) generic coupled interface
+   !!            3.4  ! 2011_11  (C. Harris) more flexibility + multi-category fields
+   !!----------------------------------------------------------------------
+   !!----------------------------------------------------------------------
+   !!   namsbc_cpl      : coupled formulation namlist
+   !!   sbc_cpl_init    : initialisation of the coupled exchanges
+   !!   sbc_cpl_rcv     : receive fields from the atmosphere over the ocean (ocean only)
+   !!                     receive stress from the atmosphere over the ocean (ocean-ice case)
+   !!   sbc_cpl_ice_tau : receive stress from the atmosphere over ice
+   !!   sbc_cpl_ice_flx : receive fluxes from the atmosphere over ice
+   !!   sbc_cpl_snd     : send     fields to the atmosphere
+   !!----------------------------------------------------------------------
+   USE dom_oce         ! ocean space and time domain
+   USE sbc_oce         ! Surface boundary condition: ocean fields
+   USE sbc_ice         ! Surface boundary condition: ice fields
+   USE sbcapr
+   USE sbcdcy          ! surface boundary condition: diurnal cycle
+   USE phycst          ! physical constants
+#if defined key_lim3
+   USE ice             ! ice variables
+#endif
+#if defined key_lim2
+   USE par_ice_2       ! ice parameters
+   USE ice_2           ! ice variables
+#endif
+   USE cpl_oasis3      ! OASIS3 coupling
+   USE geo2ocean       ! 
+   USE oce   , ONLY : tsn, un, vn, sshn, ub, vb, sshb, fraqsr_1lev
+   USE albedo          !
+   USE in_out_manager  ! I/O manager
+   USE iom             ! NetCDF library
+   USE lib_mpp         ! distribued memory computing library
+   USE wrk_nemo        ! work arrays
+   USE timing          ! Timing
+   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
+   USE eosbn2
+   USE sbcrnf   , ONLY : l_rnfcpl
+   USE sbcisf   , ONLY : l_isfcpl
+#if defined key_cpl_carbon_cycle
+   USE p4zflx, ONLY : oce_co2
+#endif
+!AC#if defined key_transm_ocninca
+   USE p4zflx, ONLY : oce_dms
+!AC#endif
+#if defined key_cice
+   USE ice_domain_size, only: ncat
+#endif
+#if defined key_lim3
+   USE limthd_dh       ! for CALL lim_thd_snwblow
+#endif
+   USE closea
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   sbc_cpl_init       ! routine called by sbcmod.F90
+   PUBLIC   sbc_cpl_rcv        ! routine called by sbc_ice_lim(_2).F90
+   PUBLIC   sbc_cpl_snd        ! routine called by step.F90
+   PUBLIC   sbc_cpl_ice_tau    ! routine called by sbc_ice_lim(_2).F90
+   PUBLIC   sbc_cpl_ice_flx    ! routine called by sbc_ice_lim(_2).F90
+   PUBLIC   sbc_cpl_alloc      ! routine called in sbcice_cice.F90
+
+   INTEGER, PARAMETER ::   jpr_otx1   =  1            ! 3 atmosphere-ocean stress components on grid 1
+   INTEGER, PARAMETER ::   jpr_oty1   =  2            ! 
+   INTEGER, PARAMETER ::   jpr_otz1   =  3            ! 
+   INTEGER, PARAMETER ::   jpr_otx2   =  4            ! 3 atmosphere-ocean stress components on grid 2
+   INTEGER, PARAMETER ::   jpr_oty2   =  5            ! 
+   INTEGER, PARAMETER ::   jpr_otz2   =  6            ! 
+   INTEGER, PARAMETER ::   jpr_itx1   =  7            ! 3 atmosphere-ice   stress components on grid 1
+   INTEGER, PARAMETER ::   jpr_ity1   =  8            ! 
+   INTEGER, PARAMETER ::   jpr_itz1   =  9            ! 
+   INTEGER, PARAMETER ::   jpr_itx2   = 10            ! 3 atmosphere-ice   stress components on grid 2
+   INTEGER, PARAMETER ::   jpr_ity2   = 11            ! 
+   INTEGER, PARAMETER ::   jpr_itz2   = 12            ! 
+   INTEGER, PARAMETER ::   jpr_qsroce = 13            ! Qsr above the ocean
+   INTEGER, PARAMETER ::   jpr_qsrice = 14            ! Qsr above the ice
+   INTEGER, PARAMETER ::   jpr_qsrmix = 15 
+   INTEGER, PARAMETER ::   jpr_qnsoce = 16            ! Qns above the ocean
+   INTEGER, PARAMETER ::   jpr_qnsice = 17            ! Qns above the ice
+   INTEGER, PARAMETER ::   jpr_qnsmix = 18
+   INTEGER, PARAMETER ::   jpr_rain   = 19            ! total liquid precipitation (rain)
+   INTEGER, PARAMETER ::   jpr_snow   = 20            ! solid precipitation over the ocean (snow)
+   INTEGER, PARAMETER ::   jpr_tevp   = 21            ! total evaporation
+   INTEGER, PARAMETER ::   jpr_ievp   = 22            ! solid evaporation (sublimation)
+   INTEGER, PARAMETER ::   jpr_sbpr   = 23            ! sublimation - liquid precipitation - solid precipitation
+   INTEGER, PARAMETER ::   jpr_semp   = 24            ! solid freshwater budget (sublimation - snow)
+   INTEGER, PARAMETER ::   jpr_oemp   = 25            ! ocean freshwater budget (evap - precip)
+   INTEGER, PARAMETER ::   jpr_w10m   = 26            ! 10m wind
+   INTEGER, PARAMETER ::   jpr_dqnsdt = 27            ! d(Q non solar)/d(temperature)
+   INTEGER, PARAMETER ::   jpr_rnf    = 28            ! runoffs
+   INTEGER, PARAMETER ::   jpr_cal    = 29            ! calving
+   INTEGER, PARAMETER ::   jpr_taum   = 30            ! wind stress module
+   INTEGER, PARAMETER ::   jpr_co2    = 31
+   INTEGER, PARAMETER ::   jpr_topm   = 32            ! topmeltn
+   INTEGER, PARAMETER ::   jpr_botm   = 33            ! botmeltn
+   INTEGER, PARAMETER ::   jpr_sflx   = 34            ! salt flux
+   INTEGER, PARAMETER ::   jpr_toce   = 35            ! ocean temperature
+   INTEGER, PARAMETER ::   jpr_soce   = 36            ! ocean salinity
+   INTEGER, PARAMETER ::   jpr_ocx1   = 37            ! ocean current on grid 1
+   INTEGER, PARAMETER ::   jpr_ocy1   = 38            !
+   INTEGER, PARAMETER ::   jpr_ssh    = 39            ! sea surface height
+   INTEGER, PARAMETER ::   jpr_fice   = 40            ! ice fraction          
+   INTEGER, PARAMETER ::   jpr_e3t1st = 41            ! first T level thickness 
+   INTEGER, PARAMETER ::   jpr_fraqsr = 42            ! fraction of solar net radiation absorbed in the first ocean level
+   INTEGER, PARAMETER ::   jpr_isf    = 43
+   INTEGER, PARAMETER ::   jpr_icb    = 44
+   INTEGER, PARAMETER ::   jprcv      = 44            ! total number of fields received
+
+   INTEGER, PARAMETER ::   jps_fice   =  1            ! ice fraction sent to the atmosphere
+   INTEGER, PARAMETER ::   jps_toce   =  2            ! ocean temperature
+   INTEGER, PARAMETER ::   jps_tice   =  3            ! ice   temperature
+   INTEGER, PARAMETER ::   jps_tmix   =  4            ! mixed temperature (ocean+ice)
+   INTEGER, PARAMETER ::   jps_albice =  5            ! ice   albedo
+   INTEGER, PARAMETER ::   jps_albmix =  6            ! mixed albedo
+   INTEGER, PARAMETER ::   jps_hice   =  7            ! ice  thickness
+   INTEGER, PARAMETER ::   jps_hsnw   =  8            ! snow thickness
+   INTEGER, PARAMETER ::   jps_ocx1   =  9            ! ocean current on grid 1
+   INTEGER, PARAMETER ::   jps_ocy1   = 10            !
+   INTEGER, PARAMETER ::   jps_ocz1   = 11            !
+   INTEGER, PARAMETER ::   jps_ivx1   = 12            ! ice   current on grid 1
+   INTEGER, PARAMETER ::   jps_ivy1   = 13            !
+   INTEGER, PARAMETER ::   jps_ivz1   = 14            !
+   INTEGER, PARAMETER ::   jps_co2    = 15
+   INTEGER, PARAMETER ::   jps_soce   = 16            ! ocean salinity
+   INTEGER, PARAMETER ::   jps_ssh    = 17            ! sea surface height
+   INTEGER, PARAMETER ::   jps_qsroce = 18            ! Qsr above the ocean
+   INTEGER, PARAMETER ::   jps_qnsoce = 19            ! Qns above the ocean
+   INTEGER, PARAMETER ::   jps_oemp   = 20            ! ocean freshwater budget (evap - precip)
+   INTEGER, PARAMETER ::   jps_sflx   = 21            ! salt flux
+   INTEGER, PARAMETER ::   jps_otx1   = 22            ! 2 atmosphere-ocean stress components on grid 1
+   INTEGER, PARAMETER ::   jps_oty1   = 23            ! 
+   INTEGER, PARAMETER ::   jps_rnf    = 24            ! runoffs
+   INTEGER, PARAMETER ::   jps_taum   = 25            ! wind stress module
+   INTEGER, PARAMETER ::   jps_fice2  = 26            ! ice fraction sent to OPA (by SAS when doing SAS-OPA coupling)
+   INTEGER, PARAMETER ::   jps_e3t1st = 27            ! first level depth (vvl)
+   INTEGER, PARAMETER ::   jps_fraqsr = 28            ! fraction of solar net radiation absorbed in the first ocean level
+   INTEGER, PARAMETER ::   jps_dms    = 29            ! Ocean DMS
+   INTEGER, PARAMETER ::   jpsnd      = 29            ! total number of fields sent
+
+   !                                                         !!** namelist namsbc_cpl **
+   TYPE ::   FLD_C
+      CHARACTER(len = 32) ::   cldes                  ! desciption of the coupling strategy
+      CHARACTER(len = 32) ::   clcat                  ! multiple ice categories strategy
+      CHARACTER(len = 32) ::   clvref                 ! reference of vector ('spherical' or 'cartesian')
+      CHARACTER(len = 32) ::   clvor                  ! orientation of vector fields ('eastward-northward' or 'local grid')
+      CHARACTER(len = 32) ::   clvgrd                 ! grids on which is located the vector fields
+   END TYPE FLD_C
+   ! Sent to the atmosphere                           !
+   TYPE(FLD_C) ::   sn_snd_temp, sn_snd_alb, sn_snd_thick, sn_snd_crt, sn_snd_co2, sn_snd_dms
+   ! Received from the atmosphere                     !
+   TYPE(FLD_C) ::   sn_rcv_w10m, sn_rcv_taumod, sn_rcv_tau, sn_rcv_dqnsdt, sn_rcv_qsr, sn_rcv_qns, sn_rcv_emp, sn_rcv_rnf
+   TYPE(FLD_C) ::   sn_rcv_cal, sn_rcv_iceflx, sn_rcv_co2, sn_rcv_icb, sn_rcv_isf                               
+   ! Other namelist parameters                        !
+   INTEGER     ::   nn_cplmodel            ! Maximum number of models to/from which NEMO is potentialy sending/receiving data
+   LOGICAL     ::   ln_usecplmask          !  use a coupling mask file to merge data received from several models
+                                           !   -> file cplmask.nc with the float variable called cplmask (jpi,jpj,nn_cplmodel)
+   TYPE ::   DYNARR     
+      REAL(wp), POINTER, DIMENSION(:,:,:)    ::   z3   
+   END TYPE DYNARR
+
+   TYPE( DYNARR ), SAVE, DIMENSION(jprcv) ::   frcv                      ! all fields recieved from the atmosphere
+
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:)   ::   albedo_oce_mix     ! ocean albedo sent to atmosphere (mix clear/overcast sky)
+
+   INTEGER , ALLOCATABLE, SAVE, DIMENSION(    :) ::   nrcvinfo           ! OASIS info argument
+
+   !! Substitution
+#  include "domzgr_substitute.h90"
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.3 , NEMO Consortium (2010)
+   !! $Id: sbccpl.F90 9429 2018-03-26 14:42:05Z nicolasmartin $
+   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+  
+   INTEGER FUNCTION sbc_cpl_alloc()
+      !!----------------------------------------------------------------------
+      !!             ***  FUNCTION sbc_cpl_alloc  ***
+      !!----------------------------------------------------------------------
+      INTEGER :: ierr(3)
+      !!----------------------------------------------------------------------
+      ierr(:) = 0
+      !
+      ALLOCATE( albedo_oce_mix(jpi,jpj), nrcvinfo(jprcv),  STAT=ierr(1) )
+      
+#if ! defined key_lim3 && ! defined key_lim2 && ! defined key_cice
+      ALLOCATE( a_i(jpi,jpj,1) , STAT=ierr(2) )  ! used in sbcice_if.F90 (done here as there is no sbc_ice_if_init)
+#endif
+      ALLOCATE( xcplmask(jpi,jpj,0:nn_cplmodel) , STAT=ierr(3) )
+      !
+      sbc_cpl_alloc = MAXVAL( ierr )
+      IF( lk_mpp            )   CALL mpp_sum ( sbc_cpl_alloc )
+      IF( sbc_cpl_alloc > 0 )   CALL ctl_warn('sbc_cpl_alloc: allocation of arrays failed')
+      !
+   END FUNCTION sbc_cpl_alloc
+
+
+   SUBROUTINE sbc_cpl_init( k_ice )     
+      !!----------------------------------------------------------------------
+      !!             ***  ROUTINE sbc_cpl_init  ***
+      !!
+      !! ** Purpose :   Initialisation of send and received information from
+      !!                the atmospheric component
+      !!
+      !! ** Method  : * Read namsbc_cpl namelist 
+      !!              * define the receive interface
+      !!              * define the send    interface
+      !!              * initialise the OASIS coupler
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT(in) ::   k_ice       ! ice management in the sbc (=0/1/2/3)
+      !!
+      INTEGER ::   jn   ! dummy loop index
+      INTEGER ::   ios  ! Local integer output status for namelist read
+      INTEGER ::   inum 
+      REAL(wp), POINTER, DIMENSION(:,:) ::   zacs, zaos
+      !!
+      NAMELIST/namsbc_cpl/  sn_snd_temp, sn_snd_alb   , sn_snd_thick, sn_snd_crt   , sn_snd_co2, sn_snd_dms,  &
+          &                  sn_rcv_w10m, sn_rcv_taumod, sn_rcv_tau  ,sn_rcv_dqnsdt, sn_rcv_qsr,      &
+          &                  sn_rcv_qns , sn_rcv_emp   , sn_rcv_rnf  ,sn_rcv_cal   , sn_rcv_iceflx,   &
+          &                  sn_rcv_co2 , sn_rcv_icb , sn_rcv_isf, nn_cplmodel, ln_usecplmask
+      !!---------------------------------------------------------------------
+      !
+      IF( nn_timing == 1 )  CALL timing_start('sbc_cpl_init')
+      !
+      CALL wrk_alloc( jpi,jpj, zacs, zaos )
+
+      ! ================================ !
+      !      Namelist informations       !
+      ! ================================ !
+
+      REWIND( numnam_ref )              ! Namelist namsbc_cpl in reference namelist : Variables for OASIS coupling
+      READ  ( numnam_ref, namsbc_cpl, IOSTAT = ios, ERR = 901)
+901   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namsbc_cpl in reference namelist', lwp )
+
+      REWIND( numnam_cfg )              ! Namelist namsbc_cpl in configuration namelist : Variables for OASIS coupling
+      READ  ( numnam_cfg, namsbc_cpl, IOSTAT = ios, ERR = 902 )
+902   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namsbc_cpl in configuration namelist', lwp )
+      IF(lwm) WRITE ( numond, namsbc_cpl )
+
+      IF(lwp) THEN                        ! control print
+         WRITE(numout,*)
+         WRITE(numout,*)'sbc_cpl_init : namsbc_cpl namelist '
+         WRITE(numout,*)'~~~~~~~~~~~~'
+      ENDIF
+      IF( lwp .AND. ln_cpl ) THEN                        ! control print
+         WRITE(numout,*)'  received fields (mutiple ice categogies)'
+         WRITE(numout,*)'      10m wind module                 = ', TRIM(sn_rcv_w10m%cldes  ), ' (', TRIM(sn_rcv_w10m%clcat  ), ')'
+         WRITE(numout,*)'      stress module                   = ', TRIM(sn_rcv_taumod%cldes), ' (', TRIM(sn_rcv_taumod%clcat), ')'
+         WRITE(numout,*)'      surface stress                  = ', TRIM(sn_rcv_tau%cldes   ), ' (', TRIM(sn_rcv_tau%clcat   ), ')'
+         WRITE(numout,*)'                     - referential    = ', sn_rcv_tau%clvref
+         WRITE(numout,*)'                     - orientation    = ', sn_rcv_tau%clvor
+         WRITE(numout,*)'                     - mesh           = ', sn_rcv_tau%clvgrd
+         WRITE(numout,*)'      non-solar heat flux sensitivity = ', TRIM(sn_rcv_dqnsdt%cldes), ' (', TRIM(sn_rcv_dqnsdt%clcat), ')'
+         WRITE(numout,*)'      solar heat flux                 = ', TRIM(sn_rcv_qsr%cldes   ), ' (', TRIM(sn_rcv_qsr%clcat   ), ')'
+         WRITE(numout,*)'      non-solar heat flux             = ', TRIM(sn_rcv_qns%cldes   ), ' (', TRIM(sn_rcv_qns%clcat   ), ')'
+         WRITE(numout,*)'      freshwater budget               = ', TRIM(sn_rcv_emp%cldes   ), ' (', TRIM(sn_rcv_emp%clcat   ), ')'
+         WRITE(numout,*)'      runoffs                         = ', TRIM(sn_rcv_rnf%cldes   ), ' (', TRIM(sn_rcv_rnf%clcat   ), ')'
+         WRITE(numout,*)'      calving                         = ', TRIM(sn_rcv_cal%cldes   ), ' (', TRIM(sn_rcv_cal%clcat   ), ')'
+         WRITE(numout,*)'      iceberg                         = ', TRIM(sn_rcv_icb%cldes   ), ' (', TRIM(sn_rcv_icb%clcat   ), ')'
+         WRITE(numout,*)'      ice shelf                       = ', TRIM(sn_rcv_isf%cldes   ), ' (', TRIM(sn_rcv_isf%clcat   ), ')'
+         WRITE(numout,*)'      sea ice heat fluxes             = ', TRIM(sn_rcv_iceflx%cldes), ' (', TRIM(sn_rcv_iceflx%clcat), ')'
+         WRITE(numout,*)'      atm co2                         = ', TRIM(sn_rcv_co2%cldes   ), ' (', TRIM(sn_rcv_co2%clcat   ), ')'
+         WRITE(numout,*)'  sent fields (multiple ice categories)'
+         WRITE(numout,*)'      surface temperature             = ', TRIM(sn_snd_temp%cldes  ), ' (', TRIM(sn_snd_temp%clcat  ), ')'
+         WRITE(numout,*)'      albedo                          = ', TRIM(sn_snd_alb%cldes   ), ' (', TRIM(sn_snd_alb%clcat   ), ')'
+         WRITE(numout,*)'      ice/snow thickness              = ', TRIM(sn_snd_thick%cldes ), ' (', TRIM(sn_snd_thick%clcat ), ')'
+         WRITE(numout,*)'      surface current                 = ', TRIM(sn_snd_crt%cldes   ), ' (', TRIM(sn_snd_crt%clcat   ), ')'
+         WRITE(numout,*)'                      - referential   = ', sn_snd_crt%clvref 
+         WRITE(numout,*)'                      - orientation   = ', sn_snd_crt%clvor
+         WRITE(numout,*)'                      - mesh          = ', sn_snd_crt%clvgrd
+         WRITE(numout,*)'      oce co2 flux                    = ', TRIM(sn_snd_co2%cldes   ), ' (', TRIM(sn_snd_co2%clcat   ), ')'
+         WRITE(numout,*)'      oce dms flux                    = ', TRIM(sn_snd_dms%cldes   ), ' (', TRIM(sn_snd_dms%clcat   ), ')'
+         WRITE(numout,*)'  nn_cplmodel                         = ', nn_cplmodel
+         WRITE(numout,*)'  ln_usecplmask                       = ', ln_usecplmask
+      ENDIF
+
+      !                                   ! allocate sbccpl arrays
+      IF( sbc_cpl_alloc() /= 0 )   CALL ctl_stop( 'STOP', 'sbc_cpl_alloc : unable to allocate arrays' )
+     
+      ! ================================ !
+      !   Define the receive interface   !
+      ! ================================ !
+      nrcvinfo(:) = OASIS_idle   ! needed by nrcvinfo(jpr_otx1) if we do not receive ocean stress 
+
+      ! for each field: define the OASIS name                              (srcv(:)%clname)
+      !                 define receive or not from the namelist parameters (srcv(:)%laction)
+      !                 define the north fold type of lbc                  (srcv(:)%nsgn)
+
+      ! default definitions of srcv
+      srcv(:)%laction = .FALSE.   ;   srcv(:)%clgrid = 'T'   ;   srcv(:)%nsgn = 1.   ;   srcv(:)%nct = 1
+
+      !                                                      ! ------------------------- !
+      !                                                      ! ice and ocean wind stress !   
+      !                                                      ! ------------------------- !
+      !                                                           ! Name 
+      srcv(jpr_otx1)%clname = 'O_OTaux1'      ! 1st ocean component on grid ONE (T or U)
+      srcv(jpr_oty1)%clname = 'O_OTauy1'      ! 2nd   -      -         -     - 
+      srcv(jpr_otz1)%clname = 'O_OTauz1'      ! 3rd   -      -         -     - 
+      srcv(jpr_otx2)%clname = 'O_OTaux2'      ! 1st ocean component on grid TWO (V)
+      srcv(jpr_oty2)%clname = 'O_OTauy2'      ! 2nd   -      -         -     - 
+      srcv(jpr_otz2)%clname = 'O_OTauz2'      ! 3rd   -      -         -     - 
+      !
+      srcv(jpr_itx1)%clname = 'O_ITaux1'      ! 1st  ice  component on grid ONE (T, F, I or U)
+      srcv(jpr_ity1)%clname = 'O_ITauy1'      ! 2nd   -      -         -     - 
+      srcv(jpr_itz1)%clname = 'O_ITauz1'      ! 3rd   -      -         -     - 
+      srcv(jpr_itx2)%clname = 'O_ITaux2'      ! 1st  ice  component on grid TWO (V)
+      srcv(jpr_ity2)%clname = 'O_ITauy2'      ! 2nd   -      -         -     - 
+      srcv(jpr_itz2)%clname = 'O_ITauz2'      ! 3rd   -      -         -     - 
+      ! 
+      ! Vectors: change of sign at north fold ONLY if on the local grid
+      IF( TRIM( sn_rcv_tau%clvor ) == 'local grid' )   srcv(jpr_otx1:jpr_itz2)%nsgn = -1.
+      
+      !                                                           ! Set grid and action
+      SELECT CASE( TRIM( sn_rcv_tau%clvgrd ) )      !  'T', 'U,V', 'U,V,I', 'U,V,F', 'T,I', 'T,F', or 'T,U,V'
+      CASE( 'T' ) 
+         srcv(jpr_otx1:jpr_itz2)%clgrid  = 'T'        ! oce and ice components given at T-point
+         srcv(jpr_otx1:jpr_otz1)%laction = .TRUE.     ! receive oce components on grid 1 
+         srcv(jpr_itx1:jpr_itz1)%laction = .TRUE.     ! receive ice components on grid 1 
+      CASE( 'U,V' ) 
+         srcv(jpr_otx1:jpr_otz1)%clgrid  = 'U'        ! oce components given at U-point
+         srcv(jpr_otx2:jpr_otz2)%clgrid  = 'V'        !           and           V-point
+         srcv(jpr_itx1:jpr_itz1)%clgrid  = 'U'        ! ice components given at U-point
+         srcv(jpr_itx2:jpr_itz2)%clgrid  = 'V'        !           and           V-point
+         srcv(jpr_otx1:jpr_itz2)%laction = .TRUE.     ! receive oce and ice components on both grid 1 & 2
+      CASE( 'U,V,T' )
+         srcv(jpr_otx1:jpr_otz1)%clgrid  = 'U'        ! oce components given at U-point
+         srcv(jpr_otx2:jpr_otz2)%clgrid  = 'V'        !           and           V-point
+         srcv(jpr_itx1:jpr_itz1)%clgrid  = 'T'        ! ice components given at T-point
+         srcv(jpr_otx1:jpr_otz2)%laction = .TRUE.     ! receive oce components on grid 1 & 2
+         srcv(jpr_itx1:jpr_itz1)%laction = .TRUE.     ! receive ice components on grid 1 only
+      CASE( 'U,V,I' )
+         srcv(jpr_otx1:jpr_otz1)%clgrid  = 'U'        ! oce components given at U-point
+         srcv(jpr_otx2:jpr_otz2)%clgrid  = 'V'        !           and           V-point
+         srcv(jpr_itx1:jpr_itz1)%clgrid  = 'I'        ! ice components given at I-point
+         srcv(jpr_otx1:jpr_otz2)%laction = .TRUE.     ! receive oce components on grid 1 & 2
+         srcv(jpr_itx1:jpr_itz1)%laction = .TRUE.     ! receive ice components on grid 1 only
+      CASE( 'U,V,F' )
+         srcv(jpr_otx1:jpr_otz1)%clgrid  = 'U'        ! oce components given at U-point
+         srcv(jpr_otx2:jpr_otz2)%clgrid  = 'V'        !           and           V-point
+         srcv(jpr_itx1:jpr_itz1)%clgrid  = 'F'        ! ice components given at F-point
+         srcv(jpr_otx1:jpr_otz2)%laction = .TRUE.     ! receive oce components on grid 1 & 2
+         srcv(jpr_itx1:jpr_itz1)%laction = .TRUE.     ! receive ice components on grid 1 only
+      CASE( 'T,I' ) 
+         srcv(jpr_otx1:jpr_itz2)%clgrid  = 'T'        ! oce and ice components given at T-point
+         srcv(jpr_itx1:jpr_itz1)%clgrid  = 'I'        ! ice components given at I-point
+         srcv(jpr_otx1:jpr_otz1)%laction = .TRUE.     ! receive oce components on grid 1 
+         srcv(jpr_itx1:jpr_itz1)%laction = .TRUE.     ! receive ice components on grid 1 
+      CASE( 'T,F' ) 
+         srcv(jpr_otx1:jpr_itz2)%clgrid  = 'T'        ! oce and ice components given at T-point
+         srcv(jpr_itx1:jpr_itz1)%clgrid  = 'F'        ! ice components given at F-point
+         srcv(jpr_otx1:jpr_otz1)%laction = .TRUE.     ! receive oce components on grid 1 
+         srcv(jpr_itx1:jpr_itz1)%laction = .TRUE.     ! receive ice components on grid 1 
+      CASE( 'T,U,V' )
+         srcv(jpr_otx1:jpr_otz1)%clgrid  = 'T'        ! oce components given at T-point
+         srcv(jpr_itx1:jpr_itz1)%clgrid  = 'U'        ! ice components given at U-point
+         srcv(jpr_itx2:jpr_itz2)%clgrid  = 'V'        !           and           V-point
+         srcv(jpr_otx1:jpr_otz1)%laction = .TRUE.     ! receive oce components on grid 1 only
+         srcv(jpr_itx1:jpr_itz2)%laction = .TRUE.     ! receive ice components on grid 1 & 2
+      CASE default   
+         CALL ctl_stop( 'sbc_cpl_init: wrong definition of sn_rcv_tau%clvgrd' )
+      END SELECT
+      !
+      IF( TRIM( sn_rcv_tau%clvref ) == 'spherical' )   &           ! spherical: 3rd component not received
+         &     srcv( (/jpr_otz1, jpr_otz2, jpr_itz1, jpr_itz2/) )%laction = .FALSE. 
+      !
+      IF( TRIM( sn_rcv_tau%clvor  ) == 'local grid' ) THEN        ! already on local grid -> no need of the second grid
+            srcv(jpr_otx2:jpr_otz2)%laction = .FALSE. 
+            srcv(jpr_itx2:jpr_itz2)%laction = .FALSE. 
+            srcv(jpr_oty1)%clgrid = srcv(jpr_oty2)%clgrid   ! not needed but cleaner...
+            srcv(jpr_ity1)%clgrid = srcv(jpr_ity2)%clgrid   ! not needed but cleaner...
+      ENDIF
+      !
+      IF( TRIM( sn_rcv_tau%cldes ) /= 'oce and ice' ) THEN        ! 'oce and ice' case ocean stress on ocean mesh used
+         srcv(jpr_itx1:jpr_itz2)%laction = .FALSE.    ! ice components not received
+         srcv(jpr_itx1)%clgrid = 'U'                  ! ocean stress used after its transformation
+         srcv(jpr_ity1)%clgrid = 'V'                  ! i.e. it is always at U- & V-points for i- & j-comp. resp.
+      ENDIF
+       
+      !                                                      ! ------------------------- !
+      !                                                      !    freshwater budget      !   E-P
+      !                                                      ! ------------------------- !
+      ! we suppose that atmosphere modele do not make the difference between precipiration (liquide or solid)
+      ! over ice of free ocean within the same atmospheric cell.cd 
+      srcv(jpr_rain)%clname = 'OTotRain'      ! Rain = liquid precipitation
+      srcv(jpr_snow)%clname = 'OTotSnow'      ! Snow = solid precipitation
+      srcv(jpr_tevp)%clname = 'OTotEvap'      ! total evaporation (over oce + ice sublimation)
+      srcv(jpr_ievp)%clname = 'OIceEvap'      ! evaporation over ice = sublimation
+      srcv(jpr_sbpr)%clname = 'OSubMPre'      ! sublimation - liquid precipitation - solid precipitation 
+      srcv(jpr_semp)%clname = 'OISubMSn'      ! ice solid water budget = sublimation - solid precipitation
+      srcv(jpr_oemp)%clname = 'OOEvaMPr'      ! ocean water budget = ocean Evap - ocean precip
+      SELECT CASE( TRIM( sn_rcv_emp%cldes ) )
+      CASE( 'none'          )       ! nothing to do
+      CASE( 'oce only'      )   ;   srcv(                                 jpr_oemp   )%laction = .TRUE. 
+      CASE( 'conservative'  )
+         srcv( (/jpr_rain, jpr_snow, jpr_ievp, jpr_tevp/) )%laction = .TRUE.
+         IF ( k_ice <= 1 )  srcv(jpr_ievp)%laction = .FALSE.
+      CASE( 'oce and ice'   )   ;   srcv( (/jpr_ievp, jpr_sbpr, jpr_semp, jpr_oemp/) )%laction = .TRUE.
+      CASE default              ;   CALL ctl_stop( 'sbc_cpl_init: wrong definition of sn_rcv_emp%cldes' )
+      END SELECT
+
+
+      !                                                      ! ---------------------------------------------------- !
+      !                                                      !     Runoffs, Calving, Iceberg, Iceshelf cavities     !   
+      !                                                      ! ---------------------------------------------------- !
+      srcv(jpr_rnf   )%clname = 'O_Runoff'
+      IF( TRIM( sn_rcv_rnf%cldes ) == 'coupled' ) THEN
+         srcv(jpr_rnf)%laction = .TRUE.
+         l_rnfcpl              = .TRUE.                      ! -> no need to read runoffs in sbcrnf
+         ln_rnf                = nn_components /= jp_iam_sas ! -> force to go through sbcrnf if not sas
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) '   runoffs received from oasis -> force ln_rnf = ', ln_rnf
+      ENDIF
+      !
+      srcv(jpr_cal)%clname = 'OCalving'   ;  IF( TRIM( sn_rcv_cal%cldes) == 'coupled' )   srcv(jpr_cal)%laction = .TRUE.
+      srcv(jpr_isf)%clname = 'OIcshelf'   ;  IF( TRIM( sn_rcv_isf%cldes) == 'coupled' )   srcv(jpr_isf)%laction = .TRUE.
+      srcv(jpr_icb)%clname = 'OIceberg'   ;  IF( TRIM( sn_rcv_icb%cldes) == 'coupled' )   srcv(jpr_icb)%laction = .TRUE.
+
+      IF( srcv(jpr_isf)%laction .AND. nn_isf > 0 ) THEN
+         l_isfcpl             = .TRUE.                      ! -> no need to read isf in sbcisf
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) '   iceshelf received from oasis '
+      ENDIF
+
+      !                                                      ! ------------------------- !
+      !                                                      !    non solar radiation    !   Qns
+      !                                                      ! ------------------------- !
+      srcv(jpr_qnsoce)%clname = 'O_QnsOce'
+      srcv(jpr_qnsice)%clname = 'O_QnsIce'
+      srcv(jpr_qnsmix)%clname = 'O_QnsMix'
+      SELECT CASE( TRIM( sn_rcv_qns%cldes ) )
+      CASE( 'none'          )       ! nothing to do
+      CASE( 'oce only'      )   ;   srcv(               jpr_qnsoce   )%laction = .TRUE.
+      CASE( 'conservative'  )   ;   srcv( (/jpr_qnsice, jpr_qnsmix/) )%laction = .TRUE.
+      CASE( 'oce and ice'   )   ;   srcv( (/jpr_qnsice, jpr_qnsoce/) )%laction = .TRUE.
+      CASE( 'mixed oce-ice' )   ;   srcv(               jpr_qnsmix   )%laction = .TRUE. 
+      CASE default              ;   CALL ctl_stop( 'sbc_cpl_init: wrong definition of sn_rcv_qns%cldes' )
+      END SELECT
+      IF( TRIM( sn_rcv_qns%cldes ) == 'mixed oce-ice' .AND. jpl > 1 ) &
+         CALL ctl_stop( 'sbc_cpl_init: sn_rcv_qns%cldes not currently allowed to be mixed oce-ice for multi-category ice' )
+      !                                                      ! ------------------------- !
+      !                                                      !    solar radiation        !   Qsr
+      !                                                      ! ------------------------- !
+      srcv(jpr_qsroce)%clname = 'O_QsrOce'
+      srcv(jpr_qsrice)%clname = 'O_QsrIce'
+      srcv(jpr_qsrmix)%clname = 'O_QsrMix'
+      SELECT CASE( TRIM( sn_rcv_qsr%cldes ) )
+      CASE( 'none'          )       ! nothing to do
+      CASE( 'oce only'      )   ;   srcv(               jpr_qsroce   )%laction = .TRUE.
+      CASE( 'conservative'  )   ;   srcv( (/jpr_qsrice, jpr_qsrmix/) )%laction = .TRUE.
+      CASE( 'oce and ice'   )   ;   srcv( (/jpr_qsrice, jpr_qsroce/) )%laction = .TRUE.
+      CASE( 'mixed oce-ice' )   ;   srcv(               jpr_qsrmix   )%laction = .TRUE. 
+      CASE default              ;   CALL ctl_stop( 'sbc_cpl_init: wrong definition of sn_rcv_qsr%cldes' )
+      END SELECT
+      IF( TRIM( sn_rcv_qsr%cldes ) == 'mixed oce-ice' .AND. jpl > 1 ) &
+         CALL ctl_stop( 'sbc_cpl_init: sn_rcv_qsr%cldes not currently allowed to be mixed oce-ice for multi-category ice' )
+      !                                                      ! ------------------------- !
+      !                                                      !   non solar sensitivity   !   d(Qns)/d(T)
+      !                                                      ! ------------------------- !
+      srcv(jpr_dqnsdt)%clname = 'O_dQnsdT'   
+      IF( TRIM( sn_rcv_dqnsdt%cldes ) == 'coupled' )   srcv(jpr_dqnsdt)%laction = .TRUE.
+      !
+      ! non solar sensitivity mandatory for LIM ice model
+      IF( TRIM( sn_rcv_dqnsdt%cldes ) == 'none' .AND. k_ice /= 0 .AND. k_ice /= 4 .AND. nn_components /= jp_iam_sas ) &
+         CALL ctl_stop( 'sbc_cpl_init: sn_rcv_dqnsdt%cldes must be coupled in namsbc_cpl namelist' )
+      ! non solar sensitivity mandatory for mixed oce-ice solar radiation coupling technique
+      IF( TRIM( sn_rcv_dqnsdt%cldes ) == 'none' .AND. TRIM( sn_rcv_qns%cldes ) == 'mixed oce-ice' ) &
+         CALL ctl_stop( 'sbc_cpl_init: namsbc_cpl namelist mismatch between sn_rcv_qns%cldes and sn_rcv_dqnsdt%cldes' )
+      !                                                      ! ------------------------- !
+      !                                                      !      10m wind module      !   
+      !                                                      ! ------------------------- !
+      srcv(jpr_w10m)%clname = 'O_Wind10'   ;   IF( TRIM(sn_rcv_w10m%cldes  ) == 'coupled' )   srcv(jpr_w10m)%laction = .TRUE. 
+      !
+      !                                                      ! ------------------------- !
+      !                                                      !   wind stress module      !   
+      !                                                      ! ------------------------- !
+      srcv(jpr_taum)%clname = 'O_TauMod'   ;   IF( TRIM(sn_rcv_taumod%cldes) == 'coupled' )   srcv(jpr_taum)%laction = .TRUE.
+      lhftau = srcv(jpr_taum)%laction
+
+      !                                                      ! ------------------------- !
+      !                                                      !      Atmospheric CO2      !
+      !                                                      ! ------------------------- !
+      srcv(jpr_co2 )%clname = 'O_AtmCO2'   ;   IF( TRIM(sn_rcv_co2%cldes   ) == 'coupled' )    srcv(jpr_co2 )%laction = .TRUE.
+      !                                                      ! ------------------------- !
+      !                                                      !   topmelt and botmelt     !   
+      !                                                      ! ------------------------- !
+      srcv(jpr_topm )%clname = 'OTopMlt'
+      srcv(jpr_botm )%clname = 'OBotMlt'
+      IF( TRIM(sn_rcv_iceflx%cldes) == 'coupled' ) THEN
+         IF ( TRIM( sn_rcv_iceflx%clcat ) == 'yes' ) THEN
+            srcv(jpr_topm:jpr_botm)%nct = jpl
+         ELSE
+            CALL ctl_stop( 'sbc_cpl_init: sn_rcv_iceflx%clcat should always be set to yes currently' )
+         ENDIF
+         srcv(jpr_topm:jpr_botm)%laction = .TRUE.
+      ENDIF
+      !                                                      ! ------------------------------- !
+      !                                                      !   OPA-SAS coupling - rcv by opa !   
+      !                                                      ! ------------------------------- !
+      srcv(jpr_sflx)%clname = 'O_SFLX'
+      srcv(jpr_fice)%clname = 'RIceFrc'
+      !
+      IF( nn_components == jp_iam_opa ) THEN    ! OPA coupled to SAS via OASIS: force received field by OPA (sent by SAS)
+         srcv(:)%laction = .FALSE.   ! force default definition in case of opa <-> sas coupling
+         srcv(:)%clgrid  = 'T'       ! force default definition in case of opa <-> sas coupling
+         srcv(:)%nsgn    = 1.        ! force default definition in case of opa <-> sas coupling
+         srcv( (/jpr_qsroce, jpr_qnsoce, jpr_oemp, jpr_sflx, jpr_fice, jpr_otx1, jpr_oty1, jpr_taum/) )%laction = .TRUE.
+         srcv(jpr_otx1)%clgrid = 'U'        ! oce components given at U-point
+         srcv(jpr_oty1)%clgrid = 'V'        !           and           V-point
+         ! Vectors: change of sign at north fold ONLY if on the local grid
+         srcv( (/jpr_otx1,jpr_oty1/) )%nsgn = -1.
+         sn_rcv_tau%clvgrd = 'U,V'
+         sn_rcv_tau%clvor = 'local grid'
+         sn_rcv_tau%clvref = 'spherical'
+         sn_rcv_emp%cldes = 'oce only'
+         !
+         IF(lwp) THEN                        ! control print
+            WRITE(numout,*)
+            WRITE(numout,*)'               Special conditions for SAS-OPA coupling  '
+            WRITE(numout,*)'               OPA component  '
+            WRITE(numout,*)
+            WRITE(numout,*)'  received fields from SAS component '
+            WRITE(numout,*)'                  ice cover '
+            WRITE(numout,*)'                  oce only EMP  '
+            WRITE(numout,*)'                  salt flux  '
+            WRITE(numout,*)'                  mixed oce-ice solar flux  '
+            WRITE(numout,*)'                  mixed oce-ice non solar flux  '
+            WRITE(numout,*)'                  wind stress U,V on local grid and sperical coordinates '
+            WRITE(numout,*)'                  wind stress module'
+            WRITE(numout,*)
+         ENDIF
+      ENDIF
+      !                                                      ! -------------------------------- !
+      !                                                      !   OPA-SAS coupling - rcv by sas  !   
+      !                                                      ! -------------------------------- !
+      srcv(jpr_toce  )%clname = 'I_SSTSST'
+      srcv(jpr_soce  )%clname = 'I_SSSal'
+      srcv(jpr_ocx1  )%clname = 'I_OCurx1'
+      srcv(jpr_ocy1  )%clname = 'I_OCury1'
+      srcv(jpr_ssh   )%clname = 'I_SSHght'
+      srcv(jpr_e3t1st)%clname = 'I_E3T1st'   
+      srcv(jpr_fraqsr)%clname = 'I_FraQsr'   
+      !
+      IF( nn_components == jp_iam_sas ) THEN
+         IF( .NOT. ln_cpl ) srcv(:)%laction = .FALSE.   ! force default definition in case of opa <-> sas coupling
+         IF( .NOT. ln_cpl ) srcv(:)%clgrid  = 'T'       ! force default definition in case of opa <-> sas coupling
+         IF( .NOT. ln_cpl ) srcv(:)%nsgn    = 1.        ! force default definition in case of opa <-> sas coupling
+         srcv( (/jpr_toce, jpr_soce, jpr_ssh, jpr_fraqsr, jpr_ocx1, jpr_ocy1/) )%laction = .TRUE.
+         srcv( jpr_e3t1st )%laction = lk_vvl
+         srcv(jpr_ocx1)%clgrid = 'U'        ! oce components given at U-point
+         srcv(jpr_ocy1)%clgrid = 'V'        !           and           V-point
+         ! Vectors: change of sign at north fold ONLY if on the local grid
+         srcv(jpr_ocx1:jpr_ocy1)%nsgn = -1.
+         ! Change first letter to couple with atmosphere if already coupled OPA
+         ! this is nedeed as each variable name used in the namcouple must be unique:
+         ! for example O_Runoff received by OPA from SAS and therefore O_Runoff received by SAS from the Atmosphere
+         DO jn = 1, jprcv
+            IF ( srcv(jn)%clname(1:1) == "O" ) srcv(jn)%clname = "S"//srcv(jn)%clname(2:LEN(srcv(jn)%clname))
+         END DO
+         !
+         IF(lwp) THEN                        ! control print
+            WRITE(numout,*)
+            WRITE(numout,*)'               Special conditions for SAS-OPA coupling  '
+            WRITE(numout,*)'               SAS component  '
+            WRITE(numout,*)
+            IF( .NOT. ln_cpl ) THEN
+               WRITE(numout,*)'  received fields from OPA component '
+            ELSE
+               WRITE(numout,*)'  Additional received fields from OPA component : '
+            ENDIF
+            WRITE(numout,*)'               sea surface temperature (Celcius) '
+            WRITE(numout,*)'               sea surface salinity ' 
+            WRITE(numout,*)'               surface currents ' 
+            WRITE(numout,*)'               sea surface height ' 
+            WRITE(numout,*)'               thickness of first ocean T level '        
+            WRITE(numout,*)'               fraction of solar net radiation absorbed in the first ocean level'
+            WRITE(numout,*)
+         ENDIF
+      ENDIF
+      
+      ! =================================================== !
+      ! Allocate all parts of frcv used for received fields !
+      ! =================================================== !
+      DO jn = 1, jprcv
+         IF ( srcv(jn)%laction ) ALLOCATE( frcv(jn)%z3(jpi,jpj,srcv(jn)%nct) )
+      END DO
+      ! Allocate taum part of frcv which is used even when not received as coupling field
+      IF ( .NOT. srcv(jpr_taum)%laction ) ALLOCATE( frcv(jpr_taum)%z3(jpi,jpj,srcv(jpr_taum)%nct) )
+      ! Allocate w10m part of frcv which is used even when not received as coupling field
+      IF ( .NOT. srcv(jpr_w10m)%laction ) ALLOCATE( frcv(jpr_w10m)%z3(jpi,jpj,srcv(jpr_w10m)%nct) )
+      ! Allocate jpr_otx1 part of frcv which is used even when not received as coupling field
+      IF ( .NOT. srcv(jpr_otx1)%laction ) ALLOCATE( frcv(jpr_otx1)%z3(jpi,jpj,srcv(jpr_otx1)%nct) )
+      IF ( .NOT. srcv(jpr_oty1)%laction ) ALLOCATE( frcv(jpr_oty1)%z3(jpi,jpj,srcv(jpr_oty1)%nct) )
+      ! Allocate itx1 and ity1 as they are used in sbc_cpl_ice_tau even if srcv(jpr_itx1)%laction = .FALSE.
+      IF( k_ice /= 0 ) THEN
+         IF ( .NOT. srcv(jpr_itx1)%laction ) ALLOCATE( frcv(jpr_itx1)%z3(jpi,jpj,srcv(jpr_itx1)%nct) )
+         IF ( .NOT. srcv(jpr_ity1)%laction ) ALLOCATE( frcv(jpr_ity1)%z3(jpi,jpj,srcv(jpr_ity1)%nct) )
+      END IF
+
+      ! ================================ !
+      !     Define the send interface    !
+      ! ================================ !
+      ! for each field: define the OASIS name                           (ssnd(:)%clname)
+      !                 define send or not from the namelist parameters (ssnd(:)%laction)
+      !                 define the north fold type of lbc               (ssnd(:)%nsgn)
+      
+      ! default definitions of nsnd
+      ssnd(:)%laction = .FALSE.   ;   ssnd(:)%clgrid = 'T'   ;   ssnd(:)%nsgn = 1.  ; ssnd(:)%nct = 1
+         
+      !                                                      ! ------------------------- !
+      !                                                      !    Surface temperature    !
+      !                                                      ! ------------------------- !
+      ssnd(jps_toce)%clname = 'O_SSTSST'
+      ssnd(jps_tice)%clname = 'O_TepIce'
+      ssnd(jps_tmix)%clname = 'O_TepMix'
+      SELECT CASE( TRIM( sn_snd_temp%cldes ) )
+      CASE( 'none'                                 )       ! nothing to do
+      CASE( 'oce only'                             )   ;   ssnd( jps_toce )%laction = .TRUE.
+      CASE( 'oce and ice' , 'weighted oce and ice' )
+         ssnd( (/jps_toce, jps_tice/) )%laction = .TRUE.
+         IF ( TRIM( sn_snd_temp%clcat ) == 'yes' )  ssnd(jps_tice)%nct = jpl
+      CASE( 'mixed oce-ice'                        )   ;   ssnd( jps_tmix )%laction = .TRUE.
+      CASE default   ;   CALL ctl_stop( 'sbc_cpl_init: wrong definition of sn_snd_temp%cldes' )
+      END SELECT
+           
+      !                                                      ! ------------------------- !
+      !                                                      !          Albedo           !
+      !                                                      ! ------------------------- !
+      ssnd(jps_albice)%clname = 'O_AlbIce' 
+      ssnd(jps_albmix)%clname = 'O_AlbMix'
+      SELECT CASE( TRIM( sn_snd_alb%cldes ) )
+      CASE( 'none'                 )     ! nothing to do
+      CASE( 'ice' , 'weighted ice' )   ; ssnd(jps_albice)%laction = .TRUE.
+      CASE( 'mixed oce-ice'        )   ; ssnd(jps_albmix)%laction = .TRUE.
+      CASE default   ;   CALL ctl_stop( 'sbc_cpl_init: wrong definition of sn_snd_alb%cldes' )
+      END SELECT
+      !
+      ! Need to calculate oceanic albedo if
+      !     1. sending mixed oce-ice albedo or
+      !     2. receiving mixed oce-ice solar radiation 
+      IF ( TRIM ( sn_snd_alb%cldes ) == 'mixed oce-ice' .OR. TRIM ( sn_rcv_qsr%cldes ) == 'mixed oce-ice' ) THEN
+         CALL albedo_oce( zaos, zacs )
+         ! Due to lack of information on nebulosity : mean clear/overcast sky
+         albedo_oce_mix(:,:) = ( zacs(:,:) + zaos(:,:) ) * 0.5
+      ENDIF
+
+      !                                                      ! ------------------------- !
+      !                                                      !  Ice fraction & Thickness ! 
+      !                                                      ! ------------------------- !
+      ssnd(jps_fice)%clname = 'OIceFrc'
+      ssnd(jps_hice)%clname = 'OIceTck'
+      ssnd(jps_hsnw)%clname = 'OSnwTck'
+      IF( k_ice /= 0 ) THEN
+         ssnd(jps_fice)%laction = .TRUE.                  ! if ice treated in the ocean (even in climato case)
+! Currently no namelist entry to determine sending of multi-category ice fraction so use the thickness entry for now
+         IF ( TRIM( sn_snd_thick%clcat ) == 'yes' ) ssnd(jps_fice)%nct = jpl
+      ENDIF
+      
+      SELECT CASE ( TRIM( sn_snd_thick%cldes ) )
+      CASE( 'none'         )       ! nothing to do
+      CASE( 'ice and snow' ) 
+         ssnd(jps_hice:jps_hsnw)%laction = .TRUE.
+         IF ( TRIM( sn_snd_thick%clcat ) == 'yes' ) THEN
+            ssnd(jps_hice:jps_hsnw)%nct = jpl
+         ENDIF
+      CASE ( 'weighted ice and snow' ) 
+         ssnd(jps_hice:jps_hsnw)%laction = .TRUE.
+         IF ( TRIM( sn_snd_thick%clcat ) == 'yes' ) ssnd(jps_hice:jps_hsnw)%nct = jpl
+      CASE default   ;   CALL ctl_stop( 'sbc_cpl_init: wrong definition of sn_snd_thick%cldes' )
+      END SELECT
+
+      !                                                      ! ------------------------- !
+      !                                                      !      Surface current      !
+      !                                                      ! ------------------------- !
+      !        ocean currents              !            ice velocities
+      ssnd(jps_ocx1)%clname = 'O_OCurx1'   ;   ssnd(jps_ivx1)%clname = 'O_IVelx1'
+      ssnd(jps_ocy1)%clname = 'O_OCury1'   ;   ssnd(jps_ivy1)%clname = 'O_IVely1'
+      ssnd(jps_ocz1)%clname = 'O_OCurz1'   ;   ssnd(jps_ivz1)%clname = 'O_IVelz1'
+      !
+      ssnd(jps_ocx1:jps_ivz1)%nsgn = -1.   ! vectors: change of the sign at the north fold
+
+      IF( sn_snd_crt%clvgrd == 'U,V' ) THEN
+         ssnd(jps_ocx1)%clgrid = 'U' ; ssnd(jps_ocy1)%clgrid = 'V'
+      ELSE IF( sn_snd_crt%clvgrd /= 'T' ) THEN  
+         CALL ctl_stop( 'sn_snd_crt%clvgrd must be equal to T' )
+         ssnd(jps_ocx1:jps_ivz1)%clgrid  = 'T'      ! all oce and ice components on the same unique grid
+      ENDIF
+      ssnd(jps_ocx1:jps_ivz1)%laction = .TRUE.   ! default: all are send
+      IF( TRIM( sn_snd_crt%clvref ) == 'spherical' )   ssnd( (/jps_ocz1, jps_ivz1/) )%laction = .FALSE. 
+      IF( TRIM( sn_snd_crt%clvor ) == 'eastward-northward' ) ssnd(jps_ocx1:jps_ivz1)%nsgn = 1.
+      SELECT CASE( TRIM( sn_snd_crt%cldes ) )
+      CASE( 'none'                 )   ;   ssnd(jps_ocx1:jps_ivz1)%laction = .FALSE.
+      CASE( 'oce only'             )   ;   ssnd(jps_ivx1:jps_ivz1)%laction = .FALSE.
+      CASE( 'weighted oce and ice' )   !   nothing to do
+      CASE( 'mixed oce-ice'        )   ;   ssnd(jps_ivx1:jps_ivz1)%laction = .FALSE.
+      CASE default   ;   CALL ctl_stop( 'sbc_cpl_init: wrong definition of sn_snd_crt%cldes' )
+      END SELECT
+
+      !                                                      ! ------------------------- !
+      !                                                      !          CO2 flux         !
+      !                                                      ! ------------------------- !
+      ssnd(jps_co2)%clname = 'O_CO2FLX' ;  IF( TRIM(sn_snd_co2%cldes) == 'coupled' )    ssnd(jps_co2 )%laction = .TRUE.
+
+      !                                                      ! ------------------------- !
+      !                                                      !          DMS flux         !
+      !                                                      ! ------------------------- !
+      ssnd(jps_dms)%clname = 'O_DMSFLX' ;  IF( TRIM(sn_snd_dms%cldes) == 'coupled' )    ssnd(jps_dms )%laction = .TRUE.
+
+      !                                                      ! ------------------------------- !
+      !                                                      !   OPA-SAS coupling - snd by opa !   
+      !                                                      ! ------------------------------- !
+      ssnd(jps_ssh   )%clname = 'O_SSHght' 
+      ssnd(jps_soce  )%clname = 'O_SSSal' 
+      ssnd(jps_e3t1st)%clname = 'O_E3T1st'   
+      ssnd(jps_fraqsr)%clname = 'O_FraQsr'
+      !
+      IF( nn_components == jp_iam_opa ) THEN
+         ssnd(:)%laction = .FALSE.   ! force default definition in case of opa <-> sas coupling
+         ssnd( (/jps_toce, jps_soce, jps_ssh, jps_fraqsr, jps_ocx1, jps_ocy1/) )%laction = .TRUE.
+         ssnd( jps_e3t1st )%laction = lk_vvl
+         ! vector definition: not used but cleaner...
+         ssnd(jps_ocx1)%clgrid  = 'U'        ! oce components given at U-point
+         ssnd(jps_ocy1)%clgrid  = 'V'        !           and           V-point
+         sn_snd_crt%clvgrd = 'U,V'
+         sn_snd_crt%clvor = 'local grid'
+         sn_snd_crt%clvref = 'spherical'
+         !
+         IF(lwp) THEN                        ! control print
+            WRITE(numout,*)
+            WRITE(numout,*)'  sent fields to SAS component '
+            WRITE(numout,*)'               sea surface temperature (T before, Celcius) '
+            WRITE(numout,*)'               sea surface salinity ' 
+            WRITE(numout,*)'               surface currents U,V on local grid and spherical coordinates' 
+            WRITE(numout,*)'               sea surface height ' 
+            WRITE(numout,*)'               thickness of first ocean T level '        
+            WRITE(numout,*)'               fraction of solar net radiation absorbed in the first ocean level'
+            WRITE(numout,*)
+         ENDIF
+      ENDIF
+      !                                                      ! ------------------------------- !
+      !                                                      !   OPA-SAS coupling - snd by sas !   
+      !                                                      ! ------------------------------- !
+      ssnd(jps_sflx  )%clname = 'I_SFLX'     
+      ssnd(jps_fice2 )%clname = 'IIceFrc'
+      ssnd(jps_qsroce)%clname = 'I_QsrOce'   
+      ssnd(jps_qnsoce)%clname = 'I_QnsOce'   
+      ssnd(jps_oemp  )%clname = 'IOEvaMPr' 
+      ssnd(jps_otx1  )%clname = 'I_OTaux1'   
+      ssnd(jps_oty1  )%clname = 'I_OTauy1'   
+      ssnd(jps_rnf   )%clname = 'I_Runoff'   
+      ssnd(jps_taum  )%clname = 'I_TauMod'   
+      !
+      IF( nn_components == jp_iam_sas ) THEN
+         IF( .NOT. ln_cpl ) ssnd(:)%laction = .FALSE.   ! force default definition in case of opa <-> sas coupling
+         ssnd( (/jps_qsroce, jps_qnsoce, jps_oemp, jps_fice2, jps_sflx, jps_otx1, jps_oty1, jps_taum/) )%laction = .TRUE.
+         !
+         ! Change first letter to couple with atmosphere if already coupled with sea_ice
+         ! this is nedeed as each variable name used in the namcouple must be unique:
+         ! for example O_SSTSST sent by OPA to SAS and therefore S_SSTSST sent by SAS to the Atmosphere
+         DO jn = 1, jpsnd
+            IF ( ssnd(jn)%clname(1:1) == "O" ) ssnd(jn)%clname = "S"//ssnd(jn)%clname(2:LEN(ssnd(jn)%clname))
+         END DO
+         !
+         IF(lwp) THEN                        ! control print
+            WRITE(numout,*)
+            IF( .NOT. ln_cpl ) THEN
+               WRITE(numout,*)'  sent fields to OPA component '
+            ELSE
+               WRITE(numout,*)'  Additional sent fields to OPA component : '
+            ENDIF
+            WRITE(numout,*)'                  ice cover '
+            WRITE(numout,*)'                  oce only EMP  '
+            WRITE(numout,*)'                  salt flux  '
+            WRITE(numout,*)'                  mixed oce-ice solar flux  '
+            WRITE(numout,*)'                  mixed oce-ice non solar flux  '
+            WRITE(numout,*)'                  wind stress U,V components'
+            WRITE(numout,*)'                  wind stress module'
+         ENDIF
+      ENDIF
+
+      !
+      ! ================================ !
+      !   initialisation of the coupler  !
+      ! ================================ !
+
+      CALL cpl_define(jprcv, jpsnd, nn_cplmodel)
+      
+      IF (ln_usecplmask) THEN 
+         xcplmask(:,:,:) = 0.
+         CALL iom_open( 'cplmask', inum )
+         CALL iom_get( inum, jpdom_unknown, 'cplmask', xcplmask(1:nlci,1:nlcj,1:nn_cplmodel),   &
+            &          kstart = (/ mig(1),mjg(1),1 /), kcount = (/ nlci,nlcj,nn_cplmodel /) )
+         CALL iom_close( inum )
+      ELSE
+         xcplmask(:,:,:) = 1.
+      ENDIF
+      xcplmask(:,:,0) = 1. - SUM( xcplmask(:,:,1:nn_cplmodel), dim = 3 )
+      !
+      ncpl_qsr_freq = cpl_freq( 'O_QsrOce' ) + cpl_freq( 'O_QsrMix' ) + cpl_freq( 'I_QsrOce' ) + cpl_freq( 'I_QsrMix' )
+      IF( ln_dm2dc .AND. ln_cpl .AND. ncpl_qsr_freq /= 86400 )   &
+         &   CALL ctl_stop( 'sbc_cpl_init: diurnal cycle reconstruction (ln_dm2dc) needs daily couping for solar radiation' )
+
+      CALL wrk_dealloc( jpi,jpj, zacs, zaos )
+      !
+      IF( nn_timing == 1 )  CALL timing_stop('sbc_cpl_init')
+      !
+   END SUBROUTINE sbc_cpl_init
+
+
+   SUBROUTINE sbc_cpl_rcv( kt, k_fsbc, k_ice )     
+      !!----------------------------------------------------------------------
+      !!             ***  ROUTINE sbc_cpl_rcv  ***
+      !!
+      !! ** Purpose :   provide the stress over the ocean and, if no sea-ice,
+      !!                provide the ocean heat and freshwater fluxes.
+      !!
+      !! ** Method  : - Receive all the atmospheric fields (stored in frcv array). called at each time step.
+      !!                OASIS controls if there is something do receive or not. nrcvinfo contains the info
+      !!                to know if the field was really received or not
+      !!
+      !!              --> If ocean stress was really received:
+      !!
+      !!                  - transform the received ocean stress vector from the received
+      !!                 referential and grid into an atmosphere-ocean stress in 
+      !!                 the (i,j) ocean referencial and at the ocean velocity point. 
+      !!                    The received stress are :
+      !!                     - defined by 3 components (if cartesian coordinate)
+      !!                            or by 2 components (if spherical)
+      !!                     - oriented along geographical   coordinate (if eastward-northward)
+      !!                            or  along the local grid coordinate (if local grid)
+      !!                     - given at U- and V-point, resp.   if received on 2 grids
+      !!                            or at T-point               if received on 1 grid
+      !!                    Therefore and if necessary, they are successively 
+      !!                  processed in order to obtain them 
+      !!                     first  as  2 components on the sphere 
+      !!                     second as  2 components oriented along the local grid
+      !!                     third  as  2 components on the U,V grid 
+      !!
+      !!              --> 
+      !!
+      !!              - In 'ocean only' case, non solar and solar ocean heat fluxes 
+      !!             and total ocean freshwater fluxes  
+      !!
+      !! ** Method  :   receive all fields from the atmosphere and transform 
+      !!              them into ocean surface boundary condition fields 
+      !!
+      !! ** Action  :   update  utau, vtau   ocean stress at U,V grid 
+      !!                        taum         wind stress module at T-point
+      !!                        wndm         wind speed  module at T-point over free ocean or leads in presence of sea-ice
+      !!                        qns          non solar heat fluxes including emp heat content    (ocean only case)
+      !!                                     and the latent heat flux of solid precip. melting
+      !!                        qsr          solar ocean heat fluxes   (ocean only case)
+      !!                        emp          upward mass flux [evap. - precip. (- runoffs) (- calving)] (ocean only case)
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT(in)           ::   kt          ! ocean model time step index
+      INTEGER, INTENT(in)           ::   k_fsbc      ! frequency of sbc (-> ice model) computation 
+      INTEGER, INTENT(in)           ::   k_ice       ! ice management in the sbc (=0/1/2/3)
+
+      !!
+      LOGICAL  ::   llnewtx, llnewtau      ! update wind stress components and module??
+      INTEGER  ::   ji, jj, jn             ! dummy loop indices
+      INTEGER  ::   isec                   ! number of seconds since nit000 (assuming rdttra did not change since nit000)
+      REAL(wp) ::   zcumulneg, zcumulpos   ! temporary scalars     
+      REAL(wp) ::   zcoef                  ! temporary scalar
+      REAL(wp) ::   zrhoa  = 1.22          ! Air density kg/m3
+      REAL(wp) ::   zcdrag = 1.5e-3        ! drag coefficient
+      REAL(wp) ::   zzx, zzy               ! temporary variables
+      REAL(wp), POINTER, DIMENSION(:,:) ::   ztx, zty, zmsk, zemp, zqns, zqsr
+      !!----------------------------------------------------------------------
+      !
+      IF( nn_timing == 1 )  CALL timing_start('sbc_cpl_rcv')
+      !
+      CALL wrk_alloc( jpi,jpj, ztx, zty, zmsk, zemp, zqns, zqsr )
+      !
+      IF( ln_mixcpl )   zmsk(:,:) = 1. - xcplmask(:,:,0)
+      !
+      !                                                      ! ======================================================= !
+      !                                                      ! Receive all the atmos. fields (including ice information)
+      !                                                      ! ======================================================= !
+      isec = ( kt - nit000 ) * NINT( rdttra(1) )                ! date of exchanges
+      DO jn = 1, jprcv                                          ! received fields sent by the atmosphere
+         IF( srcv(jn)%laction )   CALL cpl_rcv( jn, isec, frcv(jn)%z3, xcplmask(:,:,1:nn_cplmodel), nrcvinfo(jn) )
+      END DO
+
+      !                                                      ! ========================= !
+      IF( srcv(jpr_otx1)%laction ) THEN                      !  ocean stress components  !
+         !                                                   ! ========================= !
+         ! define frcv(jpr_otx1)%z3(:,:,1) and frcv(jpr_oty1)%z3(:,:,1): stress at U/V point along model grid
+         ! => need to be done only when we receive the field
+         IF(  nrcvinfo(jpr_otx1) == OASIS_Rcv ) THEN
+            !
+            IF( TRIM( sn_rcv_tau%clvref ) == 'cartesian' ) THEN            ! 2 components on the sphere
+               !                                                       ! (cartesian to spherical -> 3 to 2 components)
+               !
+               CALL geo2oce( frcv(jpr_otx1)%z3(:,:,1), frcv(jpr_oty1)%z3(:,:,1), frcv(jpr_otz1)%z3(:,:,1),   &
+                  &          srcv(jpr_otx1)%clgrid, ztx, zty )
+               frcv(jpr_otx1)%z3(:,:,1) = ztx(:,:)   ! overwrite 1st comp. on the 1st grid
+               frcv(jpr_oty1)%z3(:,:,1) = zty(:,:)   ! overwrite 2nd comp. on the 1st grid
+               !
+               IF( srcv(jpr_otx2)%laction ) THEN
+                  CALL geo2oce( frcv(jpr_otx2)%z3(:,:,1), frcv(jpr_oty2)%z3(:,:,1), frcv(jpr_otz2)%z3(:,:,1),   &
+                     &          srcv(jpr_otx2)%clgrid, ztx, zty )
+                  frcv(jpr_otx2)%z3(:,:,1) = ztx(:,:)   ! overwrite 1st comp. on the 2nd grid
+                  frcv(jpr_oty2)%z3(:,:,1) = zty(:,:)   ! overwrite 2nd comp. on the 2nd grid
+               ENDIF
+               !
+            ENDIF
+            !
+            IF( TRIM( sn_rcv_tau%clvor ) == 'eastward-northward' ) THEN   ! 2 components oriented along the local grid
+               !                                                       ! (geographical to local grid -> rotate the components)
+               CALL rot_rep( frcv(jpr_otx1)%z3(:,:,1), frcv(jpr_oty1)%z3(:,:,1), srcv(jpr_otx1)%clgrid, 'en->i', ztx )   
+               IF( srcv(jpr_otx2)%laction ) THEN
+                  CALL rot_rep( frcv(jpr_otx2)%z3(:,:,1), frcv(jpr_oty2)%z3(:,:,1), srcv(jpr_otx2)%clgrid, 'en->j', zty )   
+               ELSE	
+                  CALL rot_rep( frcv(jpr_otx1)%z3(:,:,1), frcv(jpr_oty1)%z3(:,:,1), srcv(jpr_otx1)%clgrid, 'en->j', zty )  
+               ENDIF
+               frcv(jpr_otx1)%z3(:,:,1) = ztx(:,:)      ! overwrite 1st component on the 1st grid
+               frcv(jpr_oty1)%z3(:,:,1) = zty(:,:)      ! overwrite 2nd component on the 2nd grid
+            ENDIF
+            !                              
+            IF( srcv(jpr_otx1)%clgrid == 'T' ) THEN
+               DO jj = 2, jpjm1                                          ! T ==> (U,V)
+                  DO ji = fs_2, fs_jpim1   ! vector opt.
+                     frcv(jpr_otx1)%z3(ji,jj,1) = 0.5 * ( frcv(jpr_otx1)%z3(ji+1,jj  ,1) + frcv(jpr_otx1)%z3(ji,jj,1) )
+                     frcv(jpr_oty1)%z3(ji,jj,1) = 0.5 * ( frcv(jpr_oty1)%z3(ji  ,jj+1,1) + frcv(jpr_oty1)%z3(ji,jj,1) )
+                  END DO
+               END DO
+               CALL lbc_lnk( frcv(jpr_otx1)%z3(:,:,1), 'U',  -1. )   ;   CALL lbc_lnk( frcv(jpr_oty1)%z3(:,:,1), 'V',  -1. )
+            ENDIF
+            llnewtx = .TRUE.
+         ELSE
+            llnewtx = .FALSE.
+         ENDIF
+         !                                                   ! ========================= !
+      ELSE                                                   !   No dynamical coupling   !
+         !                                                   ! ========================= !
+         frcv(jpr_otx1)%z3(:,:,1) = 0.e0                               ! here simply set to zero 
+         frcv(jpr_oty1)%z3(:,:,1) = 0.e0                               ! an external read in a file can be added instead
+         llnewtx = .TRUE.
+         !
+      ENDIF
+      !                                                      ! ========================= !
+      !                                                      !    wind stress module     !   (taum)
+      !                                                      ! ========================= !
+      !
+      IF( .NOT. srcv(jpr_taum)%laction ) THEN                    ! compute wind stress module from its components if not received 
+         ! => need to be done only when otx1 was changed
+         IF( llnewtx ) THEN
+!CDIR NOVERRCHK
+            DO jj = 2, jpjm1
+!CDIR NOVERRCHK
+               DO ji = fs_2, fs_jpim1   ! vect. opt.
+                  zzx = frcv(jpr_otx1)%z3(ji-1,jj  ,1) + frcv(jpr_otx1)%z3(ji,jj,1)
+                  zzy = frcv(jpr_oty1)%z3(ji  ,jj-1,1) + frcv(jpr_oty1)%z3(ji,jj,1)
+                  frcv(jpr_taum)%z3(ji,jj,1) = 0.5 * SQRT( zzx * zzx + zzy * zzy )
+               END DO
+            END DO
+            CALL lbc_lnk( frcv(jpr_taum)%z3(:,:,1), 'T', 1. )
+            llnewtau = .TRUE.
+         ELSE
+            llnewtau = .FALSE.
+         ENDIF
+      ELSE
+         llnewtau = nrcvinfo(jpr_taum) == OASIS_Rcv
+         ! Stress module can be negative when received (interpolation problem)
+         IF( llnewtau ) THEN 
+            frcv(jpr_taum)%z3(:,:,1) = MAX( 0._wp, frcv(jpr_taum)%z3(:,:,1) )
+         ENDIF
+      ENDIF
+      !
+      !                                                      ! ========================= !
+      !                                                      !      10 m wind speed      !   (wndm)
+      !                                                      ! ========================= !
+      !
+      IF( .NOT. srcv(jpr_w10m)%laction ) THEN                    ! compute wind spreed from wind stress module if not received  
+         ! => need to be done only when taumod was changed
+         IF( llnewtau ) THEN 
+            zcoef = 1. / ( zrhoa * zcdrag ) 
+!CDIR NOVERRCHK
+            DO jj = 1, jpj
+!CDIR NOVERRCHK
+               DO ji = 1, jpi 
+                  frcv(jpr_w10m)%z3(ji,jj,1) = SQRT( frcv(jpr_taum)%z3(ji,jj,1) * zcoef )
+               END DO
+            END DO
+         ENDIF
+      ENDIF
+
+      ! u(v)tau and taum will be modified by ice model
+      ! -> need to be reset before each call of the ice/fsbc      
+      IF( MOD( kt-1, k_fsbc ) == 0 ) THEN
+         !
+         IF( ln_mixcpl ) THEN
+            utau(:,:) = utau(:,:) * xcplmask(:,:,0) + frcv(jpr_otx1)%z3(:,:,1) * zmsk(:,:)
+            vtau(:,:) = vtau(:,:) * xcplmask(:,:,0) + frcv(jpr_oty1)%z3(:,:,1) * zmsk(:,:)
+            taum(:,:) = taum(:,:) * xcplmask(:,:,0) + frcv(jpr_taum)%z3(:,:,1) * zmsk(:,:)
+            wndm(:,:) = wndm(:,:) * xcplmask(:,:,0) + frcv(jpr_w10m)%z3(:,:,1) * zmsk(:,:)
+         ELSE
+            utau(:,:) = frcv(jpr_otx1)%z3(:,:,1)
+            vtau(:,:) = frcv(jpr_oty1)%z3(:,:,1)
+            taum(:,:) = frcv(jpr_taum)%z3(:,:,1)
+            wndm(:,:) = frcv(jpr_w10m)%z3(:,:,1)
+         ENDIF
+         CALL iom_put( "taum_oce", taum )   ! output wind stress module
+         !  
+      ENDIF
+
+#if defined key_cpl_carbon_cycle
+      !                                                      ! ================== !
+      !                                                      ! atmosph. CO2 (ppm) !
+      !                                                      ! ================== !
+      IF( srcv(jpr_co2)%laction )   atm_co2(:,:) = frcv(jpr_co2)%z3(:,:,1)
+#endif
+
+      !  Fields received by SAS when OASIS coupling
+      !  (arrays no more filled at sbcssm stage)
+      !                                                      ! ================== !
+      !                                                      !        SSS         !
+      !                                                      ! ================== !
+      IF( srcv(jpr_soce)%laction ) THEN                      ! received by sas in case of opa <-> sas coupling
+         sss_m(:,:) = frcv(jpr_soce)%z3(:,:,1)
+         CALL iom_put( 'sss_m', sss_m )
+      ENDIF
+      !                                               
+      !                                                      ! ================== !
+      !                                                      !        SST         !
+      !                                                      ! ================== !
+      IF( srcv(jpr_toce)%laction ) THEN                      ! received by sas in case of opa <-> sas coupling
+         sst_m(:,:) = frcv(jpr_toce)%z3(:,:,1)
+         IF( srcv(jpr_soce)%laction .AND. ln_useCT ) THEN    ! make sure that sst_m is the potential temperature
+            sst_m(:,:) = eos_pt_from_ct( sst_m(:,:), sss_m(:,:) )
+         ENDIF
+      ENDIF
+      !                                                      ! ================== !
+      !                                                      !        SSH         !
+      !                                                      ! ================== !
+      IF( srcv(jpr_ssh )%laction ) THEN                      ! received by sas in case of opa <-> sas coupling
+         ssh_m(:,:) = frcv(jpr_ssh )%z3(:,:,1)
+         CALL iom_put( 'ssh_m', ssh_m )
+      ENDIF
+      !                                                      ! ================== !
+      !                                                      !  surface currents  !
+      !                                                      ! ================== !
+      IF( srcv(jpr_ocx1)%laction ) THEN                      ! received by sas in case of opa <-> sas coupling
+         ssu_m(:,:) = frcv(jpr_ocx1)%z3(:,:,1)
+         ub (:,:,1) = ssu_m(:,:)                             ! will be used in sbcice_lim in the call of lim_sbc_tau
+         un (:,:,1) = ssu_m(:,:)                             ! will be used in sbc_cpl_snd if atmosphere coupling
+         CALL iom_put( 'ssu_m', ssu_m )
+      ENDIF
+      IF( srcv(jpr_ocy1)%laction ) THEN
+         ssv_m(:,:) = frcv(jpr_ocy1)%z3(:,:,1)
+         vb (:,:,1) = ssv_m(:,:)                             ! will be used in sbcice_lim in the call of lim_sbc_tau
+         vn (:,:,1) = ssv_m(:,:)                             ! will be used in sbc_cpl_snd if atmosphere coupling
+         CALL iom_put( 'ssv_m', ssv_m )
+      ENDIF
+      !                                                      ! ======================== !
+      !                                                      !  first T level thickness !
+      !                                                      ! ======================== !
+      IF( srcv(jpr_e3t1st )%laction ) THEN                   ! received by sas in case of opa <-> sas coupling
+         e3t_m(:,:) = frcv(jpr_e3t1st )%z3(:,:,1)
+         CALL iom_put( 'e3t_m', e3t_m(:,:) )
+      ENDIF
+      !                                                      ! ================================ !
+      !                                                      !  fraction of solar net radiation !
+      !                                                      ! ================================ !
+      IF( srcv(jpr_fraqsr)%laction ) THEN                    ! received by sas in case of opa <-> sas coupling
+         frq_m(:,:) = frcv(jpr_fraqsr)%z3(:,:,1)
+         CALL iom_put( 'frq_m', frq_m )
+      ENDIF
+      
+      !                                                      ! ========================= !
+      IF( k_ice <= 1 .AND. MOD( kt-1, k_fsbc ) == 0 ) THEN   !  heat & freshwater fluxes ! (Ocean only case)
+         !                                                   ! ========================= !
+         !
+         !                                                       ! total freshwater fluxes over the ocean (emp)
+         IF( srcv(jpr_oemp)%laction .OR. srcv(jpr_rain)%laction ) THEN
+            SELECT CASE( TRIM( sn_rcv_emp%cldes ) )                                    ! evaporation - precipitation
+            CASE( 'conservative' )
+               zemp(:,:) = frcv(jpr_tevp)%z3(:,:,1) - ( frcv(jpr_rain)%z3(:,:,1) + frcv(jpr_snow)%z3(:,:,1) )
+            CASE( 'oce only', 'oce and ice' )
+               zemp(:,:) = frcv(jpr_oemp)%z3(:,:,1)
+            CASE default
+               CALL ctl_stop( 'sbc_cpl_rcv: wrong definition of sn_rcv_emp%cldes' )
+            END SELECT
+         ELSE
+            zemp(:,:) = 0._wp
+         ENDIF
+         !
+         !   
+         !                                                        ! runoffs and calving (added in emp)
+         IF( srcv(jpr_rnf)%laction )     rnf(:,:)  = frcv(jpr_rnf)%z3(:,:,1)
+         IF( srcv(jpr_cal)%laction )     zemp(:,:) = zemp(:,:) - frcv(jpr_cal)%z3(:,:,1)
+
+         IF( srcv(jpr_icb)%laction )  THEN 
+             fwficb(:,:) = frcv(jpr_icb)%z3(:,:,1)
+             rnf(:,:)    = rnf(:,:) + fwficb(:,:)   ! iceberg added to runfofs
+         ENDIF
+         IF( srcv(jpr_isf)%laction )  fwfisf(:,:) = - frcv(jpr_isf)%z3(:,:,1)  ! fresh water flux from the isf (fwfisf <0 mean melting)  
+         
+         IF( ln_mixcpl ) THEN   ;   emp(:,:) = emp(:,:) * xcplmask(:,:,0) + zemp(:,:) * zmsk(:,:)
+         ELSE                   ;   emp(:,:) =                              zemp(:,:)
+         ENDIF
+         !
+         !                                                       ! non solar heat flux over the ocean (qns)
+         IF(      srcv(jpr_qnsoce)%laction ) THEN   ;   zqns(:,:) = frcv(jpr_qnsoce)%z3(:,:,1)
+         ELSE IF( srcv(jpr_qnsmix)%laction ) THEN   ;   zqns(:,:) = frcv(jpr_qnsmix)%z3(:,:,1)
+         ELSE                                       ;   zqns(:,:) = 0._wp
+         END IF
+         ! update qns over the free ocean with:
+         IF( nn_components /= jp_iam_opa ) THEN
+            zqns(:,:) =  zqns(:,:) - zemp(:,:) * sst_m(:,:) * rcp         ! remove heat content due to mass flux (assumed to be at SST)
+            IF( srcv(jpr_snow  )%laction ) THEN
+               zqns(:,:) = zqns(:,:) - frcv(jpr_snow)%z3(:,:,1) * lfus    ! energy for melting solid precipitation over the free ocean
+            ENDIF
+         ENDIF
+         !
+         IF( srcv(jpr_icb)%laction )  zqns(:,:) = zqns(:,:) - frcv(jpr_icb)%z3(:,:,1) * lfus ! remove heat content associated to iceberg melting
+         !
+         IF( ln_mixcpl ) THEN   ;   qns(:,:) = qns(:,:) * xcplmask(:,:,0) + zqns(:,:) * zmsk(:,:)
+         ELSE                   ;   qns(:,:) =                              zqns(:,:)
+         ENDIF
+
+         !                                                       ! solar flux over the ocean          (qsr)
+         IF     ( srcv(jpr_qsroce)%laction ) THEN   ;   zqsr(:,:) = frcv(jpr_qsroce)%z3(:,:,1)
+         ELSE IF( srcv(jpr_qsrmix)%laction ) then   ;   zqsr(:,:) = frcv(jpr_qsrmix)%z3(:,:,1)
+         ELSE                                       ;   zqsr(:,:) = 0._wp
+         ENDIF
+         IF( ln_dm2dc .AND. ln_cpl )   zqsr(:,:) = sbc_dcy( zqsr )   ! modify qsr to include the diurnal cycle
+         IF( ln_mixcpl ) THEN   ;   qsr(:,:) = qsr(:,:) * xcplmask(:,:,0) + zqsr(:,:) * zmsk(:,:)
+         ELSE                   ;   qsr(:,:) =                              zqsr(:,:)
+         ENDIF
+         !
+         ! salt flux over the ocean (received by opa in case of opa <-> sas coupling)
+         IF( srcv(jpr_sflx )%laction )   sfx(:,:) = frcv(jpr_sflx  )%z3(:,:,1)
+         ! Ice cover  (received by opa in case of opa <-> sas coupling)
+         IF( srcv(jpr_fice )%laction )   fr_i(:,:) = frcv(jpr_fice )%z3(:,:,1)
+         !
+
+      ENDIF
+      !
+      CALL wrk_dealloc( jpi,jpj, ztx, zty, zmsk, zemp, zqns, zqsr )
+      !
+      IF( nn_timing == 1 )  CALL timing_stop('sbc_cpl_rcv')
+      !
+   END SUBROUTINE sbc_cpl_rcv
+   
+
+   SUBROUTINE sbc_cpl_ice_tau( p_taui, p_tauj )     
+      !!----------------------------------------------------------------------
+      !!             ***  ROUTINE sbc_cpl_ice_tau  ***
+      !!
+      !! ** Purpose :   provide the stress over sea-ice in coupled mode 
+      !!
+      !! ** Method  :   transform the received stress from the atmosphere into
+      !!             an atmosphere-ice stress in the (i,j) ocean referencial
+      !!             and at the velocity point of the sea-ice model (cp_ice_msh):
+      !!                'C'-grid : i- (j-) components given at U- (V-) point 
+      !!                'I'-grid : B-grid lower-left corner: both components given at I-point 
+      !!
+      !!                The received stress are :
+      !!                 - defined by 3 components (if cartesian coordinate)
+      !!                        or by 2 components (if spherical)
+      !!                 - oriented along geographical   coordinate (if eastward-northward)
+      !!                        or  along the local grid coordinate (if local grid)
+      !!                 - given at U- and V-point, resp.   if received on 2 grids
+      !!                        or at a same point (T or I) if received on 1 grid
+      !!                Therefore and if necessary, they are successively 
+      !!             processed in order to obtain them 
+      !!                 first  as  2 components on the sphere 
+      !!                 second as  2 components oriented along the local grid
+      !!                 third  as  2 components on the cp_ice_msh point 
+      !!
+      !!                Except in 'oce and ice' case, only one vector stress field 
+      !!             is received. It has already been processed in sbc_cpl_rcv
+      !!             so that it is now defined as (i,j) components given at U-
+      !!             and V-points, respectively. Therefore, only the third
+      !!             transformation is done and only if the ice-grid is a 'I'-grid. 
+      !!
+      !! ** Action  :   return ptau_i, ptau_j, the stress over the ice at cp_ice_msh point
+      !!----------------------------------------------------------------------
+      REAL(wp), INTENT(out), DIMENSION(:,:) ::   p_taui   ! i- & j-components of atmos-ice stress [N/m2]
+      REAL(wp), INTENT(out), DIMENSION(:,:) ::   p_tauj   ! at I-point (B-grid) or U & V-point (C-grid)
+      !!
+      INTEGER ::   ji, jj                          ! dummy loop indices
+      INTEGER ::   itx                             ! index of taux over ice
+      REAL(wp), POINTER, DIMENSION(:,:) ::   ztx, zty 
+      !!----------------------------------------------------------------------
+      !
+      IF( nn_timing == 1 )  CALL timing_start('sbc_cpl_ice_tau')
+      !
+      CALL wrk_alloc( jpi,jpj, ztx, zty )
+
+      IF( srcv(jpr_itx1)%laction ) THEN   ;   itx =  jpr_itx1   
+      ELSE                                ;   itx =  jpr_otx1
+      ENDIF
+
+      ! do something only if we just received the stress from atmosphere
+      IF(  nrcvinfo(itx) == OASIS_Rcv ) THEN
+
+         !                                                      ! ======================= !
+         IF( srcv(jpr_itx1)%laction ) THEN                      !   ice stress received   !
+            !                                                   ! ======================= !
+            !  
+            IF( TRIM( sn_rcv_tau%clvref ) == 'cartesian' ) THEN            ! 2 components on the sphere
+               !                                                       ! (cartesian to spherical -> 3 to 2 components)
+               CALL geo2oce(  frcv(jpr_itx1)%z3(:,:,1), frcv(jpr_ity1)%z3(:,:,1), frcv(jpr_itz1)%z3(:,:,1),   &
+                  &          srcv(jpr_itx1)%clgrid, ztx, zty )
+               frcv(jpr_itx1)%z3(:,:,1) = ztx(:,:)   ! overwrite 1st comp. on the 1st grid
+               frcv(jpr_ity1)%z3(:,:,1) = zty(:,:)   ! overwrite 2nd comp. on the 1st grid
+               !
+               IF( srcv(jpr_itx2)%laction ) THEN
+                  CALL geo2oce( frcv(jpr_itx2)%z3(:,:,1), frcv(jpr_ity2)%z3(:,:,1), frcv(jpr_itz2)%z3(:,:,1),   &
+                     &          srcv(jpr_itx2)%clgrid, ztx, zty )
+                  frcv(jpr_itx2)%z3(:,:,1) = ztx(:,:)   ! overwrite 1st comp. on the 2nd grid
+                  frcv(jpr_ity2)%z3(:,:,1) = zty(:,:)   ! overwrite 2nd comp. on the 2nd grid
+               ENDIF
+               !
+            ENDIF
+            !
+            IF( TRIM( sn_rcv_tau%clvor ) == 'eastward-northward' ) THEN   ! 2 components oriented along the local grid
+               !                                                       ! (geographical to local grid -> rotate the components)
+               CALL rot_rep( frcv(jpr_itx1)%z3(:,:,1), frcv(jpr_ity1)%z3(:,:,1), srcv(jpr_itx1)%clgrid, 'en->i', ztx )   
+               IF( srcv(jpr_itx2)%laction ) THEN
+                  CALL rot_rep( frcv(jpr_itx2)%z3(:,:,1), frcv(jpr_ity2)%z3(:,:,1), srcv(jpr_itx2)%clgrid, 'en->j', zty )   
+               ELSE
+                  CALL rot_rep( frcv(jpr_itx1)%z3(:,:,1), frcv(jpr_ity1)%z3(:,:,1), srcv(jpr_itx1)%clgrid, 'en->j', zty )  
+               ENDIF
+               frcv(jpr_itx1)%z3(:,:,1) = ztx(:,:)      ! overwrite 1st component on the 1st grid
+               frcv(jpr_ity1)%z3(:,:,1) = zty(:,:)      ! overwrite 2nd component on the 1st grid
+            ENDIF
+            !                                                   ! ======================= !
+         ELSE                                                   !     use ocean stress    !
+            !                                                   ! ======================= !
+            frcv(jpr_itx1)%z3(:,:,1) = frcv(jpr_otx1)%z3(:,:,1)
+            frcv(jpr_ity1)%z3(:,:,1) = frcv(jpr_oty1)%z3(:,:,1)
+            !
+         ENDIF
+         !                                                      ! ======================= !
+         !                                                      !     put on ice grid     !
+         !                                                      ! ======================= !
+         !    
+         !                                                  j+1   j     -----V---F
+         ! ice stress on ice velocity point (cp_ice_msh)                 !       |
+         ! (C-grid ==>(U,V) or B-grid ==> I or F)                 j      |   T   U
+         !                                                               |       |
+         !                                                   j    j-1   -I-------|
+         !                                               (for I)         |       |
+         !                                                              i-1  i   i
+         !                                                               i      i+1 (for I)
+         SELECT CASE ( cp_ice_msh )
+            !
+         CASE( 'I' )                                         ! B-grid ==> I
+            SELECT CASE ( srcv(jpr_itx1)%clgrid )
+            CASE( 'U' )
+               DO jj = 2, jpjm1                                   ! (U,V) ==> I
+                  DO ji = 2, jpim1   ! NO vector opt.
+                     p_taui(ji,jj) = 0.5 * ( frcv(jpr_itx1)%z3(ji-1,jj  ,1) + frcv(jpr_itx1)%z3(ji-1,jj-1,1) )
+                     p_tauj(ji,jj) = 0.5 * ( frcv(jpr_ity1)%z3(ji  ,jj-1,1) + frcv(jpr_ity1)%z3(ji-1,jj-1,1) )
+                  END DO
+               END DO
+            CASE( 'F' )
+               DO jj = 2, jpjm1                                   ! F ==> I
+                  DO ji = 2, jpim1   ! NO vector opt.
+                     p_taui(ji,jj) = frcv(jpr_itx1)%z3(ji-1,jj-1,1)
+                     p_tauj(ji,jj) = frcv(jpr_ity1)%z3(ji-1,jj-1,1)
+                  END DO
+               END DO
+            CASE( 'T' )
+               DO jj = 2, jpjm1                                   ! T ==> I
+                  DO ji = 2, jpim1   ! NO vector opt.
+                     p_taui(ji,jj) = 0.25 * ( frcv(jpr_itx1)%z3(ji,jj  ,1) + frcv(jpr_itx1)%z3(ji-1,jj  ,1)   &
+                        &                   + frcv(jpr_itx1)%z3(ji,jj-1,1) + frcv(jpr_itx1)%z3(ji-1,jj-1,1) ) 
+                     p_tauj(ji,jj) = 0.25 * ( frcv(jpr_ity1)%z3(ji,jj  ,1) + frcv(jpr_ity1)%z3(ji-1,jj  ,1)   &
+                        &                   + frcv(jpr_ity1)%z3(ji,jj-1,1) + frcv(jpr_ity1)%z3(ji-1,jj-1,1) )
+                  END DO
+               END DO
+            CASE( 'I' )
+               p_taui(:,:) = frcv(jpr_itx1)%z3(:,:,1)                   ! I ==> I
+               p_tauj(:,:) = frcv(jpr_ity1)%z3(:,:,1)
+            END SELECT
+            IF( srcv(jpr_itx1)%clgrid /= 'I' ) THEN 
+               CALL lbc_lnk( p_taui, 'I',  -1. )   ;   CALL lbc_lnk( p_tauj, 'I',  -1. )
+            ENDIF
+            !
+         CASE( 'F' )                                         ! B-grid ==> F
+            SELECT CASE ( srcv(jpr_itx1)%clgrid )
+            CASE( 'U' )
+               DO jj = 2, jpjm1                                   ! (U,V) ==> F
+                  DO ji = fs_2, fs_jpim1   ! vector opt.
+                     p_taui(ji,jj) = 0.5 * ( frcv(jpr_itx1)%z3(ji,jj,1) + frcv(jpr_itx1)%z3(ji  ,jj+1,1) )
+                     p_tauj(ji,jj) = 0.5 * ( frcv(jpr_ity1)%z3(ji,jj,1) + frcv(jpr_ity1)%z3(ji+1,jj  ,1) )
+                  END DO
+               END DO
+            CASE( 'I' )
+               DO jj = 2, jpjm1                                   ! I ==> F
+                  DO ji = 2, jpim1   ! NO vector opt.
+                     p_taui(ji,jj) = frcv(jpr_itx1)%z3(ji+1,jj+1,1)
+                     p_tauj(ji,jj) = frcv(jpr_ity1)%z3(ji+1,jj+1,1)
+                  END DO
+               END DO
+            CASE( 'T' )
+               DO jj = 2, jpjm1                                   ! T ==> F
+                  DO ji = 2, jpim1   ! NO vector opt.
+                     p_taui(ji,jj) = 0.25 * ( frcv(jpr_itx1)%z3(ji,jj  ,1) + frcv(jpr_itx1)%z3(ji+1,jj  ,1)   &
+                        &                   + frcv(jpr_itx1)%z3(ji,jj+1,1) + frcv(jpr_itx1)%z3(ji+1,jj+1,1) ) 
+                     p_tauj(ji,jj) = 0.25 * ( frcv(jpr_ity1)%z3(ji,jj  ,1) + frcv(jpr_ity1)%z3(ji+1,jj  ,1)   &
+                        &                   + frcv(jpr_ity1)%z3(ji,jj+1,1) + frcv(jpr_ity1)%z3(ji+1,jj+1,1) )
+                  END DO
+               END DO
+            CASE( 'F' )
+               p_taui(:,:) = frcv(jpr_itx1)%z3(:,:,1)                   ! F ==> F
+               p_tauj(:,:) = frcv(jpr_ity1)%z3(:,:,1)
+            END SELECT
+            IF( srcv(jpr_itx1)%clgrid /= 'F' ) THEN 
+               CALL lbc_lnk( p_taui, 'F',  -1. )   ;   CALL lbc_lnk( p_tauj, 'F',  -1. )
+            ENDIF
+            !
+         CASE( 'C' )                                         ! C-grid ==> U,V
+            SELECT CASE ( srcv(jpr_itx1)%clgrid )
+            CASE( 'U' )
+               p_taui(:,:) = frcv(jpr_itx1)%z3(:,:,1)                   ! (U,V) ==> (U,V)
+               p_tauj(:,:) = frcv(jpr_ity1)%z3(:,:,1)
+            CASE( 'F' )
+               DO jj = 2, jpjm1                                   ! F ==> (U,V)
+                  DO ji = fs_2, fs_jpim1   ! vector opt.
+                     p_taui(ji,jj) = 0.5 * ( frcv(jpr_itx1)%z3(ji,jj,1) + frcv(jpr_itx1)%z3(ji  ,jj-1,1) )
+                     p_tauj(ji,jj) = 0.5 * ( frcv(jpr_ity1)%z3(jj,jj,1) + frcv(jpr_ity1)%z3(ji-1,jj  ,1) )
+                  END DO
+               END DO
+            CASE( 'T' )
+               DO jj = 2, jpjm1                                   ! T ==> (U,V)
+                  DO ji = fs_2, fs_jpim1   ! vector opt.
+                     p_taui(ji,jj) = 0.5 * ( frcv(jpr_itx1)%z3(ji+1,jj  ,1) + frcv(jpr_itx1)%z3(ji,jj,1) )
+                     p_tauj(ji,jj) = 0.5 * ( frcv(jpr_ity1)%z3(ji  ,jj+1,1) + frcv(jpr_ity1)%z3(ji,jj,1) )
+                  END DO
+               END DO
+            CASE( 'I' )
+               DO jj = 2, jpjm1                                   ! I ==> (U,V)
+                  DO ji = 2, jpim1   ! NO vector opt.
+                     p_taui(ji,jj) = 0.5 * ( frcv(jpr_itx1)%z3(ji+1,jj+1,1) + frcv(jpr_itx1)%z3(ji+1,jj  ,1) )
+                     p_tauj(ji,jj) = 0.5 * ( frcv(jpr_ity1)%z3(ji+1,jj+1,1) + frcv(jpr_ity1)%z3(ji  ,jj+1,1) )
+                  END DO
+               END DO
+            END SELECT
+            IF( srcv(jpr_itx1)%clgrid /= 'U' ) THEN 
+               CALL lbc_lnk( p_taui, 'U',  -1. )   ;   CALL lbc_lnk( p_tauj, 'V',  -1. )
+            ENDIF
+         END SELECT
+
+      ENDIF
+      !   
+      CALL wrk_dealloc( jpi,jpj, ztx, zty )
+      !
+      IF( nn_timing == 1 )  CALL timing_stop('sbc_cpl_ice_tau')
+      !
+   END SUBROUTINE sbc_cpl_ice_tau
+   
+
+   SUBROUTINE sbc_cpl_ice_flx( p_frld, palbi, psst, pist )
+      !!----------------------------------------------------------------------
+      !!             ***  ROUTINE sbc_cpl_ice_flx  ***
+      !!
+      !! ** Purpose :   provide the heat and freshwater fluxes of the ocean-ice system
+      !!
+      !! ** Method  :   transform the fields received from the atmosphere into
+      !!             surface heat and fresh water boundary condition for the 
+      !!             ice-ocean system. The following fields are provided:
+      !!               * total non solar, solar and freshwater fluxes (qns_tot, 
+      !!             qsr_tot and emp_tot) (total means weighted ice-ocean flux)
+      !!             NB: emp_tot include runoffs and calving.
+      !!               * fluxes over ice (qns_ice, qsr_ice, emp_ice) where
+      !!             emp_ice = sublimation - solid precipitation as liquid
+      !!             precipitation are re-routed directly to the ocean and 
+      !!             calving directly enter the ocean (runoffs are read but included in trasbc.F90)
+      !!               * solid precipitation (sprecip), used to add to qns_tot 
+      !!             the heat lost associated to melting solid precipitation
+      !!             over the ocean fraction.
+      !!               * heat content of rain, snow and evap can also be provided,
+      !!             otherwise heat flux associated with these mass flux are
+      !!             guessed (qemp_oce, qemp_ice)
+      !!
+      !!             - the fluxes have been separated from the stress as
+      !!               (a) they are updated at each ice time step compare to
+      !!               an update at each coupled time step for the stress, and
+      !!               (b) the conservative computation of the fluxes over the
+      !!               sea-ice area requires the knowledge of the ice fraction
+      !!               after the ice advection and before the ice thermodynamics,
+      !!               so that the stress is updated before the ice dynamics
+      !!               while the fluxes are updated after it.
+      !!
+      !! ** Details
+      !!             qns_tot = pfrld * qns_oce + ( 1 - pfrld ) * qns_ice   => provided
+      !!                     + qemp_oce + qemp_ice                         => recalculated and added up to qns
+      !!
+      !!             qsr_tot = pfrld * qsr_oce + ( 1 - pfrld ) * qsr_ice   => provided
+      !!
+      !!             emp_tot = emp_oce + emp_ice                           => calving is provided and added to emp_tot (and emp_oce).
+      !!                                                                      runoff (which includes rivers+icebergs) and iceshelf
+      !!                                                                      are provided but not included in emp here. Only runoff will
+      !!                                                                      be included in emp in other parts of NEMO code
+      !! ** Action  :   update at each nf_ice time step:
+      !!                   qns_tot, qsr_tot  non-solar and solar total heat fluxes
+      !!                   qns_ice, qsr_ice  non-solar and solar heat fluxes over the ice
+      !!                   emp_tot           total evaporation - precipitation(liquid and solid) (-calving)
+      !!                   emp_ice           ice sublimation - solid precipitation over the ice
+      !!                   dqns_ice          d(non-solar heat flux)/d(Temperature) over the ice
+      !!                   sprecip           solid precipitation over the ocean  
+      !!----------------------------------------------------------------------
+      REAL(wp), INTENT(in   ), DIMENSION(:,:)   ::   p_frld     ! lead fraction                [0 to 1]
+      ! optional arguments, used only in 'mixed oce-ice' case
+      REAL(wp), INTENT(in   ), DIMENSION(:,:,:), OPTIONAL ::   palbi      ! all skies ice albedo 
+      REAL(wp), INTENT(in   ), DIMENSION(:,:  ), OPTIONAL ::   psst       ! sea surface temperature     [Celsius]
+      REAL(wp), INTENT(in   ), DIMENSION(:,:,:), OPTIONAL ::   pist       ! ice surface temperature     [Kelvin]
+      !
+      INTEGER ::   jl         ! dummy loop index
+      REAL(wp), POINTER, DIMENSION(:,:  ) ::   zcptn, zcptrain, zcptsnw, zicefr, zmsk, zsnw
+      REAL(wp), POINTER, DIMENSION(:,:  ) ::   zemp_tot, zemp_ice, zemp_oce, ztprecip, zsprecip, zevap_oce, zevap_ice, zdevap_ice
+      REAL(wp), POINTER, DIMENSION(:,:  ) ::   zqns_tot, zqns_oce, zqsr_tot, zqsr_oce, zqprec_ice, zqemp_oce, zqemp_ice
+      REAL(wp), POINTER, DIMENSION(:,:,:) ::   zqns_ice, zqsr_ice, zdqns_ice, zqevap_ice
+      !!----------------------------------------------------------------------
+      !
+      IF( nn_timing == 1 )  CALL timing_start('sbc_cpl_ice_flx')
+      !
+      CALL wrk_alloc( jpi,jpj,     zcptn, zcptrain, zcptsnw, zicefr, zmsk, zsnw )
+      CALL wrk_alloc( jpi,jpj,     zemp_tot, zemp_ice, zemp_oce, ztprecip, zsprecip, zevap_oce, zevap_ice, zdevap_ice )
+      CALL wrk_alloc( jpi,jpj,     zqns_tot, zqns_oce, zqsr_tot, zqsr_oce, zqprec_ice, zqemp_oce, zqemp_ice )
+      CALL wrk_alloc( jpi,jpj,jpl, zqns_ice, zqsr_ice, zdqns_ice, zqevap_ice )
+
+      IF( ln_mixcpl )   zmsk(:,:) = 1. - xcplmask(:,:,0)
+      zicefr(:,:) = 1.- p_frld(:,:)
+      zcptn(:,:) = rcp * sst_m(:,:)
+      !
+      !                                                      ! ========================= !
+      !                                                      !    freshwater budget      !   (emp_tot)
+      !                                                      ! ========================= !
+      !
+      !                                                           ! solid Precipitation                                (sprecip)
+      !                                                           ! liquid + solid Precipitation                       (tprecip)
+      !                                                           ! total Evaporation - total Precipitation            (emp_tot)
+      !                                                           ! sublimation - solid precipitation (cell average)   (emp_ice)
+      SELECT CASE( TRIM( sn_rcv_emp%cldes ) )
+      CASE( 'conservative' )   ! received fields: jpr_rain, jpr_snow, jpr_ievp, jpr_tevp
+         zsprecip(:,:) =   frcv(jpr_snow)%z3(:,:,1)                  ! May need to ensure positive here
+         ztprecip(:,:) =   frcv(jpr_rain)%z3(:,:,1) + zsprecip(:,:)  ! May need to ensure positive here
+         zemp_tot(:,:) =   frcv(jpr_tevp)%z3(:,:,1) - ztprecip(:,:)
+         zemp_ice(:,:) = ( frcv(jpr_ievp)%z3(:,:,1) - frcv(jpr_snow)%z3(:,:,1) ) * zicefr(:,:)
+      CASE( 'oce and ice'   )   ! received fields: jpr_sbpr, jpr_semp, jpr_oemp, jpr_ievp
+         zemp_tot(:,:) = p_frld(:,:) * frcv(jpr_oemp)%z3(:,:,1) + zicefr(:,:) * frcv(jpr_sbpr)%z3(:,:,1)
+         zemp_ice(:,:) = frcv(jpr_semp)%z3(:,:,1) * zicefr(:,:)
+         zsprecip(:,:) = frcv(jpr_ievp)%z3(:,:,1) - frcv(jpr_semp)%z3(:,:,1)
+         ztprecip(:,:) = frcv(jpr_semp)%z3(:,:,1) - frcv(jpr_sbpr)%z3(:,:,1) + zsprecip(:,:)
+      END SELECT
+
+#if defined key_lim3
+      ! zsnw = snow fraction over ice after wind blowing (=zicefr if no blowing)
+      zsnw(:,:) = 0._wp  ;  CALL lim_thd_snwblow( p_frld, zsnw )
+      
+      ! --- evaporation minus precipitation corrected (because of wind blowing on snow) --- !
+      zemp_ice(:,:) = zemp_ice(:,:) + zsprecip(:,:) * ( zicefr(:,:) - zsnw(:,:) )  ! emp_ice = A * sublimation - zsnw * sprecip
+      zemp_oce(:,:) = zemp_tot(:,:) - zemp_ice(:,:)                                ! emp_oce = emp_tot - emp_ice
+
+      ! --- evaporation over ocean (used later for qemp) --- !
+      zevap_oce(:,:) = frcv(jpr_tevp)%z3(:,:,1) - frcv(jpr_ievp)%z3(:,:,1) * zicefr(:,:)
+
+      ! --- evaporation over ice (kg/m2/s) --- !
+      zevap_ice(:,:) = frcv(jpr_ievp)%z3(:,:,1)
+      ! since the sensitivity of evap to temperature (devap/dT) is not prescribed by the atmosphere, we set it to 0
+      ! therefore, sublimation is not redistributed over the ice categories when no subgrid scale fluxes are provided by atm.
+      zdevap_ice(:,:) = 0._wp
+      
+      ! --- Continental fluxes --- !
+      IF( srcv(jpr_rnf)%laction ) THEN   ! runoffs (included in emp later on)
+         rnf(:,:) = frcv(jpr_rnf)%z3(:,:,1)
+      ENDIF
+      IF( srcv(jpr_cal)%laction ) THEN   ! calving (put in emp_tot and emp_oce)
+         zemp_tot(:,:) = zemp_tot(:,:) - frcv(jpr_cal)%z3(:,:,1)
+         zemp_oce(:,:) = zemp_oce(:,:) - frcv(jpr_cal)%z3(:,:,1)
+      ENDIF
+      IF( srcv(jpr_icb)%laction ) THEN   ! iceberg added to runoffs
+         fwficb(:,:) = frcv(jpr_icb)%z3(:,:,1)
+         rnf(:,:)    = rnf(:,:) + fwficb(:,:)
+      ENDIF
+      IF( srcv(jpr_isf)%laction ) THEN   ! iceshelf (fwfisf <0 mean melting)
+        fwfisf(:,:) = - frcv(jpr_isf)%z3(:,:,1)  
+      ENDIF
+
+      IF( ln_mixcpl ) THEN
+         emp_tot(:,:) = emp_tot(:,:) * xcplmask(:,:,0) + zemp_tot(:,:) * zmsk(:,:)
+         emp_ice(:,:) = emp_ice(:,:) * xcplmask(:,:,0) + zemp_ice(:,:) * zmsk(:,:)
+         emp_oce(:,:) = emp_oce(:,:) * xcplmask(:,:,0) + zemp_oce(:,:) * zmsk(:,:)
+         sprecip(:,:) = sprecip(:,:) * xcplmask(:,:,0) + zsprecip(:,:) * zmsk(:,:)
+         tprecip(:,:) = tprecip(:,:) * xcplmask(:,:,0) + ztprecip(:,:) * zmsk(:,:)
+         DO jl=1,jpl
+            evap_ice (:,:,jl) = evap_ice (:,:,jl) * xcplmask(:,:,0) + zevap_ice (:,:) * zmsk(:,:)
+            devap_ice(:,:,jl) = devap_ice(:,:,jl) * xcplmask(:,:,0) + zdevap_ice(:,:) * zmsk(:,:)
+         ENDDO
+      ELSE
+         emp_tot(:,:) =         zemp_tot(:,:)
+         emp_ice(:,:) =         zemp_ice(:,:)
+         emp_oce(:,:) =         zemp_oce(:,:)     
+         sprecip(:,:) =         zsprecip(:,:)
+         tprecip(:,:) =         ztprecip(:,:)
+         DO jl=1,jpl
+            evap_ice (:,:,jl) = zevap_ice (:,:)
+            devap_ice(:,:,jl) = zdevap_ice(:,:)
+         ENDDO
+      ENDIF
+
+#else
+      zsnw(:,:) = zicefr(:,:)
+      ! --- Continental fluxes --- !
+      IF( srcv(jpr_rnf)%laction ) THEN   ! runoffs (included in emp later on)
+         rnf(:,:) = frcv(jpr_rnf)%z3(:,:,1)
+      ENDIF
+      IF( srcv(jpr_cal)%laction ) THEN   ! calving (put in emp_tot)
+         zemp_tot(:,:) = zemp_tot(:,:) - frcv(jpr_cal)%z3(:,:,1)
+      ENDIF
+      IF( srcv(jpr_icb)%laction ) THEN   ! iceberg added to runoffs
+         fwficb(:,:) = frcv(jpr_icb)%z3(:,:,1)
+         rnf(:,:)    = rnf(:,:) + fwficb(:,:)
+      ENDIF
+      IF( srcv(jpr_isf)%laction ) THEN   ! iceshelf (fwfisf <0 mean melting)
+        fwfisf(:,:) = - frcv(jpr_isf)%z3(:,:,1)
+      ENDIF
+
+      IF( ln_mixcpl ) THEN
+         emp_tot(:,:) = emp_tot(:,:) * xcplmask(:,:,0) + zemp_tot(:,:) * zmsk(:,:)
+         emp_ice(:,:) = emp_ice(:,:) * xcplmask(:,:,0) + zemp_ice(:,:) * zmsk(:,:)
+         sprecip(:,:) = sprecip(:,:) * xcplmask(:,:,0) + zsprecip(:,:) * zmsk(:,:)
+         tprecip(:,:) = tprecip(:,:) * xcplmask(:,:,0) + ztprecip(:,:) * zmsk(:,:)
+      ELSE
+         emp_tot(:,:) =                                  zemp_tot(:,:)
+         emp_ice(:,:) =                                  zemp_ice(:,:)
+         sprecip(:,:) =                                  zsprecip(:,:)
+         tprecip(:,:) =                                  ztprecip(:,:)
+      ENDIF
+
+#endif
+      ! outputs
+!!      IF( srcv(jpr_rnf)%laction )   CALL iom_put( 'runoffs' , rnf(:,:) * tmask(:,:,1)                                 )  ! runoff
+!!      IF( srcv(jpr_isf)%laction )   CALL iom_put( 'iceshelf_cea', -fwfisf(:,:) * tmask(:,:,1)                         )  ! iceshelf
+      IF( srcv(jpr_cal)%laction )   CALL iom_put( 'calving_cea' , frcv(jpr_cal)%z3(:,:,1) * tmask(:,:,1)                )  ! calving
+      IF( srcv(jpr_icb)%laction )   CALL iom_put( 'iceberg_cea' , frcv(jpr_icb)%z3(:,:,1) * tmask(:,:,1)                )  ! icebergs
+      IF( iom_use('snowpre') )      CALL iom_put( 'snowpre'     , sprecip(:,:)                                          )  ! Snow
+      IF( iom_use('precip') )       CALL iom_put( 'precip'      , tprecip(:,:)                                          )  ! total  precipitation
+      IF( iom_use('rain') )         CALL iom_put( 'rain'        , tprecip(:,:) - sprecip(:,:)                           )  ! liquid precipitation 
+      IF( iom_use('snow_ao_cea') )  CALL iom_put( 'snow_ao_cea' , sprecip(:,:) * ( 1._wp - zsnw(:,:) )                  )  ! Snow over ice-free ocean  (cell average)
+      IF( iom_use('snow_ai_cea') )  CALL iom_put( 'snow_ai_cea' , sprecip(:,:) *           zsnw(:,:)                    )  ! Snow over sea-ice         (cell average)
+      IF( iom_use('rain_ao_cea') )  CALL iom_put( 'rain_ao_cea' , ( tprecip(:,:) - sprecip(:,:) ) * p_frld(:,:)         )  ! liquid precipitation over ocean (cell average)
+      IF( iom_use('subl_ai_cea') )  CALL iom_put( 'subl_ai_cea' , frcv(jpr_ievp)%z3(:,:,1) * zicefr(:,:) * tmask(:,:,1) )  ! Sublimation over sea-ice (cell average)
+      IF( iom_use('evap_ao_cea') )  CALL iom_put( 'evap_ao_cea' , ( frcv(jpr_tevp)%z3(:,:,1)  &
+         &                                                        - frcv(jpr_ievp)%z3(:,:,1) * zicefr(:,:) ) * tmask(:,:,1) )  ! ice-free oce evap (cell average)
+      ! note: runoff output is done in sbcrnf (which includes icebergs too) and iceshelf output is done in sbcisf
+      !
+      !                                                      ! ========================= !
+      SELECT CASE( TRIM( sn_rcv_qns%cldes ) )                !   non solar heat fluxes   !   (qns)
+      !                                                      ! ========================= !
+      CASE( 'oce only' )         ! the required field is directly provided
+         zqns_tot(:,:) = frcv(jpr_qnsoce)%z3(:,:,1)
+      CASE( 'conservative' )     ! the required fields are directly provided
+         zqns_tot(:,:) = frcv(jpr_qnsmix)%z3(:,:,1)
+         IF ( TRIM(sn_rcv_qns%clcat) == 'yes' ) THEN
+            zqns_ice(:,:,1:jpl) = frcv(jpr_qnsice)%z3(:,:,1:jpl)
+         ELSE
+            DO jl=1,jpl
+               zqns_ice(:,:,jl) = frcv(jpr_qnsice)%z3(:,:,1) ! Set all category values equal
+            ENDDO
+         ENDIF
+      CASE( 'oce and ice' )      ! the total flux is computed from ocean and ice fluxes
+         zqns_tot(:,:) =  p_frld(:,:) * frcv(jpr_qnsoce)%z3(:,:,1)
+         IF ( TRIM(sn_rcv_qns%clcat) == 'yes' ) THEN
+            DO jl=1,jpl
+               zqns_tot(:,:   ) = zqns_tot(:,:) + a_i(:,:,jl) * frcv(jpr_qnsice)%z3(:,:,jl)   
+               zqns_ice(:,:,jl) = frcv(jpr_qnsice)%z3(:,:,jl)
+            ENDDO
+         ELSE
+            qns_tot(:,:) = qns_tot(:,:) + zicefr(:,:) * frcv(jpr_qnsice)%z3(:,:,1)
+            DO jl=1,jpl
+               zqns_tot(:,:   ) = zqns_tot(:,:) + zicefr(:,:) * frcv(jpr_qnsice)%z3(:,:,1)
+               zqns_ice(:,:,jl) = frcv(jpr_qnsice)%z3(:,:,1)
+            ENDDO
+         ENDIF
+      CASE( 'mixed oce-ice' )    ! the ice flux is cumputed from the total flux, the SST and ice informations
+! ** NEED TO SORT OUT HOW THIS SHOULD WORK IN THE MULTI-CATEGORY CASE - CURRENTLY NOT ALLOWED WHEN INTERFACE INITIALISED **
+         zqns_tot(:,:  ) = frcv(jpr_qnsmix)%z3(:,:,1)
+         zqns_ice(:,:,1) = frcv(jpr_qnsmix)%z3(:,:,1)    &
+            &            + frcv(jpr_dqnsdt)%z3(:,:,1) * ( pist(:,:,1) - ( (rt0 + psst(:,:  ) ) * p_frld(:,:)   &
+            &                                           + pist(:,:,1) * zicefr(:,:) ) )
+      END SELECT
+      !                                     
+      ! --- calving (removed from qns_tot) --- !
+      IF( srcv(jpr_cal)%laction )   zqns_tot(:,:) = zqns_tot(:,:) - frcv(jpr_cal)%z3(:,:,1) * lfus  ! remove latent heat of calving
+                                                                                                    ! we suppose it melts at 0deg, though it should be temp. of surrounding ocean
+      ! --- iceberg (removed from qns_tot) --- !
+      IF( srcv(jpr_icb)%laction )   zqns_tot(:,:) = zqns_tot(:,:) - frcv(jpr_icb)%z3(:,:,1) * lfus  ! remove latent heat of iceberg melting
+
+#if defined key_lim3      
+      ! --- non solar flux over ocean --- !
+      !         note: p_frld cannot be = 0 since we limit the ice concentration to amax
+      zqns_oce = 0._wp
+      WHERE( p_frld /= 0._wp )  zqns_oce(:,:) = ( zqns_tot(:,:) - SUM( a_i * zqns_ice, dim=3 ) ) / p_frld(:,:)
+
+      ! Heat content per unit mass of snow (J/kg)
+      WHERE( SUM( a_i, dim=3 ) > 1.e-10 )   ;   zcptsnw(:,:) = cpic * SUM( (tn_ice - rt0) * a_i, dim=3 ) / SUM( a_i, dim=3 )
+      ELSEWHERE                             ;   zcptsnw(:,:) = zcptn(:,:)
+      ENDWHERE
+      ! Heat content per unit mass of rain (J/kg)
+      zcptrain(:,:) = rcp * ( SUM( (tn_ice(:,:,:) - rt0) * a_i(:,:,:), dim=3 ) + sst_m(:,:) * p_frld(:,:) ) 
+
+      ! --- enthalpy of snow precip over ice in J/m3 (to be used in 1D-thermo) --- !
+      zqprec_ice(:,:) = rhosn * ( zcptsnw(:,:) - lfus )
+
+      ! --- heat content of evap over ice in W/m2 (to be used in 1D-thermo) --- !
+      DO jl = 1, jpl
+         zqevap_ice(:,:,jl) = 0._wp ! should be -evap * ( ( Tice - rt0 ) * cpic ) but atm. does not take it into account
+      END DO
+
+      ! --- heat flux associated with emp (W/m2) --- !
+      zqemp_oce(:,:) = -  zevap_oce(:,:)                                      *   zcptn   (:,:)   &        ! evap
+         &             + ( ztprecip(:,:) - zsprecip(:,:) )                    *   zcptrain(:,:)   &        ! liquid precip
+         &             +   zsprecip(:,:)                   * ( 1._wp - zsnw ) * ( zcptsnw (:,:) - lfus )   ! solid precip over ocean + snow melting
+      zqemp_ice(:,:) =     zsprecip(:,:)                   * zsnw             * ( zcptsnw (:,:) - lfus )   ! solid precip over ice (qevap_ice=0 since atm. does not take it into account)
+!!    zqemp_ice(:,:) = -   frcv(jpr_ievp)%z3(:,:,1)        * zicefr(:,:)      *   zcptsnw (:,:)   &        ! ice evap
+!!       &             +   zsprecip(:,:)                   * zsnw             * zqprec_ice(:,:) * r1_rhosn ! solid precip over ice
+      
+      ! --- total non solar flux (including evap/precip) --- !
+      zqns_tot(:,:) = zqns_tot(:,:) + zqemp_ice(:,:) + zqemp_oce(:,:)
+
+      ! --- in case both coupled/forced are active, we must mix values --- ! 
+      IF( ln_mixcpl ) THEN
+         qns_tot(:,:) = qns_tot(:,:) * xcplmask(:,:,0) + zqns_tot(:,:)* zmsk(:,:)
+         qns_oce(:,:) = qns_oce(:,:) * xcplmask(:,:,0) + zqns_oce(:,:)* zmsk(:,:)
+         DO jl=1,jpl
+            qns_ice  (:,:,jl) = qns_ice  (:,:,jl) * xcplmask(:,:,0) +  zqns_ice  (:,:,jl)* zmsk(:,:)
+            qevap_ice(:,:,jl) = qevap_ice(:,:,jl) * xcplmask(:,:,0) +  zqevap_ice(:,:,jl)* zmsk(:,:)
+         ENDDO
+         qprec_ice(:,:) = qprec_ice(:,:) * xcplmask(:,:,0) + zqprec_ice(:,:)* zmsk(:,:)
+         qemp_oce (:,:) =  qemp_oce(:,:) * xcplmask(:,:,0) +  zqemp_oce(:,:)* zmsk(:,:)
+         qemp_ice (:,:) =  qemp_ice(:,:) * xcplmask(:,:,0) +  zqemp_ice(:,:)* zmsk(:,:)
+      ELSE
+         qns_tot  (:,:  ) = zqns_tot  (:,:  )
+         qns_oce  (:,:  ) = zqns_oce  (:,:  )
+         qns_ice  (:,:,:) = zqns_ice  (:,:,:)
+         qevap_ice(:,:,:) = zqevap_ice(:,:,:)
+         qprec_ice(:,:  ) = zqprec_ice(:,:  )
+         qemp_oce (:,:  ) = zqemp_oce (:,:  )
+         qemp_ice (:,:  ) = zqemp_ice (:,:  )
+      ENDIF
+
+#else
+      zcptsnw (:,:) = zcptn(:,:)
+      zcptrain(:,:) = zcptn(:,:)
+      
+      ! clem: this formulation is certainly wrong... but better than it was...
+      zqns_tot(:,:) = zqns_tot(:,:)                            &          ! zqns_tot update over free ocean with:
+         &          - (  p_frld(:,:) * zsprecip(:,:) * lfus )  &          ! remove the latent heat flux of solid precip. melting
+         &          - (  zemp_tot(:,:)                         &          ! remove the heat content of mass flux (assumed to be at SST)
+         &             - zemp_ice(:,:) ) * zcptn(:,:) 
+
+     IF( ln_mixcpl ) THEN
+         qns_tot(:,:) = qns(:,:) * p_frld(:,:) + SUM( qns_ice(:,:,:) * a_i(:,:,:), dim=3 )   ! total flux from blk
+         qns_tot(:,:) = qns_tot(:,:) * xcplmask(:,:,0) +  zqns_tot(:,:)* zmsk(:,:)
+         DO jl=1,jpl
+            qns_ice(:,:,jl) = qns_ice(:,:,jl) * xcplmask(:,:,0) +  zqns_ice(:,:,jl)* zmsk(:,:)
+         ENDDO
+      ELSE
+         qns_tot(:,:  ) = zqns_tot(:,:  )
+         qns_ice(:,:,:) = zqns_ice(:,:,:)
+      ENDIF
+
+#endif
+      ! outputs
+      IF( srcv(jpr_cal)%laction )    CALL iom_put('hflx_cal_cea' , - frcv(jpr_cal)%z3(:,:,1) * lfus                               ) ! latent heat from calving
+      IF( srcv(jpr_icb)%laction )    CALL iom_put('hflx_icb_cea' , - frcv(jpr_icb)%z3(:,:,1) * lfus                               ) ! latent heat from icebergs melting
+      IF( iom_use('hflx_snow_cea') ) CALL iom_put('hflx_snow_cea',  sprecip(:,:) * ( zcptsnw(:,:) - Lfus )                        ) ! heat flux from snow (cell average)
+      IF( iom_use('hflx_rain_cea') ) CALL iom_put('hflx_rain_cea',( tprecip(:,:) - sprecip(:,:) ) * zcptrain(:,:)                 ) ! heat flux from rain (cell average)
+      IF( iom_use('hflx_evap_cea') ) CALL iom_put('hflx_evap_cea',(frcv(jpr_tevp)%z3(:,:,1)-frcv(jpr_ievp)%z3(:,:,1)*zicefr(:,:)) & ! heat flux from from evap (cell average)
+         &                                                        * zcptn(:,:) * tmask(:,:,1) )
+      IF( iom_use('hflx_prec_cea') ) CALL iom_put('hflx_prec_cea',   sprecip(:,:) * ( zcptsnw(:,:) - Lfus ) +  &                    ! heat flux from all precip (cell avg)
+         &                                                         ( tprecip(:,:) - sprecip(:,:) ) * zcptrain(:,:)                )
+      IF( iom_use('hflx_snow_ao_cea') ) CALL iom_put('hflx_snow_ao_cea',sprecip(:,:) * (zcptsnw(:,:) - Lfus) * (1._wp - zsnw(:,:))) ! heat flux from snow (over ocean)
+      IF( iom_use('hflx_snow_ai_cea') ) CALL iom_put('hflx_snow_ai_cea',sprecip(:,:) * (zcptsnw(:,:) - Lfus) *          zsnw(:,:) ) ! heat flux from snow (over ice)
+      ! note: hflx for runoff and iceshelf are done in sbcrnf and sbcisf resp.
+      !
+      !                                                      ! ========================= !
+      SELECT CASE( TRIM( sn_rcv_qsr%cldes ) )                !      solar heat fluxes    !   (qsr)
+      !                                                      ! ========================= !
+      CASE( 'oce only' )
+         zqsr_tot(:,:  ) = MAX( 0._wp , frcv(jpr_qsroce)%z3(:,:,1) )
+      CASE( 'conservative' )
+         zqsr_tot(:,:  ) = frcv(jpr_qsrmix)%z3(:,:,1)
+         IF ( TRIM(sn_rcv_qsr%clcat) == 'yes' ) THEN
+            zqsr_ice(:,:,1:jpl) = frcv(jpr_qsrice)%z3(:,:,1:jpl)
+         ELSE
+            ! Set all category values equal for the moment
+            DO jl=1,jpl
+               zqsr_ice(:,:,jl) = frcv(jpr_qsrice)%z3(:,:,1)
+            ENDDO
+         ENDIF
+         zqsr_tot(:,:  ) = frcv(jpr_qsrmix)%z3(:,:,1)
+         zqsr_ice(:,:,1) = frcv(jpr_qsrice)%z3(:,:,1)
+      CASE( 'oce and ice' )
+         zqsr_tot(:,:  ) =  p_frld(:,:) * frcv(jpr_qsroce)%z3(:,:,1)
+         IF ( TRIM(sn_rcv_qsr%clcat) == 'yes' ) THEN
+            DO jl=1,jpl
+               zqsr_tot(:,:   ) = zqsr_tot(:,:) + a_i(:,:,jl) * frcv(jpr_qsrice)%z3(:,:,jl)   
+               zqsr_ice(:,:,jl) = frcv(jpr_qsrice)%z3(:,:,jl)
+            ENDDO
+         ELSE
+            qsr_tot(:,:   ) = qsr_tot(:,:) + zicefr(:,:) * frcv(jpr_qsrice)%z3(:,:,1)
+            DO jl=1,jpl
+               zqsr_tot(:,:   ) = zqsr_tot(:,:) + zicefr(:,:) * frcv(jpr_qsrice)%z3(:,:,1)
+               zqsr_ice(:,:,jl) = frcv(jpr_qsrice)%z3(:,:,1)
+            ENDDO
+         ENDIF
+      CASE( 'mixed oce-ice' )
+         zqsr_tot(:,:  ) = frcv(jpr_qsrmix)%z3(:,:,1)
+! ** NEED TO SORT OUT HOW THIS SHOULD WORK IN THE MULTI-CATEGORY CASE - CURRENTLY NOT ALLOWED WHEN INTERFACE INITIALISED **
+!       Create solar heat flux over ice using incoming solar heat flux and albedos
+!       ( see OASIS3 user guide, 5th edition, p39 )
+         zqsr_ice(:,:,1) = frcv(jpr_qsrmix)%z3(:,:,1) * ( 1.- palbi(:,:,1) )   &
+            &            / (  1.- ( albedo_oce_mix(:,:  ) * p_frld(:,:)       &
+            &                     + palbi         (:,:,1) * zicefr(:,:) ) )
+      END SELECT
+      IF( ln_dm2dc .AND. ln_cpl ) THEN   ! modify qsr to include the diurnal cycle
+         zqsr_tot(:,:  ) = sbc_dcy( zqsr_tot(:,:  ) )
+         DO jl=1,jpl
+            zqsr_ice(:,:,jl) = sbc_dcy( zqsr_ice(:,:,jl) )
+         ENDDO
+      ENDIF
+
+#if defined key_lim3
+      ! --- solar flux over ocean --- !
+      !         note: p_frld cannot be = 0 since we limit the ice concentration to amax
+      zqsr_oce = 0._wp
+      WHERE( p_frld /= 0._wp )  zqsr_oce(:,:) = ( zqsr_tot(:,:) - SUM( a_i * zqsr_ice, dim=3 ) ) / p_frld(:,:)
+
+      IF( ln_mixcpl ) THEN   ;   qsr_oce(:,:) = qsr_oce(:,:) * xcplmask(:,:,0) +  zqsr_oce(:,:)* zmsk(:,:)
+      ELSE                   ;   qsr_oce(:,:) = zqsr_oce(:,:)   ;   ENDIF
+#endif
+
+      IF( ln_mixcpl ) THEN
+         qsr_tot(:,:) = qsr(:,:) * p_frld(:,:) + SUM( qsr_ice(:,:,:) * a_i(:,:,:), dim=3 )   ! total flux from blk
+         qsr_tot(:,:) = qsr_tot(:,:) * xcplmask(:,:,0) +  zqsr_tot(:,:)* zmsk(:,:)
+         DO jl=1,jpl
+            qsr_ice(:,:,jl) = qsr_ice(:,:,jl) * xcplmask(:,:,0) +  zqsr_ice(:,:,jl)* zmsk(:,:)
+         ENDDO
+      ELSE
+         qsr_tot(:,:  ) = zqsr_tot(:,:  )
+         qsr_ice(:,:,:) = zqsr_ice(:,:,:)
+      ENDIF
+
+      !                                                      ! ========================= !
+      SELECT CASE( TRIM( sn_rcv_dqnsdt%cldes ) )             !          d(qns)/dt        !
+      !                                                      ! ========================= !
+      CASE ('coupled')
+         IF ( TRIM(sn_rcv_dqnsdt%clcat) == 'yes' ) THEN
+            zdqns_ice(:,:,1:jpl) = frcv(jpr_dqnsdt)%z3(:,:,1:jpl)
+         ELSE
+            ! Set all category values equal for the moment
+            DO jl=1,jpl
+               zdqns_ice(:,:,jl) = frcv(jpr_dqnsdt)%z3(:,:,1)
+            ENDDO
+         ENDIF
+      END SELECT
+      
+      IF( ln_mixcpl ) THEN
+         DO jl=1,jpl
+            dqns_ice(:,:,jl) = dqns_ice(:,:,jl) * xcplmask(:,:,0) + zdqns_ice(:,:,jl) * zmsk(:,:)
+         ENDDO
+      ELSE
+         dqns_ice(:,:,:) = zdqns_ice(:,:,:)
+      ENDIF
+      
+      !                                                      ! ========================= !
+      SELECT CASE( TRIM( sn_rcv_iceflx%cldes ) )             !    topmelt and botmelt    !
+      !                                                      ! ========================= !
+      CASE ('coupled')
+         topmelt(:,:,:)=frcv(jpr_topm)%z3(:,:,:)
+         botmelt(:,:,:)=frcv(jpr_botm)%z3(:,:,:)
+      END SELECT
+
+      ! Surface transimission parameter io (Maykut Untersteiner , 1971 ; Ebert and Curry, 1993 )
+      ! Used for LIM2 and LIM3
+      ! Coupled case: since cloud cover is not received from atmosphere 
+      !               ===> used prescribed cloud fraction representative for polar oceans in summer (0.81)
+      fr1_i0(:,:) = ( 0.18 * ( 1.0 - cldf_ice ) + 0.35 * cldf_ice )
+      fr2_i0(:,:) = ( 0.82 * ( 1.0 - cldf_ice ) + 0.65 * cldf_ice )
+
+      CALL wrk_dealloc( jpi,jpj,     zcptn, zcptrain, zcptsnw, zicefr, zmsk, zsnw )
+      CALL wrk_dealloc( jpi,jpj,     zemp_tot, zemp_ice, zemp_oce, ztprecip, zsprecip, zevap_oce, zevap_ice, zdevap_ice )
+      CALL wrk_dealloc( jpi,jpj,     zqns_tot, zqns_oce, zqsr_tot, zqsr_oce, zqprec_ice, zqemp_oce, zqemp_ice )
+      CALL wrk_dealloc( jpi,jpj,jpl, zqns_ice, zqsr_ice, zdqns_ice, zqevap_ice )
+      !
+      IF( nn_timing == 1 )  CALL timing_stop('sbc_cpl_ice_flx')
+      !
+   END SUBROUTINE sbc_cpl_ice_flx
+   
+   
+   SUBROUTINE sbc_cpl_snd( kt )
+      !!----------------------------------------------------------------------
+      !!             ***  ROUTINE sbc_cpl_snd  ***
+      !!
+      !! ** Purpose :   provide the ocean-ice informations to the atmosphere
+      !!
+      !! ** Method  :   send to the atmosphere through a call to cpl_snd
+      !!              all the needed fields (as defined in sbc_cpl_init)
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT(in) ::   kt
+      !
+      INTEGER ::   ji, jj, jl   ! dummy loop indices
+      INTEGER ::   isec, info   ! local integer
+      REAL(wp) ::   zumax, zvmax
+      REAL(wp), POINTER, DIMENSION(:,:)   ::   zfr_l, ztmp1, ztmp2, zotx1, zoty1, zotz1, zitx1, zity1, zitz1
+      REAL(wp), POINTER, DIMENSION(:,:,:) ::   ztmp3, ztmp4   
+      !!----------------------------------------------------------------------
+      !
+      IF( nn_timing == 1 )  CALL timing_start('sbc_cpl_snd')
+      !
+      CALL wrk_alloc( jpi,jpj, zfr_l, ztmp1, ztmp2, zotx1, zoty1, zotz1, zitx1, zity1, zitz1 )
+      CALL wrk_alloc( jpi,jpj,jpl, ztmp3, ztmp4 )
+
+      isec = ( kt - nit000 ) * NINT(rdttra(1))        ! date of exchanges
+
+      zfr_l(:,:) = 1.- fr_i(:,:)
+      !                                                      ! ------------------------- !
+      !                                                      !    Surface temperature    !   in Kelvin
+      !                                                      ! ------------------------- !
+      IF( ssnd(jps_toce)%laction .OR. ssnd(jps_tice)%laction .OR. ssnd(jps_tmix)%laction ) THEN
+         
+         IF ( nn_components == jp_iam_opa ) THEN
+            ztmp1(:,:) = tsn(:,:,1,jp_tem)   ! send temperature as it is (potential or conservative) -> use of ln_useCT on the received part
+         ELSE
+            ! we must send the surface potential temperature 
+            IF( ln_useCT )  THEN    ;   ztmp1(:,:) = eos_pt_from_ct( tsn(:,:,1,jp_tem), tsn(:,:,1,jp_sal) )
+            ELSE                    ;   ztmp1(:,:) = tsn(:,:,1,jp_tem)
+            ENDIF
+            !
+            SELECT CASE( sn_snd_temp%cldes)
+            CASE( 'oce only'             )   ;   ztmp1(:,:) =   ztmp1(:,:) + rt0
+            CASE( 'oce and ice'          )   ;   ztmp1(:,:) =   ztmp1(:,:) + rt0
+               SELECT CASE( sn_snd_temp%clcat )
+               CASE( 'yes' )   
+                  ztmp3(:,:,1:jpl) = tn_ice(:,:,1:jpl)
+               CASE( 'no' )
+                  WHERE( SUM( a_i, dim=3 ) /= 0. )
+                     ztmp3(:,:,1) = SUM( tn_ice * a_i, dim=3 ) / SUM( a_i, dim=3 )
+                  ELSEWHERE
+                     ztmp3(:,:,1) = rt0
+                  END WHERE
+               CASE default   ;   CALL ctl_stop( 'sbc_cpl_snd: wrong definition of sn_snd_temp%clcat' )
+               END SELECT
+            CASE( 'weighted oce and ice' )   ;   ztmp1(:,:) = ( ztmp1(:,:) + rt0 ) * zfr_l(:,:)   
+               SELECT CASE( sn_snd_temp%clcat )
+               CASE( 'yes' )   
+                  ztmp3(:,:,1:jpl) = tn_ice(:,:,1:jpl) * a_i(:,:,1:jpl)
+               CASE( 'no' )
+                  ztmp3(:,:,:) = 0.0
+                  DO jl=1,jpl
+                     ztmp3(:,:,1) = ztmp3(:,:,1) + tn_ice(:,:,jl) * a_i(:,:,jl)
+                  ENDDO
+               CASE default                  ;   CALL ctl_stop( 'sbc_cpl_snd: wrong definition of sn_snd_temp%clcat' )
+               END SELECT
+            CASE( 'mixed oce-ice'        )   
+               ztmp1(:,:) = ( ztmp1(:,:) + rt0 ) * zfr_l(:,:) 
+               DO jl=1,jpl
+                  ztmp1(:,:) = ztmp1(:,:) + tn_ice(:,:,jl) * a_i(:,:,jl)
+               ENDDO
+            CASE default                     ;   CALL ctl_stop( 'sbc_cpl_snd: wrong definition of sn_snd_temp%cldes' )
+            END SELECT
+         ENDIF
+         IF( ssnd(jps_toce)%laction )   CALL cpl_snd( jps_toce, isec, RESHAPE ( ztmp1, (/jpi,jpj,1/) ), info )
+         IF( ssnd(jps_tice)%laction )   CALL cpl_snd( jps_tice, isec, ztmp3, info )
+         IF( ssnd(jps_tmix)%laction )   CALL cpl_snd( jps_tmix, isec, RESHAPE ( ztmp1, (/jpi,jpj,1/) ), info )
+      ENDIF
+      !                                                      ! ------------------------- !
+      !                                                      !           Albedo          !
+      !                                                      ! ------------------------- !
+      IF( ssnd(jps_albice)%laction ) THEN                         ! ice 
+          SELECT CASE( sn_snd_alb%cldes )
+          CASE( 'ice' )
+             SELECT CASE( sn_snd_alb%clcat )
+             CASE( 'yes' )   
+                ztmp3(:,:,1:jpl) = alb_ice(:,:,1:jpl)
+             CASE( 'no' )
+                WHERE( SUM( a_i, dim=3 ) /= 0. )
+                   ztmp1(:,:) = SUM( alb_ice (:,:,1:jpl) * a_i(:,:,1:jpl), dim=3 ) / SUM( a_i(:,:,1:jpl), dim=3 )
+                ELSEWHERE
+                   ztmp1(:,:) = albedo_oce_mix(:,:)
+                END WHERE
+             CASE default   ;   CALL ctl_stop( 'sbc_cpl_snd: wrong definition of sn_snd_alb%clcat' )
+             END SELECT
+          CASE( 'weighted ice' )   ;
+             SELECT CASE( sn_snd_alb%clcat )
+             CASE( 'yes' )   
+                ztmp3(:,:,1:jpl) =  alb_ice(:,:,1:jpl) * a_i(:,:,1:jpl)
+             CASE( 'no' )
+                WHERE( fr_i (:,:) > 0. )
+                   ztmp1(:,:) = SUM (  alb_ice(:,:,1:jpl) * a_i(:,:,1:jpl), dim=3 )
+                ELSEWHERE
+                   ztmp1(:,:) = 0.
+                END WHERE
+             CASE default   ;   CALL ctl_stop( 'sbc_cpl_snd: wrong definition of sn_snd_ice%clcat' )
+             END SELECT
+          CASE default      ;   CALL ctl_stop( 'sbc_cpl_snd: wrong definition of sn_snd_alb%cldes' )
+         END SELECT
+
+         SELECT CASE( sn_snd_alb%clcat )
+            CASE( 'yes' )   
+               CALL cpl_snd( jps_albice, isec, ztmp3, info )      !-> MV this has never been checked in coupled mode
+            CASE( 'no'  )   
+               CALL cpl_snd( jps_albice, isec, RESHAPE ( ztmp1, (/jpi,jpj,1/) ), info ) 
+         END SELECT
+      ENDIF
+
+      IF( ssnd(jps_albmix)%laction ) THEN                         ! mixed ice-ocean
+         ztmp1(:,:) = albedo_oce_mix(:,:) * zfr_l(:,:)
+         DO jl=1,jpl
+            ztmp1(:,:) = ztmp1(:,:) + alb_ice(:,:,jl) * a_i(:,:,jl)
+         ENDDO
+         CALL cpl_snd( jps_albmix, isec, RESHAPE ( ztmp1, (/jpi,jpj,1/) ), info )
+      ENDIF
+      !                                                      ! ------------------------- !
+      !                                                      !  Ice fraction & Thickness ! 
+      !                                                      ! ------------------------- !
+      ! Send ice fraction field to atmosphere
+      IF( ssnd(jps_fice)%laction ) THEN
+         SELECT CASE( sn_snd_thick%clcat )
+         CASE( 'yes' )   ;   ztmp3(:,:,1:jpl) =  a_i(:,:,1:jpl)
+         CASE( 'no'  )   ;   ztmp3(:,:,1    ) = fr_i(:,:      )
+         CASE default    ;   CALL ctl_stop( 'sbc_cpl_snd: wrong definition of sn_snd_thick%clcat' )
+         END SELECT
+         IF( ssnd(jps_fice)%laction )   CALL cpl_snd( jps_fice, isec, ztmp3, info )
+      ENDIF
+      
+      ! Send ice fraction field to OPA (sent by SAS in SAS-OPA coupling)
+      IF( ssnd(jps_fice2)%laction ) THEN
+         ztmp3(:,:,1) = fr_i(:,:)
+         IF( ssnd(jps_fice2)%laction )   CALL cpl_snd( jps_fice2, isec, ztmp3, info )
+      ENDIF
+
+      ! Send ice and snow thickness field 
+      IF( ssnd(jps_hice)%laction .OR. ssnd(jps_hsnw)%laction ) THEN 
+         SELECT CASE( sn_snd_thick%cldes)
+         CASE( 'none'                  )       ! nothing to do
+         CASE( 'weighted ice and snow' )   
+            SELECT CASE( sn_snd_thick%clcat )
+            CASE( 'yes' )   
+               ztmp3(:,:,1:jpl) =  ht_i(:,:,1:jpl) * a_i(:,:,1:jpl)
+               ztmp4(:,:,1:jpl) =  ht_s(:,:,1:jpl) * a_i(:,:,1:jpl)
+            CASE( 'no' )
+               ztmp3(:,:,:) = 0.0   ;  ztmp4(:,:,:) = 0.0
+               DO jl=1,jpl
+                  ztmp3(:,:,1) = ztmp3(:,:,1) + ht_i(:,:,jl) * a_i(:,:,jl)
+                  ztmp4(:,:,1) = ztmp4(:,:,1) + ht_s(:,:,jl) * a_i(:,:,jl)
+               ENDDO
+            CASE default                  ;   CALL ctl_stop( 'sbc_cpl_snd: wrong definition of sn_snd_thick%clcat' )
+            END SELECT
+         CASE( 'ice and snow'         )   
+            SELECT CASE( sn_snd_thick%clcat )
+            CASE( 'yes' )
+               ztmp3(:,:,1:jpl) = ht_i(:,:,1:jpl)
+               ztmp4(:,:,1:jpl) = ht_s(:,:,1:jpl)
+            CASE( 'no' )
+               WHERE( SUM( a_i, dim=3 ) /= 0. )
+                  ztmp3(:,:,1) = SUM( ht_i * a_i, dim=3 ) / SUM( a_i, dim=3 )
+                  ztmp4(:,:,1) = SUM( ht_s * a_i, dim=3 ) / SUM( a_i, dim=3 )
+               ELSEWHERE
+                 ztmp3(:,:,1) = 0.
+                 ztmp4(:,:,1) = 0.
+               END WHERE
+            CASE default                  ;   CALL ctl_stop( 'sbc_cpl_snd: wrong definition of sn_snd_thick%clcat' )
+            END SELECT
+         CASE default                     ;   CALL ctl_stop( 'sbc_cpl_snd: wrong definition of sn_snd_thick%cldes' )
+         END SELECT
+         IF( ssnd(jps_hice)%laction )   CALL cpl_snd( jps_hice, isec, ztmp3, info )
+         IF( ssnd(jps_hsnw)%laction )   CALL cpl_snd( jps_hsnw, isec, ztmp4, info )
+      ENDIF
+      !
+#if defined key_cpl_carbon_cycle
+      !                                                      ! ------------------------- !
+      !                                                      !  CO2 flux from PISCES     ! 
+      !                                                      ! ------------------------- !
+      IF( nn_closea == 1 )  THEN  ! No carbon flux on closed seas
+         DO jl = 1, jpncs
+            DO jj = ncsj1(jl), ncsj2(jl)
+               DO ji = ncsi1(jl), ncsi2(jl)
+                  oce_co2(ji,jj) = 0.
+               END DO
+            END DO
+         END DO
+      ENDIF
+      IF( ssnd(jps_co2)%laction )   CALL cpl_snd( jps_co2, isec, RESHAPE ( oce_co2, (/jpi,jpj,1/) ) , info )
+      !
+#endif
+
+!AC#if defined key_transm_ocninca
+      !                                                      ! ------------------------- !
+      !                                                      !  DMS flux from PISCES     ! 
+      !                                                      ! ------------------------- !
+      IF( ssnd(jps_dms)%laction ) THEN 
+         IF( nn_closea == 1 )  THEN  ! No DMS flux on closed seas
+            DO jl = 1, jpncs
+               DO jj = ncsj1(jl), ncsj2(jl)
+                  DO ji = ncsi1(jl), ncsi2(jl)
+                     oce_dms(ji,jj) = 0.
+                  END DO
+               END DO
+            END DO
+         ENDIF
+         !
+         oce_dms(:,:) = 1000. * oce_dms(:,:)  ! factor 1e3 to have molS.m-2.s-1
+         !
+         CALL cpl_snd( jps_dms , isec, RESHAPE ( oce_dms, (/jpi,jpj,1/) ) , info )
+      ENDIF
+!AC#endif
+      !                                                      ! ------------------------- !
+      IF( ssnd(jps_ocx1)%laction ) THEN                      !      Surface current      !
+         !                                                   ! ------------------------- !
+         !    
+         !                                                  j+1   j     -----V---F
+         ! surface velocity always sent from T point                     !       |
+         !                                                        j      |   T   U
+         !                                                               |       |
+         !                                                   j    j-1   -I-------|
+         !                                               (for I)         |       |
+         !                                                              i-1  i   i
+         !                                                               i      i+1 (for I)
+         IF( nn_components == jp_iam_opa ) THEN
+            zotx1(:,:) = un(:,:,1)  
+            zoty1(:,:) = vn(:,:,1)  
+         ELSE        
+            SELECT CASE( TRIM( sn_snd_crt%cldes ) )
+            CASE( 'oce only'             )      ! C-grid ==> T
+               DO jj = 2, jpjm1
+                  DO ji = fs_2, fs_jpim1   ! vector opt.
+                     zotx1(ji,jj) = 0.5 * ( un(ji,jj,1) + un(ji-1,jj  ,1) )
+                     zoty1(ji,jj) = 0.5 * ( vn(ji,jj,1) + vn(ji  ,jj-1,1) ) 
+                  END DO
+               END DO
+            CASE( 'weighted oce and ice' )   
+               SELECT CASE ( cp_ice_msh )
+               CASE( 'C' )                      ! Ocean and Ice on C-grid ==> T
+                  DO jj = 2, jpjm1
+                     DO ji = fs_2, fs_jpim1   ! vector opt.
+                        zotx1(ji,jj) = 0.5 * ( un   (ji,jj,1) + un   (ji-1,jj  ,1) ) * zfr_l(ji,jj)  
+                        zoty1(ji,jj) = 0.5 * ( vn   (ji,jj,1) + vn   (ji  ,jj-1,1) ) * zfr_l(ji,jj)
+                        zitx1(ji,jj) = 0.5 * ( u_ice(ji,jj  ) + u_ice(ji-1,jj    ) ) *  fr_i(ji,jj)
+                        zity1(ji,jj) = 0.5 * ( v_ice(ji,jj  ) + v_ice(ji  ,jj-1  ) ) *  fr_i(ji,jj)
+                     END DO
+                  END DO
+               CASE( 'I' )                      ! Ocean on C grid, Ice on I-point (B-grid) ==> T
+                  DO jj = 2, jpjm1
+                     DO ji = 2, jpim1   ! NO vector opt.
+                        zotx1(ji,jj) = 0.5  * ( un(ji,jj,1)      + un(ji-1,jj  ,1) ) * zfr_l(ji,jj)  
+                        zoty1(ji,jj) = 0.5  * ( vn(ji,jj,1)      + vn(ji  ,jj-1,1) ) * zfr_l(ji,jj)  
+                        zitx1(ji,jj) = 0.25 * ( u_ice(ji+1,jj+1) + u_ice(ji,jj+1)                     &
+                           &                  + u_ice(ji+1,jj  ) + u_ice(ji,jj  )  ) *  fr_i(ji,jj)
+                        zity1(ji,jj) = 0.25 * ( v_ice(ji+1,jj+1) + v_ice(ji,jj+1)                     &
+                           &                  + v_ice(ji+1,jj  ) + v_ice(ji,jj  )  ) *  fr_i(ji,jj)
+                     END DO
+                  END DO
+               CASE( 'F' )                      ! Ocean on C grid, Ice on F-point (B-grid) ==> T
+                  DO jj = 2, jpjm1
+                     DO ji = 2, jpim1   ! NO vector opt.
+                        zotx1(ji,jj) = 0.5  * ( un(ji,jj,1)      + un(ji-1,jj  ,1) ) * zfr_l(ji,jj)  
+                        zoty1(ji,jj) = 0.5  * ( vn(ji,jj,1)      + vn(ji  ,jj-1,1) ) * zfr_l(ji,jj)  
+                        zitx1(ji,jj) = 0.25 * ( u_ice(ji-1,jj-1) + u_ice(ji,jj-1)                     &
+                           &                  + u_ice(ji-1,jj  ) + u_ice(ji,jj  )  ) *  fr_i(ji,jj)
+                        zity1(ji,jj) = 0.25 * ( v_ice(ji-1,jj-1) + v_ice(ji,jj-1)                     &
+                           &                  + v_ice(ji-1,jj  ) + v_ice(ji,jj  )  ) *  fr_i(ji,jj)
+                     END DO
+                  END DO
+               END SELECT
+               CALL lbc_lnk( zitx1, 'T', -1. )   ;   CALL lbc_lnk( zity1, 'T', -1. )
+            CASE( 'mixed oce-ice'        )
+               SELECT CASE ( cp_ice_msh )
+               CASE( 'C' )                      ! Ocean and Ice on C-grid ==> T
+                  DO jj = 2, jpjm1
+                     DO ji = fs_2, fs_jpim1   ! vector opt.
+                        zotx1(ji,jj) = 0.5 * ( un   (ji,jj,1) + un   (ji-1,jj  ,1) ) * zfr_l(ji,jj)   &
+                           &         + 0.5 * ( u_ice(ji,jj  ) + u_ice(ji-1,jj    ) ) *  fr_i(ji,jj)
+                        zoty1(ji,jj) = 0.5 * ( vn   (ji,jj,1) + vn   (ji  ,jj-1,1) ) * zfr_l(ji,jj)   &
+                           &         + 0.5 * ( v_ice(ji,jj  ) + v_ice(ji  ,jj-1  ) ) *  fr_i(ji,jj)
+                     END DO
+                  END DO
+               CASE( 'I' )                      ! Ocean on C grid, Ice on I-point (B-grid) ==> T
+                  DO jj = 2, jpjm1
+                     DO ji = 2, jpim1   ! NO vector opt.
+                        zotx1(ji,jj) = 0.5  * ( un(ji,jj,1)      + un(ji-1,jj  ,1) ) * zfr_l(ji,jj)   &   
+                           &         + 0.25 * ( u_ice(ji+1,jj+1) + u_ice(ji,jj+1)                     &
+                           &                  + u_ice(ji+1,jj  ) + u_ice(ji,jj  )  ) *  fr_i(ji,jj)
+                        zoty1(ji,jj) = 0.5  * ( vn(ji,jj,1)      + vn(ji  ,jj-1,1) ) * zfr_l(ji,jj)   & 
+                           &         + 0.25 * ( v_ice(ji+1,jj+1) + v_ice(ji,jj+1)                     &
+                           &                  + v_ice(ji+1,jj  ) + v_ice(ji,jj  )  ) *  fr_i(ji,jj)
+                     END DO
+                  END DO
+               CASE( 'F' )                      ! Ocean on C grid, Ice on F-point (B-grid) ==> T
+                  DO jj = 2, jpjm1
+                     DO ji = 2, jpim1   ! NO vector opt.
+                        zotx1(ji,jj) = 0.5  * ( un(ji,jj,1)      + un(ji-1,jj  ,1) ) * zfr_l(ji,jj)   &   
+                           &         + 0.25 * ( u_ice(ji-1,jj-1) + u_ice(ji,jj-1)                     &
+                           &                  + u_ice(ji-1,jj  ) + u_ice(ji,jj  )  ) *  fr_i(ji,jj)
+                        zoty1(ji,jj) = 0.5  * ( vn(ji,jj,1)      + vn(ji  ,jj-1,1) ) * zfr_l(ji,jj)   & 
+                           &         + 0.25 * ( v_ice(ji-1,jj-1) + v_ice(ji,jj-1)                     &
+                           &                  + v_ice(ji-1,jj  ) + v_ice(ji,jj  )  ) *  fr_i(ji,jj)
+                     END DO
+                  END DO
+               END SELECT
+            END SELECT
+            CALL lbc_lnk( zotx1, ssnd(jps_ocx1)%clgrid, -1. )   ;   CALL lbc_lnk( zoty1, ssnd(jps_ocy1)%clgrid, -1. )
+            !
+         ENDIF
+         !
+         !
+         IF( TRIM( sn_snd_crt%clvor ) == 'eastward-northward' ) THEN             ! Rotation of the components
+            !                                                                     ! Ocean component
+            CALL rot_rep( zotx1, zoty1, ssnd(jps_ocx1)%clgrid, 'ij->e', ztmp1 )       ! 1st component 
+            CALL rot_rep( zotx1, zoty1, ssnd(jps_ocx1)%clgrid, 'ij->n', ztmp2 )       ! 2nd component 
+            zotx1(:,:) = ztmp1(:,:)                                                   ! overwrite the components 
+            zoty1(:,:) = ztmp2(:,:)
+            IF( ssnd(jps_ivx1)%laction ) THEN                                     ! Ice component
+               CALL rot_rep( zitx1, zity1, ssnd(jps_ivx1)%clgrid, 'ij->e', ztmp1 )    ! 1st component 
+               CALL rot_rep( zitx1, zity1, ssnd(jps_ivx1)%clgrid, 'ij->n', ztmp2 )    ! 2nd component 
+               zitx1(:,:) = ztmp1(:,:)                                                ! overwrite the components 
+               zity1(:,:) = ztmp2(:,:)
+            ENDIF
+         ENDIF
+         !
+         ! spherical coordinates to cartesian -> 2 components to 3 components
+         IF( TRIM( sn_snd_crt%clvref ) == 'cartesian' ) THEN
+            ztmp1(:,:) = zotx1(:,:)                     ! ocean currents
+            ztmp2(:,:) = zoty1(:,:)
+            CALL oce2geo ( ztmp1, ztmp2, 'T', zotx1, zoty1, zotz1 )
+            !
+            IF( ssnd(jps_ivx1)%laction ) THEN           ! ice velocities
+               ztmp1(:,:) = zitx1(:,:)
+               ztmp1(:,:) = zity1(:,:)
+               CALL oce2geo ( ztmp1, ztmp2, 'T', zitx1, zity1, zitz1 )
+            ENDIF
+         ENDIF
+         !
+         IF( ssnd(jps_ocx1)%laction )   CALL cpl_snd( jps_ocx1, isec, RESHAPE ( zotx1, (/jpi,jpj,1/) ), info )   ! ocean x current 1st grid
+         IF( ssnd(jps_ocy1)%laction )   CALL cpl_snd( jps_ocy1, isec, RESHAPE ( zoty1, (/jpi,jpj,1/) ), info )   ! ocean y current 1st grid
+         IF( ssnd(jps_ocz1)%laction )   CALL cpl_snd( jps_ocz1, isec, RESHAPE ( zotz1, (/jpi,jpj,1/) ), info )   ! ocean z current 1st grid
+         !
+         IF( ssnd(jps_ivx1)%laction )   CALL cpl_snd( jps_ivx1, isec, RESHAPE ( zitx1, (/jpi,jpj,1/) ), info )   ! ice   x current 1st grid
+         IF( ssnd(jps_ivy1)%laction )   CALL cpl_snd( jps_ivy1, isec, RESHAPE ( zity1, (/jpi,jpj,1/) ), info )   ! ice   y current 1st grid
+         IF( ssnd(jps_ivz1)%laction )   CALL cpl_snd( jps_ivz1, isec, RESHAPE ( zitz1, (/jpi,jpj,1/) ), info )   ! ice   z current 1st grid
+         ! 
+      ENDIF
+      !
+      !
+      !  Fields sent by OPA to SAS when doing OPA<->SAS coupling
+      !                                                        ! SSH
+      IF( ssnd(jps_ssh )%laction )  THEN
+         !                          ! removed inverse barometer ssh when Patm
+         !                          forcing is used (for sea-ice dynamics)
+         IF( ln_apr_dyn ) THEN   ;   ztmp1(:,:) = sshb(:,:) - 0.5 * ( ssh_ib(:,:) + ssh_ibb(:,:) )
+         ELSE                    ;   ztmp1(:,:) = sshn(:,:)
+         ENDIF
+         CALL cpl_snd( jps_ssh   , isec, RESHAPE ( ztmp1            , (/jpi,jpj,1/) ), info )
+
+      ENDIF
+      !                                                        ! SSS
+      IF( ssnd(jps_soce  )%laction )  THEN
+         CALL cpl_snd( jps_soce  , isec, RESHAPE ( tsn(:,:,1,jp_sal), (/jpi,jpj,1/) ), info )
+      ENDIF
+      !                                                        ! first T level thickness 
+      IF( ssnd(jps_e3t1st )%laction )  THEN
+         CALL cpl_snd( jps_e3t1st, isec, RESHAPE ( fse3t_n(:,:,1)   , (/jpi,jpj,1/) ), info )
+      ENDIF
+      !                                                        ! Qsr fraction
+      IF( ssnd(jps_fraqsr)%laction )  THEN
+         CALL cpl_snd( jps_fraqsr, isec, RESHAPE ( fraqsr_1lev(:,:) , (/jpi,jpj,1/) ), info )
+      ENDIF
+      !
+      !  Fields sent by SAS to OPA when OASIS coupling
+      !                                                        ! Solar heat flux
+      IF( ssnd(jps_qsroce)%laction )  CALL cpl_snd( jps_qsroce, isec, RESHAPE ( qsr , (/jpi,jpj,1/) ), info )
+      IF( ssnd(jps_qnsoce)%laction )  CALL cpl_snd( jps_qnsoce, isec, RESHAPE ( qns , (/jpi,jpj,1/) ), info )
+      IF( ssnd(jps_oemp  )%laction )  CALL cpl_snd( jps_oemp  , isec, RESHAPE ( emp , (/jpi,jpj,1/) ), info )
+      IF( ssnd(jps_sflx  )%laction )  CALL cpl_snd( jps_sflx  , isec, RESHAPE ( sfx , (/jpi,jpj,1/) ), info )
+      IF( ssnd(jps_otx1  )%laction )  CALL cpl_snd( jps_otx1  , isec, RESHAPE ( utau, (/jpi,jpj,1/) ), info )
+      IF( ssnd(jps_oty1  )%laction )  CALL cpl_snd( jps_oty1  , isec, RESHAPE ( vtau, (/jpi,jpj,1/) ), info )
+      IF( ssnd(jps_rnf   )%laction )  CALL cpl_snd( jps_rnf   , isec, RESHAPE ( rnf , (/jpi,jpj,1/) ), info )
+      IF( ssnd(jps_taum  )%laction )  CALL cpl_snd( jps_taum  , isec, RESHAPE ( taum, (/jpi,jpj,1/) ), info )
+
+      CALL wrk_dealloc( jpi,jpj, zfr_l, ztmp1, ztmp2, zotx1, zoty1, zotz1, zitx1, zity1, zitz1 )
+      CALL wrk_dealloc( jpi,jpj,jpl, ztmp3, ztmp4 )
+      !
+      IF( nn_timing == 1 )  CALL timing_stop('sbc_cpl_snd')
+      !
+   END SUBROUTINE sbc_cpl_snd
+   
+   !!======================================================================
+END MODULE sbccpl
Index: CONFIG/UNIFORM/v6/IPSLCM6.3/compile_ipslcm6.sh
===================================================================
--- CONFIG/UNIFORM/v6/IPSLCM6.3/compile_ipslcm6.sh	(revision 6570)
+++ CONFIG/UNIFORM/v6/IPSLCM6.3/compile_ipslcm6.sh	(revision 6571)
@@ -318,7 +318,12 @@
 cd $nemo_root ; cp $mysrc_path/NEMO/arch-${fcm_arch}.fcm ../ARCH/.
 
+
 if [ ${resol_oce} == ORCA2 ]   ; then  cfg_wrk=ORCA2_LIM_PISCES    ; fi
 if [ ${resol_oce} == ORCA1 ]   ; then  cfg_wrk=ORCA1_LIM3_PISCES    ; fi
 if [ ${resol_oce} == ORCA025 ] ; then  cfg_wrk=ORCA025_LIM3_PISCES  ; fi
+
+# Temporary use of SOURCES/ORCA1_LIM3_PISCES to handle modifications needed by pisces coupling with inca
+cp $mysrc_path/ORCA1_LIM3_PISCES/* $nemo_root/ORCA1_LIM3_PISCES/MY_SRC
+
 
 echo cp $modipsl/config/IPSLCM6/SOURCES/NEMO/*.*90 $nemo_root/$cfg_wrk/MY_SRC/   >> $outfile
@@ -398,4 +403,8 @@
 echo >> $outfile ; echo " NOW COMPILE LMDZ REGULAR LAT-LON MODE. Resolution = ${resol_atm}"   >> $outfile 
 
+# Temporary use of SOURCES/LMDZ to handle modifications needed by LMDZ rev 4515
+cp $mysrc_path/LMDZ/*.*90  libf/phylmd/.
+
+
 # Check if the compilation of LMDZ was previsouly interupted prematured. 
 # In that case, the files dimension.h and .lock exist. If the files exist, they are here removed to avoid makelmdz_fcm 
