Index: branches/2012/dev_INGV/NEMOGCM/ARCH/CNRS/arch-ifort_CICLAD.fcm
===================================================================
--- branches/2012/dev_INGV/NEMOGCM/ARCH/CNRS/arch-ifort_CICLAD.fcm	(revision 3575)
+++ branches/2012/dev_INGV/NEMOGCM/ARCH/CNRS/arch-ifort_CICLAD.fcm	(revision 3575)
@@ -0,0 +1,29 @@
+# generic ifort compiler options for linux
+# NCDF_INC    netcdf include file
+# NCDF_LIB    netcdf library
+# FC          Fortran compiler command
+# FCFLAGS     Fortran compiler flags
+# FFLAGS      Fortran 77 compiler flags
+# LD          linker
+# LDFLAGS     linker flags, e.g. -L<lib dir> if you have libraries in a
+# FPPFLAGS    pre-processing flags
+# AR          assembler
+# ARFLAGS     assembler flags
+# MK          make
+# USER_INC    additional include files for the compiler,  e.g. -I<include dir>
+# USER_LIB    additional libraries to pass to the linker, e.g. -l<library>
+
+
+%NCDF_INC            -I/opt/netcdf3/ifort/include 
+%NCDF_LIB            -L /opt/netcdf3/ifort/lib -lnetcdf   
+%FC                  /usr/lib64/openmpi/1.4.3-ifort/bin/mpif90 -c -cpp -DCPP_PARA -pg
+%FCFLAGS 	     -i4 -r8 -O3  -traceback 
+%FFLAGS 	     -i4 -r8 -O3  -traceback 
+%LD                  /usr/lib64/openmpi/1.4.3-ifort/bin/mpif90 
+%FPPFLAGS            -P -C -traditional
+%LDFLAGS
+%AR                  ar 
+%ARFLAGS             -r
+%MK                  gmake
+%USER_INC            %NCDF_INC
+%USER_LIB            %NCDF_LIB 
Index: branches/2012/dev_INGV/NEMOGCM/CONFIG/ORCA2_LIM_PISCES/EXP00/namelist_pisces
===================================================================
--- branches/2012/dev_INGV/NEMOGCM/CONFIG/ORCA2_LIM_PISCES/EXP00/namelist_pisces	(revision 3574)
+++ branches/2012/dev_INGV/NEMOGCM/CONFIG/ORCA2_LIM_PISCES/EXP00/namelist_pisces	(revision 3575)
@@ -16,5 +16,5 @@
 !,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
    ln_co2int  =  .false. ! read atm pco2 from a file (T) or constant (F)
-   atcco2     =  287.    ! Constant value atmospheric pCO2 - ln_co2int = F
+   atcco2     =  280.    ! Constant value atmospheric pCO2 - ln_co2int = F
    clname     =  'atcco2.txt'  ! Name of atm pCO2 file - ln_co2int = T
    nn_offset  =  0       ! Offset model-data start year - ln_co2int = T
@@ -35,7 +35,7 @@
 &nampisbio     !   biological parameters
 !,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
-   nrdttrc    =  1        ! time step frequency for biology
+   nrdttrc    =  4        ! time step frequency for biology
    wsbio      =  2.       ! POC sinking speed
-   xkmort     =  1.E-7    ! half saturation constant for mortality
+   xkmort     =  2.E-7    ! half saturation constant for mortality
    ferat3     =  10.E-6   ! Fe/C in zooplankton 
    wsbio2     =  30.      ! Big particles sinking speed
@@ -44,18 +44,18 @@
 &nampislim     !   parameters for nutrient limitations
 !,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
-   conc0      =  2.e-6    ! Phosphate half saturation
+   conc0      =  1.e-6    ! Phosphate half saturation
    conc1      =  8E-6     ! Phosphate half saturation for diatoms
-   conc2      =  2E-9     ! Iron half saturation for phyto
-   conc2m     =  4E-9     ! Max iron half saturation for phyto
+   conc2      =  1E-9     ! Iron half saturation for phyto
+   conc2m     =  3E-9     ! Max iron half saturation for phyto
    conc3      =  3E-9     ! Iron half saturation for diatoms
-   conc3m     =  9E-9     ! Maxi iron half saturation for diatoms
-   xsizedia   =  5.E-7    ! Minimum size criteria for diatoms
+   conc3m     =  8E-9     ! Maxi iron half saturation for diatoms
+   xsizedia   =  1.E-6    ! Minimum size criteria for diatoms
    xsizephy   =  1.E-6    ! Minimum size criteria for phyto
    concnnh4   =  1.E-7    ! NH4 half saturation for phyto
-   concdnh4   =  4.E-7    ! NH4 half saturation for diatoms
+   concdnh4   =  8.E-7    ! NH4 half saturation for diatoms
    xksi1      =  2.E-6    ! half saturation constant for Si uptake
    xksi2      =  3.33E-6  ! half saturation constant for Si/C
    xkdoc      =  417.E-6  ! half-saturation constant of DOC remineralization
-   concfebac  =  3.E-11   ! Half-saturation for Fe limitation of Bacteria
+   concfebac  =  1.E-11   ! Half-saturation for Fe limitation of Bacteria
    qnfelim    =  7.E-6    ! Optimal quota of phyto
    qdfelim    =  7.E-6    ! Optimal quota of diatoms
@@ -65,12 +65,12 @@
 &nampisprod     !   parameters for phytoplankton growth
 !,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
-   pislope    =  3.       ! P-I slope
+   pislope    =  2.       ! P-I slope
    pislope2   =  2.       ! P-I slope  for diatoms
    excret     =  0.05     ! excretion ratio of phytoplankton
    excret2    =  0.05     ! excretion ratio of diatoms
-   ln_newprod =  .false.  ! Enable new parame. of production (T/F) 
+   ln_newprod =  .true.  ! Enable new parame. of production (T/F) 
    bresp      =  0.00333  ! Basal respiration rate
    chlcnm     =  0.033    ! Minimum Chl/C in nanophytoplankton
-   chlcdm     =  0.04     ! Minimum Chl/C in diatoms
+   chlcdm     =  0.05     ! Minimum Chl/C in diatoms
    chlcmin    =  0.0033   ! Maximum Chl/c in phytoplankton
    fecnm      =  40E-6    ! Maximum Fe/C in nanophytoplankton
@@ -100,12 +100,12 @@
    xthresh2zoo = 1E-8     ! zoo feeding threshold for mesozooplankton 
    xthresh2dia = 1E-8     ! diatoms feeding threshold for mesozooplankton 
-   xthresh2phy = 2E-7     ! nanophyto feeding threshold for mesozooplankton 
+   xthresh2phy = 1E-8     ! nanophyto feeding threshold for mesozooplankton 
    xthresh2poc = 1E-8     ! poc feeding threshold for mesozooplankton 
-   xthresh2   =  0.       ! Food threshold for grazing
+   xthresh2   =  2E-7    ! Food threshold for grazing
    xkgraz2    =  20.E-6   ! half sturation constant for meso grazing
-   epsher2    =  0.33     ! Efficicency of Mesozoo growth
+   epsher2    =  0.3      ! Efficicency of Mesozoo growth
    sigma2     =  0.6      ! Fraction of mesozoo excretion as DOM
    unass2     =  0.3      ! non assimilated fraction of P by mesozoo
-   grazflux   =  3.e3     ! flux-feeding rate
+   grazflux   =  2.e3     ! flux-feeding rate
 /
 !'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
@@ -115,14 +115,14 @@
    grazrat    =  3.0      ! maximal zoo grazing rate
    resrat     =  0.03     ! exsudation rate of zooplankton
-   mzrat      =  0.0      ! zooplankton mortality rate
+   mzrat      =  0.001    ! zooplankton mortality rate
    xpref2c    =  0.1      ! Microzoo preference for POM
    xpref2p    =  1.       ! Microzoo preference for Nanophyto
-   xpref2d    =  0.6      ! Microzoo preference for Diatoms
+   xpref2d    =  0.5      ! Microzoo preference for Diatoms
    xthreshdia =  1.E-8    ! Diatoms feeding threshold for microzooplankton 
-   xthreshphy =  2.E-7    ! Nanophyto feeding threshold for microzooplankton 
+   xthreshphy =  1.E-8    ! Nanophyto feeding threshold for microzooplankton 
    xthreshpoc =  1.E-8    ! POC feeding threshold for microzooplankton 
-   xthresh    =  0.       ! Food threshold for feeding
+   xthresh    =  2.E-7    ! Food threshold for feeding
    xkgraz     =  20.E-6   ! half sturation constant for grazing
-   epsher     =  0.33     ! Efficiency of microzoo growth
+   epsher     =  0.3      ! Efficiency of microzoo growth
    sigma1     =  0.6      ! Fraction of microzoo excretion as DOM
    unass      =  0.3      ! non assimilated fraction of phyto by zoo
@@ -160,5 +160,5 @@
    cn_dir      = './'      !  root directory for the location of the dynamical files
    ln_dust     =  .true.   ! boolean for dust input from the atmosphere
-   ln_river    =  .true.   ! boolean for river input of nutrients
+   ln_river    =  .false.   ! boolean for river input of nutrients
    ln_ndepo    =  .true.   ! boolean for atmospheric deposition of N
    ln_ironsed  =  .true.   ! boolean for Fe input from sediments
Index: branches/2012/dev_INGV/NEMOGCM/CONFIG/ORCA2_OFF_PISCES/EXP00/namelist_pisces
===================================================================
--- branches/2012/dev_INGV/NEMOGCM/CONFIG/ORCA2_OFF_PISCES/EXP00/namelist_pisces	(revision 3574)
+++ branches/2012/dev_INGV/NEMOGCM/CONFIG/ORCA2_OFF_PISCES/EXP00/namelist_pisces	(revision 3575)
@@ -16,5 +16,5 @@
 !,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
    ln_co2int  =  .false. ! read atm pco2 from a file (T) or constant (F)
-   atcco2     =  287.    ! Constant value atmospheric pCO2 - ln_co2int = F
+   atcco2     =  280.    ! Constant value atmospheric pCO2 - ln_co2int = F
    clname     =  'atcco2.txt'  ! Name of atm pCO2 file - ln_co2int = T
    nn_offset  =  0       ! Offset model-data start year - ln_co2int = T
@@ -37,5 +37,5 @@
    nrdttrc    =  4        ! time step frequency for biology
    wsbio      =  2.       ! POC sinking speed
-   xkmort     =  1.E-7    ! half saturation constant for mortality
+   xkmort     =  2.E-7    ! half saturation constant for mortality
    ferat3     =  10.E-6   ! Fe/C in zooplankton 
    wsbio2     =  30.      ! Big particles sinking speed
@@ -44,18 +44,18 @@
 &nampislim     !   parameters for nutrient limitations
 !,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
-   conc0      =  2.e-6    ! Phosphate half saturation
+   conc0      =  1.e-6    ! Phosphate half saturation
    conc1      =  8E-6     ! Phosphate half saturation for diatoms
-   conc2      =  2E-9     ! Iron half saturation for phyto
-   conc2m     =  4E-9     ! Max iron half saturation for phyto
+   conc2      =  1E-9     ! Iron half saturation for phyto
+   conc2m     =  3E-9     ! Max iron half saturation for phyto
    conc3      =  3E-9     ! Iron half saturation for diatoms
-   conc3m     =  9E-9     ! Maxi iron half saturation for diatoms
-   xsizedia   =  5.E-7    ! Minimum size criteria for diatoms
+   conc3m     =  8E-9     ! Maxi iron half saturation for diatoms
+   xsizedia   =  1.E-6    ! Minimum size criteria for diatoms
    xsizephy   =  1.E-6    ! Minimum size criteria for phyto
    concnnh4   =  1.E-7    ! NH4 half saturation for phyto
-   concdnh4   =  4.E-7    ! NH4 half saturation for diatoms
+   concdnh4   =  8.E-7    ! NH4 half saturation for diatoms
    xksi1      =  2.E-6    ! half saturation constant for Si uptake
    xksi2      =  3.33E-6  ! half saturation constant for Si/C
    xkdoc      =  417.E-6  ! half-saturation constant of DOC remineralization
-   concfebac  =  3.E-11   ! Half-saturation for Fe limitation of Bacteria
+   concfebac  =  1.E-11   ! Half-saturation for Fe limitation of Bacteria
    qnfelim    =  7.E-6    ! Optimal quota of phyto
    qdfelim    =  7.E-6    ! Optimal quota of diatoms
@@ -65,12 +65,12 @@
 &nampisprod     !   parameters for phytoplankton growth
 !,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
-   pislope    =  3.       ! P-I slope
+   pislope    =  2.       ! P-I slope
    pislope2   =  2.       ! P-I slope  for diatoms
    excret     =  0.05     ! excretion ratio of phytoplankton
    excret2    =  0.05     ! excretion ratio of diatoms
-   ln_newprod =  .false.  ! Enable new parame. of production (T/F) 
+   ln_newprod =  .true.  ! Enable new parame. of production (T/F) 
    bresp      =  0.00333  ! Basal respiration rate
    chlcnm     =  0.033    ! Minimum Chl/C in nanophytoplankton
-   chlcdm     =  0.04     ! Minimum Chl/C in diatoms
+   chlcdm     =  0.05     ! Minimum Chl/C in diatoms
    chlcmin    =  0.0033   ! Maximum Chl/c in phytoplankton
    fecnm      =  40E-6    ! Maximum Fe/C in nanophytoplankton
@@ -100,12 +100,12 @@
    xthresh2zoo = 1E-8     ! zoo feeding threshold for mesozooplankton 
    xthresh2dia = 1E-8     ! diatoms feeding threshold for mesozooplankton 
-   xthresh2phy = 2E-7     ! nanophyto feeding threshold for mesozooplankton 
+   xthresh2phy = 1E-8     ! nanophyto feeding threshold for mesozooplankton 
    xthresh2poc = 1E-8     ! poc feeding threshold for mesozooplankton 
-   xthresh2   =  0.       ! Food threshold for grazing
+   xthresh2   =  2E-7    ! Food threshold for grazing
    xkgraz2    =  20.E-6   ! half sturation constant for meso grazing
-   epsher2    =  0.33     ! Efficicency of Mesozoo growth
+   epsher2    =  0.3      ! Efficicency of Mesozoo growth
    sigma2     =  0.6      ! Fraction of mesozoo excretion as DOM
    unass2     =  0.3      ! non assimilated fraction of P by mesozoo
-   grazflux   =  3.e3     ! flux-feeding rate
+   grazflux   =  2.e3     ! flux-feeding rate
 /
 !'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
@@ -115,14 +115,14 @@
    grazrat    =  3.0      ! maximal zoo grazing rate
    resrat     =  0.03     ! exsudation rate of zooplankton
-   mzrat      =  0.0      ! zooplankton mortality rate
+   mzrat      =  0.001    ! zooplankton mortality rate
    xpref2c    =  0.1      ! Microzoo preference for POM
    xpref2p    =  1.       ! Microzoo preference for Nanophyto
-   xpref2d    =  0.6      ! Microzoo preference for Diatoms
+   xpref2d    =  0.5      ! Microzoo preference for Diatoms
    xthreshdia =  1.E-8    ! Diatoms feeding threshold for microzooplankton 
-   xthreshphy =  2.E-7    ! Nanophyto feeding threshold for microzooplankton 
+   xthreshphy =  1.E-8    ! Nanophyto feeding threshold for microzooplankton 
    xthreshpoc =  1.E-8    ! POC feeding threshold for microzooplankton 
-   xthresh    =  0.       ! Food threshold for feeding
+   xthresh    =  2.E-7    ! Food threshold for feeding
    xkgraz     =  20.E-6   ! half sturation constant for grazing
-   epsher     =  0.33     ! Efficiency of microzoo growth
+   epsher     =  0.3      ! Efficiency of microzoo growth
    sigma1     =  0.6      ! Fraction of microzoo excretion as DOM
    unass      =  0.3      ! non assimilated fraction of phyto by zoo
@@ -160,5 +160,5 @@
    cn_dir      = './'      !  root directory for the location of the dynamical files
    ln_dust     =  .true.   ! boolean for dust input from the atmosphere
-   ln_river    =  .true.   ! boolean for river input of nutrients
+   ln_river    =  .false.   ! boolean for river input of nutrients
    ln_ndepo    =  .true.   ! boolean for atmospheric deposition of N
    ln_ironsed  =  .true.   ! boolean for Fe input from sediments
Index: branches/2012/dev_INGV/NEMOGCM/NEMO/OFF_SRC/domain.F90
===================================================================
--- branches/2012/dev_INGV/NEMOGCM/NEMO/OFF_SRC/domain.F90	(revision 3574)
+++ branches/2012/dev_INGV/NEMOGCM/NEMO/OFF_SRC/domain.F90	(revision 3575)
@@ -205,5 +205,4 @@
       rdtmax    = rn_rdtmin
       rdth      = rn_rdth
-      nclosea   = nn_closea
 
       REWIND( numnam )             ! Namelist cross land advection
