Index: LMDZ6/branches/DYNAMICO-conv/libf/phylmd/ini_histday_seri.h
===================================================================
--- LMDZ6/branches/DYNAMICO-conv/libf/phylmd/ini_histday_seri.h	(revision 3065)
+++ 	(revision )
@@ -1,131 +1,0 @@
-!
-! $Id$
-!
-!ym Ne fonctionnera pas en mode parallele
-      IF (is_sequential) THEN
-      
-      IF (type_run.EQ."AMIP") THEN
-!
-       zstophy = pdtphys
-       zout = ecrit_day
-!
-         idayref = day_ref
-         CALL ymds2ju(annee_ref, 1, idayref, 0.0, zjulian)
-!
-         CALL gr_fi_ecrit(1,klon,nbp_lon,nbp_lat,longitude_deg,zx_lon)
-         DO i = 1, nbp_lon
-            zx_lon(i,1) = longitude_deg(i+1)
-            zx_lon(i,nbp_lat) = longitude_deg(i+1)
-         ENDDO
-         DO ll=1,klev
-            znivsig(ll)=REAL(ll)
-         ENDDO
-         CALL gr_fi_ecrit(1,klon,nbp_lon,nbp_lat,latitude_deg,zx_lat)
-!
-         imin_debut=1 
-         nbpti=1
-         jmin_debut=1 
-         nbptj=1
-!
-         CALL histbeg("histday_seri.nc",  &
-                       nbp_lon,zx_lon(:,1),nbp_lat,zx_lat(1,:), &
-                       imin_debut,nbpti,jmin_debut,nbptj, &
-                       itau_phy, zjulian, dtime, &
-                       nhori, nid_day_seri)
-!
-         CALL histvert(nid_day_seri, "presnivs",  &
-                      "Vertical levels","mb", &
-                       klev, presnivs/100., nvert)
-!
-         CALL histdef(nid_day_seri, "bilTOA",  &
-                      "Net radiation at model top", "W/m2", &
-                      nbp_lon,nbp_lat,nhori, 1,1,1, -99, 32,  &
-                      "ave(X)", zstophy,zout)
-!
-         CALL histdef(nid_day_seri, "bils",  &
-                      "Net downward energy flux at surface","W/m2", &
-                      nbp_lon,nbp_lat,nhori, 1,1,1, -99, 32,  &
-                      "ave(X)", zstophy,zout)
-!
-         CALL histdef(nid_day_seri, "ecin",  &
-                      "Total kinetic energy (per unit area)","J/m2", &
-                      nbp_lon,nbp_lat,nhori, 1,1,1, -99, 32, &
-                      "ave(X)", zstophy,zout)
-!
-!IM 151004 BEG
-         IF(1.EQ.0) THEN
-!
-         CALL histdef(nid_day_seri, "momang",  &
-                     "Total relative angular momentum (per unit area)", &
-                     "kg/s", &
-                      nbp_lon,nbp_lat,nhori, 1,1,1, -99, 32, &
-                      "ave(X)", zstophy,zout)
-!
-         CALL histdef(nid_day_seri, "frictor",  &
-                     "Friction torque (per unit area)", "N/m", &
-                      nbp_lon,nbp_lat,nhori, 1,1,1, -99, 32, &
-                      "ave(X)", zstophy,zout)
-!
-         CALL histdef(nid_day_seri, "mountor",  &
-                     "Mountain torque (per unit area)", "N/m", &
-                      nbp_lon,nbp_lat,nhori, 1,1,1, -99, 32, &
-                      "ave(X)", zstophy,zout)
-!
-         ENDIF !(1.EQ.0) THEN
-!
-         CALL histdef(nid_day_seri, "momang",  &
-                     "Axial angular momentum (per unit area)", &
-                     "kg/s", &
-                      nbp_lon,nbp_lat,nhori, 1,1,1, -99, 32, &
-                      "ave(X)", zstophy,zout)
-!
-         CALL histdef(nid_day_seri, "torsfc",  &
-              "Total surface torque (including mountain torque)", "N/m", &
-                      nbp_lon,nbp_lat,nhori, 1,1,1, -99, 32, &
-                      "ave(X)", zstophy,zout)
-!
-!IM 151004 END        
-!
-         CALL histdef(nid_day_seri, "tamv",  &
-                      "Temperature (mass-weighted vert. ave)", "K", &
-                      nbp_lon,nbp_lat,nhori, 1,1,1, -99, 32, &
-                      "ave(X)", zstophy,zout)
-!
-         CALL histdef(nid_day_seri, "psol",  &
-                      "Surface pressure", "Pa", &
-                      nbp_lon,nbp_lat,nhori, 1,1,1, -99, 32,  &
-                      "ave(X)", zstophy,zout)
-!
-         CALL histdef(nid_day_seri, "evap",  &
-                      "Evaporation and sublimation (per unit area)",  &
-                      "kg/(m2*s)", &
-                      nbp_lon,nbp_lat,nhori, 1,1,1, -99, 32,  &
-                      "ave(X)", zstophy,zout)
-!
-!          call histdef(nid_day_seri, 
-!    .         "SnowFrac", 
-!    .         "Snow-covered area ", "%",  
-!    .         nbp_lon,nbp_lat,nhori, 1,1,1, -99, 32,
-!    .         "ave(X)", zstophy,zout)
-!
-!        CALL histdef(nid_day_seri, "snow_depth", 
-!IM 080904  .                "Snow Depth (water equivalent)", "m",
-!IM 191104  .                "Snow Depth (water equivalent)", "kg/m2",
-!    .                "Snow Mass", "kg/m2",
-!    .                nbp_lon,nbp_lat,nhori, 1,1,1, -99, 32, 
-!    .               "ave(X)", zstophy,zout)
-!
-           call histdef(nid_day_seri,  &
-               "tsol_"//clnsurf(is_oce),  &
-               "SST over open (ice-free) ocean ", "K",   &
-               nbp_lon,nbp_lat,nhori, 1,1,1, -99, 32, &
-               "ave(X)", zstophy,zout)
-!
-!=================================================================
-!
-         CALL histend(nid_day_seri)
-!
-!=================================================================
-      ENDIF ! fin de test sur type_run.EQ.AMIP
-      
-      ENDIF ! is_sequential
Index: LMDZ6/branches/DYNAMICO-conv/libf/phylmd/iophy.F90
===================================================================
--- LMDZ6/branches/DYNAMICO-conv/libf/phylmd/iophy.F90	(revision 3065)
+++ LMDZ6/branches/DYNAMICO-conv/libf/phylmd/iophy.F90	(revision 3077)
@@ -45,5 +45,5 @@
                                 mpi_size, mpi_rank, klon_mpi, &
                                 is_sequential, is_south_pole_dyn
