Index: DZ6/branches/Amaury_dev/libf/dyn3d/abort_gcm.F90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/dyn3d/abort_gcm.F90	(revision 5127)
+++ 	(revision )
@@ -1,43 +1,0 @@
-! $Id$
-
-!
-!
-SUBROUTINE abort_gcm(modname, message, ierr)
-
-  USE IOIPSL
-  !! ug Pour les sorties XIOS
-  USE lmdz_wxios
-  USE lmdz_iniprint, ONLY: lunout, prt_level
-
-  !
-  ! Stops the simulation cleanly, closing files and printing various
-  ! comments
-  !
-  !  Input: modname = name of calling program
-  !     message = stuff to print
-  !     ierr    = severity of situation ( = 0 normal )
-
-  CHARACTER(LEN = *), INTENT(IN) :: modname
-  INTEGER, INTENT(IN) :: ierr
-  CHARACTER(LEN = *), INTENT(IN) :: message
-
-  WRITE(lunout, *) 'in abort_gcm'
-
-  IF (using_xios) THEN
-    !Fermeture propre de XIOS
-    CALL wxios_close()
-  ENDIF
-
-  CALL histclo
-  CALL restclo
-  CALL getin_dump
-  WRITE(lunout, *) 'Stopping in ', modname
-  WRITE(lunout, *) 'Reason = ', message
-  IF (ierr == 0) THEN
-    WRITE(lunout, *) 'Everything is cool'
-    stop
-  else
-    WRITE(lunout, *) 'Houston, we have a problem, ierr = ', ierr
-    stop 1
-  ENDIF
-END SUBROUTINE abort_gcm
Index: /LMDZ6/branches/Amaury_dev/libf/dyn3d/bilan_dyn.F90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/dyn3d/bilan_dyn.F90	(revision 5127)
+++ /LMDZ6/branches/Amaury_dev/libf/dyn3d/bilan_dyn.F90	(revision 5128)
@@ -14,4 +14,5 @@
   USE temps_mod, ONLY: annee_ref, day_ref, itau_dyn
   USE lmdz_iniprint, ONLY: lunout, prt_level
+
 
   IMPLICIT NONE
Index: /LMDZ6/branches/Amaury_dev/libf/dyn3d/check_isotopes.F90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/dyn3d/check_isotopes.F90	(revision 5127)
+++ /LMDZ6/branches/Amaury_dev/libf/dyn3d/check_isotopes.F90	(revision 5128)
@@ -3,4 +3,5 @@
    USE infotrac,    ONLY: nqtot, niso, nphas, isotope, isoCheck, iqIsoPha, isoSelect, &
                           ntiso, iH2O, nzone, tracers, isoName,  itZonIso, getKey
+
    IMPLICIT NONE
    include "dimensions.h"
Index: /LMDZ6/branches/Amaury_dev/libf/dyn3d/conf_gcm.f90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/dyn3d/conf_gcm.f90	(revision 5127)
+++ /LMDZ6/branches/Amaury_dev/libf/dyn3d/conf_gcm.f90	(revision 5128)
@@ -17,4 +17,5 @@
   USE temps_mod, ONLY: calend, year_len
   USE lmdz_iniprint, ONLY: lunout, prt_level
+
 
   IMPLICIT NONE
Index: /LMDZ6/branches/Amaury_dev/libf/dyn3d/dynetat0.F90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/dyn3d/dynetat0.F90	(revision 5127)
+++ /LMDZ6/branches/Amaury_dev/libf/dyn3d/dynetat0.F90	(revision 5128)
@@ -22,4 +22,5 @@
   USE lmdz_description, ONLY: descript
   USE lmdz_iniprint, ONLY: lunout, prt_level
+
 
   IMPLICIT NONE
Index: /LMDZ6/branches/Amaury_dev/libf/dyn3d/dynredem_mod.F90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/dyn3d/dynredem_mod.F90	(revision 5127)
+++ /LMDZ6/branches/Amaury_dev/libf/dyn3d/dynredem_mod.F90	(revision 5128)
@@ -1,6 +1,6 @@
 MODULE dynredem_mod
 
-  USE netcdf, ONLY: nf90_strerror,nf90_noerr,nf90_redef,nf90_put_var,nf90_enddef,nf90_put_att,&
-          nf90_inq_varid,nf90_get_var,nf90_def_var
+  USE netcdf, ONLY: nf90_strerror, nf90_noerr, nf90_redef, nf90_put_var, nf90_enddef, nf90_put_att, &
+          nf90_inq_varid, nf90_get_var, nf90_def_var
   USE lmdz_cppkeys_wrapper, ONLY: nf90_format
   IMPLICIT NONE; PRIVATE
@@ -9,6 +9,6 @@
   include "dimensions.h"
   include "paramet.h"
-  CHARACTER(LEN=256), SAVE :: fil, modname
-  INTEGER,            SAVE :: nvarid
+  CHARACTER(LEN = 256), SAVE :: fil, modname
+  INTEGER, SAVE :: nvarid
 
 
@@ -16,184 +16,184 @@
 
 
-!===============================================================================
-
-SUBROUTINE dynredem_write_u(ncid,id,var,ll)
-
-!===============================================================================
-! Arguments:
-  INTEGER,          INTENT(IN) :: ncid
-  CHARACTER(LEN=*), INTENT(IN) :: id
-  REAL,             INTENT(IN) :: var(iip1,jjp1,ll)
-  INTEGER,          INTENT(IN) :: ll
-!===============================================================================
-! Local variables:
-  INTEGER :: start(4), count(4)
-!===============================================================================
-  start(:)=[1,1,1,1]; count(:)=[iip1,jjp1,ll,1]
-  CALL err(nf90_inq_varid(ncid,id,nvarid),"inq",id)
-  CALL err(nf90_put_var(ncid,nvarid,var,start,count),"put",id)
-  
-END SUBROUTINE dynredem_write_u
-
-!===============================================================================
-
-
-!===============================================================================
-
-SUBROUTINE dynredem_write_v(ncid,id,var,ll)
-
-!===============================================================================
-! Arguments:
-  INTEGER,          INTENT(IN) :: ncid
-  CHARACTER(LEN=*), INTENT(IN) :: id
-  REAL,             INTENT(IN) :: var(iip1,jjm,ll)
-  INTEGER,          INTENT(IN) :: ll
-!===============================================================================
-! Local variables:
-  INTEGER :: start(4), count(4)
-!===============================================================================
-  start(:)=[1,1,1,1]; count(:)=[iip1,jjm,ll,1]
-  CALL err(nf90_inq_varid(ncid,id,nvarid),"inq",id)
-  CALL err(nf90_put_var(ncid,nvarid,var,start,count),"put",id)
-  
-END SUBROUTINE dynredem_write_v
-
-!===============================================================================
-
-
-!===============================================================================
-
-SUBROUTINE dynredem_read_u(ncid,id,var,ll)
-
-!===============================================================================
-! Arguments:
-  INTEGER,          INTENT(IN)  :: ncid
-  CHARACTER(LEN=*), INTENT(IN)  :: id
-  REAL,             INTENT(OUT) :: var(iip1,jjp1,ll)
-  INTEGER,          INTENT(IN)  :: ll
-!===============================================================================
-! Local variables:
-  INTEGER :: start(4), count(4)
-!===============================================================================
-  start(:)=[1,1,1,1]; count(:)=[iip1,jjp1,ll,1]
-  CALL err(nf90_inq_varid(ncid,id,nvarid),"inq",id)
-  CALL err(nf90_get_var(ncid,nvarid,var,start,count),"get",id)
-  
-END SUBROUTINE dynredem_read_u    
-
-!===============================================================================
-
-
-!===============================================================================
-
-SUBROUTINE cre_var(ncid,var,title,did,units)
-
-!===============================================================================
-! Arguments:
-  INTEGER,                    INTENT(IN) :: ncid
-  CHARACTER(LEN=*),           INTENT(IN) :: var, title
-  INTEGER,                    INTENT(IN) :: did(:)
-  CHARACTER(LEN=*), OPTIONAL, INTENT(IN) :: units
-!===============================================================================
-  CALL err(nf90_def_var(ncid,var,nf90_format,did,nvarid),"inq",var)
-  IF(title/="")      CALL err(nf90_put_att(ncid,nvarid,"title",title),var)
-  IF(PRESENT(units)) CALL err(nf90_put_att(ncid,nvarid,"units",units),var)
-
-END SUBROUTINE cre_var
-
-!===============================================================================
-
-
-!===============================================================================
-
-SUBROUTINE put_var1(ncid,var,title,did,v,units)
-
-!===============================================================================
-! Arguments:
-  INTEGER,                    INTENT(IN) :: ncid
-  CHARACTER(LEN=*),           INTENT(IN) :: var, title
-  INTEGER,                    INTENT(IN) :: did(1)
-  REAL,                       INTENT(IN) :: v(:)
-  CHARACTER(LEN=*), OPTIONAL, INTENT(IN) :: units
-!===============================================================================
-  IF(     PRESENT(units)) CALL cre_var(ncid,var,title,did,units)
-  IF(.NOT.PRESENT(units)) CALL cre_var(ncid,var,title,did)
-  CALL err(nf90_enddef(ncid))
-  CALL err(nf90_put_var(ncid,nvarid,v),"put",var)
-  CALL err(nf90_redef(ncid))
-
-END SUBROUTINE put_var1
-
-!===============================================================================
-
-
-!===============================================================================
-
-SUBROUTINE put_var2(ncid,var,title,did,v,units)
-
-!===============================================================================
-! Arguments:
-  INTEGER,                    INTENT(IN) :: ncid
-  CHARACTER(LEN=*),           INTENT(IN) :: var, title
-  INTEGER,                    INTENT(IN) :: did(2)
-  REAL,                       INTENT(IN) :: v(:,:)
-  CHARACTER(LEN=*), OPTIONAL, INTENT(IN) :: units
-!===============================================================================
-  IF(     PRESENT(units)) CALL cre_var(ncid,var,title,did,units)
-  IF(.NOT.PRESENT(units)) CALL cre_var(ncid,var,title,did)
-  CALL err(nf90_enddef(ncid))
-  CALL err(nf90_put_var(ncid,nvarid,v),"put",var)
-  CALL err(nf90_redef(ncid))
-
-END SUBROUTINE put_var2
-
-!===============================================================================
-
-
-!===============================================================================
-
-FUNCTION msg(typ,nam)
-
-!===============================================================================
-! Arguments:
-  CHARACTER(LEN=256)                     :: msg    !--- STANDARDIZED MESSAGE
-  CHARACTER(LEN=*),           INTENT(IN) :: typ    !--- TYPE OF OPERATION
-  CHARACTER(LEN=*), OPTIONAL, INTENT(IN) :: nam    !--- FIELD NAME
-!===============================================================================
-  SELECT CASE(typ)
-    CASE('open');  msg="Opening failed for <"//TRIM(fil)//">"
-    CASE('close'); msg="Closing failed for <"//TRIM(fil)//">"
-    CASE('get');   msg="Reading failed for <"//TRIM(nam)//">"
-    CASE('put');   msg="Writting failed for <"//TRIM(nam)//">"
-    CASE('inq');   msg="Missing field <"//TRIM(nam)//">"
-    CASE('fnd');   msg="Found field <"//TRIM(nam)//">"
-  END SELECT
-  msg=TRIM(msg)//" in file <"//TRIM(fil)//">"
-
-END FUNCTION msg
-
-!===============================================================================
-
-
-!===============================================================================
-
-SUBROUTINE err(ierr,typ,nam)
-
-!===============================================================================
-! Arguments:
-  INTEGER,                    INTENT(IN) :: ierr   !--- NetCDF ERROR CODE
-  CHARACTER(LEN=*), OPTIONAL, INTENT(IN) :: typ    !--- TYPE OF OPERATION
-  CHARACTER(LEN=*), OPTIONAL, INTENT(IN) :: nam    !--- FIELD NAME
-!===============================================================================
-  IF(ierr==nf90_noerr) RETURN
-  IF(.NOT.PRESENT(typ)) THEN
-    CALL ABORT_gcm(modname,nf90_strerror(ierr),ierr)
-  ELSE
-    CALL ABORT_gcm(modname,msg(typ,nam),ierr)
-  END IF
-
-END SUBROUTINE err
-
-!===============================================================================
+  !===============================================================================
+
+  SUBROUTINE dynredem_write_u(ncid, id, var, ll)
+
+    !===============================================================================
+    ! Arguments:
+    INTEGER, INTENT(IN) :: ncid
+    CHARACTER(LEN = *), INTENT(IN) :: id
+    REAL, INTENT(IN) :: var(iip1, jjp1, ll)
+    INTEGER, INTENT(IN) :: ll
+    !===============================================================================
+    ! Local variables:
+    INTEGER :: start(4), count(4)
+    !===============================================================================
+    start(:) = [1, 1, 1, 1]; count(:) = [iip1, jjp1, ll, 1]
+    CALL err(nf90_inq_varid(ncid, id, nvarid), "inq", id)
+    CALL err(nf90_put_var(ncid, nvarid, var, start, count), "put", id)
+
+  END SUBROUTINE dynredem_write_u
+
+  !===============================================================================
+
+
+  !===============================================================================
+
+  SUBROUTINE dynredem_write_v(ncid, id, var, ll)
+
+    !===============================================================================
+    ! Arguments:
+    INTEGER, INTENT(IN) :: ncid
+    CHARACTER(LEN = *), INTENT(IN) :: id
+    REAL, INTENT(IN) :: var(iip1, jjm, ll)
+    INTEGER, INTENT(IN) :: ll
+    !===============================================================================
+    ! Local variables:
+    INTEGER :: start(4), count(4)
+    !===============================================================================
+    start(:) = [1, 1, 1, 1]; count(:) = [iip1, jjm, ll, 1]
+    CALL err(nf90_inq_varid(ncid, id, nvarid), "inq", id)
+    CALL err(nf90_put_var(ncid, nvarid, var, start, count), "put", id)
+
+  END SUBROUTINE dynredem_write_v
+
+  !===============================================================================
+
+
+  !===============================================================================
+
+  SUBROUTINE dynredem_read_u(ncid, id, var, ll)
+
+    !===============================================================================
+    ! Arguments:
+    INTEGER, INTENT(IN) :: ncid
+    CHARACTER(LEN = *), INTENT(IN) :: id
+    REAL, INTENT(OUT) :: var(iip1, jjp1, ll)
+    INTEGER, INTENT(IN) :: ll
+    !===============================================================================
+    ! Local variables:
+    INTEGER :: start(4), count(4)
+    !===============================================================================
+    start(:) = [1, 1, 1, 1]; count(:) = [iip1, jjp1, ll, 1]
+    CALL err(nf90_inq_varid(ncid, id, nvarid), "inq", id)
+    CALL err(nf90_get_var(ncid, nvarid, var, start, count), "get", id)
+
+  END SUBROUTINE dynredem_read_u
+
+  !===============================================================================
+
+
+  !===============================================================================
+
+  SUBROUTINE cre_var(ncid, var, title, did, units)
+
+    !===============================================================================
+    ! Arguments:
+    INTEGER, INTENT(IN) :: ncid
+    CHARACTER(LEN = *), INTENT(IN) :: var, title
+    INTEGER, INTENT(IN) :: did(:)
+    CHARACTER(LEN = *), OPTIONAL, INTENT(IN) :: units
+    !===============================================================================
+    CALL err(nf90_def_var(ncid, var, nf90_format, did, nvarid), "inq", var)
+    IF(title/="")      CALL err(nf90_put_att(ncid, nvarid, "title", title), var)
+    IF(PRESENT(units)) CALL err(nf90_put_att(ncid, nvarid, "units", units), var)
+
+  END SUBROUTINE cre_var
+
+  !===============================================================================
+
+
+  !===============================================================================
+
+  SUBROUTINE put_var1(ncid, var, title, did, v, units)
+
+    !===============================================================================
+    ! Arguments:
+    INTEGER, INTENT(IN) :: ncid
+    CHARACTER(LEN = *), INTENT(IN) :: var, title
+    INTEGER, INTENT(IN) :: did(1)
+    REAL, INTENT(IN) :: v(:)
+    CHARACTER(LEN = *), OPTIONAL, INTENT(IN) :: units
+    !===============================================================================
+    IF(PRESENT(units)) CALL cre_var(ncid, var, title, did, units)
+    IF(.NOT.PRESENT(units)) CALL cre_var(ncid, var, title, did)
+    CALL err(nf90_enddef(ncid))
+    CALL err(nf90_put_var(ncid, nvarid, v), "put", var)
+    CALL err(nf90_redef(ncid))
+
+  END SUBROUTINE put_var1
+
+  !===============================================================================
+
+
+  !===============================================================================
+
+  SUBROUTINE put_var2(ncid, var, title, did, v, units)
+
+    !===============================================================================
+    ! Arguments:
+    INTEGER, INTENT(IN) :: ncid
+    CHARACTER(LEN = *), INTENT(IN) :: var, title
+    INTEGER, INTENT(IN) :: did(2)
+    REAL, INTENT(IN) :: v(:, :)
+    CHARACTER(LEN = *), OPTIONAL, INTENT(IN) :: units
+    !===============================================================================
+    IF(PRESENT(units)) CALL cre_var(ncid, var, title, did, units)
+    IF(.NOT.PRESENT(units)) CALL cre_var(ncid, var, title, did)
+    CALL err(nf90_enddef(ncid))
+    CALL err(nf90_put_var(ncid, nvarid, v), "put", var)
+    CALL err(nf90_redef(ncid))
+
+  END SUBROUTINE put_var2
+
+  !===============================================================================
+
+
+  !===============================================================================
+
+  FUNCTION msg(typ, nam)
+
+    !===============================================================================
+    ! Arguments:
+    CHARACTER(LEN = 256) :: msg    !--- STANDARDIZED MESSAGE
+    CHARACTER(LEN = *), INTENT(IN) :: typ    !--- TYPE OF OPERATION
+    CHARACTER(LEN = *), OPTIONAL, INTENT(IN) :: nam    !--- FIELD NAME
+    !===============================================================================
+    SELECT CASE(typ)
+    CASE('open');  msg = "Opening failed for <" // TRIM(fil) // ">"
+    CASE('close'); msg = "Closing failed for <" // TRIM(fil) // ">"
+    CASE('get');   msg = "Reading failed for <" // TRIM(nam) // ">"
+    CASE('put');   msg = "Writting failed for <" // TRIM(nam) // ">"
+    CASE('inq');   msg = "Missing field <" // TRIM(nam) // ">"
+    CASE('fnd');   msg = "Found field <" // TRIM(nam) // ">"
+    END SELECT
+    msg = TRIM(msg) // " in file <" // TRIM(fil) // ">"
+
+  END FUNCTION msg
+
+  !===============================================================================
+
+
+  !===============================================================================
+
+  SUBROUTINE err(ierr, typ, nam)
+
+    !===============================================================================
+    ! Arguments:
+    INTEGER, INTENT(IN) :: ierr   !--- NetCDF ERROR CODE
+    CHARACTER(LEN = *), OPTIONAL, INTENT(IN) :: typ    !--- TYPE OF OPERATION
+    CHARACTER(LEN = *), OPTIONAL, INTENT(IN) :: nam    !--- FIELD NAME
+    !===============================================================================
+    IF(ierr==nf90_noerr) RETURN
+    IF(.NOT.PRESENT(typ)) THEN
+      CALL ABORT_gcm(modname, nf90_strerror(ierr), ierr)
+    ELSE
+      CALL ABORT_gcm(modname, msg(typ, nam), ierr)
+    END IF
+
+  END SUBROUTINE err
+
+  !===============================================================================
 
 END MODULE dynredem_mod   
Index: /LMDZ6/branches/Amaury_dev/libf/dyn3d/friction.F90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/dyn3d/friction.F90	(revision 5127)
+++ /LMDZ6/branches/Amaury_dev/libf/dyn3d/friction.F90	(revision 5128)
@@ -8,4 +8,6 @@
   USE comconst_mod, ONLY: pi
   USE lmdz_iniprint, ONLY: lunout, prt_level
+
+
   IMPLICIT NONE
 
Index: /LMDZ6/branches/Amaury_dev/libf/dyn3d/gcm.F90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/dyn3d/gcm.F90	(revision 5127)
+++ /LMDZ6/branches/Amaury_dev/libf/dyn3d/gcm.F90	(revision 5128)
@@ -28,4 +28,5 @@
   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
   USE lmdz_iniprint, ONLY: lunout, prt_level
+
 
   IMPLICIT NONE
Index: /LMDZ6/branches/Amaury_dev/libf/dyn3d/groupe.F90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/dyn3d/groupe.F90	(revision 5127)
+++ /LMDZ6/branches/Amaury_dev/libf/dyn3d/groupe.F90	(revision 5128)
@@ -5,4 +5,5 @@
   USE comconst_mod, ONLY: ngroup
   USE lmdz_ssum_scopy, ONLY: scopy
+
 
   IMPLICIT NONE
@@ -105,5 +106,4 @@
   CALL vitvert(zconvmm, wm)
 
-
 END SUBROUTINE  groupe
 
Index: /LMDZ6/branches/Amaury_dev/libf/dyn3d/guide_mod.F90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/dyn3d/guide_mod.F90	(revision 5127)
+++ /LMDZ6/branches/Amaury_dev/libf/dyn3d/guide_mod.F90	(revision 5128)
@@ -16,4 +16,5 @@
           nf90_64bit_offset, nf90_inq_dimid, nf90_inquire_dimension, nf90_put_var
   USE lmdz_pres2lev, ONLY: pres2lev
+
 
   IMPLICIT NONE
@@ -75,4 +76,5 @@
     USE serre_mod, ONLY: grossismx
 
+
     IMPLICIT NONE
 
@@ -355,4 +357,5 @@
     USE comvert_mod, ONLY: ap, bp, preff, presnivs, pressure_exner
     USE lmdz_iniprint, ONLY: lunout, prt_level
+
 
     IMPLICIT NONE
Index: /LMDZ6/branches/Amaury_dev/libf/dyn3d/iniacademic.F90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/dyn3d/iniacademic.F90	(revision 5127)
+++ /LMDZ6/branches/Amaury_dev/libf/dyn3d/iniacademic.F90	(revision 5128)
@@ -19,4 +19,5 @@
   USE lmdz_ran1, ONLY: ran1
   USE lmdz_iniprint, ONLY: lunout, prt_level
+
 
   !   Author:    Frederic Hourdin      original: 15/01/93
Index: /LMDZ6/branches/Amaury_dev/libf/dyn3d/integrd.F90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/dyn3d/integrd.F90	(revision 5127)
+++ /LMDZ6/branches/Amaury_dev/libf/dyn3d/integrd.F90	(revision 5128)
@@ -13,4 +13,5 @@
   USE lmdz_iniprint, ONLY: lunout, prt_level
   USE lmdz_ssum_scopy, ONLY: scopy, ssum
+
 
   IMPLICIT NONE
Index: /LMDZ6/branches/Amaury_dev/libf/dyn3d/leapfrog.F90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/dyn3d/leapfrog.F90	(revision 5127)
+++ /LMDZ6/branches/Amaury_dev/libf/dyn3d/leapfrog.F90	(revision 5128)
@@ -28,4 +28,5 @@
   USE lmdz_iniprint, ONLY: lunout, prt_level
   USE lmdz_ssum_scopy, ONLY: scopy, ssum
+
 
   IMPLICIT NONE
Index: /LMDZ6/branches/Amaury_dev/libf/dyn3d/paramet.h
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/dyn3d/paramet.h	(revision 5127)
+++ /LMDZ6/branches/Amaury_dev/libf/dyn3d/paramet.h	(revision 5128)
@@ -18,5 +18,5 @@
 
       PARAMETER( iip1= iim+1,iip2=iim+2,iip3=iim+3                       &
-     &    ,jjp1=jjm+1-1/jjm)
+          ,jjp1=jjm+1-1/jjm)
       PARAMETER( llmp1 = llm+1,  llmp2 = llm+2, llmm1 = llm-1 )
       PARAMETER( kftd  = iim/2 -ndm )
Index: /LMDZ6/branches/Amaury_dev/libf/dyn3d/replay3d.F90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/dyn3d/replay3d.F90	(revision 5127)
+++ /LMDZ6/branches/Amaury_dev/libf/dyn3d/replay3d.F90	(revision 5128)
@@ -21,4 +21,5 @@
         grossismx, grossismy, dzoomx, dzoomy,taux,tauy
   USE mod_const_mpi, ONLY: comm_lmdz
+
 
   IMPLICIT NONE
Index: /LMDZ6/branches/Amaury_dev/libf/dyn3d/vlspltqs.F90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/dyn3d/vlspltqs.F90	(revision 5127)
+++ /LMDZ6/branches/Amaury_dev/libf/dyn3d/vlspltqs.F90	(revision 5128)
@@ -16,5 +16,5 @@
   !
   ! pente_max facteur de limitation des pentes: 2 en general
-  !                                            0 pour un schema amont
+  !0 pour un schema amont
   ! pbaru,pbarv,w flux de masse en u ,v ,w
   ! pdt pas de temps
Index: /LMDZ6/branches/Amaury_dev/libf/dyn3d/wrgrads.f90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/dyn3d/wrgrads.f90	(revision 5127)
+++ /LMDZ6/branches/Amaury_dev/libf/dyn3d/wrgrads.f90	(revision 5128)
@@ -3,4 +3,6 @@
 subroutine wrgrads(if, nl, field, name, titlevar)
   USE lmdz_formcoord, ONLY: formcoord
+
+
   IMPLICIT NONE
 
Index: /LMDZ6/branches/Amaury_dev/libf/dyn3d_common/comdissip.h
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/dyn3d_common/comdissip.h	(revision 5127)
+++ /LMDZ6/branches/Amaury_dev/libf/dyn3d_common/comdissip.h	(revision 5128)
@@ -6,5 +6,5 @@
 
       COMMON/comdissip/                                                 &
-     &    coefdis,tetavel,tetatemp,gamdissip,niterdis
+          coefdis,tetavel,tetatemp,gamdissip,niterdis
 
 
Index: /LMDZ6/branches/Amaury_dev/libf/dyn3d_common/comdissipn.h
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/dyn3d_common/comdissipn.h	(revision 5127)
+++ /LMDZ6/branches/Amaury_dev/libf/dyn3d_common/comdissipn.h	(revision 5128)
@@ -12,5 +12,5 @@
 
       COMMON/comdissipn/ tetaudiv(llm),tetaurot(llm),tetah(llm)   ,     &
-     &                        cdivu,      crot,         cdivh
+                              cdivu,      crot,         cdivh
 
 !    Les parametres de ce common proviennent des calculs effectues dans 
Index: /LMDZ6/branches/Amaury_dev/libf/dyn3d_common/comdissnew.h
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/dyn3d_common/comdissnew.h	(revision 5127)
+++ /LMDZ6/branches/Amaury_dev/libf/dyn3d_common/comdissnew.h	(revision 5128)
@@ -12,5 +12,5 @@
 
       COMMON/comdissnew/ lstardis,nitergdiv,nitergrot,niterh,tetagdiv,  &
-     &                   tetagrot,tetatemp,coefdis, vert_prof_dissip
+                         tetagrot,tetatemp,coefdis, vert_prof_dissip
 
       LOGICAL lstardis
Index: /LMDZ6/branches/Amaury_dev/libf/dyn3d_common/comgeom.h
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/dyn3d_common/comgeom.h	(revision 5127)
+++ /LMDZ6/branches/Amaury_dev/libf/dyn3d_common/comgeom.h	(revision 5128)
@@ -4,28 +4,28 @@
 !CDK comgeom
       COMMON/comgeom/                                                   &
-     & cu(ip1jmp1),cv(ip1jm),unscu2(ip1jmp1),unscv2(ip1jm),             &
-     & aire(ip1jmp1),airesurg(ip1jmp1),aireu(ip1jmp1),                  &
-     & airev(ip1jm),unsaire(ip1jmp1),apoln,apols,                       &
-     & unsairez(ip1jm),airuscv2(ip1jm),airvscu2(ip1jm),                 &
-     & aireij1(ip1jmp1),aireij2(ip1jmp1),aireij3(ip1jmp1),              &
-     & aireij4(ip1jmp1),alpha1(ip1jmp1),alpha2(ip1jmp1),                &
-     & alpha3(ip1jmp1),alpha4(ip1jmp1),alpha1p2(ip1jmp1),               &
-     & alpha1p4(ip1jmp1),alpha2p3(ip1jmp1),alpha3p4(ip1jmp1),           &
-     & fext(ip1jm),constang(ip1jmp1),rlatu(jjp1),rlatv(jjm),            &
-     & rlonu(iip1),rlonv(iip1),cuvsurcv(ip1jm),cvsurcuv(ip1jm),         &
-     & cvusurcu(ip1jmp1),cusurcvu(ip1jmp1),cuvscvgam1(ip1jm),           &
-     & cuvscvgam2(ip1jm),cvuscugam1(ip1jmp1),                           &
-     & cvuscugam2(ip1jmp1),cvscuvgam(ip1jm),cuscvugam(ip1jmp1),         &
-     & unsapolnga1,unsapolnga2,unsapolsga1,unsapolsga2,                 &
-     & unsair_gam1(ip1jmp1),unsair_gam2(ip1jmp1),unsairz_gam(ip1jm),    &
-     & aivscu2gam(ip1jm),aiuscv2gam(ip1jm),xprimu(iip1),xprimv(iip1)
+       cu(ip1jmp1),cv(ip1jm),unscu2(ip1jmp1),unscv2(ip1jm),             &
+       aire(ip1jmp1),airesurg(ip1jmp1),aireu(ip1jmp1),                  &
+       airev(ip1jm),unsaire(ip1jmp1),apoln,apols,                       &
+       unsairez(ip1jm),airuscv2(ip1jm),airvscu2(ip1jm),                 &
+       aireij1(ip1jmp1),aireij2(ip1jmp1),aireij3(ip1jmp1),              &
+       aireij4(ip1jmp1),alpha1(ip1jmp1),alpha2(ip1jmp1),                &
+       alpha3(ip1jmp1),alpha4(ip1jmp1),alpha1p2(ip1jmp1),               &
+       alpha1p4(ip1jmp1),alpha2p3(ip1jmp1),alpha3p4(ip1jmp1),           &
+       fext(ip1jm),constang(ip1jmp1),rlatu(jjp1),rlatv(jjm),            &
+       rlonu(iip1),rlonv(iip1),cuvsurcv(ip1jm),cvsurcuv(ip1jm),         &
+       cvusurcu(ip1jmp1),cusurcvu(ip1jmp1),cuvscvgam1(ip1jm),           &
+       cuvscvgam2(ip1jm),cvuscugam1(ip1jmp1),                           &
+       cvuscugam2(ip1jmp1),cvscuvgam(ip1jm),cuscvugam(ip1jmp1),         &
+       unsapolnga1,unsapolnga2,unsapolsga1,unsapolsga2,                 &
+       unsair_gam1(ip1jmp1),unsair_gam2(ip1jmp1),unsairz_gam(ip1jm),    &
+       aivscu2gam(ip1jm),aiuscv2gam(ip1jm),xprimu(iip1),xprimv(iip1)
 
         REAL                                                            &
-     & cu,cv,unscu2,unscv2,aire,airesurg,aireu,airev,unsaire,apoln     ,&
-     & apols,unsairez,airuscv2,airvscu2,aireij1,aireij2,aireij3,aireij4,&
-     & alpha1,alpha2,alpha3,alpha4,alpha1p2,alpha1p4,alpha2p3,alpha3p4 ,&
-     & fext,constang,rlatu,rlatv,rlonu,rlonv,cuvscvgam1,cuvscvgam2     ,&
-     & cvuscugam1,cvuscugam2,cvscuvgam,cuscvugam,unsapolnga1,unsapolnga2&
-     & ,unsapolsga1,unsapolsga2,unsair_gam1,unsair_gam2,unsairz_gam    ,&
-     & aivscu2gam ,aiuscv2gam,cuvsurcv,cvsurcuv,cvusurcu,cusurcvu,xprimu&
-     & , xprimv
+       cu,cv,unscu2,unscv2,aire,airesurg,aireu,airev,unsaire,apoln     ,&
+       apols,unsairez,airuscv2,airvscu2,aireij1,aireij2,aireij3,aireij4,&
+       alpha1,alpha2,alpha3,alpha4,alpha1p2,alpha1p4,alpha2p3,alpha3p4 ,&
+       fext,constang,rlatu,rlatv,rlonu,rlonv,cuvscvgam1,cuvscvgam2     ,&
+       cvuscugam1,cvuscugam2,cvscuvgam,cuscvugam,unsapolnga1,unsapolnga2&
+       ,unsapolsga1,unsapolsga2,unsair_gam1,unsair_gam2,unsairz_gam    ,&
+       aivscu2gam ,aiuscv2gam,cuvsurcv,cvsurcuv,cvusurcu,cusurcvu,xprimu&
+       , xprimv
Index: /LMDZ6/branches/Amaury_dev/libf/dyn3d_common/comgeom2.h
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/dyn3d_common/comgeom2.h	(revision 5127)
+++ /LMDZ6/branches/Amaury_dev/libf/dyn3d_common/comgeom2.h	(revision 5128)
@@ -4,30 +4,30 @@
 !CDK comgeom2
       COMMON/comgeom/                                                   &
-     & cu(iip1,jjp1),cv(iip1,jjm),unscu2(iip1,jjp1),unscv2(iip1,jjm)  , &
-     & aire(iip1,jjp1),airesurg(iip1,jjp1),aireu(iip1,jjp1)           , &
-     & airev(iip1,jjm),unsaire(iip1,jjp1),apoln,apols                 , &
-     & unsairez(iip1,jjm),airuscv2(iip1,jjm),airvscu2(iip1,jjm)       , &
-     & aireij1(iip1,jjp1),aireij2(iip1,jjp1),aireij3(iip1,jjp1)       , &
-     & aireij4(iip1,jjp1),alpha1(iip1,jjp1),alpha2(iip1,jjp1)         , &
-     & alpha3(iip1,jjp1),alpha4(iip1,jjp1),alpha1p2(iip1,jjp1)        , &
-     & alpha1p4(iip1,jjp1),alpha2p3(iip1,jjp1),alpha3p4(iip1,jjp1)    , &
-     & fext(iip1,jjm),constang(iip1,jjp1), rlatu(jjp1),rlatv(jjm),      &
-     & rlonu(iip1),rlonv(iip1),cuvsurcv(iip1,jjm),cvsurcuv(iip1,jjm)  , &
-     & cvusurcu(iip1,jjp1),cusurcvu(iip1,jjp1)                        , &
-     & cuvscvgam1(iip1,jjm),cuvscvgam2(iip1,jjm),cvuscugam1(iip1,jjp1), &
-     & cvuscugam2(iip1,jjp1),cvscuvgam(iip1,jjm),cuscvugam(iip1,jjp1) , &
-     & unsapolnga1,unsapolnga2,unsapolsga1,unsapolsga2                , &
-     & unsair_gam1(iip1,jjp1),unsair_gam2(iip1,jjp1)                  , &
-     & unsairz_gam(iip1,jjm),aivscu2gam(iip1,jjm),aiuscv2gam(iip1,jjm)  &
-     & , xprimu(iip1),xprimv(iip1)
+       cu(iip1,jjp1),cv(iip1,jjm),unscu2(iip1,jjp1),unscv2(iip1,jjm)  , &
+       aire(iip1,jjp1),airesurg(iip1,jjp1),aireu(iip1,jjp1)           , &
+       airev(iip1,jjm),unsaire(iip1,jjp1),apoln,apols                 , &
+       unsairez(iip1,jjm),airuscv2(iip1,jjm),airvscu2(iip1,jjm)       , &
+       aireij1(iip1,jjp1),aireij2(iip1,jjp1),aireij3(iip1,jjp1)       , &
+       aireij4(iip1,jjp1),alpha1(iip1,jjp1),alpha2(iip1,jjp1)         , &
+       alpha3(iip1,jjp1),alpha4(iip1,jjp1),alpha1p2(iip1,jjp1)        , &
+       alpha1p4(iip1,jjp1),alpha2p3(iip1,jjp1),alpha3p4(iip1,jjp1)    , &
+       fext(iip1,jjm),constang(iip1,jjp1), rlatu(jjp1),rlatv(jjm),      &
+       rlonu(iip1),rlonv(iip1),cuvsurcv(iip1,jjm),cvsurcuv(iip1,jjm)  , &
+       cvusurcu(iip1,jjp1),cusurcvu(iip1,jjp1)                        , &
+       cuvscvgam1(iip1,jjm),cuvscvgam2(iip1,jjm),cvuscugam1(iip1,jjp1), &
+       cvuscugam2(iip1,jjp1),cvscuvgam(iip1,jjm),cuscvugam(iip1,jjp1) , &
+       unsapolnga1,unsapolnga2,unsapolsga1,unsapolsga2                , &
+       unsair_gam1(iip1,jjp1),unsair_gam2(iip1,jjp1)                  , &
+       unsairz_gam(iip1,jjm),aivscu2gam(iip1,jjm),aiuscv2gam(iip1,jjm)  &
+       , xprimu(iip1),xprimv(iip1)
 
 
       REAL                                                               &
-     & cu,cv,unscu2,unscv2,aire,airesurg,aireu,airev,apoln,apols,unsaire &
-     & ,unsairez,airuscv2,airvscu2,aireij1,aireij2,aireij3,aireij4     , &
-     & alpha1,alpha2,alpha3,alpha4,alpha1p2,alpha1p4,alpha2p3,alpha3p4 , &
-     & fext,constang,rlatu,rlatv,rlonu,rlonv,cuvscvgam1,cuvscvgam2     , &
-     & cvuscugam1,cvuscugam2,cvscuvgam,cuscvugam,unsapolnga1           , &
-     & unsapolnga2,unsapolsga1,unsapolsga2,unsair_gam1,unsair_gam2     , &
-     & unsairz_gam,aivscu2gam,aiuscv2gam,cuvsurcv,cvsurcuv,cvusurcu    , &
-     & cusurcvu,xprimu,xprimv
+       cu,cv,unscu2,unscv2,aire,airesurg,aireu,airev,apoln,apols,unsaire &
+       ,unsairez,airuscv2,airvscu2,aireij1,aireij2,aireij3,aireij4     , &
+       alpha1,alpha2,alpha3,alpha4,alpha1p2,alpha1p4,alpha2p3,alpha3p4 , &
+       fext,constang,rlatu,rlatv,rlonu,rlonv,cuvscvgam1,cuvscvgam2     , &
+       cvuscugam1,cvuscugam2,cvscuvgam,cuscvugam,unsapolnga1           , &
+       unsapolnga2,unsapolsga1,unsapolsga2,unsair_gam1,unsair_gam2     , &
+       unsairz_gam,aivscu2gam,aiuscv2gam,cuvsurcv,cvsurcuv,cvusurcu    , &
+       cusurcvu,xprimu,xprimv
Index: /LMDZ6/branches/Amaury_dev/libf/dyn3d_common/disvert.F90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/dyn3d_common/disvert.F90	(revision 5127)
+++ /LMDZ6/branches/Amaury_dev/libf/dyn3d_common/disvert.F90	(revision 5128)
@@ -10,4 +10,5 @@
   USE logic_mod, ONLY: ok_strato
   USE lmdz_iniprint, ONLY: lunout, prt_level
