Index: LMDZ6/branches/DYNAMICO-conv/libf/misc/wxios.F90
===================================================================
--- LMDZ6/branches/DYNAMICO-conv/libf/misc/wxios.F90	(revision 3335)
+++ LMDZ6/branches/DYNAMICO-conv/libf/misc/wxios.F90	(revision 3336)
@@ -15,5 +15,5 @@
     
     INTEGER, SAVE :: g_comm
-    CHARACTER(len=100), SAVE :: g_ctx_name
+    CHARACTER(len=100), SAVE :: g_ctx_name ="LMDZ"
     TYPE(xios_context), SAVE :: g_ctx
 !$OMP THREADPRIVATE(g_comm,g_cts_name,g_ctx)
@@ -145,5 +145,5 @@
     SUBROUTINE wxios_context_init()
         USE print_control_mod, ONLY : prt_level, lunout
-!        USE mod_phys_lmdz_mpi_data, ONLY : COMM_LMDZ_PHY
+        USE mod_phys_lmdz_mpi_data, ONLY : COMM_LMDZ_PHY
         IMPLICIT NONE
 
@@ -152,5 +152,5 @@
 !$OMP MASTER
         !Initialisation du contexte:
-        CALL xios_context_initialize(g_ctx_name, g_comm)
+        CALL xios_context_initialize(g_ctx_name, COMM_LMDZ_PHY)
         CALL xios_get_handle(g_ctx_name, xios_ctx)    !Récupération
         CALL xios_set_current_context(xios_ctx)            !Activation
Index: LMDZ6/branches/DYNAMICO-conv/libf/phylmd/limit_read_mod.F90
===================================================================
--- LMDZ6/branches/DYNAMICO-conv/libf/phylmd/limit_read_mod.F90	(revision 3335)
+++ LMDZ6/branches/DYNAMICO-conv/libf/phylmd/limit_read_mod.F90	(revision 3336)
@@ -288,5 +288,7 @@
 
     is_modified = .FALSE.
-    IF (MOD(itime-1, lmt_pas) == 0 .OR. jour_lu /= jour ) THEN   ! time to read
+!ym    IF (MOD(itime-1, lmt_pas) == 0 .OR. jour_lu /= jour ) THEN   ! time to read
+!  not REALLY PERIODIC
+    IF (MOD(itime-1, lmt_pas) == 0) THEN   ! time to read
        jour_lu = jour
        is_modified = .TRUE.
Index: LMDZ6/branches/DYNAMICO-conv/libf/phylmd/phys_cal_mod.F90
===================================================================
--- LMDZ6/branches/DYNAMICO-conv/libf/phylmd/phys_cal_mod.F90	(revision 3335)
+++ LMDZ6/branches/DYNAMICO-conv/libf/phylmd/phys_cal_mod.F90	(revision 3336)
@@ -36,9 +36,8 @@
   
   SUBROUTINE phys_cal_init(annee_ref,day_ref)
-
-    USE IOIPSL, ONLY:  ymds2ju
-    USE ioipsl_getin_p_mod, ONLY: getin_p
-
-    IMPLICIT NONE
+  USE IOIPSL, ONLY:  ymds2ju, ioconf_calendar
+  USE mod_phys_lmdz_para, ONLY:  is_master,is_omp_master
+  USE ioipsl_getin_p_mod, ONLY: getin_p
+  IMPLICIT NONE
     INTEGER,INTENT(IN) :: annee_ref
     INTEGER,INTENT(IN) :: day_ref
@@ -48,4 +47,17 @@
     CALL getin_p("calend",calend)
      
+    IF (is_omp_master) THEN
+      IF (calend == 'earth_360d') THEN
+        CALL ioconf_calendar('360d')
+      ELSE IF (calend == 'earth_365d') THEN
+        CALL ioconf_calendar('noleap')
+      ELSE IF (calend == 'earth_366d') THEN
+        CALL ioconf_calendar('gregorian')
+      ELSE
+        CALL abort_physic('phys_cal_init','Mauvais choix de calendrier',1)
+      ENDIF
+    ENDIF
+!$OMP BARRIER
+
     CALL ymds2ju(annee_ref, 1, day_ref, 0., jD_ref)
     jD_ref=INT(jD_ref)
Index: LMDZ6/branches/DYNAMICO-conv/libf/phylmd/phys_output_write_mod.F90
===================================================================
--- LMDZ6/branches/DYNAMICO-conv/libf/phylmd/phys_output_write_mod.F90	(revision 3335)
+++ LMDZ6/branches/DYNAMICO-conv/libf/phylmd/phys_output_write_mod.F90	(revision 3336)
@@ -348,5 +348,5 @@
     ! ug Pour les sorties XIOS
     USE xios
