Index: LMDZ6/branches/LMDZ-ECRAD/libf/phylmd/phyetat0.F90
===================================================================
--- LMDZ6/branches/LMDZ-ECRAD/libf/phylmd/phyetat0.F90	(revision 3879)
+++ LMDZ6/branches/LMDZ-ECRAD/libf/phylmd/phyetat0.F90	(revision 4171)
@@ -13,20 +13,26 @@
        du_gwd_rando, du_gwd_front, entr_therm, f0, fm_therm, &
        falb_dir, falb_dif, prw_ancien, prlw_ancien, prsw_ancien, &
-       ftsol, pbl_tke, pctsrf, q_ancien, ql_ancien, qs_ancien, radpas, radsol, rain_fall, ratqs, &
+       ftsol, pbl_tke, pctsrf, q_ancien, ql_ancien, qs_ancien, rneb_ancien, radpas, radsol, rain_fall, ratqs, &
        rnebcon, rugoro, sig1, snow_fall, solaire_etat0, sollw, sollwdown, &
        solsw, solswfdiff, t_ancien, u_ancien, v_ancien, w01, wake_cstar, wake_deltaq, &
-       wake_deltat, wake_delta_pbl_TKE, delta_tsurf, wake_fip, wake_pe, &
-       wake_s, wake_dens, zgam, zmax0, zmea, zpic, zsig, &
+       wake_deltat, wake_delta_pbl_TKE, delta_tsurf, beta_aridity, wake_fip, wake_pe, &
+       wake_s, wake_dens, awake_dens, cv_gen, zgam, zmax0, zmea, zpic, zsig, &
        zstd, zthe, zval, ale_bl, ale_bl_trig, alp_bl, u10m, v10m, treedrg, &
-       ale_wake, ale_bl_stat
+       ale_wake, ale_bl_stat, ds_ns, dt_ns, delta_sst, delta_sal, ratqs_inter
 !FC
-  USE geometry_mod, ONLY : longitude_deg, latitude_deg
-  USE iostart, ONLY : close_startphy, get_field, get_var, open_startphy
-  USE infotrac_phy, only: nbtr, nqo, type_trac, tname, niadv
-  USE traclmdz_mod,    ONLY : traclmdz_from_restart
-  USE carbon_cycle_mod, ONLY : carbon_cycle_tr, carbon_cycle_cpl, co2_send
-  USE indice_sol_mod, only: nbsrf, is_ter, epsfra, is_lic, is_oce, is_sic
-  USE ocean_slab_mod, ONLY: nslay, tslab, seaice, tice, ocean_slab_init
+  USE geometry_mod,     ONLY: longitude_deg, latitude_deg
+  USE iostart,          ONLY: close_startphy, get_field, get_var, open_startphy
+  USE infotrac_phy,     ONLY: nqtot, nbtr, types_trac, tracers
+  USE traclmdz_mod,     ONLY: traclmdz_from_restart
+  USE carbon_cycle_mod, ONLY: carbon_cycle_tr, carbon_cycle_cpl, co2_send
+  USE indice_sol_mod,   ONLY: nbsrf, is_ter, epsfra, is_lic, is_oce, is_sic
+  USE ocean_slab_mod,   ONLY: nslay, tslab, seaice, tice, ocean_slab_init
   USE time_phylmdz_mod, ONLY: init_iteration, pdtphys, itau_phy
+#ifdef CPP_XIOS
+  USE wxios, ONLY: missing_val
+#else
+  use netcdf, only: missing_val => nf90_fill_real
+#endif
+  use config_ocean_skin_m, only: activate_ocean_skin
 
   IMPLICIT none
@@ -35,8 +41,7 @@
   ! Objet: Lecture de l'etat initial pour la physique
   !======================================================================
-  include "netcdf.inc"
   include "dimsoil.h"
   include "clesphys.h"
-  include "thermcell.h"
+  include "alpale.h"
   include "compbl.h"
   include "YOMCST.h"
@@ -70,5 +75,5 @@
   INTEGER length
   PARAMETER (length=100)
-  INTEGER it, iiq, isw
+  INTEGER it, iq, isw
   REAL tab_cntrl(length), tabcntr0(length)
   CHARACTER*7 str7
@@ -356,4 +361,5 @@
   ancien_ok=ancien_ok.AND.phyetat0_get(klev,ql_ancien,"QLANCIEN","QLANCIEN",0.)
   ancien_ok=ancien_ok.AND.phyetat0_get(klev,qs_ancien,"QSANCIEN","QSANCIEN",0.)
+  ancien_ok=ancien_ok.AND.phyetat0_get(klev,rneb_ancien,"RNEBANCIEN","RNEBANCIEN",0.)
   ancien_ok=ancien_ok.AND.phyetat0_get(klev,u_ancien,"UANCIEN","UANCIEN",0.)
   ancien_ok=ancien_ok.AND.phyetat0_get(klev,v_ancien,"VANCIEN","VANCIEN",0.)
@@ -368,4 +374,5 @@
        (maxval(ql_ancien).EQ.minval(ql_ancien))     .OR. &
        (maxval(qs_ancien).EQ.minval(qs_ancien))     .OR. &