-  USE mod_grid_phy_lmdz, ONLY: nbp_lon, nbp_lat, klon_glo
+  USE mod_grid_phy_lmdz, ONLY: nbp_lon, nbp_lat, klon_glo, grid_type, unstructured
   USE print_control_mod, ONLY: prt_level,lunout 
 #ifdef CPP_IOIPSL
@@ -51,5 +51,5 @@
 #endif
 #ifdef CPP_XIOS
-  USE wxios, ONLY: wxios_domain_param
+  use wxios, ONLY: wxios_domain_param, wxios_domain_param_unstructured, wxios_context_init
 #endif
   IMPLICIT NONE
@@ -70,8 +70,21 @@
     INTEGER :: data_ibegin, data_iend
 
-    CALL gather(rlat,rlat_glo)
-    CALL bcast(rlat_glo)
-    CALL gather(rlon,rlon_glo)
-    CALL bcast(rlon_glo)
+!#ifdef CPP_XIOS
+!      CALL wxios_context_init
+!#endif
+    
+
+    IF (grid_type==unstructured) THEN
+    
+#ifdef CPP_XIOS
+      CALL wxios_domain_param_unstructured("dom_glo")
+#endif
+
+    ELSE
+
+      CALL gather(rlat,rlat_glo)
+      CALL bcast(rlat_glo)
+      CALL gather(rlon,rlon_glo)
+      CALL bcast(rlon_glo)
     
 !$OMP MASTER  
@@ -126,32 +139,34 @@
 #endif
 #ifdef CPP_XIOS