-    USE wxios, ONLY: wxios_closedef, missing_val
+    USE wxios, ONLY: wxios_closedef, missing_val, wxios_set_context
 #endif
     USE phys_cal_mod, ONLY : mth_len
@@ -417,9 +417,13 @@
     CALL set_itau_iophy(itau_w)
 
-    IF (.NOT.vars_defined) THEN
-       iinitend = 2
-    ELSE
+ !   IF (.NOT.vars_defined) THEN
        iinitend = 1
-    ENDIF
+ !   ELSE
+ !      iinitend = 1
+ !   ENDIF
+
+#ifdef CPP_XIOS
+    CALL wxios_set_context
+#endif
 
     DO ilev=1,klev
@@ -1954,20 +1958,20 @@
             IF (type_trac == 'lmdz' .OR. type_trac == 'repr' .OR. type_trac == 'coag') THEN
              !--3D fields
-             CALL histwrite_phy(o_trac(iq-nqo), tr_seri(:,:,iq-nqo))
-             CALL histwrite_phy(o_dtr_vdf(iq-nqo),d_tr_cl(:,:,iq-nqo))
-             CALL histwrite_phy(o_dtr_the(iq-nqo),d_tr_th(:,:,iq-nqo))
-             CALL histwrite_phy(o_dtr_con(iq-nqo),d_tr_cv(:,:,iq-nqo))
-             CALL histwrite_phy(o_dtr_lessi_impa(iq-nqo),d_tr_lessi_impa(:,:,iq-nqo))
-             CALL histwrite_phy(o_dtr_lessi_nucl(iq-nqo),d_tr_lessi_nucl(:,:,iq-nqo))
-             CALL histwrite_phy(o_dtr_insc(iq-nqo),d_tr_insc(:,:,iq-nqo))
-             CALL histwrite_phy(o_dtr_bcscav(iq-nqo),d_tr_bcscav(:,:,iq-nqo))
-             CALL histwrite_phy(o_dtr_evapls(iq-nqo),d_tr_evapls(:,:,iq-nqo))
-             CALL histwrite_phy(o_dtr_ls(iq-nqo),d_tr_ls(:,:,iq-nqo))
-             CALL histwrite_phy(o_dtr_trsp(iq-nqo),d_tr_trsp(:,:,iq-nqo))
-             CALL histwrite_phy(o_dtr_sscav(iq-nqo),d_tr_sscav(:,:,iq-nqo))
-             CALL histwrite_phy(o_dtr_sat(iq-nqo),d_tr_sat(:,:,iq-nqo))
-             CALL histwrite_phy(o_dtr_uscav(iq-nqo),d_tr_uscav(:,:,iq-nqo))
+!             CALL histwrite_phy(o_trac(iq-nqo), tr_seri(:,:,iq-nqo))
+!             CALL histwrite_phy(o_dtr_vdf(iq-nqo),d_tr_cl(:,:,iq-nqo))
+!             CALL histwrite_phy(o_dtr_the(iq-nqo),d_tr_th(:,:,iq-nqo))
+!             CALL histwrite_phy(o_dtr_con(iq-nqo),d_tr_cv(:,:,iq-nqo))
+!             CALL histwrite_phy(o_dtr_lessi_impa(iq-nqo),d_tr_lessi_impa(:,:,iq-nqo))
+!             CALL histwrite_phy(o_dtr_lessi_nucl(iq-nqo),d_tr_lessi_nucl(:,:,iq-nqo))
+!             CALL histwrite_phy(o_dtr_insc(iq-nqo),d_tr_insc(:,:,iq-nqo))
+!             CALL histwrite_phy(o_dtr_bcscav(iq-nqo),d_tr_bcscav(:,:,iq-nqo))
+!             CALL histwrite_phy(o_dtr_evapls(iq-nqo),d_tr_evapls(:,:,iq-nqo))
+!             CALL histwrite_phy(o_dtr_ls(iq-nqo),d_tr_ls(:,:,iq-nqo))
+!             CALL histwrite_phy(o_dtr_trsp(iq-nqo),d_tr_trsp(:,:,iq-nqo))
+!             CALL histwrite_phy(o_dtr_sscav(iq-nqo),d_tr_sscav(:,:,iq-nqo))
+!             CALL histwrite_phy(o_dtr_sat(iq-nqo),d_tr_sat(:,:,iq-nqo))
+!             CALL histwrite_phy(o_dtr_uscav(iq-nqo),d_tr_uscav(:,:,iq-nqo))
              !--2D fields