+
 
   IMPLICIT NONE
Index: /LMDZ6/branches/Amaury_dev/libf/dyn3d_common/exner_hyb_m.F90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/dyn3d_common/exner_hyb_m.F90	(revision 5127)
+++ /LMDZ6/branches/Amaury_dev/libf/dyn3d_common/exner_hyb_m.F90	(revision 5128)
@@ -35,6 +35,6 @@
     USE comconst_mod, ONLY: jmp1, cpp, kappa, r
     USE comvert_mod, ONLY: preff
-    USE lmdz_filtreg, ONLY: filtreg
-    
+    USE lmdz_filtreg, ONLY: filtreg ! < TODO if we uncomment this, compilation fails in 1D because 1D doesn't have the filtrez/ sources... But why does it even compile in the first place when it's commented ? ...
+
     IMPLICIT NONE
     
Index: /LMDZ6/branches/Amaury_dev/libf/dyn3d_common/exner_milieu_m.F90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/dyn3d_common/exner_milieu_m.F90	(revision 5127)
+++ /LMDZ6/branches/Amaury_dev/libf/dyn3d_common/exner_milieu_m.F90	(revision 5128)
@@ -33,4 +33,5 @@
     USE comvert_mod, ONLY: preff
     USE lmdz_filtreg, ONLY: filtreg
+
     
     IMPLICIT NONE
Index: /LMDZ6/branches/Amaury_dev/libf/dyn3d_common/grilles_gcm_netcdf_sub.F90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/dyn3d_common/grilles_gcm_netcdf_sub.F90	(revision 5127)
+++ /LMDZ6/branches/Amaury_dev/libf/dyn3d_common/grilles_gcm_netcdf_sub.F90	(revision 5128)
@@ -234,4 +234,5 @@
   USE netcdf, ONLY: nf90_strerror
 
+
   INTEGER status
   IF (status/=nf90_noerr) THEN
Index: /LMDZ6/branches/Amaury_dev/libf/dyn3d_common/infotrac.F90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/dyn3d_common/infotrac.F90	(revision 5127)
+++ /LMDZ6/branches/Amaury_dev/libf/dyn3d_common/infotrac.F90	(revision 5128)
@@ -7,4 +7,6 @@
           delPhase, niso, getKey, isot_type, processIsotopes, isotope, maxTableWidth, iqIsoPha, nphas, ixIso, isoPhas, &
           addPhase, iH2O, addKey, isoSelect, testTracersFiles, isoKeys, indexUpdate, iqWIsoPha, nbIso, ntiso, isoName, isoCheck
+
+
   IMPLICIT NONE
 
@@ -119,4 +121,5 @@
     USE lmdz_cppkeys_wrapper, ONLY: CPPKEY_INCA, CPPKEY_STRATAER
     USE lmdz_iniprint, ONLY: lunout, prt_level
+
     IMPLICIT NONE
     !==============================================================================================================================
Index: /LMDZ6/branches/Amaury_dev/libf/dyn3d_common/iniconst.F90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/dyn3d_common/iniconst.F90	(revision 5127)
+++ /LMDZ6/branches/Amaury_dev/libf/dyn3d_common/iniconst.F90	(revision 5128)
@@ -9,4 +9,5 @@
   USE comvert_mod, ONLY: disvert_type, pressure_exner
   USE lmdz_iniprint, ONLY: lunout, prt_level
+
 
   IMPLICIT NONE
Index: /LMDZ6/branches/Amaury_dev/libf/dyn3d_common/inidissip.F90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/dyn3d_common/inidissip.F90	(revision 5127)
+++ /LMDZ6/branches/Amaury_dev/libf/dyn3d_common/inidissip.F90	(revision 5128)
@@ -18,4 +18,5 @@
   USE lmdz_ran1, ONLY: ran1
   USE lmdz_iniprint, ONLY: lunout, prt_level
+
 
   IMPLICIT NONE
Index: DZ6/branches/Amaury_dev/libf/dyn3dmem/abort_gcm.f90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/dyn3dmem/abort_gcm.f90	(revision 5127)
+++ 	(revision )
@@ -1,52 +1,0 @@
-
-! $Id: abort_gcm.F 1747 2013-04-23 14:06:30Z lguez $
-
-!
-!
-SUBROUTINE abort_gcm(modname, message, ierr)
-
-  USE IOIPSL
-  USE parallel_lmdz
-  USE lmdz_iniprint, ONLY: lunout, prt_level
-
-  !
-  ! Stops the simulation cleanly, closing files and printing various
-  ! comments
-  !
-  !  Input: modname = name of calling program
-  !     message = stuff to print
-  !     ierr    = severity of situation ( = 0 normal )
-
-  CHARACTER(LEN=*), INTENT(IN):: modname
-  INTEGER :: ierr, ierror_mpi
-  CHARACTER(LEN=*), INTENT(IN):: message
-
-  WRITE(lunout,*) 'in abort_gcm'
-!$OMP MASTER
-  CALL histclo
-  CALL restclo
-  IF (MPI_rank == 0) THEN
-     CALL getin_dump
-  ENDIF
-!$OMP END MASTER
-  ! CALL histclo(2)
-  ! CALL histclo(3)
-  ! CALL histclo(4)
-  ! CALL histclo(5)
-  WRITE(lunout,*) 'Stopping in ', modname
-  WRITE(lunout,*) 'Reason = ',message
-  IF (ierr == 0) THEN
-    WRITE(lunout,*) 'Everything is cool'
-  else
-    WRITE(lunout,*) 'Houston, we have a problem, ierr = ', ierr
-
-    IF (using_mpi) THEN
-!$OMP CRITICAL (MPI_ABORT_GCM)
-      CALL MPI_ABORT(COMM_LMDZ, 1, ierror_mpi)
-!$OMP END CRITICAL (MPI_ABORT_GCM)
-    else
-     stop 1
-    endif
-
-  ENDIF
-END SUBROUTINE abort_gcm
Index: /LMDZ6/branches/Amaury_dev/libf/dyn3dmem/advtrac_loc.f90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/dyn3dmem/advtrac_loc.f90	(revision 5127)
+++ /LMDZ6/branches/Amaury_dev/libf/dyn3dmem/advtrac_loc.f90	(revision 5128)
@@ -22,4 +22,5 @@
   USE lmdz_libmath, ONLY: minmax
 
+
   IMPLICIT NONE
 
Index: /LMDZ6/branches/Amaury_dev/libf/dyn3dmem/bilan_dyn_loc.f90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/dyn3dmem/bilan_dyn_loc.f90	(revision 5127)
+++ /LMDZ6/branches/Amaury_dev/libf/dyn3dmem/bilan_dyn_loc.f90	(revision 5128)
@@ -19,4 +19,5 @@
   USE temps_mod, ONLY: annee_ref, day_ref, itau_dyn
   USE lmdz_iniprint, ONLY: lunout, prt_level
+
 
   IMPLICIT NONE
Index: /LMDZ6/branches/Amaury_dev/libf/dyn3dmem/check_isotopes_loc.F90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/dyn3dmem/check_isotopes_loc.F90	(revision 5127)
+++ /LMDZ6/branches/Amaury_dev/libf/dyn3dmem/check_isotopes_loc.F90	(revision 5128)
@@ -4,4 +4,6 @@
    USE infotrac,    ONLY: nqtot, niso, nphas, isotope, isoCheck, iqIsoPha, isoSelect, &
                           ntiso, iH2O, nzone, tracers, isoName,  itZonIso, getKey
+
+
    IMPLICIT NONE
    include "dimensions.h"
Index: /LMDZ6/branches/Amaury_dev/libf/dyn3dmem/conf_gcm.F90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/dyn3dmem/conf_gcm.F90	(revision 5127)
+++ /LMDZ6/branches/Amaury_dev/libf/dyn3dmem/conf_gcm.F90	(revision 5128)
@@ -22,4 +22,5 @@
   USE temps_mod, ONLY: calend, year_len, offline_time
   USE lmdz_iniprint, ONLY: lunout, prt_level
+
 
   IMPLICIT NONE
Index: /LMDZ6/branches/Amaury_dev/libf/dyn3dmem/dynetat0_loc.F90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/dyn3dmem/dynetat0_loc.F90	(revision 5127)
+++ /LMDZ6/branches/Amaury_dev/libf/dyn3dmem/dynetat0_loc.F90	(revision 5128)
@@ -23,4 +23,5 @@
   USE lmdz_description, ONLY: descript
   USE lmdz_iniprint, ONLY: lunout, prt_level
+
 
   IMPLICIT NONE
Index: /LMDZ6/branches/Amaury_dev/libf/dyn3dmem/dynredem_mod.F90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/dyn3dmem/dynredem_mod.F90	(revision 5127)
+++ /LMDZ6/branches/Amaury_dev/libf/dyn3dmem/dynredem_mod.F90	(revision 5128)
@@ -250,5 +250,4 @@
 SUBROUTINE err(ierr,typ,nam)
 
-!===============================================================================
   IMPLICIT NONE
 !===============================================================================
Index: /LMDZ6/branches/Amaury_dev/libf/dyn3dmem/exner_hyb_loc_m.F90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/dyn3dmem/exner_hyb_loc_m.F90	(revision 5127)
+++ /LMDZ6/branches/Amaury_dev/libf/dyn3dmem/exner_hyb_loc_m.F90	(revision 5128)
@@ -37,4 +37,5 @@
     USE comvert_mod, ONLY: preff
     USE lmdz_cppkeys_wrapper, ONLY: CPPKEY_DEBUGIO
+
 
     IMPLICIT NONE
Index: /LMDZ6/branches/Amaury_dev/libf/dyn3dmem/exner_milieu_loc_m.F90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/dyn3dmem/exner_milieu_loc_m.F90	(revision 5127)
+++ /LMDZ6/branches/Amaury_dev/libf/dyn3dmem/exner_milieu_loc_m.F90	(revision 5128)
@@ -33,4 +33,5 @@
     USE comconst_mod, ONLY: cpp, kappa, r, jmp1
     USE comvert_mod, ONLY: preff
+
     
     IMPLICIT NONE
Index: DZ6/branches/Amaury_dev/libf/dyn3dmem/filtreg_p.F90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/dyn3dmem/filtreg_p.F90	(revision 5127)
+++ 	(revision )
@@ -1,427 +1,0 @@
-! Amaury: on a ce fichier + lmdz_filtreg_p ! C'est totalement incompréhensible ;_;
-! A minima il faut un nom clair pour chaque
-
-SUBROUTINE filtreg_p( champ, ibeg, iend, nlat, nbniv, &
-        ifiltre, iaire, griscal ,iter)
-  USE parallel_lmdz, ONLY: OMP_CHUNK
-  USE lmdz_filtre_fft, ONLY: use_filtre_fft, filtre_u_fft, filtre_v_fft, filtre_inv_fft
-  USE lmdz_timer_filtre, ONLY: init_timer, start_timer, stop_timer
-  USE lmdz_coefils, ONLY: jfiltnu, jfiltnv, jfiltsu, jfiltsv, sddu, sddv, unsddu, unsddv, modfrstv, modfrstu
-  USE lmdz_filtreg, ONLY: matrinvn, matrinvs, matriceun, matriceus, matricevn, matricevs
-
-  IMPLICIT NONE
-
-  !=======================================================================
-  !
-  !   Auteur: P. Le Van        07/10/97
-  !   ------
-  !
-  !   Objet: filtre matriciel longitudinal ,avec les matrices precalculees
-  !                 pour l'operateur  Filtre    .
-  !   ------
-  !
-  !   Arguments:
-  !   ----------
-  !
-  !
-  !  ibeg..iend            lattitude a filtrer
-  !  nlat                  nombre de latitudes du champ
-  !  nbniv                 nombre de niveaux verticaux a filtrer
-  !  champ(iip1,nblat,nbniv)  en entree : champ a filtrer
-  !                        en sortie : champ filtre
-  !  ifiltre               +1  Transformee directe
-  !                        -1  Transformee inverse
-  !                        +2  Filtre directe
-  !                        -2  Filtre inverse
-  !
-  !  iaire                 1   si champ intensif
-  !                        2   si champ extensif (pondere par les aires)
-  !
-  !  iter                  1   filtre simple
-  !
-  !=======================================================================
-  !
-  !
-  !                  Variable Intensive
-  !            ifiltre = 1     filtre directe
-  !            ifiltre =-1     filtre inverse
-  !
-  !                  Variable Extensive
-  !            ifiltre = 2     filtre directe
-  !            ifiltre =-2     filtre inverse
-  !
-  !
-  INCLUDE "dimensions.h"
-  INCLUDE "paramet.h"
-
-  INTEGER :: ibeg,iend,nlat,nbniv,ifiltre,iter
-  INTEGER :: i,j,l,k
-  INTEGER :: iim2,immjm
-  INTEGER :: jdfil1,jdfil2,jffil1,jffil2,jdfil,jffil
-
-  REAL :: champ( iip1,nlat,nbniv)
-
-  LOGICAL :: griscal
-  INTEGER :: hemisph, iaire
-
-  REAL :: champ_fft(iip1,nlat,nbniv)
-  REAL :: champ_in(iip1,nlat,nbniv)
-
-  LOGICAL,SAVE     :: first=.TRUE.
-!$OMP THREADPRIVATE(first)
-
-  REAL, DIMENSION(iip1,nlat,nbniv) :: champ_loc
-  INTEGER :: ll_nb, nbniv_loc
-  REAL, SAVE :: sdd12(iim,4)
-!$OMP THREADPRIVATE(sdd12)
-
-  INTEGER, PARAMETER :: type_sddu=1
-  INTEGER, PARAMETER :: type_sddv=2
-  INTEGER, PARAMETER :: type_unsddu=3
-  INTEGER, PARAMETER :: type_unsddv=4
-
-  INTEGER :: sdd1_type, sdd2_type
-
-  IF (first) THEN
-     sdd12(1:iim,type_sddu) = sddu(1:iim)
-     sdd12(1:iim,type_sddv) = sddv(1:iim)
-     sdd12(1:iim,type_unsddu) = unsddu(1:iim)
-     sdd12(1:iim,type_unsddv) = unsddv(1:iim)
-
-     CALL Init_timer
-     first=.FALSE.
-  ENDIF
-
-!$OMP MASTER
-  CALL start_timer
-!$OMP END MASTER
-
-  !-------------------------------------------------------c
-
-  IF(ifiltre==1.OR.ifiltre==-1) &
-        CALL abort_gcm("fitreg_p","Pas de transformee simple&
-        &dans cette version",1)
-
-  IF( iter== 2 )  THEN
-     PRINT *,' Pas d iteration du filtre dans cette version !'&
-           &        , ' Utiliser old_filtreg et repasser !'
-     CALL abort_gcm("fitreg_p","stopped",1)
-  ENDIF
-
-  IF( ifiltre== -2 .AND..NOT.griscal )     THEN
-     PRINT *,' Cette routine ne calcule le filtre inverse que ' &
-           , ' sur la grille des scalaires !'
-     CALL abort_gcm("fitreg_p","stopped",1)
-  ENDIF
-
-  IF( ifiltre/=2 .AND.ifiltre/= - 2 )  THEN
-     PRINT *,' Probleme dans filtreg car ifiltre NE 2 et NE -2' &
-           , ' corriger et repasser !'
-     CALL abort_gcm("fitreg_p","stopped",1)
-   ENDIF
-  !
-
-  iim2   = iim * iim
-  immjm  = iim * jjm
-  !
-  !
-  IF( griscal )   THEN
-     IF( nlat /= jjp1 )  THEN
-        CALL abort_gcm("fitreg_p","nlat. NE. jjp1",1)
-     ELSE
-  !
-        IF( iaire==1 )  THEN
-           sdd1_type = type_sddv
-           sdd2_type = type_unsddv
-        ELSE
-           sdd1_type = type_unsddv
-           sdd2_type = type_sddv
-        ENDIF
-  !
-        jdfil1 = 2
-        jffil1 = jfiltnu
-        jdfil2 = jfiltsu
-        jffil2 = jjm
-     ENDIF
-  ELSE
-     IF( nlat/=jjm )  THEN
-        CALL abort_gcm("fitreg_p","nlat. NE. jjm",1)
-     ELSE
-  !
-        IF( iaire==1 )  THEN
-           sdd1_type = type_sddu
-           sdd2_type = type_unsddu
-        ELSE
-           sdd1_type = type_unsddu
-           sdd2_type = type_sddu
-        ENDIF
-  !
-        jdfil1 = 1
-        jffil1 = jfiltnv
-        jdfil2 = jfiltsv
-        jffil2 = jjm
-     ENDIF
-  ENDIF
-  !
-  DO hemisph = 1, 2
-  !
-     IF ( hemisph==1 )  THEN
-  !ym
-        jdfil = max(jdfil1,ibeg)
-        jffil = min(jffil1,iend)
-     ELSE
-  !ym
-        jdfil = max(jdfil2,ibeg)
-        jffil = min(jffil2,iend)
-     ENDIF
-
-
-  !ccccccccccccccccccccccccccccccccccccccccccc
-  ! Utilisation du filtre classique
-  !ccccccccccccccccccccccccccccccccccccccccccc
-
-     IF (.NOT. use_filtre_fft) THEN
-
-  !---------------------------------!
-  ! Agregation des niveau verticaux !
-  ! uniquement necessaire pour une  !
-  ! execution OpenMP                !
-  !---------------------------------!
-        ll_nb = 0
-!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
-        DO l = 1, nbniv
-           ll_nb = ll_nb+1
-           DO j = jdfil,jffil
-              DO i = 1, iim
-                 champ_loc(i,j,ll_nb) = &
-                       champ(i,j,l) * sdd12(i,sdd1_type)
-              ENDDO
-           ENDDO
-        ENDDO
-!$OMP END DO NOWAIT
-
-        nbniv_loc = ll_nb
-
-        IF( hemisph==1 )      THEN
-
-           IF( ifiltre==-2 )   THEN
-              DO j = jdfil,jffil
-#ifdef BLAS
-                 CALL DGEMM("N", "N", iim, nbniv_loc, iim, 1.0, &
-                       matrinvn(1,1,j), iim, &
-                       champ_loc(1,j,1), iip1*nlat, 0.0, &
-                       champ_fft(1,j-jdfil+1,1), iip1*nlat)
-#else
-                 champ_fft(:iim,j-jdfil+1,:) &
-                       =matmul(matrinvn(:,:,j),champ_loc(:iim,j,:))
-#endif
-              ENDDO
-
-           ELSE IF ( griscal )     THEN
-              DO j = jdfil,jffil
-#ifdef BLAS
-                 CALL DGEMM("N", "N", iim, nbniv_loc, iim, 1.0, &
-                       matriceun(1,1,j), iim, &
-                       champ_loc(1,j,1), iip1*nlat, 0.0, &
-                       champ_fft(1,j-jdfil+1,1), iip1*nlat)
-#else
-                 champ_fft(:iim,j-jdfil+1,:) &
-                       =matmul(matriceun(:,:,j),champ_loc(:iim,j,:))
-#endif
-              ENDDO
-
-           ELSE
-              DO j = jdfil,jffil
-#ifdef BLAS
-                 CALL DGEMM("N", "N", iim, nbniv_loc, iim, 1.0, &
-                       matricevn(1,1,j), iim, &
-                       champ_loc(1,j,1), iip1*nlat, 0.0, &
-                       champ_fft(1,j-jdfil+1,1), iip1*nlat)
-#else
-                 champ_fft(:iim,j-jdfil+1,:) &
-                       =matmul(matricevn(:,:,j),champ_loc(:iim,j,:))
-#endif
-              ENDDO
-
-           ENDIF
-
-        ELSE
-
-           IF( ifiltre==-2 )   THEN
-              DO j = jdfil,jffil
-#ifdef BLAS
-                 CALL DGEMM("N", "N", iim, nbniv_loc, iim, 1.0, &
-                       matrinvs(1,1,j-jfiltsu+1), iim, &
-                       champ_loc(1,j,1), iip1*nlat, 0.0, &
-                       champ_fft(1,j-jdfil+1,1), iip1*nlat)
-#else
-                 champ_fft(:iim,j-jdfil+1,:) &
-                       =matmul(matrinvs(:,:,j-jfiltsu+1), &
-                       champ_loc(:iim,j,:))
-#endif
-              ENDDO
-
-           ELSE IF ( griscal )     THEN
-
-              DO j = jdfil,jffil
-#ifdef BLAS
-                 CALL DGEMM("N", "N", iim, nbniv_loc, iim, 1.0, &
-                       matriceus(1,1,j-jfiltsu+1), iim, &
-                       champ_loc(1,j,1), iip1*nlat, 0.0, &
-                       champ_fft(1,j-jdfil+1,1), iip1*nlat)
-#else
-                 champ_fft(:iim,j-jdfil+1,:) &
-                       =matmul(matriceus(:,:,j-jfiltsu+1), &
-                       champ_loc(:iim,j,:))
-#endif
-              ENDDO
-
-           ELSE
-
-              DO j = jdfil,jffil
-#ifdef BLAS
-                 CALL DGEMM("N", "N", iim, nbniv_loc, iim, 1.0, &
-                       matricevs(1,1,j-jfiltsv+1), iim, &
-                       champ_loc(1,j,1), iip1*nlat, 0.0, &
-                       champ_fft(1,j-jdfil+1,1), iip1*nlat)
-#else
-                 champ_fft(:iim,j-jdfil+1,:) &
-                       =matmul(matricevs(:,:,j-jfiltsv+1), &
-                       champ_loc(:iim,j,:))
-#endif
-              ENDDO
-
-           ENDIF
-
-        ENDIF
-  ! c
-        IF( ifiltre==2 )  THEN
-
-  !-------------------------------------!
-  ! Dés-agregation des niveau verticaux !
-  ! uniquement necessaire pour une      !
-  ! execution OpenMP                    !
-  !-------------------------------------!
-           ll_nb = 0
-!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
-           DO l = 1, nbniv
-              ll_nb = ll_nb + 1
-              DO j = jdfil,jffil
-                 DO i = 1, iim
-                    champ( i,j,l ) = (champ_loc(i,j,ll_nb) &
-                          + champ_fft(i,j-jdfil+1,ll_nb)) &
-                          * sdd12(i,sdd2_type)
-                 ENDDO
-              ENDDO
-           ENDDO
-!$OMP END DO NOWAIT
-
-        ELSE
-
-           ll_nb = 0
-!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
-           DO l = 1, nbniv_loc
-              ll_nb = ll_nb + 1
-              DO j = jdfil,jffil
-                 DO i = 1, iim
-                    champ( i,j,l ) = (champ_loc(i,j,ll_nb) &
-                          - champ_fft(i,j-jdfil+1,ll_nb)) &
-                          * sdd12(i,sdd2_type)
-                 ENDDO
-              ENDDO
-           ENDDO
-!$OMP END DO NOWAIT
-
-        ENDIF
-
-!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
-        DO l = 1, nbniv
-           DO j = jdfil,jffil
-              champ( iip1,j,l ) = champ( 1,j,l )
-           ENDDO
-        ENDDO
-!$OMP END DO NOWAIT
-
-  !cccccccccccccccccccccccccccccccccccccccccccc
-  ! Utilisation du filtre FFT
-  !cccccccccccccccccccccccccccccccccccccccccccc
-
-     ELSE
-
-!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
-        DO l=1,nbniv
-           DO j=jdfil,jffil
-              DO  i = 1, iim
-                 champ( i,j,l)= champ(i,j,l)*sdd12(i,sdd1_type)
-                 champ_fft( i,j,l) = champ(i,j,l)
-              ENDDO
-           ENDDO
-        ENDDO
-!$OMP END DO NOWAIT
-
-        IF (jdfil<=jffil) THEN
-           IF( ifiltre == -2 )   THEN
-              CALL Filtre_inv_fft(champ_fft,nlat,jdfil,jffil,nbniv)
-           ELSE IF ( griscal )     THEN
-              CALL Filtre_u_fft(champ_fft,nlat,jdfil,jffil,nbniv)
-           ELSE
-              CALL Filtre_v_fft(champ_fft,nlat,jdfil,jffil,nbniv)
-           ENDIF
-        ENDIF
-
-
-        IF( ifiltre== 2 )  THEN
-!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
-           DO l=1,nbniv
-              DO j=jdfil,jffil
-                 DO  i = 1, iim
-                    champ( i,j,l)=(champ(i,j,l)+champ_fft(i,j,l)) &
-                          *sdd12(i,sdd2_type)
-                 ENDDO
-              ENDDO
-           ENDDO
-!$OMP END DO NOWAIT	
-        ELSE
-
-!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
-           DO l=1,nbniv
-              DO j=jdfil,jffil
-                 DO  i = 1, iim
-                    champ(i,j,l)=(champ(i,j,l)-champ_fft(i,j,l)) &
-                          *sdd12(i,sdd2_type)
-                 ENDDO
-              ENDDO
-           ENDDO
-!$OMP END DO NOWAIT
-        ENDIF
-  !
-!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
-        DO l=1,nbniv
-           DO j=jdfil,jffil
-         ! champ_FFT( iip1,j,l ) = champ_FFT( 1,j,l )
-              champ( iip1,j,l ) = champ( 1,j,l )
-           ENDDO
-        ENDDO
-!$OMP END DO NOWAIT          	
-     ENDIF
-  ! Fin de la zone de filtrage
-
-
-  ENDDO
-
-   ! DO j=1,nlat
-
-   !     PRINT *,"check FFT ----> Delta(",j,")=",
-  ! &            sum(champ(:,j,:)-champ_fft(:,j,:))/sum(champ(:,j,:)),
-  ! &            sum(champ(:,j,:)-champ_in(:,j,:))/sum(champ(:,j,:))
-  !  ENDDO
-
-  !      PRINT *,"check FFT ----> Delta(",j,")=",
-  ! &            sum(champ-champ_fft)/sum(champ)
-
-  !
-!$OMP MASTER
-  CALL stop_timer
-!$OMP END MASTER
-
-END SUBROUTINE filtreg_p
Index: /LMDZ6/branches/Amaury_dev/libf/dyn3dmem/friction_loc.f90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/dyn3dmem/friction_loc.f90	(revision 5127)
+++ /LMDZ6/branches/Amaury_dev/libf/dyn3dmem/friction_loc.f90	(revision 5128)
@@ -8,4 +8,6 @@
   USE comconst_mod, ONLY: pi
   USE lmdz_iniprint, ONLY: lunout, prt_level
+
+
   IMPLICIT NONE
 
Index: /LMDZ6/branches/Amaury_dev/libf/dyn3dmem/gcm.F90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/dyn3dmem/gcm.F90	(revision 5127)
+++ /LMDZ6/branches/Amaury_dev/libf/dyn3dmem/gcm.F90	(revision 5128)
@@ -27,4 +27,5 @@
   USE lmdz_description, ONLY: descript
   USE lmdz_iniprint, ONLY: lunout, prt_level
+
 
   IMPLICIT NONE
Index: /LMDZ6/branches/Amaury_dev/libf/dyn3dmem/guide_loc_mod.F90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/dyn3dmem/guide_loc_mod.F90	(revision 5127)
+++ /LMDZ6/branches/Amaury_dev/libf/dyn3dmem/guide_loc_mod.F90	(revision 5128)
@@ -15,4 +15,5 @@
   USE parallel_lmdz
   USE lmdz_pres2lev, ONLY: pres2lev
+
 
   IMPLICIT NONE
Index: /LMDZ6/branches/Amaury_dev/libf/dyn3dmem/iniacademic_loc.F90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/dyn3dmem/iniacademic_loc.F90	(revision 5127)
+++ /LMDZ6/branches/Amaury_dev/libf/dyn3dmem/iniacademic_loc.F90	(revision 5128)
@@ -20,4 +20,5 @@
   USE lmdz_ran1, ONLY: ran1
   USE lmdz_iniprint, ONLY: lunout, prt_level
+
 
   !   Author:    Frederic Hourdin      original: 15/01/93
Index: /LMDZ6/branches/Amaury_dev/libf/dyn3dmem/integrd_loc.f90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/dyn3dmem/integrd_loc.f90	(revision 5127)
+++ /LMDZ6/branches/Amaury_dev/libf/dyn3dmem/integrd_loc.f90	(revision 5128)
@@ -18,4 +18,5 @@
   USE lmdz_iniprint, ONLY: lunout, prt_level
   USE lmdz_ssum_scopy, ONLY: ssum
+
 
   IMPLICIT NONE
Index: /LMDZ6/branches/Amaury_dev/libf/dyn3dmem/leapfrog_loc.F90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/dyn3dmem/leapfrog_loc.F90	(revision 5127)
+++ /LMDZ6/branches/Amaury_dev/libf/dyn3dmem/leapfrog_loc.F90	(revision 5128)
@@ -42,4 +42,5 @@
   USE lmdz_description, ONLY: descript
   USE lmdz_iniprint, ONLY: lunout, prt_level
+
 
   IMPLICIT NONE
Index: /LMDZ6/branches/Amaury_dev/libf/dyn3dmem/lmdz_filtreg_p.F90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/dyn3dmem/lmdz_filtreg_p.F90	(revision 5127)
+++ /LMDZ6/branches/Amaury_dev/libf/dyn3dmem/lmdz_filtreg_p.F90	(revision 5128)
@@ -14,4 +14,5 @@
     USE lmdz_timer_filtre, ONLY: init_timer, start_timer, stop_timer
     USE lmdz_coefils, ONLY: jfiltnu, jfiltnv, jfiltsu, jfiltsv, sddu, sddv, unsddu, unsddv, modfrstv, modfrstu
+
 
     !=======================================================================
Index: /LMDZ6/branches/Amaury_dev/libf/dyn3dmem/mod_hallo.F90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/dyn3dmem/mod_hallo.F90	(revision 5127)
+++ /LMDZ6/branches/Amaury_dev/libf/dyn3dmem/mod_hallo.F90	(revision 5128)
@@ -138,4 +138,5 @@
       
   SUBROUTINE allocate_buffer(Size,Index,Pos)
+
   IMPLICIT NONE
     INTEGER :: Size
Index: /LMDZ6/branches/Amaury_dev/libf/dyn3dmem/parallel_lmdz.F90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/dyn3dmem/parallel_lmdz.F90	(revision 5127)
+++ /LMDZ6/branches/Amaury_dev/libf/dyn3dmem/parallel_lmdz.F90	(revision 5128)
@@ -374,4 +374,5 @@
     ! ug Pour les sorties XIOS
     USE lmdz_wxios
+
 
 #ifdef CPP_COUPLE
Index: /LMDZ6/branches/Amaury_dev/libf/dyn3dmem/paramet.h
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/dyn3dmem/paramet.h	(revision 5127)
+++ /LMDZ6/branches/Amaury_dev/libf/dyn3dmem/paramet.h	(revision 5128)
@@ -18,5 +18,5 @@
 
       PARAMETER( iip1= iim+1-1/iim,iip2=iim+2,iip3=iim+3                &
-     &    ,jjp1=jjm+1-1/jjm)
+          ,jjp1=jjm+1-1/jjm)
       PARAMETER( llmp1 = llm+1,  llmp2 = llm+2, llmm1 = llm-1 )
       PARAMETER( kftd  = iim/2 -ndm )
Index: /LMDZ6/branches/Amaury_dev/libf/dyn3dmem/qminimum_loc.f90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/dyn3dmem/qminimum_loc.f90	(revision 5127)
+++ /LMDZ6/branches/Amaury_dev/libf/dyn3dmem/qminimum_loc.f90	(revision 5128)
@@ -8,4 +8,6 @@
   USE lmdz_readTracFiles, ONLY: addPhase
   USE lmdz_iniprint, ONLY: lunout, prt_level
+
+
   IMPLICIT none
   !
Index: /LMDZ6/branches/Amaury_dev/libf/dyn3dmem/times.F90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/dyn3dmem/times.F90	(revision 5127)
+++ /LMDZ6/branches/Amaury_dev/libf/dyn3dmem/times.F90	(revision 5128)
@@ -49,4 +49,6 @@
   
   SUBROUTINE start_timer(no_timer)
+
+
     IMPLICIT NONE
     INTEGER :: no_timer
Index: /LMDZ6/branches/Amaury_dev/libf/dyn3dmem/vlsplt_loc.f90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/dyn3dmem/vlsplt_loc.f90	(revision 5127)
+++ /LMDZ6/branches/Amaury_dev/libf/dyn3dmem/vlsplt_loc.f90	(revision 5128)
@@ -814,4 +814,5 @@
   USE lmdz_iniprint, ONLY: lunout, prt_level
 
+
   IMPLICIT NONE
   !
Index: /LMDZ6/branches/Amaury_dev/libf/dyn3dmem/vlspltgen_loc.F90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/dyn3dmem/vlspltgen_loc.F90	(revision 5127)
+++ /LMDZ6/branches/Amaury_dev/libf/dyn3dmem/vlspltgen_loc.F90	(revision 5128)
@@ -31,4 +31,6 @@
   USE comconst_mod, ONLY: cpp
   USE logic_mod, ONLY: adv_qsat_liq
+
+
   IMPLICIT NONE
 
Index: /LMDZ6/branches/Amaury_dev/libf/dyn3dmem/vlspltqs_loc.f90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/dyn3dmem/vlspltqs_loc.f90	(revision 5127)
+++ /LMDZ6/branches/Amaury_dev/libf/dyn3dmem/vlspltqs_loc.f90	(revision 5128)
@@ -771,6 +771,5 @@
 
     IF (pole_sud) THEN
-
-      convps = -SSUM(iim, qbyv(ip1jm - iim, l, iq), iq, 1) / apols  ! /!\ called with 4 args ???
+      convps = -SSUM(iim, qbyv(ip1jm - iim, l, iq), 1) / apols
       convmps = -SSUM(iim, masse_adv_v(ip1jm - iim, l), 1) / apols
       DO ij = ip1jm + 1, ip1jmp1
@@ -780,5 +779,4 @@
         masse(ij, l, iq) = newmasse
       ENDDO
-
     ENDIF
     !.-. fin ancienne version
Index: /LMDZ6/branches/Amaury_dev/libf/dyn3dmem/wrgrads.f90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/dyn3dmem/wrgrads.f90	(revision 5127)
+++ /LMDZ6/branches/Amaury_dev/libf/dyn3dmem/wrgrads.f90	(revision 5128)
@@ -3,4 +3,6 @@
 SUBROUTINE wrgrads(if, nl, field, name, titlevar)
   USE lmdz_formcoord, ONLY: formcoord
+
+
   IMPLICIT NONE
 
Index: /LMDZ6/branches/Amaury_dev/libf/dynphy_lonlat/calfis.f90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/dynphy_lonlat/calfis.f90	(revision 5127)
+++ /LMDZ6/branches/Amaury_dev/libf/dynphy_lonlat/calfis.f90	(revision 5128)
@@ -37,4 +37,5 @@
   USE lmdz_ssum_scopy, ONLY: scopy, ssum
 
+
   IMPLICIT NONE
   !=======================================================================
Index: /LMDZ6/branches/Amaury_dev/libf/dynphy_lonlat/gr_dyn_fi.f90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/dynphy_lonlat/gr_dyn_fi.f90	(revision 5127)
+++ /LMDZ6/branches/Amaury_dev/libf/dynphy_lonlat/gr_dyn_fi.f90	(revision 5128)
@@ -3,4 +3,5 @@
 SUBROUTINE gr_dyn_fi(nfield, im, jm, ngrid, pdyn, pfi)
   USE lmdz_ssum_scopy, ONLY: scopy
+
 
   IMPLICIT NONE
Index: /LMDZ6/branches/Amaury_dev/libf/dynphy_lonlat/grid_atob_m.f90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/dynphy_lonlat/grid_atob_m.f90	(revision 5127)
+++ /LMDZ6/branches/Amaury_dev/libf/dynphy_lonlat/grid_atob_m.f90	(revision 5128)
@@ -209,4 +209,5 @@
 ! Purpose: Compute rugosity due to orography by using standard dev in a 1x1 cell
 !-------------------------------------------------------------------------------
+
   IMPLICIT NONE
 !-------------------------------------------------------------------------------
Index: /LMDZ6/branches/Amaury_dev/libf/dynphy_lonlat/lmdz_calfis_loc.F90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/dynphy_lonlat/lmdz_calfis_loc.F90	(revision 5127)
+++ /LMDZ6/branches/Amaury_dev/libf/dynphy_lonlat/lmdz_calfis_loc.F90	(revision 5128)
@@ -52,4 +52,5 @@
     USE lmdz_iniprint, ONLY: lunout, prt_level
     USE lmdz_ssum_scopy, ONLY: ssum
+
 
 
Index: /LMDZ6/branches/Amaury_dev/libf/dynphy_lonlat/phylmd/callphysiq_mod.F90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/dynphy_lonlat/phylmd/callphysiq_mod.F90	(revision 5127)
+++ /LMDZ6/branches/Amaury_dev/libf/dynphy_lonlat/phylmd/callphysiq_mod.F90	(revision 5128)
@@ -23,4 +23,6 @@
   USE physiq_mod, ONLY: physiq
   USE lmdz_xios, ONLY: xios_set_current_context, xios_get_current_context, xios_context
+
+
   IMPLICIT NONE
 
Index: /LMDZ6/branches/Amaury_dev/libf/dynphy_lonlat/phylmd/ce0l.F90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/dynphy_lonlat/phylmd/ce0l.F90	(revision 5127)
+++ /LMDZ6/branches/Amaury_dev/libf/dynphy_lonlat/phylmd/ce0l.F90	(revision 5128)
@@ -46,4 +46,5 @@
   USE lmdz_mpi
   USE lmdz_iniprint, ONLY: lunout, prt_level
+
 
   IMPLICIT NONE
Index: /LMDZ6/branches/Amaury_dev/libf/dynphy_lonlat/phylmd/etat0dyn_netcdf.F90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/dynphy_lonlat/phylmd/etat0dyn_netcdf.F90	(revision 5127)
+++ /LMDZ6/branches/Amaury_dev/libf/dynphy_lonlat/phylmd/etat0dyn_netcdf.F90	(revision 5128)
@@ -204,5 +204,6 @@
   SUBROUTINE startget_dyn3d(var, lon_in, lat_in, pls, workvar, &
           champ, lon_in2, lat_in2)
-    !-------------------------------------------------------------------------------
+
+
     IMPLICIT NONE
     !===============================================================================
@@ -396,4 +397,5 @@
     USE lmdz_libmath, ONLY: minmax
 
+
     IMPLICIT NONE
     !-------------------------------------------------------------------------------
Index: /LMDZ6/branches/Amaury_dev/libf/dynphy_lonlat/phylmd/limit_netcdf.f90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/dynphy_lonlat/phylmd/limit_netcdf.f90	(revision 5127)
+++ /LMDZ6/branches/Amaury_dev/libf/dynphy_lonlat/phylmd/limit_netcdf.f90	(revision 5128)
@@ -653,7 +653,7 @@
 
     SUBROUTINE start_init_orog0(lon_in, lat_in, phis, masque)
-
-      !-------------------------------------------------------------------------------
       USE grid_noro_m, ONLY: grid_noro0
+
+
       IMPLICIT NONE
       !===============================================================================