-    ! Set values for the mask:
-    IF (mpi_rank == 0) THEN
-        data_ibegin = 0
-    ELSE 
-        data_ibegin = ii_begin - 1
-    ENDIF
-
-    IF (mpi_rank == mpi_size-1) THEN
-        data_iend = nbp_lon
-    ELSE
-        data_iend = ii_end + 1
-    ENDIF
-
-    IF (prt_level>=10) THEN
-      write(lunout,*) "init_iophy_new: mpirank=",mpi_rank," iibegin=",ii_begin , " ii_end=",ii_end," jjbegin=",jj_begin," jj_nb=",jj_nb," jj_end=",jj_end
-      write(lunout,*) "init_iophy_new: mpirank=",mpi_rank," nbp_lon=",nbp_lon," nbp_lat=",nbp_lat
-      write(lunout,*) "init_iophy_new: mpirank=",mpi_rank," data_ibegin=",data_ibegin," data_iend=",data_iend
-      write(lunout,*) "init_iophy_new: mpirank=",mpi_rank," data_ibegin=",data_ibegin," data_iend=",data_iend
-      write(lunout,*) "init_iophy_new: mpirank=",mpi_rank," is_south_pole=",is_south_pole_dyn
-    ENDIF
-
-    ! Initialize the XIOS domain coreesponding to this process:
-    CALL wxios_domain_param("dom_glo", is_sequential, nbp_lon, jj_nb, nbp_lon, nbp_lat, &
-                            1, nbp_lon, ii_begin, ii_end, jj_begin, jj_end,             &
-                            klon_mpi+2*(nbp_lon-1), data_ibegin, data_iend,             &
-                            io_lat, io_lon,is_south_pole_dyn,mpi_rank)
+      ! Set values for the mask:
+      IF (mpi_rank == 0) THEN
+          data_ibegin = 0
+      ELSE 
+          data_ibegin = ii_begin - 1
+      END IF
+
+      IF (mpi_rank == mpi_size-1) THEN
+          data_iend = nbp_lon
+      ELSE
+          data_iend = ii_end + 1
+      END IF
+
+      IF (prt_level>=10) THEN
+        write(lunout,*) "init_iophy_new: mpirank=",mpi_rank," iibegin=",ii_begin , " ii_end=",ii_end," jjbegin=",jj_begin," jj_nb=",jj_nb," jj_end=",jj_end
+        write(lunout,*) "init_iophy_new: mpirank=",mpi_rank," nbp_lon=",nbp_lon," nbp_lat=",nbp_lat
+        write(lunout,*) "init_iophy_new: mpirank=",mpi_rank," data_ibegin=",data_ibegin," data_iend=",data_iend
+        write(lunout,*) "init_iophy_new: mpirank=",mpi_rank," data_ibegin=",data_ibegin," data_iend=",data_iend
+        write(lunout,*) "init_iophy_new: mpirank=",mpi_rank," is_south_pole_dyn=",is_south_pole_dyn
+      ENDIF
+
+      ! Initialize the XIOS domain coreesponding to this process:
 #endif
 !$OMP END MASTER
+
+#ifdef CPP_XIOS    
+        CALL wxios_domain_param("dom_glo")
+#endif
+      
+    ENDIF
       
   END SUBROUTINE init_iophy_new
@@ -925,9 +940,9 @@
                                  nid_files
   USE print_control_mod, ONLY: prt_level,lunout
-  USE mod_grid_phy_lmdz, ONLY : nbp_lon, nbp_lat
+  USE mod_grid_phy_lmdz, ONLY : nbp_lon, nbp_lat, grid_type, unstructured, regular_lonlat
 #ifdef CPP_XIOS
   USE xios, ONLY: xios_send_field
 #endif
-
+  USE print_control_mod, ONLY: lunout, prt_level
 
   IMPLICIT NONE
@@ -967,5 +982,6 @@
       IF (.not. ok_all_xml) THEN
       IF (prt_level >= 10) THEN
-      WRITE (lunout,*)"histwrite2d_phy: .not.vars_defined ; time to define ", trim(var%name)
+      write(lunout,*)"histwrite2d_phy: .not.vars_defined ; time to define ", &
+                     trim(var%name)
       ENDIF
       DO iff=iff_beg, iff_end
