Index: /branches/2013/dev_CMCC_2013/DOC/TexFiles/Chapters/Chap_DIA.tex
===================================================================
--- /branches/2013/dev_CMCC_2013/DOC/TexFiles/Chapters/Chap_DIA.tex	(revision 4176)
+++ /branches/2013/dev_CMCC_2013/DOC/TexFiles/Chapters/Chap_DIA.tex	(revision 4177)
@@ -362,5 +362,5 @@
 \subsubsection{Use of Groups}
 
-Groups can be used for 2 purposes. Firstly, the group can be used to define common attributes to be shared by the elements of the group through the inheritance. In the following example, we define a group of field that will share a common grid ''grid\_T\_2D''. Note that for the field ''toce'', we overwrite the grid definition inherited from the group by ''grid\_T\_3D''.
+Groups can be used for 2 purposes. Firstly, the group can be used to define common attributes to be shared by the elements of the group through inheritance. In the following example, we define a group of field that will share a common grid ''grid\_T\_2D''. Note that for the field ''toce'', we overwrite the grid definition inherited from the group by ''grid\_T\_3D''.
 \vspace{-20pt}
 \begin{alltt}  {{\scriptsize
@@ -386,5 +386,5 @@
 \end{verbatim}
 }}\end{alltt} 
-that can be directly include in a file through the following syntax:
+that can be directly included in a file through the following syntax:
 \vspace{-20pt}
 \begin{alltt}  {{\scriptsize
@@ -466,5 +466,5 @@
 \end{verbatim}
 }}\end{alltt} 
-However it is often very convienent to define the file name with the name of the experience, the output file frequency and the date of the beginning and the end of the simulation (which are informations stored either in the namelist or in the XML file). To do so, we added the following rule: if the id of the tag file is ''fileN''(where N = 1 to 99) or one of the predefined section or mooring (see next subsection), the following part of the name and the name\_suffix (that can be inherited) will be automatically replaced by:\\
+However it is often very convienent to define the file name with the name of the experiment, the output file frequency and the date of the beginning and the end of the simulation (which are informations stored either in the namelist or in the XML file). To do so, we added the following rule: if the id of the tag file is ''fileN''(where N = 1 to 99) or one of the predefined sections or moorings (see next subsection), the following part of the name and the name\_suffix (that can be inherited) will be automatically replaced by:\\
 \\
 \begin{tabular}{|p{4cm}|p{8cm}|}
@@ -474,5 +474,5 @@
    \hline
    \centering @expname@ &
-   the experience name (from cn\_exp in the namelist) \\
+   the experiment name (from cn\_exp in the namelist) \\
    \hline
    \centering @freq@ &
@@ -590,5 +590,5 @@
    file\_definition & 
    encapsulates the definition of all the files that will be outputted &
-   enabled, min\_digits, name, name\_suffix, output\_level, split\_format, split\_freq, sync\_freq, type, src &
+   enabled, min\_digits, name, name\_suffix, output\_level, split\_freq\_format, split\_freq, sync\_freq, type, src &
    context & 
    file or file\_group \\
@@ -596,5 +596,5 @@
    file\_group & 
    encapsulates a group of files that will be outputted &
-   enabled, description, id, min\_digits, name, name\_suffix, output\_freq, output\_level, split\_format, split\_freq, sync\_freq, type, src &
+   enabled, description, id, min\_digits, name, name\_suffix, output\_freq, output\_level, split\_freq\_format, split\_freq, sync\_freq, type, src &
    file\_definition, file\_group & 
    file or file\_group \\
@@ -602,5 +602,5 @@
    file & 
    define the contents of a file to be outputted &
-   enabled, description, id, min\_digits, name, name\_suffix, output\_freq, output\_level, split\_format, split\_freq, sync\_freq, type, src &
+   enabled, description, id, min\_digits, name, name\_suffix, output\_freq, output\_level, split\_freq\_format, split\_freq, sync\_freq, type, src &
    file\_definition, file\_group & 
    field \\
@@ -775,12 +775,13 @@
    field family \\ 
    \hline   
-   split\_format & 
-   date format used in the name of splitted output files. can be spécified using the following syntaxe: \%y, \%mo, \%d, \%h \%mi and \%s & 
-   split\_format= "\%yy\%mom\%dd" & 
+   split\_freq & 
+   frequency at which to temporally split output files. Units can be ts (timestep), y, mo, d, h, mi, s. Useful for long runs to prevent over-sized output files.& 
+   split\_freq="1mo" & 
    file family \\ 
    \hline   
-   split\_freq & 
-   split output files frequency. units can be ts (timestep), y, mo, d, h, mi, s. & 
-   split\_freq="1mo" & 
+   split\_freq\-\_format & 
+   date format used in the name of temporally split output files. Can be specified 
+   using the following syntaxes: \%y, \%mo, \%d, \%h \%mi and \%s & 
+   split\_freq\_format= "\%y\%mo\%d" & 
    file family \\ 
    \hline   
@@ -812,5 +813,5 @@
    \hline   
    type (1)& 
-   specify if the output files must be split (multiple\_file) or not (one\_file) & 
+   specify if the output files are to be split spatially (multiple\_file) or not (one\_file) & 
    type="multiple\_file" & 
    file familly \\ 
Index: anches/2013/dev_CMCC_2013/NEMOGCM/ARCH/OLD/arch-PW7_METO.fcm
===================================================================
--- /branches/2013/dev_CMCC_2013/NEMOGCM/ARCH/OLD/arch-PW7_METO.fcm	(revision 4176)
+++ 	(revision )
@@ -1,29 +1,0 @@
-# IBM POWER6  UKMO
-# 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/home/nwp/ofrd/share/netcdf-3.6.0-p1_ec/include
-%NCDF_LIB            -L /home/nwp/ofrd/share/netcdf-3.6.0-p1_ec/lib -lnetcdf
-%FC                  mpxlf90_r
-%FCFLAGS             -qrealsize=8 -qextname -qsuffix=f=f90 -qarch=pwr7 -qtune=pwr7 -NS32768 -I/home/nwp/ofrd/share/netcdf-3.6.0-p1_ex/include -g -O3 -qnostrict 
-%FFLAGS              -qrealsize=8 -qextname -qsuffix=f=f90 -qarch=pwr7 -qtune=pwr7 -NS32768 -I/home/nwp/ofrd/share/netcdf-3.6.0-p1_ex/include -g -O3 -qnostrict 
-%LD                  mpxlf90_r
-%LDFLAGS             -L /home/nwp/ofrd/share/netcdf-3.6.0-p1_ec/lib -lnetcdf -L/projects/um1/lib -lsig -O3 -L MASS
-%FPPFLAGS            -E -P -traditional -I/opt/ibmhpc/pecurrent/ppe.poe/include -I/usr/lpp/ppe.poe/include/thread64
-%AR                  ar
-%ARFLAGS             rs
-%MK                  gmake
-%USER_INC            %NCDF_INC
-%USER_LIB            %NCDF_LIB
Index: /branches/2013/dev_CMCC_2013/NEMOGCM/ARCH/arch-PW7_METO.fcm
===================================================================
--- /branches/2013/dev_CMCC_2013/NEMOGCM/ARCH/arch-PW7_METO.fcm	(revision 4177)
+++ /branches/2013/dev_CMCC_2013/NEMOGCM/ARCH/arch-PW7_METO.fcm	(revision 4177)
@@ -0,0 +1,30 @@
+# IBM POWER6  UKMO
+# 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/home/nwp/nm/frrj/lib/MTOOLS/include
+%NCDF_LIB            -L/home/nwp/nm/frrj/lib/MTOOLS/lib -lnetcdf -lhdf5 -lhdf5_hl -lhdf5_fortran -lz
+%XIOS_ROOT           /home/cr/ocean/hadcv/xios_r445
+%FC                  mpxlf90_r
+%FCFLAGS             -qrealsize=8 -qextname -qsuffix=f=f90 -qarch=pwr7 -qtune=pwr7 -NS32768 -I/home/nwp/nm/frrj/lib/MTOOLS/include -g -O3 -qnostrict
+%FFLAGS              -qrealsize=8 -qextname -qsuffix=f=f90 -qarch=pwr7 -qtune=pwr7 -NS32768 -I/home/nwp/nm/frrj/lib/MTOOLS/include -g -O3 -qnostrict
+%LD                  mpCC_r
+%LDFLAGS             -lxlf90 -L/home/nwp/nm/frrj/lib/MTOOLS/lib -lnetcdf -L/projects/um1/lib -lsig -O3 -L MASS
+%FPPFLAGS            -E -P -traditional -I/opt/ibmhpc/pecurrent/ppe.poe/include -I/usr/lpp/ppe.poe/include/thread64
+%AR                  ar
+%ARFLAGS             rs
+%MK                  gmake
+%USER_INC            %NCDF_INC -I%XIOS_ROOT/inc
+%USER_LIB            %NCDF_LIB -L%XIOS_ROOT/lib -lxios
Index: /branches/2013/dev_CMCC_2013/NEMOGCM/NEMO/NST_SRC/agrif_opa_sponge.F90
===================================================================
--- /branches/2013/dev_CMCC_2013/NEMOGCM/NEMO/NST_SRC/agrif_opa_sponge.F90	(revision 4176)
+++ /branches/2013/dev_CMCC_2013/NEMOGCM/NEMO/NST_SRC/agrif_opa_sponge.F90	(revision 4177)
@@ -185,71 +185,121 @@
       INTEGER  :: ji,jj,jk
       INTEGER  :: ispongearea, ilci, ilcj
-      REAL(wp) :: z1spongearea
-      REAL(wp), POINTER, DIMENSION(:,:) :: zlocalviscsponge
+      LOGICAL  :: ll_spdone
+      REAL(wp) :: z1spongearea, zramp
+      REAL(wp), POINTER, DIMENSION(:,:) :: ztabramp
 
 #if defined SPONGE || defined SPONGE_TOP
-
-      CALL wrk_alloc( jpi, jpj, zlocalviscsponge )
-
-      ispongearea  = 2 + 2 * Agrif_irhox()
-      ilci = nlci - ispongearea
-      ilcj = nlcj - ispongearea 
-      z1spongearea = 1._wp / REAL( ispongearea - 2 )
-      spbtr2(:,:) = 1. / ( e1t(:,:) * e2t(:,:) )
+      ll_spdone=.TRUE.
+      IF (( .NOT. spongedoneT ).OR.( .NOT. spongedoneU )) THEN
+         ! Define ramp from boundaries towards domain interior
+         ! at T-points
+         ! Store it in ztabramp
+         ll_spdone=.FALSE.
+
+         CALL wrk_alloc( jpi, jpj, ztabramp )
+
+         ispongearea  = 2 + 2 * Agrif_irhox()
+         ilci = nlci - ispongearea
+         ilcj = nlcj - ispongearea 
+         z1spongearea = 1._wp / REAL( ispongearea - 2 )
+         spbtr2(:,:) = 1. / ( e1t(:,:) * e2t(:,:) )
+
+         ztabramp(:,:) = 0.
+
+         IF( (nbondi == -1) .OR. (nbondi == 2) ) THEN
+            DO jj = 1, jpj
+               IF ( umask(2,jj,1) == 1._wp ) THEN
+                 DO ji = 2, ispongearea                  
+                    ztabramp(ji,jj) = ( ispongearea-ji ) * z1spongearea
+                 END DO
+               ENDIF
+            ENDDO
+         ENDIF
+
+         IF( (nbondi == 1) .OR. (nbondi == 2) ) THEN
+            DO jj = 1, jpj
+               IF ( umask(nlci-2,jj,1) == 1._wp ) THEN
+                  DO ji = ilci+1,nlci-1
+                     zramp = (ji - (ilci+1) ) * z1spongearea
+                     ztabramp(ji,jj) = MAX( ztabramp(ji,jj), zramp )
+                  ENDDO
+               ENDIF
+            ENDDO
+         ENDIF
+
+         IF( (nbondj == -1) .OR. (nbondj == 2) ) THEN
+            DO ji = 1, jpi
+               IF ( vmask(ji,2,1) == 1._wp ) THEN
+                  DO jj = 2, ispongearea
+                     zramp = ( ispongearea-jj ) * z1spongearea
+                     ztabramp(ji,jj) = MAX( ztabramp(ji,jj), zramp )
+                  END DO
+               ENDIF
+            ENDDO
+         ENDIF
+
+         IF( (nbondj == 1) .OR. (nbondj == 2) ) THEN
+            DO ji = 1, jpi
+               IF ( vmask(ji,nlcj-2,1) == 1._wp ) THEN
+                  DO jj = ilcj+1,nlcj-1
+                     zramp = (jj - (ilcj+1) ) * z1spongearea
+                     ztabramp(ji,jj) = MAX( ztabramp(ji,jj), zramp )
+                  END DO
+               ENDIF
+            ENDDO
+         ENDIF
+
+      ENDIF
 
       ! Tracers
       IF( .NOT. spongedoneT ) THEN
