Index: LMDZ4/trunk/libf/phylmd/write_histISCCP.h
===================================================================
--- LMDZ4/trunk/libf/phylmd/write_histISCCP.h	(revision 684)
+++ LMDZ4/trunk/libf/phylmd/write_histISCCP.h	(revision 766)
@@ -15,16 +15,16 @@
         DO k=1,kmaxm1
          zx_tmp_fi3d(1:klon, 1:lmaxm1)=fq_isccp(1:klon,k,1:lmaxm1,n)*100.
-         CALL gr_fi_ecrit(lmaxm1,klon,iim,jjmp1,zx_tmp_fi3d,
-     .                    zx_tmp_3d)
+cym         CALL gr_fi_ecrit(lmaxm1,klon,iim,jjmp1,zx_tmp_fi3d,
+cym     .                    zx_tmp_3d)
 c
 cIM: champ 3d : (lon,lat,pres) pour un tau fixe
 c
-         CALL histwrite(nid_isccp,"cldISCCP_"//taulev(k)//typinout(n),
-     .                  itau_w,zx_tmp_3d,iim*jjmp1*lmaxm1,ndex3d)
+       CALL histwrite_phy(nid_isccp,"cldISCCP_"//taulev(k)//typinout(n),
+     .                  itau_w,zx_tmp_fi3d)
         ENDDO !k
 c
-        CALL gr_fi_ecrit(1, klon,iim,jjmp1,nbsunlit(1,:,n),zx_tmp_2d)
-        CALL histwrite(nid_isccp,"nsunlit"//typinout(n),itau_w,
-     .                 zx_tmp_2d,iim*jjmp1,ndex2d)
+cym        CALL gr_fi_ecrit(1, klon,iim,jjmp1,nbsunlit(1,:,n),zx_tmp_2d)
+        CALL histwrite_phy(nid_isccp,"nsunlit"//typinout(n),itau_w,
+     .                 nbsunlit(1,:,n))
 c
         ENDDO ! n=1, napisccp
@@ -50,25 +50,25 @@
           ENDDO
          ENDIF
-         CALL gr_fi_ecrit(1,klon,iim,jjmp1,fq_is_true,
-     .                    zx_tmp_2d)
+cym         CALL gr_fi_ecrit(1,klon,iim,jjmp1,fq_is_true,
+cym     .                    zx_tmp_2d)
 c
 cIM: champ 2d : (lon,lat) pour un tau et une pc fixes
 c
-         CALL histwrite(nid_isccp,pclev(l)//taulev(k)//typinout(n),
-     .                  itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
+         CALL histwrite_phy(nid_isccp,pclev(l)//taulev(k)//typinout(n),
+     .                  itau_w,fq_is_true(:,:,l,n))
          ENDDO !l
         ENDDO !k
 c
 c       print*,'n=',n,' write_ISCCP avant nbsunlit'
-        CALL gr_fi_ecrit(1, klon,iim,jjmp1,nbsunlit(1,:,n),zx_tmp_2d)
-        CALL histwrite(nid_isccp,"nsunlit"//typinout(n),
-     .                 itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
+cym        CALL gr_fi_ecrit(1, klon,iim,jjmp1,nbsunlit(1,:,n),zx_tmp_2d)
+        CALL histwrite_phy(nid_isccp,"nsunlit"//typinout(n),
+     .                 itau_w,nbsunlit(1,:,n))
 c
         zx_tmp_fi2d(1:klon)=float(seed(1:klon,n))
 c
 c       print*,'n=',n,' write_ISCCP avant seed'
-        CALL gr_fi_ecrit(1, klon,iim,jjmp1,zx_tmp_fi2d,zx_tmp_2d)
-        CALL histwrite(nid_isccp,"seed"//verticaxe(n),
-     .                 itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
+cym        CALL gr_fi_ecrit(1, klon,iim,jjmp1,zx_tmp_fi2d,zx_tmp_2d)
+        CALL histwrite_phy(nid_isccp,"seed"//verticaxe(n),
+     .                 itau_w,zx_tmp_fi2d)
 c
 c 9types de nuages ISCCP-D2
@@ -80,7 +80,6 @@
      $  fq_is_true(i,1,3,n)+ fq_is_true(i,2,3,n)+ fq_is_true(i,3,3,n) )
         ENDDO
-        CALL gr_fi_ecrit(1, klon,iim,jjmp1,zx_tmp_fi2d,zx_tmp_2d)
-        CALL histwrite(nid_isccp,"cirr",itau_w,zx_tmp_2d,
-     $  iim*jjmp1,ndex2d)
+cym       CALL gr_fi_ecrit(1, klon,iim,jjmp1,zx_tmp_fi2d,zx_tmp_2d)
+        CALL histwrite_phy(nid_isccp,"cirr",itau_w,zx_tmp_fi2d)
 c
         DO i=1, klon
@@ -90,7 +89,6 @@
      $   fq_is_true(i,4,3,n)+ fq_is_true(i,5,3,n) )
         ENDDO
-	CALL gr_fi_ecrit(1, klon,iim,jjmp1,zx_tmp_fi2d,zx_tmp_2d)
-        CALL histwrite(nid_isccp,"cist",itau_w,zx_tmp_2d,
-     $  iim*jjmp1,ndex2d)
+cym	CALL gr_fi_ecrit(1, klon,iim,jjmp1,zx_tmp_fi2d,zx_tmp_2d)
+        CALL histwrite_phy(nid_isccp,"cist",itau_w,zx_tmp_fi2d)
 c
         DO i=1, klon
@@ -100,7 +98,6 @@
      $   fq_is_true(i,6,3,n)+ fq_is_true(i,7,3,n) )
         ENDDO