Index: branches/2012/dev_INGV/NEMOGCM/NEMO/OPA_SRC/BDY/bdyini.F90
===================================================================
--- branches/2012/dev_INGV/NEMOGCM/NEMO/OPA_SRC/BDY/bdyini.F90	(revision 3574)
+++ branches/2012/dev_INGV/NEMOGCM/NEMO/OPA_SRC/BDY/bdyini.F90	(revision 3575)
@@ -773,5 +773,5 @@
             DO ib = 1, idx_bdy(ib_bdy)%nblenrim(igrd)
                nbi => idx_bdy(ib_bdy)%nbi(ib,igrd)
-               nbj => idx_bdy(ib_bdy)%nbi(ib,igrd)
+               nbj => idx_bdy(ib_bdy)%nbj(ib,igrd)
                flagu => idx_bdy(ib_bdy)%flagu(ib)
                bdysurftot = bdysurftot + hu     (nbi  , nbj)                           &
@@ -786,5 +786,5 @@
             DO ib = 1, idx_bdy(ib_bdy)%nblenrim(igrd)
                nbi => idx_bdy(ib_bdy)%nbi(ib,igrd)
-               nbj => idx_bdy(ib_bdy)%nbi(ib,igrd)
+               nbj => idx_bdy(ib_bdy)%nbj(ib,igrd)
                flagv => idx_bdy(ib_bdy)%flagv(ib)
                bdysurftot = bdysurftot + hv     (nbi, nbj  )                           &
Index: branches/2012/dev_INGV/NEMOGCM/NEMO/OPA_SRC/DIA/diadct.F90
===================================================================
--- branches/2012/dev_INGV/NEMOGCM/NEMO/OPA_SRC/DIA/diadct.F90	(revision 3574)
+++ branches/2012/dev_INGV/NEMOGCM/NEMO/OPA_SRC/DIA/diadct.F90	(revision 3575)
@@ -38,6 +38,9 @@
   USE dianam          ! build name of file
   USE lib_mpp         ! distributed memory computing library
-#if defined key_lim2 || defined key_lim3
-  USE ice
+#if defined key_lim2
+  USE ice_2
+#endif
+#if defined key_lim3
+  USE ice_3
 #endif
   USE domvvl
@@ -362,5 +365,5 @@
               WRITE(numout,*)"      List of points in global domain:"
               DO jpt=1,iptglo
-                 WRITE(numout,*)'        # I J ',jpt,coordtemp(jpt)
+                 WRITE(numout,*)'        # I J ',jpt,coordtemp(jpt),directemp(jpt)
               ENDDO                  
            ENDIF
@@ -403,9 +406,7 @@
 
               IF(jsec==nn_secdebug .AND. secs(jsec)%nb_point .NE. 0)THEN
-              WRITE(narea+200,*)'avant secs(jsec)%nb_point iptloc ',secs(jsec)%nb_point,iptloc
               DO jpt = 1,iptloc
                  iiglo = secs(jsec)%listPoint(jpt)%I + jpizoom - 1 + nimpp - 1
                  ijglo = secs(jsec)%listPoint(jpt)%J + jpjzoom - 1 + njmpp - 1
-                 WRITE(narea+200,*)'avant # I J : ',iiglo,ijglo
               ENDDO
               ENDIF
@@ -421,9 +422,7 @@
            ENDIF
            IF(jsec==nn_secdebug .AND. secs(jsec)%nb_point .NE. 0)THEN
-              WRITE(narea+200,*)'apres secs(jsec)%nb_point iptloc ',secs(jsec)%nb_point,iptloc
               DO jpt = 1,secs(jsec)%nb_point
                  iiglo = secs(jsec)%listPoint(jpt)%I + jpizoom - 1 + nimpp - 1
                  ijglo = secs(jsec)%listPoint(jpt)%J + jpjzoom - 1 + njmpp - 1
-                 WRITE(narea+200,*)'apres # I J : ',iiglo,ijglo
               ENDDO
            ENDIF
@@ -626,6 +625,7 @@
         ELSE                                ; isgnv =  1
         ENDIF
-
-        IF( ld_debug )write(numout,*)"isgnu isgnv ",isgnu,isgnv
+        IF( sec%slopeSection .GE. 9999. )     isgnv =  1
+
+        IF( ld_debug )write(numout,*)"sec%slopeSection isgnu isgnv ",sec%slopeSection,isgnu,isgnv
 
         !--------------------------------------!
Index: branches/2012/dev_INGV/NEMOGCM/NEMO/OPA_SRC/DOM/closea.F90
===================================================================
--- branches/2012/dev_INGV/NEMOGCM/NEMO/OPA_SRC/DOM/closea.F90	(revision 3574)
+++ branches/2012/dev_INGV/NEMOGCM/NEMO/OPA_SRC/DOM/closea.F90	(revision 3575)
@@ -7,4 +7,5 @@
    !!             8.5  !  02-06  (E. Durand, G. Madec)  F90
    !!             9.0  !  06-07  (G. Madec)  add clo_rnf, clo_ups, clo_bat
+   !!        NEMO 3.4  !  03-12  (P.G. Fogli) sbc_clo bug fix & mpp reproducibility
    !!----------------------------------------------------------------------
 
@@ -20,6 +21,8 @@
    USE in_out_manager  ! I/O manager
    USE sbc_oce         ! ocean surface boundary conditions
-   USE lib_mpp         ! distributed memory computing library
-   USE lbclnk          ! ???
+   USE lib_fortran,    ONLY: glob_sum, DDPDD
+   USE lbclnk          ! lateral boundary condition - MPP exchanges
+   USE lib_mpp         ! MPP library
+   USE timing
 
    IMPLICIT NONE
@@ -85,4 +88,12 @@
          SELECT CASE ( jp_cfg )
          !                                           ! =======================
+         CASE ( 1 )                                  ! ORCA_R1 configuration
+            !                                        ! =======================
+            ncsnr(1)   = 1    ; ncstt(1)   = 0           ! Caspian Sea
+            ncsi1(1)   = 332  ; ncsj1(1)   = 203
+            ncsi2(1)   = 344  ; ncsj2(1)   = 235
+            ncsir(1,1) = 1    ; ncsjr(1,1) = 1
+            !                                        
+            !                                        ! =======================
          CASE ( 2 )                                  !  ORCA_R2 configuration
             !                                        ! =======================
@@ -177,9 +188,12 @@
       INTEGER, INTENT(in) ::   kt   ! ocean model time step
       !
-      INTEGER                     ::   ji, jj, jc, jn   ! dummy loop indices
-      REAL(wp)                    ::   zze2
-      REAL(wp), DIMENSION (jpncs) ::   zfwf 
-      !!----------------------------------------------------------------------
-      !
+      INTEGER             ::   ji, jj, jc, jn   ! dummy loop indices
+      REAL(wp), PARAMETER ::   rsmall = 1.e-20_wp    ! Closed sea correction epsilon
+      REAL(wp)            ::   zze2, ztmp, zcorr     ! 
+      COMPLEX(wp)         ::   ctmp 
+      REAL(wp), DIMENSION(jpncs) ::   zfwf   ! 1D workspace
+      !!----------------------------------------------------------------------
+      !
+      IF( nn_timing == 1 )  CALL timing_start('sbc_clo')
       !                                                   !------------------!
       IF( kt == nit000 ) THEN                             !  Initialisation  !
@@ -189,16 +203,31 @@
          IF(lwp) WRITE(numout,*)'~~~~~~~'
 
-         ! Total surface of ocean
-         surf(jpncs+1) = SUM( e1t(:,:) * e2t(:,:) * tmask_i(:,:) )
-
-         DO jc = 1, jpncs
-            surf(jc) =0.e0
-            DO jj = ncsj1(jc), ncsj2(jc)
-               DO ji = ncsi1(jc), ncsi2(jc)
-                  surf(jc) = surf(jc) + e1t(ji,jj) * e2t(ji,jj) * tmask_i(ji,jj)      ! surface of closed seas
+         surf(:) = 0.e0_wp
+         !
+         surf(jpncs+1) = glob_sum( e1e2t(:,:) )   ! surface of the global ocean
+         !
+         !                                        ! surface of closed seas 
+         IF( lk_mpp_rep ) THEN                         ! MPP reproductible calculation
+            DO jc = 1, jpncs
+               ctmp = CMPLX( 0.e0, 0.e0, wp )
+               DO jj = ncsj1(jc), ncsj2(jc)
+                  DO ji = ncsi1(jc), ncsi2(jc)
+                     ztmp = e1e2t(ji,jj) * tmask_i(ji,jj)
+                     CALL DDPDD( CMPLX( ztmp, 0.e0, wp ), ctmp )
+                  END DO 
                END DO 
-            END DO 
-         END DO 
-         IF( lk_mpp )   CALL mpp_sum ( surf, jpncs+1 )       ! mpp: sum over all the global domain
+               IF( lk_mpp )   CALL mpp_sum( ctmp )
+               surf(jc) = REAL(ctmp,wp)
+            END DO
+         ELSE                                          ! Standard calculation           
+            DO jc = 1, jpncs
+               DO jj = ncsj1(jc), ncsj2(jc)
+                  DO ji = ncsi1(jc), ncsi2(jc)
+                     surf(jc) = surf(jc) + e1e2t(ji,jj) * tmask_i(ji,jj)      ! surface of closed seas
+                  END DO 
+               END DO 
+            END DO 
+            IF( lk_mpp )   CALL mpp_sum ( surf, jpncs )       ! mpp: sum over all the global domain
+         ENDIF
 
          IF(lwp) WRITE(numout,*)'     Closed sea surfaces'
@@ -215,74 +244,108 @@
       !                                                   !--------------------!
       !                                                   !  update emp, emps  !
-      zfwf = 0.e0                                         !--------------------!
-      DO jc = 1, jpncs
-         DO jj = ncsj1(jc), ncsj2(jc)
-            DO ji = ncsi1(jc), ncsi2(jc)
-               zfwf(jc) = zfwf(jc) + e1t(ji,jj) * e2t(ji,jj) * ( emp(ji,jj)-rnf(ji,jj) ) * tmask_i(ji,jj) 
-            END DO  
-         END DO 
-      END DO
-      IF( lk_mpp )   CALL mpp_sum ( zfwf(:) , jpncs )       ! mpp: sum over all the global domain
+      zfwf = 0.e0_wp                                      !--------------------!
+      IF( lk_mpp_rep ) THEN                         ! MPP reproductible calculation
+         DO jc = 1, jpncs
+            ctmp = CMPLX( 0.e0, 0.e0, wp )
+            DO jj = ncsj1(jc), ncsj2(jc)
+               DO ji = ncsi1(jc), ncsi2(jc)
+                  ztmp = e1e2t(ji,jj) * ( emp(ji,jj)-rnf(ji,jj) ) * tmask_i(ji,jj)
+                  CALL DDPDD( CMPLX( ztmp, 0.e0, wp ), ctmp )
+               END DO  
+            END DO 
+            IF( lk_mpp )   CALL mpp_sum( ctmp )
+            zfwf(jc) = REAL(ctmp,wp)
+         END DO
+      ELSE                                          ! Standard calculation           
+         DO jc = 1, jpncs
+            DO jj = ncsj1(jc), ncsj2(jc)
+               DO ji = ncsi1(jc), ncsi2(jc)
+                  zfwf(jc) = zfwf(jc) + e1e2t(ji,jj) * ( emp(ji,jj)-rnf(ji,jj) ) * tmask_i(ji,jj) 
+               END DO  
+            END DO 
+         END DO
+         IF( lk_mpp )   CALL mpp_sum ( zfwf(:) , jpncs )       ! mpp: sum over all the global domain
+      ENDIF
 
       IF( cp_cfg == "orca" .AND. jp_cfg == 2 ) THEN      ! Black Sea case for ORCA_R2 configuration
-         zze2    = ( zfwf(3) + zfwf(4) ) / 2.
+         zze2    = ( zfwf(3) + zfwf(4) ) * 0.5_wp
          zfwf(3) = zze2
          zfwf(4) = zze2
       ENDIF
 
+      zcorr = 0._wp
+
       DO jc = 1, jpncs
          !
-         IF( ncstt(jc) == 0 ) THEN 
-            ! water/evap excess is shared by all open ocean
-            emp (:,:) = emp (:,:) + zfwf(jc) / surf(jpncs+1)
-            emps(:,:) = emps(:,:) + zfwf(jc) / surf(jpncs+1)
-         ELSEIF( ncstt(jc) == 1 ) THEN 
-            ! Excess water in open sea, at outflow location, excess evap shared
-            IF ( zfwf(jc) <= 0.e0 ) THEN 
-                DO jn = 1, ncsnr(jc)
+         ! The following if avoids the redistribution of the round off
+         IF ( ABS(zfwf(jc) / surf(jpncs+1) ) > rsmall) THEN
+            !
+            IF( ncstt(jc) == 0 ) THEN           ! water/evap excess is shared by all open ocean
+               emp (:,:) = emp (:,:) + zfwf(jc) / surf(jpncs+1)
+               emps(:,:) = emps(:,:) + zfwf(jc) / surf(jpncs+1)
+               ! accumulate closed seas correction
+               zcorr     = zcorr     + zfwf(jc) / surf(jpncs+1)
+               !
+            ELSEIF( ncstt(jc) == 1 ) THEN       ! Excess water in open sea, at outflow location, excess evap shared
+               IF ( zfwf(jc) <= 0.e0_wp ) THEN 
+                   DO jn = 1, ncsnr(jc)
+                     ji = mi0(ncsir(jc,jn))
+                     jj = mj0(ncsjr(jc,jn)) ! Location of outflow in open ocean
+                     IF (      ji > 1 .AND. ji < jpi   &
+                         .AND. jj > 1 .AND. jj < jpj ) THEN 
+                         emp (ji,jj) = emp (ji,jj) + zfwf(jc) / ( REAL(ncsnr(jc)) * e1e2t(ji,jj) )
+                         emps(ji,jj) = emps(ji,jj) + zfwf(jc) / ( REAL(ncsnr(jc)) * e1e2t(ji,jj) )
+                     ENDIF 
+                   END DO 
+               ELSE 
+                   emp (:,:) = emp (:,:) + zfwf(jc) / surf(jpncs+1)
+                   emps(:,:) = emps(:,:) + zfwf(jc) / surf(jpncs+1)
+                   ! accumulate closed seas correction
+                   zcorr     = zcorr     + zfwf(jc) / surf(jpncs+1)
+               ENDIF
+            ELSEIF( ncstt(jc) == 2 ) THEN       ! Excess e-p-r (either sign) goes to open ocean, at outflow location
+               DO jn = 1, ncsnr(jc)
                   ji = mi0(ncsir(jc,jn))
                   jj = mj0(ncsjr(jc,jn)) ! Location of outflow in open ocean
-                  IF (      ji > 1 .AND. ji < jpi   &
-                      .AND. jj > 1 .AND. jj < jpj ) THEN 
-                      emp (ji,jj) = emp (ji,jj) + zfwf(jc) /   &
-                         (FLOAT(ncsnr(jc)) * e1t(ji,jj) * e2t(ji,jj))
-                      emps(ji,jj) = emps(ji,jj) + zfwf(jc) /   &
-                          (FLOAT(ncsnr(jc)) * e1t(ji,jj) * e2t(ji,jj))
-                  END IF 
-                END DO 
-            ELSE 
-                emp (:,:) = emp (:,:) + zfwf(jc) / surf(jpncs+1)
-                emps(:,:) = emps(:,:) + zfwf(jc) / surf(jpncs+1)
-            ENDIF
-         ELSEIF( ncstt(jc) == 2 ) THEN 
-            ! Excess e-p+r (either sign) goes to open ocean, at outflow location
-            IF(      ji > 1 .AND. ji < jpi    &
-               .AND. jj > 1 .AND. jj < jpj ) THEN 
-                DO jn = 1, ncsnr(jc)
-                  ji = mi0(ncsir(jc,jn))
-                  jj = mj0(ncsjr(jc,jn)) ! Location of outflow in open ocean
-                  emp (ji,jj) = emp (ji,jj) + zfwf(jc)   &
-                      / (FLOAT(ncsnr(jc)) *  e1t(ji,jj) * e2t(ji,jj) )
-                  emps(ji,jj) = emps(ji,jj) + zfwf(jc)   &
-                      / (FLOAT(ncsnr(jc)) *  e1t(ji,jj) * e2t(ji,jj) )
-                END DO 
+                  IF(      ji > 1 .AND. ji < jpi    &
+                     .AND. jj > 1 .AND. jj < jpj ) THEN 
+                     emp (ji,jj) = emp (ji,jj) + zfwf(jc) / ( REAL(ncsnr(jc)) *  e1e2t(ji,jj) )
+                     emps(ji,jj) = emps(ji,jj) + zfwf(jc) / ( REAL(ncsnr(jc)) *  e1e2t(ji,jj) )
+                  ENDIF 
+               END DO 
             ENDIF 