Index: /LMDZ6/branches/Amaury_dev/libf/filtrez/lmdz_filtre_fft_loc.F90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/filtrez/lmdz_filtre_fft_loc.F90	(revision 5128)
+++ /LMDZ6/branches/Amaury_dev/libf/filtrez/lmdz_filtre_fft_loc.F90	(revision 5128)
@@ -0,0 +1,342 @@
+MODULE lmdz_filtre_fft_loc
+  IMPLICIT NONE; PRIVATE
+  PUBLIC use_filtre_fft, filtre_u, filtre_v, filtre_inv, init_filtre_fft, filtre_u_fft, &
+          filtre_v_fft, filtre_inv_fft
+
+  LOGICAL, SAVE :: use_filtre_fft
+  REAL, SAVE, ALLOCATABLE :: Filtre_u(:, :)
+  REAL, SAVE, ALLOCATABLE :: Filtre_v(:, :)
+  REAL, SAVE, ALLOCATABLE :: Filtre_inv(:, :)
+
+CONTAINS
+
+  SUBROUTINE Init_filtre_fft(coeffu, modfrstu, jfiltnu, jfiltsu, coeffv, modfrstv, jfiltnv, jfiltsv)
+    USE lmdz_fft
+    IMPLICIT NONE
+    include 'dimensions.h'
+    REAL, INTENT(IN) :: coeffu(iim, jjm)
+    INTEGER, INTENT(IN) :: modfrstu(jjm)
+    INTEGER, INTENT(IN) :: jfiltnu
+    INTEGER, INTENT(IN) :: jfiltsu
+    REAL, INTENT(IN) :: coeffv(iim, jjm)
+    INTEGER, INTENT(IN) :: modfrstv(jjm)
+    INTEGER, INTENT(IN) :: jfiltnv
+    INTEGER, INTENT(IN) :: jfiltsv
+
+    INTEGER :: index_vp(iim)
+    INTEGER :: i, j
+
+    index_vp(1) = 1
+    DO i = 1, iim / 2
+      index_vp(i + 1) = i * 2
+    ENDDO
+
+    DO i = 1, iim / 2 - 1
+      index_vp(iim / 2 + i + 1) = iim - 2 * i + 1
+    ENDDO
+
+    ALLOCATE(Filtre_u(iim, jjm))
+    ALLOCATE(Filtre_v(iim, jjm))
+    ALLOCATE(Filtre_inv(iim, jjm))
+
+    DO j = 2, jfiltnu
+      DO i = 1, iim
+        IF (index_vp(i) < modfrstu(j)) THEN
+          Filtre_u(i, j) = 0
+        ELSE
+          Filtre_u(i, j) = coeffu(index_vp(i), j)
+        ENDIF
+      ENDDO
+    ENDDO
+
+    DO j = jfiltsu, jjm
+      DO i = 1, iim
+        IF (index_vp(i) < modfrstu(j)) THEN
+          Filtre_u(i, j) = 0
+        ELSE
+          Filtre_u(i, j) = coeffu(index_vp(i), j)
+        ENDIF
+      ENDDO
+    ENDDO
+
+    DO j = 1, jfiltnv
+      DO i = 1, iim
+        IF (index_vp(i) < modfrstv(j)) THEN
+          Filtre_v(i, j) = 0
+        ELSE
+          Filtre_v(i, j) = coeffv(index_vp(i), j)
+        ENDIF
+      ENDDO
+    ENDDO
+
+    DO j = jfiltsv, jjm
+      DO i = 1, iim
+        IF (index_vp(i) < modfrstv(j)) THEN
+          Filtre_v(i, j) = 0
+        ELSE
+          Filtre_v(i, j) = coeffv(index_vp(i), j)
+        ENDIF
+      ENDDO
+    ENDDO
+
+    DO j = 2, jfiltnu
+      DO i = 1, iim
+        IF (index_vp(i) < modfrstu(j)) THEN
+          Filtre_inv(i, j) = 0
+        ELSE
+          Filtre_inv(i, j) = coeffu(index_vp(i), j) / (1. + coeffu(index_vp(i), j))
+        ENDIF
+      ENDDO
+    ENDDO
+
+    DO j = jfiltsu, jjm
+      DO i = 1, iim
+        IF (index_vp(i) < modfrstu(j)) THEN
+          Filtre_inv(i, j) = 0
+        ELSE
+          Filtre_inv(i, j) = coeffu(index_vp(i), j) / (1. + coeffu(index_vp(i), j))
+        ENDIF
+      ENDDO
+    ENDDO
+
+
+    !    CALL Init_FFT(iim,(jjm+1)*(llm+1))
+
+  END SUBROUTINE Init_filtre_fft
+
+  SUBROUTINE Filtre_u_fft(vect_inout, jjb, jje, jj_begin, jj_end, nbniv)
+    USE lmdz_fft
+#ifdef CPP_PARA
+    USE parallel_lmdz,ONLY: OMP_CHUNK
+#endif
+    IMPLICIT NONE
+    include 'dimensions.h'
+    INTEGER, INTENT(IN) :: jjb
+    INTEGER, INTENT(IN) :: jje
+    INTEGER, INTENT(IN) :: jj_begin
+    INTEGER, INTENT(IN) :: jj_end
+    INTEGER, INTENT(IN) :: nbniv
+    REAL, INTENT(INOUT) :: vect_inout(iim + 1, jjb:jje, nbniv)
+
+    REAL :: vect(iim + inc, jj_end - jj_begin + 1, nbniv)
+    COMPLEX :: TF_vect(iim / 2 + 1, jj_end - jj_begin + 1, nbniv)
+    INTEGER :: nb_vect
+    INTEGER :: i, j, l
+    INTEGER :: ll_nb
+    !    REAL               :: vect_tmp(iim+inc,jj_end-jj_begin+1,nbniv)
+
+    ll_nb = 0
+    !$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
+    DO l = 1, nbniv
+      ll_nb = ll_nb + 1
+      DO j = 1, jj_end - jj_begin + 1
+        DO i = 1, iim + 1
+          vect(i, j, ll_nb) = vect_inout(i, j + jj_begin - 1, l)
+        ENDDO
+      ENDDO
+    ENDDO
+    !$OMP END DO NOWAIT
+
+    nb_vect = (jj_end - jj_begin + 1) * ll_nb
+
+    !    vect_tmp=vect
+
+    CALL FFT_forward(vect, TF_vect, nb_vect)
+
+    !    CALL FFT_forward(vect,TF_vect_test,nb_vect)
+    !      PRINT *,"XXXXXXXXXXXXX Filtre_u_FFT xxxxxxxxxxxx"
+    !      DO j=1,jj_end-jj_begin+1
+    !      DO i=1,iim/2+1
+    !         PRINT *,"====",i,j,"----->",TF_vect_test(i,j,1)
+    !       ENDDO
+    !      ENDDO
+
+    DO l = 1, ll_nb
+      DO j = 1, jj_end - jj_begin + 1
+        DO i = 1, iim / 2 + 1
+          TF_vect(i, j, l) = TF_vect(i, j, l) * Filtre_u(i, jj_begin + j - 1)
+        ENDDO
+      ENDDO
+    ENDDO
+
+    CALL FFT_backward(TF_vect, vect, nb_vect)
+    !    CALL FFT_backward(TF_vect_test,vect_test,nb_vect)
+
+    !      PRINT *,"XXXXXXXXXXXXX Filtre_u_FFT xxxxxxxxxxxx"
+    !      DO j=1,jj_end-jj_begin+1
+    !         DO i=1,iim
+    !           PRINT *,"====",i,j,"----->",vect_test(i,j,1)
+    !         ENDDO
+    !      ENDDO
+
+    ll_nb = 0
+    !$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
+    DO l = 1, nbniv
+      ll_nb = ll_nb + 1
+      DO j = 1, jj_end - jj_begin + 1
+        DO i = 1, iim + 1
+          vect_inout(i, j + jj_begin - 1, l) = vect(i, j, ll_nb)
+        ENDDO
+      ENDDO
+    ENDDO
+    !$OMP END DO NOWAIT
+
+  END SUBROUTINE Filtre_u_fft
+
+
+  SUBROUTINE Filtre_v_fft(vect_inout, jjb, jje, jj_begin, jj_end, nbniv)
+    USE lmdz_fft
+#ifdef CPP_PARA
+    USE parallel_lmdz,ONLY: OMP_CHUNK
+#endif
+    IMPLICIT NONE
+    INCLUDE 'dimensions.h'
+    INTEGER, INTENT(IN) :: jjb
+    INTEGER, INTENT(IN) :: jje
+    INTEGER, INTENT(IN) :: jj_begin
+    INTEGER, INTENT(IN) :: jj_end
+    INTEGER, INTENT(IN) :: nbniv
+    REAL, INTENT(INOUT) :: vect_inout(iim + 1, jjb:jje, nbniv)
+
+    REAL :: vect(iim + inc, jj_end - jj_begin + 1, nbniv)
+    COMPLEX :: TF_vect(iim / 2 + 1, jj_end - jj_begin + 1, nbniv)
+    INTEGER :: nb_vect
+    INTEGER :: i, j, l
+    INTEGER :: ll_nb
+
+    ll_nb = 0
+    !$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
+    DO l = 1, nbniv
+      ll_nb = ll_nb + 1
+      DO j = 1, jj_end - jj_begin + 1
+        DO i = 1, iim + 1
+          vect(i, j, ll_nb) = vect_inout(i, j + jj_begin - 1, l)
+        ENDDO
+      ENDDO
+    ENDDO
+    !$OMP END DO NOWAIT
+
+    nb_vect = (jj_end - jj_begin + 1) * ll_nb
+
+    CALL FFT_forward(vect, TF_vect, nb_vect)
+
+    DO l = 1, ll_nb
+      DO j = 1, jj_end - jj_begin + 1
+        DO i = 1, iim / 2 + 1
+          TF_vect(i, j, l) = TF_vect(i, j, l) * Filtre_v(i, jj_begin + j - 1)
+        ENDDO
+      ENDDO
+    ENDDO
+
+    CALL FFT_backward(TF_vect, vect, nb_vect)
+
+    ll_nb = 0
+    !$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
+    DO l = 1, nbniv
+      ll_nb = ll_nb + 1
+      DO j = 1, jj_end - jj_begin + 1
+        DO i = 1, iim + 1
+          vect_inout(i, j + jj_begin - 1, l) = vect(i, j, ll_nb)
+        ENDDO
+      ENDDO
+    ENDDO
+    !$OMP END DO NOWAIT
+
+  END SUBROUTINE Filtre_v_fft
+
+
+  SUBROUTINE Filtre_inv_fft(vect_inout, jjb, jje, jj_begin, jj_end, nbniv)
+    USE lmdz_fft
+#ifdef CPP_PARA
+    USE parallel_lmdz,ONLY: OMP_CHUNK
+#endif
+    IMPLICIT NONE
+    INCLUDE 'dimensions.h'
+    INTEGER, INTENT(IN) :: jjb
+    INTEGER, INTENT(IN) :: jje
+    INTEGER, INTENT(IN) :: jj_begin
+    INTEGER, INTENT(IN) :: jj_end
+    INTEGER, INTENT(IN) :: nbniv
+    REAL, INTENT(INOUT) :: vect_inout(iim + 1, jjb:jje, nbniv)
+
+    REAL :: vect(iim + inc, jj_end - jj_begin + 1, nbniv)
+    COMPLEX :: TF_vect(iim / 2 + 1, jj_end - jj_begin + 1, nbniv)
+    INTEGER :: nb_vect
+    INTEGER :: i, j, l
+    INTEGER :: ll_nb
+
+    ll_nb = 0
+    !$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
+    DO l = 1, nbniv
+      ll_nb = ll_nb + 1
+      DO j = 1, jj_end - jj_begin + 1
+        DO i = 1, iim + 1
+          vect(i, j, ll_nb) = vect_inout(i, j + jj_begin - 1, l)
+        ENDDO
+      ENDDO
+    ENDDO
+    !$OMP END DO NOWAIT
+
+    nb_vect = (jj_end - jj_begin + 1) * ll_nb
+
+    CALL FFT_forward(vect, TF_vect, nb_vect)
+
+    DO l = 1, ll_nb
+      DO j = 1, jj_end - jj_begin + 1
+        DO i = 1, iim / 2 + 1
+          TF_vect(i, j, l) = TF_vect(i, j, l) * Filtre_inv(i, jj_begin + j - 1)
+        ENDDO
+      ENDDO
+    ENDDO
+
+    CALL FFT_backward(TF_vect, vect, nb_vect)
+
+    ll_nb = 0
+    !$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
+    DO l = 1, nbniv
+      ll_nb = ll_nb + 1
+      DO j = 1, jj_end - jj_begin + 1
+        DO i = 1, iim + 1
+          vect_inout(i, j + jj_begin - 1, l) = vect(i, j, ll_nb)
+        ENDDO
+      ENDDO
+    ENDDO
+    !$OMP END DO NOWAIT
+
+  END SUBROUTINE Filtre_inv_fft
+
+
+  !  SUBROUTINE get_ll_index(nbniv,ll_index,ll_nb)
+  !  IMPLICIT NONE
+  !    INTEGER,INTENT(IN)  :: nbniv
+  !    INTEGER,INTENT(OUT) :: ll_index(nbniv)
+  !    INTEGER,INTENT(OUT) :: ll_nb
+
+  !    INTEGER :: l,ll_begin, ll_end
+  !   INTEGER :: omp_rank,omp_size
+  !   INTEGER :: OMP_GET_NUM_THREADS
+  !   INTEGER :: omp_chunk
+  !   EXTERNAL OMP_GET_NUM_THREADS
+  !   INTEGER :: OMP_GET_THREAD_NUM
+  !   EXTERNAL OMP_GET_THREAD_NUM
+
+
+  !   omp_size=OMP_GET_NUM_THREADS()
+  !   omp_rank=OMP_GET_THREAD_NUM()
+  !   omp_chunk=nbniv/omp_size+min(1,MOD(nbniv,omp_size))
+
+  !   ll_begin=omp_rank*OMP_CHUNK+1
+  !   ll_nb=0
+  !   DO WHILE (ll_begin<=nbniv)
+  !     ll_end=min(ll_begin+OMP_CHUNK-1,nbniv)
+  !     DO l=ll_begin,ll_end
+  !       ll_nb=ll_nb+1
+  !       ll_index(ll_nb)=l
+  !     ENDDO
+  !     ll_begin=ll_begin+omp_size*OMP_CHUNK
+  !   ENDDO
+
+  !  END SUBROUTINE get_ll_index
+
+END MODULE lmdz_filtre_fft_loc
+ 
Index: DZ6/branches/Amaury_dev/libf/filtrez/lmdz_filtre_fft_loc.f90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/filtrez/lmdz_filtre_fft_loc.f90	(revision 5127)
+++ 	(revision )
@@ -1,342 +1,0 @@
-MODULE lmdz_filtre_fft_loc
-  IMPLICIT NONE; PRIVATE
-  PUBLIC use_filtre_fft, filtre_u, filtre_v, filtre_inv, init_filtre_fft, filtre_u_fft, &
-          filtre_v_fft, filtre_inv_fft
-
-  LOGICAL, SAVE :: use_filtre_fft
-  REAL, SAVE, ALLOCATABLE :: Filtre_u(:, :)
-  REAL, SAVE, ALLOCATABLE :: Filtre_v(:, :)
-  REAL, SAVE, ALLOCATABLE :: Filtre_inv(:, :)
-
-CONTAINS
-
-  SUBROUTINE Init_filtre_fft(coeffu, modfrstu, jfiltnu, jfiltsu, coeffv, modfrstv, jfiltnv, jfiltsv)
-    USE lmdz_fft
-    IMPLICIT NONE
-    include 'dimensions.h'
-    REAL, INTENT(IN) :: coeffu(iim, jjm)
-    INTEGER, INTENT(IN) :: modfrstu(jjm)
-    INTEGER, INTENT(IN) :: jfiltnu
-    INTEGER, INTENT(IN) :: jfiltsu
-    REAL, INTENT(IN) :: coeffv(iim, jjm)
-    INTEGER, INTENT(IN) :: modfrstv(jjm)
-    INTEGER, INTENT(IN) :: jfiltnv
-    INTEGER, INTENT(IN) :: jfiltsv
-
-    INTEGER :: index_vp(iim)
-    INTEGER :: i, j
-
-    index_vp(1) = 1
-    DO i = 1, iim / 2
-      index_vp(i + 1) = i * 2
-    ENDDO
-
-    DO i = 1, iim / 2 - 1
-      index_vp(iim / 2 + i + 1) = iim - 2 * i + 1
-    ENDDO
-
-    ALLOCATE(Filtre_u(iim, jjm))
-    ALLOCATE(Filtre_v(iim, jjm))
-    ALLOCATE(Filtre_inv(iim, jjm))
-
-    DO j = 2, jfiltnu
-      DO i = 1, iim
-        IF (index_vp(i) < modfrstu(j)) THEN
-          Filtre_u(i, j) = 0
-        ELSE
-          Filtre_u(i, j) = coeffu(index_vp(i), j)
-        ENDIF
-      ENDDO
-    ENDDO
-
-    DO j = jfiltsu, jjm
-      DO i = 1, iim
-        IF (index_vp(i) < modfrstu(j)) THEN
-          Filtre_u(i, j) = 0
-        ELSE
-          Filtre_u(i, j) = coeffu(index_vp(i), j)
-        ENDIF
-      ENDDO
-    ENDDO
-
-    DO j = 1, jfiltnv
-      DO i = 1, iim
-        IF (index_vp(i) < modfrstv(j)) THEN
-          Filtre_v(i, j) = 0
-        ELSE
-          Filtre_v(i, j) = coeffv(index_vp(i), j)
-        ENDIF
-      ENDDO
-    ENDDO
-
-    DO j = jfiltsv, jjm
-      DO i = 1, iim
-        IF (index_vp(i) < modfrstv(j)) THEN
-          Filtre_v(i, j) = 0
-        ELSE
-          Filtre_v(i, j) = coeffv(index_vp(i), j)
-        ENDIF
-      ENDDO
-    ENDDO
-
-    DO j = 2, jfiltnu
-      DO i = 1, iim
-        IF (index_vp(i) < modfrstu(j)) THEN
-          Filtre_inv(i, j) = 0
-        ELSE
-          Filtre_inv(i, j) = coeffu(index_vp(i), j) / (1. + coeffu(index_vp(i), j))
-        ENDIF
-      ENDDO
-    ENDDO
-
-    DO j = jfiltsu, jjm
-      DO i = 1, iim
-        IF (index_vp(i) < modfrstu(j)) THEN
-          Filtre_inv(i, j) = 0
-        ELSE
-          Filtre_inv(i, j) = coeffu(index_vp(i), j) / (1. + coeffu(index_vp(i), j))
-        ENDIF
-      ENDDO
-    ENDDO
-
-
-    !    CALL Init_FFT(iim,(jjm+1)*(llm+1))
-
-  END SUBROUTINE Init_filtre_fft
-
-  SUBROUTINE Filtre_u_fft(vect_inout, jjb, jje, jj_begin, jj_end, nbniv)
-    USE lmdz_fft
-#ifdef CPP_PARA
-    USE parallel_lmdz,ONLY: OMP_CHUNK
-#endif
-    IMPLICIT NONE
-    include 'dimensions.h'
-    INTEGER, INTENT(IN) :: jjb
-    INTEGER, INTENT(IN) :: jje
-    INTEGER, INTENT(IN) :: jj_begin
-    INTEGER, INTENT(IN) :: jj_end
-    INTEGER, INTENT(IN) :: nbniv
-    REAL, INTENT(INOUT) :: vect_inout(iim + 1, jjb:jje, nbniv)
-
-    REAL :: vect(iim + inc, jj_end - jj_begin + 1, nbniv)
-    COMPLEX :: TF_vect(iim / 2 + 1, jj_end - jj_begin + 1, nbniv)
-    INTEGER :: nb_vect
-    INTEGER :: i, j, l
-    INTEGER :: ll_nb
-    !    REAL               :: vect_tmp(iim+inc,jj_end-jj_begin+1,nbniv)
-
-    ll_nb = 0
-    !$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
-    DO l = 1, nbniv
-      ll_nb = ll_nb + 1
-      DO j = 1, jj_end - jj_begin + 1
-        DO i = 1, iim + 1
-          vect(i, j, ll_nb) = vect_inout(i, j + jj_begin - 1, l)
-        ENDDO
-      ENDDO
-    ENDDO
-    !$OMP END DO NOWAIT
-
-    nb_vect = (jj_end - jj_begin + 1) * ll_nb
-
-    !    vect_tmp=vect
-
-    CALL FFT_forward(vect, TF_vect, nb_vect)
-
-    !    CALL FFT_forward(vect,TF_vect_test,nb_vect)
-    !      PRINT *,"XXXXXXXXXXXXX Filtre_u_FFT xxxxxxxxxxxx"
-    !      DO j=1,jj_end-jj_begin+1
-    !      DO i=1,iim/2+1
-    !         PRINT *,"====",i,j,"----->",TF_vect_test(i,j,1)
-    !       ENDDO
-    !      ENDDO
-
-    DO l = 1, ll_nb
-      DO j = 1, jj_end - jj_begin + 1
-        DO i = 1, iim / 2 + 1
-          TF_vect(i, j, l) = TF_vect(i, j, l) * Filtre_u(i, jj_begin + j - 1)
-        ENDDO
-      ENDDO
-    ENDDO
-
-    CALL FFT_backward(TF_vect, vect, nb_vect)
-    !    CALL FFT_backward(TF_vect_test,vect_test,nb_vect)
-
-    !      PRINT *,"XXXXXXXXXXXXX Filtre_u_FFT xxxxxxxxxxxx"
-    !      DO j=1,jj_end-jj_begin+1
-    !         DO i=1,iim
-    !           PRINT *,"====",i,j,"----->",vect_test(i,j,1)
-    !         ENDDO
-    !      ENDDO
-
-    ll_nb = 0
-    !$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
-    DO l = 1, nbniv
-      ll_nb = ll_nb + 1
-      DO j = 1, jj_end - jj_begin + 1
-        DO i = 1, iim + 1
-          vect_inout(i, j + jj_begin - 1, l) = vect(i, j, ll_nb)
-        ENDDO
-      ENDDO
-    ENDDO
-    !$OMP END DO NOWAIT
-
-  END SUBROUTINE Filtre_u_fft
-
-
-  SUBROUTINE Filtre_v_fft(vect_inout, jjb, jje, jj_begin, jj_end, nbniv)
-    USE lmdz_fft
-#ifdef CPP_PARA
-    USE parallel_lmdz,ONLY: OMP_CHUNK
-#endif
-    IMPLICIT NONE
-    INCLUDE 'dimensions.h'
-    INTEGER, INTENT(IN) :: jjb
-    INTEGER, INTENT(IN) :: jje
-    INTEGER, INTENT(IN) :: jj_begin
-    INTEGER, INTENT(IN) :: jj_end
-    INTEGER, INTENT(IN) :: nbniv
-    REAL, INTENT(INOUT) :: vect_inout(iim + 1, jjb:jje, nbniv)
-
-    REAL :: vect(iim + inc, jj_end - jj_begin + 1, nbniv)
-    COMPLEX :: TF_vect(iim / 2 + 1, jj_end - jj_begin + 1, nbniv)
-    INTEGER :: nb_vect
-    INTEGER :: i, j, l
-    INTEGER :: ll_nb
-
-    ll_nb = 0
-    !$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
-    DO l = 1, nbniv
-      ll_nb = ll_nb + 1
-      DO j = 1, jj_end - jj_begin + 1
-        DO i = 1, iim + 1
-          vect(i, j, ll_nb) = vect_inout(i, j + jj_begin - 1, l)
-        ENDDO
-      ENDDO
-    ENDDO
-    !$OMP END DO NOWAIT
-
-    nb_vect = (jj_end - jj_begin + 1) * ll_nb
-
-    CALL FFT_forward(vect, TF_vect, nb_vect)
-
-    DO l = 1, ll_nb
-      DO j = 1, jj_end - jj_begin + 1
-        DO i = 1, iim / 2 + 1
-          TF_vect(i, j, l) = TF_vect(i, j, l) * Filtre_v(i, jj_begin + j - 1)
-        ENDDO
-      ENDDO
-    ENDDO
-
-    CALL FFT_backward(TF_vect, vect, nb_vect)
-
-    ll_nb = 0
-    !$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
-    DO l = 1, nbniv
-      ll_nb = ll_nb + 1
-      DO j = 1, jj_end - jj_begin + 1
-        DO i = 1, iim + 1
-          vect_inout(i, j + jj_begin - 1, l) = vect(i, j, ll_nb)
-        ENDDO
-      ENDDO
-    ENDDO
-    !$OMP END DO NOWAIT
-
-  END SUBROUTINE Filtre_v_fft
-
-
-  SUBROUTINE Filtre_inv_fft(vect_inout, jjb, jje, jj_begin, jj_end, nbniv)
-    USE lmdz_fft
-#ifdef CPP_PARA
-    USE parallel_lmdz,ONLY: OMP_CHUNK
-#endif
-    IMPLICIT NONE
-    INCLUDE 'dimensions.h'
-    INTEGER, INTENT(IN) :: jjb
-    INTEGER, INTENT(IN) :: jje
-    INTEGER, INTENT(IN) :: jj_begin
-    INTEGER, INTENT(IN) :: jj_end
-    INTEGER, INTENT(IN) :: nbniv
-    REAL, INTENT(INOUT) :: vect_inout(iim + 1, jjb:jje, nbniv)
-
-    REAL :: vect(iim + inc, jj_end - jj_begin + 1, nbniv)
-    COMPLEX :: TF_vect(iim / 2 + 1, jj_end - jj_begin + 1, nbniv)
-    INTEGER :: nb_vect
-    INTEGER :: i, j, l
-    INTEGER :: ll_nb
-
-    ll_nb = 0
-    !$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
-    DO l = 1, nbniv
-      ll_nb = ll_nb + 1
-      DO j = 1, jj_end - jj_begin + 1
-        DO i = 1, iim + 1
-          vect(i, j, ll_nb) = vect_inout(i, j + jj_begin - 1, l)
-        ENDDO
-      ENDDO
-    ENDDO
-    !$OMP END DO NOWAIT
-
-    nb_vect = (jj_end - jj_begin + 1) * ll_nb
-
-    CALL FFT_forward(vect, TF_vect, nb_vect)
-
-    DO l = 1, ll_nb
-      DO j = 1, jj_end - jj_begin + 1
-        DO i = 1, iim / 2 + 1
-          TF_vect(i, j, l) = TF_vect(i, j, l) * Filtre_inv(i, jj_begin + j - 1)
-        ENDDO
-      ENDDO
-    ENDDO
-
-    CALL FFT_backward(TF_vect, vect, nb_vect)
-
-    ll_nb = 0
-    !$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
-    DO l = 1, nbniv
-      ll_nb = ll_nb + 1
-      DO j = 1, jj_end - jj_begin + 1
-        DO i = 1, iim + 1
-          vect_inout(i, j + jj_begin - 1, l) = vect(i, j, ll_nb)
-        ENDDO
-      ENDDO
-    ENDDO
-    !$OMP END DO NOWAIT
-
-  END SUBROUTINE Filtre_inv_fft
-
-
-  !  SUBROUTINE get_ll_index(nbniv,ll_index,ll_nb)
-  !  IMPLICIT NONE
-  !    INTEGER,INTENT(IN)  :: nbniv
-  !    INTEGER,INTENT(OUT) :: ll_index(nbniv)
-  !    INTEGER,INTENT(OUT) :: ll_nb
-
-  !    INTEGER :: l,ll_begin, ll_end
-  !   INTEGER :: omp_rank,omp_size
-  !   INTEGER :: OMP_GET_NUM_THREADS
-  !   INTEGER :: omp_chunk
-  !   EXTERNAL OMP_GET_NUM_THREADS
-  !   INTEGER :: OMP_GET_THREAD_NUM
-  !   EXTERNAL OMP_GET_THREAD_NUM
-
-
-  !   omp_size=OMP_GET_NUM_THREADS()
-  !   omp_rank=OMP_GET_THREAD_NUM()
-  !   omp_chunk=nbniv/omp_size+min(1,MOD(nbniv,omp_size))
-
-  !   ll_begin=omp_rank*OMP_CHUNK+1
-  !   ll_nb=0
-  !   DO WHILE (ll_begin<=nbniv)
-  !     ll_end=min(ll_begin+OMP_CHUNK-1,nbniv)
-  !     DO l=ll_begin,ll_end
-  !       ll_nb=ll_nb+1
-  !       ll_index(ll_nb)=l
-  !     ENDDO
-  !     ll_begin=ll_begin+omp_size*OMP_CHUNK
-  !   ENDDO
-
-  !  END SUBROUTINE get_ll_index
-
-END MODULE lmdz_filtre_fft_loc
- 
Index: /LMDZ6/branches/Amaury_dev/libf/misc/lmdz_NOMODULE_abort_gcm.f90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/misc/lmdz_NOMODULE_abort_gcm.f90	(revision 5128)
+++ /LMDZ6/branches/Amaury_dev/libf/misc/lmdz_NOMODULE_abort_gcm.f90	(revision 5128)
@@ -0,0 +1,56 @@
+! $Id: abort_gcm.F 1747 2013-04-23 14:06:30Z lguez $
+
+! /!\ We can't put this in a module right away with FCM1, as this creates a circular dependency e.g. with wxios through lmdz_iniprint
+
+SUBROUTINE abort_gcm(modname, ierr, message)
+  !END
+  ! Stops the simulation cleanly, closing files and printing various
+  ! comments
+  !
+  !  Input: modname = name of calling program
+  !     message = stuff to print
+  !     ierr    = severity of situation ( = 0 normal )
+
+  USE IOIPSL, ONLY: histclo, restclo, getin_dump
+  USE lmdz_wxios, ONLY: using_xios, wxios_close
+  USE lmdz_phys_mpi_data, ONLY: mpi_rank
+  USE lmdz_mpi, ONLY: using_mpi
+  USE mod_const_mpi, ONLY: comm_lmdz
+  USE lmdz_iniprint, ONLY: lunout, prt_level
+  IMPLICIT NONE
+
+  CHARACTER(LEN = *), INTENT(IN) :: modname
+  INTEGER, INTENT(IN) :: ierr
+  CHARACTER(LEN = *), INTENT(IN) :: message
+
+  INTEGER :: ierror_mpi
+
+  WRITE(lunout, *) 'in abort_gcm'
+
+  IF (using_xios) THEN !Fermeture propre de XIOS
+    CALL wxios_close()
+  ENDIF
+
+  !$OMP MASTER
+  CALL histclo
+  CALL restclo
+  IF (mpi_rank == 0) THEN
+    CALL getin_dump
+  ENDIF
+  !$OMP END MASTER
+  WRITE(lunout, *) 'Stopping in ', modname
+  WRITE(lunout, *) 'Reason = ', message
+  IF (ierr == 0) THEN
+    WRITE(lunout, *) 'Everything is cool'
+  ELSE
+    WRITE(lunout, *) 'Houston, we have a problem, ierr = ', ierr
+
+    IF (using_mpi) THEN
+      !$OMP CRITICAL (MPI_ABORT_GCM)
+      CALL MPI_ABORT(comm_lmdz, 1, ierror_mpi)
+      !$OMP END CRITICAL (MPI_ABORT_GCM)
+    ELSE
+      STOP 1
+    END IF
+  ENDIF
+END SUBROUTINE abort_gcm
Index: /LMDZ6/branches/Amaury_dev/libf/obsolete/filtreg_p.F90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/obsolete/filtreg_p.F90	(revision 5128)
+++ /LMDZ6/branches/Amaury_dev/libf/obsolete/filtreg_p.F90	(revision 5128)
@@ -0,0 +1,427 @@
+! Amaury: on a ce fichier + lmdz_filtreg_p ! C'est totalement incompréhensible ;_;
+! A minima il faut un nom clair pour chaque
+
+SUBROUTINE filtreg_p( champ, ibeg, iend, nlat, nbniv, &
+        ifiltre, iaire, griscal ,iter)
+  USE parallel_lmdz, ONLY: OMP_CHUNK
+  USE lmdz_filtre_fft, ONLY: use_filtre_fft, filtre_u_fft, filtre_v_fft, filtre_inv_fft
+  USE lmdz_timer_filtre, ONLY: init_timer, start_timer, stop_timer
+  USE lmdz_coefils, ONLY: jfiltnu, jfiltnv, jfiltsu, jfiltsv, sddu, sddv, unsddu, unsddv, modfrstv, modfrstu
+  USE lmdz_filtreg, ONLY: matrinvn, matrinvs, matriceun, matriceus, matricevn, matricevs
+
+  IMPLICIT NONE
+
+  !=======================================================================
+  !
+  !   Auteur: P. Le Van        07/10/97
+  !   ------
+  !
+  !   Objet: filtre matriciel longitudinal ,avec les matrices precalculees
+  !                 pour l'operateur  Filtre    .
+  !   ------
+  !
+  !   Arguments:
+  !   ----------
+  !
+  !
+  !  ibeg..iend            lattitude a filtrer
+  !  nlat                  nombre de latitudes du champ
+  !  nbniv                 nombre de niveaux verticaux a filtrer
+  !  champ(iip1,nblat,nbniv)  en entree : champ a filtrer
+  !                        en sortie : champ filtre
+  !  ifiltre               +1  Transformee directe
+  !                        -1  Transformee inverse
+  !                        +2  Filtre directe
+  !                        -2  Filtre inverse
+  !
+  !  iaire                 1   si champ intensif
+  !                        2   si champ extensif (pondere par les aires)
+  !
+  !  iter                  1   filtre simple
+  !
+  !=======================================================================
+  !
+  !
+  !                  Variable Intensive
+  !            ifiltre = 1     filtre directe
+  !            ifiltre =-1     filtre inverse
+  !
+  !                  Variable Extensive
+  !            ifiltre = 2     filtre directe
+  !            ifiltre =-2     filtre inverse
+  !
+  !
+  INCLUDE "dimensions.h"
+  INCLUDE "paramet.h"
+
+  INTEGER :: ibeg,iend,nlat,nbniv,ifiltre,iter
+  INTEGER :: i,j,l,k
+  INTEGER :: iim2,immjm
+  INTEGER :: jdfil1,jdfil2,jffil1,jffil2,jdfil,jffil
+
+  REAL :: champ( iip1,nlat,nbniv)
+
+  LOGICAL :: griscal
+  INTEGER :: hemisph, iaire
+
+  REAL :: champ_fft(iip1,nlat,nbniv)
+  REAL :: champ_in(iip1,nlat,nbniv)
+
+  LOGICAL,SAVE     :: first=.TRUE.
+!$OMP THREADPRIVATE(first)
+
+  REAL, DIMENSION(iip1,nlat,nbniv) :: champ_loc
+  INTEGER :: ll_nb, nbniv_loc
+  REAL, SAVE :: sdd12(iim,4)
+!$OMP THREADPRIVATE(sdd12)
+
+  INTEGER, PARAMETER :: type_sddu=1
+  INTEGER, PARAMETER :: type_sddv=2
+  INTEGER, PARAMETER :: type_unsddu=3
+  INTEGER, PARAMETER :: type_unsddv=4
+
+  INTEGER :: sdd1_type, sdd2_type
+
+  IF (first) THEN
+     sdd12(1:iim,type_sddu) = sddu(1:iim)
+     sdd12(1:iim,type_sddv) = sddv(1:iim)
+     sdd12(1:iim,type_unsddu) = unsddu(1:iim)
+     sdd12(1:iim,type_unsddv) = unsddv(1:iim)
+
+     CALL Init_timer
+     first=.FALSE.
+  ENDIF
+
+!$OMP MASTER
+  CALL start_timer
+!$OMP END MASTER
+
+  !-------------------------------------------------------c
+
+  IF(ifiltre==1.OR.ifiltre==-1) &
+        CALL abort_gcm("fitreg_p","Pas de transformee simple&
+        &dans cette version",1)
+
+  IF( iter== 2 )  THEN
+     PRINT *,' Pas d iteration du filtre dans cette version !'&
+           &        , ' Utiliser old_filtreg et repasser !'
+     CALL abort_gcm("fitreg_p","stopped",1)
+  ENDIF
+
+  IF( ifiltre== -2 .AND..NOT.griscal )     THEN
+     PRINT *,' Cette routine ne calcule le filtre inverse que ' &
+           , ' sur la grille des scalaires !'
+     CALL abort_gcm("fitreg_p","stopped",1)
+  ENDIF
+
+  IF( ifiltre/=2 .AND.ifiltre/= - 2 )  THEN
+     PRINT *,' Probleme dans filtreg car ifiltre NE 2 et NE -2' &
+           , ' corriger et repasser !'
+     CALL abort_gcm("fitreg_p","stopped",1)
+   ENDIF
+  !
+
+  iim2   = iim * iim
+  immjm  = iim * jjm
+  !
+  !
+  IF( griscal )   THEN
+     IF( nlat /= jjp1 )  THEN
+        CALL abort_gcm("fitreg_p","nlat. NE. jjp1",1)
+     ELSE
+  !
+        IF( iaire==1 )  THEN
+           sdd1_type = type_sddv
+           sdd2_type = type_unsddv
+        ELSE
+           sdd1_type = type_unsddv
+           sdd2_type = type_sddv
+        ENDIF
+  !
+        jdfil1 = 2
+        jffil1 = jfiltnu
+        jdfil2 = jfiltsu
+        jffil2 = jjm
+     ENDIF
+  ELSE
+     IF( nlat/=jjm )  THEN
+        CALL abort_gcm("fitreg_p","nlat. NE. jjm",1)
+     ELSE
+  !
+        IF( iaire==1 )  THEN
+           sdd1_type = type_sddu
+           sdd2_type = type_unsddu
+        ELSE
+           sdd1_type = type_unsddu
+           sdd2_type = type_sddu
+        ENDIF
+  !
+        jdfil1 = 1
+        jffil1 = jfiltnv
+        jdfil2 = jfiltsv
+        jffil2 = jjm
+     ENDIF
+  ENDIF
+  !
+  DO hemisph = 1, 2
+  !
+     IF ( hemisph==1 )  THEN
+  !ym
+        jdfil = max(jdfil1,ibeg)
+        jffil = min(jffil1,iend)
+     ELSE
+  !ym
+        jdfil = max(jdfil2,ibeg)
+        jffil = min(jffil2,iend)
+     ENDIF
+
+
+  !ccccccccccccccccccccccccccccccccccccccccccc
+  ! Utilisation du filtre classique
+  !ccccccccccccccccccccccccccccccccccccccccccc
+
+     IF (.NOT. use_filtre_fft) THEN
+
+  !---------------------------------!
+  ! Agregation des niveau verticaux !
+  ! uniquement necessaire pour une  !
+  ! execution OpenMP                !
+  !---------------------------------!
+        ll_nb = 0
+!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
+        DO l = 1, nbniv
+           ll_nb = ll_nb+1
+           DO j = jdfil,jffil
+              DO i = 1, iim
+                 champ_loc(i,j,ll_nb) = &
+                       champ(i,j,l) * sdd12(i,sdd1_type)
+              ENDDO
+           ENDDO
+        ENDDO
+!$OMP END DO NOWAIT
+
+        nbniv_loc = ll_nb
+
+        IF( hemisph==1 )      THEN
+
+           IF( ifiltre==-2 )   THEN
+              DO j = jdfil,jffil
+#ifdef BLAS
+                 CALL DGEMM("N", "N", iim, nbniv_loc, iim, 1.0, &
+                       matrinvn(1,1,j), iim, &
+                       champ_loc(1,j,1), iip1*nlat, 0.0, &
+                       champ_fft(1,j-jdfil+1,1), iip1*nlat)
+#else
+                 champ_fft(:iim,j-jdfil+1,:) &
+                       =matmul(matrinvn(:,:,j),champ_loc(:iim,j,:))
+#endif
+              ENDDO
+
+           ELSE IF ( griscal )     THEN
+              DO j = jdfil,jffil
+#ifdef BLAS
+                 CALL DGEMM("N", "N", iim, nbniv_loc, iim, 1.0, &
+                       matriceun(1,1,j), iim, &
+                       champ_loc(1,j,1), iip1*nlat, 0.0, &
+                       champ_fft(1,j-jdfil+1,1), iip1*nlat)
+#else
+                 champ_fft(:iim,j-jdfil+1,:) &
+                       =matmul(matriceun(:,:,j),champ_loc(:iim,j,:))
+#endif
+              ENDDO
+
+           ELSE
+              DO j = jdfil,jffil
+#ifdef BLAS
+                 CALL DGEMM("N", "N", iim, nbniv_loc, iim, 1.0, &
+                       matricevn(1,1,j), iim, &
+                       champ_loc(1,j,1), iip1*nlat, 0.0, &
+                       champ_fft(1,j-jdfil+1,1), iip1*nlat)
+#else
+                 champ_fft(:iim,j-jdfil+1,:) &
+                       =matmul(matricevn(:,:,j),champ_loc(:iim,j,:))
+#endif
+              ENDDO
+
+           ENDIF
+
+        ELSE
+
+           IF( ifiltre==-2 )   THEN
+              DO j = jdfil,jffil
+#ifdef BLAS
+                 CALL DGEMM("N", "N", iim, nbniv_loc, iim, 1.0, &
+                       matrinvs(1,1,j-jfiltsu+1), iim, &
+                       champ_loc(1,j,1), iip1*nlat, 0.0, &
+                       champ_fft(1,j-jdfil+1,1), iip1*nlat)
+#else
+                 champ_fft(:iim,j-jdfil+1,:) &
+                       =matmul(matrinvs(:,:,j-jfiltsu+1), &
+                       champ_loc(:iim,j,:))
+#endif
+              ENDDO
+
+           ELSE IF ( griscal )     THEN
+
+              DO j = jdfil,jffil
+#ifdef BLAS
+                 CALL DGEMM("N", "N", iim, nbniv_loc, iim, 1.0, &
+                       matriceus(1,1,j-jfiltsu+1), iim, &
+                       champ_loc(1,j,1), iip1*nlat, 0.0, &
+                       champ_fft(1,j-jdfil+1,1), iip1*nlat)
+#else
+                 champ_fft(:iim,j-jdfil+1,:) &
+                       =matmul(matriceus(:,:,j-jfiltsu+1), &
+                       champ_loc(:iim,j,:))
+#endif
+              ENDDO
+
+           ELSE
+
+              DO j = jdfil,jffil
+#ifdef BLAS
+                 CALL DGEMM("N", "N", iim, nbniv_loc, iim, 1.0, &
+                       matricevs(1,1,j-jfiltsv+1), iim, &
+                       champ_loc(1,j,1), iip1*nlat, 0.0, &
+                       champ_fft(1,j-jdfil+1,1), iip1*nlat)
+#else
+                 champ_fft(:iim,j-jdfil+1,:) &
+                       =matmul(matricevs(:,:,j-jfiltsv+1), &
+                       champ_loc(:iim,j,:))
+#endif
+              ENDDO
+
+           ENDIF
+
+        ENDIF
+  ! c
+        IF( ifiltre==2 )  THEN
+
+  !-------------------------------------!
+  ! Dés-agregation des niveau verticaux !
+  ! uniquement necessaire pour une      !
+  ! execution OpenMP                    !
+  !-------------------------------------!
+           ll_nb = 0
+!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
+           DO l = 1, nbniv
+              ll_nb = ll_nb + 1
+              DO j = jdfil,jffil
+                 DO i = 1, iim
+                    champ( i,j,l ) = (champ_loc(i,j,ll_nb) &
+                          + champ_fft(i,j-jdfil+1,ll_nb)) &
+                          * sdd12(i,sdd2_type)
+                 ENDDO
+              ENDDO
+           ENDDO
+!$OMP END DO NOWAIT
+
+        ELSE
+
+           ll_nb = 0
+!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
+           DO l = 1, nbniv_loc
+              ll_nb = ll_nb + 1
+              DO j = jdfil,jffil
+                 DO i = 1, iim
+                    champ( i,j,l ) = (champ_loc(i,j,ll_nb) &
+                          - champ_fft(i,j-jdfil+1,ll_nb)) &
+                          * sdd12(i,sdd2_type)
+                 ENDDO
+              ENDDO
+           ENDDO
+!$OMP END DO NOWAIT
+
+        ENDIF
+
+!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
+        DO l = 1, nbniv
+           DO j = jdfil,jffil
+              champ( iip1,j,l ) = champ( 1,j,l )
+           ENDDO
+        ENDDO
+!$OMP END DO NOWAIT
+
+  !cccccccccccccccccccccccccccccccccccccccccccc
+  ! Utilisation du filtre FFT
+  !cccccccccccccccccccccccccccccccccccccccccccc
+
+     ELSE
+
+!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
+        DO l=1,nbniv
+           DO j=jdfil,jffil
+              DO  i = 1, iim
+                 champ( i,j,l)= champ(i,j,l)*sdd12(i,sdd1_type)
+                 champ_fft( i,j,l) = champ(i,j,l)
+              ENDDO
+           ENDDO
+        ENDDO
+!$OMP END DO NOWAIT
+
+        IF (jdfil<=jffil) THEN
+           IF( ifiltre == -2 )   THEN
+              CALL Filtre_inv_fft(champ_fft,nlat,jdfil,jffil,nbniv)
+           ELSE IF ( griscal )     THEN
+              CALL Filtre_u_fft(champ_fft,nlat,jdfil,jffil,nbniv)
+           ELSE
+              CALL Filtre_v_fft(champ_fft,nlat,jdfil,jffil,nbniv)
+           ENDIF
+        ENDIF
+
+
+        IF( ifiltre== 2 )  THEN
+!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
+           DO l=1,nbniv
+              DO j=jdfil,jffil
+                 DO  i = 1, iim
+                    champ( i,j,l)=(champ(i,j,l)+champ_fft(i,j,l)) &
+                          *sdd12(i,sdd2_type)
+                 ENDDO
+              ENDDO
+           ENDDO
+!$OMP END DO NOWAIT	
+        ELSE
+
+!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
+           DO l=1,nbniv
+              DO j=jdfil,jffil
+                 DO  i = 1, iim
+                    champ(i,j,l)=(champ(i,j,l)-champ_fft(i,j,l)) &
+                          *sdd12(i,sdd2_type)
+                 ENDDO
+              ENDDO
+           ENDDO
+!$OMP END DO NOWAIT
+        ENDIF
+  !
+!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
+        DO l=1,nbniv
+           DO j=jdfil,jffil
+         ! champ_FFT( iip1,j,l ) = champ_FFT( 1,j,l )
+              champ( iip1,j,l ) = champ( 1,j,l )
+           ENDDO
+        ENDDO
+!$OMP END DO NOWAIT          	
+     ENDIF
+  ! Fin de la zone de filtrage
+
+
+  ENDDO
+
+   ! DO j=1,nlat
+
+   !     PRINT *,"check FFT ----> Delta(",j,")=",
+  ! &            sum(champ(:,j,:)-champ_fft(:,j,:))/sum(champ(:,j,:)),
+  ! &            sum(champ(:,j,:)-champ_in(:,j,:))/sum(champ(:,j,:))
+  !  ENDDO
+
+  !      PRINT *,"check FFT ----> Delta(",j,")=",
+  ! &            sum(champ-champ_fft)/sum(champ)
+
+  !
+!$OMP MASTER
+  CALL stop_timer
+!$OMP END MASTER
+
+END SUBROUTINE filtreg_p
Index: /LMDZ6/branches/Amaury_dev/libf/phylmd/Dust/checknanqfi.F90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/phylmd/Dust/checknanqfi.F90	(revision 5127)
+++ /LMDZ6/branches/Amaury_dev/libf/phylmd/Dust/checknanqfi.F90	(revision 5128)
@@ -1,4 +1,5 @@
 SUBROUTINE checknanqfi(zq,qmin,qmax,comment)
   USE dimphy
+
   IMPLICIT NONE
 
Index: /LMDZ6/branches/Amaury_dev/libf/phylmd/Dust/phytracr_spl_mod.F90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/phylmd/Dust/phytracr_spl_mod.F90	(revision 5127)
+++ /LMDZ6/branches/Amaury_dev/libf/phylmd/Dust/phytracr_spl_mod.F90	(revision 5128)
@@ -3,4 +3,5 @@
 
 MODULE phytracr_spl_mod
+
 
   ! Recuperation des morceaux de la physique de Jeronimo specifiques
Index: /LMDZ6/branches/Amaury_dev/libf/phylmd/FCTTRE.h
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/phylmd/FCTTRE.h	(revision 5127)
+++ /LMDZ6/branches/Amaury_dev/libf/phylmd/FCTTRE.h	(revision 5128)
@@ -22,24 +22,24 @@
 
       FOEEW ( PTARG,PDELARG ) = EXP (                                   &
-     &          (R3LES*(1.-PDELARG)+R3IES*PDELARG) * (PTARG-RTT)        &
-     & / (PTARG-(R4LES*(1.-PDELARG)+R4IES*PDELARG)) )
+                (R3LES*(1.-PDELARG)+R3IES*PDELARG) * (PTARG-RTT)        &
+       / (PTARG-(R4LES*(1.-PDELARG)+R4IES*PDELARG)) )
 
       FOEDE ( PTARG,PDELARG,P5ARG,PQSARG,PCOARG ) = PQSARG*PCOARG*P5ARG &
