Index: /LMDZ4/trunk/libf/phylmd/phys_output_mod.F90
===================================================================
--- /LMDZ4/trunk/libf/phylmd/phys_output_mod.F90	(revision 1064)
+++ /LMDZ4/trunk/libf/phylmd/phys_output_mod.F90	(revision 1065)
@@ -12,4 +12,6 @@
   IMPLICIT NONE
 
+  private histdef2d, histdef3d
+
    integer, parameter                           :: nfiles = 5
    logical, dimension(nfiles), save             :: clef_files
@@ -17,18 +19,9 @@
    integer, dimension(nfiles), save             :: nid_files
 
-   integer, dimension(nfiles), save             :: nhorim, nvertm
-   real, dimension(nfiles), save                :: zstophym, zoutm
-   CHARACTER(len=20), dimension(nfiles), save   :: type_ecri
+   integer, dimension(nfiles), private, save :: nhorim, nvertm
+   real, dimension(nfiles), private, save                :: zstophym, zoutm
+   CHARACTER(len=20), dimension(nfiles), private, save   :: type_ecri
 
 !   integer, save                     :: nid_hf3d 
-
-!!!!!!!!!! stockage dans une region limitee pour chaque fichier !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-!                 entre [lonmin_reg,lonmax_reg] et [latmin_reg,latmax_reg]
-
-  logical, dimension(nfiles), save  :: ok_reglim         = (/ .false., .false., .false., .false., .true. /) 
-  real, dimension(nfiles), save     :: lonmin_reg        = (/ 0., -45., 0., 0., -162. /)
-  real, dimension(nfiles), save     :: lonmax_reg        = (/ 90., 45., 90., 90., -144. /)
-  real, dimension(nfiles), save     :: latmin_reg        = (/ 0., -45., 0., 0., 7. /)
-  real, dimension(nfiles), save     :: latmax_reg        = (/ 90., 90., 90., 90., 21. /)
 
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@@ -36,4 +29,7 @@
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!/ histmth, histday, histhf, histins /)!!!!!!!!!!!!
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+  integer, private:: levmin(nfiles) = 1
+  integer, private:: levmax(nfiles)
 
 !!! 1D
@@ -318,5 +314,5 @@
                               ctetaSTD,dtime, presnivs, ok_veget, &
                               ocean, iflag_pbl,ok_mensuel,ok_journe, &
-                              ok_hf,ok_instan,ok_LES, nid_fil)   
+                              ok_hf,ok_instan,ok_LES)   
 
   USE iophy 
@@ -349,5 +345,4 @@
   character(len=6)                      :: ocean
   CHARACTER(len=3)                      :: ctetaSTD(nbteta)
-  integer, dimension(nfiles)            :: nid_fil
   real, dimension(nfiles)               :: ecrit_files
   CHARACTER(len=20), dimension(nfiles)  :: name_files
@@ -356,7 +351,15 @@
   integer                               :: imin_ins, imax_ins
   integer                               :: jmin_ins, jmax_ins
-  integer, dimension(nfiles)            :: lvlmax_reg
-
-   lvlmax_reg = (/ klev, klev, klev, klev, 17 /)
+
+!!!!!!!!!! stockage dans une region limitee pour chaque fichier !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!                 entre [lonmin_reg,lonmax_reg] et [latmin_reg,latmax_reg]
+
+  logical, dimension(nfiles), save  :: ok_reglim         = (/ .false., .false., .false., .false., .true. /) 
+  real, dimension(nfiles), save     :: lonmin_reg        = (/ 0., -45., 0., 0., -162. /)
+  real, dimension(nfiles), save     :: lonmax_reg        = (/ 90., 45., 90., 90., -144. /)
+  real, dimension(nfiles), save     :: latmin_reg        = (/ 0., -45., 0., 0., 7. /)
+  real, dimension(nfiles), save     :: latmax_reg        = (/ 90., 90., 90., 90., 21. /)
+
+   levmax = (/ klev, klev, klev, klev, 17 /)
 
    name_files(1) = 'histmth'
@@ -409,6 +412,4 @@
      if (ok_reglim(iff)) then
 
-        klev = lvlmax_reg(iff)
-
         imin_ins=1
         imax_ins=iim
@@ -438,13 +439,13 @@
               imin_ins,imax_ins-imin_ins+1, &
               jmin_ins,jmax_ins-jmin_ins+1, &
-              itau_phy,zjulian,dtime,nhorim(iff),nid_fil(iff))
+              itau_phy,zjulian,dtime,nhorim(iff),nid_files(iff))
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
        else
- CALL histbeg_phy(name_files(iff),itau_phy,zjulian,dtime,nhorim(iff),nid_fil(iff))
+ CALL histbeg_phy(name_files(iff),itau_phy,zjulian,dtime,nhorim(iff),nid_files(iff))
        endif
  
-      nid_files(iff)=nid_fil(iff)
-
- CALL histvert(nid_files(iff),"presnivs","Vertical levels","mb",klev, presnivs/100., nvertm(iff))
+      CALL histvert(nid_files(iff), "presnivs", "Vertical levels", "mb", &
+           levmax(iff) - levmin(iff) + 1, &
+           presnivs(levmin(iff):levmax(iff))/100., nvertm(iff))
 
 !!!!!!!!!!!!! Traitement des champs 3D pour histhf !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@@ -785,6 +786,4 @@
 
          ENDDO ! 
-      klev = lvlmax_reg(1)
-
       end subroutine phys_output_open
 
@@ -837,7 +836,8 @@
 
        if ( flag_var(iff)<=lev_files(iff) ) then
- call histdef (nid_files(iff),nomvar,titrevar,unitvar, &
-               iim,jj_nb,nhorim(iff), klev,1,klev,nvertm(iff), 32, &
-               type_ecri(iff), zstophym(iff),zoutm(iff))
+          call histdef (nid_files(iff), nomvar, titrevar, unitvar, &
+               iim, jj_nb, nhorim(iff), klev, levmin(iff), &
+               levmax(iff)-levmin(iff)+1, nvertm(iff), 32, type_ecri(iff), &
+               zstophym(iff), zoutm(iff))
        endif
       end subroutine histdef3d
Index: /LMDZ4/trunk/libf/phylmd/physiq.F
===================================================================
--- /LMDZ4/trunk/libf/phylmd/physiq.F	(revision 1064)
+++ /LMDZ4/trunk/libf/phylmd/physiq.F	(revision 1065)
@@ -1,5 +1,2 @@
-!
-! $Header$
-!
 c
 c#define IO_DEBUG
@@ -1535,5 +1532,5 @@
      &                        ctetaSTD,dtime,presnivs,ok_veget,
      &                        type_ocean,iflag_pbl,ok_mensuel,ok_journe,
-     &                        ok_hf,ok_instan,ok_LES,nid_files)
+     &                        ok_hf,ok_instan,ok_LES)
 c$OMP END MASTER
 c$OMP BARRIER