-         ENDIF 
-         !
-         DO jj = ncsj1(jc), ncsj2(jc)
-            DO ji = ncsi1(jc), ncsi2(jc)
-               emp (ji,jj) = emp (ji,jj) - zfwf(jc) / surf(jc)
-               emps(ji,jj) = emps(ji,jj) - zfwf(jc) / surf(jc)
-            END DO  
-         END DO 
-         !
+            !
+            DO jj = ncsj1(jc), ncsj2(jc)
+               DO ji = ncsi1(jc), ncsi2(jc)
+                  emp (ji,jj) = emp (ji,jj) - zfwf(jc) / surf(jc)
+                  emps(ji,jj) = emps(ji,jj) - zfwf(jc) / surf(jc)
+               END DO  
+            END DO 
+            !
+         END IF
       END DO 
-      !
-      CALL lbc_lnk( emp , 'T', 1. )
-      CALL lbc_lnk( emps, 'T', 1. )
+
+      IF ( ABS(zcorr) > rsmall ) THEN      ! remove the global correction from the closed seas
+         DO jc = 1, jpncs                  ! only if it is large enough
+            DO jj = ncsj1(jc), ncsj2(jc)
+               DO ji = ncsi1(jc), ncsi2(jc)
+                  emp (ji,jj) = emp (ji,jj) - zcorr
+                  emps(ji,jj) = emps(ji,jj) - zcorr
+               END DO  
+             END DO 
+          END DO
+      ENDIF
+      !
+      emp (:,:) = emp (:,:) * tmask(:,:,1)
+      emps(:,:) = emps(:,:) * tmask(:,:,1)
+      !
+      CALL lbc_lnk( emp , 'T', 1._wp )
+      CALL lbc_lnk( emps, 'T', 1._wp )
+      !
+      IF( nn_timing == 1 )  CALL timing_stop('sbc_clo')
       !
    END SUBROUTINE sbc_clo
-   
-   
+
+
    SUBROUTINE clo_rnf( p_rnfmsk )
       !!---------------------------------------------------------------------
@@ -308,5 +371,5 @@
                ii = mi0( ncsir(jc,jn) )
                ij = mj0( ncsjr(jc,jn) )
-               p_rnfmsk(ii,ij) = MAX( p_rnfmsk(ii,ij), 1.0 )
+               p_rnfmsk(ii,ij) = MAX( p_rnfmsk(ii,ij), 1.0_wp )
             END DO 
          ENDIF 
@@ -336,5 +399,5 @@
          DO jj = ncsj1(jc), ncsj2(jc)
             DO ji = ncsi1(jc), ncsi2(jc)
-               p_upsmsk(ji,jj) = 0.5            ! mixed upstream/centered scheme over closed seas
+               p_upsmsk(ji,jj) = 0.5_wp         ! mixed upstream/centered scheme over closed seas
             END DO 
          END DO 
@@ -374,2 +437,3 @@
    !!======================================================================
 END MODULE closea
+
Index: branches/2012/dev_INGV/NEMOGCM/NEMO/OPA_SRC/DOM/dom_oce.F90
===================================================================
--- branches/2012/dev_INGV/NEMOGCM/NEMO/OPA_SRC/DOM/dom_oce.F90	(revision 3574)
+++ branches/2012/dev_INGV/NEMOGCM/NEMO/OPA_SRC/DOM/dom_oce.F90	(revision 3575)
@@ -52,5 +52,4 @@
    REAL(wp), PUBLIC ::   rdtmax          !: maximum time step on tracers
    REAL(wp), PUBLIC ::   rdth            !: depth variation of tracer step
-   INTEGER , PUBLIC ::   nclosea         !: =0 suppress closed sea/lake from the ORCA domain or not (=1)
 
    !                                                  !!! associated variables
Index: branches/2012/dev_INGV/NEMOGCM/NEMO/OPA_SRC/DOM/domain.F90
===================================================================
--- branches/2012/dev_INGV/NEMOGCM/NEMO/OPA_SRC/DOM/domain.F90	(revision 3574)
+++ branches/2012/dev_INGV/NEMOGCM/NEMO/OPA_SRC/DOM/domain.F90	(revision 3575)
@@ -238,5 +238,4 @@
       rdtmax    = rn_rdtmin
       rdth      = rn_rdth
-      nclosea   = nn_closea
 
       REWIND( numnam )              ! Namelist cross land advection
Index: branches/2012/dev_INGV/NEMOGCM/NEMO/OPA_SRC/DOM/domzgr.F90
===================================================================
--- branches/2012/dev_INGV/NEMOGCM/NEMO/OPA_SRC/DOM/domzgr.F90	(revision 3574)
+++ branches/2012/dev_INGV/NEMOGCM/NEMO/OPA_SRC/DOM/domzgr.F90	(revision 3575)
@@ -422,7 +422,7 @@
             CALL iom_close( inum )
             mbathy(:,:) = INT( bathy(:,:) )
-            !                                                ! =====================
+            !
             IF( cp_cfg == "orca" .AND. jp_cfg == 2 ) THEN    ! ORCA R2 configuration
-               !                                             ! =====================
+               !
                IF( nn_cla == 0 ) THEN
                   ii0 = 140   ;   ii1 = 140                  ! Gibraltar Strait open 
@@ -454,7 +454,7 @@
             CALL iom_get  ( inum, jpdom_data, 'Bathymetry', bathy )
             CALL iom_close( inum )
-            !                                                ! =====================
+            !                                                
             IF( cp_cfg == "orca" .AND. jp_cfg == 2 ) THEN    ! ORCA R2 configuration
-               !                                             ! =====================
+               !
               IF( nn_cla == 0 ) THEN
                  ii0 = 140   ;   ii1 = 140                   ! Gibraltar Strait open 
@@ -489,20 +489,7 @@
       ENDIF
       !
-      !                                               ! =========================== !
-      IF( nclosea == 0 ) THEN                         !   NO closed seas or lakes   !
-         DO jl = 1, jpncs                             ! =========================== !
-            DO jj = ncsj1(jl), ncsj2(jl)
-               DO ji = ncsi1(jl), ncsi2(jl)
-                  mbathy(ji,jj) = 0                   ! suppress closed seas and lakes from bathymetry
-                  bathy (ji,jj) = 0._wp               
-               END DO
-            END DO
-         END DO
-      ENDIF
-      !
-      !                                               ! =========================== !
-      !                                               !     set a minimum depth     !
-      !                                               ! =========================== !
-      IF ( .not. ln_sco ) THEN
+      IF( nn_closea == 0 )   CALL clo_bat( bathy, mbathy )    !==  NO closed seas or lakes  ==!
+      !                       
+      IF ( .not. ln_sco ) THEN                                !==  set a minimum depth  ==!
          IF( rn_hmin < 0._wp ) THEN    ;   ik = - INT( rn_hmin )                                      ! from a nb of level
          ELSE                          ;   ik = MINLOC( gdepw_0, mask = gdepw_0 > rn_hmin, dim = 1 )  ! from a depth
Index: branches/2012/dev_INGV/NEMOGCM/NEMO/OPA_SRC/DYN/dynhpg.F90
===================================================================
--- branches/2012/dev_INGV/NEMOGCM/NEMO/OPA_SRC/DYN/dynhpg.F90	(revision 3574)
+++ branches/2012/dev_INGV/NEMOGCM/NEMO/OPA_SRC/DYN/dynhpg.F90	(revision 3575)
@@ -678,11 +678,10 @@
       REAL(wp) :: zrhdt1 
       REAL(wp) :: zdpdx1, zdpdx2, zdpdy1, zdpdy2
-      INTEGER  :: zbhitwe, zbhitns
-      REAL(wp), POINTER, DIMENSION(:,:,:) ::   zdeptht, zrhh 
+      REAL(wp), POINTER, DIMENSION(:,:,:) ::   zdept, zrhh 
       REAL(wp), POINTER, DIMENSION(:,:,:) ::   zhpi, zu, zv, fsp, xsp, asp, bsp, csp, dsp
       !!----------------------------------------------------------------------
       !
       CALL wrk_alloc( jpi,jpj,jpk, zhpi, zu, zv, fsp, xsp, asp, bsp, csp, dsp ) 
-      CALL wrk_alloc( jpi,jpj,jpk, zdeptht, zrhh ) 
+      CALL wrk_alloc( jpi,jpj,jpk, zdept, zrhh ) 
       !
       IF( kt == nit000 ) THEN
@@ -717,23 +716,15 @@
       END DO
 
-      ! Transfer the depth of "T(:,:,:)" to vertical coordinate "zdeptht(:,:,:)"
-      DO jj = 1, jpj
-        DO ji = 1, jpi
-          zdeptht(ji,jj,1) = 0.5_wp * fse3w(ji,jj,1)
-          zdeptht(ji,jj,1) = zdeptht(ji,jj,1) - sshn(ji,jj) * znad
-          DO jk = 2, jpk
-             zdeptht(ji,jj,jk) = zdeptht(ji,jj,jk-1) + fse3w(ji,jj,jk)
-          END DO
-        END DO
-      END DO
-
-      DO jk = 1, jpkm1
-        DO jj = 1, jpj
-          DO ji = 1, jpi
-            fsp(ji,jj,jk) = zrhh(ji,jj,jk)
-            xsp(ji,jj,jk) = zdeptht(ji,jj,jk)
-          END DO
-        END DO
-      END DO
+      ! Transfer the depth of "T(:,:,:)" to vertical coordinate "zdept(:,:,:)"
+      DO jj = 1, jpj;   DO ji = 1, jpi
+          zdept(ji,jj,1) = 0.5_wp * fse3w(ji,jj,1) - sshn(ji,jj) * znad
+      END DO        ;   END DO
+
+      DO jk = 2, jpk;   DO jj = 1, jpj;   DO ji = 1, jpi
+          zdept(ji,jj,jk) = zdept(ji,jj,jk-1) + fse3w(ji,jj,jk)
+      END DO        ;   END DO        ;   END DO
+
+      fsp(:,:,:) = zrhh(:,:,:)
+      xsp(:,:,:) = zdept(:,:,:)
 
       ! Construct the vertical density profile with the 
@@ -745,8 +736,7 @@
       DO jj = 2, jpj
         DO ji = 2, jpi 
-          zrhdt1 = zrhh(ji,jj,1) - interp3(zdeptht(ji,jj,1),asp(ji,jj,1), &
+          zrhdt1 = zrhh(ji,jj,1) - interp3(zdept(ji,jj,1),asp(ji,jj,1), &
                                          bsp(ji,jj,1),   csp(ji,jj,1), &
-                                         dsp(ji,jj,1) ) * 0.5_wp * zdeptht(ji,jj,1)
-          zrhdt1 = MAX(zrhdt1, 1000._wp - rau0)        ! no lighter than fresh water
+                                         dsp(ji,jj,1) ) * 0.25_wp * fse3w(ji,jj,1)
 
           ! assuming linear profile across the top half surface layer
@@ -760,5 +750,5 @@
           DO ji = 2, jpi
             zhpi(ji,jj,jk) = zhpi(ji,jj,jk-1) +                          &