@@ -991,5 +1007,5 @@
     ENDIF
 !$OMP MASTER
-    CALL grid1Dto2D_mpi(buffer_omp,Field2d)
+    IF (grid_type==regular_lonlat) CALL grid1Dto2D_mpi(buffer_omp,Field2d)
 
 ! La boucle sur les fichiers:
@@ -1001,11 +1017,17 @@
              write(lunout,*)'Dans iophy histwrite2D,var%name ', trim(var%name)                       
           ENDIF
-          IF (SIZE(field) == klon) then
+          
+          IF (grid_type==regular_lonlat) THEN
+            IF (SIZE(field) == klon) then
               CALL xios_send_field(var%name, Field2d)
-          ELSE
-             CALL xios_send_field(var%name, field)
-          ENDIF 
+            ELSE
+               CALL xios_send_field(var%name, field)
+            ENDIF 
+          ELSE IF (grid_type==unstructured) THEN
+            CALL xios_send_field(var%name, buffer_omp)
+          ENDIF
           IF (prt_level >= 10) THEN
-             WRITE (lunout,*)'Dans iophy histwrite2D,var%name apres xios_send ', trim(var%name)                       
+             write(lunout,*)'Dans iophy histwrite2D,var%name apres xios_send ',&
+                             trim(var%name)                       
           ENDIF
 #else
@@ -1019,12 +1041,18 @@
                IF (firstx) THEN
                   IF (prt_level >= 10) THEN
-                     WRITE (lunout,*)'Dans iophy histwrite2D,iff,var%name ', iff,trim(var%name)                       
-                     WRITE (lunout,*)"histwrite2d_phy:.NOT.clef_stations(iff)and iff==iff_beg, call xios_send_field"
+                     write(lunout,*)'Dans iophy histwrite2D,iff,var%name ',&
+                                    iff,trim(var%name)                       
+                     write(lunout,*)"histwrite2d_phy:.NOT.clef_stations(iff)and iff==iff_beg, call xios_send_field"
                   ENDIF
-                  IF (SIZE(field) == klon) then
-                     CALL xios_send_field(var%name, Field2d)
-                  ELSE
-                     CALL xios_send_field(var%name, field)
+                  IF (grid_type==regular_lonlat) THEN
+                    IF (SIZE(field) == klon) then
+                       CALL xios_send_field(var%name, Field2d)
+                    ELSE
+                       CALL xios_send_field(var%name, field)
+                    ENDIF
+                  ELSE IF (grid_type==unstructured) THEN
+                    CALL xios_send_field(var%name, buffer_omp)
                   ENDIF
+
                   firstx=.false.
                ENDIF
@@ -1039,7 +1067,7 @@
 !#ifdef CPP_XIOS
 !                        IF (iff == iff_beg) THEN
-!                          if (prt_level >= 10) then
+!                          IF (prt_level >= 10) THEN
 !                            write(lunout,*)"histwrite2d_phy: .NOT.clef_stations(iff) and iff==iff_beg, call xios_send_field"
-!                          endif
+!                          ENDIF
 !                          CALL xios_send_field(var%name, Field2d)
 !                        ENDIF
@@ -1063,5 +1091,5 @@
                        ENDIF ! of IF (is_sequential)
 #ifndef CPP_IOIPSL_NO_OUTPUT 
-                       IF (prt_level >= 10) THEn
+                       IF (prt_level >= 10) THEN
                          write(lunout,*)"histwrite2d_phy: clef_stations(iff) and iff==iff_beg, call wxios_write_2D"
                        ENDIF
@@ -1091,5 +1119,5 @@
                                  nfiles, vars_defined, clef_stations, &
                                  nid_files
-  USE mod_grid_phy_lmdz, ONLY : nbp_lon, nbp_lat
+  USE mod_grid_phy_lmdz, ONLY : nbp_lon, nbp_lat, grid_type, regular_lonlat, unstructured
 #ifdef CPP_XIOS
   USE xios, ONLY: xios_send_field
@@ -1152,5 +1180,5 @@
     ENDIF
 !$OMP MASTER