-	CALL gr_fi_ecrit(1, klon,iim,jjmp1,zx_tmp_fi2d,zx_tmp_2d)
-        CALL histwrite(nid_isccp,"deep",itau_w,zx_tmp_2d,
-     $  iim*jjmp1,ndex2d)
+cym	CALL gr_fi_ecrit(1, klon,iim,jjmp1,zx_tmp_fi2d,zx_tmp_2d)
+        CALL histwrite_phy(nid_isccp,"deep",itau_w,zx_tmp_fi2d)
 c
         DO i=1, klon
@@ -109,7 +106,6 @@
      $  fq_is_true(i,1,5,n)+ fq_is_true(i,2,5,n)+ fq_is_true(i,3,5,n) )
         ENDDO
-	CALL gr_fi_ecrit(1, klon,iim,jjmp1,zx_tmp_fi2d,zx_tmp_2d)
-        CALL histwrite(nid_isccp,"alcu",itau_w,zx_tmp_2d,
-     $  iim*jjmp1,ndex2d)
+cym	CALL gr_fi_ecrit(1, klon,iim,jjmp1,zx_tmp_fi2d,zx_tmp_2d)
+        CALL histwrite_phy(nid_isccp,"alcu",itau_w,zx_tmp_fi2d)
 c
         DO i=1, klon
@@ -118,7 +114,6 @@
      $   fq_is_true(i,4,5,n)+ fq_is_true(i,5,5,n) )
         ENDDO
-	CALL gr_fi_ecrit(1, klon,iim,jjmp1,zx_tmp_fi2d,zx_tmp_2d)
-        CALL histwrite(nid_isccp,"alst",itau_w,zx_tmp_2d,
-     $  iim*jjmp1,ndex2d)
+cym	CALL gr_fi_ecrit(1, klon,iim,jjmp1,zx_tmp_fi2d,zx_tmp_2d)
+        CALL histwrite_phy(nid_isccp,"alst",itau_w,zx_tmp_fi2d)
 c
         DO i=1, klon
@@ -127,7 +122,6 @@
      $   fq_is_true(i,6,5,n)+ fq_is_true(i,7,5,n) )
         ENDDO
-	CALL gr_fi_ecrit(1, klon,iim,jjmp1,zx_tmp_fi2d,zx_tmp_2d)
-        CALL histwrite(nid_isccp,"nist",itau_w,zx_tmp_2d,
-     $  iim*jjmp1,ndex2d)
+cym	CALL gr_fi_ecrit(1, klon,iim,jjmp1,zx_tmp_fi2d,zx_tmp_2d)
+        CALL histwrite_phy(nid_isccp,"nist",itau_w,zx_tmp_fi2d)
 c
         DO i=1, klon
@@ -136,7 +130,6 @@
      $  fq_is_true(i,1,7,n)+ fq_is_true(i,2,7,n)+ fq_is_true(i,3,7,n) )
         ENDDO