-         zlocalviscsponge(:,:) = 0.
          spe1ur(:,:) = 0.
          spe2vr(:,:) = 0.
 
          IF( (nbondi == -1) .OR. (nbondi == 2) ) THEN
-            DO ji = 2, ispongearea
-               zlocalviscsponge(ji,:) = visc_tra * ( ispongearea-ji ) * z1spongearea
-            ENDDO
-            spe1ur(2:ispongearea-1,:      ) = 0.5 * ( zlocalviscsponge(2:ispongearea-1,:      )   &
-               &                         +            zlocalviscsponge(3:ispongearea  ,:      ) ) &
-               &                         * e2u(2:ispongearea-1,:      ) / e1u(2:ispongearea-1,:      )
-            spe2vr(2:ispongearea  ,1:jpjm1) = 0.5 * ( zlocalviscsponge(2:ispongearea  ,1:jpjm1)   &
-               &                         +            zlocalviscsponge(2:ispongearea,2  :jpj  ) ) &
-               &                         * e1v(2:ispongearea  ,1:jpjm1) / e2v(2:ispongearea  ,1:jpjm1)
+            spe1ur(2:ispongearea-1,:       ) = visc_tra                                        &
+               &                             *    0.5 * (  ztabramp(2:ispongearea-1,:      )   &
+               &                                         + ztabramp(3:ispongearea  ,:      ) ) &
+               &                             * e2u(2:ispongearea-1,:) / e1u(2:ispongearea-1,:)
+
+            spe2vr(2:ispongearea  ,1:jpjm1 ) = visc_tra                                        &
+               &                             *    0.5 * (  ztabramp(2:ispongearea  ,1:jpjm1)   &
+               &                                         + ztabramp(2:ispongearea,2  :jpj  ) ) &
+               &                             * e1v(2:ispongearea,1:jpjm1) / e2v(2:ispongearea,1:jpjm1)
          ENDIF
 
          IF( (nbondi == 1) .OR. (nbondi == 2) ) THEN
-            DO ji = ilci+1,nlci-1
-               zlocalviscsponge(ji,:) = visc_tra * (ji - (ilci+1) ) * z1spongearea
-            ENDDO
-  
-            spe1ur(ilci+1:nlci-2,:      ) = 0.5 * (  zlocalviscsponge(ilci+1:nlci-2,:)    & 
-               &                          +          zlocalviscsponge(ilci+2:nlci-1,:) )  &
-               &                          * e2u(ilci+1:nlci-2,:) / e1u(ilci+1:nlci-2,:)
-
-            spe2vr(ilci+1:nlci-1,1:jpjm1) = 0.5 * (  zlocalviscsponge(ilci+1:nlci-1,1:jpjm1)    & 
-               &                            +        zlocalviscsponge(ilci+1:nlci-1,2:jpj  )  ) & 
-               &                                   * e1v(ilci+1:nlci-1,1:jpjm1) / e2v(ilci+1:nlci-1,1:jpjm1)
+            spe1ur(ilci+1:nlci-2,:        ) = visc_tra                                   &
+               &                            * 0.5 * (  ztabramp(ilci+1:nlci-2,:      )   & 
+               &                                     + ztabramp(ilci+2:nlci-1,:      ) ) &
+               &                            * e2u(ilci+1:nlci-2,:) / e1u(ilci+1:nlci-2,:)
+
+            spe2vr(ilci+1:nlci-1,1:jpjm1  )  = visc_tra                                  &
+               &                            * 0.5 * (  ztabramp(ilci+1:nlci-1,1:jpjm1)   & 
+               &                                     + ztabramp(ilci+1:nlci-1,2:jpj  ) ) & 
+               &                            * e1v(ilci+1:nlci-1,1:jpjm1) / e2v(ilci+1:nlci-1,1:jpjm1)
          ENDIF
 
          IF( (nbondj == -1) .OR. (nbondj == 2) ) THEN
-            DO jj = 2, ispongearea
-               zlocalviscsponge(:,jj) = visc_tra * ( ispongearea-jj ) * z1spongearea
-            ENDDO
-            spe1ur(1:jpim1,2:ispongearea  ) = 0.5 * ( zlocalviscsponge(1:jpim1,2:ispongearea  ) & 
-               &                            +         zlocalviscsponge(2:jpi  ,2:ispongearea) ) &
+            spe1ur(1:jpim1,2:ispongearea  ) = visc_tra                                     &
+               &                            * 0.5 * (  ztabramp(1:jpim1,2:ispongearea  )   & 
+               &                                     + ztabramp(2:jpi  ,2:ispongearea  ) ) &
                &                            * e2u(1:jpim1,2:ispongearea) / e1u(1:jpim1,2:ispongearea)
    
-            spe2vr(:      ,2:ispongearea-1) = 0.5 * ( zlocalviscsponge(:,2:ispongearea-1)       &
-               &                            +         zlocalviscsponge(:,3:ispongearea  )     ) &
+            spe2vr(:      ,2:ispongearea-1) = visc_tra                                     &
+               &                            * 0.5 * (  ztabramp(:      ,2:ispongearea-1)   &
+               &                                     + ztabramp(:      ,3:ispongearea  ) ) &
                &                            * e1v(:,2:ispongearea-1) / e2v(:,2:ispongearea-1)
          ENDIF
 
          IF( (nbondj == 1) .OR. (nbondj == 2) ) THEN
-            DO jj = ilcj+1,nlcj-1
-               zlocalviscsponge(:,jj) = visc_tra * (jj - (ilcj+1) ) * z1spongearea
-            ENDDO
-            spe1ur(1:jpim1,ilcj+1:nlcj-1) = 0.5 * ( zlocalviscsponge(1:jpim1,ilcj+1:nlcj-1)   &
-               &                          +         zlocalviscsponge(2:jpi  ,ilcj+1:nlcj-1) ) &
+            spe1ur(1:jpim1,ilcj+1:nlcj-1) = visc_tra                                   &
+               &                          * 0.5 * (  ztabramp(1:jpim1,ilcj+1:nlcj-1)   &
+               &                                   + ztabramp(2:jpi  ,ilcj+1:nlcj-1) ) &
                &                                * e2u(1:jpim1,ilcj+1:nlcj-1) / e1u(1:jpim1,ilcj+1:nlcj-1)
-            spe2vr(:      ,ilcj+1:nlcj-2) = 0.5 * ( zlocalviscsponge(:,ilcj+1:nlcj-2      )   &
-               &                          +         zlocalviscsponge(:,ilcj+2:nlcj-1)     )   &
+
+            spe2vr(:      ,ilcj+1:nlcj-2) = visc_tra                                   &
+               &                          * 0.5 * (  ztabramp(:      ,ilcj+1:nlcj-2)   &
+               &                                   + ztabramp(:      ,ilcj+2:nlcj-1) ) &
                &                                * e1v(:,ilcj+1:nlcj-2) / e2v(:,ilcj+1:nlcj-2)
          ENDIF
@@ -259,46 +309,41 @@
       ! Dynamics
       IF( .NOT. spongedoneU ) THEN
-         zlocalviscsponge(:,:) = 0.
          spe1ur2(:,:) = 0.
          spe2vr2(:,:) = 0.
 
          IF( (nbondi == -1) .OR. (nbondi == 2) ) THEN
-            DO ji = 2, ispongearea
-               zlocalviscsponge(ji,:) = visc_dyn * ( ispongearea-ji ) * z1spongearea
-            ENDDO
-            spe1ur2(2:ispongearea-1,:      ) = 0.5 * ( zlocalviscsponge(2:ispongearea-1,:      ) &
-                                             &     +   zlocalviscsponge(3:ispongearea,:    ) )
-            spe2vr2(2:ispongearea  ,1:jpjm1) = 0.5 * ( zlocalviscsponge(2:ispongearea  ,1:jpjm1) &
-                                             &     +   zlocalviscsponge(2:ispongearea,2:jpj) ) 
+            spe1ur2(2:ispongearea-1,:      ) = visc_dyn                                   &
+               &                             * 0.5 * (  ztabramp(2:ispongearea-1,:      ) &
+               &                                      + ztabramp(3:ispongearea  ,:      ) )
+            spe2vr2(2:ispongearea  ,1:jpjm1) = visc_dyn                                   &
+               &                             * 0.5 * (  ztabramp(2:ispongearea  ,1:jpjm1) &
+               &                                      + ztabramp(2:ispongearea  ,2:jpj  ) ) 
          ENDIF
 
          IF( (nbondi == 1) .OR. (nbondi == 2) ) THEN
-            DO ji = ilci+1,nlci-1
-               zlocalviscsponge(ji,:) = visc_dyn * (ji - (ilci+1) ) * z1spongearea
-            ENDDO
-            spe1ur2(ilci+1:nlci-2,:      ) = 0.5 * (  zlocalviscsponge(ilci+1:nlci-2,:) &
-                                           &        + zlocalviscsponge(ilci+2:nlci-1,:) )  
-            spe2vr2(ilci+1:nlci-1,1:jpjm1) = 0.5 * (  zlocalviscsponge(ilci+1:nlci-1,1:jpjm1) &
-                                           &        + zlocalviscsponge(ilci+1:nlci-1,2:jpj  )  ) 
+            spe1ur2(ilci+1:nlci-2  ,:      ) = visc_dyn                                   &
+               &                             * 0.5 * (  ztabramp(ilci+1:nlci-2, :       ) &
+               &                                      + ztabramp(ilci+2:nlci-1, :       ) )                      
+            spe2vr2(ilci+1:nlci-1  ,1:jpjm1) = visc_dyn                                   &
+               &                             * 0.5 * (  ztabramp(ilci+1:nlci-1,1:jpjm1  ) &
+               &                                      + ztabramp(ilci+1:nlci-1,2:jpj    ) ) 
          ENDIF
 
          IF( (nbondj == -1) .OR. (nbondj == 2) ) THEN
-            DO jj = 2, ispongearea
-               zlocalviscsponge(:,jj) = visc_dyn * ( ispongearea-jj ) * z1spongearea
-            ENDDO
-            spe1ur2(1:jpim1,2:ispongearea  ) = 0.5 * ( zlocalviscsponge(1:jpim1,2:ispongearea) &
-                                             &      + zlocalviscsponge(2:jpi,2:ispongearea) ) 
-            spe2vr2(:      ,2:ispongearea-1) = 0.5 * ( zlocalviscsponge(:,2:ispongearea-1)     &
-                                             &      + zlocalviscsponge(:,3:ispongearea)     )
+            spe1ur2(1:jpim1,2:ispongearea  ) = visc_dyn                                   &  
+               &                             * 0.5 * (  ztabramp(1:jpim1,2:ispongearea  ) &
+               &                                      + ztabramp(2:jpi  ,2:ispongearea  ) ) 
+            spe2vr2(:      ,2:ispongearea-1) = visc_dyn                                   &
+               &                             * 0.5 * (  ztabramp(:      ,2:ispongearea-1) &
+               &                                      + ztabramp(:      ,3:ispongearea  ) )
          ENDIF
 
          IF( (nbondj == 1) .OR. (nbondj == 2) ) THEN