-     & / (PTARG-(R4LES*(1.-PDELARG)+R4IES*PDELARG))**2
+       / (PTARG-(R4LES*(1.-PDELARG)+R4IES*PDELARG))**2
 
       qsats(ptarg) = 100.0 * 0.622 * 10.0                               &
-     &           ** (2.07023 - 0.00320991 * ptarg                       &
-     &           - 2484.896 / ptarg + 3.56654 * LOG10(ptarg))
+                 ** (2.07023 - 0.00320991 * ptarg                       &
+                 - 2484.896 / ptarg + 3.56654 * LOG10(ptarg))
       qsatl(ptarg) = 100.0 * 0.622 * 10.0                               &
-     &           ** (23.8319 - 2948.964 / ptarg                         &
-     &           - 5.028 * LOG10(ptarg)                                 &
-     &           - 29810.16 * EXP( - 0.0699382 * ptarg)                 &
-     &           + 25.21935 * EXP( - 2999.924 / ptarg))
+                 ** (23.8319 - 2948.964 / ptarg                         &
+                 - 5.028 * LOG10(ptarg)                                 &
+                 - 29810.16 * EXP( - 0.0699382 * ptarg)                 &
+                 + 25.21935 * EXP( - 2999.924 / ptarg))
 
       dqsats(ptarg,pqsarg) = RLVTT/RCPD*pqsarg * (3.56654/ptarg         &
-     &                     +2484.896*LOG(10.)/ptarg**2                  &
-     &                     -0.00320991*LOG(10.))
+                           +2484.896*LOG(10.)/ptarg**2                  &
+                           -0.00320991*LOG(10.))
       dqsatl(ptarg,pqsarg) = RLVTT/RCPD*pqsarg*LOG(10.)*                &
-     &                (2948.964/ptarg**2-5.028/LOG(10.)/ptarg           &
-     &                +25.21935*2999.924/ptarg**2*EXP(-2999.924/ptarg)  &
-     &                +29810.16*0.0699382*EXP(-0.0699382*ptarg))
+                      (2948.964/ptarg**2-5.028/LOG(10.)/ptarg           &
+                      +25.21935*2999.924/ptarg**2*EXP(-2999.924/ptarg)  &
+                      +29810.16*0.0699382*EXP(-0.0699382*ptarg))
Index: /LMDZ6/branches/Amaury_dev/libf/phylmd/YOECUMF.h
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/phylmd/YOECUMF.h	(revision 5127)
+++ /LMDZ6/branches/Amaury_dev/libf/phylmd/YOECUMF.h	(revision 5128)
@@ -12,7 +12,7 @@
 
       COMMON /YOECUMF/                                                  &
-     &                 ENTRPEN,ENTRSCV,ENTRMID,ENTRDD,CMFCTOP,          &
-     &                 CMFCMAX,CMFCMIN,CMFDEPS,RHCDD,CPRCON,            &
-     &                 LMFPEN,LMFSCV,LMFMID,LMFDD,LMFDUDV
+                       ENTRPEN,ENTRSCV,ENTRMID,ENTRDD,CMFCTOP,          &
+                       CMFCMAX,CMFCMIN,CMFDEPS,RHCDD,CPRCON,            &
+                       LMFPEN,LMFSCV,LMFMID,LMFDD,LMFDUDV
 
 
Index: /LMDZ6/branches/Amaury_dev/libf/phylmd/YOEGWD.h
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/phylmd/YOEGWD.h	(revision 5127)
+++ /LMDZ6/branches/Amaury_dev/libf/phylmd/YOEGWD.h	(revision 5128)
@@ -25,7 +25,7 @@
 
       COMMON/YOEGWD/ GFRCRIT,GKWAKE,GRCRIT,GVCRIT,GKDRAG,GKLIFT,        &
-     &     GHMAX,GRAHILO,GSIGCR,NKTOPG,NSTRA,GSSEC,GTSEC,GVSEC,         &
-     &     GWD_RANDO_RUWMAX, gwd_rando_sat,                             &
-     &     GWD_FRONT_RUWMAX, gwd_front_sat
+           GHMAX,GRAHILO,GSIGCR,NKTOPG,NSTRA,GSSEC,GTSEC,GVSEC,         &
+           GWD_RANDO_RUWMAX, gwd_rando_sat,                             &
+           GWD_FRONT_RUWMAX, gwd_front_sat
 
       save /YOEGWD/
Index: /LMDZ6/branches/Amaury_dev/libf/phylmd/YOETHF.h
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/phylmd/YOETHF.h	(revision 5127)
+++ /LMDZ6/branches/Amaury_dev/libf/phylmd/YOETHF.h	(revision 5128)
@@ -22,10 +22,10 @@
                                   ! If FALSE, then variables set by suphel.F90
       COMMON /YOETHF/R2ES, R3LES, R3IES, R4LES, R4IES, R5LES, R5IES,    &
-     &               RVTMP2, RHOH2O,                                    &
-     &               R5ALVCP,R5ALSCP,RALVDCP,RALSDCP,                   &
-     &               RALFDCP,RTWAT,RTBER,RTBERCU,                       &
-     &               RTICE,RTICECU,RTWAT_RTICE_R,RTWAT_RTICECU_R,RKOOP1,&
-     &               RKOOP2,                                            &
-     &               OK_BAD_ECMWF_THERMO
+                     RVTMP2, RHOH2O,                                    &
+                     R5ALVCP,R5ALSCP,RALVDCP,RALSDCP,                   &
+                     RALFDCP,RTWAT,RTBER,RTBERCU,                       &
+                     RTICE,RTICECU,RTWAT_RTICE_R,RTWAT_RTICECU_R,RKOOP1,&
+                     RKOOP2,                                            &
+                     OK_BAD_ECMWF_THERMO
 
 !$OMP THREADPRIVATE(/YOETHF/)
Index: /LMDZ6/branches/Amaury_dev/libf/phylmd/YOMCST.h
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/phylmd/YOMCST.h	(revision 5127)
+++ /LMDZ6/branches/Amaury_dev/libf/phylmd/YOMCST.h	(revision 5128)
@@ -32,15 +32,15 @@
 
       COMMON/YOMCST/RPI   ,RCLUM ,RHPLA ,RKBOL ,RNAVO                   &
-     &      ,RDAY  ,REA   ,REPSM ,RSIYEA,RSIDAY,ROMEGA                  &
-     &      ,R_ecc, R_peri, R_incl                                      &
-     &      ,RA    ,RG    ,R1SA                                         &
-     &      ,RSIGMA                                                     &
-     &      ,R     ,RMD   ,RMV   ,RD    ,RV    ,RCPD                    &
-     &      ,RMO3  ,RMCO2 ,RMC   ,RMCH4 ,RMN2O ,RMCFC11 ,RMCFC12        &
-     &      ,RCPV  ,RCVD  ,RCVV  ,RKAPPA,RETV, eps_w                    &
-     &      ,RCW   ,RCS                                                 &
-     &      ,RLVTT ,RLSTT ,RLMLT ,RTT   ,RATM                           &
-     &      ,RESTT ,RALPW ,RBETW ,RGAMW ,RALPS ,RBETS ,RGAMS            &
-     &      ,RALPD ,RBETD ,RGAMD
+            ,RDAY  ,REA   ,REPSM ,RSIYEA,RSIDAY,ROMEGA                  &
+            ,R_ecc, R_peri, R_incl                                      &
+            ,RA    ,RG    ,R1SA                                         &
+            ,RSIGMA                                                     &
+            ,R     ,RMD   ,RMV   ,RD    ,RV    ,RCPD                    &
+            ,RMO3  ,RMCO2 ,RMC   ,RMCH4 ,RMN2O ,RMCFC11 ,RMCFC12        &
+            ,RCPV  ,RCVD  ,RCVV  ,RKAPPA,RETV, eps_w                    &
+            ,RCW   ,RCS                                                 &
+            ,RLVTT ,RLSTT ,RLMLT ,RTT   ,RATM                           &
+            ,RESTT ,RALPW ,RBETW ,RGAMW ,RALPS ,RBETS ,RGAMS            &
+            ,RALPD ,RBETD ,RGAMD
 !    ------------------------------------------------------------------
 !$OMP THREADPRIVATE(/YOMCST/)
Index: /LMDZ6/branches/Amaury_dev/libf/phylmd/YOMCST2.h
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/phylmd/YOMCST2.h	(revision 5127)
+++ /LMDZ6/branches/Amaury_dev/libf/phylmd/YOMCST2.h	(revision 5128)
@@ -6,8 +6,8 @@
 
       COMMON/YOMCST2/gammas,    alphas, betas, Fmax, scut,              &
-     &               qqa1, qqa2, qqa3,                                  &
-     &               Qcoef1max,Qcoef2max,                               &
-     &               Supcrit1, Supcrit2,                                &
-     &               choice,iflag_mix,coef_clos_ls,iflag_mix_adiab
+                     qqa1, qqa2, qqa3,                                  &
+                     Qcoef1max,Qcoef2max,                               &
+                     Supcrit1, Supcrit2,                                &
+                     choice,iflag_mix,coef_clos_ls,iflag_mix_adiab
 !$OMP THREADPRIVATE(/YOMCST2/)
 !    --------------------------------------------------------------------
Index: /LMDZ6/branches/Amaury_dev/libf/phylmd/calcul_REGDYN.h
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/phylmd/calcul_REGDYN.h	(revision 5127)
+++ /LMDZ6/branches/Amaury_dev/libf/phylmd/calcul_REGDYN.h	(revision 5128)
@@ -1,22 +1,22 @@
-c
-c $Header$
-c
-c calculs statistiques distribution nuage ftion du regime dynamique 
-c
-c Ce calcul doit etre fait a partir de valeurs mensuelles ??
-      CALL histo_o500_pctau(nbregdyn,pct_ocean,o500,fq_isccp,
-     &histoW,nhistoW)
-c
-c nhistoWt = somme de toutes les nhistoW
+!
+! $Header$
+!
+! calculs statistiques distribution nuage ftion du regime dynamique
+!
+! Ce calcul doit etre fait a partir de valeurs mensuelles ??
+      CALL histo_o500_pctau(nbregdyn,pct_ocean,o500,fq_isccp, &
+     histoW,nhistoW)
+!
+! nhistoWt = somme de toutes les nhistoW
       DO nreg=1, nbregdyn
        DO k = 1, kmaxm1
         DO l = 1, lmaxm1
          DO iw = 1, iwmax
-          nhistoWt(k,l,iw,nreg)=nhistoWt(k,l,iw,nreg)+
-     &    nhistoW(k,l,iw,nreg)
+          nhistoWt(k,l,iw,nreg)=nhistoWt(k,l,iw,nreg)+&
+         nhistoW(k,l,iw,nreg)
          ENDDO
         ENDDO
        ENDDO
       ENDDO
-c
-cIM 190504 END
+!
+!IM 190504 END
Index: /LMDZ6/branches/Amaury_dev/libf/phylmd/calltherm.F90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/phylmd/calltherm.F90	(revision 5127)
+++ /LMDZ6/branches/Amaury_dev/libf/phylmd/calltherm.F90	(revision 5128)
@@ -33,4 +33,5 @@
       USE lmdz_thermcell_old, ONLY: thermcell, thermcell_2002, thermcell_eau, calcul_sec, thermcell_sec
       USE lmdz_abort_physic, ONLY: abort_physic
+
 #ifdef ISO
       USE infotrac_phy, ONLY: ntiso
Index: /LMDZ6/branches/Amaury_dev/libf/phylmd/clesphys.h
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/phylmd/clesphys.h	(revision 5127)
+++ /LMDZ6/branches/Amaury_dev/libf/phylmd/clesphys.h	(revision 5128)
@@ -116,54 +116,54 @@
 ! REAL FIRST
 ! rajout choix_bulk et nit_bulk kz0 par Olivier Torres
-     &       co2_ppm, solaire                                           &
-     &     , RCO2, RCH4, RN2O, RCFC11, RCFC12                           &
-     &     , RCO2_act, RCH4_act, RN2O_act, RCFC11_act, RCFC12_act       &
-     &     , RCO2_per, RCH4_per, RN2O_per, RCFC11_per, RCFC12_per       &
-     &     , CH4_ppb, N2O_ppb, CFC11_ppt, CFC12_ppt                     &
-     &     , CH4_ppb_per, N2O_ppb_per, CFC11_ppt_per, CFC12_ppt_per     &
-     &     , cdmmax,cdhmax,ksta,ksta_ter,f_ri_cd_min                    &
-     &     , fmagic, pmagic                                             &
-     &     , f_cdrag_ter,f_cdrag_oce,f_rugoro,z0min,tau_gl              &
-     &     , min_wind_speed,f_gust_wk,f_gust_bl,f_qsat_oce,f_z0qh_oce   &
-     &     , z0m_seaice,z0h_seaice,z0m_landice,z0h_landice              &
-     &     , freq_outNMC, freq_calNMC                                   &
-     &     , lonmin_ins, lonmax_ins, latmin_ins, latmax_ins             &
-     &     , freq_ISCCP, ecrit_ISCCP, freq_COSP, freq_AIRS              &
-     &     , cvl_corr                                                   &
-     &     , qsol0,albsno0,evap0                                        &
-     &     , co2_ppm0                                                   &
-     &     , tau_thermals                                               &
+             co2_ppm, solaire                                           &
+           , RCO2, RCH4, RN2O, RCFC11, RCFC12                           &
+           , RCO2_act, RCH4_act, RN2O_act, RCFC11_act, RCFC12_act       &
+           , RCO2_per, RCH4_per, RN2O_per, RCFC11_per, RCFC12_per       &
+           , CH4_ppb, N2O_ppb, CFC11_ppt, CFC12_ppt                     &
+           , CH4_ppb_per, N2O_ppb_per, CFC11_ppt_per, CFC12_ppt_per     &
+           , cdmmax,cdhmax,ksta,ksta_ter,f_ri_cd_min                    &
+           , fmagic, pmagic                                             &
+           , f_cdrag_ter,f_cdrag_oce,f_rugoro,z0min,tau_gl              &
+           , min_wind_speed,f_gust_wk,f_gust_bl,f_qsat_oce,f_z0qh_oce   &
+           , z0m_seaice,z0h_seaice,z0m_landice,z0h_landice              &
+           , freq_outNMC, freq_calNMC                                   &
+           , lonmin_ins, lonmax_ins, latmin_ins, latmax_ins             &
+           , freq_ISCCP, ecrit_ISCCP, freq_COSP, freq_AIRS              &
+           , cvl_corr                                                   &
+           , qsol0,albsno0,evap0                                        &
+           , co2_ppm0                                                   &
+           , tau_thermals                                               &
 !FC
-     &     , Cd_frein,zrel_oro_t,zpmm_orodr_t,zpmm_orolf_t,zstd_orodr_t &
-     &     , ecrit_LES                                                  &
-     &     , ecrit_ins, ecrit_hf, ecrit_day                             &
-     &     , ecrit_mth, ecrit_tra, ecrit_reg                            &
+           , Cd_frein,zrel_oro_t,zpmm_orodr_t,zpmm_orolf_t,zstd_orodr_t &
+           , ecrit_LES                                                  &
+           , ecrit_ins, ecrit_hf, ecrit_day                             &
+           , ecrit_mth, ecrit_tra, ecrit_reg                            &
 ! THEN INTEGER AND LOGICALS
-     &     , top_height                                                 &
-     &     , iflag_cycle_diurne, soil_model, new_oliq                   &
-     &     , ok_orodr, ok_orolf, ok_limitvrai, nbapp_rad                &
-     &     , iflag_con, nbapp_cv, nbapp_wk                              &
-     &     , choix_bulk, nit_bulk, kz0                                  &
-     &     , iflag_ener_conserv                                         &
-     &     , ok_suntime_rrtm                                            & 
-     &     , overlap                                                    &
-     &     , ok_kzmin                                                   &
-     &     , lev_histhf, lev_histday, lev_histmth                       &
-     &     , lev_histins, lev_histLES, lev_histdayNMC, levout_histNMC   &
-     &     , ok_histNMC                                                 &
-     &     , type_run, ok_regdyn, ok_cosp, ok_airs                      &
-     &     , ok_mensuelCOSP,ok_journeCOSP,ok_hfCOSP                     &
-     &     , ip_ebil_phy                                                &
-     &     , iflag_gusts ,iflag_z0_oce                                  &
-     &     , ok_lic_melt, ok_lic_cond, aer_type                         &
-     &     , iflag_rrtm, ok_strato,ok_hines, ok_qch4                    &
-     &     , iflag_ice_thermo, ok_ice_sursat                            & 
-     &     , ok_plane_h2o, ok_plane_contrail                            & 
-     &     , ok_gwd_rando, NSW, iflag_albedo                            &
-     &     , ok_chlorophyll,ok_conserv_q, adjust_tropopause             &
-     &     , ok_daily_climoz, ok_all_xml, ok_lwoff                      &
-     &     , iflag_phytrac, ok_new_lscp, ok_bs, ok_rad_bs               &
-     &     ,  iflag_thermals,nsplit_thermals              &
-     &     , iflag_physiq, ok_3Deffect, ok_water_mass_fixer
+           , top_height                                                 &
+           , iflag_cycle_diurne, soil_model, new_oliq                   &
+           , ok_orodr, ok_orolf, ok_limitvrai, nbapp_rad                &
+           , iflag_con, nbapp_cv, nbapp_wk                              &
+           , choix_bulk, nit_bulk, kz0                                  &
+           , iflag_ener_conserv                                         &
+           , ok_suntime_rrtm                                            &
+           , overlap                                                    &
+           , ok_kzmin                                                   &
+           , lev_histhf, lev_histday, lev_histmth                       &
+           , lev_histins, lev_histLES, lev_histdayNMC, levout_histNMC   &
+           , ok_histNMC                                                 &
+           , type_run, ok_regdyn, ok_cosp, ok_airs                      &
+           , ok_mensuelCOSP,ok_journeCOSP,ok_hfCOSP                     &
+           , ip_ebil_phy                                                &
+           , iflag_gusts ,iflag_z0_oce                                  &
+           , ok_lic_melt, ok_lic_cond, aer_type                         &
+           , iflag_rrtm, ok_strato,ok_hines, ok_qch4                    &
+           , iflag_ice_thermo, ok_ice_sursat                            &
+           , ok_plane_h2o, ok_plane_contrail                            &
+           , ok_gwd_rando, NSW, iflag_albedo                            &
+           , ok_chlorophyll,ok_conserv_q, adjust_tropopause             &
+           , ok_daily_climoz, ok_all_xml, ok_lwoff                      &
+           , iflag_phytrac, ok_new_lscp, ok_bs, ok_rad_bs               &
+           ,  iflag_thermals,nsplit_thermals              &
+           , iflag_physiq, ok_3Deffect, ok_water_mass_fixer
        save /clesphys/
 !$OMP THREADPRIVATE(/clesphys/)
Index: /LMDZ6/branches/Amaury_dev/libf/phylmd/comsoil.h
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/phylmd/comsoil.h	(revision 5127)
+++ /LMDZ6/branches/Amaury_dev/libf/phylmd/comsoil.h	(revision 5128)
@@ -3,5 +3,5 @@
 
       common /comsoil/inertie_sol,inertie_sno,inertie_sic,inertie_lic,  &
-     &                iflag_sic,iflag_inertie
+                      iflag_sic,iflag_inertie
       REAL inertie_sol,inertie_sno,inertie_sic,inertie_lic
       INTEGER iflag_sic,iflag_inertie
Index: /LMDZ6/branches/Amaury_dev/libf/phylmd/dyn1d/1D_decl_cases.h
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/phylmd/dyn1d/1D_decl_cases.h	(revision 5127)
+++ /LMDZ6/branches/Amaury_dev/libf/phylmd/dyn1d/1D_decl_cases.h	(revision 5128)
@@ -190,5 +190,5 @@
 
         common /turb_forcing/                                                   &
-     &  dtime_frcg,hthturb_gcssold, hqturb_gcssold,Turb_fcg_gcssold
+        dtime_frcg,hthturb_gcssold, hqturb_gcssold,Turb_fcg_gcssold
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 ! Declarations specifiques au cas Arm_cu
Index: /LMDZ6/branches/Amaury_dev/libf/phylmd/dyn1d/1D_interp_cases.h
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/phylmd/dyn1d/1D_interp_cases.h	(revision 5127)
+++ /LMDZ6/branches/Amaury_dev/libf/phylmd/dyn1d/1D_interp_cases.h	(revision 5128)
@@ -9,25 +9,25 @@
         CALL interp_case_time_std(daytime,day1,annee_ref                                       &
 !    &       ,year_ini_cas,day_ju_ini_cas,nt_cas,pdt_cas,nlev_cas                           &
-     &       ,nt_cas,nlev_cas                                                               &
-     &       ,ts_cas,tskin_cas,ps_cas,plev_cas,t_cas,th_cas,thv_cas,thl_cas,qv_cas,ql_cas,qi_cas      &
-     &       ,u_cas,v_cas,ug_cas,vg_cas                                                     &
-     &       ,temp_nudg_cas,qv_nudg_cas,u_nudg_cas,v_nudg_cas                               &
-     &       ,invtau_temp_nudg_cas,invtau_qv_nudg_cas,invtau_u_nudg_cas,invtau_v_nudg_cas    &
-     &       ,vitw_cas,omega_cas,tke_cas,du_cas,hu_cas,vu_cas                                       &
-     &       ,dv_cas,hv_cas,vv_cas,dt_cas,ht_cas,vt_cas,dtrad_cas                           &
-     &       ,dq_cas,hq_cas,vq_cas,dth_cas,hth_cas,vth_cas,lat_cas,sens_cas,ustar_cas       &
-     &       ,uw_cas,vw_cas,q1_cas,q2_cas,tkes_cas                                           &
+             ,nt_cas,nlev_cas                                                               &
+             ,ts_cas,tskin_cas,ps_cas,plev_cas,t_cas,th_cas,thv_cas,thl_cas,qv_cas,ql_cas,qi_cas      &
+             ,u_cas,v_cas,ug_cas,vg_cas                                                     &
+             ,temp_nudg_cas,qv_nudg_cas,u_nudg_cas,v_nudg_cas                               &
+             ,invtau_temp_nudg_cas,invtau_qv_nudg_cas,invtau_u_nudg_cas,invtau_v_nudg_cas    &
+             ,vitw_cas,omega_cas,tke_cas,du_cas,hu_cas,vu_cas                                       &
+             ,dv_cas,hv_cas,vv_cas,dt_cas,ht_cas,vt_cas,dtrad_cas                           &
+             ,dq_cas,hq_cas,vq_cas,dth_cas,hth_cas,vth_cas,lat_cas,sens_cas,ustar_cas       &
+             ,uw_cas,vw_cas,q1_cas,q2_cas,tkes_cas                                           &
 
-     &       ,ts_prof_cas,tskin_prof_cas,ps_prof_cas,plev_prof_cas,t_prof_cas,theta_prof_cas,thv_prof_cas  &
-     &       ,thl_prof_cas,qv_prof_cas,ql_prof_cas,qi_prof_cas                              &
-     &       ,u_prof_cas,v_prof_cas,ug_prof_cas,vg_prof_cas                                 &
-     &       ,temp_nudg_prof_cas,qv_nudg_prof_cas,u_nudg_prof_cas,v_nudg_prof_cas           &
-     &       ,invtau_temp_nudg_prof_cas,invtau_qv_nudg_prof_cas,invtau_u_nudg_prof_cas,invtau_v_nudg_prof_cas  &     
-     &       ,vitw_prof_cas,omega_prof_cas,tke_prof_cas                                     &
-     &       ,du_prof_cas,hu_prof_cas,vu_prof_cas                                           &
-     &       ,dv_prof_cas,hv_prof_cas,vv_prof_cas,dt_prof_cas,ht_prof_cas,vt_prof_cas       &
-     &       ,dtrad_prof_cas,dq_prof_cas,hq_prof_cas,vq_prof_cas                            &
-     &       ,dth_prof_cas,hth_prof_cas,vth_prof_cas,lat_prof_cas                           &
-     &       ,sens_prof_cas,ustar_prof_cas,uw_prof_cas,vw_prof_cas,q1_prof_cas,q2_prof_cas,tkes_prof_cas)
+             ,ts_prof_cas,tskin_prof_cas,ps_prof_cas,plev_prof_cas,t_prof_cas,theta_prof_cas,thv_prof_cas  &
+             ,thl_prof_cas,qv_prof_cas,ql_prof_cas,qi_prof_cas                              &
+             ,u_prof_cas,v_prof_cas,ug_prof_cas,vg_prof_cas                                 &
+             ,temp_nudg_prof_cas,qv_nudg_prof_cas,u_nudg_prof_cas,v_nudg_prof_cas           &
+             ,invtau_temp_nudg_prof_cas,invtau_qv_nudg_prof_cas,invtau_u_nudg_prof_cas,invtau_v_nudg_prof_cas  &
+             ,vitw_prof_cas,omega_prof_cas,tke_prof_cas                                     &
+             ,du_prof_cas,hu_prof_cas,vu_prof_cas                                           &
+             ,dv_prof_cas,hv_prof_cas,vv_prof_cas,dt_prof_cas,ht_prof_cas,vt_prof_cas       &
+             ,dtrad_prof_cas,dq_prof_cas,hq_prof_cas,vq_prof_cas                            &
+             ,dth_prof_cas,hth_prof_cas,vth_prof_cas,lat_prof_cas                           &
+             ,sens_prof_cas,ustar_prof_cas,uw_prof_cas,vw_prof_cas,q1_prof_cas,q2_prof_cas,tkes_prof_cas)
 ! EV tg instead of ts_cur
              tg = ts_prof_cas