-    CALL grid1Dto2D_mpi(buffer_omp,field3d)
+    IF (grid_type==regular_lonlat) CALL grid1Dto2D_mpi(buffer_omp,field3d)
 
 
@@ -1164,9 +1192,14 @@
                              trim(var%name)                       
           ENDIF
-          IF (SIZE(field,1) == klon) then
-             CALL xios_send_field(var%name, Field3d(:,:,1:nlevx))
-          ELSE
-             CALL xios_send_field(var%name, field)
+          IF (grid_type==regular_lonlat) THEN
+            IF (SIZE(field,1) == klon) then
+               CALL xios_send_field(var%name, Field3d(:,:,1:nlevx))
+            ELSE
+               CALL xios_send_field(var%name, field)
+            ENDIF
+          ELSE IF (grid_type==unstructured) THEN
+            CALL xios_send_field(var%name, buffer_omp(:,1:nlevx))
           ENDIF
+
 #else
         CALL abort_physic ('iophy','cannot have ok_all_xml = .T. without CPP_XIOS defined' ,1)
@@ -1179,16 +1212,21 @@
 #ifdef CPP_XIOS
               IF (firstx) THEN
-                IF (prt_level >= 10) THEn
-                  WRITE (lunout,*)'Dans iophy, histwrite3D iff nlev klev firstx', &
+                IF (prt_level >= 10) THEN
+                  write(lunout,*)'Dans iophy, histwrite3D iff nlev klev firstx', &
                                   iff,nlev,klev, firstx                       
-                  WRITE (lunout,*)'histwrite3d_phy: call xios_send_field for ', &
+                  write(lunout,*)'histwrite3d_phy: call xios_send_field for ', &
                                   trim(var%name), ' with iim jjm nlevx = ', &
                                   nbp_lon,jj_nb,nlevx
                 ENDIF
-                IF (SIZE(field,1) == klon) then
-                    CALL xios_send_field(var%name, Field3d(:,:,1:nlevx))
-                ELSE
-                     CALL xios_send_field(var%name, field)
+                IF (grid_type==regular_lonlat) THEN
+                  IF (SIZE(field,1) == klon) then
+                      CALL xios_send_field(var%name, Field3d(:,:,1:nlevx))
+                  ELSE
+                       CALL xios_send_field(var%name, field)
+                  ENDIF
+                ELSE IF (grid_type==unstructured) THEN
+                  CALL xios_send_field(var%name, buffer_omp(:,1:nlevx))
                 ENDIF
+
                 firstx=.false.
               ENDIF
@@ -1251,5 +1289,5 @@
                                 is_sequential, klon_mpi_begin, klon_mpi_end, &
                                 jj_nb, klon_mpi
-  USE mod_grid_phy_lmdz, ONLY : nbp_lon, nbp_lat
+  USE mod_grid_phy_lmdz, ONLY : nbp_lon, nbp_lat, grid_type, unstructured
   USE xios, ONLY: xios_send_field
   USE print_control_mod, ONLY: prt_level,lunout
@@ -1279,4 +1317,11 @@
         CALL Gather_omp(field,buffer_omp)    
 !$OMP MASTER
+
+      IF (grid_type==unstructured) THEN
+  
+        CALL xios_send_field(field_name, buffer_omp)
+
+      ELSE
+
         CALL grid1Dto2D_mpi(buffer_omp,Field2d)
     
@@ -1314,4 +1359,5 @@
         DEALLOCATE(index2d)
         DEALLOCATE(fieldok)
+      ENDIF
 !$OMP END MASTER   
     ENDIF
@@ -1328,5 +1374,5 @@
                                 jj_nb, klon_mpi
   USE xios, ONLY: xios_send_field
-  USE mod_grid_phy_lmdz, ONLY : nbp_lon, nbp_lat
+  USE mod_grid_phy_lmdz, ONLY : nbp_lon, nbp_lat, grid_type, unstructured
   USE print_control_mod, ONLY: prt_level,lunout
 
@@ -1357,4 +1403,10 @@
         CALL Gather_omp(field,buffer_omp)
 !$OMP MASTER
+
+    IF (grid_type==unstructured) THEN
+
+      CALL xios_send_field(field_name, buffer_omp(:,1:nlev))
+
+    ELSE
         CALL grid1Dto2D_mpi(buffer_omp,field3d)
 