-             CALL histwrite_phy(o_dtr_dry(iq-nqo), flux_tr_dry(:,iq-nqo))
+!             CALL histwrite_phy(o_dtr_dry(iq-nqo), flux_tr_dry(:,iq-nqo))
              zx_tmp_fi2d=0.
              IF (vars_defined) THEN
@@ -1976,5 +1980,5 @@
                 ENDDO
              ENDIF
-             CALL histwrite_phy(o_trac_cum(iq-nqo), zx_tmp_fi2d)
+!             CALL histwrite_phy(o_trac_cum(iq-nqo), zx_tmp_fi2d)
             ENDIF
           ENDDO
Index: LMDZ6/branches/DYNAMICO-conv/libf/phylmd/physiq_mod.F90
===================================================================
--- LMDZ6/branches/DYNAMICO-conv/libf/phylmd/physiq_mod.F90	(revision 3335)
+++ LMDZ6/branches/DYNAMICO-conv/libf/phylmd/physiq_mod.F90	(revision 3336)
@@ -25,5 +25,5 @@
     USE dimphy
     USE infotrac_phy, ONLY: nqtot, nbtr, nqo, type_trac
-    USE mod_grid_phy_lmdz, ONLY: nbp_lon, nbp_lat, nbp_lev, klon_glo
+    USE mod_grid_phy_lmdz, ONLY: nbp_lon, nbp_lat, nbp_lev, klon_glo, grid1dTo2d_glo, grid_type, unstructured
     USE mod_phys_lmdz_para
     USE iophy
@@ -252,4 +252,10 @@
     use ACAMA_GWD_rando_m, only: ACAMA_GWD_rando
     USE VERTICAL_LAYERS_MOD, ONLY: aps,bps
+    USE etat0_limit_unstruct_mod
+#ifdef CPP_XIOS
+    USE xios, ONLY: xios_update_calendar, xios_context_finalize
+#endif
+    USE climoz_mod
+    USE limit_read_mod, ONLY : init_limit_read
 
 
@@ -1129,4 +1135,7 @@
     CALL update_time(pdtphys)
     phys_tstep=NINT(pdtphys)
+#ifdef CPP_XIOS
+    IF (.NOT. debut .AND. is_omp_master) CALL xios_update_calendar(itap+1)
+#endif
 
     !======================================================================
@@ -1161,4 +1170,6 @@
 
     IF (first) THEN 
+       CALL init_etat0_limit_unstruct
+       IF (.NOT. create_etat0_limit) CALL init_limit_read(days_elapsed)
        !CR:nvelles variables convection/poches froides
 
@@ -1394,6 +1405,107 @@
        CALL init_iophy_new(latitude_deg,longitude_deg)
 