@@ -41,23 +41,23 @@
 ! vertical interpolation:
       CALL interp2_case_vertical_std(play,plev,nlev_cas,plev_prof_cas                                              &
-     &         ,t_prof_cas,theta_prof_cas,thv_prof_cas,thl_prof_cas                                       &
-     &         ,qv_prof_cas,ql_prof_cas,qi_prof_cas,u_prof_cas,v_prof_cas                                 &
-     &         ,ug_prof_cas,vg_prof_cas                                                                   &
-     &         ,temp_nudg_prof_cas,qv_nudg_prof_cas,u_nudg_prof_cas,v_nudg_prof_cas                       &
-     &         ,invtau_temp_nudg_prof_cas,invtau_qv_nudg_prof_cas,invtau_u_nudg_prof_cas,invtau_v_nudg_prof_cas &
+               ,t_prof_cas,theta_prof_cas,thv_prof_cas,thl_prof_cas                                       &
+               ,qv_prof_cas,ql_prof_cas,qi_prof_cas,u_prof_cas,v_prof_cas                                 &
+               ,ug_prof_cas,vg_prof_cas                                                                   &
+               ,temp_nudg_prof_cas,qv_nudg_prof_cas,u_nudg_prof_cas,v_nudg_prof_cas                       &
+               ,invtau_temp_nudg_prof_cas,invtau_qv_nudg_prof_cas,invtau_u_nudg_prof_cas,invtau_v_nudg_prof_cas &
 
-     &         ,vitw_prof_cas,omega_prof_cas,tke_prof_cas                                                 &
-     &         ,du_prof_cas,hu_prof_cas,vu_prof_cas,dv_prof_cas,hv_prof_cas,vv_prof_cas                   &
-     &         ,dt_prof_cas,ht_prof_cas,vt_prof_cas,dtrad_prof_cas,dq_prof_cas,hq_prof_cas,vq_prof_cas    &
-     &         ,dth_prof_cas,hth_prof_cas,vth_prof_cas                                                    &
+               ,vitw_prof_cas,omega_prof_cas,tke_prof_cas                                                 &
+               ,du_prof_cas,hu_prof_cas,vu_prof_cas,dv_prof_cas,hv_prof_cas,vv_prof_cas                   &
+               ,dt_prof_cas,ht_prof_cas,vt_prof_cas,dtrad_prof_cas,dq_prof_cas,hq_prof_cas,vq_prof_cas    &
+               ,dth_prof_cas,hth_prof_cas,vth_prof_cas                                                    &
 
-     &         ,t_mod_cas,theta_mod_cas,thv_mod_cas,thl_mod_cas,qv_mod_cas,ql_mod_cas,qi_mod_cas          &
-     &         ,u_mod_cas,v_mod_cas,ug_mod_cas,vg_mod_cas                                                 &
-     &         ,temp_nudg_mod_cas,qv_nudg_mod_cas,u_nudg_mod_cas,v_nudg_mod_cas                           &
-     &         ,invtau_temp_nudg_mod_cas,invtau_qv_nudg_mod_cas,invtau_u_nudg_mod_cas,invtau_v_nudg_mod_cas   &     
-     &         ,w_mod_cas,omega_mod_cas,tke_mod_cas                                                       &
-     &         ,du_mod_cas,hu_mod_cas,vu_mod_cas,dv_mod_cas,hv_mod_cas,vv_mod_cas                         &
-     &         ,dt_mod_cas,ht_mod_cas,vt_mod_cas,dtrad_mod_cas,dq_mod_cas,hq_mod_cas,vq_mod_cas           &
-     &         ,dth_mod_cas,hth_mod_cas,vth_mod_cas,mxcalc)
+               ,t_mod_cas,theta_mod_cas,thv_mod_cas,thl_mod_cas,qv_mod_cas,ql_mod_cas,qi_mod_cas          &
+               ,u_mod_cas,v_mod_cas,ug_mod_cas,vg_mod_cas                                                 &
+               ,temp_nudg_mod_cas,qv_nudg_mod_cas,u_nudg_mod_cas,v_nudg_mod_cas                           &
+               ,invtau_temp_nudg_mod_cas,invtau_qv_nudg_mod_cas,invtau_u_nudg_mod_cas,invtau_v_nudg_mod_cas   &
+               ,w_mod_cas,omega_mod_cas,tke_mod_cas                                                       &
+               ,du_mod_cas,hu_mod_cas,vu_mod_cas,dv_mod_cas,hv_mod_cas,vv_mod_cas                         &
+               ,dt_mod_cas,ht_mod_cas,vt_mod_cas,dtrad_mod_cas,dq_mod_cas,hq_mod_cas,vq_mod_cas           &
+               ,dth_mod_cas,hth_mod_cas,vth_mod_cas,mxcalc)
 
 
Index: /LMDZ6/branches/Amaury_dev/libf/phylmd/dyn1d/1D_read_forc_cases.h
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/phylmd/dyn1d/1D_read_forc_cases.h	(revision 5127)
+++ /LMDZ6/branches/Amaury_dev/libf/phylmd/dyn1d/1D_read_forc_cases.h	(revision 5128)
@@ -22,25 +22,25 @@
         CALL interp_case_time_std(daytime,day1,annee_ref                                       &
 !    &       ,year_ini_cas,day_ju_ini_cas,nt_cas,pdt_cas,nlev_cas                           &
-     &       ,nt_cas,nlev_cas                                                               &
-     &       ,ts_cas,tskin_cas,ps_cas,plev_cas,t_cas,th_cas,thv_cas,thl_cas,qv_cas,ql_cas,qi_cas      &
-     &       ,u_cas,v_cas,ug_cas,vg_cas                                                     &
-     &       ,temp_nudg_cas,qv_nudg_cas,u_nudg_cas,v_nudg_cas                               &
-     &       ,invtau_temp_nudg_cas,invtau_qv_nudg_cas,invtau_u_nudg_cas,invtau_v_nudg_cas    &
-     &       ,vitw_cas,omega_cas,tke_cas,du_cas,hu_cas,vu_cas                               &
-     &       ,dv_cas,hv_cas,vv_cas,dt_cas,ht_cas,vt_cas,dtrad_cas                           &
-     &       ,dq_cas,hq_cas,vq_cas,dth_cas,hth_cas,vth_cas,lat_cas,sens_cas,ustar_cas       &
-     &       ,uw_cas,vw_cas,q1_cas,q2_cas,tkes_cas                                           &
+             ,nt_cas,nlev_cas                                                               &
+             ,ts_cas,tskin_cas,ps_cas,plev_cas,t_cas,th_cas,thv_cas,thl_cas,qv_cas,ql_cas,qi_cas      &
+             ,u_cas,v_cas,ug_cas,vg_cas                                                     &
+             ,temp_nudg_cas,qv_nudg_cas,u_nudg_cas,v_nudg_cas                               &
+             ,invtau_temp_nudg_cas,invtau_qv_nudg_cas,invtau_u_nudg_cas,invtau_v_nudg_cas    &
+             ,vitw_cas,omega_cas,tke_cas,du_cas,hu_cas,vu_cas                               &
+             ,dv_cas,hv_cas,vv_cas,dt_cas,ht_cas,vt_cas,dtrad_cas                           &
+             ,dq_cas,hq_cas,vq_cas,dth_cas,hth_cas,vth_cas,lat_cas,sens_cas,ustar_cas       &
+             ,uw_cas,vw_cas,q1_cas,q2_cas,tkes_cas                                           &
 
-     &       ,ts_prof_cas,tskin_prof_cas,ps_prof_cas,plev_prof_cas,t_prof_cas,theta_prof_cas,thv_prof_cas  &
-     &       ,thl_prof_cas,qv_prof_cas,ql_prof_cas,qi_prof_cas                              &
-     &       ,u_prof_cas,v_prof_cas,ug_prof_cas,vg_prof_cas                                 &
-     &       ,temp_nudg_prof_cas,qv_nudg_prof_cas,u_nudg_prof_cas,v_nudg_prof_cas           &
-     &       ,invtau_temp_nudg_prof_cas,invtau_qv_nudg_prof_cas,invtau_u_nudg_prof_cas,invtau_v_nudg_prof_cas &
-     &       ,vitw_prof_cas,omega_prof_cas,tke_prof_cas                                    &
-     &       ,du_prof_cas,hu_prof_cas,vu_prof_cas                                           &
-     &       ,dv_prof_cas,hv_prof_cas,vv_prof_cas,dt_prof_cas,ht_prof_cas,vt_prof_cas       &
-     &       ,dtrad_prof_cas,dq_prof_cas,hq_prof_cas,vq_prof_cas                            &
-     &       ,dth_prof_cas,hth_prof_cas,vth_prof_cas,lat_prof_cas                           &
-     &       ,sens_prof_cas,ustar_prof_cas,uw_prof_cas,vw_prof_cas,q1_prof_cas,q2_prof_cas,tkes_prof_cas)
+             ,ts_prof_cas,tskin_prof_cas,ps_prof_cas,plev_prof_cas,t_prof_cas,theta_prof_cas,thv_prof_cas  &
+             ,thl_prof_cas,qv_prof_cas,ql_prof_cas,qi_prof_cas                              &
+             ,u_prof_cas,v_prof_cas,ug_prof_cas,vg_prof_cas                                 &
+             ,temp_nudg_prof_cas,qv_nudg_prof_cas,u_nudg_prof_cas,v_nudg_prof_cas           &
+             ,invtau_temp_nudg_prof_cas,invtau_qv_nudg_prof_cas,invtau_u_nudg_prof_cas,invtau_v_nudg_prof_cas &
+             ,vitw_prof_cas,omega_prof_cas,tke_prof_cas                                    &
+             ,du_prof_cas,hu_prof_cas,vu_prof_cas                                           &
+             ,dv_prof_cas,hv_prof_cas,vv_prof_cas,dt_prof_cas,ht_prof_cas,vt_prof_cas       &
+             ,dtrad_prof_cas,dq_prof_cas,hq_prof_cas,vq_prof_cas                            &
+             ,dth_prof_cas,hth_prof_cas,vth_prof_cas,lat_prof_cas                           &
+             ,sens_prof_cas,ustar_prof_cas,uw_prof_cas,vw_prof_cas,q1_prof_cas,q2_prof_cas,tkes_prof_cas)
 
       do l = 1, nlev_cas
@@ -51,22 +51,22 @@
 !      WRITE(*,*)'avant interp vert', t_prof
       CALL interp2_case_vertical_std(play,plev,nlev_cas,plev_prof_cas                                              &
-     &         ,t_prof_cas,theta_prof_cas,thv_prof_cas,thl_prof_cas                                          &
-     &         ,qv_prof_cas,ql_prof_cas,qi_prof_cas,u_prof_cas,v_prof_cas                                 &
-     &         ,ug_prof_cas,vg_prof_cas                                                                   &
-     &       ,temp_nudg_prof_cas,qv_nudg_prof_cas,u_nudg_prof_cas,v_nudg_prof_cas                         &
-     &       ,invtau_temp_nudg_prof_cas,invtau_qv_nudg_prof_cas,invtau_u_nudg_prof_cas,invtau_v_nudg_prof_cas       &
-     &         ,vitw_prof_cas,omega_prof_cas,tke_prof_cas                                                 &
-     &         ,du_prof_cas,hu_prof_cas,vu_prof_cas,dv_prof_cas,hv_prof_cas,vv_prof_cas                   &
-     &         ,dt_prof_cas,ht_prof_cas,vt_prof_cas,dtrad_prof_cas,dq_prof_cas,hq_prof_cas,vq_prof_cas    &
-     &         ,dth_prof_cas,hth_prof_cas,vth_prof_cas                                                    &
+               ,t_prof_cas,theta_prof_cas,thv_prof_cas,thl_prof_cas                                          &
+               ,qv_prof_cas,ql_prof_cas,qi_prof_cas,u_prof_cas,v_prof_cas                                 &
+               ,ug_prof_cas,vg_prof_cas                                                                   &
+             ,temp_nudg_prof_cas,qv_nudg_prof_cas,u_nudg_prof_cas,v_nudg_prof_cas                         &
+             ,invtau_temp_nudg_prof_cas,invtau_qv_nudg_prof_cas,invtau_u_nudg_prof_cas,invtau_v_nudg_prof_cas       &
+               ,vitw_prof_cas,omega_prof_cas,tke_prof_cas                                                 &
+               ,du_prof_cas,hu_prof_cas,vu_prof_cas,dv_prof_cas,hv_prof_cas,vv_prof_cas                   &
+               ,dt_prof_cas,ht_prof_cas,vt_prof_cas,dtrad_prof_cas,dq_prof_cas,hq_prof_cas,vq_prof_cas    &
+               ,dth_prof_cas,hth_prof_cas,vth_prof_cas                                                    &
 
-     &         ,t_mod_cas,theta_mod_cas,thv_mod_cas,thl_mod_cas,qv_mod_cas,ql_mod_cas,qi_mod_cas          &
-     &         ,u_mod_cas,v_mod_cas,ug_mod_cas,vg_mod_cas                                                 &
-     &         ,temp_nudg_mod_cas,qv_nudg_mod_cas,u_nudg_mod_cas,v_nudg_mod_cas                           &
-     &         ,invtau_temp_nudg_mod_cas,invtau_qv_nudg_mod_cas,invtau_u_nudg_mod_cas,invtau_v_nudg_mod_cas        &
-     &         ,w_mod_cas,omega_mod_cas,tke_mod_cas                                                       &
-     &         ,du_mod_cas,hu_mod_cas,vu_mod_cas,dv_mod_cas,hv_mod_cas,vv_mod_cas                         &
-     &         ,dt_mod_cas,ht_mod_cas,vt_mod_cas,dtrad_mod_cas,dq_mod_cas,hq_mod_cas,vq_mod_cas           &
-     &         ,dth_mod_cas,hth_mod_cas,vth_mod_cas,mxcalc)
+               ,t_mod_cas,theta_mod_cas,thv_mod_cas,thl_mod_cas,qv_mod_cas,ql_mod_cas,qi_mod_cas          &
+               ,u_mod_cas,v_mod_cas,ug_mod_cas,vg_mod_cas                                                 &
+               ,temp_nudg_mod_cas,qv_nudg_mod_cas,u_nudg_mod_cas,v_nudg_mod_cas                           &
+               ,invtau_temp_nudg_mod_cas,invtau_qv_nudg_mod_cas,invtau_u_nudg_mod_cas,invtau_v_nudg_mod_cas        &
+               ,w_mod_cas,omega_mod_cas,tke_mod_cas                                                       &
+               ,du_mod_cas,hu_mod_cas,vu_mod_cas,dv_mod_cas,hv_mod_cas,vv_mod_cas                         &
+               ,dt_mod_cas,ht_mod_cas,vt_mod_cas,dtrad_mod_cas,dq_mod_cas,hq_mod_cas,vq_mod_cas           &
+               ,dth_mod_cas,hth_mod_cas,vth_mod_cas,mxcalc)
 
 
Index: /LMDZ6/branches/Amaury_dev/libf/phylmd/dyn1d/compar1d.h
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/phylmd/dyn1d/compar1d.h	(revision 5127)
+++ /LMDZ6/branches/Amaury_dev/libf/phylmd/dyn1d/compar1d.h	(revision 5128)
@@ -46,15 +46,15 @@
       real    :: p_nudging_u, p_nudging_v, p_nudging_w, p_nudging_t, p_nudging_qv
       common/com_par1d/                                                 &
-     & nat_surf,tsurf,beta_surf,rugos,rugosh,                           &
-     & xqsol,qsurf,psurf,zsurf,albedo,time,time_ini,xlat,xlon,airefi,   &
-     & wtsurf,wqsurf,restart_runoff,xagesno,qsolinp,zpicinp,            &
-     & forcing_type,tend_u,tend_v,tend_w,tend_t,tend_q,tend_rayo,       &
-     & nudge_u,nudge_v,nudge_w,nudge_t,nudge_q,                         &
-     & iflag_nudge,snowmass,                                            &
-     & restart,ok_old_disvert,                                          &
-     & tadv, tadvv, tadvh, qadv, qadvv, qadvh, thadv, thadvv, thadvh,   &
-     & trad, forc_omega, forc_u, forc_v, forc_w, forc_geo, forc_ustar,  &
-     & nudging_u, nudging_v, nudging_t, nudging_qv, nudging_w,          &
-     & p_nudging_u, p_nudging_v, p_nudging_t, p_nudging_qv, p_nudging_w
+       nat_surf,tsurf,beta_surf,rugos,rugosh,                           &
+       xqsol,qsurf,psurf,zsurf,albedo,time,time_ini,xlat,xlon,airefi,   &
+       wtsurf,wqsurf,restart_runoff,xagesno,qsolinp,zpicinp,            &
+       forcing_type,tend_u,tend_v,tend_w,tend_t,tend_q,tend_rayo,       &
+       nudge_u,nudge_v,nudge_w,nudge_t,nudge_q,                         &
+       iflag_nudge,snowmass,                                            &
+       restart,ok_old_disvert,                                          &
+       tadv, tadvv, tadvh, qadv, qadvv, qadvh, thadv, thadvv, thadvh,   &
+       trad, forc_omega, forc_u, forc_v, forc_w, forc_geo, forc_ustar,  &
+       nudging_u, nudging_v, nudging_t, nudging_qv, nudging_w,          &
+       p_nudging_u, p_nudging_v, p_nudging_t, p_nudging_qv, p_nudging_w
 
 !$OMP THREADPRIVATE(/com_par1d/)
Index: /LMDZ6/branches/Amaury_dev/libf/phylmd/dyn1d/lmdz_1dutils.f90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/phylmd/dyn1d/lmdz_1dutils.f90	(revision 5127)
+++ /LMDZ6/branches/Amaury_dev/libf/phylmd/dyn1d/lmdz_1dutils.f90	(revision 5128)
@@ -1,5 +1,5 @@
 MODULE lmdz_1dutils
   IMPLICIT NONE; PRIVATE
-  PUBLIC fq_sat, conf_unicol, dyn1deta0, dyn1dredem, gr_fi_dyn, abort_gcm, gr_dyn_fi, &
+  PUBLIC fq_sat, conf_unicol, dyn1deta0, dyn1dredem, &
           disvert0, advect_vert, advect_va, lstendh, nudge_rht_init, nudge_uv_init, &
           nudge_rht, nudge_uv, interp2_case_vertical
@@ -981,114 +981,4 @@
 
 
-  SUBROUTINE gr_fi_dyn(nfield, ngrid, im, jm, pfi, pdyn)
-    USE lmdz_ssum_scopy, ONLY: scopy
-
-    IMPLICIT NONE
-    !=======================================================================
-    !   passage d'un champ de la grille scalaire a la grille physique
-    !=======================================================================
-
-    !-----------------------------------------------------------------------
-    !   declarations:
-    !   -------------
-
-    INTEGER im, jm, ngrid, nfield
-    REAL pdyn(im, jm, nfield)
-    REAL pfi(ngrid, nfield)
-
-    INTEGER i, j, ifield, ig
-
-    !-----------------------------------------------------------------------
-    !   calcul:
-    !   -------
-
-    DO ifield = 1, nfield
-      !   traitement des poles
-      DO i = 1, im
-        pdyn(i, 1, ifield) = pfi(1, ifield)
-        pdyn(i, jm, ifield) = pfi(ngrid, ifield)
-      ENDDO
-
-      !   traitement des point normaux
-      DO j = 2, jm - 1
-        ig = 2 + (j - 2) * (im - 1)
-        CALL SCOPY(im - 1, pfi(ig, ifield), 1, pdyn(1, j, ifield), 1)
-        pdyn(im, j, ifield) = pdyn(1, j, ifield)
-      ENDDO
-    ENDDO
-
-  END SUBROUTINE gr_fi_dyn
-
-
-  SUBROUTINE abort_gcm(modname, message, ierr)
-    USE IOIPSL
-
-    ! Stops the simulation cleanly, closing files and printing various
-    ! comments
-
-    !  Input: modname = name of calling program
-    !         message = stuff to print
-    !         ierr    = severity of situation ( = 0 normal )
-
-    CHARACTER(LEN = *) modname
-    INTEGER ierr
-    CHARACTER(LEN = *) message
-
-    WRITE(*, *) 'in abort_gcm'
-    CALL histclo
-    !     CALL histclo(2)
-    !     CALL histclo(3)
-    !     CALL histclo(4)
-    !     CALL histclo(5)
-    WRITE(*, *) 'out of histclo'
-    WRITE(*, *) 'Stopping in ', modname
-    WRITE(*, *) 'Reason = ', message
-    CALL getin_dump
-
-    IF (ierr == 0) THEN
-      WRITE(*, *) 'Everything is cool'
-    else
-      WRITE(*, *) 'Houston, we have a problem ', ierr
-    endif
-    STOP
-  END SUBROUTINE abort_gcm
-
-
-  SUBROUTINE gr_dyn_fi(nfield, im, jm, ngrid, pdyn, pfi)
-    IMPLICIT NONE
-    !=======================================================================
-    !   passage d'un champ de la grille scalaire a la grille physique
-    !=======================================================================
-
-    !-----------------------------------------------------------------------
-    !   declarations:
-    !   -------------
-
-    INTEGER im, jm, ngrid, nfield
-    REAL pdyn(im, jm, nfield)
-    REAL pfi(ngrid, nfield)
-
-    INTEGER j, ifield, ig
-
-    !-----------------------------------------------------------------------
-    !   calcul:
-    !   -------
-
-    IF(ngrid/=2 + (jm - 2) * (im - 1).AND.ngrid/=1)                          &
-            &    STOP 'probleme de dim'
-    !   traitement des poles
-    CALL SCOPY(nfield, pdyn, im * jm, pfi, ngrid)
-    CALL SCOPY(nfield, pdyn(1, jm, 1), im * jm, pfi(ngrid, 1), ngrid)
-
-    !   traitement des point normaux
-    DO ifield = 1, nfield
-      DO j = 2, jm - 1
-        ig = 2 + (j - 2) * (im - 1)
-        CALL SCOPY(im - 1, pdyn(1, j, ifield), 1, pfi(ig, ifield), 1)
-      ENDDO
-    ENDDO
-  END SUBROUTINE gr_dyn_fi
-
-
   SUBROUTINE disvert0(pa, preff, ap, bp, dpres, presnivs, nivsigs, nivsig)
 
@@ -1852,2 +1742,78 @@
 
 END MODULE lmdz_1dutils
+
+SUBROUTINE gr_fi_dyn(nfield, ngrid, im, jm, pfi, pdyn)
+  USE lmdz_ssum_scopy, ONLY: scopy
+
+  IMPLICIT NONE
+  !=======================================================================
+  !   passage d'un champ de la grille scalaire a la grille physique
+  !=======================================================================
+
+  !-----------------------------------------------------------------------
+  !   declarations:
+  !   -------------
+
+  INTEGER im, jm, ngrid, nfield
+  REAL pdyn(im, jm, nfield)
+  REAL pfi(ngrid, nfield)
+
+  INTEGER i, j, ifield, ig
+
+  !-----------------------------------------------------------------------
+  !   calcul:
+  !   -------
+
+  DO ifield = 1, nfield
+    !   traitement des poles
+    DO i = 1, im
+      pdyn(i, 1, ifield) = pfi(1, ifield)
+      pdyn(i, jm, ifield) = pfi(ngrid, ifield)
+    ENDDO
+
+    !   traitement des point normaux
+    DO j = 2, jm - 1
+      ig = 2 + (j - 2) * (im - 1)
+      CALL SCOPY(im - 1, pfi(ig, ifield), 1, pdyn(1, j, ifield), 1)
+      pdyn(im, j, ifield) = pdyn(1, j, ifield)
+    ENDDO
+  ENDDO
+
+END SUBROUTINE gr_fi_dyn
+
+SUBROUTINE gr_dyn_fi(nfield, im, jm, ngrid, pdyn, pfi)
+  USE lmdz_ssum_scopy, ONLY: scopy
+
+  IMPLICIT NONE
+  !=======================================================================
+  !   passage d'un champ de la grille scalaire a la grille physique
+  !=======================================================================
+
+  !-----------------------------------------------------------------------
+  !   declarations:
+  !   -------------
+
+  INTEGER im, jm, ngrid, nfield
+  REAL pdyn(im, jm, nfield)
+  REAL pfi(ngrid, nfield)
+
+  INTEGER j, ifield, ig
+
+  !-----------------------------------------------------------------------
+  !   calcul:
+  !   -------
+
+  IF(ngrid/=2 + (jm - 2) * (im - 1).AND.ngrid/=1)                          &
+          &    STOP 'probleme de dim'
+  !   traitement des poles
+  CALL SCOPY(nfield, pdyn, im * jm, pfi, ngrid)
+  CALL SCOPY(nfield, pdyn(1, jm, 1), im * jm, pfi(ngrid, 1), ngrid)
+
+  !   traitement des point normaux
+  DO ifield = 1, nfield
+    DO j = 2, jm - 1
+      ig = 2 + (j - 2) * (im - 1)
+      CALL SCOPY(im - 1, pdyn(1, j, ifield), 1, pfi(ig, ifield), 1)
+    ENDDO
+  ENDDO
+END SUBROUTINE gr_dyn_fi
Index: /LMDZ6/branches/Amaury_dev/libf/phylmd/dyn1d/lmdz_old_1dconv.f90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/phylmd/dyn1d/lmdz_old_1dconv.f90	(revision 5127)
+++ /LMDZ6/branches/Amaury_dev/libf/phylmd/dyn1d/lmdz_old_1dconv.f90	(revision 5128)
@@ -1,5 +1,5 @@
 MODULE lmdz_old_1dconv
-  IMPLICIT NONE; PRIVATE
-  PUBLIC get_uvd, copie
+   PRIVATE  ! -- We'd love to put IMPLICIT NONE;  here...
+  PUBLIC get_uvd, copie, get_uvd2, rdgrads, spaces
 CONTAINS
 
@@ -67,11 +67,11 @@
     INTEGER itap
     REAL dtime
-    REAL ht(100)
-    REAL hq(100)
-    REAL hu(100)
-    REAL hv(100)
-    REAL hw(100)
-    REAL hthturb(100)
-    REAL hqturb(100)
+    REAL ht(:)
+    REAL hq(:)
+    REAL hu(:)
+    REAL hv(:)
+    REAL hw(:)
+    REAL hthturb(:)
+    REAL hqturb(:)
     REAL Ts, Ts_subr
     LOGICAL imp_fcg
@@ -142,9 +142,6 @@
     ! variables destinees a la lecture du pas de temps du fichier de donnees
     !---------------------------------------------------------------------
-    character*80 aaa, atemps, spaces, apasmax
+    character*80 aaa, atemps, apasmax
     INTEGER nch, imn, ipa
-    !---------------------------------------------------------------------
-    !  procedures appelees
-    external rdgrads    !lire en iterant dans forcing.dat
     !---------------------------------------------------------------------
     PRINT*, 'le pas itap est:', itap
@@ -583,5 +580,5 @@
 
     character*4 a
-    character*80 aaa, anblvl, spaces
+    character*80 aaa, anblvl
     INTEGER nch
 
@@ -812,5 +809,5 @@
     ENDIF
   END
-  CHARACTER*(*) FUNCTION SPACES(STR, NSPACE)
+  CHARACTER*(80) FUNCTION SPACES(STR, NSPACE)
 
     ! CERN PROGLIB# M433    SPACES          .VERSION KERNFOR  4.14  860211
@@ -821,6 +818,6 @@
     !-    replaced by NSPACE blanks inside the string STR
 
-    CHARACTER*(*) STR
-    INTEGER nspace
+    CHARACTER*(80) STR
+    INTEGER nspace, IBLANK, ISPACE, INONBL, LENSPA
 
     LENSPA = LEN(SPACES)
@@ -854,5 +851,5 @@
 
     CHARACTER*(*) STR, SSTR
-    INTEGER I
+    INTEGER I, LENS, LENSS
 
     LENS = LEN(STR)
Index: /LMDZ6/branches/Amaury_dev/libf/phylmd/dyn1d/lmdz_old_lmdz1d.F90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/phylmd/dyn1d/lmdz_old_lmdz1d.F90	(revision 5127)
+++ /LMDZ6/branches/Amaury_dev/libf/phylmd/dyn1d/lmdz_old_lmdz1d.F90	(revision 5128)
@@ -2,5 +2,8 @@
 
 MODULE lmdz_old_lmdz1d
-  IMPLICIT NONE; PRIVATE
+  USE lmdz_old_1dconv, ONLY: copie, get_uvd2, get_uvd, rdgrads, spaces
+  USE lmdz_1dutils, ONLY: interp2_case_vertical, nudge_uv, nudge_rht, lstendh, nudge_uv_init, &
+          nudge_rht_init, disvert0
+   PRIVATE  ! -- We'd love to put IMPLICIT NONE;  here...
   PUBLIC old_lmdz1d
 CONTAINS
Index: /LMDZ6/branches/Amaury_dev/libf/phylmd/dyn1d/lmdz_scm.F90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/phylmd/dyn1d/lmdz_scm.F90	(revision 5127)
+++ /LMDZ6/branches/Amaury_dev/libf/phylmd/dyn1d/lmdz_scm.F90	(revision 5128)
@@ -1,4 +1,4 @@
 MODULE lmdz_scm
-  ; PRIVATE
+  PRIVATE  ! -- We'd love to put IMPLICIT NONE;  here...
   PUBLIC scm
 CONTAINS
@@ -41,8 +41,8 @@
             itau_dyn, itau_phy, start_time, year_len
     USE phys_cal_mod, ONLY: year_len_phys_cal_mod => year_len
-    USE lmdz_1dutils, ONLY: fq_sat, conf_unicol, dyn1deta0, dyn1dredem
+    USE lmdz_1dutils, ONLY: fq_sat, conf_unicol, dyn1deta0, dyn1dredem, disvert0
+
     USE lmdz_cppkeys_wrapper, ONLY: CPPKEY_OUTPUTPHYSSCM
-    END SUBROUTINE scm
-    
+
     INCLUDE "dimensions.h"
     INCLUDE "YOMCST.h"
Index: /LMDZ6/branches/Amaury_dev/libf/phylmd/dyn1d/replay1d.F90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/phylmd/dyn1d/replay1d.F90	(revision 5127)
+++ /LMDZ6/branches/Amaury_dev/libf/phylmd/dyn1d/replay1d.F90	(revision 5128)
@@ -88,34 +88,4 @@
 
 !=======================================================================
-SUBROUTINE abort_gcm(modname, message, ierr)
-  USE IOIPSL
-  ! Stops the simulation cleanly, closing files and printing various
-  ! comments
-  !=======================================================================
-
-  !  Input: modname = name of calling program
-  !         message = stuff to print
-  !         ierr    = severity of situation ( = 0 normal )
-
-  CHARACTER(LEN = *) modname
-  INTEGER ierr
-  CHARACTER(LEN = *) message
-
-  WRITE(*, *) 'in abort_gcm'
-  CALL histclo
-  WRITE(*, *) 'out of histclo'
-  WRITE(*, *) 'Stopping in ', modname
-  WRITE(*, *) 'Reason = ', message
-  CALL getin_dump
-
-  IF (ierr == 0) THEN
-    WRITE(*, *) 'Everything is cool'
-  else
-    WRITE(*, *) 'Houston, we have a problem ', ierr
-  endif
-  STOP
-END
-
-!=======================================================================
 SUBROUTINE gr_dyn_fi(nfield, im, jm, ngrid, pdyn, pfi)
   USE lmdz_ssum_scopy, ONLY: scopy
Index: /LMDZ6/branches/Amaury_dev/libf/phylmd/fcg_gcssold.h
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/phylmd/fcg_gcssold.h	(revision 5127)
+++ /LMDZ6/branches/Amaury_dev/libf/phylmd/fcg_gcssold.h	(revision 5128)
@@ -7,6 +7,6 @@
 
       common /fcg_gcssold/imp_fcg_gcssold,ts_fcg_gcssold,Tp_fcg_gcssold,        & 
-     & Tp_ini_gcssold,                                                          &
-     & xTurb_fcg_gcssold
+       Tp_ini_gcssold,                                                          &
+       xTurb_fcg_gcssold
 
 !$OMP THREADPRIVATE(/fcg_gcssold/)
Index: /LMDZ6/branches/Amaury_dev/libf/phylmd/fonte_neige_mod.F90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/phylmd/fonte_neige_mod.F90	(revision 5127)
+++ /LMDZ6/branches/Amaury_dev/libf/phylmd/fonte_neige_mod.F90	(revision 5128)
@@ -10,4 +10,5 @@
   USE dimphy, ONLY: klon
   USE indice_sol_mod
+
 
   IMPLICIT NONE
Index: /LMDZ6/branches/Amaury_dev/libf/phylmd/infotrac_phy.F90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/phylmd/infotrac_phy.F90	(revision 5127)
+++ /LMDZ6/branches/Amaury_dev/libf/phylmd/infotrac_phy.F90	(revision 5128)
@@ -135,4 +135,6 @@
     USE lmdz_abort_physic, ONLY: abort_physic
     USE lmdz_iniprint, ONLY: lunout, prt_level
+
+
     IMPLICIT NONE
     !==============================================================================================================================
Index: /LMDZ6/branches/Amaury_dev/libf/phylmd/ini_histREGDYN.h
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/phylmd/ini_histREGDYN.h	(revision 5127)
+++ /LMDZ6/branches/Amaury_dev/libf/phylmd/ini_histREGDYN.h	(revision 5128)
@@ -49,74 +49,74 @@
 c TROP
          CALL histdef(nid_regdyn, "hw1", "Tropics Histogram ", "%",
-     &                kmaxm1,lmaxm1,nhoriRD, iwmax,1,iwmax, komega, 32, 
-     &                "ave(X)", zstophy,zout)
+                      kmaxm1,lmaxm1,nhoriRD, iwmax,1,iwmax, komega, 32,
+                      "ave(X)", zstophy,zout)
 
          CALL histdef(nid_regdyn, "nh1", "Nb of pixels Tropics Histo",
-     &                "%",kmaxm1,lmaxm1,nhoriRD, iwmax,1,iwmax, komega,
-     &                32,"ave(X)", zstophy,zout)
+                      "%",kmaxm1,lmaxm1,nhoriRD, iwmax,1,iwmax, komega,
+                      32,"ave(X)", zstophy,zout)
 c
 
          CALL histdef(nid_regdyn, "nht1",
-     &                "Total Nb pixels Tropics Histo",
-     &                "%",kmaxm1,lmaxm1,nhoriRD, iwmax,1,iwmax, komega,
-     &                32,"ave(X)", zstophy,zout)
+                      "Total Nb pixels Tropics Histo",
+                      "%",kmaxm1,lmaxm1,nhoriRD, iwmax,1,iwmax, komega,
+                      32,"ave(X)", zstophy,zout)
 c
 c PAN
          CALL histdef(nid_regdyn, "hw2", "North Pacific Histogram", "%",
-     &                kmaxm1,lmaxm1,nhoriRD, iwmax,1,iwmax, komega, 32, 
-     &                "ave(X)", zstophy,zout)
+                      kmaxm1,lmaxm1,nhoriRD, iwmax,1,iwmax, komega, 32,
+                      "ave(X)", zstophy,zout)
 
          CALL histdef(nid_regdyn, "nh2", "Nb of pixels North Pacific",
-     &                "%",kmaxm1,lmaxm1,nhoriRD, iwmax,1,iwmax, komega,
-     &                32,"ave(X)", zstophy,zout)
+                      "%",kmaxm1,lmaxm1,nhoriRD, iwmax,1,iwmax, komega,
+                      32,"ave(X)", zstophy,zout)
 c
 
          CALL histdef(nid_regdyn, "nht2",
-     &                "Total Nb pixels North Pacific Histo",
-     &                "%",kmaxm1,lmaxm1,nhoriRD, iwmax,1,iwmax, komega,
-     &                32,"ave(X)", zstophy,zout)
+                      "Total Nb pixels North Pacific Histo",
+                      "%",kmaxm1,lmaxm1,nhoriRD, iwmax,1,iwmax, komega,
+                      32,"ave(X)", zstophy,zout)
 c CAL
          CALL histdef(nid_regdyn, "hw3", "California Histogram", "%",
-     &                kmaxm1,lmaxm1,nhoriRD, iwmax,1,iwmax, komega, 32, 
-     &                "ave(X)", zstophy,zout)
+                      kmaxm1,lmaxm1,nhoriRD, iwmax,1,iwmax, komega, 32,
+                      "ave(X)", zstophy,zout)
 
          CALL histdef(nid_regdyn, "nh3", 
-     &                "Nb of pixels California Histo",
-     &                "%",kmaxm1,lmaxm1,nhoriRD, iwmax,1,iwmax, komega,
-     &                32,"ave(X)", zstophy,zout)
+                      "Nb of pixels California Histo",
+                      "%",kmaxm1,lmaxm1,nhoriRD, iwmax,1,iwmax, komega,
+                      32,"ave(X)", zstophy,zout)
 c
 
          CALL histdef(nid_regdyn, "nht3",
-     &                "Total Nb pixels California Histo",
-     &                "%",kmaxm1,lmaxm1,nhoriRD, iwmax,1,iwmax, komega,
-     &                32,"ave(X)", zstophy,zout)
+                      "Total Nb pixels California Histo",
+                      "%",kmaxm1,lmaxm1,nhoriRD, iwmax,1,iwmax, komega,
+                      32,"ave(X)", zstophy,zout)
 c HAW
          CALL histdef(nid_regdyn, "hw4", "Hawai Histogram", "%",
-     &                kmaxm1,lmaxm1,nhoriRD, iwmax,1,iwmax, komega, 32, 
-     &                "ave(X)", zstophy,zout)
+                      kmaxm1,lmaxm1,nhoriRD, iwmax,1,iwmax, komega, 32,
+                      "ave(X)", zstophy,zout)
 
          CALL histdef(nid_regdyn, "nh4", "Nb of pixels Hawai Histo",
-     &                "%",kmaxm1,lmaxm1,nhoriRD, iwmax,1,iwmax, komega,
-     &                32,"ave(X)", zstophy,zout)
+                      "%",kmaxm1,lmaxm1,nhoriRD, iwmax,1,iwmax, komega,
+                      32,"ave(X)", zstophy,zout)
 c
 
          CALL histdef(nid_regdyn, "nht4",
-     &                "Total Nb pixels Hawai Histo",
-     &                "%",kmaxm1,lmaxm1,nhoriRD, iwmax,1,iwmax, komega,
-     &                32,"ave(X)", zstophy,zout)
+                      "Total Nb pixels Hawai Histo",
+                      "%",kmaxm1,lmaxm1,nhoriRD, iwmax,1,iwmax, komega,
+                      32,"ave(X)", zstophy,zout)
 c WAP
          CALL histdef(nid_regdyn, "hw5", "Warm Pool Histogram", "%",
-     &                kmaxm1,lmaxm1,nhoriRD, iwmax,1,iwmax, komega, 32, 
-     &                "ave(X)", zstophy,zout)
+                      kmaxm1,lmaxm1,nhoriRD, iwmax,1,iwmax, komega, 32,
+                      "ave(X)", zstophy,zout)
 
          CALL histdef(nid_regdyn, "nh5", "Nb of pixels Warm Pool Histo",
-     &                "%",kmaxm1,lmaxm1,nhoriRD, iwmax,1,iwmax, komega,
-     &                32,"ave(X)", zstophy,zout)
+                      "%",kmaxm1,lmaxm1,nhoriRD, iwmax,1,iwmax, komega,
+                      32,"ave(X)", zstophy,zout)
 c
 
          CALL histdef(nid_regdyn, "nht5",
-     &                "Total Nb pixels Warm Pool Histo",
-     &                "%",kmaxm1,lmaxm1,nhoriRD, iwmax,1,iwmax, komega,
-     &                32,"ave(X)", zstophy,zout)
+                      "Total Nb pixels Warm Pool Histo",
+                      "%",kmaxm1,lmaxm1,nhoriRD, iwmax,1,iwmax, komega,
+                      32,"ave(X)", zstophy,zout)
 c
          CALL histend(nid_regdyn)
Index: /LMDZ6/branches/Amaury_dev/libf/phylmd/inlandsis/sisvat_qso.f90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/phylmd/inlandsis/sisvat_qso.f90	(revision 5127)
+++ /LMDZ6/branches/Amaury_dev/libf/phylmd/inlandsis/sisvat_qso.f90	(revision 5128)
@@ -533,11 +533,9 @@
       ist    =   isotSV(ikl)                   ! Soil Type
       SatRat =  (eta_SV(ikl,isl)-etadSV(ist)) & ! OverSaturation Rate
