Index: LMDZ6/branches/Ocean_skin/libf/phylmd/cpl_mod.F90
===================================================================
--- LMDZ6/branches/Ocean_skin/libf/phylmd/cpl_mod.F90	(revision 3605)
+++ LMDZ6/branches/Ocean_skin/libf/phylmd/cpl_mod.F90	(revision 3627)
@@ -48,4 +48,8 @@
   REAL, ALLOCATABLE, DIMENSION(:,:), SAVE   :: cpl_snow, cpl_evap, cpl_tsol
   !$OMP THREADPRIVATE(cpl_snow,cpl_evap,cpl_tsol)
+
+  REAL, ALLOCATABLE, SAVE:: cpl_t_int(:)
+  !$OMP THREADPRIVATE(cpl_t_int)
+  
   REAL, ALLOCATABLE, DIMENSION(:,:), SAVE   :: cpl_fder, cpl_albe, cpl_taux, cpl_tauy
   !$OMP THREADPRIVATE(cpl_fder,cpl_albe,cpl_taux,cpl_tauy)
@@ -66,4 +70,9 @@
   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)
@@ -84,4 +93,8 @@
   REAL, ALLOCATABLE, DIMENSION(:,:,:), SAVE :: cpl_snow2D, cpl_evap2D, cpl_tsol2D
   !$OMP THREADPRIVATE(cpl_snow2D, cpl_evap2D, cpl_tsol2D)
+
+  REAL, ALLOCATABLE, SAVE:: cpl_t_int_2D(:,:)
+  !$OMP THREADPRIVATE(cpl_t_int_2D)
+
   REAL, ALLOCATABLE, DIMENSION(:,:,:), SAVE :: cpl_fder2D, cpl_albe2D
   !$OMP THREADPRIVATE(cpl_fder2D, cpl_albe2D)
@@ -122,4 +135,5 @@
     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
@@ -217,4 +231,15 @@
     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_t_int(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
@@ -376,4 +401,5 @@
     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"
@@ -437,4 +463,5 @@
        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
 
@@ -494,5 +521,6 @@
 !
 
-  SUBROUTINE cpl_receive_ocean_fields(knon, knindex, tsurf_new, u0_new, v0_new)
+  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
@@ -502,4 +530,5 @@
     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
@@ -511,4 +540,8 @@
 !*************************************************************************************
     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
@@ -525,4 +558,5 @@
 !*************************************************************************************
     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)
@@ -611,14 +645,17 @@
        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)
-!
-! 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).
-!
+       sens_prec_liq, sens_prec_sol, lat_prec_liq, lat_prec_sol, t_int)
+
+    ! 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
@@ -634,4 +671,5 @@
     REAL, DIMENSION(klon), INTENT(IN)       :: sens_prec_liq, sens_prec_sol
     REAL, DIMENSION(klon), INTENT(IN)       :: lat_prec_liq, lat_prec_sol
+    real, intent(in):: t_int(:) ! (klon) ocean-air interface temperature, in K
 
 ! Local variables
@@ -669,4 +707,5 @@
        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) cpl_t_int(:knon) = 0.
     ENDIF
        
@@ -710,4 +749,7 @@
 !!---OB: this is correct but why knindex ??
        ENDIF
+
+       if (activate_ocean_skin == 2) &
+            cpl_t_int(ig) = cpl_t_int(ig) + t_int(ig) / REAL(nexca)
      ENDDO
 
@@ -755,4 +797,9 @@
              sum_error = sum_error + error
           ENDIF
+
+          if (activate_ocean_skin == 2) then
+             ALLOCATE(cpl_t_int_2D(nbp_lon, jj_nb), stat = error)
+             sum_error = sum_error + error
+          end if
 
           IF (sum_error /= 0) THEN
@@ -810,5 +857,7 @@
        IF (carbon_cycle_cpl) &
             CALL gath2cpl(cpl_atm_co2(:,cpl_index), cpl_atm_co22D(:,:), knon, knindex)
-   ENDIF
+       if (activate_ocean_skin == 2) &
+            CALL gath2cpl(cpl_t_int, cpl_t_int_2D, knon, knindex)
+    ENDIF
 
   END SUBROUTINE cpl_send_ocean_fields
@@ -1145,4 +1194,5 @@
     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
 !    
@@ -1202,4 +1252,5 @@
     tab_flds(:,:,ids_qraiic) = cpl_sens_rain2D(:,:,2)
     tab_flds(:,:,ids_qsnoic) = cpl_sens_snow2D(:,:,2)
+    if (activate_ocean_skin == 2) tab_flds(:, :, ids_t_int) = cpl_t_int_2D
     
     IF (version_ocean=='nemo') THEN
@@ -1438,4 +1489,6 @@
     ENDIF
 
+    if (activate_ocean_skin == 2) deallocate(cpl_t_int_2d)
+
     IF (sum_error /= 0) THEN
        abort_message='Pb in deallocation of cpl_xxxx2D coupling variables'