-                             integ2(zdeptht(ji,jj,jk-1), zdeptht(ji,jj,jk),&
+                             integ_spline(zdept(ji,jj,jk-1), zdept(ji,jj,jk),&
                                     asp(ji,jj,jk-1),    bsp(ji,jj,jk-1), &
                                     csp(ji,jj,jk-1),    dsp(ji,jj,jk-1))
@@ -793,4 +783,16 @@
       END DO
 
+      DO jk = 1, jpkm1
+        DO jj = 2, jpjm1
+          DO ji = 2, jpim1
+            zu(ji,jj,jk) = min(zu(ji,jj,jk), max(-zdept(ji,jj,jk), -zdept(ji+1,jj,jk)))
+            zu(ji,jj,jk) = max(zu(ji,jj,jk), min(-zdept(ji,jj,jk), -zdept(ji+1,jj,jk)))
+            zv(ji,jj,jk) = min(zv(ji,jj,jk), max(-zdept(ji,jj,jk), -zdept(ji,jj+1,jk)))
+            zv(ji,jj,jk) = max(zv(ji,jj,jk), min(-zdept(ji,jj,jk), -zdept(ji,jj+1,jk)))
+          END DO
+        END DO
+      END DO
+
+
       DO jk = 1, jpkm1                                  
         DO jj = 2, jpjm1     
@@ -803,5 +805,5 @@
             !!!!!     for u equation
             IF( jk <= mbku(ji,jj) ) THEN
-               IF( -zdeptht(ji+1,jj,mbku(ji,jj)) >= -zdeptht(ji,jj,mbku(ji,jj)) ) THEN
+               IF( -zdept(ji+1,jj,jk) >= -zdept(ji,jj,jk) ) THEN
                  jis = ji + 1; jid = ji
                ELSE
@@ -811,13 +813,12 @@
                ! integrate the pressure on the shallow side
                jk1 = jk 
-               zbhitwe = 0
-               DO WHILE ( -zdeptht(jis,jj,jk1) > zuijk )
+               DO WHILE ( -zdept(jis,jj,jk1) > zuijk )
                  IF( jk1 == mbku(ji,jj) ) THEN
-                   zbhitwe = 1
+                   zuijk = -zdept(jis,jj,jk1)
                    EXIT
                  ENDIF
-                 zdeps = MIN(zdeptht(jis,jj,jk1+1), -zuijk)
+                 zdeps = MIN(zdept(jis,jj,jk1+1), -zuijk)
                  zpwes = zpwes +                                    & 
-                      integ2(zdeptht(jis,jj,jk1), zdeps,            &
+                      integ_spline(zdept(jis,jj,jk1), zdeps,            &
                              asp(jis,jj,jk1),    bsp(jis,jj,jk1), &
                              csp(jis,jj,jk1),    dsp(jis,jj,jk1))
@@ -825,19 +826,18 @@
                END DO
             
-               IF(zbhitwe == 1) THEN
-                 zuijk = -zdeptht(jis,jj,jk1)
-               ENDIF
-
                ! integrate the pressure on the deep side
                jk1 = jk 
-               zbhitwe = 0
-               DO WHILE ( -zdeptht(jid,jj,jk1) < zuijk )
+               DO WHILE ( -zdept(jid,jj,jk1) < zuijk )
                  IF( jk1 == 1 ) THEN
-                   zbhitwe = 1
+                   zdeps = zdept(jid,jj,1) + MIN(zuijk, sshn(jid,jj)*znad)
+                   zrhdt1 = zrhh(jid,jj,1) - interp3(zdept(jid,jj,1), asp(jid,jj,1), &
+                                                     bsp(jid,jj,1),   csp(jid,jj,1), &
+                                                     dsp(jid,jj,1)) * zdeps
+                   zpwed  = zpwed + 0.5_wp * (zrhh(jid,jj,1) + zrhdt1) * zdeps
                    EXIT
                  ENDIF
-                 zdeps = MAX(zdeptht(jid,jj,jk1-1), -zuijk)
+                 zdeps = MAX(zdept(jid,jj,jk1-1), -zuijk)
                  zpwed = zpwed +                                        & 
-                        integ2(zdeps,              zdeptht(jid,jj,jk1), &
+                        integ_spline(zdeps,              zdept(jid,jj,jk1), &
                                asp(jid,jj,jk1-1), bsp(jid,jj,jk1-1),  &
                                csp(jid,jj,jk1-1), dsp(jid,jj,jk1-1) )
@@ -845,13 +845,4 @@
                END DO
             
-               IF( zbhitwe == 1 ) THEN
-                 zdeps = zdeptht(jid,jj,1) + MIN(zuijk, sshn(jid,jj)*znad)
-                 zrhdt1 = zrhh(jid,jj,1) - interp3(zdeptht(jid,jj,1), asp(jid,jj,1), &
-                                                 bsp(jid,jj,1),    csp(jid,jj,1), &
-                                                 dsp(jid,jj,1)) * zdeps
-                 zrhdt1 = MAX(zrhdt1, 1000._wp - rau0)        ! no lighter than fresh water
-                 zpwed  = zpwed + 0.5_wp * (zrhh(jid,jj,1) + zrhdt1) * zdeps
-               ENDIF
-
                ! update the momentum trends in u direction
 
@@ -870,5 +861,5 @@
             !!!!!     for v equation
             IF( jk <= mbkv(ji,jj) ) THEN
-               IF( -zdeptht(ji,jj+1,mbkv(ji,jj)) >= -zdeptht(ji,jj,mbkv(ji,jj)) ) THEN
+               IF( -zdept(ji,jj+1,jk) >= -zdept(ji,jj,jk) ) THEN
                  jjs = jj + 1; jjd = jj
                ELSE
@@ -878,13 +869,12 @@
                ! integrate the pressure on the shallow side
                jk1 = jk 
-               zbhitns = 0
-               DO WHILE ( -zdeptht(ji,jjs,jk1) > zvijk )
+               DO WHILE ( -zdept(ji,jjs,jk1) > zvijk )
                  IF( jk1 == mbkv(ji,jj) ) THEN
-                   zbhitns = 1
+                   zvijk = -zdept(ji,jjs,jk1)
                    EXIT
                  ENDIF
-                 zdeps = MIN(zdeptht(ji,jjs,jk1+1), -zvijk)
+                 zdeps = MIN(zdept(ji,jjs,jk1+1), -zvijk)
                  zpnss = zpnss +                                      & 
-                        integ2(zdeptht(ji,jjs,jk1), zdeps,            &
+                        integ_spline(zdept(ji,jjs,jk1), zdeps,            &
                                asp(ji,jjs,jk1),    bsp(ji,jjs,jk1), &
                                csp(ji,jjs,jk1),    dsp(ji,jjs,jk1) )
@@ -892,19 +882,18 @@
                END DO
             
-               IF(zbhitns == 1) THEN
-                 zvijk = -zdeptht(ji,jjs,jk1)
-               ENDIF
-
                ! integrate the pressure on the deep side
                jk1 = jk 
-               zbhitns = 0
-               DO WHILE ( -zdeptht(ji,jjd,jk1) < zvijk )
+               DO WHILE ( -zdept(ji,jjd,jk1) < zvijk )
                  IF( jk1 == 1 ) THEN
-                   zbhitns = 1
+                   zdeps = zdept(ji,jjd,1) + MIN(zvijk, sshn(ji,jjd)*znad)
+                   zrhdt1 = zrhh(ji,jjd,1) - interp3(zdept(ji,jjd,1), asp(ji,jjd,1), &
+                                                     bsp(ji,jjd,1),   csp(ji,jjd,1), &
+                                                     dsp(ji,jjd,1) ) * zdeps
+                   zpnsd  = zpnsd + 0.5_wp * (zrhh(ji,jjd,1) + zrhdt1) * zdeps
                    EXIT
                  ENDIF
-                 zdeps = MAX(zdeptht(ji,jjd,jk1-1), -zvijk)
+                 zdeps = MAX(zdept(ji,jjd,jk1-1), -zvijk)
                  zpnsd = zpnsd +                                        & 
-                        integ2(zdeps,              zdeptht(ji,jjd,jk1), &
+                        integ_spline(zdeps,              zdept(ji,jjd,jk1), &
                                asp(ji,jjd,jk1-1), bsp(ji,jjd,jk1-1), &
                                csp(ji,jjd,jk1-1), dsp(ji,jjd,jk1-1) )
@@ -912,12 +901,4 @@
                END DO
             
-               IF( zbhitns == 1 ) THEN
-                 zdeps = zdeptht(ji,jjd,1) + MIN(zvijk, sshn(ji,jjd)*znad)
-                 zrhdt1 = zrhh(ji,jjd,1) - interp3(zdeptht(ji,jjd,1), asp(ji,jjd,1), &
-                                                 bsp(ji,jjd,1),    csp(ji,jjd,1), &
-                                                 dsp(ji,jjd,1) ) * zdeps
-                 zrhdt1 = MAX(zrhdt1, 1000._wp - rau0)        ! no lighter than fresh water
-                 zpnsd  = zpnsd + 0.5_wp * (zrhh(ji,jjd,1) + zrhdt1) * zdeps
-               ENDIF
 
                ! update the momentum trends in v direction
@@ -941,5 +922,5 @@
       !
       CALL wrk_dealloc( jpi,jpj,jpk, zhpi, zu, zv, fsp, xsp, asp, bsp, csp, dsp ) 
-      CALL wrk_dealloc( jpi,jpj,jpk, zdeptht, zrhh ) 
+      CALL wrk_dealloc( jpi,jpj,jpk, zdept, zrhh ) 
       !
    END SUBROUTINE hpg_prj
@@ -1121,5 +1102,5 @@
 
    
-   FUNCTION integ2(xl, xr, a, b, c, d)  RESULT(f) 
+   FUNCTION integ_spline(xl, xr, a, b, c, d)  RESULT(f) 
       !!----------------------------------------------------------------------
       !!                 ***  ROUTINE interp1  ***
@@ -1143,7 +1124,8 @@
          & xl * ( a + xl * ( za1 + xl * ( za2 + za3 * xl ) ) )
 
-   END FUNCTION integ2
+   END FUNCTION integ_spline
 
 
    !!======================================================================
 END MODULE dynhpg
+
Index: branches/2012/dev_INGV/NEMOGCM/NEMO/OPA_SRC/LBC/lib_mpp.F90
===================================================================
--- branches/2012/dev_INGV/NEMOGCM/NEMO/OPA_SRC/LBC/lib_mpp.F90	(revision 3574)
+++ branches/2012/dev_INGV/NEMOGCM/NEMO/OPA_SRC/LBC/lib_mpp.F90	(revision 3575)
@@ -80,10 +80,6 @@
    END INTERFACE
    INTERFACE mpp_sum
-# if defined key_mpp_rep
       MODULE PROCEDURE mppsum_a_int, mppsum_int, mppsum_a_real, mppsum_real, &
                        mppsum_realdd, mppsum_a_realdd
-# else
-      MODULE PROCEDURE mppsum_a_int, mppsum_int, mppsum_a_real, mppsum_real
-# endif
    END INTERFACE
    INTERFACE mpp_lbc_north
@@ -114,10 +110,9 @@
 !$AGRIF_END_DO_NOT_TREAT
 
-# if defined key_mpp_rep
    INTEGER :: MPI_SUMDD
-# endif
 
    ! variables used in case of sea-ice
-   INTEGER, PUBLIC ::   ncomm_ice       !: communicator made by the processors with sea-ice
+   INTEGER, PUBLIC ::   ncomm_ice       !: communicator made by the processors with sea-ice (public so that it can be freed in limthd)
+   INTEGER ::   ngrp_iworld     !  group ID for the world processors (for rheology)
    INTEGER ::   ngrp_ice        !  group ID for the ice processors (for rheology)
    INTEGER ::   ndim_rank_ice   !  number of 'ice' processors
@@ -355,7 +350,5 @@
       mynode = mpprank
       ! 
-#if defined key_mpp_rep
       CALL MPI_OP_CREATE(DDPDD_MPI, .TRUE., MPI_SUMDD, ierr)
-#endif
       !
    END FUNCTION mynode
@@ -1506,5 +1499,4 @@
    END SUBROUTINE mppsum_real
 
-# if defined key_mpp_rep
    SUBROUTINE mppsum_realdd( ytab, kcom )
       !!----------------------------------------------------------------------
@@ -1559,5 +1551,4 @@
 
    END SUBROUTINE mppsum_a_realdd
-# endif   
    
    SUBROUTINE mpp_minloc2d( ptab, pmask, pmin, ki,kj )
@@ -1977,5 +1968,5 @@
       !!      ndim_rank_ice = number of processors with ice
       !!      nrank_ice (ndim_rank_ice) = ice processors
-      !!      ngrp_world = group ID for the world processors
+      !!      ngrp_iworld = group ID for the world processors
       !!      ngrp_ice = group ID for the ice processors
       !!      ncomm_ice = communicator for the ice procs.
@@ -2026,8 +2017,8 @@
 
       ! Create the world group
-      CALL MPI_COMM_GROUP( mpi_comm_opa, ngrp_world, ierr )
+      CALL MPI_COMM_GROUP( mpi_comm_opa, ngrp_iworld, ierr )
 
       ! Create the ice group from the world group
-      CALL MPI_GROUP_INCL( ngrp_world, ndim_rank_ice, nrank_ice, ngrp_ice, ierr )
+      CALL MPI_GROUP_INCL( ngrp_iworld, ndim_rank_ice, nrank_ice, ngrp_ice, ierr )
 
       ! Create the ice communicator , ie the pool of procs with sea-ice
@@ -2036,6 +2027,9 @@
       ! Find proc number in the world of proc 0 in the north
       ! The following line seems to be useless, we just comment & keep it as reminder
-      ! CALL MPI_GROUP_TRANSLATE_RANKS(ngrp_ice,1,0,ngrp_world,n_ice_root,ierr)
-      !
+      ! CALL MPI_GROUP_TRANSLATE_RANKS(ngrp_ice,1,0,ngrp_iworld,n_ice_root,ierr)
+      !
+      CALL MPI_GROUP_FREE(ngrp_ice, ierr)
+      CALL MPI_GROUP_FREE(ngrp_iworld, ierr)
+
       DEALLOCATE(kice, zwork)
       !
@@ -2599,5 +2593,4 @@
    END SUBROUTINE mpi_init_opa
 
-#if defined key_mpp_rep
    SUBROUTINE DDPDD_MPI (ydda, yddb, ilen, itype)
       !!---------------------------------------------------------------------
@@ -2628,5 +2621,4 @@
 
    END SUBROUTINE DDPDD_MPI
-#endif
 
 #else
Index: branches/2012/dev_INGV/NEMOGCM/NEMO/OPA_SRC/SBC/sbccpl.F90
===================================================================
--- branches/2012/dev_INGV/NEMOGCM/NEMO/OPA_SRC/SBC/sbccpl.F90	(revision 3574)
+++ branches/2012/dev_INGV/NEMOGCM/NEMO/OPA_SRC/SBC/sbccpl.F90	(revision 3575)
@@ -721,5 +721,4 @@
                !                                                       ! (geographical to local grid -> rotate the components)
                CALL rot_rep( frcv(jpr_otx1)%z3(:,:,1), frcv(jpr_oty1)%z3(:,:,1), srcv(jpr_otx1)%clgrid, 'en->i', ztx )   
-               frcv(jpr_otx1)%z3(:,:,1) = ztx(:,:)      ! overwrite 1st component on the 1st grid
                IF( srcv(jpr_otx2)%laction ) THEN
                   CALL rot_rep( frcv(jpr_otx2)%z3(:,:,1), frcv(jpr_oty2)%z3(:,:,1), srcv(jpr_otx2)%clgrid, 'en->j', zty )   
@@ -727,4 +726,5 @@
                   CALL rot_rep( frcv(jpr_otx1)%z3(:,:,1), frcv(jpr_oty1)%z3(:,:,1), srcv(jpr_otx1)%clgrid, 'en->j', zty )  
                ENDIF
+               frcv(jpr_otx1)%z3(:,:,1) = ztx(:,:)      ! overwrite 1st component on the 1st grid
                frcv(jpr_oty1)%z3(:,:,1) = zty(:,:)      ! overwrite 2nd component on the 2nd grid
             ENDIF
@@ -949,5 +949,4 @@
                !                                                       ! (geographical to local grid -> rotate the components)
                CALL rot_rep( frcv(jpr_itx1)%z3(:,:,1), frcv(jpr_ity1)%z3(:,:,1), srcv(jpr_itx1)%clgrid, 'en->i', ztx )   
-               frcv(jpr_itx1)%z3(:,:,1) = ztx(:,:)      ! overwrite 1st component on the 1st grid
                IF( srcv(jpr_itx2)%laction ) THEN
                   CALL rot_rep( frcv(jpr_itx2)%z3(:,:,1), frcv(jpr_ity2)%z3(:,:,1), srcv(jpr_itx2)%clgrid, 'en->j', zty )   
@@ -955,4 +954,5 @@
                   CALL rot_rep( frcv(jpr_itx1)%z3(:,:,1), frcv(jpr_ity1)%z3(:,:,1), srcv(jpr_itx1)%clgrid, 'en->j', zty )  
                ENDIF
+               frcv(jpr_itx1)%z3(:,:,1) = ztx(:,:)      ! overwrite 1st component on the 1st grid
                frcv(jpr_ity1)%z3(:,:,1) = zty(:,:)      ! overwrite 2nd component on the 1st grid
             ENDIF
Index: branches/2012/dev_INGV/NEMOGCM/NEMO/OPA_SRC/SBC/sbcmod.F90
===================================================================
--- branches/2012/dev_INGV/NEMOGCM/NEMO/OPA_SRC/SBC/sbcmod.F90	(revision 3574)
+++ branches/2012/dev_INGV/NEMOGCM/NEMO/OPA_SRC/SBC/sbcmod.F90	(revision 3575)
@@ -284,23 +284,20 @@
       !                                            !==  Misc. Options  ==!
       
-      SELECT CASE( nn_ice )                                     ! Update heat and freshwater fluxes over sea-ice areas
-      CASE(  1 )   ;       CALL sbc_ice_if   ( kt )                  ! Ice-cover climatology ("Ice-if" model)
-         !                                                      
-      CASE(  2 )   ;       CALL sbc_ice_lim_2( kt, nsbc )            ! LIM-2 ice model
-         IF( lk_bdy )      CALL bdy_ice_lim_2( kt )                  ! BDY boundary condition
-         !                                                     
-      CASE(  3 )   ;       CALL sbc_ice_lim  ( kt, nsbc )            ! LIM-3 ice model
-         !
-      CASE(  4 )   ;       CALL sbc_ice_cice ( kt, nsbc )            ! CICE ice model
+      SELECT CASE( nn_ice )                                       ! Update heat and freshwater fluxes over sea-ice areas
+      CASE(  1 )   ;         CALL sbc_ice_if   ( kt )                ! Ice-cover climatology ("Ice-if" model)
+      CASE(  2 )   ;         CALL sbc_ice_lim_2( kt, nsbc )          ! LIM-2 ice model
+              IF( lk_bdy )   CALL bdy_ice_lim_2( kt )                ! BDY boundary condition
+      CASE(  3 )   ;         CALL sbc_ice_lim  ( kt, nsbc )          ! LIM-3 ice model
+      CASE(  4 )   ;         CALL sbc_ice_cice ( kt, nsbc )          ! CICE ice model
       END SELECT                                              
 
-      IF( ln_rnf       )   CALL sbc_rnf( kt )                   ! add runoffs to fresh water fluxes
+      IF( ln_rnf         )   CALL sbc_rnf( kt )                   ! add runoffs to fresh water fluxes
  
-      IF( ln_ssr       )   CALL sbc_ssr( kt )                   ! add SST/SSS damping term
-
-      IF( nn_fwb  /= 0 )   CALL sbc_fwb( kt, nn_fwb, nn_fsbc )  ! control the freshwater budget
-
-      IF( nclosea == 1 )   CALL sbc_clo( kt )                   ! treatment of closed sea in the model domain 
-      !                                                         ! (update freshwater fluxes)
+      IF( ln_ssr         )   CALL sbc_ssr( kt )                   ! add SST/SSS damping term
+
+      IF( nn_fwb    /= 0 )   CALL sbc_fwb( kt, nn_fwb, nn_fsbc )  ! control the freshwater budget
+
+      IF( nn_closea == 1 )   CALL sbc_clo( kt )                   ! treatment of closed sea in the model domain 
+      !                                                           ! (update freshwater fluxes)
 !RBbug do not understand why see ticket 667
       CALL lbc_lnk( emp, 'T', 1. )
Index: branches/2012/dev_INGV/NEMOGCM/NEMO/OPA_SRC/SBC/sbcrnf.F90
===================================================================
--- branches/2012/dev_INGV/NEMOGCM/NEMO/OPA_SRC/SBC/sbcrnf.F90	(revision 3574)
+++ branches/2012/dev_INGV/NEMOGCM/NEMO/OPA_SRC/SBC/sbcrnf.F90	(revision 3575)
@@ -457,7 +457,7 @@
       CALL iom_close( inum )                                      ! close file
       
-      IF( nclosea == 1 )    CALL clo_rnf( rnfmsk )                ! closed sea inflow set as ruver mouth
-
-      rnfmsk_z(:)   = 0._wp                                        ! vertical structure 
+      IF( nn_closea == 1 )   CALL clo_rnf( rnfmsk )               ! closed sea inflow set as ruver mouth
+
+      rnfmsk_z(:)   = 0._wp                                       ! vertical structure 
       rnfmsk_z(1)   = 1.0
       rnfmsk_z(2)   = 1.0                                         ! **********
Index: branches/2012/dev_INGV/NEMOGCM/NEMO/OPA_SRC/TRD/trdtra.F90
===================================================================
--- branches/2012/dev_INGV/NEMOGCM/NEMO/OPA_SRC/TRD/trdtra.F90	(revision 3574)
+++ branches/2012/dev_INGV/NEMOGCM/NEMO/OPA_SRC/TRD/trdtra.F90	(revision 3575)
@@ -8,5 +8,5 @@
    !!            3.3  !  2010-06  (C. Ethe) merge TRA-TRC 
    !!----------------------------------------------------------------------
-#if  defined key_trdtra || defined key_trdmld || defined key_trdmld_trc 
+#if  defined key_trdtra || defined key_trdtrc || defined key_trdmld || defined key_trdmld_trc 
    !!----------------------------------------------------------------------
    !!   trd_tra      : Call the trend to be computed
Index: branches/2012/dev_INGV/NEMOGCM/NEMO/OPA_SRC/ZDF/zdftke.F90
===================================================================
--- branches/2012/dev_INGV/NEMOGCM/NEMO/OPA_SRC/ZDF/zdftke.F90	(revision 3574)
+++ branches/2012/dev_INGV/NEMOGCM/NEMO/OPA_SRC/ZDF/zdftke.F90	(revision 3575)
@@ -87,4 +87,6 @@
    REAL(wp)        , ALLOCATABLE, SAVE, DIMENSION(:,:)   ::   htau           ! depth of tke penetration (nn_htau)
    REAL(wp)        , ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   dissl          ! now mixing lenght of dissipation
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   avt_k , avm_k  ! not enhanced Kz
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   avmu_k, avmv_k ! not enhanced Kz
 #if defined key_c1d
    !                                                                        !!** 1D cfg only  **   ('key_c1d')
@@ -112,5 +114,7 @@
          &      e_pdl(jpi,jpj,jpk) , e_ric(jpi,jpj,jpk) ,                          &
 #endif
-         &      en   (jpi,jpj,jpk) , htau (jpi,jpj)     , dissl(jpi,jpj,jpk) , STAT= zdf_tke_alloc )
+         &      en    (jpi,jpj,jpk) , htau  (jpi,jpj)    , dissl(jpi,jpj,jpk) ,     & 
+         &      avt_k (jpi,jpj,jpk) , avm_k (jpi,jpj,jpk),                          &
+         &      avmu_k(jpi,jpj,jpk) , avmv_k(jpi,jpj,jpk), STAT= zdf_tke_alloc      )
          !
       IF( lk_mpp             )   CALL mpp_sum ( zdf_tke_alloc )
@@ -168,7 +172,19 @@
       !!----------------------------------------------------------------------
       !
+      IF( kt /= nit000 ) THEN   ! restore before value to compute tke
+         avt (:,:,:) = avt_k (:,:,:) 
+         avm (:,:,:) = avm_k (:,:,:) 
+         avmu(:,:,:) = avmu_k(:,:,:) 
+         avmv(:,:,:) = avmv_k(:,:,:) 
+      ENDIF 
+      !
       CALL tke_tke      ! now tke (en)
       !
       CALL tke_avn      ! now avt, avm, avmu, avmv
+      !
+      avt_k (:,:,:) = avt (:,:,:) 
+      avm_k (:,:,:) = avm (:,:,:) 
+      avmu_k(:,:,:) = avmu(:,:,:) 
+      avmv_k(:,:,:) = avmv(:,:,:) 
       !
    END SUBROUTINE zdf_tke
@@ -811,10 +827,10 @@
         !                                   ! -------------------
         IF(lwp) WRITE(numout,*) '---- tke-rst ----'
-        CALL iom_rstput( kt, nitrst, numrow, 'en'   , en    )
-        CALL iom_rstput( kt, nitrst, numrow, 'avt'  , avt   )
-        CALL iom_rstput( kt, nitrst, numrow, 'avm'  , avm   )
-        CALL iom_rstput( kt, nitrst, numrow, 'avmu' , avmu  )
-        CALL iom_rstput( kt, nitrst, numrow, 'avmv' , avmv  )
-        CALL iom_rstput( kt, nitrst, numrow, 'dissl', dissl )
+        CALL iom_rstput( kt, nitrst, numrow, 'en'   , en     )
+        CALL iom_rstput( kt, nitrst, numrow, 'avt'  , avt_k  )
+        CALL iom_rstput( kt, nitrst, numrow, 'avm'  , avm_k  )
+        CALL iom_rstput( kt, nitrst, numrow, 'avmu' , avmu_k )
+        CALL iom_rstput( kt, nitrst, numrow, 'avmv' , avmv_k )
+        CALL iom_rstput( kt, nitrst, numrow, 'dissl', dissl  )
         !
      ENDIF
Index: branches/2012/dev_INGV/NEMOGCM/NEMO/OPA_SRC/lib_fortran.F90
===================================================================
--- branches/2012/dev_INGV/NEMOGCM/NEMO/OPA_SRC/lib_fortran.F90	(revision 3574)
+++ branches/2012/dev_INGV/NEMOGCM/NEMO/OPA_SRC/lib_fortran.F90	(revision 3575)
@@ -14,13 +14,14 @@
    !!                 of intrinsinc sign function
    !!----------------------------------------------------------------------
-   USE par_oce          ! Ocean parameter
-   USE lib_mpp          ! distributed memory computing
-   USE dom_oce          ! ocean domain
-   USE in_out_manager   ! I/O manager
+   USE par_oce         ! Ocean parameter
+   USE dom_oce         ! ocean domain
+   USE in_out_manager  ! I/O manager
+   USE lib_mpp         ! distributed memory computing
 
    IMPLICIT NONE
    PRIVATE
 
-   PUBLIC glob_sum
+   PUBLIC   glob_sum   ! used in many places
+   PUBLIC   DDPDD      ! also used in closea module
 #if defined key_nosignedzero
    PUBLIC SIGN
@@ -47,4 +48,5 @@
 
 #if ! defined key_mpp_rep
+
    FUNCTION glob_sum_2d( ptab ) 
       !!-----------------------------------------------------------------------
@@ -246,4 +248,5 @@
    END FUNCTION glob_sum_3d_a   
 
+#endif
 
    SUBROUTINE DDPDD( ydda, yddb )
@@ -280,5 +283,4 @@
       !
    END SUBROUTINE DDPDD
-#endif
 
 #if defined key_nosignedzero
Index: branches/2012/dev_INGV/NEMOGCM/NEMO/TOP_SRC/PISCES/p4zsink.F90
===================================================================
--- branches/2012/dev_INGV/NEMOGCM/NEMO/TOP_SRC/PISCES/p4zsink.F90	(revision 3574)
+++ branches/2012/dev_INGV/NEMOGCM/NEMO/TOP_SRC/PISCES/p4zsink.F90	(revision 3575)
@@ -295,5 +295,5 @@
       ENDIF
       !
-      CALL wrk_alloc( jpi, jpj, jpk, znum3d )
+      CALL wrk_dealloc( jpi, jpj, jpk, znum3d )
       !
       IF( nn_timing == 1 )  CALL timing_stop('p4z_sink')
Index: branches/2012/dev_INGV/NEMOGCM/NEMO/TOP_SRC/TRP/trczdf.F90
===================================================================
--- branches/2012/dev_INGV/NEMOGCM/NEMO/TOP_SRC/TRP/trczdf.F90	(revision 3574)
+++ branches/2012/dev_INGV/NEMOGCM/NEMO/TOP_SRC/TRP/trczdf.F90	(revision 3575)
@@ -101,5 +101,5 @@
       END SELECT
 
-      IF( l_trdtra )   THEN                      ! save the vertical diffusive trends for further diagnostics
+      IF( l_trdtrc )   THEN                      ! save the vertical diffusive trends for further diagnostics
          DO jn = 1, jptra
             DO jk = 1, jpkm1
Index: branches/2012/dev_INGV/NEMOGCM/NEMO/TOP_SRC/TRP/trdmod_trc.F90
===================================================================
--- branches/2012/dev_INGV/NEMOGCM/NEMO/TOP_SRC/TRP/trdmod_trc.F90	(revision 3574)
+++ branches/2012/dev_INGV/NEMOGCM/NEMO/TOP_SRC/TRP/trdmod_trc.F90	(revision 3575)
@@ -59,4 +59,5 @@
       ! Mixed layer trends for passive tracers
       !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+#if defined key_trdmld_trc  
       IF( lk_trdmld_trc .AND. ln_trdtrc( kjn ) ) THEN
          !
@@ -82,17 +83,23 @@
          !
       END IF
+#endif
 
       IF( lk_trdtrc .AND. ln_trdtrc( kjn ) ) THEN
          !
          SELECT CASE( ktrd )
-         CASE( jptra_trd_xad )       ;    WRITE (cltra,'("XAD_",16a)')   ctrcnm(kjn)
-         CASE( jptra_trd_yad )       ;    WRITE (cltra,'("YAD_",16a)')   ctrcnm(kjn)
-         CASE( jptra_trd_zad )       ;    WRITE (cltra,'("ZAD_",16a)')   ctrcnm(kjn)
-         CASE( jptra_trd_ldf )       ;    WRITE (cltra,'("LDF_",16a)')   ctrcnm(kjn)
-         CASE( jptra_trd_bbl )       ;    WRITE (cltra,'("BBL_",16a)')   ctrcnm(kjn)
-         CASE( jptra_trd_zdf )       ;    WRITE (cltra,'("ZDF_",16a)')   ctrcnm(kjn)
-         CASE( jptra_trd_dmp )       ;    WRITE (cltra,'("DMP_",16a)')   ctrcnm(kjn)
-         CASE( jptra_trd_nsr )       ;    WRITE (cltra,'("FOR_",16a)')   ctrcnm(kjn)
+         CASE( jptra_trd_xad  )       ;    WRITE (cltra,'("XAD_",4a)')
+         CASE( jptra_trd_yad  )       ;    WRITE (cltra,'("YAD_",4a)')
+         CASE( jptra_trd_zad  )       ;    WRITE (cltra,'("ZAD_",4a)')
+         CASE( jptra_trd_ldf  )       ;    WRITE (cltra,'("LDF_",4a)')
+         CASE( jptra_trd_bbl  )       ;    WRITE (cltra,'("BBL_",4a)')
+         CASE( jptra_trd_nsr  )       ;    WRITE (cltra,'("FOR_",4a)')
+         CASE( jptra_trd_zdf  )       ;    WRITE (cltra,'("ZDF_",4a)')
+         CASE( jptra_trd_dmp  )       ;    WRITE (cltra,'("DMP_",4a)')
+         CASE( jptra_trd_sms  )       ;    WRITE (cltra,'("SMS_",4a)')
+         CASE( jptra_trd_atf  )       ;    WRITE (cltra,'("ATF_",4a)')
+         CASE( jptra_trd_radb )       ;    WRITE (cltra,'("RDB_",4a)')
+         CASE( jptra_trd_radn )       ;    WRITE (cltra,'("RDN_",4a)')
          END SELECT
+                                          cltra = TRIM(cltra)//TRIM(ctrcnm(kjn))
                                           CALL iom_put( cltra,  ptrtrd(:,:,:) )
          !
@@ -111,5 +118,7 @@
       !!----------------------------------------------------------------------
 
+#if defined key_trdmld_trc  
       CALL trd_mld_bio_zint( ptrbio, ktrd ) ! Verticaly integrated biological trends
+#endif
 
    END SUBROUTINE trd_mod_trc_bio
Index: branches/2012/dev_INGV/NEMOGCM/SETTE/BATCH_TEMPLATE/batch-PW6_VARGAS
===================================================================
--- branches/2012/dev_INGV/NEMOGCM/SETTE/BATCH_TEMPLATE/batch-PW6_VARGAS	(revision 3574)
+++ branches/2012/dev_INGV/NEMOGCM/SETTE/BATCH_TEMPLATE/batch-PW6_VARGAS	(revision 3575)
@@ -11,5 +11,5 @@
 # @ total_tasks = NPROCS
 # time
-# @ wall_clock_limit = 0:30:00
+# @ wall_clock_limit = 1:30:00
 # @ queue
 
Index: branches/2012/dev_INGV/NEMOGCM/SETTE/README
===================================================================
--- branches/2012/dev_INGV/NEMOGCM/SETTE/README	(revision 3574)
+++ branches/2012/dev_INGV/NEMOGCM/SETTE/README	(revision 3575)
@@ -11,8 +11,10 @@
                COMPILER    : compiler among those available in NEMOGCM/ARCH, needed for makenemo (see below)
                              can also be pass as an argument, e.g. ./sette.sh ifort_osx
-	       BATCH_COMMAND : command for job submission in batch mode
-	       MPI_INTERACT : "yes" if you want to run in interactive mode for MPI run
-	       		      "no" if you want to run in batch mode for MPI run
-			      NOTE : every job using only 1 proc is run in interactive mode
+	       BATCH_COMMAND_PAR : command for job submission in batch mode parallel (MMIÂ)
+	       BATCH_COMMAND_SEQ : command for job submission in batch mode sequential (NB_PROC = 1)
+	       INTERACT_FLAG : "yes" if you want to run in interactive mode 
+	       		       "no" if you want to run in batch mode
+	       MPIRUN_FLAG   : "yes" if you want to run in parallel (MPI)
+			       "no" if you want to run in sequential mode (NB_PROC = 1)
 
                makenemo -m : machine (compilator); see ./makenemo -m help (in NEMOGCM/CONFIG directory)
@@ -33,9 +35,9 @@
 
                prepare_job.sh generates the script to be executed 
-			input: INPUT_FILE_CONFIG_NAME NB_PROCS TEST_NAME MPI_FLAG JOB_FILE_NAME
+			input: INPUT_FILE_CONFIG_NAME NUMBER_PROC TEST_NAME MPIRUN_FLAG JOB_FILE
 
-               fcm_job.sh needs input: TOTAL_NUMBER_OF_PROCS_used JOB_FILE_NAME INTERACT_FLAG MPI_FLAG 
-			(for example if you compile ORCA2_LIM with key_mpp_mpi 
-			and only run short test ===> ./fcm_job input_ORCA2_LIM.cfg 4 SHORT)
+               fcm_job.sh needs input: TOTAL_NUMBER_OF_PROCS_used JOB_FILE_NAME INTERACT_FLAG MPIRUN_FLAG 
+			(for example if you run with 4 procs JOB_FILE batch parallel 
+			and only run short test ===> ./fcm_job 4 SHORT no    yes   )
 
  in param.cfg :
@@ -49,6 +51,6 @@
                is the same of that in input_REF_CONFIG.cfg, if not change one.
 
-               change in "RUN OPA" if [ ${MPI_INTERACT} == "yes" ] mpirun command line (some examples are already written)
-	       NOTE: if MPI_INTERACT="no" it is neede a batch_file (see below to create a new one)
+               change in "RUN OPA" if [ ${INTERACT_FLAG} == "yes" ] mpirun command line (some examples are already written)
+	       NOTE: if INTERACT_FLAG="no" it is needed a batch_file (see below to create a new one)
 
 NOTE:
@@ -77,3 +79,3 @@
 1. see in SETTE/BATCH_TEMPLATE directory existing examples
 2. create you own batch file like: batch-${COMPILER}
-(note: sette.sh will copy it in job_batch_template if you run tests in MPI_INTERACT="no")
+(note: sette.sh will copy it in job_batch_template if you run tests in INTERACT_FLAG="no")
Index: branches/2012/dev_INGV/NEMOGCM/SETTE/fcm_job.sh
===================================================================
--- branches/2012/dev_INGV/NEMOGCM/SETTE/fcm_job.sh	(revision 3574)
+++ branches/2012/dev_INGV/NEMOGCM/SETTE/fcm_job.sh	(revision 3575)
@@ -25,5 +25,5 @@
 # :: lauches the script $JOB_FILE interactive or batch, one task or MPI
 #
-#  $ ./fcm_job.sh NUMBER_OF_PROCS JOB_FILE INTERACT MPI_FLAG
+#  $ ./fcm_job.sh NUMBER_OF_PROCS JOB_FILE INTERACT_FLAG MPIRUN_FLAG
 #
 #
@@ -40,7 +40,10 @@
 # ::
 #
-#  $ ./fcm_job.sh NUMBER_OF_PROCS JOB_FILE INTERACT MPI_FLAG
+#  $ ./fcm_job.sh NUMBER_OF_PROCS JOB_FILE INTERACT_FLAG MPIRUN_FLAG
 #
-#  run a 
+#  run a job with 1 processor SHORT test ( 5 days ) 
+#  using an interactive run without mpirun 
+#
+#  ./fcm_job.sh        1           SHORT        yes          no 
 #
 #
@@ -54,5 +57,5 @@
 # ==========
 #
-# $Id$
+# $Id: $
 #
 #
@@ -63,6 +66,6 @@
 #
 
-usage=" Usage : ./fcm_job.sh  NUMBER_OF_PROCS JOB_FILE INTERACT MPI_FLAG"
-usage=" example : ./fcm_job.sh 8 SHORT no/yes no/yes"
+usage=" Usage : ./fcm_job.sh  NUMBER_OF_PROCS JOB_FILE INTERACT_FLAG MPIRUN_FLAG"
+usage=" example : ./fcm_job.sh       8          SHORT      no/yes       no/yes"
 
 
@@ -83,17 +86,17 @@
 export NB_PROCS=$1
 export JOB_FILE=$2
-export INTERACT=$3
-export MPI_FLAG=$4
+export INTERACT_FLAG=$3
+export MPIRUN_FLAG=$4
 ################################################################
 # RUN OPA
 cd ${EXE_DIR}
-if [ "$INTERACT" == "yes" ]; then
-        eval $JOB_FILE
-else if [ "$INTERACT" == "no" ]; then
-# submit job to batch system 
-        if [ "$NB_PROC" == "1" ]; then
-	   eval ${BATCH_COMMAND_SEQ} $JOB_FILE ; echo  ${BATCH_COMMAND_SEQ} $JOB_FILE
+if [ "${INTERACT_FLAG}" == "yes" ]; then
+	eval ${JOB_FILE}
+else if [ "${INTERACT_FLAG}" == "no" ]; then
+	# submit job to batch system 
+        if [ "${NB_PROC}" == "1" ]; then
+		eval ${BATCH_COMMAND_SEQ} ${JOB_FILE} ; echo  ${BATCH_COMMAND_SEQ} ${JOB_FILE}
         else
-	   eval ${BATCH_COMMAND_PAR} $JOB_FILE ; echo ${BATCH_COMMAND_PAR} $JOB_FILE
+		eval ${BATCH_COMMAND_PAR} ${JOB_FILE} ; echo ${BATCH_COMMAND_PAR} ${JOB_FILE}
         fi
 fi
Index: branches/2012/dev_INGV/NEMOGCM/SETTE/input_ORCA2_LIM.cfg
===================================================================
--- branches/2012/dev_INGV/NEMOGCM/SETTE/input_ORCA2_LIM.cfg	(revision 3574)
+++ branches/2012/dev_INGV/NEMOGCM/SETTE/input_ORCA2_LIM.cfg	(revision 3575)
@@ -1,1 +1,1 @@
-ORCA2_LIM_nemo_v3.3.tar
+ORCA2_LIM_nemo_v3.4.tar
Index: branches/2012/dev_INGV/NEMOGCM/SETTE/input_ORCA2_LIM_PISCES.cfg
===================================================================
--- branches/2012/dev_INGV/NEMOGCM/SETTE/input_ORCA2_LIM_PISCES.cfg	(revision 3574)
+++ branches/2012/dev_INGV/NEMOGCM/SETTE/input_ORCA2_LIM_PISCES.cfg	(revision 3575)
@@ -1,1 +1,1 @@
-ORCA2_LIM_nemo_v3.3.tar
+ORCA2_LIM_PISCES_v3.4.tar
Index: branches/2012/dev_INGV/NEMOGCM/SETTE/input_POMME.cfg
===================================================================
--- branches/2012/dev_INGV/NEMOGCM/SETTE/input_POMME.cfg	(revision 3574)
+++ 	(revision )
@@ -1,1 +1,0 @@
-POMME_nemo_v3_3.tar
Index: branches/2012/dev_INGV/NEMOGCM/SETTE/prepare_job.sh
===================================================================
--- branches/2012/dev_INGV/NEMOGCM/SETTE/prepare_job.sh	(revision 3574)
+++ branches/2012/dev_INGV/NEMOGCM/SETTE/prepare_job.sh	(revision 3575)
@@ -1,8 +1,13 @@
 #####################################################
-# Author : Italo Epicoco for NEMO
-# Contact : italo.epicoco@unisalento.it
-#
-# Some scripts called by sette.sh 
-# prepare_job.sh   : create the job script for running job 
+# Author : Simona Flavoni for NEMO
+# Contact : sflod@locean-ipsl.upmc.fr
+#
+# ----------------------------------------------------------------------
+# NEMO/SETTE , NEMO Consortium (2010)
+# Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
+# ----------------------------------------------------------------------
+#
+# Some scripts called by sette.sh
+# prepare_job.sh   : creates the job script for running job 
 ######################################################
 #set -vx
@@ -16,7 +21,7 @@
 # ================
 #
-# --------------------------
-# create the job script for NEMO tests 
-# --------------------------
+# -------------------------------------------------
+# script that creates the job script for NEMO tests 
+# -------------------------------------------------
 #
 # SYNOPSIS
Index: branches/2012/dev_INGV/NEMOGCM/SETTE/sette.sh
===================================================================
--- branches/2012/dev_INGV/NEMOGCM/SETTE/sette.sh	(revision 3574)
+++ branches/2012/dev_INGV/NEMOGCM/SETTE/sette.sh	(revision 3575)
@@ -11,5 +11,5 @@
 #
 #############################################################
-#set -x
+set -vx
 set -o posix
 #set -u
@@ -125,5 +125,5 @@
 # ==========
 #
-# $Id$
+# $Id: $
 #
 #   * creation
@@ -139,5 +139,4 @@
 export MPIRUN_FLAG="yes"
 
-
 # Directory to run the tests
 SETTE_DIR=$(cd $(dirname "$0"); pwd)
@@ -167,5 +166,5 @@
     JOB_FILE=${EXE_DIR}/run_job.sh
     NPROC=1
-    \rm $JOB_FILE
+    \rm ${JOB_FILE}
     cd ${EXE_DIR}
     set_namelist namelist cn_exp \"GYRELOB_LONG\"
@@ -177,8 +176,7 @@
     set_namelist namelist_top ln_diatrc .false.
     cd ${SETTE_DIR}
-    cp BATCH_TEMPLATE/batch-${COMPILER} job_batch_template || exit
-    . ./prepare_job.sh input_GYRE.cfg $NPROC ${TEST_NAME} $MPIRUN_FLAG $JOB_FILE
-    cd ${SETTE_DIR}
-    . ./fcm_job.sh $NPROC $JOB_FILE $INTERACT_FLAG $MPIRUN_FLAG
+    . ./prepare_job.sh input_GYRE.cfg $NPROC ${TEST_NAME} no ${JOB_FILE}
+    cd ${SETTE_DIR}
+    . ./fcm_job.sh $NPROC ${JOB_FILE} ${INTERACT_FLAG} no
 
     cd ${SETTE_DIR}
@@ -202,8 +200,7 @@
     set_namelist namelist_top cn_trcrst_in \"GYRELOB_LONG_00000060_restart_trc\"
     cd ${SETTE_DIR}
-    cp BATCH_TEMPLATE/batch-${COMPILER} job_batch_template || exit
-    . ./prepare_job.sh input_GYRE.cfg $NPROC ${TEST_NAME} $MPIRUN_FLAG $JOB_FILE
-    cd ${SETTE_DIR}
-    . ./fcm_job.sh $NPROC $JOB_FILE  $INTERACT_FLAG $MPIRUN_FLAG
+    . ./prepare_job.sh input_GYRE.cfg $NPROC ${TEST_NAME} no ${JOB_FILE}
+    cd ${SETTE_DIR}
+    . ./fcm_job.sh $NPROC ${JOB_FILE} ${INTERACT_FLAG} no
 fi
 
@@ -235,8 +232,7 @@
     set_namelist namelist jpnij 4
     cd ${SETTE_DIR}
-    cp BATCH_TEMPLATE/batch-${COMPILER} job_batch_template || exit
-    . ./prepare_job.sh input_GYRE.cfg $NPROC ${TEST_NAME} $MPIRUN_FLAG $JOB_FILE
-    cd ${SETTE_DIR}
-    . ./fcm_job.sh $NPROC $JOB_FILE  $INTERACT_FLAG $MPIRUN_FLAG
+    . ./prepare_job.sh input_GYRE.cfg $NPROC ${TEST_NAME} ${MPIRUN_FLAG} ${JOB_FILE}
+    cd ${SETTE_DIR}
+    . ./fcm_job.sh $NPROC ${JOB_FILE} ${INTERACT_FLAG} ${MPIRUN_FLAG}
 
     cd ${SETTE_DIR}
@@ -260,8 +256,7 @@
     set_namelist namelist jpnij 4
     cd ${SETTE_DIR}
-    cp BATCH_TEMPLATE/batch-${COMPILER} job_batch_template || exit
-    . ./prepare_job.sh input_GYRE.cfg $NPROC ${TEST_NAME} $MPIRUN_FLAG $JOB_FILE
-    cd ${SETTE_DIR}
-    . ./fcm_job.sh $NPROC $JOB_FILE  $INTERACT_FLAG $MPIRUN_FLAG
+    . ./prepare_job.sh input_GYRE.cfg $NPROC ${TEST_NAME} ${MPIRUN_FLAG} ${JOB_FILE}
+    cd ${SETTE_DIR}
+    . ./fcm_job.sh $NPROC ${JOB_FILE} ${INTERACT_FLAG} ${MPIRUN_FLAG}
 fi
 
@@ -296,8 +291,7 @@
     set_namelist namelist_pisces ln_presatm .false.
     cd ${SETTE_DIR}
-    cp BATCH_TEMPLATE/batch-${COMPILER} job_batch_template || exit
-    . ./prepare_job.sh input_ORCA2_LIM_PISCES.cfg $NPROC ${TEST_NAME} $MPIRUN_FLAG $JOB_FILE    
-    cd ${SETTE_DIR}
-    . ./fcm_job.sh $NPROC $JOB_FILE  $INTERACT_FLAG $MPIRUN_FLAG
+    . ./prepare_job.sh input_ORCA2_LIM_PISCES.cfg $NPROC ${TEST_NAME} no ${JOB_FILE}
+    cd ${SETTE_DIR}
+    . ./fcm_job.sh $NPROC  ${JOB_FILE} ${INTERACT_FLAG} no
 #
     export TEST_NAME="SHORT"
@@ -330,8 +324,7 @@
     set_namelist namelist_pisces ln_presatm .false.
     cd ${SETTE_DIR}
-    cp BATCH_TEMPLATE/batch-${COMPILER} job_batch_template || exit
-    . ./prepare_job.sh input_ORCA2_LIM_PISCES.cfg $NPROC ${TEST_NAME} $MPIRUN_FLAG $JOB_FILE
-    cd ${SETTE_DIR}
-    . ./fcm_job.sh $NPROC $JOB_FILE $INTERACT_FLAG $MPIRUN_FLAG 
+    . ./prepare_job.sh input_ORCA2_LIM_PISCES.cfg $NPROC ${TEST_NAME} no ${JOB_FILE}
+    cd ${SETTE_DIR}
+    . ./fcm_job.sh $NPROC ${JOB_FILE} ${INTERACT_FLAG} no
 fi
 
@@ -367,8 +360,7 @@
     set_namelist namelist_pisces ln_presatm .false.
     cd ${SETTE_DIR}
-    cp BATCH_TEMPLATE/batch-${COMPILER} job_batch_template || exit
-    . ./prepare_job.sh input_ORCA2_LIM_PISCES.cfg $NPROC ${TEST_NAME} $MPIRUN_FLAG $JOB_FILE
-    cd ${SETTE_DIR}
-    . ./fcm_job.sh $NPROC $JOB_FILE  $INTERACT_FLAG $MPIRUN_FLAG
+    . ./prepare_job.sh input_ORCA2_LIM_PISCES.cfg $NPROC ${TEST_NAME} ${MPIRUN_FLAG} ${JOB_FILE}
+    cd ${SETTE_DIR}
+    . ./fcm_job.sh $NPROC ${JOB_FILE} ${INTERACT_FLAG} ${MPIRUN_FLAG} 
 
     cd ${SETTE_DIR}
@@ -397,8 +389,7 @@
     set_namelist namelist_pisces ln_presatm .false.
     cd ${SETTE_DIR}
-    cp BATCH_TEMPLATE/batch-${COMPILER} job_batch_template || exit
-    . ./prepare_job.sh input_ORCA2_LIM_PISCES.cfg $NPROC ${TEST_NAME} $MPIRUN_FLAG $JOB_FILE
-    cd ${SETTE_DIR}
-    . ./fcm_job.sh $NPROC $JOB_FILE $INTERACT_FLAG $MPIRUN_FLAG
+    . ./prepare_job.sh input_ORCA2_LIM_PISCES.cfg $NPROC ${TEST_NAME} ${MPIRUN_FLAG} ${JOB_FILE}
+    cd ${SETTE_DIR}
+    . ./fcm_job.sh $NPROC ${JOB_FILE} ${INTERACT_FLAG} ${MPIRUN_FLAG}
 fi
 
@@ -432,6 +423,5 @@
     set_namelist namelist_pisces ln_presatm .false.
     cd ${SETTE_DIR}
-   cp BATCH_TEMPLATE/batch-${COMPILER} job_batch_template || exit
-    . ./prepare_job.sh input_ORCA2_OFF_PISCES.cfg $NPROC ${TEST_NAME} $MPIRUN_FLAG $JOB_FILE
+    . ./prepare_job.sh input_ORCA2_OFF_PISCES.cfg $NPROC ${TEST_NAME} ${MPIRUN_FLAG} ${JOB_FILE}
     
     cd ${SETTE_DIR}
@@ -457,8 +447,7 @@
     set_namelist namelist_pisces ln_presatm .false.
     cd ${SETTE_DIR}
-   cp BATCH_TEMPLATE/batch-${COMPILER} job_batch_template || exit
-    . ./prepare_job.sh input_ORCA2_OFF_PISCES.cfg $NPROC ${TEST_NAME} $MPIRUN_FLAG $JOB_FILE
-    cd ${SETTE_DIR}
-    . ./fcm_job.sh $NPROC $JOB_FILE  $INTERACT_FLAG $MPIRUN_FLAG
+    . ./prepare_job.sh input_ORCA2_OFF_PISCES.cfg $NPROC ${TEST_NAME}  ${MPIRUN_FLAG} ${JOB_FILE}
+    cd ${SETTE_DIR}
+    . ./fcm_job.sh $NPROC  ${JOB_FILE} ${INTERACT_FLAG} ${MPIRUN_FLAG}
 fi
 
@@ -492,8 +481,7 @@
     set_namelist namelist_pisces ln_presatm .false.
     cd ${SETTE_DIR}
-   cp BATCH_TEMPLATE/batch-${COMPILER} job_batch_template || exit
-    . ./prepare_job.sh input_ORCA2_OFF_PISCES.cfg $NPROC ${TEST_NAME} $MPIRUN_FLAG $JOB_FILE
-    cd ${SETTE_DIR}
-    . ./fcm_job.sh $NPROC $JOB_FILE  $INTERACT_FLAG $MPIRUN_FLAG
+    . ./prepare_job.sh input_ORCA2_OFF_PISCES.cfg $NPROC ${TEST_NAME} ${MPIRUN_FLAG} ${JOB_FILE}
+    cd ${SETTE_DIR}
+    . ./fcm_job.sh $NPROC  ${JOB_FILE} ${INTERACT_FLAG} ${MPIRUN_FLAG}
 
     cd ${SETTE_DIR}
@@ -520,8 +508,7 @@
     set_namelist namelist_pisces ln_presatm .false.
     cd ${SETTE_DIR}
-   cp BATCH_TEMPLATE/batch-${COMPILER} job_batch_template || exit
-    . ./prepare_job.sh input_ORCA2_OFF_PISCES.cfg $NPROC ${TEST_NAME} $MPIRUN_FLAG $JOB_FILE
-    cd ${SETTE_DIR}
-    . ./fcm_job.sh $NPROC $JOB_FILE  $INTERACT_FLAG $MPIRUN_FLAG
+    . ./prepare_job.sh input_ORCA2_OFF_PISCES.cfg $NPROC ${TEST_NAME} ${MPIRUN_FLAG} ${JOB_FILE}
+    cd ${SETTE_DIR}
+    . ./fcm_job.sh $NPROC  ${JOB_FILE} ${INTERACT_FLAG} ${MPIRUN_FLAG}
 fi
 
@@ -551,8 +538,7 @@
     set_namelist namelist jpnij 32
     cd ${SETTE_DIR}
-   cp BATCH_TEMPLATE/batch-${COMPILER} job_batch_template || exit
-    . ./prepare_job.sh input_AMM12.cfg $NPROC ${TEST_NAME} $MPIRUN_FLAG $JOB_FILE
-    cd ${SETTE_DIR}
-    . ./fcm_job.sh $NPROC $JOB_FILE $INTERACT_FLAG $MPIRUN_FLAG 
+    . ./prepare_job.sh input_AMM12.cfg $NPROC ${TEST_NAME} ${MPIRUN_FLAG} ${JOB_FILE}
+    cd ${SETTE_DIR}
+    . ./fcm_job.sh $NPROC  ${JOB_FILE} ${INTERACT_FLAG} ${MPIRUN_FLAG}
 
     cd ${SETTE_DIR}
@@ -574,8 +560,7 @@
     set_namelist namelist jpnij 32
     cd ${SETTE_DIR}
-   cp BATCH_TEMPLATE/batch-${COMPILER} job_batch_template || exit
-    . ./prepare_job.sh input_AMM12.cfg $NPROC ${TEST_NAME} $MPIRUN_FLAG $JOB_FILE
-    cd ${SETTE_DIR}
-    . ./fcm_job.sh $NPROC $JOB_FILE $INTERACT_FLAG $MPIRUN_FLAG
+    . ./prepare_job.sh input_AMM12.cfg $NPROC ${TEST_NAME} ${MPIRUN_FLAG} ${JOB_FILE}
+    cd ${SETTE_DIR}
+    . ./fcm_job.sh $NPROC  ${JOB_FILE} ${INTERACT_FLAG} ${MPIRUN_FLAG}
 fi
 
@@ -605,8 +590,7 @@
     set_namelist namelist jpnij 32
     cd ${SETTE_DIR}
-   cp BATCH_TEMPLATE/batch-${COMPILER} job_batch_template || exit
-    . ./prepare_job.sh input_AMM12.cfg $NPROC ${TEST_NAME} $MPIRUN_FLAG $JOB_FILE
-    cd ${SETTE_DIR}
-    . ./fcm_job.sh $NPROC $JOB_FILE  $INTERACT_FLAG $MPIRUN_FLAG
+    . ./prepare_job.sh input_AMM12.cfg $NPROC ${TEST_NAME} ${MPIRUN_FLAG} ${JOB_FILE}
+    cd ${SETTE_DIR}
+    . ./fcm_job.sh $NPROC ${JOB_FILE} ${INTERACT_FLAG} ${MPIRUN_FLAG}
 
     cd ${SETTE_DIR}
@@ -628,8 +612,7 @@
     set_namelist namelist cn_ocerst_in \"../LONG/AMM12_00000006_restart\"
     cd ${SETTE_DIR}
-   cp BATCH_TEMPLATE/batch-${COMPILER} job_batch_template || exit
-    . ./prepare_job.sh input_AMM12.cfg $NPROC ${TEST_NAME} $MPIRUN_FLAG $JOB_FILE
-    cd ${SETTE_DIR}
-    . ./fcm_job.sh $NPROC $JOB_FILE $INTERACT_FLAG $MPIRUN_FLAG 
+    . ./prepare_job.sh input_AMM12.cfg $NPROC ${TEST_NAME} ${MPIRUN_FLAG} ${JOB_FILE}
+    cd ${SETTE_DIR}
+    . ./fcm_job.sh $NPROC  ${JOB_FILE} ${INTERACT_FLAG} ${MPIRUN_FLAG}
 fi
 
@@ -660,8 +643,7 @@
     set_namelist 1_namelist ln_clobber .true.
     cd ${SETTE_DIR}
-   cp BATCH_TEMPLATE/batch-${COMPILER} job_batch_template || exit
-    . ./prepare_job.sh input_ORCA2_LIM_AGRIF.cfg $NPROC ${TEST_NAME} $MPIRUN_FLAG $JOB_FILE
-    cd ${SETTE_DIR}
-    . ./fcm_job.sh $NPROC $JOB_FILE  $INTERACT_FLAG $MPIRUN_FLAG
+    . ./prepare_job.sh input_ORCA2_LIM_AGRIF.cfg $NPROC ${TEST_NAME} ${MPIRUN_FLAG} ${JOB_FILE}
+    cd ${SETTE_DIR}
+    . ./fcm_job.sh $NPROC  ${JOB_FILE} ${INTERACT_FLAG} ${MPIRUN_FLAG}
 fi
 
Index: branches/2012/dev_INGV/NEMOGCM/SETTE/sette.sh.vargas
===================================================================
--- branches/2012/dev_INGV/NEMOGCM/SETTE/sette.sh.vargas	(revision 3574)
+++ 	(revision )
@@ -1,593 +1,0 @@
-#!/bin/bash
-#############################################################
-# Author : Simona Flavoni for NEMO
-# Contact : sflod@locean-ipsl.upmc.fr
-#
-# sette.sh   : principal script of SET TEsts for NEMO (SETTE)
-# ----------------------------------------------------------------------
-# NEMO/SETTE , NEMO Consortium (2010)
-# Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
-# ----------------------------------------------------------------------
-#
-#############################################################
-#set -x
-set -o posix
-#set -u
-#set -e
-#+
-#
-# ================
-# sette.sh
-# ================
-#
-# ----------------------------------------------
-# Set of tests for NEMO
-# ----------------------------------------------
-#
-# SYNOPSIS
-# ========
-#
-# ::
-#
-#  $ ./sette.sh
-#
-# DESCRIPTION
-# ===========
-#
-# Variables to be checked by user:
-#
-# COMPILER : name of compiler as defined in NEMOGCM/ARCH directory 
-#
-# BATCH_COMMAND :  name of the command for batch submission
-#
-# MPI_INTERACT :  
-#
-#         for MPP tests, "no" for batch execution, "yes" for interactive execution 
-#
-#         NOTE: for run with 1 process tests are run always in MPI_INTERACT="yes"
-#
-# Principal script is sette.sh, that calls 
-#
-#  makenemo 
-#
-#   creates the exectuable in ${CONFIG_NAME}/BLD/bin/nemo.exe  (and its link opa in ${CONFIG_NAME}/EXP00)
-#
-#  param.cfg : sets and loads following directories:
-#
-#   FORCING_DIR : is the directory for forcing files (tarfile)
-#
-#   INPUT_DIR : is the directory for input files storing 
-#
-#   TMPDIR : is the temporary directory (if needed)
-# 
-#   NEMO_VALIDATION_DIR : is the validation directory
-#
-#   (NOTE: this file is the same for all configrations to be tested with sette)
-#
-#
-#  all_functions.sh : loads functions used by sette (note: new functions can be added here)
-#
-#   set_namelist : function declared in all_functions that set namelist parameters for tests
-#
-#   post_test_tidyup : creates validation storage directory and copy needed output files (solver.stat and ocean.output) in it after execution of test.
-#
-#   Tree of VALIDATION is:
-#
-#   NEMO_VALIDATION_DIR/WCONFIG_NAME/WCOMPILER_NAME/TEST_NAME/REVISION_NUMBER(or DATE)
-#
-#
-#  prepare_exe_dir.sh : defines and creates directory where the test is executed
-#
-#       execution directory takes name of TEST_NAME defined in every test in sette.sh
-#
-#       ( each test in executed in its own directory )
-#
-#
-#  fcm_job.sh 
-#
-#   runs job in interactive or batch mode : all jobs using 1 process are run interactive, and all MPP jobs are
-#
-#   run in batch (MPI_INTERACT="no") or interactive (MPI_INTERACT="yes") see sette.sh and BATCH_TEMPLATE directory
-#
-#   (note this job needs to have an input_CONFIG.cfg in which can be found input tar file)
-# 
-#  NOTE: if job is not launched for some problems you have executable ready in ${EXE_DIR} directory
-#
-#  NOTE: the changed namelists are leaved in ${EXE_DIR} directory whereas original namelist remains in ${NEW_CONF}/EXP00
-# 
-#  in ${SETTE_DIR} is created output.sette with the echo of executed commands
-#
-#  if sette.sh is stopped in output.sette there is written the last command executed by sette.sh
-#
-#  if you run: ./sette.sh 2>&1 | tee out.sette
-#
-#  in ${SETTE_DIR} out.sette is redirected standard error & standard output
-#
-#
-# EXAMPLES
-# ========
-#
-# ::
-#
-#  $ ./sette.sh 
-#
-#
-# TODO
-# ====
-#
-# option debug
-#
-# EVOLUTIONS
-# ==========
-#
-# $Id: sette.sh 2890 2011-10-06 11:03:48Z flavoni $
-#
-#   * creation
-#
-#-
-#
-#-
-# Compiler among those in NEMOGCM/ARCH
-COMPILER=PW6_VARGAS
-export BATCH_COMMAND=llsubmit
-export MPI_INTERACT="yes"
-
-# Directory to run the tests
-SETTE_DIR=$(cd $(dirname "$0"); pwd)
-MAIN_DIR=${SETTE_DIR%/SETTE}
-CONFIG_DIR=${MAIN_DIR}/CONFIG
-TOOLS_DIR=${MAIN_DIR}/TOOLS
-COMPIL_DIR=${TOOLS_DIR}/COMPILE
-
-CMP_NAM=${1:-$COMPILER}
-# Copy job_batch_COMPILER file for specific compiler into job_batch_template
-cd ${SETTE_DIR}
-cp BATCH_TEMPLATE/batch-${COMPILER} job_batch_template || exit
-
-for config in 1 2 3 4 5 6 7 8
-do
-
-# TESTS FOR GYRE_LOBSTER CONFIGURATION
-if [ ${config} -eq 1 ] ;  then
-    ## Restartability tests for GYRE_LOBSTER
-    export TEST_NAME="LONG"
-    cd ${SETTE_DIR}
-    . ../CONFIG/makenemo -m ${CMP_NAM} -n GYRELOB_LONG -r GYRE_LOBSTER add_key "key_mpp_mpi key_mpp_rep"
-    cd ${SETTE_DIR}
-    . param.cfg
-    . all_functions.sh
-    . prepare_exe_dir.sh
-    cd ${EXE_DIR}
-    set_namelist namelist cn_exp \"GYRELOB_LONG\"
-    set_namelist namelist nn_it000 1
-    set_namelist namelist nn_itend 120
-    set_namelist namelist nn_stock 60
-    set_namelist namelist ln_clobber .true.
-    set_namelist namelist nn_solv 2
-    set_namelist namelist_top ln_diatrc .false.
-    set_namelist namelist jpni 2
-    set_namelist namelist jpnj 2
-    set_namelist namelist jpnij 4
-    cd ${SETTE_DIR}
-    . ./fcm_job.sh input_GYRE.cfg 4 ${TEST_NAME}
-
-    cd ${SETTE_DIR}
-    export TEST_NAME="SHORT"
-    . prepare_exe_dir.sh
-    cd ${EXE_DIR}
-    set_namelist namelist cn_exp \"GYRELOB_SHORT\"
-    set_namelist namelist nn_it000 61
-    set_namelist namelist nn_itend 120
-    set_namelist namelist nn_stock 60
-    set_namelist namelist ln_rstart .true.
-    set_namelist namelist nn_rstctl 2
-    set_namelist namelist ln_clobber .true.
-    set_namelist namelist nn_solv 2
-    set_namelist namelist jpni 2
-    set_namelist namelist jpnj 2
-    set_namelist namelist jpnij 4
-    cp ..\/LONG\/GYRELOB_LONG_00000060_restart*.nc .
-    set_namelist namelist cn_ocerst_in \"GYRELOB_LONG_00000060_restart\"
-    set_namelist namelist_top ln_diatrc .false.
-    set_namelist namelist_top ln_rsttr .true.
-    set_namelist namelist_top nn_rsttr 2
-    set_namelist namelist_top cn_trcrst_in \"GYRELOB_LONG_00000060_restart_trc\"
-    cd ${SETTE_DIR}
-    . ./fcm_job.sh input_GYRE.cfg 4 ${TEST_NAME}
-fi
-
-if [ ${config} -eq 2 ] ;  then
-    ## Repropducibility tests for GYRE_LOBSTER
-    export TEST_NAME="REPRO_1_4"
-    cd ${SETTE_DIR}
-    . ../CONFIG/makenemo -m ${CMP_NAM} -n GYRELOB_4 -r GYRE_LOBSTER add_key "key_mpp_rep key_mpp_mpi"
-    cd ${SETTE_DIR}
-    . param.cfg
-    . all_functions.sh
-    . prepare_exe_dir.sh
-    cd ${EXE_DIR}
-    set_namelist namelist cn_exp \"GYRELOB_14\"
-    set_namelist namelist nn_it000 1
-    set_namelist namelist nn_itend 60
-    set_namelist namelist nn_fwb 0
-    set_namelist namelist nn_bench 0
-    set_namelist namelist ln_ctl .false.
-    set_namelist namelist ln_clobber .true.
-    set_namelist namelist nn_solv 2
-    set_namelist namelist_top ln_diatrc .false.
-    set_namelist namelist_top ln_trcdta .false.
-    set_namelist namelist jpni 1
-    set_namelist namelist jpnj 4
-    set_namelist namelist jpnij 4
-    cd ${SETTE_DIR}
-    . ./fcm_job.sh input_GYRE.cfg 4 ${TEST_NAME}
-
-    cd ${SETTE_DIR}
-    export TEST_NAME="REPRO_2_2"
-    . prepare_exe_dir.sh
-    cd ${EXE_DIR}
-    set_namelist namelist cn_exp \"GYRELOB_22\"
-    set_namelist namelist nn_it000 1
-    set_namelist namelist nn_itend 60
-    set_namelist namelist nn_fwb 0
-    set_namelist namelist ln_ctl .false.
-    set_namelist namelist ln_clobber .true.
-    set_namelist namelist nn_solv 2
-    set_namelist namelist_top ln_diatrc .false.
-    set_namelist namelist_top ln_trcdta .false.
-    set_namelist namelist jpni 2
-    set_namelist namelist jpnj 2
-    set_namelist namelist jpnij 4
-    cd ${SETTE_DIR}
-    . ./fcm_job.sh input_GYRE.cfg 4 ${TEST_NAME}
-fi
-
-# TESTS FOR ORCA2_LIM_PISCES CONFIGURATION
-if [ ${config} -eq 3 ] ;  then
-    ## Restartability tests for ORCA2_LIM_PISCES
-    export TEST_NAME="LONG"
-    cd ${SETTE_DIR}
-    . ../CONFIG/makenemo -m ${CMP_NAM} -n ORCA2LIMPIS_LONG -r ORCA2_LIM_PISCES -j 8 add_key "key_mpp_mpi key_mpp_rep" 
-    cd ${SETTE_DIR}
-    . param.cfg
-    . all_functions.sh
-    . prepare_exe_dir.sh
-    cd ${EXE_DIR}
-    set_namelist namelist cn_exp \"O2LP_LONG\"
-    set_namelist namelist nn_it000 1
-    set_namelist namelist nn_itend 150
-    set_namelist namelist nn_stock 75
-    set_namelist namelist ln_clobber .true.
-    set_namelist namelist jpni 2
-    set_namelist namelist jpnj 2
-    set_namelist namelist jpnij 4
-    set_namelist namelist nn_solv 2
-    set_namelist namelist_top ln_trcdta .false.
-    set_namelist namelist_top ln_diatrc .false.
-    # put ln_ironsed, ln_river, ln_ndepo, ln_dust to false
-    # if not you need input files, and for tests is not necessary
-    set_namelist namelist_pisces ln_ironsed .false.
-    set_namelist namelist_pisces ln_river .false.
-    set_namelist namelist_pisces ln_ndepo .false.
-    set_namelist namelist_pisces ln_dust .false.
-    set_namelist namelist_pisces ln_presatm .false.
-    cd ${SETTE_DIR}
-    . ./fcm_job.sh input_ORCA2_LIM_PISCES.cfg 4 ${TEST_NAME}
-    
-    cd ${SETTE_DIR}
-    export TEST_NAME="SHORT"
-    . prepare_exe_dir.sh
-    cd ${EXE_DIR}
-    set_namelist namelist cn_exp \"O2LP_SHORT\"
-    set_namelist namelist nn_it000 76
-    set_namelist namelist nn_itend 150
-    set_namelist namelist nn_stock 75
-    set_namelist namelist ln_rstart .true.
-    set_namelist namelist nn_rstctl 2
-    set_namelist namelist ln_clobber .true.
-    set_namelist namelist jpni 2
-    set_namelist namelist jpnj 2
-    set_namelist namelist jpnij 4
-    set_namelist namelist nn_solv 2
-    cp ../LONG/O2LP_LONG_00000075_restart*nc .
-    set_namelist namelist cn_ocerst_in \"O2LP_LONG_00000075_restart\"
-    set_namelist namelist_ice cn_icerst_in \"O2LP_LONG_00000075_restart_ice\"
-    set_namelist namelist_top ln_diatrc .false.
-    set_namelist namelist_top ln_rsttr .true.
-    set_namelist namelist_top nn_rsttr 2
-    set_namelist namelist_top cn_trcrst_in \"O2LP_LONG_00000075_restart_trc\"
-    # put ln_ironsed, ln_river, ln_ndepo, ln_dust
-    # if not you need input files, and for tests is not necessary
-    set_namelist namelist_pisces ln_ironsed .false.
-    set_namelist namelist_pisces ln_river .false.
-    set_namelist namelist_pisces ln_ndepo .false.
-    set_namelist namelist_pisces ln_dust .false.
-    set_namelist namelist_pisces ln_presatm .false.
-    cd ${SETTE_DIR}
-    . ./fcm_job.sh input_ORCA2_LIM_PISCES.cfg 4 ${TEST_NAME}
-fi
-
-if [ ${config} -eq 4 ] ;  then
-    ## Repropducibility tests for ORCA2_LIM_PISCES
-    export TEST_NAME="REPRO_4_4"
-    cd ${SETTE_DIR}
-    . ../CONFIG/makenemo -m ${CMP_NAM} -n ORCA2LIMPIS_16 -r ORCA2_LIM_PISCES -j 8 add_key "key_mpp_rep key_mpp_mpi"
-    cd ${SETTE_DIR}
-    . param.cfg
-    . all_functions.sh
-    . prepare_exe_dir.sh
-    cd ${EXE_DIR}
-    set_namelist namelist nn_it000 1
-    set_namelist namelist nn_itend 75
-    set_namelist namelist nn_fwb 0
-    set_namelist namelist ln_ctl .false.
-    set_namelist namelist ln_clobber .true.
-    set_namelist namelist jpni 4
-    set_namelist namelist jpnj 4
-    set_namelist namelist jpnij 16
-    set_namelist namelist nn_solv 2
-    set_namelist namelist_top ln_trcdta .false.
-    set_namelist namelist_top ln_diatrc .false.
-    # put ln_ironsed, ln_river, ln_ndepo, ln_dust to false
-    # if not you need input files, and for tests is not necessary
-    set_namelist namelist_pisces ln_ironsed .false.
-    set_namelist namelist_pisces ln_river .false.
-    set_namelist namelist_pisces ln_ndepo .false.
-    set_namelist namelist_pisces ln_dust .false.
-    set_namelist namelist_pisces ln_presatm .false.
-    cd ${SETTE_DIR}
-    . ./fcm_job.sh input_ORCA2_LIM_PISCES.cfg 16 ${TEST_NAME}
-
-    cd ${SETTE_DIR}
-    export TEST_NAME="REPRO_2_8"
-    . prepare_exe_dir.sh
-    cd ${EXE_DIR}
-    set_namelist namelist nn_it000 1
-    set_namelist namelist nn_itend 75
-    set_namelist namelist nn_fwb 0
-    set_namelist namelist ln_ctl .false.
-    set_namelist namelist ln_clobber .true.
-    set_namelist namelist jpni 2
-    set_namelist namelist jpnj 8
-    set_namelist namelist jpnij 16
-    set_namelist namelist nn_solv 2
-    set_namelist namelist_top ln_trcdta .false.
-    set_namelist namelist_top ln_diatrc .false.
-    # put ln_ironsed, ln_river, ln_ndepo, ln_dust to false
-    # if not you need input files, and for tests is not necessary
-    set_namelist namelist_pisces ln_ironsed .false.
-    set_namelist namelist_pisces ln_river .false.
-    set_namelist namelist_pisces ln_ndepo .false.
-    set_namelist namelist_pisces ln_dust .false.
-    set_namelist namelist_pisces ln_presatm .false.
-    cd ${SETTE_DIR}
-    . ./fcm_job.sh input_ORCA2_LIM_PISCES.cfg 16 ${TEST_NAME}
-fi
-
-# TESTS FOR ORCA2_OFF_PISCES CONFIGURATION
-if [ ${config} -eq 5 ] ;  then
-    ## Restartability tests for ORCA2_OFF_PISCES
-    export TEST_NAME="LONG"
-    cd ${SETTE_DIR}
-    . ../CONFIG/makenemo -m ${CMP_NAM} -n ORCA2OFFPIS_LONG -r ORCA2_OFF_PISCES -j 8 add_key "key_mpp_mpi key_mpp_rep"
-    cd ${SETTE_DIR}
-    . param.cfg
-    . all_functions.sh
-    . prepare_exe_dir.sh
-    cd ${EXE_DIR}
-    set_namelist namelist cn_exp \"OFFP_LONG\"
-    set_namelist namelist nn_it000 1
-    set_namelist namelist nn_itend 40
-    set_namelist namelist nn_stock 20
-    set_namelist namelist ln_clobber .true.
-    set_namelist namelist jpni 2
-    set_namelist namelist jpnj 2
-    set_namelist namelist jpnij 4
-    set_namelist namelist_top ln_trcdta .false.
-    set_namelist namelist_top ln_diatrc .false.
-    # put ln_ironsed, ln_river, ln_ndepo, ln_dust to false
-    # if not you need input files, and for tests is not necessary
-    set_namelist namelist_pisces ln_ironsed .false.
-    set_namelist namelist_pisces ln_river .false.
-    set_namelist namelist_pisces ln_ndepo .false.
-    set_namelist namelist_pisces ln_dust .false.
-    set_namelist namelist_pisces ln_presatm .false.
-    cd ${SETTE_DIR}
-    . ./fcm_job.sh input_ORCA2_OFF_PISCES.cfg 4 ${TEST_NAME}
-    
-    cd ${SETTE_DIR}
-    export TEST_NAME="SHORT"
-    . prepare_exe_dir.sh
-    cd ${EXE_DIR}
-    set_namelist namelist cn_exp \"OFFP_SHORT\"
-    set_namelist namelist nn_it000 21
-    set_namelist namelist nn_itend 40
-    set_namelist namelist nn_stock 20
-    set_namelist namelist ln_clobber .true.
-    set_namelist namelist jpni 2
-    set_namelist namelist jpnj 2
-    set_namelist namelist jpnij 4
-    cp ../LONG/OFFP_LONG_00000020_restart*nc .
-    set_namelist namelist_top ln_diatrc .false.
-    set_namelist namelist_top ln_rsttr .true.
-    set_namelist namelist_top nn_rsttr 2
-    set_namelist namelist_top cn_trcrst_in \"OFFP_LONG_00000020_restart_trc\"
-    # put ln_ironsed, ln_river, ln_ndepo, ln_dust
-    # if not you need input files, and for tests is not necessary
-    set_namelist namelist_pisces ln_ironsed .false.
-    set_namelist namelist_pisces ln_river .false.
-    set_namelist namelist_pisces ln_ndepo .false.
-    set_namelist namelist_pisces ln_dust .false.
-    set_namelist namelist_pisces ln_presatm .false.
-    cd ${SETTE_DIR}
-    . ./fcm_job.sh input_ORCA2_OFF_PISCES.cfg 4 ${TEST_NAME}
-fi
-
-if [ ${config} -eq 6 ] ;  then
-    ## Repropducibility tests for ORCA2_OFF_PISCES
-    export TEST_NAME="REPRO_4_4"
-    cd ${SETTE_DIR}
-    . ../CONFIG/makenemo -m ${CMP_NAM} -n ORCA2OFFPIS_16 -r ORCA2_OFF_PISCES -j 8 add_key "key_mpp_rep key_mpp_mpi"
-    cd ${SETTE_DIR}
-    . param.cfg
-    . all_functions.sh
-    . prepare_exe_dir.sh
-    cd ${EXE_DIR}
-    set_namelist namelist nn_it000 1
-    set_namelist namelist nn_itend 40
-    set_namelist namelist ln_ctl .false.
-    set_namelist namelist ln_clobber .true.
-    set_namelist namelist jpni 4
-    set_namelist namelist jpnj 4
-    set_namelist namelist jpnij 16
-    set_namelist namelist_top ln_trcdta .false.
-    set_namelist namelist_top ln_diatrc .false.
-    # put ln_ironsed, ln_river, ln_ndepo, ln_dust to false
-    # if not you need input files, and for tests is not necessary
-    set_namelist namelist_pisces ln_ironsed .false.
-    set_namelist namelist_pisces ln_river .false.
-    set_namelist namelist_pisces ln_ndepo .false.
-    set_namelist namelist_pisces ln_dust .false.
-    set_namelist namelist_pisces ln_presatm .false.
-    cd ${SETTE_DIR}
-    . ./fcm_job.sh input_ORCA2_OFF_PISCES.cfg 16 ${TEST_NAME}
-
-    cd ${SETTE_DIR}
-    export TEST_NAME="REPRO_2_8"
-    . prepare_exe_dir.sh
-    cd ${EXE_DIR}
-    set_namelist namelist nn_it000 1
-    set_namelist namelist nn_itend 40
-    set_namelist namelist ln_ctl .false.
-    set_namelist namelist ln_clobber .true.
-    set_namelist namelist jpni 2
-    set_namelist namelist jpnj 8
-    set_namelist namelist jpnij 16
-    set_namelist namelist_top ln_trcdta .false.
-    set_namelist namelist_top ln_diatrc .false.
-    # put ln_ironsed, ln_river, ln_ndepo, ln_dust to false
-    # if not you need input files, and for tests is not necessary
-    set_namelist namelist_pisces ln_ironsed .false.
-    set_namelist namelist_pisces ln_river .false.
-    set_namelist namelist_pisces ln_ndepo .false.
-    set_namelist namelist_pisces ln_dust .false.
-    set_namelist namelist_pisces ln_presatm .false.
-    cd ${SETTE_DIR}
-    . ./fcm_job.sh input_ORCA2_OFF_PISCES.cfg 16 ${TEST_NAME}
-fi
-
-# TESTS FOR AMM12 CONFIGURATION
-if [ ${config} -eq 7 ] ;  then
-    ## Reproducibility tests for AMM12
-    export TEST_NAME="REPO_8_4"
-    cd ${SETTE_DIR}
-    . ../CONFIG/makenemo -m ${CMP_NAM} -n AMM12_32 -r AMM12 add_key "key_mpp_rep"
-    cd ${SETTE_DIR}
-    . param.cfg
-    . all_functions.sh
-    . prepare_exe_dir.sh
-    cd ${EXE_DIR}
-    set_namelist namelist nn_it000 1
-    set_namelist namelist nn_itend 576
-    set_namelist namelist nn_fwb 0
-    set_namelist namelist ln_ctl .false.
-    set_namelist namelist ln_clobber .true.
-    set_namelist namelist nn_dyn2d 2
-    set_namelist namelist nn_tra_dta 0
-    set_namelist namelist jpni 8
-    set_namelist namelist jpnj 4
-    set_namelist namelist jpnij 32
-    cd ${SETTE_DIR}
-    . ./fcm_job.sh input_AMM12.cfg 32 ${TEST_NAME}
-
-    cd ${SETTE_DIR}
-    export TEST_NAME="REPO_4_8"
-    . prepare_exe_dir.sh
-    cd ${EXE_DIR}
-    set_namelist namelist nn_it000 1
-    set_namelist namelist nn_itend 576
-    set_namelist namelist nn_fwb 0
-    set_namelist namelist ln_ctl .false.
-    set_namelist namelist nn_dyn2d 2
-    set_namelist namelist nn_tra_dta 0
-    set_namelist namelist ln_clobber .true.
-    set_namelist namelist jpni 4
-    set_namelist namelist jpnj 8
-    set_namelist namelist jpnij 32
-    cd ${SETTE_DIR}
-    . ./fcm_job.sh input_AMM12.cfg 32 ${TEST_NAME}
-fi
-
-if [ ${config} -eq 8 ] ;  then
-    ## Restartability tests for AMM12
-    export TEST_NAME="LONG"
-    cd ${SETTE_DIR}
-    . ../CONFIG/makenemo -m ${CMP_NAM} -n AMM12_LONG -r AMM12 add_key "key_mpp_rep"
-    cd ${SETTE_DIR}
-    . param.cfg
-    . all_functions.sh
-    . prepare_exe_dir.sh
-    cd ${EXE_DIR}
-    set_namelist namelist nn_it000 1
-    set_namelist namelist nn_itend 12
-    set_namelist namelist nn_stock 6
-    set_namelist namelist nn_fwb 0
-    set_namelist namelist ln_ctl .false.
-    set_namelist namelist ln_clobber .true.
-    set_namelist namelist nn_dyn2d 2
-    set_namelist namelist nn_tra_dta 0
-    set_namelist namelist jpni 8
-    set_namelist namelist jpnj 4
-    set_namelist namelist jpnij 32
-    cd ${SETTE_DIR}
-    . ./fcm_job.sh input_AMM12.cfg 32 ${TEST_NAME}
-
-    cd ${SETTE_DIR}
-    export TEST_NAME="SHORT"
-    . prepare_exe_dir.sh
-    cd ${EXE_DIR}
-    set_namelist namelist nn_it000 7
-    set_namelist namelist nn_itend 12
-    set_namelist namelist nn_fwb 0
-    set_namelist namelist ln_ctl .false.
-    set_namelist namelist ln_clobber .true.
-    set_namelist namelist nn_dyn2d 2
-    set_namelist namelist nn_tra_dta 0
-    set_namelist namelist jpni 8
-    set_namelist namelist jpnj 4
-    set_namelist namelist jpnij 32
-    set_namelist namelist ln_rstart .true.
-    set_namelist namelist nn_rstctl 2
-    cp ../LONG/AMM12_00000006_restart*.nc .
-    set_namelist namelist cn_ocerst_in \"AMM12_00000006_restart\"
-    cd ${SETTE_DIR}
-    . ./fcm_job.sh input_AMM12.cfg 32 ${TEST_NAME}
-fi
-
-# TEST FOR ORCA2_LIM_AGRIF : simple test of running AGRIF (no restartability neither reproducibility tests)
-if [ ${config} -eq 9 ] ;  then
-    ## ORCA2_LIM with Agulhas AGRIF zoom in MPI
-    export TEST_NAME="SHORT"
-    cd ${SETTE_DIR}
-    . ../CONFIG/makenemo -m ${CMP_NAM} -n ORCA2AGUL_1_2 -r ORCA2_LIM -j 8 add_key "key_mpp_rep key_mpp_mpi key_agrif" del_key "key_zdftmx"
-    cd ${SETTE_DIR}
-    . param.cfg
-    . all_functions.sh
-    . prepare_exe_dir.sh
-    cd ${EXE_DIR}
-    set_namelist namelist nn_it000 1
-    set_namelist namelist nn_itend 75
-    set_namelist namelist ln_ctl .false.
-    set_namelist namelist ln_clobber .true.
-    set_namelist namelist jpni 1
-    set_namelist namelist jpnj 2
-    set_namelist namelist jpnij 2
-    set_namelist 1_namelist nn_it000 1
-    set_namelist 1_namelist nn_itend 150
-    set_namelist 1_namelist ln_ctl .false.
-    set_namelist 1_namelist ln_clobber .true.
-    cd ${SETTE_DIR}
-    . ./fcm_job.sh input_ORCA2_LIM_AGRIF.cfg 2 ${TEST_NAME}
-fi
-
-done
Index: branches/2012/dev_INGV/NEMOGCM/SETTE/sette_beginner.sh
===================================================================
--- branches/2012/dev_INGV/NEMOGCM/SETTE/sette_beginner.sh	(revision 3574)
+++ branches/2012/dev_INGV/NEMOGCM/SETTE/sette_beginner.sh	(revision 3575)
@@ -41,5 +41,6 @@
 export BATCH_COMMAND_PAR="llsubmit"
 export BATCH_COMMAND_SEQ=$BATCH_COMMAND_PAR
-# export MPI_INTERACT="no"
+export INTERACT_FLAG="no"
+export MPIRUN_FLAG="yes"
 
 # Directory to run the tests
@@ -58,7 +59,7 @@
 # small test to start
 # compile GYRE configuration with gfortran_osx compiler run with 1 proc, by default in cpp_GYRE.fcm file : 
-export TEST_NAME="TEST02"
+export TEST_NAME="prova_beginner"
 cd ${SETTE_DIR}
-. ../CONFIG/makenemo -m ${CMP_NAM} -n GYRE_SHORT -r GYRE
+. ../CONFIG/makenemo -m ${CMP_NAM} -n GYRE_SHORT -r GYRE -j 10 add_key "key_mpp_mpi"
 cd ${SETTE_DIR}
 . param.cfg 
@@ -67,4 +68,6 @@
 . prepare_exe_dir.sh
 JOB_FILE=${EXE_DIR}/run_job.sh
+NPROC=4
+\rm $JOB_FILE
 cd ${EXE_DIR}
 # setting namelist parameters
@@ -79,9 +82,6 @@
 
 cd ${SETTE_DIR}
-# . ./prepare_job.sh input_file_config_name NB_PROCS TEST_NAME MPI_FLAG JOB_FILE
-. ./prepare_job.sh input_GYRE.cfg 1 SHORT no $JOB_FILE
+. ./prepare_job.sh input_GYRE.cfg $NPROC ${TEST_NAME} ${MPIRUN_FLAG} ${JOB_FILE}
 # run job, with 1 processor, test named SHORT (= 60 time steps)
-#. ./fcm_job.sh NB_PROCS JOB_FILE INTERACT_FLAG MPI_FLAG
-    cd ${SETTE_DIR}   
-. ./fcm_job.sh 1 $JOB_FILE no no
-
+cd ${SETTE_DIR}   
+. ./fcm_job.sh 4 ${JOB_FILE} ${INTERACT_FLAG} ${MPIRUN_FLAG}
Index: branches/2012/dev_INGV/NEMOGCM/TOOLS/SECTIONS_DIADCT/src/compute_sections.f90
===================================================================
--- branches/2012/dev_INGV/NEMOGCM/TOOLS/SECTIONS_DIADCT/src/compute_sections.f90	(revision 3574)
+++ branches/2012/dev_INGV/NEMOGCM/TOOLS/SECTIONS_DIADCT/src/compute_sections.f90	(revision 3575)
@@ -370,5 +370,5 @@
         DO WHILE ( (  sec%listPoint(jseg)%I .NE.  endingPoint%I    &
                  .OR. sec%listPoint(jseg)%J .NE. endingPoint%J   ) &
-                 .AND. jseg .LT. nb_inmesh + 1 .AND. sec%listPoint(jseg)%I .GT. 0  )         
+                 .AND. jseg .LT. nb_inmesh + 10 .AND. sec%listPoint(jseg)%I .GT. 0  )         
    
            ! a. find the 4 adjacent points (North, South, East, West)
@@ -429,11 +429,11 @@
            !--------------------
            IF(      SouthPoint%I==endingPoint%I .AND. SouthPoint%J==endingPoint%J )THEN 
-               jseg = jseg+1 ; sec%listPoint(jseg) = SouthPoint
+               sec%direction(jseg)=2 ; jseg = jseg+1 ; sec%listPoint(jseg) = SouthPoint
            ELSE IF( NorthPoint%I==endingPoint%I .AND. NorthPoint%J==endingPoint%J )THEN
-               jseg = jseg+1 ; sec%listPoint(jseg) = NorthPoint
+               sec%direction(jseg)=3 ; jseg = jseg+1 ; sec%listPoint(jseg) = NorthPoint
            ELSE IF(  WestPoint%I==endingPoint%I .AND.  WestPoint%J==endingPoint%J )THEN
-               jseg = jseg+1 ; sec%listPoint(jseg) = WestPoint
+               sec%direction(jseg)=0 ; jseg = jseg+1 ; sec%listPoint(jseg) = WestPoint
            ELSE IF(   EstPoint%I==endingPoint%I .AND.   EstPoint%J==endingPoint%J )THEN
-               jseg = jseg+1 ; sec%listPoint(jseg) = EstPoint
+               sec%direction(jseg)=1 ; jseg = jseg+1 ; sec%listPoint(jseg) = EstPoint
 
            ELSE