+       (maxval(rneb_ancien).EQ.minval(rneb_ancien)) .OR. &
        (maxval(prw_ancien).EQ.minval(prw_ancien))   .OR. &
        (maxval(prlw_ancien).EQ.minval(prlw_ancien)) .OR. &
@@ -391,5 +398,8 @@
   IF (iflag_pbl>1 .AND. iflag_wake>=1  .AND. iflag_pbl_split >=1 ) then
     found=phyetat0_srf(klev+1,wake_delta_pbl_tke,"DELTATKE","Del TKE wk/env",0.)
-    found=phyetat0_srf(1,delta_tsurf,"DELTA_TSURF","Delta Ts wk/env ",0.)
+!!    found=phyetat0_srf(1,delta_tsurf,"DELTA_TSURF","Delta Ts wk/env ",0.)
+    found=phyetat0_srf(1,delta_tsurf,"DELTATS","Delta Ts wk/env ",0.)
+!!    found=phyetat0_srf(1,beta_aridity,"BETA_S","Aridity factor ",1.)
+    found=phyetat0_srf(1,beta_aridity,"BETAS","Aridity factor ",1.)
   ENDIF   !(iflag_pbl>1 .AND. iflag_wake>=1 .AND. iflag_pbl_split >=1 )
 
@@ -411,4 +421,6 @@
 !!  found=phyetat0_get(1,wake_dens,"WAKE_DENS","Wake num. /unit area",0.)
   found=phyetat0_get(1,wake_dens,"WAKE_DENS","Wake num. /unit area",-1000.)
+  found=phyetat0_get(1,awake_dens,"AWAKE_DENS","Active Wake num. /unit area",0.)
+  found=phyetat0_get(1,cv_gen,"CV_GEN","CB birth rate",0.)
 !>jyg
   found=phyetat0_get(1,wake_cstar,"WAKE_CSTAR","WAKE_CSTAR",0.)
@@ -430,20 +442,13 @@
   found=phyetat0_get(1,ale_bl_stat,"ALE_BL_STAT","ALE_BL_STAT",0.)
 
+! fisrtilp/Clouds 0.002 could be ratqsbas. But can stay like this as well
+  found=phyetat0_get(klev,ratqs_inter,"RATQS_INTER","Relative width of the lsc sugrid scale water",0.002)
+
 !===========================================
   ! Read and send field trs to traclmdz
 !===========================================
 
-  IF (type_trac == 'lmdz') THEN
-     DO it=1, nbtr                                                                  
-!!        iiq=niadv(it+2)                                                           ! jyg
-        iiq=niadv(it+nqo)                                                           ! jyg
-        found=phyetat0_get(1,trs(:,it),"trs_"//tname(iiq), &
-              "Surf trac"//tname(iiq),0.)
-     ENDDO
-     CALL traclmdz_from_restart(trs)
-  ENDIF
-
-!--OB now this is for co2i
-  IF (type_trac == 'co2i') THEN
+!--OB now this is for co2i - ThL: and therefore also for inco
+  IF (ANY(types_trac == 'co2i') .OR. ANY(types_trac == 'inco')) THEN
      IF (carbon_cycle_cpl) THEN
         ALLOCATE(co2_send(klon), stat=ierr)
@@ -451,5 +456,15 @@
         found=phyetat0_get(1,co2_send,"co2_send","co2 send",co2_ppm)
      ENDIF
-  ENDIF
+  ELSE IF (ANY(types_trac == 'lmdz')) THEN
+     it = 0
+     DO iq = 1, nqtot
+        IF(.NOT.(tracers(iq)%isAdvected .AND. tracers(iq)%isInPhysics)) CYCLE
+        it = it+1
+        found=phyetat0_get(1,trs(:,it),"trs_"//TRIM(tracers(iq)%name), &
+                                  "Surf trac"//TRIM(tracers(iq)%name),0.)
+     END DO
+     CALL traclmdz_from_restart(trs)
+  ENDIF
+
 
 !===========================================
@@ -519,4 +534,24 @@
   ENDIF ! Slab        
 
+  if (activate_ocean_skin >= 1) then
+     if (activate_ocean_skin == 2 .and. type_ocean == 'couple') then
+        found = phyetat0_get(1, delta_sal, "delta_sal", &
+             "ocean-air interface salinity minus bulk salinity", 0.)
+        found = phyetat0_get(1, delta_sst, "delta_SST", &
+             "ocean-air interface temperature minus bulk SST", 0.)
+     end if
+     
+     found = phyetat0_get(1, ds_ns, "dS_ns", "delta salinity near surface", 0.)
+     found = phyetat0_get(1, dt_ns, "dT_ns", "delta temperature near surface", &
+          0.)
+
+     where (pctsrf(:, is_oce) == 0.)
+        ds_ns = missing_val
+        dt_ns = missing_val
+        delta_sst = missing_val
+        delta_sal = missing_val
+     end where
+  end if
+
   ! on ferme le fichier
   CALL close_startphy
@@ -566,5 +601,5 @@
    CALL get_field(name, field, found)
    IF (.NOT. found) THEN
-     WRITE(lunout,*) "phyetat0: Le champ <",name,"> est absent"
+     WRITE(lunout,*) "phyetat0: Le champ <",TRIM(name),"> est absent"
      WRITE(lunout,*) "Depart legerement fausse. Mais je continue"
      field(:,:)=default