+          !===================================================================
+          !IM stations CFMIP
+          nCFMIP=npCFMIP
+          OPEN(98,file='npCFMIP_param.data',status='old', &
+               form='formatted',iostat=iostat)
+          IF (iostat == 0) THEN
+             READ(98,*,end=998) nCFMIP
+998          CONTINUE
+             CLOSE(98)
+             CONTINUE
+             IF(nCFMIP.GT.npCFMIP) THEN
+                print*,'nCFMIP > npCFMIP : augmenter npCFMIP et recompiler'
+                CALL abort_physic("physiq", "", 1)
+             ELSE
+                print*,'physiq npCFMIP=',npCFMIP,'nCFMIP=',nCFMIP
+             ENDIF
+
+             !
+             ALLOCATE(tabCFMIP(nCFMIP))
+             ALLOCATE(lonCFMIP(nCFMIP), latCFMIP(nCFMIP))
+             ALLOCATE(tabijGCM(nCFMIP))
+             ALLOCATE(lonGCM(nCFMIP), latGCM(nCFMIP))
+             ALLOCATE(iGCM(nCFMIP), jGCM(nCFMIP))
+             !
+             ! lecture des nCFMIP stations CFMIP, de leur numero 
+             ! et des coordonnees geographiques lonCFMIP, latCFMIP
+             !
+             CALL read_CFMIP_point_locations(nCFMIP, tabCFMIP,  &
+                  lonCFMIP, latCFMIP)
+             !
+             ! identification des
+             ! 1) coordonnees lonGCM, latGCM des points CFMIP dans la
+             ! grille de LMDZ
+             ! 2) indices points tabijGCM de la grille physique 1d sur
+             ! klon points
+             ! 3) indices iGCM, jGCM de la grille physique 2d
+             !
+             CALL LMDZ_CFMIP_point_locations(nCFMIP, lonCFMIP, latCFMIP, &
+                  tabijGCM, lonGCM, latGCM, iGCM, jGCM)
+             !
+          ELSE
+             ALLOCATE(tabijGCM(0))
+             ALLOCATE(lonGCM(0), latGCM(0))
+             ALLOCATE(iGCM(0), jGCM(0))
+          ENDIF
+
+#ifdef CPP_IOIPSL
+
+       !$OMP MASTER
+       ! FH : if ok_sync=.true. , the time axis is written at each time step
+       ! in the output files. Only at the end in the opposite case
+       ok_sync_omp=.false.
+       CALL getin('ok_sync',ok_sync_omp)
+       CALL phys_output_open(longitude_deg,latitude_deg,nCFMIP,tabijGCM, &
+            iGCM,jGCM,lonGCM,latGCM, &
+            jjmp1,nlevSTD,clevSTD,rlevSTD, phys_tstep,ok_veget, &
+            type_ocean,iflag_pbl,iflag_pbl_split,ok_mensuel,ok_journe, &
+            ok_hf,ok_instan,ok_LES,ok_ade,ok_aie, &
+            read_climoz, phys_out_filestations, &
+            new_aod, aerosol_couple, &
+            flag_aerosol_strat, pdtphys, paprs, pphis,  &
+            pplay, lmax_th, ptconv, ptconvth, ivap,  &
+            d_u, d_t, qx, d_qx, zmasse, ok_sync_omp)
+       !$OMP END MASTER
+       !$OMP BARRIER
+       ok_sync=ok_sync_omp
+
+       freq_outNMC(1) = ecrit_files(7)
+       freq_outNMC(2) = ecrit_files(8)
+       freq_outNMC(3) = ecrit_files(9)
+       WRITE(lunout,*)'OK freq_outNMC(1)=',freq_outNMC(1)
+       WRITE(lunout,*)'OK freq_outNMC(2)=',freq_outNMC(2)
+       WRITE(lunout,*)'OK freq_outNMC(3)=',freq_outNMC(3)
+
+#ifndef CPP_XIOS
+       CALL ini_paramLMDZ_phy(phys_tstep,nid_ctesGCM)
+#endif
+
+#endif
+       ecrit_reg = ecrit_reg * un_jour
+       ecrit_tra = ecrit_tra * un_jour
+
+       !XXXPB Positionner date0 pour initialisation de ORCHIDEE
+       date0 = jD_ref 
+       WRITE(*,*) 'physiq date0 : ',date0
+       !
+
+       CALL create_climoz(read_climoz)
+
+       CALL phys_output_write(itap, pdtphys, paprs, pphis,                    &
+                              pplay, lmax_th, aerosol_couple,                 &
+                              ok_ade, ok_aie, ivap, iliq, isol, new_aod, ok_sync,&
+                              ptconv, read_climoz, clevSTD,                   &
+                              ptconvth, d_u, d_t, qx, d_qx, zmasse,           &
+                              flag_aerosol, flag_aerosol_strat, ok_cdnc)
+
+#ifdef CPP_XIOS
+       IF (is_omp_master) CALL xios_update_calendar(1)
+#endif
+       CALL create_etat0_limit_unstruct
 
        CALL phyetat0 ("startphy.nc",clesphy0,tabcntr0)
+
 !jyg<
        IF (klon_glo==1) THEN
@@ -1506,53 +1618,8 @@
           !        enddo
 