-            DO jj = ilcj+1,nlcj-1
-               zlocalviscsponge(:,jj) = visc_dyn * (jj - (ilcj+1) ) * z1spongearea
-            ENDDO
-            spe1ur2(1:jpim1,ilcj+1:nlcj-1) = 0.5 * ( zlocalviscsponge(1:jpim1,ilcj+1:nlcj-1) &
-                                           &         + zlocalviscsponge(2:jpi,ilcj+1:nlcj-1) ) 
-            spe2vr2(:      ,ilcj+1:nlcj-2) = 0.5 * ( zlocalviscsponge(:,ilcj+1:nlcj-2      ) &
-                                           &         + zlocalviscsponge(:,ilcj+2:nlcj-1)     )
+            spe1ur2(1:jpim1,ilcj+1:nlcj-1  ) = visc_dyn                                   &
+               &                             * 0.5 * (  ztabramp(1:jpim1,ilcj+1:nlcj-1  ) &
+               &                                      + ztabramp(2:jpi  ,ilcj+1:nlcj-1  ) ) 
+            spe2vr2(:      ,ilcj+1:nlcj-2  ) = visc_dyn                                   &
+               &                             * 0.5 * (  ztabramp(:      ,ilcj+1:nlcj-2  ) &
+               &                                      + ztabramp(:      ,ilcj+2:nlcj-1  ) )
          ENDIF
          spongedoneU = .TRUE.
@@ -306,5 +351,5 @@
       ENDIF
       !
-      CALL wrk_dealloc( jpi, jpj, zlocalviscsponge )
+      IF (.NOT.ll_spdone) CALL wrk_dealloc( jpi, jpj, ztabramp )
       !
 #endif
Index: /branches/2013/dev_CMCC_2013/NEMOGCM/NEMO/OPA_SRC/ASM/asminc.F90
===================================================================
--- /branches/2013/dev_CMCC_2013/NEMOGCM/NEMO/OPA_SRC/ASM/asminc.F90	(revision 4176)
+++ /branches/2013/dev_CMCC_2013/NEMOGCM/NEMO/OPA_SRC/ASM/asminc.F90	(revision 4177)
@@ -682,17 +682,7 @@
       ! used to prevent the applied increments taking the temperature below the local freezing point 
 
-#if defined key_cice 
-        fzptnz(:,:,:) = -1.8_wp
-#else 
-        DO jk = 1, jpk
-           DO jj = 1, jpj
-              DO ji = 1, jpk
-                 fzptnz (ji,jj,jk) = ( -0.0575_wp + 1.710523e-3_wp * SQRT( tsn(ji,jj,jk,jp_sal) )                   & 
-                                                  - 2.154996e-4_wp *       tsn(ji,jj,jk,jp_sal)   ) * tsn(ji,jj,jk,jp_sal)  & 
-                                                  - 7.53e-4_wp * fsdepw(ji,jj,jk)       ! (pressure in dbar) 
-              END DO
-           END DO
-        END DO
-#endif 
+      DO jk=1, jpkm1
+         fzptnz (:,:,jk) = tfreez( tsn(:,:,jk,jp_sal), fsdept(:,:,jk) )
+      ENDDO
 
       IF ( ln_asmiau ) THEN
Index: /branches/2013/dev_CMCC_2013/NEMOGCM/NEMO/OPA_SRC/DIA/diahsb.F90
===================================================================
--- /branches/2013/dev_CMCC_2013/NEMOGCM/NEMO/OPA_SRC/DIA/diahsb.F90	(revision 4176)
+++ /branches/2013/dev_CMCC_2013/NEMOGCM/NEMO/OPA_SRC/DIA/diahsb.F90	(revision 4177)
@@ -21,4 +21,6 @@
    USE bdy_par         ! (for lk_bdy)
    USE timing          ! preformance summary
+   USE lib_fortran
+   USE sbcrnf
 
    IMPLICIT NONE
@@ -33,4 +35,5 @@
    REAL(dp)                                ::   surf_tot   , vol_tot             !
    REAL(dp)                                ::   frc_t      , frc_s     , frc_v   ! global forcing trends
+   REAL(dp)                                ::   frc_wn_t      , frc_wn_s ! global forcing trends
    REAL(dp)                                ::   fact1                            ! conversion factors
    REAL(dp)                                ::   fact21    , fact22               !     -         -
@@ -38,4 +41,5 @@
    REAL(dp), DIMENSION(:,:)  , ALLOCATABLE ::   surf      , ssh_ini              !
    REAL(dp), DIMENSION(:,:,:), ALLOCATABLE ::   hc_loc_ini, sc_loc_ini, e3t_ini  !
+   REAL(dp), DIMENSION(:,:)  , ALLOCATABLE ::   ssh_hc_loc_ini, ssh_sc_loc_ini
 
    !! * Substitutions
@@ -67,9 +71,13 @@
       INTEGER    ::   jk                          ! dummy loop indice
       REAL(dp)   ::   zdiff_hc    , zdiff_sc      ! heat and salt content variations
+      REAL(dp)   ::   zdiff_hc1   , zdiff_sc1     ! heat and salt content variations of ssh
       REAL(dp)   ::   zdiff_v1    , zdiff_v2      ! volume variation
+      REAL(dp)   ::   zerr_hc1    , zerr_sc1      ! Non conservation due to free surface
       REAL(dp)   ::   z1_rau0                     ! local scalars
       REAL(dp)   ::   zdeltat                     !    -     -
       REAL(dp)   ::   z_frc_trd_t , z_frc_trd_s   !    -     -
       REAL(dp)   ::   z_frc_trd_v                 !    -     -
+      REAL(dp)   ::   z_wn_trd_t , z_wn_trd_s   !    -     -
+      REAL(dp)   ::   z_ssh_hc , z_ssh_sc   !    -     -
       !!---------------------------------------------------------------------------
       IF( nn_timing == 1 )   CALL timing_start('dia_hsb')
@@ -79,18 +87,27 @@
       ! ------------------------- !
       z1_rau0 = 1.e0 / rau0
-      z_frc_trd_v = z1_rau0 * SUM( - ( emp(:,:) - rnf(:,:) ) * surf(:,:) )     ! volume fluxes
-      z_frc_trd_t =           SUM( sbc_tsc(:,:,jp_tem) * surf(:,:) )     ! heat fluxes
-      z_frc_trd_s =           SUM( sbc_tsc(:,:,jp_sal) * surf(:,:) )     ! salt fluxes
+      z_frc_trd_v = z1_rau0 * glob_sum( - ( emp(:,:) - rnf(:,:) ) * surf(:,:) )     ! volume fluxes
+      z_frc_trd_t =           glob_sum( sbc_tsc(:,:,jp_tem) * surf(:,:) )     ! heat fluxes
+      z_frc_trd_s =           glob_sum( sbc_tsc(:,:,jp_sal) * surf(:,:) )     ! salt fluxes
+      ! Add runoff heat & salt input
+      IF( ln_rnf    )   z_frc_trd_t = z_frc_trd_t + glob_sum( rnf_tsc(:,:,jp_tem) * surf(:,:) )
+      IF( ln_rnf_sal)   z_frc_trd_s = z_frc_trd_s + glob_sum( rnf_tsc(:,:,jp_sal) * surf(:,:) )
       ! Add penetrative solar radiation
-      IF( ln_traqsr )   z_frc_trd_t = z_frc_trd_t + r1_rau0_rcp * SUM( qsr     (:,:) * surf(:,:) )
+      IF( ln_traqsr )   z_frc_trd_t = z_frc_trd_t + r1_rau0_rcp * glob_sum( qsr     (:,:) * surf(:,:) )
       ! Add geothermal heat flux
-      IF( ln_trabbc )   z_frc_trd_t = z_frc_trd_t + r1_rau0_rcp * SUM( qgh_trd0(:,:) * surf(:,:) )
-      IF( lk_mpp ) THEN
-         CALL mpp_sum( z_frc_trd_v )
-         CALL mpp_sum( z_frc_trd_t )
-      ENDIF
+      IF( ln_trabbc )   z_frc_trd_t = z_frc_trd_t +  glob_sum( qgh_trd0(:,:) * surf(:,:) )
+      IF( .NOT. lk_vvl ) THEN
+         z_wn_trd_t = - glob_sum( surf(:,:) * wn(:,:,1) * tsb(:,:,1,jp_tem) )
+         z_wn_trd_s = - glob_sum( surf(:,:) * wn(:,:,1) * tsb(:,:,1,jp_sal) )
+      ENDIF
+
       frc_v = frc_v + z_frc_trd_v * rdt
       frc_t = frc_t + z_frc_trd_t * rdt
       frc_s = frc_s + z_frc_trd_s * rdt
+      !                                          ! Advection flux through fixed surface (z=0)
+      IF( .NOT. lk_vvl ) THEN
+         frc_wn_t = frc_wn_t + z_wn_trd_t * rdt
+         frc_wn_s = frc_wn_s + z_wn_trd_s * rdt
+      ENDIF
 
       ! ----------------------- !
@@ -100,33 +117,40 @@
       zdiff_hc = 0.d0
       zdiff_sc = 0.d0
+
       ! volume variation (calculated with ssh)
-      zdiff_v1 = SUM( surf(:,:) * tmask(:,:,1) * ( sshn(:,:) - ssh_ini(:,:) ) )
+      zdiff_v1 = glob_sum( surf(:,:) * ( sshn(:,:) - ssh_ini(:,:) ) )
+
+      ! heat & salt content variation (associated with ssh)
+      IF( .NOT. lk_vvl ) THEN
+         z_ssh_hc = glob_sum( surf(:,:) * ( tsn(:,:,1,jp_tem) * sshn(:,:) - ssh_hc_loc_ini(:,:) ) )
+         z_ssh_sc = glob_sum( surf(:,:) * ( tsn(:,:,1,jp_sal) * sshn(:,:) - ssh_sc_loc_ini(:,:) ) )
+      ENDIF
+
       DO jk = 1, jpkm1