-	CALL gr_fi_ecrit(1, klon,iim,jjmp1,zx_tmp_fi2d,zx_tmp_2d)
-        CALL histwrite(nid_isccp,"cumu",itau_w,zx_tmp_2d,
-     $  iim*jjmp1,ndex2d)
+cym	CALL gr_fi_ecrit(1, klon,iim,jjmp1,zx_tmp_fi2d,zx_tmp_2d)
+        CALL histwrite_phy(nid_isccp,"cumu",itau_w,zx_tmp_fi2d)
 c
         DO i=1, klon
@@ -145,7 +138,6 @@
      $   fq_is_true(i,4,7,n)+ fq_is_true(i,5,7,n) )
         ENDDO
-	CALL gr_fi_ecrit(1, klon,iim,jjmp1,zx_tmp_fi2d,zx_tmp_2d)
-        CALL histwrite(nid_isccp,"stcu",itau_w,zx_tmp_2d,
-     $  iim*jjmp1,ndex2d)
+cym	CALL gr_fi_ecrit(1, klon,iim,jjmp1,zx_tmp_fi2d,zx_tmp_2d)
+        CALL histwrite_phy(nid_isccp,"stcu",itau_w,zx_tmp_fi2d)
 c
         DO i=1, klon
@@ -154,7 +146,6 @@
      $   fq_is_true(i,6,7,n)+ fq_is_true(i,7,7,n) )
         ENDDO
-	CALL gr_fi_ecrit(1, klon,iim,jjmp1,zx_tmp_fi2d,zx_tmp_2d)
-        CALL histwrite(nid_isccp,"stra",itau_w,zx_tmp_2d,
-     $  iim*jjmp1,ndex2d)
+cym	CALL gr_fi_ecrit(1, klon,iim,jjmp1,zx_tmp_fi2d,zx_tmp_2d)
+        CALL histwrite_phy(nid_isccp,"stra",itau_w,zx_tmp_fi2d)
 c
 c 3_tau_nuages x 3_levels
@@ -172,7 +163,6 @@
      $  fq_is_true(i,1,7,n)+ fq_is_true(i,2,7,n)+ fq_is_true(i,3,7,n) )
         ENDDO   
-        CALL gr_fi_ecrit(lmax3,klon,iim,jjmp1,cld_fi3d,cld_3d)
-        CALL histwrite(nid_isccp,"thin",itau_w,cld_3d,
-     $  iim*jjmp1*lmax3,ndex3d)
+cym        CALL gr_fi_ecrit(lmax3,klon,iim,jjmp1,cld_fi3d,cld_3d)
+        CALL histwrite_phy(nid_isccp,"thin",itau_w,cld_fi3d)
 c
         DO i=1, klon
@@ -188,7 +178,6 @@
      $    fq_is_true(i,4,7,n)+ fq_is_true(i,5,7,n) )
 	ENDDO   
-        CALL gr_fi_ecrit(lmax3, klon,iim,jjmp1,cld_fi3d,cld_3d)
-        CALL histwrite(nid_isccp,"mid",itau_w,cld_3d,
-     $  iim*jjmp1*lmax3,ndex3d)
+cym       CALL gr_fi_ecrit(lmax3, klon,iim,jjmp1,cld_fi3d,cld_3d)
+        CALL histwrite_phy(nid_isccp,"mid",itau_w,cld_fi3d)
 c
         DO i=1, klon
@@ -204,7 +193,6 @@
      $    fq_is_true(i,6,7,n)+ fq_is_true(i,7,7,n) )
         ENDDO   
-        CALL gr_fi_ecrit(lmax3, klon,iim,jjmp1,cld_fi3d,cld_3d)
-        CALL histwrite(nid_isccp,"thick",itau_w,cld_3d,
-     $  iim*jjmp1*lmax3,ndex3d)
+cym       CALL gr_fi_ecrit(lmax3, klon,iim,jjmp1,cld_fi3d,cld_3d)
+        CALL histwrite_phy(nid_isccp,"thick",itau_w,cld_fi3d)
 c
         ENDDO ! n=1, napisccp
@@ -213,5 +201,7 @@
 c
        if (ok_sync) then
+c$OMP MASTER
         call histsync(nid_isccp)
+c$OMP END MASTER       
        endif
 