-          !===================================================================
-          !IM stations CFMIP
-          nCFMIP=npCFMIP
-          OPEN(98,file='npCFMIP_param.data',status='old', &
-               form='formatted',iostat=iostat)
-          IF (iostat == 0) THEN
-             READ(98,*,end=998) nCFMIP
-998          CONTINUE
-             CLOSE(98)
-             CONTINUE
-             IF(nCFMIP.GT.npCFMIP) THEN
-                print*,'nCFMIP > npCFMIP : augmenter npCFMIP et recompiler'
-                CALL abort_physic("physiq", "", 1)
-             ELSE
-                print*,'physiq npCFMIP=',npCFMIP,'nCFMIP=',nCFMIP
-             ENDIF
-
-             !
-             ALLOCATE(tabCFMIP(nCFMIP))
-             ALLOCATE(lonCFMIP(nCFMIP), latCFMIP(nCFMIP))
-             ALLOCATE(tabijGCM(nCFMIP))
-             ALLOCATE(lonGCM(nCFMIP), latGCM(nCFMIP))
-             ALLOCATE(iGCM(nCFMIP), jGCM(nCFMIP))
-             !
-             ! lecture des nCFMIP stations CFMIP, de leur numero 
-             ! et des coordonnees geographiques lonCFMIP, latCFMIP
-             !
-             CALL read_CFMIP_point_locations(nCFMIP, tabCFMIP,  &
-                  lonCFMIP, latCFMIP)
-             !
-             ! identification des
-             ! 1) coordonnees lonGCM, latGCM des points CFMIP dans la
-             ! grille de LMDZ
-             ! 2) indices points tabijGCM de la grille physique 1d sur
-             ! klon points
-             ! 3) indices iGCM, jGCM de la grille physique 2d
-             !
-             CALL LMDZ_CFMIP_point_locations(nCFMIP, lonCFMIP, latCFMIP, &
-                  tabijGCM, lonGCM, latGCM, iGCM, jGCM)
-             !
-          ELSE
-             ALLOCATE(tabijGCM(0))
-             ALLOCATE(lonGCM(0), latGCM(0))
-             ALLOCATE(iGCM(0), jGCM(0))
-          ENDIF
-       ELSE
-          ALLOCATE(tabijGCM(0))
-          ALLOCATE(lonGCM(0), latGCM(0))
-          ALLOCATE(iGCM(0), jGCM(0))
+       !ELSE
+       !   ALLOCATE(tabijGCM(0))
+       !   ALLOCATE(lonGCM(0), latGCM(0))
+       !   ALLOCATE(iGCM(0), jGCM(0))
        ENDIF
 
@@ -1642,43 +1709,7 @@
 #endif 
 
-#ifdef CPP_IOIPSL
-
-       !$OMP MASTER
-       ! FH : if ok_sync=.true. , the time axis is written at each time step
-       ! in the output files. Only at the end in the opposite case
-       ok_sync_omp=.false.
-       CALL getin('ok_sync',ok_sync_omp)
-       CALL phys_output_open(longitude_deg,latitude_deg,nCFMIP,tabijGCM, &
-            iGCM,jGCM,lonGCM,latGCM, &
-            jjmp1,nlevSTD,clevSTD,rlevSTD, phys_tstep,ok_veget, &
-            type_ocean,iflag_pbl,iflag_pbl_split,ok_mensuel,ok_journe, &
-            ok_hf,ok_instan,ok_LES,ok_ade,ok_aie, &
-            read_climoz, phys_out_filestations, &
-            new_aod, aerosol_couple, &
-            flag_aerosol_strat, pdtphys, paprs, pphis,  &
-            pplay, lmax_th, ptconv, ptconvth, ivap,  &
-            d_u, d_t, qx, d_qx, zmasse, ok_sync_omp)
-       !$OMP END MASTER
-       !$OMP BARRIER
-       ok_sync=ok_sync_omp
-
-       freq_outNMC(1) = ecrit_files(7)
-       freq_outNMC(2) = ecrit_files(8)
-       freq_outNMC(3) = ecrit_files(9)
-       WRITE(lunout,*)'OK freq_outNMC(1)=',freq_outNMC(1)
-       WRITE(lunout,*)'OK freq_outNMC(2)=',freq_outNMC(2)
-       WRITE(lunout,*)'OK freq_outNMC(3)=',freq_outNMC(3)
-
-#ifndef CPP_XIOS
-       CALL ini_paramLMDZ_phy(phys_tstep,nid_ctesGCM)
-#endif
-
-#endif
-       ecrit_reg = ecrit_reg * un_jour
-       ecrit_tra = ecrit_tra * un_jour
-
-       !XXXPB Positionner date0 pour initialisation de ORCHIDEE
-       date0 = jD_ref 
-       WRITE(*,*) 'physiq date0 : ',date0
+
+       CALL printflag( tabcntr0,radpas,ok_journe, &
+            ok_instan, ok_region )
        !
        !
@@ -4705,4 +4736,7 @@
        ENDIF
        !$OMP END MASTER
+#ifdef CPP_XIOS
+       IF (is_omp_master) CALL xios_context_finalize
+#endif
     ENDIF
 
Index: LMDZ6/branches/DYNAMICO-conv/libf/phylmd/slab_heat_transp_mod.F90
===================================================================
--- LMDZ6/branches/DYNAMICO-conv/libf/phylmd/slab_heat_transp_mod.F90	(revision 3335)
+++ LMDZ6/branches/DYNAMICO-conv/libf/phylmd/slab_heat_transp_mod.F90	(revision 3336)
@@ -84,5 +84,4 @@
                                   aire_,apoln_,apols_, &
                                   aireu_,airev_,rlatv, rad, omeg)
-!    USE comconst_mod, ONLY: omeg, rad
     ! number of points in lon, lat
     IMPLICIT NONE