-            *ro_Wat         *dzAvSV(isl) & !
-            *LSdzsv(ikl) & !
-            /dt__SV        !
-      SoRnOF(ikl)     =          SoRnOF(ikl) & !
-            + max(zero,SatRat)       !
-      RuofSV(ikl,3)   = RuofSV(ikl,3) + &
-            + max(zero,SatRat)
+            *ro_Wat         *dzAvSV(isl) &
+            *LSdzsv(ikl) &
+            /dt__SV
+      SoRnOF(ikl)     = SoRnOF(ikl) + max(zero,SatRat)
+      RuofSV(ikl,3)   = RuofSV(ikl,3) + max(zero,SatRat)
       eta_SV(ikl,isl) = max(epsi & !
   ! #ED.                         +etamSV(isotSV(ikl))!
Index: /LMDZ6/branches/Amaury_dev/libf/phylmd/inlandsis/surf_inlandsis_mod.F90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/phylmd/inlandsis/surf_inlandsis_mod.F90	(revision 5127)
+++ /LMDZ6/branches/Amaury_dev/libf/phylmd/inlandsis/surf_inlandsis_mod.F90	(revision 5128)
@@ -783,5 +783,5 @@
         min_period = 1800. ! en secondes
         dalph_soil = 2.    ! rapport entre les epaisseurs de 2 couches succ.
-        !$OMP MASTER
+        !!! !$OMP MASTER
         !     IF (is_mpi_root) THEN
         !        OPEN(99,file='soil.def',status='old',form='formatted',iostat=ierr)
@@ -795,5 +795,5 @@
         !        END IF
         !     ENDIF
-        !$OMP END MASTER
+        !!! !$OMP END MASTER
         !     CALL bcast(min_period)
         !     CALL bcast(dalph_soil)
Index: /LMDZ6/branches/Amaury_dev/libf/phylmd/lmdz_simu_airs.f90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/phylmd/lmdz_simu_airs.f90	(revision 5128)
+++ /LMDZ6/branches/Amaury_dev/libf/phylmd/lmdz_simu_airs.f90	(revision 5128)
@@ -0,0 +1,1280 @@
+module lmdz_simu_airs
+
+  USE lmdz_print_control, ONLY: prt_level, lunout
+  USE lmdz_abort_physic, ONLY: abort_physic
+
+  IMPLICIT NONE
+
+  REAL, PARAMETER :: tau_thresh = 0.05 ! seuil nuages detectables
+  REAL, PARAMETER :: p_thresh = 445.   ! seuil nuages hauts
+  REAL, PARAMETER :: em_min = 0.2      ! seuils nuages semi-transp
+  REAL, PARAMETER :: em_max = 0.85
+  REAL, PARAMETER :: undef = 999.
+
+CONTAINS
+
+  REAL function search_tropopause(P, T, alt, N) result(P_tropo)
+    ! this function searches for the tropopause pressure in [hPa].
+    ! The search is based on ideology described in
+    ! Reichler et al., Determining the tropopause height from gridded data,
+    ! GRL, 30(20) 2042, doi:10.1029/2003GL018240, 2003
+
+    INTEGER N, i, i_lev, first_point, exit_flag, i_dir
+    REAL P(N), T(N), alt(N), slope(N)
+    REAL P_min, P_max, slope_limit, slope_2km, &
+            delta_alt_limit, tmp, delta_alt
+    PARAMETER(P_min = 75.0, P_max = 470.0)   ! hPa
+    PARAMETER(slope_limit = 0.002)         ! 2 K/km converted to K/m
+    PARAMETER(delta_alt_limit = 2000.0)    ! 2000 meters
+
+    do i = 1, N - 1
+      slope(i) = -(T(i + 1) - T(i)) / (alt(i + 1) - alt(i))
+    END DO
+    slope(N) = slope(N - 1)
+
+    IF (P(1)>P(N)) THEN
+      i_dir = 1
+      i = 1
+    else
+      i_dir = -1
+      i = N
+    end if
+
+    first_point = 0
+    exit_flag = 0
+    do while(exit_flag==0)
+      IF (P(i)>=P_min.AND.P(i)<=P_max) THEN
+        IF (first_point>0) THEN
+          delta_alt = alt(i) - alt(first_point)
+          IF (delta_alt>=delta_alt_limit) THEN
+            slope_2km = (T(first_point) - T(i)) / delta_alt
+            IF (slope_2km<slope_limit) THEN
+              exit_flag = 1
+            else
+              first_point = 0
+            end if
+          end if
+        end if
+        IF (first_point==0.AND.slope(i)<slope_limit) first_point = i
+      end if
+      i = i + i_dir
+      IF (i<=1.OR.i>=N) exit_flag = 1
+    END DO
+
+    IF (first_point<=0) P_tropo = 65.4321
+    IF (first_point==1) P_tropo = 64.5432
+    IF (first_point>1) THEN
+      tmp = (slope_limit - slope(first_point)) / (slope(first_point + 1) - &
+              slope(first_point)) * (P(first_point + 1) - P(first_point))
+      P_tropo = P(first_point) + tmp
+      ! PRINT*, 'P_tropo= ', tmp, P(first_point), P_tropo
+    end if
+
+    ! Ajout Marine
+    IF (P_tropo < 60. .OR. P_tropo > 470.) THEN
+      P_tropo = 999.
+    endif
+
+  END FUNCTION search_tropopause
+
+
+  SUBROUTINE cloud_structure(len_cs, rneb_cs, temp_cs, &
+          emis_cs, iwco_cs, &
+          pres_cs, dz_cs, rhodz_cs, rad_cs, &
+          cc_tot_cs, cc_hc_cs, cc_hist_cs, &
+          cc_Cb_cs, cc_ThCi_cs, cc_Anv_cs, &
+          pcld_hc_cs, tcld_hc_cs, &
+          em_hc_cs, iwp_hc_cs, deltaz_hc_cs, &
+          pcld_Cb_cs, tcld_Cb_cs, em_Cb_cs, &
+          pcld_ThCi_cs, tcld_ThCi_cs, em_ThCi_cs, &
+          pcld_Anv_cs, tcld_Anv_cs, em_Anv_cs, &
+          em_hist_cs, iwp_hist_cs, deltaz_hist_cs, rad_hist_cs)
+
+    INTEGER :: i, n, nss
+
+    INTEGER, INTENT(IN) :: len_cs
+    REAL, DIMENSION(:), INTENT(IN) :: rneb_cs, temp_cs
+    REAL, DIMENSION(:), INTENT(IN) :: emis_cs, iwco_cs, rad_cs
+    REAL, DIMENSION(:), INTENT(IN) :: pres_cs, dz_cs, rhodz_cs
+
+    REAL, INTENT(OUT) :: cc_tot_cs, cc_hc_cs, cc_hist_cs, &
+            cc_Cb_cs, cc_ThCi_cs, cc_Anv_cs, &
+            pcld_hc_cs, tcld_hc_cs, em_hc_cs, iwp_hc_cs, &
+            pcld_Cb_cs, tcld_Cb_cs, em_Cb_cs, &
+            pcld_ThCi_cs, tcld_ThCi_cs, em_ThCi_cs, &
+            pcld_Anv_cs, tcld_Anv_cs, em_Anv_cs, &
+            em_hist_cs, iwp_hist_cs, &
+            deltaz_hc_cs, deltaz_hist_cs, rad_hist_cs
+
+    REAL, DIMENSION(len_cs) :: rneb_ord
+    REAL :: rneb_min
+
+    REAL, DIMENSION(:), ALLOCATABLE :: s, s_hc, s_hist, rneb_max
+    REAL, DIMENSION(:), ALLOCATABLE :: sCb, sThCi, sAnv
+    REAL, DIMENSION(:), ALLOCATABLE :: iwp_ss, pcld_ss, tcld_ss, &
+            emis_ss
+    REAL, DIMENSION(:), ALLOCATABLE :: deltaz_ss, rad_ss
+
+    CHARACTER (len = 50) :: modname = 'simu_airs.cloud_structure'
+    CHARACTER (len = 160) :: abort_message
+
+    WRITE(lunout, *) 'dans cloud_structure'
+
+    CALL ordonne(len_cs, rneb_cs, rneb_ord)
+
+
+    ! Definition des sous_sections
+
+    rneb_min = rneb_ord(1)
+    nss = 1
+
+    do i = 2, size(rneb_cs)
+      IF (rneb_ord(i) > rneb_min) THEN
+        nss = nss + 1
+        rneb_min = rneb_ord(i)
+      endif
+    enddo
+
+    allocate (s(nss))
+    allocate (s_hc(nss))
+    allocate (s_hist(nss))
+    allocate (rneb_max(nss))
+    allocate (emis_ss(nss))
+    allocate (pcld_ss(nss))
+    allocate (tcld_ss(nss))
+    allocate (iwp_ss(nss))
+    allocate (deltaz_ss(nss))
+    allocate (rad_ss(nss))
+    allocate (sCb(nss))
+    allocate (sThCi(nss))
+    allocate (sAnv(nss))
+
+    rneb_min = rneb_ord(1)
+    n = 1
+    s(1) = rneb_ord(1)
+    s_hc(1) = rneb_ord(1)
+    s_hist(1) = rneb_ord(1)
+    sCb(1) = rneb_ord(1)
+    sThCi(1) = rneb_ord(1)
+    sAnv(1) = rneb_ord(1)
+
+    rneb_max(1) = rneb_ord(1)
+
+    do i = 2, size(rneb_cs)
+      IF (rneb_ord(i) > rneb_min) THEN
+        n = n + 1
+        s(n) = rneb_ord(i) - rneb_min
+        s_hc(n) = rneb_ord(i) - rneb_min
+        s_hist(n) = rneb_ord(i) - rneb_min
+        sCb(n) = rneb_ord(i) - rneb_min
+        sThCi(n) = rneb_ord(i) - rneb_min
+        sAnv(n) = rneb_ord(i) - rneb_min
+
+        rneb_max(n) = rneb_ord(i)
+        rneb_min = rneb_ord(i)
+      endif
+    enddo
+
+    ! Appel de sous_section
+
+    do i = 1, nss
+      CALL sous_section(len_cs, rneb_cs, temp_cs, &
+              emis_cs, iwco_cs, &
+              pres_cs, dz_cs, rhodz_cs, rad_cs, rneb_ord, &
+              rneb_max(i), s(i), s_hc(i), s_hist(i), &
+              sCb(i), sThCi(i), sAnv(i), &
+              emis_ss(i), &
+              pcld_ss(i), tcld_ss(i), iwp_ss(i), deltaz_ss(i), rad_ss(i))
+    enddo
+
+    ! Caracteristiques de la structure nuageuse
+
+    cc_tot_cs = 0.
+    cc_hc_cs = 0.
+    cc_hist_cs = 0.
+
+    cc_Cb_cs = 0.
+    cc_ThCi_cs = 0.
+    cc_Anv_cs = 0.
+
+    em_hc_cs = 0.
+    iwp_hc_cs = 0.
+    deltaz_hc_cs = 0.
+
+    em_hist_cs = 0.
+    iwp_hist_cs = 0.
+    deltaz_hist_cs = 0.
+    rad_hist_cs = 0.
+
+    pcld_hc_cs = 0.
+    tcld_hc_cs = 0.
+
+    pcld_Cb_cs = 0.
+    tcld_Cb_cs = 0.
+    em_Cb_cs = 0.
+
+    pcld_ThCi_cs = 0.
+    tcld_ThCi_cs = 0.
+    em_ThCi_cs = 0.
+
+    pcld_Anv_cs = 0.
+    tcld_Anv_cs = 0.
+    em_Anv_cs = 0.
+
+    do i = 1, nss
+
+      cc_tot_cs = cc_tot_cs + s(i)
+      cc_hc_cs = cc_hc_cs + s_hc(i)
+      cc_hist_cs = cc_hist_cs + s_hist(i)
+
+      cc_Cb_cs = cc_Cb_cs + sCb(i)
+      cc_ThCi_cs = cc_ThCi_cs + sThCi(i)
+      cc_Anv_cs = cc_Anv_cs + sAnv(i)
+
+      iwp_hc_cs = iwp_hc_cs + s_hc(i) * iwp_ss(i)
+      em_hc_cs = em_hc_cs + s_hc(i) * emis_ss(i)
+      deltaz_hc_cs = deltaz_hc_cs + s_hc(i) * deltaz_ss(i)
+
+      iwp_hist_cs = iwp_hist_cs + s_hist(i) * iwp_ss(i)
+      em_hist_cs = em_hist_cs + s_hist(i) * emis_ss(i)
+      deltaz_hist_cs = deltaz_hist_cs + s_hist(i) * deltaz_ss(i)
+      rad_hist_cs = rad_hist_cs + s_hist(i) * rad_ss(i)
+
+      pcld_hc_cs = pcld_hc_cs + s_hc(i) * pcld_ss(i)
+      tcld_hc_cs = tcld_hc_cs + s_hc(i) * tcld_ss(i)
+
+      pcld_Cb_cs = pcld_Cb_cs + sCb(i) * pcld_ss(i)
+      tcld_Cb_cs = tcld_Cb_cs + sCb(i) * tcld_ss(i)
+      em_Cb_cs = em_Cb_cs + sCb(i) * emis_ss(i)
+
+      pcld_ThCi_cs = pcld_ThCi_cs + sThCi(i) * pcld_ss(i)
+      tcld_ThCi_cs = tcld_ThCi_cs + sThCi(i) * tcld_ss(i)
+      em_ThCi_cs = em_ThCi_cs + sThCi(i) * emis_ss(i)
+
+      pcld_Anv_cs = pcld_Anv_cs + sAnv(i) * pcld_ss(i)
+      tcld_Anv_cs = tcld_Anv_cs + sAnv(i) * tcld_ss(i)
+      em_Anv_cs = em_Anv_cs + sAnv(i) * emis_ss(i)
+
+    enddo
+
+    deallocate(s)
+    deallocate (s_hc)
+    deallocate (s_hist)
+    deallocate (rneb_max)
+    deallocate (emis_ss)
+    deallocate (pcld_ss)
+    deallocate (tcld_ss)
+    deallocate (iwp_ss)
+    deallocate (deltaz_ss)
+    deallocate (rad_ss)
+    deallocate (sCb)
+    deallocate (sThCi)
+    deallocate (sAnv)
+
+    CALL normal_undef(pcld_hc_cs, cc_hc_cs)
+    CALL normal_undef(tcld_hc_cs, cc_hc_cs)
+    CALL normal_undef(iwp_hc_cs, cc_hc_cs)
+    CALL normal_undef(em_hc_cs, cc_hc_cs)
+    CALL normal_undef(deltaz_hc_cs, cc_hc_cs)
+
+    CALL normal_undef(iwp_hist_cs, cc_hist_cs)
+    CALL normal_undef(em_hist_cs, cc_hist_cs)
+    CALL normal_undef(deltaz_hist_cs, cc_hist_cs)
+    CALL normal_undef(rad_hist_cs, cc_hist_cs)
+
+    CALL normal_undef(pcld_Cb_cs, cc_Cb_cs)
+    CALL normal_undef(tcld_Cb_cs, cc_Cb_cs)
+    CALL normal_undef(em_Cb_cs, cc_Cb_cs)
+
+    CALL normal_undef(pcld_ThCi_cs, cc_ThCi_cs)
+    CALL normal_undef(tcld_ThCi_cs, cc_ThCi_cs)
+    CALL normal_undef(em_ThCi_cs, cc_ThCi_cs)
+
+    CALL normal_undef(pcld_Anv_cs, cc_Anv_cs)
+    CALL normal_undef(tcld_Anv_cs, cc_Anv_cs)
+    CALL normal_undef(em_Anv_cs, cc_Anv_cs)
+
+
+    ! Tests
+
+    IF (cc_tot_cs > maxval(rneb_cs) .AND. &
+            abs(cc_tot_cs - maxval(rneb_cs)) > 1.e-4)  THEN
+      WRITE(abort_message, *) 'cc_tot_cs > max rneb_cs', cc_tot_cs, maxval(rneb_cs)
+      CALL abort_physic(modname, abort_message, 1)
+    endif
+
+    IF (iwp_hc_cs < 0.) THEN
+      abort_message = 'cloud_structure: iwp_hc_cs < 0'
+      CALL abort_physic(modname, abort_message, 1)
+    endif
+
+  END SUBROUTINE  cloud_structure
+
+
+  SUBROUTINE normal_undef(num, den)
+
+    REAL, INTENT(IN) :: den
+    REAL, INTENT(INOUT) :: num
+
+    IF (den /= 0) THEN
+      num = num / den
+    else
+      num = undef
+    endif
+
+  END SUBROUTINE  normal_undef
+
+
+  SUBROUTINE normal2_undef(res, num, den)
+
+    REAL, INTENT(IN) :: den
+    REAL, INTENT(IN) :: num
+    REAL, INTENT(OUT) :: res
+
+    IF (den /= 0.) THEN
+      res = num / den
+    else
+      res = undef
+    endif
+
+  END SUBROUTINE  normal2_undef
+
+
+  SUBROUTINE sous_section(len_cs, rneb_cs, temp_cs, &
+          emis_cs, iwco_cs, &
+          pres_cs, dz_cs, rhodz_cs, rad_cs, rneb_ord, &
+          rnebmax, stot, shc, shist, &
+          sCb, sThCi, sAnv, &
+          emis, pcld, tcld, iwp, deltaz, rad)
+
+    INTEGER, INTENT(IN) :: len_cs
+    REAL, DIMENSION(len_cs), INTENT(IN) :: rneb_cs, temp_cs
+    REAL, DIMENSION(len_cs), INTENT(IN) :: emis_cs, iwco_cs, &
+            rneb_ord
+    REAL, DIMENSION(len_cs), INTENT(IN) :: pres_cs, dz_cs, rad_cs
+    REAL, DIMENSION(len_cs), INTENT(IN) :: rhodz_cs
+    REAL, DIMENSION(len_cs) :: tau_cs, w
+    REAL, INTENT(IN) :: rnebmax
+    REAL, INTENT(INOUT) :: stot, shc, shist
+    REAL, INTENT(INOUT) :: sCb, sThCi, sAnv
+    REAL, INTENT(OUT) :: emis, pcld, tcld, iwp, deltaz, rad
+
+    INTEGER :: i, ideb, ibeg, iend, nuage, visible
+    REAL :: som, som_tau, som_iwc, som_dz, som_rad, tau
+
+    CHARACTER (len = 50) :: modname = 'simu_airs.sous_section'
+    CHARACTER (len = 160) :: abort_message
+
+
+    ! Ponderation: 1 pour les nuages, 0 pour les trous
+
+    do i = 1, len_cs
+      IF (rneb_cs(i) >= rnebmax) THEN
+        w(i) = 1.
+      else
+        w(i) = 0.
+      endif
+    enddo
+
+    ! Calcul des epaisseurs optiques a partir des emissivites
+
+    som = 0.
+    do i = 1, len_cs
+      IF (emis_cs(i) == 1.) THEN
+        tau_cs(i) = 10.
+      else
+        tau_cs(i) = -log(1. - emis_cs(i))
+      endif
+      som = som + tau_cs(i)
+    enddo
+
+    ideb = 1
+    nuage = 0
+    visible = 0
+
+
+    ! Boucle sur les nuages
+    do while (ideb /= 0 .AND. ideb <= len_cs)
+
+
+      ! Definition d'un nuage de la sous-section
+
+      CALL topbot(ideb, w, ibeg, iend)
+      ideb = iend + 1
+
+      IF (ibeg > 0) THEN
+        nuage = nuage + 1
+
+        ! On determine les caracteristiques du nuage
+        ! (ep. optique, ice water path, pression, temperature)
+
+        CALL caract(ibeg, iend, temp_cs, tau_cs, iwco_cs, &
+                pres_cs, dz_cs, rhodz_cs, rad_cs, pcld, tcld, &
+                som_tau, som_iwc, som_dz, som_rad)
+
+        ! On masque le nuage s'il n'est pas detectable
+
+        CALL masque(ibeg, iend, som_tau, visible, w)
+
+      endif
+
+      ! Fin boucle nuages
+    enddo
+
+
+    ! Analyse du nuage detecte
+
+    CALL topbot(1, w, ibeg, iend)
+
+    IF (ibeg > 0) THEN
+      CALL caract(ibeg, iend, temp_cs, tau_cs, iwco_cs, &
+              pres_cs, dz_cs, rhodz_cs, rad_cs, pcld, tcld, &
+              som_tau, som_iwc, som_dz, som_rad)
+
+      tau = som_tau
+      emis = 1. - exp(-tau)
+      iwp = som_iwc
+      deltaz = som_dz
+      rad = som_rad
+
+      IF (pcld > p_thresh) THEN
+        shc = 0.
+        shist = 0.
+        sCb = 0.
+        sThCi = 0.
+        sAnv = 0.
+
+      else
+
+        IF (emis < em_min .OR. emis > em_max  &
+                .OR. tcld > 230.) THEN
+          shist = 0.
+        endif
+
+        IF (emis < 0.98) THEN
+          sCb = 0.
+        endif
+
+        IF (emis > 0.5 .OR. emis < 0.1) THEN
+          sThCi = 0.
+        endif
+
+        IF (emis <= 0.5 .OR. emis >= 0.98) THEN
+          sAnv = 0.
+        endif
+
+      endif
+
+    else
+
+      tau = 0.
+      emis = 0.
+      iwp = 0.
+      deltaz = 0.
+      pcld = 0.
+      tcld = 0.
+      stot = 0.
+      shc = 0.
+      shist = 0.
+      rad = 0.
+      sCb = 0.
+      sThCi = 0.
+      sAnv = 0.
+
+    endif
+
+
+    ! Tests
+
+    IF (iwp < 0.) THEN
+      WRITE(abort_message, *) 'ideb iwp =', ideb, iwp
+      CALL abort_physic(modname, abort_message, 1)
+    endif
+
+    IF (deltaz < 0.) THEN
+      WRITE(abort_message, *)'ideb deltaz =', ideb, deltaz
+      CALL abort_physic(modname, abort_message, 1)
+    endif
+
+    IF (emis < 0.048 .AND. emis /= 0.) THEN
+      WRITE(abort_message, *) 'ideb emis =', ideb, emis
+      CALL abort_physic(modname, abort_message, 1)
+    endif
+
+  END SUBROUTINE  sous_section
+
+
+  SUBROUTINE masque(ibeg, iend, som_tau, &
+          visible, w)
+
+    INTEGER, INTENT(IN) :: ibeg, iend
+    REAL, INTENT(IN) :: som_tau
+
+    INTEGER, INTENT(INOUT) :: visible
+    REAL, DIMENSION(:), INTENT(INOUT) :: w
+
+    INTEGER :: i
+
+
+
+    ! Masque
+
+    ! Cas ou il n'y a pas de nuage visible au-dessus
+
+    IF (visible == 0) THEN
+      IF (som_tau < tau_thresh) THEN
+        do i = ibeg, iend
+          w(i) = 0.
+        enddo
+      else
+        visible = 1
+      endif
+
+      ! Cas ou il y a un nuage visible au-dessus
+
+    else
+
+      do i = ibeg, iend
+        w(i) = 0.
+      enddo
+
+    endif
+
+  END SUBROUTINE  masque
+
+
+  SUBROUTINE caract(ibeg, iend, temp_cs, tau_cs, iwco_cs, &
+          pres_cs, dz_cs, rhodz_cs, rad_cs, pcld, tcld, &
+          som_tau, som_iwc, som_dz, som_rad)
+
+    INTEGER, INTENT(IN) :: ibeg, iend
+    REAL, DIMENSION(:), INTENT(IN) :: tau_cs, iwco_cs, temp_cs
+    REAL, DIMENSION(:), INTENT(IN) :: pres_cs, dz_cs, rad_cs
+    REAL, DIMENSION(:), INTENT(IN) :: rhodz_cs
+    REAL, INTENT(OUT) :: som_tau, som_iwc, som_dz, som_rad
+    REAL, INTENT(OUT) :: pcld, tcld
+
+    INTEGER :: i, ibase, imid
+
+    CHARACTER (len = 50) :: modname = 'simu_airs.caract'
+    CHARACTER (len = 160) :: abort_message
+
+    ! Somme des epaisseurs optiques et des contenus en glace sur le nuage
+
+    som_tau = 0.
+    som_iwc = 0.
+    som_dz = 0.
+    som_rad = 0.
+    ibase = -100
+
+    do i = ibeg, iend
+
+      som_tau = som_tau + tau_cs(i)
+
+      som_dz = som_dz + dz_cs(i)
+      som_iwc = som_iwc + iwco_cs(i) * 1000 * rhodz_cs(i)  ! en g/m2
+      som_rad = som_rad + rad_cs(i) * dz_cs(i)
+
+      IF (som_tau > 3. .AND. ibase == -100) THEN
+        ibase = i - 1
+      endif
+
+    enddo
+
+    IF (som_dz /= 0.) THEN
+      som_rad = som_rad / som_dz
+    else
+      WRITE(*, *) 'som_dez = 0 stop '
+      WRITE(*, *) 'ibeg, iend =', ibeg, iend
+      do i = ibeg, iend
+        WRITE(*, *) dz_cs(i), rhodz_cs(i)
+      enddo
+      abort_message = 'see above'
+      CALL abort_physic(modname, abort_message, 1)
+    endif
+
+    ! Determination de Pcld et Tcld
+
+    IF (ibase < ibeg) THEN
+      ibase = ibeg
+    endif
+
+    imid = (ibeg + ibase) / 2
+
+    pcld = pres_cs(imid) / 100.        ! pcld en hPa
+    tcld = temp_cs(imid)
+
+  END SUBROUTINE  caract
+
+  SUBROUTINE topbot(ideb, w, ibeg, iend)
+
+    INTEGER, INTENT(IN) :: ideb
+    REAL, DIMENSION(:), INTENT(IN) :: w
+    INTEGER, INTENT(OUT) :: ibeg, iend
+
+    INTEGER :: i, itest
+
+    itest = 0
+    ibeg = 0
+    iend = 0
+
+    do i = ideb, size(w)
+
+      IF (w(i) == 1. .AND. itest == 0) THEN
+        ibeg = i
+        itest = 1
+      endif
+
+    enddo
+
+    i = ibeg
+    do while (w(i) == 1. .AND. i <= size(w))
+      i = i + 1
+    enddo
+    iend = i - 1
+
+  END SUBROUTINE  topbot
+
+  SUBROUTINE ordonne(len_cs, rneb_cs, rneb_ord)
+
+    INTEGER, INTENT(IN) :: len_cs
+    REAL, DIMENSION(:), INTENT(IN) :: rneb_cs
+    REAL, DIMENSION(:), INTENT(OUT) :: rneb_ord
+
+    INTEGER :: i, j, ind_min
+
+    REAL, DIMENSION(len_cs) :: rneb
+    REAL :: rneb_max
+
+    do i = 1, size(rneb_cs)
+      rneb(i) = rneb_cs(i)
+    enddo
+
+    do j = 1, size(rneb_cs)
+
+      rneb_max = 100.
+
+      do i = 1, size(rneb_cs)
+        IF (rneb(i) < rneb_max) THEN
+          rneb_max = rneb(i)
+          ind_min = i
+        endif
+      enddo
+
+      rneb_ord(j) = rneb_max
+      rneb(ind_min) = 100.
+
+    enddo
+
+  END SUBROUTINE  ordonne
+
+
+  SUBROUTINE sim_mesh(rneb_1D, temp_1D, emis_1D, &
+          iwcon_1D, rad_1D, &
+          pres, dz, &
+          rhodz_1D, cc_tot_mesh, cc_hc_mesh, cc_hist_mesh, pcld_hc_mesh, &
+          tcld_hc_mesh, &
+          em_hc_mesh, iwp_hc_mesh, deltaz_hc_mesh, &
+          cc_Cb_mesh, cc_ThCi_mesh, cc_Anv_mesh, &
+          pcld_Cb_mesh, tcld_Cb_mesh, em_Cb_mesh, &
+          pcld_ThCi_mesh, tcld_ThCi_mesh, em_ThCi_mesh, &
+          pcld_Anv_mesh, tcld_Anv_mesh, em_Anv_mesh, &
+          em_hist_mesh, iwp_hist_mesh, deltaz_hist_mesh, rad_hist_mesh)
+
+    USE dimphy
+
+    REAL, DIMENSION(klev), INTENT(IN) :: rneb_1D, temp_1D, emis_1D, &
+            iwcon_1D, rad_1D
+    REAL, DIMENSION(klev), INTENT(IN) :: pres, dz, rhodz_1D
+    REAL, INTENT(OUT) :: cc_tot_mesh, cc_hc_mesh, cc_hist_mesh
+    REAL, INTENT(OUT) :: cc_Cb_mesh, cc_ThCi_mesh, cc_Anv_mesh
+    REAL, INTENT(OUT) :: em_hc_mesh, pcld_hc_mesh, tcld_hc_mesh, &
+            iwp_hc_mesh
+
+    REAL, INTENT(OUT) :: pcld_Cb_mesh, tcld_Cb_mesh, em_Cb_mesh
+    REAL, INTENT(OUT) :: pcld_ThCi_mesh, tcld_ThCi_mesh, &
+            em_ThCi_mesh
+    REAL, INTENT(OUT) :: pcld_Anv_mesh, tcld_Anv_mesh, em_Anv_mesh
+
+    REAL, INTENT(OUT) :: em_hist_mesh, iwp_hist_mesh, rad_hist_mesh
+    REAL, INTENT(OUT) :: deltaz_hc_mesh, deltaz_hist_mesh
+
+    REAL, DIMENSION(:), ALLOCATABLE :: rneb_cs, temp_cs, emis_cs, &
+            iwco_cs
+    REAL, DIMENSION(:), ALLOCATABLE :: pres_cs, dz_cs, rad_cs, &
+            rhodz_cs
+
+    INTEGER :: i, j, l
+    INTEGER :: ltop, itop, ibot, num_cs, N_cs, len_cs, ics
+
+    REAL :: som_emi_hc, som_pcl_hc, som_tcl_hc, som_iwp_hc, som_hc, &
+            som_hist
+    REAL :: som_emi_hist, som_iwp_hist, som_deltaz_hc, &
+            som_deltaz_hist
+    REAL :: som_rad_hist
+    REAL :: som_Cb, som_ThCi, som_Anv
+    REAL :: som_emi_Cb, som_tcld_Cb, som_pcld_Cb
+    REAL :: som_emi_Anv, som_tcld_Anv, som_pcld_Anv
+    REAL :: som_emi_ThCi, som_tcld_ThCi, som_pcld_ThCi
+    REAL :: tsom_tot, tsom_hc, tsom_hist
+    REAL :: prod, prod_hh
+
+    REAL :: cc_tot_cs, cc_hc_cs, cc_hist_cs
+    REAL :: cc_Cb_cs, cc_ThCi_cs, cc_Anv_cs
+    REAL :: pcld_hc_cs, tcld_hc_cs
+    REAL :: em_hc_cs, iwp_hc_cs, deltaz_hc_cs
+    REAL :: pcld_Cb_cs, tcld_Cb_cs, em_Cb_cs
+    REAL :: pcld_ThCi_cs, tcld_ThCi_cs, em_ThCi_cs
+    REAL :: pcld_Anv_cs, tcld_Anv_cs, em_Anv_cs
+    REAL :: em_hist_cs, iwp_hist_cs, deltaz_hist_cs, rad_hist_cs
+
+    REAL, DIMENSION(klev) :: test_tot, test_hc, test_hist
+    REAL, DIMENSION(klev) :: test_pcld, test_tcld, test_em, test_iwp
+
+    CHARACTER (len = 50) :: modname = 'simu_airs.sim_mesh'
+    CHARACTER (len = 160) :: abort_message
+
+    do j = 1, klev
+      WRITE(lunout, *) 'simu_airs, j, rneb_1D =', rneb_1D(j)
+    enddo
+
+    ! Definition des structures nuageuses, de la plus haute a la plus basse
+
+    num_cs = 0
+    ltop = klev - 1
+
+    prod = 1.
+
+    som_emi_hc = 0.
+    som_emi_hist = 0.
+    som_pcl_hc = 0.
+    som_tcl_hc = 0.
+    som_iwp_hc = 0.
+    som_iwp_hist = 0.
+    som_deltaz_hc = 0.
+    som_deltaz_hist = 0.
+    som_rad_hist = 0.
+    som_hc = 0.
+    som_hist = 0.
+
+    som_Cb = 0.
+    som_ThCi = 0.
+    som_Anv = 0.
+
+    som_emi_Cb = 0.
+    som_pcld_Cb = 0.
+    som_tcld_Cb = 0.
+
+    som_emi_ThCi = 0.
+    som_pcld_ThCi = 0.
+    som_tcld_ThCi = 0.
+
+    som_emi_Anv = 0.
+    som_pcld_Anv = 0.
+    som_tcld_Anv = 0.
+
+    tsom_tot = 0.
+    tsom_hc = 0.
+    tsom_hist = 0.
+
+    do while (ltop >= 1)   ! Boucle sur toute la colonne
+
+      itop = 0
+
+      do l = ltop, 1, -1
+
+        IF (itop == 0 .AND. rneb_1D(l) > 0.001) THEN
+          itop = l
+        endif
+
+      enddo
+
+      ibot = itop
+
+      do while (rneb_1D(ibot) > 0.001 .AND. ibot >= 1)
+        ibot = ibot - 1
+      enddo
+
+      ibot = ibot + 1
+
+      IF (itop > 0) then    ! itop > 0
+
+        num_cs = num_cs + 1
+        len_cs = itop - ibot + 1
+
+        ! Allocation et definition des variables de la structure nuageuse
+        ! le premier indice denote ce qui est le plus haut
+
+        allocate (rneb_cs(len_cs))
+        allocate (temp_cs(len_cs))
+        allocate (emis_cs(len_cs))
+        allocate (iwco_cs(len_cs))
+        allocate (pres_cs(len_cs))
+        allocate (dz_cs(len_cs))
+        allocate (rad_cs(len_cs))
+        allocate (rhodz_cs(len_cs))
+
+        ics = 0
+
+        do i = itop, ibot, -1
+          ics = ics + 1
+          rneb_cs(ics) = rneb_1D(i)
+          temp_cs(ics) = temp_1D(i)
+          emis_cs(ics) = emis_1D(i)
+          iwco_cs(ics) = iwcon_1D(i)
+          rad_cs(ics) = rad_1D(i)
+          pres_cs(ics) = pres(i)
+          dz_cs(ics) = dz(i)
+          rhodz_cs(ics) = rhodz_1D(i)
+        enddo
+
+        ! Appel du sous_programme cloud_structure
+
+        CALL cloud_structure(len_cs, rneb_cs, temp_cs, emis_cs, iwco_cs, &
+                pres_cs, dz_cs, rhodz_cs, rad_cs, &
+                cc_tot_cs, cc_hc_cs, cc_hist_cs, &
+                cc_Cb_cs, cc_ThCi_cs, cc_Anv_cs, &
+                pcld_hc_cs, tcld_hc_cs, &
+                em_hc_cs, iwp_hc_cs, deltaz_hc_cs, &
+                pcld_Cb_cs, tcld_Cb_cs, em_Cb_cs, &
+                pcld_ThCi_cs, tcld_ThCi_cs, em_ThCi_cs, &
+                pcld_Anv_cs, tcld_Anv_cs, em_Anv_cs, &
+                em_hist_cs, iwp_hist_cs, deltaz_hist_cs, rad_hist_cs)
+
+        deallocate (rneb_cs)
+        deallocate (temp_cs)
+        deallocate (emis_cs)
+        deallocate (iwco_cs)
+        deallocate (pres_cs)
+        deallocate (dz_cs)
+        deallocate (rad_cs)
+        deallocate (rhodz_cs)
+
+
+        ! Pour la couverture nuageuse sur la maille
+
+        prod_hh = prod
+
+        prod = prod * (1. - cc_tot_cs)
+
+        ! Pour les autres variables definies sur la maille
+
+        som_emi_hc = som_emi_hc + em_hc_cs * cc_hc_cs * prod_hh
+        som_iwp_hc = som_iwp_hc + iwp_hc_cs * cc_hc_cs * prod_hh
+        som_deltaz_hc = som_deltaz_hc + deltaz_hc_cs * cc_hc_cs * prod_hh
+
+        som_emi_Cb = som_emi_Cb + em_Cb_cs * cc_Cb_cs * prod_hh
+        som_tcld_Cb = som_tcld_Cb + tcld_Cb_cs * cc_Cb_cs * prod_hh
+        som_pcld_Cb = som_pcld_Cb + pcld_Cb_cs * cc_Cb_cs * prod_hh
+
+        som_emi_ThCi = som_emi_ThCi + em_ThCi_cs * cc_ThCi_cs * prod_hh
+        som_tcld_ThCi = som_tcld_ThCi + tcld_ThCi_cs * cc_ThCi_cs * prod_hh
+        som_pcld_ThCi = som_pcld_ThCi + pcld_ThCi_cs * cc_ThCi_cs * prod_hh
+
+        som_emi_Anv = som_emi_Anv + em_Anv_cs * cc_Anv_cs * prod_hh
+        som_tcld_Anv = som_tcld_Anv + tcld_Anv_cs * cc_Anv_cs * prod_hh
+        som_pcld_Anv = som_pcld_Anv + pcld_Anv_cs * cc_Anv_cs * prod_hh
+
+        som_emi_hist = som_emi_hist + em_hist_cs * cc_hist_cs * prod_hh
+        som_iwp_hist = som_iwp_hist + iwp_hist_cs * cc_hist_cs * prod_hh
+        som_deltaz_hist = som_deltaz_hist + &
+                deltaz_hist_cs * cc_hist_cs * prod_hh
+        som_rad_hist = som_rad_hist + rad_hist_cs * cc_hist_cs * prod_hh
+
+        som_pcl_hc = som_pcl_hc + pcld_hc_cs * cc_hc_cs * prod_hh
+        som_tcl_hc = som_tcl_hc + tcld_hc_cs * cc_hc_cs * prod_hh
+
+        som_hc = som_hc + cc_hc_cs * prod_hh
+        som_hist = som_hist + cc_hist_cs * prod_hh
+
+        som_Cb = som_Cb + cc_Cb_cs * prod_hh
+        som_ThCi = som_ThCi + cc_ThCi_cs * prod_hh
+        som_Anv = som_Anv + cc_Anv_cs * prod_hh
+
+
+        ! Pour test
+
+        CALL test_bornes('cc_tot_cs     ', cc_tot_cs, 1., 0.)
+        CALL test_bornes('cc_hc_cs      ', cc_hc_cs, 1., 0.)
+        CALL test_bornes('cc_hist_cs    ', cc_hist_cs, 1., 0.)
+        CALL test_bornes('pcld_hc_cs    ', pcld_hc_cs, 1200., 0.)
+        CALL test_bornes('tcld_hc_cs    ', tcld_hc_cs, 1000., 100.)
+        CALL test_bornes('em_hc_cs      ', em_hc_cs, 1000., 0.048)
+
+        test_tot(num_cs) = cc_tot_cs
+        test_hc(num_cs) = cc_hc_cs
+        test_hist(num_cs) = cc_hist_cs
+        test_pcld(num_cs) = pcld_hc_cs
+        test_tcld(num_cs) = tcld_hc_cs
+        test_em(num_cs) = em_hc_cs
+        test_iwp(num_cs) = iwp_hc_cs
+
+        tsom_tot = tsom_tot + cc_tot_cs
+        tsom_hc = tsom_hc + cc_hc_cs
+        tsom_hist = tsom_hist + cc_hist_cs
+
+      endif                   ! itop > 0
+
+      ltop = ibot - 1
+
+    enddo                   ! fin de la boucle sur la colonne
+
+    N_CS = num_cs
+
+
+    ! Determination des variables de sortie
+
+    IF (N_CS > 0) then   ! if N_CS>0
+
+      cc_tot_mesh = 1. - prod
+
+      cc_hc_mesh = som_hc
+      cc_hist_mesh = som_hist
+
+      cc_Cb_mesh = som_Cb
+      cc_ThCi_mesh = som_ThCi
+      cc_Anv_mesh = som_Anv
+
+      CALL normal2_undef(pcld_hc_mesh, som_pcl_hc, &
+              cc_hc_mesh)
+      CALL normal2_undef(tcld_hc_mesh, som_tcl_hc, &
+              cc_hc_mesh)
+      CALL normal2_undef(em_hc_mesh, som_emi_hc, &
+              cc_hc_mesh)
+      CALL normal2_undef(iwp_hc_mesh, som_iwp_hc, &
+              cc_hc_mesh)
+      CALL normal2_undef(deltaz_hc_mesh, som_deltaz_hc, &
+              cc_hc_mesh)
+
+      CALL normal2_undef(em_Cb_mesh, som_emi_Cb, &
+              cc_Cb_mesh)
+      CALL normal2_undef(tcld_Cb_mesh, som_tcld_Cb, &
+              cc_Cb_mesh)
+      CALL normal2_undef(pcld_Cb_mesh, som_pcld_Cb, &
+              cc_Cb_mesh)
+
+      CALL normal2_undef(em_ThCi_mesh, som_emi_ThCi, &
+              cc_ThCi_mesh)
+      CALL normal2_undef(tcld_ThCi_mesh, som_tcld_ThCi, &
+              cc_ThCi_mesh)
+      CALL normal2_undef(pcld_ThCi_mesh, som_pcld_ThCi, &
+              cc_ThCi_mesh)
+
+      CALL normal2_undef(em_Anv_mesh, som_emi_Anv, &
+              cc_Anv_mesh)
+      CALL normal2_undef(tcld_Anv_mesh, som_tcld_Anv, &
+              cc_Anv_mesh)
+      CALL normal2_undef(pcld_Anv_mesh, som_pcld_Anv, &
+              cc_Anv_mesh)
+
+      CALL normal2_undef(em_hist_mesh, som_emi_hist, &
+              cc_hist_mesh)
+      CALL normal2_undef(iwp_hist_mesh, som_iwp_hist, &
+              cc_hist_mesh)
+      CALL normal2_undef(deltaz_hist_mesh, som_deltaz_hist, &
+              cc_hist_mesh)
+      CALL normal2_undef(rad_hist_mesh, som_rad_hist, &
+              cc_hist_mesh)
+
+
+      ! Tests
+
+      ! Tests
+
+      IF (cc_tot_mesh > tsom_tot .AND. &
+              abs(cc_tot_mesh - tsom_tot) > 1.e-4) THEN
+        WRITE(abort_message, *)'cc_tot_mesh > tsom_tot', cc_tot_mesh, tsom_tot
+        CALL abort_physic(modname, abort_message, 1)
+      endif
+
+      IF (cc_tot_mesh < maxval(test_tot(1:N_CS)) .AND. &
+              abs(cc_tot_mesh - maxval(test_tot(1:N_CS))) > 1.e-4) THEN
+        WRITE(abort_message, *) 'cc_tot_mesh < max', cc_tot_mesh, maxval(test_tot(1:N_CS))
+        CALL abort_physic(modname, abort_message, 1)
+      endif
+
+      IF (cc_hc_mesh > tsom_hc .AND. &
+              abs(cc_hc_mesh - tsom_hc) > 1.e-4) THEN
+        WRITE(abort_message, *) 'cc_hc_mesh > tsom_hc', cc_hc_mesh, tsom_hc
+        CALL abort_physic(modname, abort_message, 1)
+      endif
+
+      IF (cc_hc_mesh < maxval(test_hc(1:N_CS)) .AND. &
+              abs(cc_hc_mesh - maxval(test_hc(1:N_CS))) > 1.e-4) THEN
+        WRITE(abort_message, *) 'cc_hc_mesh < max', cc_hc_mesh, maxval(test_hc(1:N_CS))
+        CALL abort_physic(modname, abort_message, 1)
+      endif
+
+      IF (cc_hist_mesh > tsom_hist .AND. &
+              abs(cc_hist_mesh - tsom_hist) > 1.e-4) THEN
+        WRITE(abort_message, *) 'cc_hist_mesh > tsom_hist', cc_hist_mesh, tsom_hist
+        CALL abort_physic(modname, abort_message, 1)
+      endif
+
+      IF (cc_hist_mesh < 0.) THEN
+        WRITE(abort_message, *) 'cc_hist_mesh < 0', cc_hist_mesh
+        CALL abort_physic(modname, abort_message, 1)
+      endif
+
+      IF ((pcld_hc_mesh > maxval(test_pcld(1:N_CS)) .OR. &
+              pcld_hc_mesh < minval(test_pcld(1:N_CS))) .AND. &
+              abs(pcld_hc_mesh - maxval(test_pcld(1:N_CS))) > 1. .AND. &
+              maxval(test_pcld(1:N_CS)) /= 999. &
+              .AND. minval(test_pcld(1:N_CS)) /= 999.) THEN
+        WRITE(abort_message, *) 'pcld_hc_mesh est faux', pcld_hc_mesh, maxval(test_pcld(1:N_CS)), &
+                minval(test_pcld(1:N_CS))
+        CALL abort_physic(modname, abort_message, 1)
+      endif
+
+      IF ((tcld_hc_mesh > maxval(test_tcld(1:N_CS)) .OR. &
+              tcld_hc_mesh < minval(test_tcld(1:N_CS))) .AND. &
+              abs(tcld_hc_mesh - maxval(test_tcld(1:N_CS))) > 0.1 .AND. &
+              maxval(test_tcld(1:N_CS)) /= 999. &
+              .AND. minval(test_tcld(1:N_CS)) /= 999.) THEN
+        WRITE(abort_message, *) 'tcld_hc_mesh est faux', tcld_hc_mesh, maxval(test_tcld(1:N_CS)), &
+                minval(test_tcld(1:N_CS))
+        CALL abort_physic(modname, abort_message, 1)
+      endif
+
+      IF ((em_hc_mesh > maxval(test_em(1:N_CS)) .OR. &
+              em_hc_mesh < minval(test_em(1:N_CS))) .AND. &
+              abs(em_hc_mesh - maxval(test_em(1:N_CS))) > 1.e-4 .AND. &
+              minval(test_em(1:N_CS)) /= 999. .AND. &
+              maxval(test_em(1:N_CS)) /= 999.) THEN
+        WRITE(abort_message, *) 'em_hc_mesh est faux', em_hc_mesh, maxval(test_em(1:N_CS)), &
+                minval(test_em(1:N_CS))
+        CALL abort_physic(modname, abort_message, 1)
+      endif
+
+    else               ! if N_CS>0
+
+      cc_tot_mesh = 0.
+      cc_hc_mesh = 0.
+      cc_hist_mesh = 0.
+
+      cc_Cb_mesh = 0.
+      cc_ThCi_mesh = 0.
+      cc_Anv_mesh = 0.
+
+      iwp_hc_mesh = undef
+      deltaz_hc_mesh = undef
+      em_hc_mesh = undef
+      iwp_hist_mesh = undef
+      deltaz_hist_mesh = undef
+      rad_hist_mesh = undef
+      em_hist_mesh = undef
+      pcld_hc_mesh = undef
+      tcld_hc_mesh = undef
+
+      pcld_Cb_mesh = undef
+      tcld_Cb_mesh = undef
+      em_Cb_mesh = undef
+
+      pcld_ThCi_mesh = undef
+      tcld_ThCi_mesh = undef
+      em_ThCi_mesh = undef
+
+      pcld_Anv_mesh = undef
+      tcld_Anv_mesh = undef
+      em_Anv_mesh = undef
+
+    endif                  ! if N_CS>0
+
+  END SUBROUTINE  sim_mesh
+
+  SUBROUTINE test_bornes(sx, x, bsup, binf)
+
+    REAL, INTENT(IN) :: x, bsup, binf
+    character*14, INTENT(IN) :: sx
+    CHARACTER (len = 50) :: modname = 'simu_airs.test_bornes'
+    CHARACTER (len = 160) :: abort_message
+
+    IF (x > bsup .OR. x < binf) THEN
+      WRITE(abort_message, *) sx, 'est faux', sx, x
+      CALL abort_physic(modname, abort_message, 1)
+    endif
+
+  END SUBROUTINE  test_bornes
+
+
+  SUBROUTINE simu_airs &
+          (itap, rneb_airs, temp_airs, cldemi_airs, iwcon0_airs, rad_airs, &
+          geop_airs, pplay_airs, paprs_airs, &
+          map_prop_hc, map_prop_hist, &
+          map_emis_hc, map_iwp_hc, map_deltaz_hc, map_pcld_hc, map_tcld_hc, &
+          map_emis_Cb, map_pcld_Cb, map_tcld_Cb, &
+          map_emis_ThCi, map_pcld_ThCi, map_tcld_ThCi, &
+          map_emis_Anv, map_pcld_Anv, map_tcld_Anv, &
+          map_emis_hist, map_iwp_hist, map_deltaz_hist, map_rad_hist, &
+          map_ntot, map_hc, map_hist, &
+          map_Cb, map_ThCi, map_Anv, alt_tropo)
+
+    USE dimphy
+
+    IMPLICIT NONE
+
+    include "YOMCST.h"
+
+    INTEGER, INTENT(IN) :: itap
+
+    REAL, DIMENSION(klon, klev), INTENT(IN) :: &
+            rneb_airs, temp_airs, cldemi_airs, iwcon0_airs, &
+            rad_airs, geop_airs, pplay_airs, paprs_airs
+
+    REAL, DIMENSION(klon, klev) :: &
+            rhodz_airs, rho_airs, iwcon_airs
+
+    REAL, DIMENSION(klon), INTENT(OUT) :: alt_tropo
+
+    REAL, DIMENSION(klev) :: rneb_1D, temp_1D, &
+            emis_1D, rad_1D, pres_1D, alt_1D, &
+            rhodz_1D, dz_1D, iwcon_1D
+
+    INTEGER :: i, j
+
+    REAL :: cc_tot_mesh, cc_hc_mesh, cc_hist_mesh
+    REAL :: cc_Cb_mesh, cc_ThCi_mesh, cc_Anv_mesh
+    REAL :: pcld_hc_mesh, tcld_hc_mesh, em_hc_mesh, iwp_hc_mesh
+    REAL :: em_hist_mesh, iwp_hist_mesh
+    REAL :: deltaz_hc_mesh, deltaz_hist_mesh, rad_hist_mesh
+    REAL :: pcld_Cb_mesh, tcld_Cb_mesh, em_Cb_mesh
+    REAL :: pcld_ThCi_mesh, tcld_ThCi_mesh, em_ThCi_mesh
+    REAL :: pcld_Anv_mesh, tcld_Anv_mesh, em_Anv_mesh
+
+    REAL, DIMENSION(klon), INTENT(OUT) :: map_prop_hc, map_prop_hist
+    REAL, DIMENSION(klon), INTENT(OUT) :: map_emis_hc, map_iwp_hc
+    REAL, DIMENSION(klon), INTENT(OUT) :: map_deltaz_hc, map_pcld_hc
+    REAL, DIMENSION(klon), INTENT(OUT) :: map_tcld_hc
+    REAL, DIMENSION(klon), INTENT(OUT) :: map_emis_Cb, map_pcld_Cb, map_tcld_Cb
+    REAL, DIMENSION(klon), INTENT(OUT) :: &
+            map_emis_ThCi, map_pcld_ThCi, map_tcld_ThCi
+    REAL, DIMENSION(klon), INTENT(OUT) :: &
+            map_emis_Anv, map_pcld_Anv, map_tcld_Anv
+    REAL, DIMENSION(klon), INTENT(OUT) :: &
+            map_emis_hist, map_iwp_hist, map_deltaz_hist, &
+            map_rad_hist
+    REAL, DIMENSION(klon), INTENT(OUT) :: map_ntot, map_hc, map_hist
+    REAL, DIMENSION(klon), INTENT(OUT) :: map_Cb, map_ThCi, map_Anv
+
+    WRITE(*, *) 'simu_airs'
+    WRITE(*, *) 'itap, klon, klev', itap, klon, klev
+    WRITE(*, *) 'RG, RD =', RG, RD
+
+
+    ! Definition des variables 1D
+
+    do i = 1, klon
+      do j = 1, klev - 1
+        rhodz_airs(i, j) = &
+                (paprs_airs(i, j) - paprs_airs(i, j + 1)) / RG
+      enddo
+      rhodz_airs(i, klev) = 0.
+    enddo
+
+    do i = 1, klon
+      do j = 1, klev
+        rho_airs(i, j) = &
+                pplay_airs(i, j) / (temp_airs(i, j) * RD)
+
+        IF (rneb_airs(i, j) > 0.001) THEN
+          iwcon_airs(i, j) = iwcon0_airs(i, j) / rneb_airs(i, j)
+        else
+          iwcon_airs(i, j) = 0.
+        endif
+
+      enddo
+    enddo
+
+    !=============================================================================
+
+    do i = 1, klon  ! boucle sur les points de grille
+
+      !=============================================================================
+
+      do j = 1, klev
+
+        rneb_1D(j) = rneb_airs(i, j)
+        temp_1D(j) = temp_airs(i, j)
+        emis_1D(j) = cldemi_airs(i, j)
+        iwcon_1D(j) = iwcon_airs(i, j)
+        rad_1D(j) = rad_airs(i, j)
+        pres_1D(j) = pplay_airs(i, j)
+        alt_1D(j) = geop_airs(i, j) / RG
+        rhodz_1D(j) = rhodz_airs(i, j)
+        dz_1D(j) = rhodz_airs(i, j) / rho_airs(i, j)
+
+      enddo
+
+      alt_tropo(i) = &
+              search_tropopause(pres_1D / 100., temp_1D, alt_1D, klev)
+
+
+      ! Appel du ss-programme sim_mesh
+
+      !        if (itap .EQ. 1 ) THEN
+      CALL sim_mesh(rneb_1D, temp_1D, emis_1D, iwcon_1D, rad_1D, &
+              pres_1D, dz_1D, rhodz_1D, &
+              cc_tot_mesh, cc_hc_mesh, cc_hist_mesh, &
+              pcld_hc_mesh, tcld_hc_mesh, em_hc_mesh, iwp_hc_mesh, &
+              deltaz_hc_mesh, &
+              cc_Cb_mesh, cc_ThCi_mesh, cc_Anv_mesh, &
+              pcld_Cb_mesh, tcld_Cb_mesh, em_Cb_mesh, &
+              pcld_ThCi_mesh, tcld_ThCi_mesh, em_ThCi_mesh, &
+              pcld_Anv_mesh, tcld_Anv_mesh, em_Anv_mesh, &
+              em_hist_mesh, iwp_hist_mesh, deltaz_hist_mesh, rad_hist_mesh)
+
+      WRITE(*, *) '===================================='
+      WRITE(*, *) 'itap, i:', itap, i
+      WRITE(*, *) 'cc_tot, cc_hc, cc_hist, pcld_hc, tcld_hc, em_hc, &
+              iwp_hc, em_hist, iwp_hist ='
+      WRITE(*, *) cc_tot_mesh, cc_hc_mesh, cc_hist_mesh
+      WRITE(*, *) pcld_hc_mesh, tcld_hc_mesh, em_hc_mesh, iwp_hc_mesh
+      WRITE(*, *)  em_hist_mesh, iwp_hist_mesh
+
+      !        endif
+
+      ! Definition des variables a ecrire dans le fichier de sortie
+
+      CALL normal2_undef(map_prop_hc(i), cc_hc_mesh, &
+              cc_tot_mesh)
+      CALL normal2_undef(map_prop_hist(i), cc_hist_mesh, &
+              cc_tot_mesh)
+
+      map_emis_hc(i) = em_hc_mesh
+      map_iwp_hc(i) = iwp_hc_mesh
+      map_deltaz_hc(i) = deltaz_hc_mesh
+      map_pcld_hc(i) = pcld_hc_mesh
+      map_tcld_hc(i) = tcld_hc_mesh
+
+      map_emis_Cb(i) = em_Cb_mesh
+      map_pcld_Cb(i) = pcld_Cb_mesh
+      map_tcld_Cb(i) = tcld_Cb_mesh
+
+      map_emis_ThCi(i) = em_ThCi_mesh
+      map_pcld_ThCi(i) = pcld_ThCi_mesh
+      map_tcld_ThCi(i) = tcld_ThCi_mesh
+
+      map_emis_Anv(i) = em_Anv_mesh
+      map_pcld_Anv(i) = pcld_Anv_mesh
+      map_tcld_Anv(i) = tcld_Anv_mesh
+
+      map_emis_hist(i) = em_hist_mesh
+      map_iwp_hist(i) = iwp_hist_mesh
+      map_deltaz_hist(i) = deltaz_hist_mesh
+      map_rad_hist(i) = rad_hist_mesh
+
+      map_ntot(i) = cc_tot_mesh
+      map_hc(i) = cc_hc_mesh
+      map_hist(i) = cc_hist_mesh
+
+      map_Cb(i) = cc_Cb_mesh
+      map_ThCi(i) = cc_ThCi_mesh
+      map_Anv(i) = cc_Anv_mesh
+
+    enddo         ! fin boucle sur les points de grille
+
+  END SUBROUTINE  simu_airs
+
+
+END MODULE lmdz_simu_airs
+
Index: /LMDZ6/branches/Amaury_dev/libf/phylmd/mod_synchro_omp.F90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/phylmd/mod_synchro_omp.F90	(revision 5127)
+++ /LMDZ6/branches/Amaury_dev/libf/phylmd/mod_synchro_omp.F90	(revision 5128)
@@ -9,5 +9,4 @@
   SUBROUTINE Init_synchro_omp
     USE lmdz_phys_para
-    USE lmdz_abort_physic, ONLY: abort_physic
     IMPLICIT NONE
 
@@ -22,4 +21,5 @@
   SUBROUTINE Synchro_omp
     USE lmdz_phys_para
+    USE lmdz_abort_physic, ONLY: abort_physic
     IMPLICIT NONE
     LOGICAL :: out
Index: /LMDZ6/branches/Amaury_dev/libf/phylmd/nuage.h
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/phylmd/nuage.h	(revision 5127)
+++ /LMDZ6/branches/Amaury_dev/libf/phylmd/nuage.h	(revision 5128)
@@ -9,7 +9,7 @@
 
       common /nuagecom/ rad_froid,rad_chau1, rad_chau2,                 &
-     &                  tau_cld_cv,coefw_cld_cv,                        &
-     &                  tmax_fonte_cv,iflag_ratqs,                      &
-     &                  iflag_cld_cv,                                   &
-     &                  ok_icefra_lscp                                 
+                        tau_cld_cv,coefw_cld_cv,                        &
+                        tmax_fonte_cv,iflag_ratqs,                      &
+                        iflag_cld_cv,                                   &
+                        ok_icefra_lscp
 !$OMP THREADPRIVATE(/nuagecom/)
Index: /LMDZ6/branches/Amaury_dev/libf/phylmd/pbl_surface_mod.F90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/phylmd/pbl_surface_mod.F90	(revision 5127)
+++ /LMDZ6/branches/Amaury_dev/libf/phylmd/pbl_surface_mod.F90	(revision 5128)
@@ -32,4 +32,5 @@
   USE config_ocean_skin_m, ONLY: activate_ocean_skin
   USE lmdz_abort_physic, ONLY: abort_physic
+
 #ifdef ISO
   USE infotrac_phy, ONLY: niso,ntraciso=>ntiso
Index: /LMDZ6/branches/Amaury_dev/libf/phylmd/physiq_mod.F90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/phylmd/physiq_mod.F90	(revision 5127)
+++ /LMDZ6/branches/Amaury_dev/libf/phylmd/physiq_mod.F90	(revision 5128)
@@ -349,4 +349,5 @@
             reffclwc, cldnvi, lcc3d, lcc3dcon, lcc3dstra, icc3dcon, icc3dstra
     USE output_physiqex_mod, ONLY: output_physiqex
+    USE lmdz_simu_airs, ONLY: simu_airs
 
     IMPLICIT NONE
@@ -600,5 +601,5 @@
 
     !      REAL,ALLOCATABLE,save :: run_off_lic_0(:)
-    !$OMP THREADPRIVATE(run_off_lic_0)
+    !!! !$OMP THREADPRIVATE(run_off_lic_0)
     !ym      SAVE run_off_lic_0
     !KE43
Index: DZ6/branches/Amaury_dev/libf/phylmd/simu_airs.F90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/phylmd/simu_airs.F90	(revision 5127)
+++ 	(revision )
@@ -1,1280 +1,0 @@
-module m_simu_airs
-
-  USE lmdz_print_control, ONLY: prt_level, lunout
-  USE lmdz_abort_physic, ONLY: abort_physic
-
-  IMPLICIT NONE
-
-  REAL, PARAMETER :: tau_thresh = 0.05 ! seuil nuages detectables
-  REAL, PARAMETER :: p_thresh = 445.   ! seuil nuages hauts
-  REAL, PARAMETER :: em_min = 0.2      ! seuils nuages semi-transp
-  REAL, PARAMETER :: em_max = 0.85
-  REAL, PARAMETER :: undef = 999.
-
-CONTAINS
-
-  REAL function search_tropopause(P, T, alt, N) result(P_tropo)
-    ! this function searches for the tropopause pressure in [hPa].
-    ! The search is based on ideology described in
-    ! Reichler et al., Determining the tropopause height from gridded data,
-    ! GRL, 30(20) 2042, doi:10.1029/2003GL018240, 2003
-
-    INTEGER N, i, i_lev, first_point, exit_flag, i_dir
-    REAL P(N), T(N), alt(N), slope(N)
-    REAL P_min, P_max, slope_limit, slope_2km, &
-            delta_alt_limit, tmp, delta_alt
-    PARAMETER(P_min = 75.0, P_max = 470.0)   ! hPa
-    PARAMETER(slope_limit = 0.002)         ! 2 K/km converted to K/m
-    PARAMETER(delta_alt_limit = 2000.0)    ! 2000 meters
-
-    do i = 1, N - 1
-      slope(i) = -(T(i + 1) - T(i)) / (alt(i + 1) - alt(i))
-    END DO
-    slope(N) = slope(N - 1)
-
-    IF (P(1)>P(N)) THEN
-      i_dir = 1
-      i = 1
-    else
-      i_dir = -1
-      i = N
-    end if
-
-    first_point = 0
-    exit_flag = 0
-    do while(exit_flag==0)
-      IF (P(i)>=P_min.AND.P(i)<=P_max) THEN
-        IF (first_point>0) THEN
-          delta_alt = alt(i) - alt(first_point)
-          IF (delta_alt>=delta_alt_limit) THEN
-            slope_2km = (T(first_point) - T(i)) / delta_alt
-            IF (slope_2km<slope_limit) THEN
-              exit_flag = 1
-            else
-              first_point = 0
-            end if
-          end if
-        end if
-        IF (first_point==0.AND.slope(i)<slope_limit) first_point = i
-      end if
-      i = i + i_dir
-      IF (i<=1.OR.i>=N) exit_flag = 1
-    END DO
-
-    IF (first_point<=0) P_tropo = 65.4321
-    IF (first_point==1) P_tropo = 64.5432
-    IF (first_point>1) THEN
-      tmp = (slope_limit - slope(first_point)) / (slope(first_point + 1) - &
-              slope(first_point)) * (P(first_point + 1) - P(first_point))
-      P_tropo = P(first_point) + tmp
-      ! PRINT*, 'P_tropo= ', tmp, P(first_point), P_tropo
-    end if
-
-    ! Ajout Marine
-    IF (P_tropo < 60. .OR. P_tropo > 470.) THEN
-      P_tropo = 999.
-    endif
-
-  END FUNCTION search_tropopause
-
-
-  SUBROUTINE cloud_structure(len_cs, rneb_cs, temp_cs, &
-          emis_cs, iwco_cs, &
-          pres_cs, dz_cs, rhodz_cs, rad_cs, &
-          cc_tot_cs, cc_hc_cs, cc_hist_cs, &
-          cc_Cb_cs, cc_ThCi_cs, cc_Anv_cs, &
-          pcld_hc_cs, tcld_hc_cs, &
-          em_hc_cs, iwp_hc_cs, deltaz_hc_cs, &
-          pcld_Cb_cs, tcld_Cb_cs, em_Cb_cs, &
-          pcld_ThCi_cs, tcld_ThCi_cs, em_ThCi_cs, &
-          pcld_Anv_cs, tcld_Anv_cs, em_Anv_cs, &
-          em_hist_cs, iwp_hist_cs, deltaz_hist_cs, rad_hist_cs)
-
-    INTEGER :: i, n, nss
-
-    INTEGER, INTENT(IN) :: len_cs
-    REAL, DIMENSION(:), INTENT(IN) :: rneb_cs, temp_cs
-    REAL, DIMENSION(:), INTENT(IN) :: emis_cs, iwco_cs, rad_cs
-    REAL, DIMENSION(:), INTENT(IN) :: pres_cs, dz_cs, rhodz_cs
-
-    REAL, INTENT(OUT) :: cc_tot_cs, cc_hc_cs, cc_hist_cs, &
-            cc_Cb_cs, cc_ThCi_cs, cc_Anv_cs, &
-            pcld_hc_cs, tcld_hc_cs, em_hc_cs, iwp_hc_cs, &
-            pcld_Cb_cs, tcld_Cb_cs, em_Cb_cs, &
-            pcld_ThCi_cs, tcld_ThCi_cs, em_ThCi_cs, &
-            pcld_Anv_cs, tcld_Anv_cs, em_Anv_cs, &
-            em_hist_cs, iwp_hist_cs, &
-            deltaz_hc_cs, deltaz_hist_cs, rad_hist_cs
-
-    REAL, DIMENSION(len_cs) :: rneb_ord
-    REAL :: rneb_min
-
-    REAL, DIMENSION(:), ALLOCATABLE :: s, s_hc, s_hist, rneb_max
-    REAL, DIMENSION(:), ALLOCATABLE :: sCb, sThCi, sAnv
-    REAL, DIMENSION(:), ALLOCATABLE :: iwp_ss, pcld_ss, tcld_ss, &
-            emis_ss
-    REAL, DIMENSION(:), ALLOCATABLE :: deltaz_ss, rad_ss
-
-    CHARACTER (len = 50) :: modname = 'simu_airs.cloud_structure'
-    CHARACTER (len = 160) :: abort_message
-
-    WRITE(lunout, *) 'dans cloud_structure'
-
-    CALL ordonne(len_cs, rneb_cs, rneb_ord)
-
-
-    ! Definition des sous_sections
-
-    rneb_min = rneb_ord(1)
-    nss = 1
-
-    do i = 2, size(rneb_cs)
-      IF (rneb_ord(i) > rneb_min) THEN
-        nss = nss + 1
-        rneb_min = rneb_ord(i)
-      endif
-    enddo
-
-    allocate (s(nss))
-    allocate (s_hc(nss))
-    allocate (s_hist(nss))
-    allocate (rneb_max(nss))
-    allocate (emis_ss(nss))
-    allocate (pcld_ss(nss))
-    allocate (tcld_ss(nss))
-    allocate (iwp_ss(nss))
-    allocate (deltaz_ss(nss))
-    allocate (rad_ss(nss))
-    allocate (sCb(nss))
-    allocate (sThCi(nss))
-    allocate (sAnv(nss))
-
-    rneb_min = rneb_ord(1)
-    n = 1
-    s(1) = rneb_ord(1)
-    s_hc(1) = rneb_ord(1)
-    s_hist(1) = rneb_ord(1)
-    sCb(1) = rneb_ord(1)
-    sThCi(1) = rneb_ord(1)
-    sAnv(1) = rneb_ord(1)
-
-    rneb_max(1) = rneb_ord(1)
-
-    do i = 2, size(rneb_cs)
-      IF (rneb_ord(i) > rneb_min) THEN
-        n = n + 1
-        s(n) = rneb_ord(i) - rneb_min
-        s_hc(n) = rneb_ord(i) - rneb_min
-        s_hist(n) = rneb_ord(i) - rneb_min
-        sCb(n) = rneb_ord(i) - rneb_min
-        sThCi(n) = rneb_ord(i) - rneb_min
-        sAnv(n) = rneb_ord(i) - rneb_min
-
-        rneb_max(n) = rneb_ord(i)
-        rneb_min = rneb_ord(i)
-      endif
-    enddo
-
-    ! Appel de sous_section
-
-    do i = 1, nss
-      CALL sous_section(len_cs, rneb_cs, temp_cs, &
-              emis_cs, iwco_cs, &
-              pres_cs, dz_cs, rhodz_cs, rad_cs, rneb_ord, &
-              rneb_max(i), s(i), s_hc(i), s_hist(i), &
-              sCb(i), sThCi(i), sAnv(i), &
-              emis_ss(i), &
-              pcld_ss(i), tcld_ss(i), iwp_ss(i), deltaz_ss(i), rad_ss(i))
-    enddo
-
-    ! Caracteristiques de la structure nuageuse
-
-    cc_tot_cs = 0.
-    cc_hc_cs = 0.
-    cc_hist_cs = 0.
-
-    cc_Cb_cs = 0.
-    cc_ThCi_cs = 0.
-    cc_Anv_cs = 0.
-
-    em_hc_cs = 0.
-    iwp_hc_cs = 0.
-    deltaz_hc_cs = 0.
-
-    em_hist_cs = 0.
-    iwp_hist_cs = 0.
-    deltaz_hist_cs = 0.
-    rad_hist_cs = 0.
-
-    pcld_hc_cs = 0.
-    tcld_hc_cs = 0.
-
-    pcld_Cb_cs = 0.
-    tcld_Cb_cs = 0.
-    em_Cb_cs = 0.
-
-    pcld_ThCi_cs = 0.
-    tcld_ThCi_cs = 0.
-    em_ThCi_cs = 0.
-
-    pcld_Anv_cs = 0.
-    tcld_Anv_cs = 0.
-    em_Anv_cs = 0.
-
-    do i = 1, nss
-
-      cc_tot_cs = cc_tot_cs + s(i)
-      cc_hc_cs = cc_hc_cs + s_hc(i)
-      cc_hist_cs = cc_hist_cs + s_hist(i)
-
-      cc_Cb_cs = cc_Cb_cs + sCb(i)
-      cc_ThCi_cs = cc_ThCi_cs + sThCi(i)
-      cc_Anv_cs = cc_Anv_cs + sAnv(i)
-
-      iwp_hc_cs = iwp_hc_cs + s_hc(i) * iwp_ss(i)
-      em_hc_cs = em_hc_cs + s_hc(i) * emis_ss(i)
-      deltaz_hc_cs = deltaz_hc_cs + s_hc(i) * deltaz_ss(i)
-
-      iwp_hist_cs = iwp_hist_cs + s_hist(i) * iwp_ss(i)
-      em_hist_cs = em_hist_cs + s_hist(i) * emis_ss(i)
-      deltaz_hist_cs = deltaz_hist_cs + s_hist(i) * deltaz_ss(i)
-      rad_hist_cs = rad_hist_cs + s_hist(i) * rad_ss(i)
-
-      pcld_hc_cs = pcld_hc_cs + s_hc(i) * pcld_ss(i)
-      tcld_hc_cs = tcld_hc_cs + s_hc(i) * tcld_ss(i)
-
-      pcld_Cb_cs = pcld_Cb_cs + sCb(i) * pcld_ss(i)
-      tcld_Cb_cs = tcld_Cb_cs + sCb(i) * tcld_ss(i)
-      em_Cb_cs = em_Cb_cs + sCb(i) * emis_ss(i)
-
-      pcld_ThCi_cs = pcld_ThCi_cs + sThCi(i) * pcld_ss(i)
-      tcld_ThCi_cs = tcld_ThCi_cs + sThCi(i) * tcld_ss(i)
-      em_ThCi_cs = em_ThCi_cs + sThCi(i) * emis_ss(i)
-
-      pcld_Anv_cs = pcld_Anv_cs + sAnv(i) * pcld_ss(i)
-      tcld_Anv_cs = tcld_Anv_cs + sAnv(i) * tcld_ss(i)
-      em_Anv_cs = em_Anv_cs + sAnv(i) * emis_ss(i)
-
-    enddo
-
-    deallocate(s)
-    deallocate (s_hc)
-    deallocate (s_hist)
-    deallocate (rneb_max)
-    deallocate (emis_ss)
-    deallocate (pcld_ss)
-    deallocate (tcld_ss)
-    deallocate (iwp_ss)
-    deallocate (deltaz_ss)
-    deallocate (rad_ss)
-    deallocate (sCb)
-    deallocate (sThCi)
-    deallocate (sAnv)
-
-    CALL normal_undef(pcld_hc_cs, cc_hc_cs)
-    CALL normal_undef(tcld_hc_cs, cc_hc_cs)
-    CALL normal_undef(iwp_hc_cs, cc_hc_cs)
-    CALL normal_undef(em_hc_cs, cc_hc_cs)
-    CALL normal_undef(deltaz_hc_cs, cc_hc_cs)
-
-    CALL normal_undef(iwp_hist_cs, cc_hist_cs)
-    CALL normal_undef(em_hist_cs, cc_hist_cs)
-    CALL normal_undef(deltaz_hist_cs, cc_hist_cs)
-    CALL normal_undef(rad_hist_cs, cc_hist_cs)
-
-    CALL normal_undef(pcld_Cb_cs, cc_Cb_cs)
-    CALL normal_undef(tcld_Cb_cs, cc_Cb_cs)
-    CALL normal_undef(em_Cb_cs, cc_Cb_cs)
-
-    CALL normal_undef(pcld_ThCi_cs, cc_ThCi_cs)
-    CALL normal_undef(tcld_ThCi_cs, cc_ThCi_cs)
-    CALL normal_undef(em_ThCi_cs, cc_ThCi_cs)
-
-    CALL normal_undef(pcld_Anv_cs, cc_Anv_cs)
-    CALL normal_undef(tcld_Anv_cs, cc_Anv_cs)
-    CALL normal_undef(em_Anv_cs, cc_Anv_cs)
-
-
-    ! Tests
-
-    IF (cc_tot_cs > maxval(rneb_cs) .AND. &
-            abs(cc_tot_cs - maxval(rneb_cs)) > 1.e-4)  THEN
-      WRITE(abort_message, *) 'cc_tot_cs > max rneb_cs', cc_tot_cs, maxval(rneb_cs)
-      CALL abort_physic(modname, abort_message, 1)
-    endif
-
-    IF (iwp_hc_cs < 0.) THEN
-      abort_message = 'cloud_structure: iwp_hc_cs < 0'
-      CALL abort_physic(modname, abort_message, 1)
-    endif
-
-  END SUBROUTINE  cloud_structure
-
-
-  SUBROUTINE normal_undef(num, den)
-
-    REAL, INTENT(IN) :: den
-    REAL, INTENT(INOUT) :: num
-
-    IF (den /= 0) THEN
-      num = num / den
-    else
-      num = undef
-    endif
-
-  END SUBROUTINE  normal_undef
-
-
-  SUBROUTINE normal2_undef(res, num, den)
-
-    REAL, INTENT(IN) :: den
-    REAL, INTENT(IN) :: num
-    REAL, INTENT(OUT) :: res
-
-    IF (den /= 0.) THEN
-      res = num / den
-    else
-      res = undef
-    endif
-
-  END SUBROUTINE  normal2_undef
-
-
-  SUBROUTINE sous_section(len_cs, rneb_cs, temp_cs, &
-          emis_cs, iwco_cs, &
-          pres_cs, dz_cs, rhodz_cs, rad_cs, rneb_ord, &
-          rnebmax, stot, shc, shist, &
-          sCb, sThCi, sAnv, &
-          emis, pcld, tcld, iwp, deltaz, rad)
-
-    INTEGER, INTENT(IN) :: len_cs
-    REAL, DIMENSION(len_cs), INTENT(IN) :: rneb_cs, temp_cs
-    REAL, DIMENSION(len_cs), INTENT(IN) :: emis_cs, iwco_cs, &
-            rneb_ord
-    REAL, DIMENSION(len_cs), INTENT(IN) :: pres_cs, dz_cs, rad_cs
-    REAL, DIMENSION(len_cs), INTENT(IN) :: rhodz_cs
-    REAL, DIMENSION(len_cs) :: tau_cs, w
-    REAL, INTENT(IN) :: rnebmax
-    REAL, INTENT(INOUT) :: stot, shc, shist
-    REAL, INTENT(INOUT) :: sCb, sThCi, sAnv
-    REAL, INTENT(OUT) :: emis, pcld, tcld, iwp, deltaz, rad
-
-    INTEGER :: i, ideb, ibeg, iend, nuage, visible
-    REAL :: som, som_tau, som_iwc, som_dz, som_rad, tau
-
-    CHARACTER (len = 50) :: modname = 'simu_airs.sous_section'
-    CHARACTER (len = 160) :: abort_message
-
-
-    ! Ponderation: 1 pour les nuages, 0 pour les trous
-
-    do i = 1, len_cs
-      IF (rneb_cs(i) >= rnebmax) THEN
-        w(i) = 1.
-      else
-        w(i) = 0.
-      endif
-    enddo
-
-    ! Calcul des epaisseurs optiques a partir des emissivites
-
-    som = 0.
-    do i = 1, len_cs
-      IF (emis_cs(i) == 1.) THEN
-        tau_cs(i) = 10.
-      else
-        tau_cs(i) = -log(1. - emis_cs(i))
-      endif
-      som = som + tau_cs(i)
-    enddo
-
-    ideb = 1
-    nuage = 0
-    visible = 0
-
-
-    ! Boucle sur les nuages
-    do while (ideb /= 0 .AND. ideb <= len_cs)
-
-
-      ! Definition d'un nuage de la sous-section
-
-      CALL topbot(ideb, w, ibeg, iend)
-      ideb = iend + 1
-
-      IF (ibeg > 0) THEN
-        nuage = nuage + 1
-
-        ! On determine les caracteristiques du nuage
-        ! (ep. optique, ice water path, pression, temperature)
-
-        CALL caract(ibeg, iend, temp_cs, tau_cs, iwco_cs, &
-                pres_cs, dz_cs, rhodz_cs, rad_cs, pcld, tcld, &
-                som_tau, som_iwc, som_dz, som_rad)
-
-        ! On masque le nuage s'il n'est pas detectable
-
-        CALL masque(ibeg, iend, som_tau, visible, w)
-
-      endif
-
-      ! Fin boucle nuages
-    enddo
-
-
-    ! Analyse du nuage detecte
-
-    CALL topbot(1, w, ibeg, iend)
-
-    IF (ibeg > 0) THEN
-      CALL caract(ibeg, iend, temp_cs, tau_cs, iwco_cs, &
-              pres_cs, dz_cs, rhodz_cs, rad_cs, pcld, tcld, &
-              som_tau, som_iwc, som_dz, som_rad)
-
-      tau = som_tau
-      emis = 1. - exp(-tau)
-      iwp = som_iwc
-      deltaz = som_dz
-      rad = som_rad
-
-      IF (pcld > p_thresh) THEN
-        shc = 0.
-        shist = 0.
-        sCb = 0.
-        sThCi = 0.
-        sAnv = 0.
-
-      else
-
-        IF (emis < em_min .OR. emis > em_max  &
-                .OR. tcld > 230.) THEN
-          shist = 0.
-        endif
-
-        IF (emis < 0.98) THEN
-          sCb = 0.
-        endif
-
-        IF (emis > 0.5 .OR. emis < 0.1) THEN
-          sThCi = 0.
-        endif
-
-        IF (emis <= 0.5 .OR. emis >= 0.98) THEN
-          sAnv = 0.
-        endif
-
-      endif
-
-    else
-
-      tau = 0.
-      emis = 0.
-      iwp = 0.
-      deltaz = 0.
-      pcld = 0.
-      tcld = 0.
-      stot = 0.
-      shc = 0.
-      shist = 0.
-      rad = 0.
-      sCb = 0.
-      sThCi = 0.
-      sAnv = 0.
-
-    endif
-
-
-    ! Tests
-
-    IF (iwp < 0.) THEN
-      WRITE(abort_message, *) 'ideb iwp =', ideb, iwp
-      CALL abort_physic(modname, abort_message, 1)
-    endif
-
-    IF (deltaz < 0.) THEN
-      WRITE(abort_message, *)'ideb deltaz =', ideb, deltaz
-      CALL abort_physic(modname, abort_message, 1)
-    endif
-
-    IF (emis < 0.048 .AND. emis /= 0.) THEN
-      WRITE(abort_message, *) 'ideb emis =', ideb, emis
-      CALL abort_physic(modname, abort_message, 1)
-    endif
-
-  END SUBROUTINE  sous_section
-
-
-  SUBROUTINE masque(ibeg, iend, som_tau, &
-          visible, w)
-
-    INTEGER, INTENT(IN) :: ibeg, iend
-    REAL, INTENT(IN) :: som_tau
-
-    INTEGER, INTENT(INOUT) :: visible
-    REAL, DIMENSION(:), INTENT(INOUT) :: w
-
-    INTEGER :: i
-
-
-
-    ! Masque
-
-    ! Cas ou il n'y a pas de nuage visible au-dessus
-
-    IF (visible == 0) THEN
-      IF (som_tau < tau_thresh) THEN
-        do i = ibeg, iend
-          w(i) = 0.
-        enddo
-      else
-        visible = 1
-      endif
-
-      ! Cas ou il y a un nuage visible au-dessus
-
-    else
-
-      do i = ibeg, iend
-        w(i) = 0.
-      enddo
-
-    endif
-
-  END SUBROUTINE  masque
-
-
-  SUBROUTINE caract(ibeg, iend, temp_cs, tau_cs, iwco_cs, &
-          pres_cs, dz_cs, rhodz_cs, rad_cs, pcld, tcld, &
-          som_tau, som_iwc, som_dz, som_rad)
-
-    INTEGER, INTENT(IN) :: ibeg, iend
-    REAL, DIMENSION(:), INTENT(IN) :: tau_cs, iwco_cs, temp_cs
-    REAL, DIMENSION(:), INTENT(IN) :: pres_cs, dz_cs, rad_cs
-    REAL, DIMENSION(:), INTENT(IN) :: rhodz_cs
-    REAL, INTENT(OUT) :: som_tau, som_iwc, som_dz, som_rad
-    REAL, INTENT(OUT) :: pcld, tcld
-
-    INTEGER :: i, ibase, imid
-
-    CHARACTER (len = 50) :: modname = 'simu_airs.caract'
-    CHARACTER (len = 160) :: abort_message
-
-    ! Somme des epaisseurs optiques et des contenus en glace sur le nuage
-
-    som_tau = 0.
-    som_iwc = 0.
-    som_dz = 0.
-    som_rad = 0.
-    ibase = -100
-
-    do i = ibeg, iend
-
-      som_tau = som_tau + tau_cs(i)
-
-      som_dz = som_dz + dz_cs(i)
-      som_iwc = som_iwc + iwco_cs(i) * 1000 * rhodz_cs(i)  ! en g/m2
-      som_rad = som_rad + rad_cs(i) * dz_cs(i)
-
-      IF (som_tau > 3. .AND. ibase == -100) THEN
-        ibase = i - 1
-      endif
-
-    enddo
-
-    IF (som_dz /= 0.) THEN
-      som_rad = som_rad / som_dz
-    else
-      WRITE(*, *) 'som_dez = 0 stop '
-      WRITE(*, *) 'ibeg, iend =', ibeg, iend
-      do i = ibeg, iend
-        WRITE(*, *) dz_cs(i), rhodz_cs(i)
-      enddo
-      abort_message = 'see above'
-      CALL abort_physic(modname, abort_message, 1)
-    endif
-
-    ! Determination de Pcld et Tcld
-
-    IF (ibase < ibeg) THEN
-      ibase = ibeg
-    endif
-
-    imid = (ibeg + ibase) / 2
-
-    pcld = pres_cs(imid) / 100.        ! pcld en hPa
-    tcld = temp_cs(imid)
-
-  END SUBROUTINE  caract
-
-  SUBROUTINE topbot(ideb, w, ibeg, iend)
-
-    INTEGER, INTENT(IN) :: ideb
-    REAL, DIMENSION(:), INTENT(IN) :: w
-    INTEGER, INTENT(OUT) :: ibeg, iend
-
-    INTEGER :: i, itest
-
-    itest = 0
-    ibeg = 0
-    iend = 0
-
-    do i = ideb, size(w)
-
-      IF (w(i) == 1. .AND. itest == 0) THEN
-        ibeg = i
-        itest = 1
-      endif
-
-    enddo
-
-    i = ibeg
-    do while (w(i) == 1. .AND. i <= size(w))
-      i = i + 1
-    enddo
-    iend = i - 1
-
-  END SUBROUTINE  topbot
-
-  SUBROUTINE ordonne(len_cs, rneb_cs, rneb_ord)
-
-    INTEGER, INTENT(IN) :: len_cs
-    REAL, DIMENSION(:), INTENT(IN) :: rneb_cs
-    REAL, DIMENSION(:), INTENT(OUT) :: rneb_ord
-
-    INTEGER :: i, j, ind_min
-
-    REAL, DIMENSION(len_cs) :: rneb
-    REAL :: rneb_max
-
-    do i = 1, size(rneb_cs)
-      rneb(i) = rneb_cs(i)
-    enddo
-
-    do j = 1, size(rneb_cs)
-
-      rneb_max = 100.
-
-      do i = 1, size(rneb_cs)
-        IF (rneb(i) < rneb_max) THEN
-          rneb_max = rneb(i)
-          ind_min = i
-        endif
-      enddo
-
-      rneb_ord(j) = rneb_max
-      rneb(ind_min) = 100.
-
-    enddo
-
-  END SUBROUTINE  ordonne
-
-
-  SUBROUTINE sim_mesh(rneb_1D, temp_1D, emis_1D, &
-          iwcon_1D, rad_1D, &
-          pres, dz, &
-          rhodz_1D, cc_tot_mesh, cc_hc_mesh, cc_hist_mesh, pcld_hc_mesh, &
-          tcld_hc_mesh, &
-          em_hc_mesh, iwp_hc_mesh, deltaz_hc_mesh, &
-          cc_Cb_mesh, cc_ThCi_mesh, cc_Anv_mesh, &
-          pcld_Cb_mesh, tcld_Cb_mesh, em_Cb_mesh, &
-          pcld_ThCi_mesh, tcld_ThCi_mesh, em_ThCi_mesh, &
-          pcld_Anv_mesh, tcld_Anv_mesh, em_Anv_mesh, &
-          em_hist_mesh, iwp_hist_mesh, deltaz_hist_mesh, rad_hist_mesh)
-
-    USE dimphy
-
-    REAL, DIMENSION(klev), INTENT(IN) :: rneb_1D, temp_1D, emis_1D, &
-            iwcon_1D, rad_1D
-    REAL, DIMENSION(klev), INTENT(IN) :: pres, dz, rhodz_1D
-    REAL, INTENT(OUT) :: cc_tot_mesh, cc_hc_mesh, cc_hist_mesh
-    REAL, INTENT(OUT) :: cc_Cb_mesh, cc_ThCi_mesh, cc_Anv_mesh
-    REAL, INTENT(OUT) :: em_hc_mesh, pcld_hc_mesh, tcld_hc_mesh, &
-            iwp_hc_mesh
-
-    REAL, INTENT(OUT) :: pcld_Cb_mesh, tcld_Cb_mesh, em_Cb_mesh
-    REAL, INTENT(OUT) :: pcld_ThCi_mesh, tcld_ThCi_mesh, &
-            em_ThCi_mesh
-    REAL, INTENT(OUT) :: pcld_Anv_mesh, tcld_Anv_mesh, em_Anv_mesh
-
-    REAL, INTENT(OUT) :: em_hist_mesh, iwp_hist_mesh, rad_hist_mesh
-    REAL, INTENT(OUT) :: deltaz_hc_mesh, deltaz_hist_mesh
-
-    REAL, DIMENSION(:), ALLOCATABLE :: rneb_cs, temp_cs, emis_cs, &
-            iwco_cs
-    REAL, DIMENSION(:), ALLOCATABLE :: pres_cs, dz_cs, rad_cs, &
-            rhodz_cs
-
-    INTEGER :: i, j, l
-    INTEGER :: ltop, itop, ibot, num_cs, N_cs, len_cs, ics
-
-    REAL :: som_emi_hc, som_pcl_hc, som_tcl_hc, som_iwp_hc, som_hc, &
-            som_hist
-    REAL :: som_emi_hist, som_iwp_hist, som_deltaz_hc, &
-            som_deltaz_hist
-    REAL :: som_rad_hist
-    REAL :: som_Cb, som_ThCi, som_Anv
-    REAL :: som_emi_Cb, som_tcld_Cb, som_pcld_Cb
-    REAL :: som_emi_Anv, som_tcld_Anv, som_pcld_Anv
-    REAL :: som_emi_ThCi, som_tcld_ThCi, som_pcld_ThCi
-    REAL :: tsom_tot, tsom_hc, tsom_hist
-    REAL :: prod, prod_hh
-
-    REAL :: cc_tot_cs, cc_hc_cs, cc_hist_cs
-    REAL :: cc_Cb_cs, cc_ThCi_cs, cc_Anv_cs
-    REAL :: pcld_hc_cs, tcld_hc_cs
-    REAL :: em_hc_cs, iwp_hc_cs, deltaz_hc_cs
-    REAL :: pcld_Cb_cs, tcld_Cb_cs, em_Cb_cs
-    REAL :: pcld_ThCi_cs, tcld_ThCi_cs, em_ThCi_cs
-    REAL :: pcld_Anv_cs, tcld_Anv_cs, em_Anv_cs
-    REAL :: em_hist_cs, iwp_hist_cs, deltaz_hist_cs, rad_hist_cs
-
-    REAL, DIMENSION(klev) :: test_tot, test_hc, test_hist
-    REAL, DIMENSION(klev) :: test_pcld, test_tcld, test_em, test_iwp
-
-    CHARACTER (len = 50) :: modname = 'simu_airs.sim_mesh'
-    CHARACTER (len = 160) :: abort_message
-
-    do j = 1, klev
-      WRITE(lunout, *) 'simu_airs, j, rneb_1D =', rneb_1D(j)
-    enddo
-
-    ! Definition des structures nuageuses, de la plus haute a la plus basse
-
-    num_cs = 0
-    ltop = klev - 1
-
-    prod = 1.
-
-    som_emi_hc = 0.
-    som_emi_hist = 0.
-    som_pcl_hc = 0.
-    som_tcl_hc = 0.
-    som_iwp_hc = 0.
-    som_iwp_hist = 0.
-    som_deltaz_hc = 0.
-    som_deltaz_hist = 0.
-    som_rad_hist = 0.
-    som_hc = 0.
-    som_hist = 0.
-
-    som_Cb = 0.
-    som_ThCi = 0.
-    som_Anv = 0.
-
-    som_emi_Cb = 0.
-    som_pcld_Cb = 0.
-    som_tcld_Cb = 0.
-
-    som_emi_ThCi = 0.
-    som_pcld_ThCi = 0.
-    som_tcld_ThCi = 0.
-
-    som_emi_Anv = 0.
-    som_pcld_Anv = 0.
-    som_tcld_Anv = 0.
-
-    tsom_tot = 0.
-    tsom_hc = 0.
-    tsom_hist = 0.
-
-    do while (ltop >= 1)   ! Boucle sur toute la colonne
-
-      itop = 0
-
-      do l = ltop, 1, -1
-
-        IF (itop == 0 .AND. rneb_1D(l) > 0.001) THEN
-          itop = l
-        endif
-
-      enddo
-
-      ibot = itop
-
-      do while (rneb_1D(ibot) > 0.001 .AND. ibot >= 1)
-        ibot = ibot - 1
-      enddo
-
-      ibot = ibot + 1
-
-      IF (itop > 0) then    ! itop > 0
-
-        num_cs = num_cs + 1
-        len_cs = itop - ibot + 1
-
-        ! Allocation et definition des variables de la structure nuageuse
-        ! le premier indice denote ce qui est le plus haut
-
-        allocate (rneb_cs(len_cs))
-        allocate (temp_cs(len_cs))
-        allocate (emis_cs(len_cs))
-        allocate (iwco_cs(len_cs))
-        allocate (pres_cs(len_cs))
-        allocate (dz_cs(len_cs))
-        allocate (rad_cs(len_cs))
-        allocate (rhodz_cs(len_cs))
-
-        ics = 0
-
-        do i = itop, ibot, -1
-          ics = ics + 1
-          rneb_cs(ics) = rneb_1D(i)
-          temp_cs(ics) = temp_1D(i)
-          emis_cs(ics) = emis_1D(i)
-          iwco_cs(ics) = iwcon_1D(i)
-          rad_cs(ics) = rad_1D(i)
-          pres_cs(ics) = pres(i)
-          dz_cs(ics) = dz(i)
-          rhodz_cs(ics) = rhodz_1D(i)
-        enddo
-
-        ! Appel du sous_programme cloud_structure
-
-        CALL cloud_structure(len_cs, rneb_cs, temp_cs, emis_cs, iwco_cs, &
-                pres_cs, dz_cs, rhodz_cs, rad_cs, &
-                cc_tot_cs, cc_hc_cs, cc_hist_cs, &
-                cc_Cb_cs, cc_ThCi_cs, cc_Anv_cs, &
-                pcld_hc_cs, tcld_hc_cs, &
-                em_hc_cs, iwp_hc_cs, deltaz_hc_cs, &
-                pcld_Cb_cs, tcld_Cb_cs, em_Cb_cs, &
-                pcld_ThCi_cs, tcld_ThCi_cs, em_ThCi_cs, &
-                pcld_Anv_cs, tcld_Anv_cs, em_Anv_cs, &
-                em_hist_cs, iwp_hist_cs, deltaz_hist_cs, rad_hist_cs)
-
-        deallocate (rneb_cs)
-        deallocate (temp_cs)
-        deallocate (emis_cs)
-        deallocate (iwco_cs)
-        deallocate (pres_cs)
-        deallocate (dz_cs)
-        deallocate (rad_cs)
-        deallocate (rhodz_cs)
-
-
-        ! Pour la couverture nuageuse sur la maille
-
-        prod_hh = prod
-
-        prod = prod * (1. - cc_tot_cs)
-
-        ! Pour les autres variables definies sur la maille
-
-        som_emi_hc = som_emi_hc + em_hc_cs * cc_hc_cs * prod_hh
-        som_iwp_hc = som_iwp_hc + iwp_hc_cs * cc_hc_cs * prod_hh
-        som_deltaz_hc = som_deltaz_hc + deltaz_hc_cs * cc_hc_cs * prod_hh
-
-        som_emi_Cb = som_emi_Cb + em_Cb_cs * cc_Cb_cs * prod_hh
-        som_tcld_Cb = som_tcld_Cb + tcld_Cb_cs * cc_Cb_cs * prod_hh
-        som_pcld_Cb = som_pcld_Cb + pcld_Cb_cs * cc_Cb_cs * prod_hh
-
-        som_emi_ThCi = som_emi_ThCi + em_ThCi_cs * cc_ThCi_cs * prod_hh
-        som_tcld_ThCi = som_tcld_ThCi + tcld_ThCi_cs * cc_ThCi_cs * prod_hh
-        som_pcld_ThCi = som_pcld_ThCi + pcld_ThCi_cs * cc_ThCi_cs * prod_hh
-
-        som_emi_Anv = som_emi_Anv + em_Anv_cs * cc_Anv_cs * prod_hh
-        som_tcld_Anv = som_tcld_Anv + tcld_Anv_cs * cc_Anv_cs * prod_hh
-        som_pcld_Anv = som_pcld_Anv + pcld_Anv_cs * cc_Anv_cs * prod_hh
-
-        som_emi_hist = som_emi_hist + em_hist_cs * cc_hist_cs * prod_hh
-        som_iwp_hist = som_iwp_hist + iwp_hist_cs * cc_hist_cs * prod_hh
-        som_deltaz_hist = som_deltaz_hist + &
-                deltaz_hist_cs * cc_hist_cs * prod_hh
-        som_rad_hist = som_rad_hist + rad_hist_cs * cc_hist_cs * prod_hh
-
-        som_pcl_hc = som_pcl_hc + pcld_hc_cs * cc_hc_cs * prod_hh
-        som_tcl_hc = som_tcl_hc + tcld_hc_cs * cc_hc_cs * prod_hh
-
-        som_hc = som_hc + cc_hc_cs * prod_hh
-        som_hist = som_hist + cc_hist_cs * prod_hh
-
-        som_Cb = som_Cb + cc_Cb_cs * prod_hh
-        som_ThCi = som_ThCi + cc_ThCi_cs * prod_hh
-        som_Anv = som_Anv + cc_Anv_cs * prod_hh
-
-
-        ! Pour test
-
-        CALL test_bornes('cc_tot_cs     ', cc_tot_cs, 1., 0.)
-        CALL test_bornes('cc_hc_cs      ', cc_hc_cs, 1., 0.)
-        CALL test_bornes('cc_hist_cs    ', cc_hist_cs, 1., 0.)
-        CALL test_bornes('pcld_hc_cs    ', pcld_hc_cs, 1200., 0.)
-        CALL test_bornes('tcld_hc_cs    ', tcld_hc_cs, 1000., 100.)
-        CALL test_bornes('em_hc_cs      ', em_hc_cs, 1000., 0.048)
-
-        test_tot(num_cs) = cc_tot_cs
-        test_hc(num_cs) = cc_hc_cs
-        test_hist(num_cs) = cc_hist_cs
-        test_pcld(num_cs) = pcld_hc_cs
-        test_tcld(num_cs) = tcld_hc_cs
-        test_em(num_cs) = em_hc_cs
-        test_iwp(num_cs) = iwp_hc_cs
-
-        tsom_tot = tsom_tot + cc_tot_cs
-        tsom_hc = tsom_hc + cc_hc_cs
-        tsom_hist = tsom_hist + cc_hist_cs
-
-      endif                   ! itop > 0
-
-      ltop = ibot - 1
-
-    enddo                   ! fin de la boucle sur la colonne
-
-    N_CS = num_cs
-
-
-    ! Determination des variables de sortie
-
-    IF (N_CS > 0) then   ! if N_CS>0
-
-      cc_tot_mesh = 1. - prod
-
-      cc_hc_mesh = som_hc
-      cc_hist_mesh = som_hist
-
-      cc_Cb_mesh = som_Cb
-      cc_ThCi_mesh = som_ThCi
-      cc_Anv_mesh = som_Anv
-
-      CALL normal2_undef(pcld_hc_mesh, som_pcl_hc, &
-              cc_hc_mesh)
-      CALL normal2_undef(tcld_hc_mesh, som_tcl_hc, &
-              cc_hc_mesh)
-      CALL normal2_undef(em_hc_mesh, som_emi_hc, &
-              cc_hc_mesh)
-      CALL normal2_undef(iwp_hc_mesh, som_iwp_hc, &
-              cc_hc_mesh)
-      CALL normal2_undef(deltaz_hc_mesh, som_deltaz_hc, &
-              cc_hc_mesh)
-
-      CALL normal2_undef(em_Cb_mesh, som_emi_Cb, &
-              cc_Cb_mesh)
-      CALL normal2_undef(tcld_Cb_mesh, som_tcld_Cb, &
-              cc_Cb_mesh)
-      CALL normal2_undef(pcld_Cb_mesh, som_pcld_Cb, &
-              cc_Cb_mesh)
-
-      CALL normal2_undef(em_ThCi_mesh, som_emi_ThCi, &
-              cc_ThCi_mesh)
-      CALL normal2_undef(tcld_ThCi_mesh, som_tcld_ThCi, &
-              cc_ThCi_mesh)
-      CALL normal2_undef(pcld_ThCi_mesh, som_pcld_ThCi, &
-              cc_ThCi_mesh)
-
-      CALL normal2_undef(em_Anv_mesh, som_emi_Anv, &
-              cc_Anv_mesh)
-      CALL normal2_undef(tcld_Anv_mesh, som_tcld_Anv, &
-              cc_Anv_mesh)
-      CALL normal2_undef(pcld_Anv_mesh, som_pcld_Anv, &
-              cc_Anv_mesh)
-
-      CALL normal2_undef(em_hist_mesh, som_emi_hist, &
-              cc_hist_mesh)
-      CALL normal2_undef(iwp_hist_mesh, som_iwp_hist, &
-              cc_hist_mesh)
-      CALL normal2_undef(deltaz_hist_mesh, som_deltaz_hist, &
-              cc_hist_mesh)
-      CALL normal2_undef(rad_hist_mesh, som_rad_hist, &
-              cc_hist_mesh)
-
-
-      ! Tests
-
-      ! Tests
-
-      IF (cc_tot_mesh > tsom_tot .AND. &
-              abs(cc_tot_mesh - tsom_tot) > 1.e-4) THEN
-        WRITE(abort_message, *)'cc_tot_mesh > tsom_tot', cc_tot_mesh, tsom_tot
-        CALL abort_physic(modname, abort_message, 1)
-      endif
-
-      IF (cc_tot_mesh < maxval(test_tot(1:N_CS)) .AND. &
-              abs(cc_tot_mesh - maxval(test_tot(1:N_CS))) > 1.e-4) THEN
-        WRITE(abort_message, *) 'cc_tot_mesh < max', cc_tot_mesh, maxval(test_tot(1:N_CS))
-        CALL abort_physic(modname, abort_message, 1)
-      endif
-
-      IF (cc_hc_mesh > tsom_hc .AND. &
-              abs(cc_hc_mesh - tsom_hc) > 1.e-4) THEN
-        WRITE(abort_message, *) 'cc_hc_mesh > tsom_hc', cc_hc_mesh, tsom_hc
-        CALL abort_physic(modname, abort_message, 1)
-      endif
-
-      IF (cc_hc_mesh < maxval(test_hc(1:N_CS)) .AND. &
-              abs(cc_hc_mesh - maxval(test_hc(1:N_CS))) > 1.e-4) THEN
-        WRITE(abort_message, *) 'cc_hc_mesh < max', cc_hc_mesh, maxval(test_hc(1:N_CS))
-        CALL abort_physic(modname, abort_message, 1)
-      endif
-
-      IF (cc_hist_mesh > tsom_hist .AND. &
-              abs(cc_hist_mesh - tsom_hist) > 1.e-4) THEN
-        WRITE(abort_message, *) 'cc_hist_mesh > tsom_hist', cc_hist_mesh, tsom_hist
-        CALL abort_physic(modname, abort_message, 1)
-      endif
-
-      IF (cc_hist_mesh < 0.) THEN
-        WRITE(abort_message, *) 'cc_hist_mesh < 0', cc_hist_mesh
-        CALL abort_physic(modname, abort_message, 1)
-      endif
-
-      IF ((pcld_hc_mesh > maxval(test_pcld(1:N_CS)) .OR. &
-              pcld_hc_mesh < minval(test_pcld(1:N_CS))) .AND. &
-              abs(pcld_hc_mesh - maxval(test_pcld(1:N_CS))) > 1. .AND. &
-              maxval(test_pcld(1:N_CS)) /= 999. &
-              .AND. minval(test_pcld(1:N_CS)) /= 999.) THEN
-        WRITE(abort_message, *) 'pcld_hc_mesh est faux', pcld_hc_mesh, maxval(test_pcld(1:N_CS)), &
-                minval(test_pcld(1:N_CS))
-        CALL abort_physic(modname, abort_message, 1)
-      endif
-
-      IF ((tcld_hc_mesh > maxval(test_tcld(1:N_CS)) .OR. &
-              tcld_hc_mesh < minval(test_tcld(1:N_CS))) .AND. &
-              abs(tcld_hc_mesh - maxval(test_tcld(1:N_CS))) > 0.1 .AND. &
-              maxval(test_tcld(1:N_CS)) /= 999. &
-              .AND. minval(test_tcld(1:N_CS)) /= 999.) THEN
-        WRITE(abort_message, *) 'tcld_hc_mesh est faux', tcld_hc_mesh, maxval(test_tcld(1:N_CS)), &
-                minval(test_tcld(1:N_CS))
-        CALL abort_physic(modname, abort_message, 1)
-      endif
-
-      IF ((em_hc_mesh > maxval(test_em(1:N_CS)) .OR. &
-              em_hc_mesh < minval(test_em(1:N_CS))) .AND. &
-              abs(em_hc_mesh - maxval(test_em(1:N_CS))) > 1.e-4 .AND. &
-              minval(test_em(1:N_CS)) /= 999. .AND. &
-              maxval(test_em(1:N_CS)) /= 999.) THEN
-        WRITE(abort_message, *) 'em_hc_mesh est faux', em_hc_mesh, maxval(test_em(1:N_CS)), &
-                minval(test_em(1:N_CS))
-        CALL abort_physic(modname, abort_message, 1)
-      endif
-
-    else               ! if N_CS>0
-
-      cc_tot_mesh = 0.
-      cc_hc_mesh = 0.
-      cc_hist_mesh = 0.
-
-      cc_Cb_mesh = 0.
-      cc_ThCi_mesh = 0.
-      cc_Anv_mesh = 0.
-
-      iwp_hc_mesh = undef
-      deltaz_hc_mesh = undef
-      em_hc_mesh = undef
-      iwp_hist_mesh = undef
-      deltaz_hist_mesh = undef
-      rad_hist_mesh = undef
-      em_hist_mesh = undef
-      pcld_hc_mesh = undef
-      tcld_hc_mesh = undef
-
-      pcld_Cb_mesh = undef
-      tcld_Cb_mesh = undef
-      em_Cb_mesh = undef
-
-      pcld_ThCi_mesh = undef
-      tcld_ThCi_mesh = undef
-      em_ThCi_mesh = undef
-
-      pcld_Anv_mesh = undef
-      tcld_Anv_mesh = undef
-      em_Anv_mesh = undef
-
-    endif                  ! if N_CS>0
-
-  END SUBROUTINE  sim_mesh
-
-  SUBROUTINE test_bornes(sx, x, bsup, binf)
-
-    REAL, INTENT(IN) :: x, bsup, binf
-    character*14, INTENT(IN) :: sx
-    CHARACTER (len = 50) :: modname = 'simu_airs.test_bornes'
-    CHARACTER (len = 160) :: abort_message
-
-    IF (x > bsup .OR. x < binf) THEN
-      WRITE(abort_message, *) sx, 'est faux', sx, x
-      CALL abort_physic(modname, abort_message, 1)
-    endif
-
-  END SUBROUTINE  test_bornes
-
-END MODULE m_simu_airs
-
-
-SUBROUTINE simu_airs &
-        (itap, rneb_airs, temp_airs, cldemi_airs, iwcon0_airs, rad_airs, &
-        geop_airs, pplay_airs, paprs_airs, &
-        map_prop_hc, map_prop_hist, &
-        map_emis_hc, map_iwp_hc, map_deltaz_hc, map_pcld_hc, map_tcld_hc, &
-        map_emis_Cb, map_pcld_Cb, map_tcld_Cb, &
-        map_emis_ThCi, map_pcld_ThCi, map_tcld_ThCi, &
-        map_emis_Anv, map_pcld_Anv, map_tcld_Anv, &
-        map_emis_hist, map_iwp_hist, map_deltaz_hist, map_rad_hist, &
-        map_ntot, map_hc, map_hist, &
-        map_Cb, map_ThCi, map_Anv, alt_tropo)
-
-  USE dimphy
-  USE m_simu_airs
-
-  IMPLICIT NONE
-
-  include "YOMCST.h"
-
-  INTEGER, INTENT(IN) :: itap
-
-  REAL, DIMENSION(klon, klev), INTENT(IN) :: &
-          rneb_airs, temp_airs, cldemi_airs, iwcon0_airs, &
-          rad_airs, geop_airs, pplay_airs, paprs_airs
-
-  REAL, DIMENSION(klon, klev) :: &
-          rhodz_airs, rho_airs, iwcon_airs
-
-  REAL, DIMENSION(klon), INTENT(OUT) :: alt_tropo
-
-  REAL, DIMENSION(klev) :: rneb_1D, temp_1D, &
-          emis_1D, rad_1D, pres_1D, alt_1D, &
-          rhodz_1D, dz_1D, iwcon_1D
-
-  INTEGER :: i, j
-
-  REAL :: cc_tot_mesh, cc_hc_mesh, cc_hist_mesh
-  REAL :: cc_Cb_mesh, cc_ThCi_mesh, cc_Anv_mesh
-  REAL :: pcld_hc_mesh, tcld_hc_mesh, em_hc_mesh, iwp_hc_mesh
-  REAL :: em_hist_mesh, iwp_hist_mesh
-  REAL :: deltaz_hc_mesh, deltaz_hist_mesh, rad_hist_mesh
-  REAL :: pcld_Cb_mesh, tcld_Cb_mesh, em_Cb_mesh
-  REAL :: pcld_ThCi_mesh, tcld_ThCi_mesh, em_ThCi_mesh
-  REAL :: pcld_Anv_mesh, tcld_Anv_mesh, em_Anv_mesh
-
-  REAL, DIMENSION(klon), INTENT(OUT) :: map_prop_hc, map_prop_hist
-  REAL, DIMENSION(klon), INTENT(OUT) :: map_emis_hc, map_iwp_hc
-  REAL, DIMENSION(klon), INTENT(OUT) :: map_deltaz_hc, map_pcld_hc
-  REAL, DIMENSION(klon), INTENT(OUT) :: map_tcld_hc
-  REAL, DIMENSION(klon), INTENT(OUT) :: map_emis_Cb, map_pcld_Cb, map_tcld_Cb
-  REAL, DIMENSION(klon), INTENT(OUT) :: &
-          map_emis_ThCi, map_pcld_ThCi, map_tcld_ThCi
-  REAL, DIMENSION(klon), INTENT(OUT) :: &
-          map_emis_Anv, map_pcld_Anv, map_tcld_Anv
-  REAL, DIMENSION(klon), INTENT(OUT) :: &
-          map_emis_hist, map_iwp_hist, map_deltaz_hist, &
-          map_rad_hist
-  REAL, DIMENSION(klon), INTENT(OUT) :: map_ntot, map_hc, map_hist
-  REAL, DIMENSION(klon), INTENT(OUT) :: map_Cb, map_ThCi, map_Anv
-
-  WRITE(*, *) 'simu_airs'
-  WRITE(*, *) 'itap, klon, klev', itap, klon, klev
-  WRITE(*, *) 'RG, RD =', RG, RD
-
-
-  ! Definition des variables 1D
-
-  do i = 1, klon
-    do j = 1, klev - 1
-      rhodz_airs(i, j) = &
-              (paprs_airs(i, j) - paprs_airs(i, j + 1)) / RG
-    enddo
-    rhodz_airs(i, klev) = 0.
-  enddo
-
-  do i = 1, klon
-    do j = 1, klev
-      rho_airs(i, j) = &
-              pplay_airs(i, j) / (temp_airs(i, j) * RD)
-
-      IF (rneb_airs(i, j) > 0.001) THEN
-        iwcon_airs(i, j) = iwcon0_airs(i, j) / rneb_airs(i, j)
-      else
-        iwcon_airs(i, j) = 0.
-      endif
-
-    enddo
-  enddo
-
-  !=============================================================================
-
-  do i = 1, klon  ! boucle sur les points de grille
-
-    !=============================================================================
-
-    do j = 1, klev
-
-      rneb_1D(j) = rneb_airs(i, j)
-      temp_1D(j) = temp_airs(i, j)
-      emis_1D(j) = cldemi_airs(i, j)
-      iwcon_1D(j) = iwcon_airs(i, j)
-      rad_1D(j) = rad_airs(i, j)
-      pres_1D(j) = pplay_airs(i, j)
-      alt_1D(j) = geop_airs(i, j) / RG
-      rhodz_1D(j) = rhodz_airs(i, j)
-      dz_1D(j) = rhodz_airs(i, j) / rho_airs(i, j)
-
-    enddo
-
-    alt_tropo(i) = &
-            search_tropopause(pres_1D / 100., temp_1D, alt_1D, klev)
-
-
-    ! Appel du ss-programme sim_mesh
-
-    !        if (itap .EQ. 1 ) THEN
-    CALL sim_mesh(rneb_1D, temp_1D, emis_1D, iwcon_1D, rad_1D, &
-            pres_1D, dz_1D, rhodz_1D, &
-            cc_tot_mesh, cc_hc_mesh, cc_hist_mesh, &
-            pcld_hc_mesh, tcld_hc_mesh, em_hc_mesh, iwp_hc_mesh, &
-            deltaz_hc_mesh, &
-            cc_Cb_mesh, cc_ThCi_mesh, cc_Anv_mesh, &
-            pcld_Cb_mesh, tcld_Cb_mesh, em_Cb_mesh, &
-            pcld_ThCi_mesh, tcld_ThCi_mesh, em_ThCi_mesh, &
-            pcld_Anv_mesh, tcld_Anv_mesh, em_Anv_mesh, &
-            em_hist_mesh, iwp_hist_mesh, deltaz_hist_mesh, rad_hist_mesh)
-
-    WRITE(*, *) '===================================='
-    WRITE(*, *) 'itap, i:', itap, i
-    WRITE(*, *) 'cc_tot, cc_hc, cc_hist, pcld_hc, tcld_hc, em_hc, &
-            iwp_hc, em_hist, iwp_hist ='
-    WRITE(*, *) cc_tot_mesh, cc_hc_mesh, cc_hist_mesh
-    WRITE(*, *) pcld_hc_mesh, tcld_hc_mesh, em_hc_mesh, iwp_hc_mesh
-    WRITE(*, *)  em_hist_mesh, iwp_hist_mesh
-
-    !        endif
-
-    ! Definition des variables a ecrire dans le fichier de sortie
-
-    CALL normal2_undef(map_prop_hc(i), cc_hc_mesh, &
-            cc_tot_mesh)
-    CALL normal2_undef(map_prop_hist(i), cc_hist_mesh, &
-            cc_tot_mesh)
-
-    map_emis_hc(i) = em_hc_mesh
-    map_iwp_hc(i) = iwp_hc_mesh
-    map_deltaz_hc(i) = deltaz_hc_mesh
-    map_pcld_hc(i) = pcld_hc_mesh
-    map_tcld_hc(i) = tcld_hc_mesh
-
-    map_emis_Cb(i) = em_Cb_mesh
-    map_pcld_Cb(i) = pcld_Cb_mesh
-    map_tcld_Cb(i) = tcld_Cb_mesh
-
-    map_emis_ThCi(i) = em_ThCi_mesh
-    map_pcld_ThCi(i) = pcld_ThCi_mesh
-    map_tcld_ThCi(i) = tcld_ThCi_mesh
-
-    map_emis_Anv(i) = em_Anv_mesh
-    map_pcld_Anv(i) = pcld_Anv_mesh
-    map_tcld_Anv(i) = tcld_Anv_mesh
-
-    map_emis_hist(i) = em_hist_mesh
-    map_iwp_hist(i) = iwp_hist_mesh
-    map_deltaz_hist(i) = deltaz_hist_mesh
-    map_rad_hist(i) = rad_hist_mesh
-
-    map_ntot(i) = cc_tot_mesh
-    map_hc(i) = cc_hc_mesh
-    map_hist(i) = cc_hist_mesh
-
-    map_Cb(i) = cc_Cb_mesh
-    map_ThCi(i) = cc_ThCi_mesh
-    map_Anv(i) = cc_Anv_mesh
-
-  enddo         ! fin boucle sur les points de grille
-
-END SUBROUTINE  simu_airs
-
Index: /LMDZ6/branches/Amaury_dev/libf/phylmd/surf_landice_mod.F90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/phylmd/surf_landice_mod.F90	(revision 5127)
+++ /LMDZ6/branches/Amaury_dev/libf/phylmd/surf_landice_mod.F90	(revision 5128)
@@ -1,3 +1,4 @@
 MODULE surf_landice_mod
+
 
   IMPLICIT NONE
Index: /LMDZ6/branches/Amaury_dev/libf/phylmd/tsoilnudge.h
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/phylmd/tsoilnudge.h	(revision 5127)
+++ /LMDZ6/branches/Amaury_dev/libf/phylmd/tsoilnudge.h	(revision 5128)
@@ -4,4 +4,4 @@
 
       common /tsoilnudge/ nudge_tsoil, isoil_nudge, Tsoil_nudge,        &
-     &                   tau_soil_nudge
+                         tau_soil_nudge
 
Index: /LMDZ6/branches/Amaury_dev/libf/phylmd/write_histREGDYN.h
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/phylmd/write_histREGDYN.h	(revision 5127)
+++ /LMDZ6/branches/Amaury_dev/libf/phylmd/write_histREGDYN.h	(revision 5128)
@@ -2,59 +2,59 @@
 ! $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_regdyn) THEN