@@ -1392,4 +1444,5 @@
         DEALLOCATE(index3d)
         DEALLOCATE(fieldok)
+      ENDIF
 !$OMP END MASTER   
     ENDIF
Index: LMDZ6/branches/DYNAMICO-conv/libf/phylmd/write_histREGDYN.h
===================================================================
--- LMDZ6/branches/DYNAMICO-conv/libf/phylmd/write_histREGDYN.h	(revision 3065)
+++ 	(revision )
@@ -1,63 +1,0 @@
-!
-! $Header$
-!
-      if (ok_regdyn) then
-      
-      if (is_sequential) then
-
-
-      ndex3d = 0
-      itau_w = itau_phy + itap + start_time * day_step / iphysiq
-c
-       CALL histwrite(nid_regdyn,"hw1",itau_w,histoW(:,:,:,1),
-     &               kmaxm1*lmaxm1*iwmax,ndex3d)
-c
-       CALL histwrite(nid_regdyn,"nh1",itau_w,nhistoW(:,:,:,1),
-     &               kmaxm1*lmaxm1*iwmax,ndex3d)
-c
-       CALL histwrite(nid_regdyn,"nht1",itau_w,nhistoWt(:,:,:,1),
-     &               kmaxm1*lmaxm1*iwmax,ndex3d)
-c
-       CALL histwrite(nid_regdyn,"hw2",itau_w,histoW(:,:,:,2),
-     &               kmaxm1*lmaxm1*iwmax,ndex3d)
-c
-       CALL histwrite(nid_regdyn,"nh2",itau_w,nhistoW(:,:,:,2),
-     &               kmaxm1*lmaxm1*iwmax,ndex3d)
-c
-       CALL histwrite(nid_regdyn,"nht2",itau_w,nhistoWt(:,:,:,2),
-     &               kmaxm1*lmaxm1*iwmax,ndex3d)
-c
-       CALL histwrite(nid_regdyn,"hw3",itau_w,histoW(:,:,:,3),
-     &               kmaxm1*lmaxm1*iwmax,ndex3d)
-c
-       CALL histwrite(nid_regdyn,"nh3",itau_w,nhistoW(:,:,:,3),
-     &               kmaxm1*lmaxm1*iwmax,ndex3d)
-c
-       CALL histwrite(nid_regdyn,"nht3",itau_w,nhistoWt(:,:,:,3),
-     &               kmaxm1*lmaxm1*iwmax,ndex3d)
-c
-       CALL histwrite(nid_regdyn,"hw4",itau_w,histoW(:,:,:,4),
-     &               kmaxm1*lmaxm1*iwmax,ndex3d)
-c
-       CALL histwrite(nid_regdyn,"nh4",itau_w,nhistoW(:,:,:,4),
-     &               kmaxm1*lmaxm1*iwmax,ndex3d)
-c
-       CALL histwrite(nid_regdyn,"nht4",itau_w,nhistoWt(:,:,:,4),
-     &               kmaxm1*lmaxm1*iwmax,ndex3d)
-c
-       CALL histwrite(nid_regdyn,"hw5",itau_w,histoW(:,:,:,5),
-     &               kmaxm1*lmaxm1*iwmax,ndex3d)
-c
-       CALL histwrite(nid_regdyn,"nh5",itau_w,nhistoW(:,:,:,5),
-     &               kmaxm1*lmaxm1*iwmax,ndex3d)
-c
-       CALL histwrite(nid_regdyn,"nht5",itau_w,nhistoWt(:,:,:,5),
-     &               kmaxm1*lmaxm1*iwmax,ndex3d)
-
-      if (ok_sync) then
-        call histsync(nid_regdyn)
-      endif
-
-      endif ! is_sequential
-
-      endif
Index: LMDZ6/branches/DYNAMICO-conv/libf/phylmd/write_histday_seri.h
===================================================================
--- LMDZ6/branches/DYNAMICO-conv/libf/phylmd/write_histday_seri.h	(revision 3065)
+++ 	(revision )
@@ -1,165 +1,0 @@
-!
-! $Header$
-!
-      IF (is_sequential) THEN
-      
-      IF (type_run.EQ."AMIP") THEN
-!
-      ndex2d = 0
-      itau_w = itau_phy + itap + start_time * day_step_phy
-!
-! Champs 2D:
-!
-      pi = ACOS(-1.)
-      pir = 4.0*ATAN(1.0) / 180.0
-!
-      DO i=1, klon
-       zx_tmp_fi2d(i)=(topsw(i)-toplw(i))
-      ENDDO
-!
-      ok_msk=.FALSE.
-      msk(1:klon)=pctsrf(1:klon,is_ter)
-      CALL moyglo_pondaire(klon, zx_tmp_fi2d, cell_area,  &
-           ok_msk, msk, moyglo)
-      zx_tmp_fi2d(1:klon)=moyglo
-!
-      CALL gr_fi_ecrit(1, klon,nbp_lon,nbp_lat, zx_tmp_fi2d,zx_tmp_2d)
-      CALL histwrite(nid_day_seri,"bilTOA",itau_w, &
-                     zx_tmp_2d,nbp_lon*nbp_lat,ndex2d)
-!
-      ok_msk=.FALSE.
-      CALL moyglo_pondaire(klon, bils, cell_area,  &
-           ok_msk, msk, moyglo)
-      zx_tmp_fi2d(1:klon)=moyglo
-!
-      CALL gr_fi_ecrit(1, klon,nbp_lon,nbp_lat, zx_tmp_fi2d,zx_tmp_2d)
-      CALL histwrite(nid_day_seri,"bils",itau_w, &
-                     zx_tmp_2d,nbp_lon*nbp_lat,ndex2d)
-!
-      DO k=1, klev
-      DO i=1, klon
-!IM 080904    zx_tmp_fi3d(i,k)=u(i,k)**2+v(i,k)**2
-       zx_tmp_fi3d(i,k)=(u(i,k)**2+v(i,k)**2)/2.
-      ENDDO
-      ENDDO
-!
-      CALL moyglo_pondaima(klon, klev, zx_tmp_fi3d,  &
-           cell_area, paprs, moyglo)
-      zx_tmp_fi2d(1:klon)=moyglo
-!
-      CALL gr_fi_ecrit(1, klon,nbp_lon,nbp_lat, zx_tmp_fi2d,zx_tmp_2d)
-      CALL histwrite(nid_day_seri,"ecin",itau_w, &
-                     zx_tmp_2d,nbp_lon*nbp_lat,ndex2d) 
-!
-!
-!
-      CALL gr_fi_ecrit(1,klon,nbp_lon,nbp_lat,cell_area,zx_tmp_2d)
-      airetot=0.
-      DO i=1, klon
-       airetot=airetot+cell_area(i)
-      ENDDO
-!     IF(itap.EQ.1) PRINT*,'airetotphy=',airetot
-!
-      airetot=0.
-      DO j=1, nbp_lat
-       DO i=1, nbp_lon
-        airetot=airetot+zx_tmp_2d(i,j)
-       ENDDO
-      ENDDO
-!
-!     IF(itap.EQ.1) PRINT*,'airetotij=',airetot,
-!    $ '4piR2',4.*pi*RA*RA
-!
-      zx_tmp_fi2d(1:klon)=aam/airetot
-      CALL gr_fi_ecrit(1,klon,nbp_lon,nbp_lat,zx_tmp_fi2d,zx_tmp_2d)
-      CALL histwrite(nid_day_seri,"momang",itau_w,zx_tmp_2d, &
-                     nbp_lon*nbp_lat,ndex2d)
-!
-      zx_tmp_fi2d(1:klon)=torsfc/airetot
-      CALL gr_fi_ecrit(1,klon,nbp_lon,nbp_lat,zx_tmp_fi2d,zx_tmp_2d)
-      CALL histwrite(nid_day_seri,"torsfc",itau_w,zx_tmp_2d, &
-                     nbp_lon*nbp_lat,ndex2d)
-!
-!IM 151004 END
-!
-      CALL moyglo_pondmass(klon, klev, t_seri, &
-           cell_area, paprs, moyglo)
-      zx_tmp_fi2d(1:klon)=moyglo
-!
-      CALL gr_fi_ecrit(1,klon,nbp_lon,nbp_lat,zx_tmp_fi2d,zx_tmp_2d)
-      CALL histwrite(nid_day_seri,"tamv",itau_w, &
-                     zx_tmp_2d,nbp_lon*nbp_lat,ndex2d)
-!
-      ok_msk=.FALSE.
-      CALL moyglo_pondaire(klon, paprs(:,1), cell_area,  &
-           ok_msk, msk, moyglo)
-      zx_tmp_fi2d(1:klon)=moyglo
-!
-      CALL gr_fi_ecrit(1, klon,nbp_lon,nbp_lat, zx_tmp_fi2d,zx_tmp_2d)
-      CALL histwrite(nid_day_seri,"psol",itau_w, &
-                     zx_tmp_2d,nbp_lon*nbp_lat,ndex2d)
-!
-      ok_msk=.FALSE.
-      CALL moyglo_pondaire(klon, evap, cell_area,  &
-           ok_msk, msk, moyglo)
-      zx_tmp_fi2d(1:klon)=moyglo
-!
-      CALL gr_fi_ecrit(1, klon,nbp_lon,nbp_lat, zx_tmp_fi2d,zx_tmp_2d)
-      CALL histwrite(nid_day_seri,"evap",itau_w, &
-                     zx_tmp_2d,nbp_lon*nbp_lat,ndex2d)
-!
-!     DO i=1, klon
-!      zx_tmp_fi2d(i)=SnowFrac(i,is_ter)
-!     ENDDO
-!
-!     ok_msk=.TRUE.
-!     msk(1:klon)=pctsrf(1:klon,is_ter)
-!     CALL moyglo_pondaire(klon, zx_tmp_fi2d, cell_area, 
-!    .                     ok_msk, msk, moyglo)
-!     zx_tmp_fi2d(1:klon)=moyglo
-!
-!     CALL gr_fi_ecrit(1, klon,nbp_lon,nbp_lat,zx_tmp_fi2d,zx_tmp_2d)
-!     CALL histwrite(nid_day_seri,"SnowFrac",
-!    .               itau_w,zx_tmp_2d,nbp_lon*nbp_lat,ndex2d) 
-!
-!     DO i=1, klon
-!IM 080904    zx_tmp_fi2d(i)=zsnow_mass(i)/330.*rowl
-!      zx_tmp_fi2d(i)=zsnow_mass(i)
-!     ENDDO
-!
-!IM 140904   ok_msk=.FALSE.
-!     ok_msk=.TRUE.
-!     msk(1:klon)=pctsrf(1:klon,is_ter)
-!     CALL moyglo_pondaire(klon, zx_tmp_fi2d, cell_area, 
-!    .     ok_msk, msk, moyglo)
-!     zx_tmp_fi2d(1:klon)=moyglo
-!
-!     CALL gr_fi_ecrit(1, klon,nbp_lon,nbp_lat,zx_tmp_fi2d,zx_tmp_2d)
-!     CALL histwrite(nid_day_seri,"snow_depth",itau_w,
-!    .               zx_tmp_2d,nbp_lon*nbp_lat,ndex2d)
-!
-      DO i=1, klon
-       zx_tmp_fi2d(i)=ftsol(i,is_oce)
-      ENDDO
-!
-      ok_msk=.TRUE.
-      msk(1:klon)=pctsrf(1:klon,is_oce)
-      CALL moyglo_pondaire(klon, zx_tmp_fi2d, cell_area,  &
-           ok_msk, msk, moyglo)
-      zx_tmp_fi2d(1:klon)=moyglo
-!
-      CALL gr_fi_ecrit(1, klon,nbp_lon,nbp_lat, zx_tmp_fi2d, zx_tmp_2d)
-      CALL histwrite(nid_day_seri,"tsol_"//clnsurf(is_oce), &
-                     itau_w,zx_tmp_2d,nbp_lon*nbp_lat,ndex2d) 
-!
-!=================================================================
-!=================================================================
-!=================================================================
-!
-      if (ok_sync) then
-        call histsync(nid_day_seri)
-      endif
-!
-      ENDIF !fin test sur type_run.EQ."AMIP"
-      
-      ENDIF  ! mono_cpu