-         ! volume variation (calculated with scale factors)
-         zdiff_v2 = zdiff_v2 + SUM( surf(:,:) * tmask(:,:,jk)   &
+        ! volume variation (calculated with scale factors)
+         zdiff_v2 = zdiff_v2 + glob_sum( surf(:,:) * tmask(:,:,jk)   &
             &                       * ( fse3t_n(:,:,jk)         &
             &                           - e3t_ini(:,:,jk) ) )
          ! heat content variation
-         zdiff_hc = zdiff_hc + SUM( surf(:,:) * tmask(:,:,jk)          &
+         zdiff_hc = zdiff_hc + glob_sum( surf(:,:) * tmask(:,:,jk)          &
             &                       * ( fse3t_n(:,:,jk) * tsn(:,:,jk,jp_tem)   &
             &                           - hc_loc_ini(:,:,jk) ) )
          ! salt content variation
-         zdiff_sc = zdiff_sc + SUM( surf(:,:) * tmask(:,:,jk)          &
+         zdiff_sc = zdiff_sc + glob_sum( surf(:,:) * tmask(:,:,jk)          &
             &                       * ( fse3t_n(:,:,jk) * tsn(:,:,jk,jp_sal)   &
             &                           - sc_loc_ini(:,:,jk) ) )
       ENDDO
 
-      IF( lk_mpp ) THEN
-         CALL mpp_sum( zdiff_hc )
-         CALL mpp_sum( zdiff_sc )
-         CALL mpp_sum( zdiff_v1 )
-         CALL mpp_sum( zdiff_v2 )
-      ENDIF
-
       ! Substract forcing from heat content, salt content and volume variations
       zdiff_v1 = zdiff_v1 - frc_v
-      zdiff_v2 = zdiff_v2 - frc_v
+      IF( lk_vvl )   zdiff_v2 = zdiff_v2 - frc_v
       zdiff_hc = zdiff_hc - frc_t
       zdiff_sc = zdiff_sc - frc_s
+      IF( .NOT. lk_vvl ) THEN
+         zdiff_hc1 = zdiff_hc + z_ssh_hc 
+         zdiff_sc1 = zdiff_sc + z_ssh_sc
+         zerr_hc1  = z_ssh_hc - frc_wn_t
+         zerr_sc1  = z_ssh_sc - frc_wn_s
+      ENDIF
       
       ! ----------------------- !
@@ -134,8 +158,15 @@
       ! ----------------------- !
       zdeltat  = 1.e0 / ( ( kt - nit000 + 1 ) * rdt )
-      WRITE(numhsb , 9020) kt , zdiff_hc / vol_tot , zdiff_hc * fact1  * zdeltat,                                &
-         &                      zdiff_sc / vol_tot , zdiff_sc * fact21 * zdeltat, zdiff_sc * fact22 * zdeltat,   &
-         &                      zdiff_v1           , zdiff_v1 * fact31 * zdeltat, zdiff_v1 * fact32 * zdeltat,   &
-         &                      zdiff_v2           , zdiff_v2 * fact31 * zdeltat, zdiff_v2 * fact32 * zdeltat
+      IF( lk_vvl ) THEN
+         WRITE(numhsb , 9020) kt , zdiff_hc / vol_tot , zdiff_hc * fact1  * zdeltat,                                &
+            &                      zdiff_sc / vol_tot , zdiff_sc * fact21 * zdeltat, zdiff_sc * fact22 * zdeltat,   &
+            &                      zdiff_v1           , zdiff_v1 * fact31 * zdeltat, zdiff_v1 * fact32 * zdeltat,   &
+            &                      zdiff_v2           , zdiff_v2 * fact31 * zdeltat, zdiff_v2 * fact32 * zdeltat
+      ELSE
+         WRITE(numhsb , 9030) kt , zdiff_hc1 / vol_tot , zdiff_hc1 * fact1  * zdeltat,                                &
+            &                      zdiff_sc1 / vol_tot , zdiff_sc1 * fact21 * zdeltat, zdiff_sc1 * fact22 * zdeltat,   &
+            &                      zdiff_v1            , zdiff_v1  * fact31 * zdeltat, zdiff_v1  * fact32 * zdeltat,   &
+            &                      zerr_hc1 / vol_tot  , zerr_sc1 / vol_tot
+      ENDIF
 
       IF ( kt == nitend ) CLOSE( numhsb )
@@ -144,4 +175,5 @@
 
 9020  FORMAT(I5,11D15.7)
+9030  FORMAT(I5,10D15.7)
       !
    END SUBROUTINE dia_hsb
@@ -179,27 +211,18 @@
 
       IF( .NOT. ln_diahsb )   RETURN
+      IF( .NOT. lk_mpp_rep ) &
+        CALL ctl_stop (' Your global mpp_sum if performed in single precision - 64 bits -', &
+             &         ' whereas the global sum to be precise must be done in double precision ',&
+             &         ' please add key_mpp_rep')
 
       ! ------------------- !
       ! 1 - Allocate memory !
       ! ------------------- !
-      ALLOCATE( hc_loc_ini(jpi,jpj,jpk), STAT=ierror )
+      ALLOCATE( hc_loc_ini(jpi,jpj,jpk), sc_loc_ini(jpi,jpj,jpk), &
+         &      ssh_hc_loc_ini(jpi,jpj), ssh_sc_loc_ini(jpi,jpj), &
+         &      e3t_ini(jpi,jpj,jpk)                            , &
+         &      surf(jpi,jpj),  ssh_ini(jpi,jpj), STAT=ierror )
       IF( ierror > 0 ) THEN
          CALL ctl_stop( 'dia_hsb: unable to allocate hc_loc_ini' )   ;   RETURN
-      ENDIF
-      ALLOCATE( sc_loc_ini(jpi,jpj,jpk), STAT=ierror )
-      IF( ierror > 0 ) THEN
-         CALL ctl_stop( 'dia_hsb: unable to allocate sc_loc_ini' )   ;   RETURN
-      ENDIF
-      ALLOCATE( e3t_ini(jpi,jpj,jpk)   , STAT=ierror )
-      IF( ierror > 0 ) THEN
-         CALL ctl_stop( 'dia_hsb: unable to allocate e3t_ini' )      ;   RETURN
-      ENDIF
-      ALLOCATE( surf(jpi,jpj)          , STAT=ierror )
-      IF( ierror > 0 ) THEN
-         CALL ctl_stop( 'dia_hsb: unable to allocate surf' )         ;   RETURN
-      ENDIF
-      ALLOCATE( ssh_ini(jpi,jpj)       , STAT=ierror )
-      IF( ierror > 0 ) THEN
-         CALL ctl_stop( 'dia_hsb: unable to allocate ssh_ini' )      ;   RETURN
       ENDIF
 
@@ -214,26 +237,33 @@
       cl_name    = 'heat_salt_volume_budgets.txt'                         ! name of output file
       surf(:,:) = e1t(:,:) * e2t(:,:) * tmask(:,:,1) * tmask_i(:,:)      ! masked surface grid cell area
-      surf_tot  = SUM( surf(:,:) )                                       ! total ocean surface area
+      surf_tot  = glob_sum( surf(:,:) )                                       ! total ocean surface area
       vol_tot   = 0.d0                                                   ! total ocean volume
       DO jk = 1, jpkm1
-         vol_tot  = vol_tot + SUM( surf(:,:) * tmask(:,:,jk)     &
-            &                      * fse3t_n(:,:,jk)         )
+         vol_tot  = vol_tot + glob_sum( surf(:,:) * tmask(:,:,jk)     &
+            &                         * fse3t_n(:,:,jk)         )
       END DO
-      IF( lk_mpp ) THEN 
-         CALL mpp_sum( vol_tot )
-         CALL mpp_sum( surf_tot )
-      ENDIF
 
       CALL ctl_opn( numhsb , cl_name , 'UNKNOWN' , 'FORMATTED' , 'SEQUENTIAL' , 1 , numout , lwp , 1 )
-      !                   12345678901234567890123456789012345678901234567890123456789012345678901234567890 -> 80
-      WRITE( numhsb, 9010 ) "kt   |     heat content budget     |            salt content budget             ",   &
-         !                                                   123456789012345678901234567890123456789012345 -> 45
-         &                                                  "|            volume budget (ssh)             ",   &
-         !                                                   678901234567890123456789012345678901234567890 -> 45
-         &                                                  "|            volume budget (e3t)             "
-      WRITE( numhsb, 9010 ) "     |      [C]         [W/m2]     |     [psu]        [mmm/s]          [SV]     ",   &
-         &                                                  "|     [m3]         [mmm/s]          [SV]     ",   &
-         &                                                  "|     [m3]         [mmm/s]          [SV]     "
-
+      IF( lk_vvl ) THEN
+         !                   12345678901234567890123456789012345678901234567890123456789012345678901234567890 -> 80
+         WRITE( numhsb, 9010 ) "kt   |     heat content budget     |            salt content budget             ",   &
+            !                                                   123456789012345678901234567890123456789012345 -> 45
+            &                                                  "|            volume budget (ssh)             ",   &
+            !                                                   678901234567890123456789012345678901234567890 -> 45
+            &                                                  "|            volume budget (e3t)             "
+         WRITE( numhsb, 9010 ) "     |      [C]         [W/m2]     |     [psu]        [mmm/s]          [SV]     ",   &
+            &                                                  "|     [m3]         [mmm/s]          [SV]     ",   &
+            &                                                  "|     [m3]         [mmm/s]          [SV]     "
+      ELSE
+         !                   12345678901234567890123456789012345678901234567890123456789012345678901234567890 -> 80
+         WRITE( numhsb, 9011 ) "kt   |     heat content budget     |            salt content budget             ",   &
+            !                                                   123456789012345678901234567890123456789012345 -> 45
+            &                                                  "|            volume budget (ssh)             ",   &
+            !                                                   678901234567890123456789012345678901234567890 -> 45
+            &                                                  "|  Non conservation due to free surface      "
+         WRITE( numhsb, 9011 ) "     |      [C]         [W/m2]     |     [psu]        [mmm/s]          [SV]     ",   &
+            &                                                  "|     [m3]         [mmm/s]          [SV]     ",   &
+            &                                                  "|  [heat - C]     [salt - psu]                "
+      ENDIF
       ! --------------- !
       ! 3 - Conversions ! (factors will be multiplied by duration afterwards)
@@ -261,6 +291,13 @@
       frc_t = 0.d0                                           ! heat content   -    -   -    -   
       frc_s = 0.d0                                           ! salt content   -    -   -    -         
+      IF( .NOT. lk_vvl ) THEN
+         ssh_hc_loc_ini(:,:) = tsn(:,:,1,jp_tem) * ssh_ini(:,:)   ! initial heat content associated with ssh
+         ssh_sc_loc_ini(:,:) = tsn(:,:,1,jp_sal) * ssh_ini(:,:)   ! initial salt content associated with ssh
+         frc_wn_t = 0.d0
+         frc_wn_s = 0.d0
+      ENDIF
       !
 9010  FORMAT(A80,A45,A45)
+9011  FORMAT(A80,A45,A45)
       !
    END SUBROUTINE dia_hsb_init
Index: /branches/2013/dev_CMCC_2013/NEMOGCM/NEMO/OPA_SRC/DOM/closea.F90
===================================================================
--- /branches/2013/dev_CMCC_2013/NEMOGCM/NEMO/OPA_SRC/DOM/closea.F90	(revision 4176)
+++ /branches/2013/dev_CMCC_2013/NEMOGCM/NEMO/OPA_SRC/DOM/closea.F90	(revision 4177)
@@ -108,15 +108,18 @@
             ncsi1(2)   =  97  ;  ncsj1(2)   = 107
             ncsi2(2)   = 103  ;  ncsj2(2)   = 111
-            ncsir(2,1) = 110  ;  ncsjr(2,1) = 111
-            !                                            ! Black Sea 1 : west part of the Black Sea 
-            ncsnr(3)   = 1    ; ncstt(3)   =   2            !            (ie west of the cyclic b.c.)
-            ncsi1(3)   = 174  ; ncsj1(3)   = 107            ! put in Med Sea
-            ncsi2(3)   = 181  ; ncsj2(3)   = 112
-            ncsir(3,1) = 171  ; ncsjr(3,1) = 106 
-            !                                            ! Black Sea 2 : est part of the Black Sea 
-            ncsnr(4)   =   1  ;  ncstt(4)   =   2           !               (ie est of the cyclic b.c.)
-            ncsi1(4)   =   2  ;  ncsj1(4)   = 107           ! put in Med Sea
-            ncsi2(4)   =   6  ;  ncsj2(4)   = 112
-            ncsir(4,1) = 171  ;  ncsjr(4,1) = 106 
+            ncsir(2,1) = 110  ;  ncsjr(2,1) = 111           
+            !                                            ! Black Sea (crossed by the cyclic boundary condition)
+            ncsnr(3:4) =   4  ;  ncstt(3:4) =   2           ! put in Med Sea (north of Aegean Sea)
+            ncsir(3:4,1) = 171;  ncsjr(3:4,1) = 106         !
+            ncsir(3:4,2) = 170;  ncsjr(3:4,2) = 106 
+            ncsir(3:4,3) = 171;  ncsjr(3:4,3) = 105 
+            ncsir(3:4,4) = 170;  ncsjr(3:4,4) = 105 
+            ncsi1(3)   = 174  ;  ncsj1(3)   = 107           ! 1 : west part of the Black Sea      
+            ncsi2(3)   = 181  ;  ncsj2(3)   = 112           !            (ie west of the cyclic b.c.)
+            ncsi1(4)   =   2  ;  ncsj1(4)   = 107           ! 2 : east part of the Black Sea 
+            ncsi2(4)   =   6  ;  ncsj2(4)   = 112           !           (ie east of the cyclic b.c.)
+             
+          
+
             !                                        ! =======================
          CASE ( 4 )                                  !  ORCA_R4 configuration
@@ -372,6 +375,5 @@
       REAL(wp), DIMENSION(jpi,jpj), INTENT(inout) ::   p_rnfmsk   ! river runoff mask (rnfmsk array)
       !
-      INTEGER  ::   jc, jn      ! dummy loop indices
-      INTEGER  ::   ii, ij      ! temporary integer
+      INTEGER  ::   jc, jn, ji, jj      ! dummy loop indices
       !!----------------------------------------------------------------------
       !
@@ -379,7 +381,9 @@
          IF( ncstt(jc) >= 1 ) THEN            ! runoff mask set to 1 at closed sea outflows
              DO jn = 1, 4
-               ii = mi0( ncsir(jc,jn) )
-               ij = mj0( ncsjr(jc,jn) )
-               p_rnfmsk(ii,ij) = MAX( p_rnfmsk(ii,ij), 1.0_wp )
+                DO jj =    mj0( ncsjr(jc,jn) ), mj1( ncsjr(jc,jn) )
+                   DO ji = mi0( ncsir(jc,jn) ), mi1( ncsir(jc,jn) )
+                      p_rnfmsk(ji,jj) = MAX( p_rnfmsk(ji,jj), 1.0_wp )
+                   END DO
+                END DO
             END DO 
          ENDIF 
Index: /branches/2013/dev_CMCC_2013/NEMOGCM/NEMO/OPA_SRC/DOM/daymod.F90
===================================================================
--- /branches/2013/dev_CMCC_2013/NEMOGCM/NEMO/OPA_SRC/DOM/daymod.F90	(revision 4176)
+++ /branches/2013/dev_CMCC_2013/NEMOGCM/NEMO/OPA_SRC/DOM/daymod.F90	(revision 4177)
@@ -238,4 +238,9 @@
                nday_year = 1
                nsec_year = ndt05
+               IF( nsec1jan000 >= 2 * (2**30 - nsecd * nyear_len(1) / 2 ) ) THEN   ! test integer 4 max value
+                  CALL ctl_stop( 'The number of seconds between Jan. 1st 00h of nit000 year and Jan. 1st 00h ',   &
+                     &           'of the current year is exceeding the INTEGER 4 max VALUE: 2^31-1 -> 68.09 years in seconds', &
+                     & 'You must do a restart at higher frequency (or remove this STOP and recompile everything in I8)' )
+               ENDIF
                nsec1jan000 = nsec1jan000 + nsecd * nyear_len(1)
                IF( nleapy == 1 )   CALL day_mth
Index: /branches/2013/dev_CMCC_2013/NEMOGCM/NEMO/OPA_SRC/DOM/domzgr.F90
===================================================================
--- /branches/2013/dev_CMCC_2013/NEMOGCM/NEMO/OPA_SRC/DOM/domzgr.F90	(revision 4176)
+++ /branches/2013/dev_CMCC_2013/NEMOGCM/NEMO/OPA_SRC/DOM/domzgr.F90	(revision 4177)
@@ -1102,9 +1102,6 @@
       INTEGER  ::   iip1, ijp1, iim1, ijm1   ! temporary integers
       REAL(wp) ::   zrmax, ztaper   ! temporary scalars
-      REAL(wp) ::   zrfact   ! temporary scalars
-      REAL(wp), POINTER, DIMENSION(:,:  ) :: ztmpi1, ztmpi2, ztmpj1, ztmpj2
-
-      !
-      REAL(wp), POINTER, DIMENSION(:,:  ) :: zenv, zri, zrj, zhbat
+      !
+      REAL(wp), POINTER, DIMENSION(:,:  ) :: zenv, ztmp, zmsk, zri, zrj, zhbat
 
       NAMELIST/namzgr_sco/ln_s_sh94, ln_s_sf12, ln_sigcrit, rn_sbot_min, rn_sbot_max, rn_hc, rn_rmax,rn_theta, &
@@ -1114,7 +1111,6 @@
       IF( nn_timing == 1 )  CALL timing_start('zgr_sco')
       !
-      CALL wrk_alloc( jpi, jpj,      ztmpi1, ztmpi2, ztmpj1, ztmpj2         )
-      CALL wrk_alloc( jpi, jpj,      zenv, zri, zrj, zhbat     )
-     !
+      CALL wrk_alloc( jpi, jpj,      zenv, ztmp, zmsk, zri, zrj, zhbat                           )
+      !
       REWIND( numnam )                       ! Read Namelist namzgr_sco : sigma-stretching parameters
       READ  ( numnam, namzgr_sco )
@@ -1163,11 +1159,9 @@
       !                                        ! =============================
       ! use r-value to create hybrid coordinates
-!     DO jj = 1, jpj
-!        DO ji = 1, jpi
-!           zenv(ji,jj) = MAX( bathy(ji,jj), 0._wp )
-!        END DO
-!     END DO
-!     CALL lbc_lnk( zenv, 'T', 1._wp )
-      zenv(:,:) = bathy(:,:)
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            zenv(ji,jj) = MAX( bathy(ji,jj), rn_sbot_min )
+         END DO
+      END DO
       ! 
       ! Smooth the bathymetry (if required)
@@ -1177,78 +1171,87 @@
       jl = 0
       zrmax = 1._wp
-      !     
-      ! set scaling factor used in reducing vertical gradients
-      zrfact = ( 1._wp - rn_rmax ) / ( 1._wp + rn_rmax ) 
-      !
-      ! initialise temporary evelope depth arrays
-      ztmpi1(:,:) = zenv(:,:)
-      ztmpi2(:,:) = zenv(:,:)
-      ztmpj1(:,:) = zenv(:,:)
-      ztmpj2(:,:) = zenv(:,:)
-      !
-      ! initialise temporary r-value arrays
-      zri(:,:) = 1._wp
-      zrj(:,:) = 1._wp
-      !                                                            ! ================ !
-      DO WHILE( jl <= 10000 .AND. ( zrmax - rn_rmax ) > 1.e-8_wp ) !  Iterative loop  !
-         !                                                         ! ================ !
+      !                                                     ! ================ !
+      DO WHILE( jl <= 10000 .AND. zrmax > rn_rmax )         !  Iterative loop  !
+         !                                                  ! ================ !
          jl = jl + 1
          zrmax = 0._wp
-         ! we set zrmax from previous r-values (zri abd zrj) first
-         ! if set after current r-value calculation (as previously)
-         ! we could exit DO WHILE prematurely before checking r-value
-         ! of current zenv
-         DO jj = 1, nlcj
-            DO ji = 1, nlci
-               zrmax = MAX( zrmax, ABS(zri(ji,jj)), ABS(zrj(ji,jj)) )
-            END DO
-         END DO
-         zri(:,:) = 0._wp
-         zrj(:,:) = 0._wp
+         zmsk(:,:) = 0._wp
          DO jj = 1, nlcj
             DO ji = 1, nlci
                iip1 = MIN( ji+1, nlci )      ! force zri = 0 on last line (ji=ncli+1 to jpi)
                ijp1 = MIN( jj+1, nlcj )      ! force zrj = 0 on last raw  (jj=nclj+1 to jpj)
-               IF( (zenv(ji,jj) > 0._wp) .AND. (zenv(iip1,jj) > 0._wp)) THEN
-                  zri(ji,jj) = ( zenv(iip1,jj  ) - zenv(ji,jj) ) / ( zenv(iip1,jj  ) + zenv(ji,jj) )
-               END IF
-               IF( (zenv(ji,jj) > 0._wp) .AND. (zenv(ji,ijp1) > 0._wp)) THEN
-                  zrj(ji,jj) = ( zenv(ji  ,ijp1) - zenv(ji,jj) ) / ( zenv(ji  ,ijp1) + zenv(ji,jj) )
-               END IF
-               IF( zri(ji,jj) >  rn_rmax )   ztmpi1(ji  ,jj  ) = zenv(iip1,jj  ) * zrfact
-               IF( zri(ji,jj) < -rn_rmax )   ztmpi2(iip1,jj  ) = zenv(ji  ,jj  ) * zrfact 
-               IF( zrj(ji,jj) >  rn_rmax )   ztmpj1(ji  ,jj  ) = zenv(ji  ,ijp1) * zrfact
-               IF( zrj(ji,jj) < -rn_rmax )   ztmpj2(ji  ,ijp1) = zenv(ji  ,jj  ) * zrfact
+               zri(ji,jj) = ABS( zenv(iip1,jj  ) - zenv(ji,jj) ) / ( zenv(iip1,jj  ) + zenv(ji,jj) )
+               zrj(ji,jj) = ABS( zenv(ji  ,ijp1) - zenv(ji,jj) ) / ( zenv(ji  ,ijp1) + zenv(ji,jj) )
+               zrmax = MAX( zrmax, zri(ji,jj), zrj(ji,jj) )
+               IF( zri(ji,jj) > rn_rmax )   zmsk(ji  ,jj  ) = 1._wp
+               IF( zri(ji,jj) > rn_rmax )   zmsk(iip1,jj  ) = 1._wp
+               IF( zrj(ji,jj) > rn_rmax )   zmsk(ji  ,jj  ) = 1._wp
+               IF( zrj(ji,jj) > rn_rmax )   zmsk(ji  ,ijp1) = 1._wp
             END DO
          END DO
          IF( lk_mpp )   CALL mpp_max( zrmax )   ! max over the global domain
+         ! lateral boundary condition on zmsk: keep 1 along closed boundary (use of MAX)
+         ztmp(:,:) = zmsk(:,:)   ;   CALL lbc_lnk( zmsk, 'T', 1._wp )
+         DO jj = 1, nlcj
+            DO ji = 1, nlci
+                zmsk(ji,jj) = MAX( zmsk(ji,jj), ztmp(ji,jj) )
+            END DO
+         END DO
          !
-         IF(lwp)WRITE(numout,*) 'zgr_sco :   iter= ',jl, ' rmax= ', zrmax
+         IF(lwp)WRITE(numout,*) 'zgr_sco :   iter= ',jl, ' rmax= ', zrmax, ' nb of pt= ', INT( SUM(zmsk(:,:) ) )
          !
          DO jj = 1, nlcj
             DO ji = 1, nlci
-               zenv(ji,jj) = MAX(zenv(ji,jj), ztmpi1(ji,jj), ztmpi2(ji,jj), ztmpj1(ji,jj), ztmpj2(ji,jj) )
+               iip1 = MIN( ji+1, nlci )     ! last  line (ji=nlci)
+               ijp1 = MIN( jj+1, nlcj )     ! last  raw  (jj=nlcj)
+               iim1 = MAX( ji-1,  1  )      ! first line (ji=nlci)
+               ijm1 = MAX( jj-1,  1  )      ! first raw  (jj=nlcj)
+               IF( zmsk(ji,jj) == 1._wp ) THEN
+                  ztmp(ji,jj) =   (                                                                                   &
+             &      zenv(iim1,ijp1)*zmsk(iim1,ijp1) + zenv(ji,ijp1)*zmsk(ji,ijp1) + zenv(iip1,ijp1)*zmsk(iip1,ijp1)   &
+             &    + zenv(iim1,jj  )*zmsk(iim1,jj  ) + zenv(ji,jj  )*    2._wp     + zenv(iip1,jj  )*zmsk(iip1,jj  )   &
+             &    + zenv(iim1,ijm1)*zmsk(iim1,ijm1) + zenv(ji,ijm1)*zmsk(ji,ijm1) + zenv(iip1,ijm1)*zmsk(iip1,ijm1)   &
+             &                    ) / (                                                                               &
+             &                      zmsk(iim1,ijp1) +               zmsk(ji,ijp1) +                 zmsk(iip1,ijp1)   &
+             &    +                 zmsk(iim1,jj  ) +                   2._wp     +                 zmsk(iip1,jj  )   &
+             &    +                 zmsk(iim1,ijm1) +               zmsk(ji,ijm1) +                 zmsk(iip1,ijm1)   &
+             &                        )
+               ENDIF
             END DO
          END DO
          !
-         CALL lbc_lnk( zenv, 'T', 1._wp )
+         DO jj = 1, nlcj
+            DO ji = 1, nlci
+               IF( zmsk(ji,jj) == 1._wp )   zenv(ji,jj) = MAX( ztmp(ji,jj), bathy(ji,jj) )
+            END DO
+         END DO
+         !
+         ! Apply lateral boundary condition   CAUTION: keep the value when the lbc field is zero
+         ztmp(:,:) = zenv(:,:)   ;   CALL lbc_lnk( zenv, 'T', 1._wp )
+         DO jj = 1, nlcj
+            DO ji = 1, nlci
+               IF( zenv(ji,jj) == 0._wp )   zenv(ji,jj) = ztmp(ji,jj)
+            END DO
+         END DO
          !                                                  ! ================ !
       END DO                                                !     End loop     !
       !                                                     ! ================ !
       !
-!     DO jj = 1, jpj
-!        DO ji = 1, jpi
-!           zenv(ji,jj) = MAX( zenv(ji,jj), rn_sbot_min ) ! set all points to avoid undefined scale values
-!        END DO
-!     END DO
+      ! Fill ghost rows with appropriate values to avoid undefined e3 values with some mpp decompositions
+      DO ji = nlci+1, jpi 
+         zenv(ji,1:nlcj) = zenv(nlci,1:nlcj)
+      END DO
+      !
+      DO jj = nlcj+1, jpj
+         zenv(:,jj) = zenv(:,nlcj)
+      END DO
       !
       ! Envelope bathymetry saved in hbatt
       hbatt(:,:) = zenv(:,:) 
-
       IF( MINVAL( gphit(:,:) ) * MAXVAL( gphit(:,:) ) <= 0._wp ) THEN
          CALL ctl_warn( ' s-coordinates are tapered in vicinity of the Equator' )
          DO jj = 1, jpj
             DO ji = 1, jpi
-               ztaper = EXP( -(gphit(ji,jj)/8._wp)**2 )
+               ztaper = EXP( -(gphit(ji,jj)/8._wp)**2._wp )
                hbatt(ji,jj) = rn_sbot_max * ztaper + hbatt(ji,jj) * ( 1._wp - ztaper )
             END DO
@@ -1365,11 +1368,11 @@
       fsde3w(:,:,:) = gdep3w(:,:,:)
       !
-      where (e3t   (:,:,:).eq.0.0)  e3t(:,:,:) = 1.0
-      where (e3u   (:,:,:).eq.0.0)  e3u(:,:,:) = 1.0
-      where (e3v   (:,:,:).eq.0.0)  e3v(:,:,:) = 1.0
-      where (e3f   (:,:,:).eq.0.0)  e3f(:,:,:) = 1.0
-      where (e3w   (:,:,:).eq.0.0)  e3w(:,:,:) = 1.0
-      where (e3uw  (:,:,:).eq.0.0)  e3uw(:,:,:) = 1.0
-      where (e3vw  (:,:,:).eq.0.0)  e3vw(:,:,:) = 1.0
+      where (e3t   (:,:,:).eq.0.0)  e3t(:,:,:) = 1._wp
+      where (e3u   (:,:,:).eq.0.0)  e3u(:,:,:) = 1._wp
+      where (e3v   (:,:,:).eq.0.0)  e3v(:,:,:) = 1._wp
+      where (e3f   (:,:,:).eq.0.0)  e3f(:,:,:) = 1._wp
+      where (e3w   (:,:,:).eq.0.0)  e3w(:,:,:) = 1._wp
+      where (e3uw  (:,:,:).eq.0.0)  e3uw(:,:,:) = 1._wp
+      where (e3vw  (:,:,:).eq.0.0)  e3vw(:,:,:) = 1._wp
 
 #if defined key_agrif
@@ -1519,5 +1522,6 @@
       END DO
       !
-      CALL wrk_dealloc( jpi, jpj,      zenv, ztmpi1, ztmpi2, ztmpj1, ztmpj2, zri, zrj, zhbat                           )      !
+      CALL wrk_dealloc( jpi, jpj,      zenv, ztmp, zmsk, zri, zrj, zhbat                           )
+      !
       IF( nn_timing == 1 )  CALL timing_stop('zgr_sco')
       !
@@ -1748,9 +1752,4 @@
       ENDDO
       !
-      CALL lbc_lnk(e3t ,'T',1.) ; CALL lbc_lnk(e3u ,'T',1.)
-      CALL lbc_lnk(e3v ,'T',1.) ; CALL lbc_lnk(e3f ,'T',1.)
-      CALL lbc_lnk(e3w ,'T',1.)
-      CALL lbc_lnk(e3uw,'T',1.) ; CALL lbc_lnk(e3vw,'T',1.)
-      !
       !                                               ! =============
 
@@ -1849,5 +1848,5 @@
       !!----------------------------------------------------------------------
       !
-      pf =   (   TANH( rn_theta * ( -(pk-0.5_wp) / REAL(jpkm1) + rn_thetb )  )   &
+      pf =   (   TANH( rn_theta * ( -(pk-0.5_wp) / REAL(jpkm1,wp) + rn_thetb )  )   &
          &     - TANH( rn_thetb * rn_theta                                )  )   &
          & * (   COSH( rn_theta                           )                      &
@@ -1875,8 +1874,8 @@
       !
       IF ( rn_theta == 0 ) then      ! uniform sigma
-         pf1 = - ( pk1 - 0.5_wp ) / REAL( jpkm1 )
+         pf1 = - ( pk1 - 0.5_wp ) / REAL( jpkm1,wp )
       ELSE                        ! stretched sigma
-         pf1 =   ( 1._wp - pbb ) * ( SINH( rn_theta*(-(pk1-0.5_wp)/REAL(jpkm1)) ) ) / SINH( rn_theta )              &
-            &  + pbb * (  (TANH( rn_theta*( (-(pk1-0.5_wp)/REAL(jpkm1)) + 0.5_wp) ) - TANH( 0.5_wp * rn_theta )  )  &
+         pf1 =   ( 1._wp - pbb ) * ( SINH( rn_theta*(-(pk1-0.5_wp)/REAL(jpkm1,wp)) ) ) / SINH( rn_theta )              &
+            &  + pbb * (  (TANH( rn_theta*( (-(pk1-0.5_wp)/REAL(jpkm1,wp)) + 0.5_wp) ) - TANH( 0.5_wp * rn_theta )  )  &
             &        / ( 2._wp * TANH( 0.5_wp * rn_theta ) )  )
       ENDIF
Index: /branches/2013/dev_CMCC_2013/NEMOGCM/NEMO/OPA_SRC/DYN/dynspg_flt.F90
===================================================================
--- /branches/2013/dev_CMCC_2013/NEMOGCM/NEMO/OPA_SRC/DYN/dynspg_flt.F90	(revision 4176)
+++ /branches/2013/dev_CMCC_2013/NEMOGCM/NEMO/OPA_SRC/DYN/dynspg_flt.F90	(revision 4177)
@@ -109,10 +109,8 @@
       INTEGER  ::   ji, jj, jk   ! dummy loop indices
       REAL(wp) ::   z2dt, z2dtg, zgcb, zbtd, ztdgu, ztdgv   ! local scalars
-      REAL(wp), POINTER, DIMENSION(:,:,:) ::  zub, zvb
       !!----------------------------------------------------------------------
       !
       IF( nn_timing == 1 )  CALL timing_start('dyn_spg_flt')
       !
-      CALL wrk_alloc( jpi,jpj,jpk, zub, zvb )
       !
       IF( kt == nit000 ) THEN
@@ -213,6 +211,6 @@
          DO jk = 1, jpkm1
             DO ji = 1, jpij
-               spgu(ji,1) = spgu(ji,1) + fse3u(ji,1,jk) * ua(ji,1,jk)
-               spgv(ji,1) = spgv(ji,1) + fse3v(ji,1,jk) * va(ji,1,jk)
+               spgu(ji,1) = spgu(ji,1) + fse3u_a(ji,1,jk) * ua(ji,1,jk)
+               spgv(ji,1) = spgv(ji,1) + fse3v_a(ji,1,jk) * va(ji,1,jk)
             END DO
          END DO
@@ -221,6 +219,6 @@
             DO jj = 2, jpjm1
                DO ji = 2, jpim1
-                  spgu(ji,jj) = spgu(ji,jj) + fse3u(ji,jj,jk) * ua(ji,jj,jk)
-                  spgv(ji,jj) = spgv(ji,jj) + fse3v(ji,jj,jk) * va(ji,jj,jk)
+                  spgu(ji,jj) = spgu(ji,jj) + fse3u_a(ji,jj,jk) * ua(ji,jj,jk)
+                  spgv(ji,jj) = spgv(ji,jj) + fse3v_a(ji,jj,jk) * va(ji,jj,jk)
                END DO
             END DO
@@ -360,5 +358,4 @@
       IF( lrst_oce ) CALL flt_rst( kt, 'WRITE' )
       !
-      CALL wrk_dealloc( jpi,jpj,jpk, zub, zvb )
       !
       IF( nn_timing == 1 )  CALL timing_stop('dyn_spg_flt')
Index: /branches/2013/dev_CMCC_2013/NEMOGCM/NEMO/OPA_SRC/LBC/lib_mpp.F90
===================================================================
--- /branches/2013/dev_CMCC_2013/NEMOGCM/NEMO/OPA_SRC/LBC/lib_mpp.F90	(revision 4176)
+++ /branches/2013/dev_CMCC_2013/NEMOGCM/NEMO/OPA_SRC/LBC/lib_mpp.F90	(revision 4177)
@@ -2181,9 +2181,9 @@
 !!gm Remark : this is very time consumming!!!
       !                                         ! ------------------------ !
-            IF( ijpt0 > ijpt1 .OR. iipt0 > iipt1 ) THEN
+        IF(((nbondi .ne. 0) .AND. (ktype .eq. 2)) .OR. ((nbondj .ne. 0) .AND. (ktype .eq. 1))) THEN
             ! there is nothing to be migrated
-               lmigr = .FALSE.
+              lmigr = .TRUE.
             ELSE
-              lmigr = .TRUE.
+              lmigr = .FALSE.
             ENDIF
 
Index: /branches/2013/dev_CMCC_2013/NEMOGCM/NEMO/OPA_SRC/SBC/geo2ocean.F90
===================================================================
--- /branches/2013/dev_CMCC_2013/NEMOGCM/NEMO/OPA_SRC/SBC/geo2ocean.F90	(revision 4176)
+++ /branches/2013/dev_CMCC_2013/NEMOGCM/NEMO/OPA_SRC/SBC/geo2ocean.F90	(revision 4177)
@@ -187,5 +187,5 @@
          &      gsinf(jpi,jpj), gcosf(jpi,jpj), STAT=ierr )
       IF(lk_mpp)   CALL mpp_sum( ierr )
-      IF( ierr /= 0 )   CALL ctl_stop('STOP', 'angle_msh_geo: unable to allocate arrays' )
+      IF( ierr /= 0 )   CALL ctl_stop('angle: unable to allocate arrays' )
 
       ! ============================= !
@@ -361,5 +361,5 @@
             &      gsinlat(jpi,jpj,4) , gcoslat(jpi,jpj,4) , STAT=ierr )
          IF( lk_mpp    )   CALL mpp_sum( ierr )
-         IF( ierr /= 0 )   CALL ctl_stop('STOP', 'angle_msh_geo: unable to allocate arrays' )
+         IF( ierr /= 0 )   CALL ctl_stop('geo2oce: unable to allocate arrays' )
       ENDIF
 
@@ -438,9 +438,9 @@
       !!----------------------------------------------------------------------
 
-      IF( ALLOCATED( gsinlon ) ) THEN
+      IF( .NOT. ALLOCATED( gsinlon ) ) THEN
          ALLOCATE( gsinlon(jpi,jpj,4) , gcoslon(jpi,jpj,4) ,   &
             &      gsinlat(jpi,jpj,4) , gcoslat(jpi,jpj,4) , STAT=ierr )
          IF( lk_mpp    )   CALL mpp_sum( ierr )
-         IF( ierr /= 0 )   CALL ctl_stop('STOP', 'angle_msh_geo: unable to allocate arrays' )
+         IF( ierr /= 0 )   CALL ctl_stop('oce2geo: unable to allocate arrays' )
       ENDIF
 
Index: /branches/2013/dev_CMCC_2013/NEMOGCM/NEMO/OPA_SRC/SBC/sbccpl.F90
===================================================================
--- /branches/2013/dev_CMCC_2013/NEMOGCM/NEMO/OPA_SRC/SBC/sbccpl.F90	(revision 4176)
+++ /branches/2013/dev_CMCC_2013/NEMOGCM/NEMO/OPA_SRC/SBC/sbccpl.F90	(revision 4177)
@@ -388,5 +388,5 @@
       !
       IF( TRIM( sn_rcv_tau%cldes ) /= 'oce and ice' ) THEN        ! 'oce and ice' case ocean stress on ocean mesh used
-         srcv(jpr_itz1:jpr_itz2)%laction = .FALSE.    ! ice components not received (itx1 and ity1 used later)
+         srcv(jpr_itx1:jpr_itz2)%laction = .FALSE.    ! ice components not received
          srcv(jpr_itx1)%clgrid = 'U'                  ! ocean stress used after its transformation
          srcv(jpr_ity1)%clgrid = 'V'                  ! i.e. it is always at U- & V-points for i- & j-comp. resp.
@@ -407,5 +407,7 @@
       SELECT CASE( TRIM( sn_rcv_emp%cldes ) )
       CASE( 'oce only'      )   ;   srcv(                                 jpr_oemp   )%laction = .TRUE. 
-      CASE( 'conservative'  )   ;   srcv( (/jpr_rain, jpr_snow, jpr_ievp, jpr_tevp/) )%laction = .TRUE.
+      CASE( 'conservative'  )
+         srcv( (/jpr_rain, jpr_snow, jpr_ievp, jpr_tevp/) )%laction = .TRUE.
+         IF ( k_ice <= 1 )  srcv(jpr_ivep)%laction = .FALSE.
       CASE( 'oce and ice'   )   ;   srcv( (/jpr_ievp, jpr_sbpr, jpr_semp, jpr_oemp/) )%laction = .TRUE.
       CASE default              ;   CALL ctl_stop( 'sbc_cpl_init: wrong definition of sn_rcv_emp%cldes' )
@@ -465,13 +467,4 @@
          CALL ctl_stop( 'sbc_cpl_init: namsbc_cpl namelist mismatch between sn_rcv_qns%cldes and sn_rcv_dqnsdt%cldes' )
       !                                                      ! ------------------------- !
-      !                                                      !    Ice Qsr penetration    !   
-      !                                                      ! ------------------------- !
-      ! fraction of net shortwave radiation which is not absorbed in the thin surface layer 
-      ! and penetrates inside the ice cover ( Maykut and Untersteiner, 1971 ; Elbert anbd Curry, 1993 )
-      ! Coupled case: since cloud cover is not received from atmosphere 
-      !               ===> defined as constant value -> definition done in sbc_cpl_init
-      fr1_i0(:,:) = 0.18
-      fr2_i0(:,:) = 0.82
-      !                                                      ! ------------------------- !
       !                                                      !      10m wind module      !   
       !                                                      ! ------------------------- !
@@ -508,4 +501,9 @@
       ! Allocate taum part of frcv which is used even when not received as coupling field
       IF ( .NOT. srcv(jpr_taum)%laction ) ALLOCATE( frcv(jpr_taum)%z3(jpi,jpj,srcv(jn)%nct) )
+      ! Allocate itx1 and ity1 as they are used in sbc_cpl_ice_tau even if srcv(jpr_itx1)%laction = .FALSE.
+      IF( k_ice /= 0 ) THEN
+         IF ( .NOT. srcv(jpr_itx1)%laction ) ALLOCATE( frcv(jpr_itx1)%z3(jpi,jpj,srcv(jn)%nct) )
+         IF ( .NOT. srcv(jpr_ity1)%laction ) ALLOCATE( frcv(jpr_ity1)%z3(jpi,jpj,srcv(jn)%nct) )
+      END IF
 
       ! ================================ !
@@ -1329,4 +1327,13 @@
       END SELECT
 
+      !    Ice Qsr penetration used (only?)in lim2 or lim3 
+      ! fraction of net shortwave radiation which is not absorbed in the thin surface layer 
+      ! and penetrates inside the ice cover ( Maykut and Untersteiner, 1971 ; Elbert anbd Curry, 1993 )
+      ! Coupled case: since cloud cover is not received from atmosphere 
+      !               ===> defined as constant value -> definition done in sbc_cpl_init
+      fr1_i0(:,:) = 0.18
+      fr2_i0(:,:) = 0.82
+
+
       CALL wrk_dealloc( jpi,jpj, zcptn, ztmp, zicefr )
       !
Index: /branches/2013/dev_CMCC_2013/NEMOGCM/NEMO/OPA_SRC/SBC/sbcmod.F90
===================================================================
--- /branches/2013/dev_CMCC_2013/NEMOGCM/NEMO/OPA_SRC/SBC/sbcmod.F90	(revision 4176)
+++ /branches/2013/dev_CMCC_2013/NEMOGCM/NEMO/OPA_SRC/SBC/sbcmod.F90	(revision 4177)
@@ -221,4 +221,6 @@
       ENDIF
       !
+                          CALL sbc_ssm_init               ! Sea-surface mean fields initialisation
+      !
       IF( ln_ssr      )   CALL sbc_ssr_init               ! Sea-Surface Restoring initialisation
       !
Index: /branches/2013/dev_CMCC_2013/NEMOGCM/NEMO/OPA_SRC/TRA/eosbn2.F90
===================================================================
--- /branches/2013/dev_CMCC_2013/NEMOGCM/NEMO/OPA_SRC/TRA/eosbn2.F90	(revision 4176)
+++ /branches/2013/dev_CMCC_2013/NEMOGCM/NEMO/OPA_SRC/TRA/eosbn2.F90	(revision 4177)
@@ -675,5 +675,5 @@
 
 
-   FUNCTION tfreez( psal ) RESULT( ptf )
+   FUNCTION tfreez( psal, pdep ) RESULT( ptf )
       !!----------------------------------------------------------------------
       !!                 ***  ROUTINE eos_init  ***
@@ -688,4 +688,5 @@
       !!----------------------------------------------------------------------
       REAL(wp), DIMENSION(jpi,jpj), INTENT(in   ) ::   psal   ! salinity             [psu]
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(in   ), OPTIONAL ::   pdep   ! depth      [decibars]
       ! Leave result array automatic rather than making explicitly allocated
       REAL(wp), DIMENSION(jpi,jpj)                ::   ptf    ! freezing temperature [Celcius]
@@ -694,4 +695,7 @@
       ptf(:,:) = ( - 0.0575_wp + 1.710523e-3_wp * SQRT( psal(:,:) )   &
          &                     - 2.154996e-4_wp *       psal(:,:)   ) * psal(:,:)
+      IF ( PRESENT( pdep ) ) THEN   
+         ptf(:,:) = ptf(:,:) - 7.53e-4_wp * pdep(:,:)
+      ENDIF
       !
    END FUNCTION tfreez
Index: /branches/2013/dev_CMCC_2013/NEMOGCM/NEMO/SAS_SRC/daymod.F90
===================================================================
--- /branches/2013/dev_CMCC_2013/NEMOGCM/NEMO/SAS_SRC/daymod.F90	(revision 4176)
+++ /branches/2013/dev_CMCC_2013/NEMOGCM/NEMO/SAS_SRC/daymod.F90	(revision 4177)
@@ -246,4 +246,9 @@
                nday_year = 1
                nsec_year = ndt05
+               IF( nsec1jan000 >= 2 * (2**30 - nsecd * nyear_len(1) / 2 ) ) THEN   ! test integer 4 max value
+                  CALL ctl_stop( 'The number of seconds between Jan. 1st 00h of nit000 year and Jan. 1st 00h ',   &
+                     &           'of the current year is exceeding the INTEGER 4 max VALUE: 2^31-1 -> 68.09 years in seconds', &
+                     & 'You must do a restart at higher frequency (or remove this STOP and recompile everything in I8)' )
+               ENDIF
                nsec1jan000 = nsec1jan000 + nsecd * nyear_len(1)
                IF( nleapy == 1 )   CALL day_mth
Index: /branches/2013/dev_CMCC_2013/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p4zsed.F90
===================================================================
--- /branches/2013/dev_CMCC_2013/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p4zsed.F90	(revision 4176)
+++ /branches/2013/dev_CMCC_2013/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p4zsed.F90	(revision 4177)
@@ -82,5 +82,5 @@
       IF( nn_timing == 1 )  CALL timing_start('p4z_sed')
       !
-      IF( kt == nit000 .AND. jnt == 1 )  THEN
+      IF( kt == nittrc000 .AND. jnt == 1 )  THEN
          ryyss    = nyear_len(1) * rday    ! number of seconds per year and per month
          rmtss    = ryyss / raamo
Index: /branches/2013/dev_CMCC_2013/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p4zsms.F90
===================================================================
--- /branches/2013/dev_CMCC_2013/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p4zsms.F90	(revision 4176)
+++ /branches/2013/dev_CMCC_2013/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p4zsms.F90	(revision 4177)
@@ -76,5 +76,14 @@
       ENDIF
       !
-      IF( ln_rsttr .AND. kt == nittrc000 )                         CALL p4z_rst( nittrc000, 'READ' )  !* read or initialize all required fields 
+      IF( kt == nittrc000 ) THEN
+        !
+        CALL p4z_che                              ! initialize the chemical constants
+        !
+        IF( .NOT. ln_rsttr ) THEN  ;   CALL p4z_ph_ini   !  set PH at kt=nit000 
+        ELSE                       ;   CALL p4z_rst( nittrc000, 'READ' )  !* read or initialize all required fields 
+        ENDIF
+        !
+      ENDIF
+
       IF( ln_pisdmp .AND. MOD( kt - nn_dttrc, nn_pisdmp ) == 0 )   CALL p4z_dmp( kt )      ! Relaxation of some tracers
       !
@@ -238,4 +247,32 @@
    END SUBROUTINE p4z_sms_init
 
+   SUBROUTINE p4z_ph_ini
+      !!---------------------------------------------------------------------
+      !!                   ***  ROUTINE p4z_ini_ph  ***
+      !!
+      !!  ** Purpose : Initialization of chemical variables of the carbon cycle
+      !!---------------------------------------------------------------------
+      INTEGER  ::  ji, jj, jk
+      REAL(wp) ::  zcaralk, zbicarb, zco3
+      REAL(wp) ::  ztmas, ztmas1
+      !!---------------------------------------------------------------------
+
+      ! Set PH from  total alkalinity, borat (???), akb3 (???) and ak23 (???)
+      ! --------------------------------------------------------
+      DO jk = 1, jpk
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               ztmas   = tmask(ji,jj,jk)
+               ztmas1  = 1. - tmask(ji,jj,jk)
+               zcaralk = trn(ji,jj,jk,jptal) - borat(ji,jj,jk) / (  1. + 1.E-8 / ( rtrn + akb3(ji,jj,jk) )  )
+               zco3    = ( zcaralk - trn(ji,jj,jk,jpdic) ) * ztmas + 0.5e-3 * ztmas1
+               zbicarb = ( 2. * trn(ji,jj,jk,jpdic) - zcaralk )
+               hi(ji,jj,jk) = ( ak23(ji,jj,jk) * zbicarb / zco3 ) * ztmas + 1.e-9 * ztmas1
+            END DO
+         END DO
+     END DO
+     !
+   END SUBROUTINE p4z_ph_ini
+
    SUBROUTINE p4z_rst( kt, cdrw )
       !!---------------------------------------------------------------------
@@ -266,18 +303,5 @@
          ELSE
 !            hi(:,:,:) = 1.e-9 
-            ! Set PH from  total alkalinity, borat (???), akb3 (???) and ak23 (???)
-            ! --------------------------------------------------------
-            DO jk = 1, jpk
-               DO jj = 1, jpj
-                  DO ji = 1, jpi
-                     ztmas   = tmask(ji,jj,jk)
-                     ztmas1  = 1. - tmask(ji,jj,jk)
-                     zcaralk = trn(ji,jj,jk,jptal) - borat(ji,jj,jk) / (  1. + 1.E-8 / ( rtrn + akb3(ji,jj,jk) )  )
-                     zco3    = ( zcaralk - trn(ji,jj,jk,jpdic) ) * ztmas + 0.5e-3 * ztmas1
-                     zbicarb = ( 2. * trn(ji,jj,jk,jpdic) - zcaralk )
-                     hi(ji,jj,jk) = ( ak23(ji,jj,jk) * zbicarb / zco3 ) * ztmas + 1.e-9 * ztmas1
-                  END DO
-               END DO
-            END DO
+            CALL p4z_ph_ini
          ENDIF
          CALL iom_get( numrtr, jpdom_autoglo, 'Silicalim', xksi(:,:) )
Index: /branches/2013/dev_CMCC_2013/NEMOGCM/NEMO/TOP_SRC/PISCES/trcini_pisces.F90
===================================================================
--- /branches/2013/dev_CMCC_2013/NEMOGCM/NEMO/TOP_SRC/PISCES/trcini_pisces.F90	(revision 4176)
+++ /branches/2013/dev_CMCC_2013/NEMOGCM/NEMO/TOP_SRC/PISCES/trcini_pisces.F90	(revision 4177)
@@ -122,6 +122,4 @@
       rdenita =   3._wp /  5._wp
       o2ut    = 131._wp / 122._wp
-
-      CALL p4z_che        ! initialize the chemical constants
 
       ! Initialization of tracer concentration in case of  no restart 
@@ -162,20 +160,5 @@
          xksi(:,:)    = 2.e-6
          xksimax(:,:) = xksi(:,:)
-
-         ! Initialization of chemical variables of the carbon cycle
-         ! --------------------------------------------------------
-         DO jk = 1, jpk
-            DO jj = 1, jpj
-               DO ji = 1, jpi
-                  ztmas   = tmask(ji,jj,jk)
-                  ztmas1  = 1. - tmask(ji,jj,jk)
-                  zcaralk = trn(ji,jj,jk,jptal) - borat(ji,jj,jk) / (  1. + 1.E-8 / ( rtrn + akb3(ji,jj,jk) )  )
-                  zco3    = ( zcaralk - trn(ji,jj,jk,jpdic) ) * ztmas + 0.5e-3 * ztmas1
-                  zbicarb = ( 2. * trn(ji,jj,jk,jpdic) - zcaralk )
-                  hi(ji,jj,jk) = ( ak23(ji,jj,jk) * zbicarb / zco3 ) * ztmas + 1.e-9 * ztmas1
-               END DO
-            END DO
-         END DO
-         !
+        !
       END IF
 
Index: /branches/2013/dev_CMCC_2013/NEMOGCM/TOOLS/COMPILE/Fcheck_archfile.sh
===================================================================
--- /branches/2013/dev_CMCC_2013/NEMOGCM/TOOLS/COMPILE/Fcheck_archfile.sh	(revision 4176)
+++ /branches/2013/dev_CMCC_2013/NEMOGCM/TOOLS/COMPILE/Fcheck_archfile.sh	(revision 4177)
@@ -40,5 +40,5 @@
 # ::
 #
-#  $ ./Fcheck_archfile.sh ARCHFILE COMPILER
+#  $ ./Fcheck_archfile.sh ARCHFILE CPPFILE COMPILER
 #
 #
@@ -94,13 +94,16 @@
 	else
 	    if [ -f ${COMPIL_DIR}/$1 ]; then
-		# has the cpp keys file been changed since we copied the arch file in ${COMPIL_DIR}?
-		mycpp=$( ls -l ${COMPIL_DIR}/$2 | sed -e "s/.* -> //" )
-		if [ "$mycpp" != "$( cat ${COMPIL_DIR}/cpp.history )" ]; then
-		    echo $mycpp > ${COMPIL_DIR}/cpp.history
-		    cpeval ${myarch} ${COMPIL_DIR}/$1
+		if [ "$2" != "nocpp" ] 
+		then
+		    # has the cpp keys file been changed since we copied the arch file in ${COMPIL_DIR}?
+		    mycpp=$( ls -l ${COMPIL_DIR}/$2 | sed -e "s/.* -> //" )
+		    if [ "$mycpp" != "$( cat ${COMPIL_DIR}/cpp.history )" ]; then
+			echo $mycpp > ${COMPIL_DIR}/cpp.history
+			cpeval ${myarch} ${COMPIL_DIR}/$1
+		    fi
+		    # has the cpp keys file been updated since we copied the arch file in ${COMPIL_DIR}?
+		    mycpp=$( find -L ${COMPIL_DIR} -cnewer ${COMPIL_DIR}/$1 -name $2 -print )
+		    [ ${#mycpp} -ne 0 ] && cpeval ${myarch} ${COMPIL_DIR}/$1
 		fi
-		# has the cpp keys file been updated since we copied the arch file in ${COMPIL_DIR}?
-		mycpp=$( find -L ${COMPIL_DIR} -cnewer ${COMPIL_DIR}/$1 -name $2 -print )
-		[ ${#mycpp} -ne 0 ] && cpeval ${myarch} ${COMPIL_DIR}/$1
 		# has myarch file been updated since we copied it in ${COMPIL_DIR}?
 		myarchdir=$( dirname ${myarch} )
@@ -134,13 +137,16 @@
     if [ "$myarch" == "$( cat ${COMPIL_DIR}/arch.history )" ]; then 
 	if [ -f ${COMPIL_DIR}/$1 ]; then
-	    # has the cpp keys file been changed since we copied the arch file in ${COMPIL_DIR}?
-	    mycpp=$( ls -l ${COMPIL_DIR}/$2 | sed -e "s/.* -> //" )
-	    if [ "$mycpp" != "$( cat ${COMPIL_DIR}/cpp.history )" ]; then
-		echo $mycpp > ${COMPIL_DIR}/cpp.history
-		cpeval ${myarch} ${COMPIL_DIR}/$1
+	    if [ "$2" != "nocpp" ] 
+	    then
+		# has the cpp keys file been changed since we copied the arch file in ${COMPIL_DIR}?
+		mycpp=$( ls -l ${COMPIL_DIR}/$2 | sed -e "s/.* -> //" )
+		if [ "$mycpp" != "$( cat ${COMPIL_DIR}/cpp.history )" ]; then
+		    echo $mycpp > ${COMPIL_DIR}/cpp.history
+		    cpeval ${myarch} ${COMPIL_DIR}/$1
+		fi
+		# has the cpp keys file been updated since we copied the arch file in ${COMPIL_DIR}?
+		mycpp=$( find -L ${COMPIL_DIR} -cnewer ${COMPIL_DIR}/$1 -name $2 -print )
+		[ ${#mycpp} -ne 0 ] && cpeval ${myarch} ${COMPIL_DIR}/$1
 	    fi
-	    # has the cpp keys file been updated since we copied the arch file in ${COMPIL_DIR}?
-	    mycpp=$( find -L ${COMPIL_DIR} -cnewer ${COMPIL_DIR}/$1 -name $2 -print )
-	    [ ${#mycpp} -ne 0 ] && cpeval ${myarch} ${COMPIL_DIR}/$1
 	    # has myarch file been updated since we copied it in ${COMPIL_DIR}?
 	    myarch=$( find -L ${MAIN_DIR}/ARCH -cnewer ${COMPIL_DIR}/$1 -name arch-${3}.fcm -print )
@@ -150,5 +156,8 @@
 	fi
     else
-	ls -l ${COMPIL_DIR}/$2 | sed -e "s/.* -> //" > ${COMPIL_DIR}/cpp.history
+	if [ "$2" != "nocpp" ] 
+	then
+	    ls -l ${COMPIL_DIR}/$2 | sed -e "s/.* -> //" > ${COMPIL_DIR}/cpp.history
+	fi
 	echo ${myarch} > ${COMPIL_DIR}/arch.history
 	cpeval ${myarch} ${COMPIL_DIR}/$1
@@ -157,5 +166,10 @@
 
 #- do we need xios library?
-use_iom=$( sed -e "s/#.*$//" ${COMPIL_DIR}/$2 | grep -c key_iomput )
+if [ "$2" != "nocpp" ] 
+then
+    use_iom=$( sed -e "s/#.*$//" ${COMPIL_DIR}/$2 | grep -c key_iomput )
+else
+    use_iom=0
+fi
 have_lxios=$( sed -e "s/#.*$//" ${COMPIL_DIR}/$1 | grep -c "\-lxios" )
 if [[ ( $use_iom -eq 0 ) && ( $have_lxios -ge 1 ) ]]
@@ -166,5 +180,10 @@
 
 #- do we need oasis libraries?
-use_oasis=$( sed -e "s/#.*$//" ${COMPIL_DIR}/$2 | grep -c key_oasis3 )
+if [ "$2" != "nocpp" ] 
+then
+    use_oasis=$( sed -e "s/#.*$//" ${COMPIL_DIR}/$2 | grep -c key_oasis3 )
+else
+    use_oasis=0
+fi
 for liboa in psmile.MPI1 mct mpeu scrip mpp_io
 do
Index: /branches/2013/dev_CMCC_2013/NEMOGCM/TOOLS/MISCELLANEOUS/chk_iomput.sh
===================================================================
--- /branches/2013/dev_CMCC_2013/NEMOGCM/TOOLS/MISCELLANEOUS/chk_iomput.sh	(revision 4176)
+++ /branches/2013/dev_CMCC_2013/NEMOGCM/TOOLS/MISCELLANEOUS/chk_iomput.sh	(revision 4177)
@@ -59,13 +59,13 @@
 #------------------------------------------------
 #
-external=$( grep -c "<field_definition.* src=" $xmlfile )
+external=$( grep -c "<field_definition  *\([^ ].* \)*src=" $xmlfile )
 if [ $external -eq 1 ]
 then
-    xmlfield_def=$( grep "<field_definition.* src=" $xmlfile | sed -e 's/.*src="\([^"]*\)".*/\1/' )
+    xmlfield_def=$( grep "<field_definition  *\([^ ].* \)*src=" $xmlfile | sed -e 's/.*src="\([^"]*\)".*/\1/' )
     xmlfield_def=$( dirname $xmlfile )/$xmlfield_def   
 else
     xmlfield_def=$xmlfile
 fi
-[ $inxml -eq 1 ] && grep "< *field * id *=" $xmlfield_def
+[ $inxml -eq 1 ] && grep "< *field  *\([^ ].* \)*id *=" $xmlfield_def
 [ $insrc -eq 1 ] && find $srcdir -name "*.[Ffh]90" -exec grep -iH "^[^\!]*call  *iom_put *(" {} \;
 [ $(( $insrc + $inxml )) -ge 1 ] && exit
@@ -91,9 +91,9 @@
 # list of variables defined in the xml file
 #
-varlistxml=$( grep "< *field.* id *=" $xmlfield_def  | sed -e "s/^.*< *field.* id *= *[\"\']\([^\"\']*\)[\"\'].*/\1/" | sort -d )
+varlistxml=$( grep "< *field  *\([^ ].* \)*id *=" $xmlfield_def  | sed -e "s/^.*< *field .*id *= *[\"\']\([^\"\']*\)[\"\'].*/\1/" | sort -d )
 #
 # list of variables to be outputed in the xml file
 #
-varlistout=$( grep "< *field.* field_ref *=" $xmlfile  | sed -e "s/^.*< *field.* field_ref *= *[\"\']\([^\"\']*\)[\"\'].*/\1/" | sort -d )
+varlistout=$( grep "< *field  *\([^ ].* \)*field_ref *=" $xmlfile  | sed -e "s/^.*< *field .*field_ref *= *[\"\']\([^\"\']*\)[\"\'].*/\1/" | sort -d )
 #
 echo "--------------------------------------------------"
Index: /branches/2013/dev_CMCC_2013/NEMOGCM/TOOLS/maketools
===================================================================
--- /branches/2013/dev_CMCC_2013/NEMOGCM/TOOLS/maketools	(revision 4176)
+++ /branches/2013/dev_CMCC_2013/NEMOGCM/TOOLS/maketools	(revision 4177)
@@ -146,5 +146,5 @@
 
 #- When used for the first time, choose a compiler ---
-. ${COMPIL_DIR}/Fcheck_archfile.sh arch_tools.fcm ${CMP_NAM} || exit
+. ${COMPIL_DIR}/Fcheck_archfile.sh arch_tools.fcm nocpp ${CMP_NAM} || exit
 
 #- Choose a default tool if needed ---