+IF (is_sequential) THEN
+ndex3d = 0
+itau_w = itau_phy + itap + start_time * day_step / iphysiq
+!
+ CALL histwrite(nid_regdyn,"hw1",itau_w,histoW(:,:,:,1), &
+       kmaxm1*lmaxm1*iwmax,ndex3d)
+!
+ CALL histwrite(nid_regdyn,"nh1",itau_w,nhistoW(:,:,:,1), &
+       kmaxm1*lmaxm1*iwmax,ndex3d)
+!
+ CALL histwrite(nid_regdyn,"nht1",itau_w,nhistoWt(:,:,:,1), &
+       kmaxm1*lmaxm1*iwmax,ndex3d)
+!
+ CALL histwrite(nid_regdyn,"hw2",itau_w,histoW(:,:,:,2), &
+       kmaxm1*lmaxm1*iwmax,ndex3d)
+!
+ CALL histwrite(nid_regdyn,"nh2",itau_w,nhistoW(:,:,:,2), &
+       kmaxm1*lmaxm1*iwmax,ndex3d)
+!
+ CALL histwrite(nid_regdyn,"nht2",itau_w,nhistoWt(:,:,:,2), &
+       kmaxm1*lmaxm1*iwmax,ndex3d)
+!
+ CALL histwrite(nid_regdyn,"hw3",itau_w,histoW(:,:,:,3), &
+       kmaxm1*lmaxm1*iwmax,ndex3d)
+!
+ CALL histwrite(nid_regdyn,"nh3",itau_w,nhistoW(:,:,:,3), &
+       kmaxm1*lmaxm1*iwmax,ndex3d)
+!
+ CALL histwrite(nid_regdyn,"nht3",itau_w,nhistoWt(:,:,:,3), &
+       kmaxm1*lmaxm1*iwmax,ndex3d)
+!
+ CALL histwrite(nid_regdyn,"hw4",itau_w,histoW(:,:,:,4), &
+       kmaxm1*lmaxm1*iwmax,ndex3d)
+!
+ CALL histwrite(nid_regdyn,"nh4",itau_w,nhistoW(:,:,:,4), &
+       kmaxm1*lmaxm1*iwmax,ndex3d)
+!
+ CALL histwrite(nid_regdyn,"nht4",itau_w,nhistoWt(:,:,:,4), &
+       kmaxm1*lmaxm1*iwmax,ndex3d)
+!
+ CALL histwrite(nid_regdyn,"hw5",itau_w,histoW(:,:,:,5), &
+       kmaxm1*lmaxm1*iwmax,ndex3d)
+!
+ CALL histwrite(nid_regdyn,"nh5",itau_w,nhistoW(:,:,:,5), &
+       kmaxm1*lmaxm1*iwmax,ndex3d)
+!
+ CALL histwrite(nid_regdyn,"nht5",itau_w,nhistoWt(:,:,:,5), &
+       kmaxm1*lmaxm1*iwmax,ndex3d)
 
-      IF (ok_sync) THEN
-        CALL histsync(nid_regdyn)
-      endif
+IF (ok_sync) THEN
+  CALL histsync(nid_regdyn)
+endif
 
-      endif ! is_sequential
+endif ! is_sequential
 
-      endif
+endif
Index: /LMDZ6/branches/Amaury_dev/libf/phylmdiso/physiq_mod.F90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/phylmdiso/physiq_mod.F90	(revision 5127)
+++ /LMDZ6/branches/Amaury_dev/libf/phylmdiso/physiq_mod.F90	(revision 5128)
@@ -417,4 +417,5 @@
        reffclwc, cldnvi, lcc3d, lcc3dcon, lcc3dstra, icc3dcon, icc3dstra
        USE output_physiqex_mod, ONLY: output_physiqex
+       USE lmdz_simu_airs, ONLY: simu_airs
 
 
@@ -679,5 +680,5 @@
 
     !      REAL,ALLOCATABLE,save :: run_off_lic_0(:)
-    !$OMP THREADPRIVATE(run_off_lic_0)
+    !!! !$OMP THREADPRIVATE(run_off_lic_0)
     !ym      SAVE run_off_lic_0
     !KE43
