Index: branches/2012/dev_MERGE_2012/DOC/TexFiles/Biblio/Biblio.bib
===================================================================
--- branches/2012/dev_MERGE_2012/DOC/TexFiles/Biblio/Biblio.bib	(revision 3759)
+++ branches/2012/dev_MERGE_2012/DOC/TexFiles/Biblio/Biblio.bib	(revision 3764)
@@ -1412,8 +1412,9 @@
 }
 
-@ARTICLE{Hunke2008,
+@TECHREPORT{Hunke2008,
   author = {E.C. Hunke and W.H. Lipscomb},
   title = {CICE: the Los Alamos sea ice model documentation and software user's manual, 
         Version 4.0},
+  institution = { Los Alamos National Laboratory, N.M.},
   publisher = {LA-CC-06-012, Los Alamos National Laboratory, N.M.},
   year = {2008}
Index: branches/2012/dev_MERGE_2012/DOC/TexFiles/Chapters/Chap_CFG.tex
===================================================================
--- branches/2012/dev_MERGE_2012/DOC/TexFiles/Chapters/Chap_CFG.tex	(revision 3759)
+++ branches/2012/dev_MERGE_2012/DOC/TexFiles/Chapters/Chap_CFG.tex	(revision 3764)
@@ -31,5 +31,5 @@
 
 % ================================================================
-% 1D model functionality
+% 1D model configuration
 % ================================================================
 \section{Water column model: 1D model (C1D) (\key{c1d})}
@@ -48,18 +48,25 @@
 
 The methodology is based on the use of the zoom functionality over the smallest possible 
-domain : a 3 x 3 domain centred on the grid point of interest (see \S\ref{MISC_zoom}), 
+domain : a 3x3 domain centred on the grid point of interest (see \S\ref{MISC_zoom}), 
 with some extra routines. There is no need to define a new mesh, bathymetry, 
 initial state or forcing, since the 1D model will use those of the configuration it is a zoom of. 
-The chosen grid point is set in par\_oce.F90 module by setting the \jp{jpizoom} and \jp{jpjzoom} 
+The chosen grid point is set in \mdl{par\_oce} module by setting the \jp{jpizoom} and \jp{jpjzoom} 
 parameters to the indices of the location of the chosen grid point.
 
-The 1D model has some specifies. First, all the horizontal derivatives are assumed to be zero. 
-Therefore a simplified \rou{step} routine is used (\rou{step\_c1d}) in which both lateral tendancy 
-terms and lateral physics are not called, and the vertical velocity is zero (so far, no attempt at
-introducing a Ekman pumping velocity has been made).
-Second, the two components of the velocity are moved on a $T$-point. 
-This requires a specific treatment of the Coriolis term (see \rou{dyncor\_c1d}) and of the 
-dynamic time stepping (\rou{dynnxt\_c1d}).
-All the relevant modules can be found in the NEMOGCM/NEMO/OPA\_SRC/C1D directory of 
+The 1D model has some specifies. First, all the horizontal derivatives are assumed to be zero, and
+second, the two components of the velocity are moved on a $T$-point. 
+Therefore, defining \key{c1d} changes five main things in the code behaviour: 
+\begin{description}
+\item[(1)] the lateral boundary condition routine (\rou{lbc\_lnk}) set the value of the central column 
+of the 3x3 domain is imposed over the whole domain ; 
+\item[(3)] a call to \rou{lbc\_lnk} is systematically done when reading input data ($i.e.$ in \mdl{iom}) ; 
+\item[(3)] a simplified \rou{stp} routine is used (\rou{stp\_c1d}, see \mdl{step\_c1d} module) in which 
+both lateral tendancy terms and lateral physics are not called ; 
+\item[(4)] the vertical velocity is zero (so far, no attempt at introducing a Ekman pumping velocity 
+has been made) ; 
+\item[(5)] a simplified treatment of the Coriolis term is performed as $U$- and $V$-points are the same 
+(see \mdl{dyncor\_c1d}).
+\end{description}
+All the relevant \textit{\_c1d} modules can be found in the NEMOGCM/NEMO/OPA\_SRC/C1D directory of 
 the \NEMO distribution.
 
@@ -206,5 +213,5 @@
 % -------------------------------------------------------------------------------------------------------------
 \section{GYRE family: double gyre basin (\key{gyre})}
-\label{MISC_config_gyre}
+\label{CFG_gyre}
 
 The GYRE configuration \citep{Levy_al_OM10} have been built to simulated 
Index: branches/2012/dev_MERGE_2012/DOC/TexFiles/Chapters/Chap_DIA.tex
===================================================================
--- branches/2012/dev_MERGE_2012/DOC/TexFiles/Chapters/Chap_DIA.tex	(revision 3759)
+++ branches/2012/dev_MERGE_2012/DOC/TexFiles/Chapters/Chap_DIA.tex	(revision 3764)
@@ -1018,5 +1018,5 @@
 In addition, a series of diagnostics has been added in the \mdl{diaar5}. 
 They corresponds to outputs that are required for AR5 simulations 
-(see Section \ref{MISC_steric} below for one of them). 
+(see Section \ref{DIA_steric} below for one of them). 
 Activating those outputs requires to define the \key{diaar5} CPP key.
 \\
Index: branches/2012/dev_MERGE_2012/DOC/TexFiles/Chapters/Chap_DOM.tex
===================================================================
--- branches/2012/dev_MERGE_2012/DOC/TexFiles/Chapters/Chap_DOM.tex	(revision 3759)
+++ branches/2012/dev_MERGE_2012/DOC/TexFiles/Chapters/Chap_DOM.tex	(revision 3764)
@@ -499,5 +499,5 @@
 Hybridation of the three main coordinates are available: $s-z$ or $s-zps$ coordinate 
 (Fig.~\ref{Fig_z_zps_s_sps}d and \ref{Fig_z_zps_s_sps}e). When using the variable 
-volume option \key{vvl}) ($i.e.$ non-linear free surface), the coordinate follow the 
+volume option \key{vvl} ($i.e.$ non-linear free surface), the coordinate follow the 
 time-variation of the free surface so that the transformation is time dependent: 
 $z(i,j,k,t)$ (Fig.~\ref{Fig_z_zps_s_sps}f). This option can be used with full step 
Index: branches/2012/dev_MERGE_2012/DOC/TexFiles/Chapters/Chap_DYN.tex
===================================================================
--- branches/2012/dev_MERGE_2012/DOC/TexFiles/Chapters/Chap_DYN.tex	(revision 3759)
+++ branches/2012/dev_MERGE_2012/DOC/TexFiles/Chapters/Chap_DYN.tex	(revision 3764)
@@ -127,5 +127,5 @@
 This is of paramount importance. Replacing $T$ by the number $1$ in the tracer equation and summing
 over the water column must lead to the sea surface height equation otherwise tracer content
-will not be conserved \ref{Griffies_al_MWR01, LeclairMadec2009}.
+will not be conserved \citep{Griffies_al_MWR01, Leclair_Madec_OM09}.
 
 The vertical velocity is computed by an upward integration of the horizontal 
@@ -189,5 +189,5 @@
 the relative vorticity term and horizontal kinetic energy for the planetary vorticity 
 term (MIX scheme) ; or conserving both the potential enstrophy of horizontally non-divergent 
-flow and horizontal kinetic energy (EEN scheme) (see  Appendix~\ref{Apdx_C_vor_zad}). In the 
+flow and horizontal kinetic energy (EEN scheme) (see  Appendix~\ref{Apdx_C_vorEEN}). In the 
 case of ENS, ENE or MIX schemes the land sea mask may be slightly modified to ensure the 
 consistency of vorticity term with analytical equations (\textit{ln\_dynvor\_con}=true).
@@ -331,5 +331,5 @@
 This EEN scheme in fact combines the conservation properties of the ENS and ENE schemes. 
 It conserves both total energy and potential enstrophy in the limit of horizontally 
-nondivergent flow ($i.e.$ $\chi$=$0$) (see  Appendix~\ref{Apdx_C_vor_zad}). 
+nondivergent flow ($i.e.$ $\chi$=$0$) (see  Appendix~\ref{Apdx_C_vorEEN}). 
 Applied to a realistic ocean configuration, it has been shown that it leads to a significant 
 reduction of the noise in the vertical velocity field \citep{Le_Sommer_al_OM09}. 
@@ -938,5 +938,5 @@
 is the \textit{before} velocity in time, except for the pure vertical component 
 that appears when a tensor of rotation is used. This latter term is solved 
-implicitly together with the vertical diffusion term (see \S\ref{DOM_nxt}) 
+implicitly together with the vertical diffusion term (see \S\ref{STP}) 
 
 At the lateral boundaries either free slip, no slip or partial slip boundary 
@@ -1066,5 +1066,5 @@
 scheme (\np{ln\_zdfexp}=true) using a time splitting technique 
 (\np{nn\_zdfexp} $>$ 1) or $(b)$ a backward (or implicit) time differencing scheme 
-(\np{ln\_zdfexp}=false) (see \S\ref{DOM_nxt}). Note that namelist variables 
+(\np{ln\_zdfexp}=false) (see \S\ref{STP}). Note that namelist variables 
 \np{ln\_zdfexp} and \np{nn\_zdfexp} apply to both tracers and dynamics. 
 
Index: branches/2012/dev_MERGE_2012/DOC/TexFiles/Chapters/Chap_TRA.tex
===================================================================
--- branches/2012/dev_MERGE_2012/DOC/TexFiles/Chapters/Chap_TRA.tex	(revision 3759)
+++ branches/2012/dev_MERGE_2012/DOC/TexFiles/Chapters/Chap_TRA.tex	(revision 3764)
@@ -264,5 +264,5 @@
 transport) rather than TVD. The TVD scheme is implemented in the \mdl{traadv\_tvd} module.
 
-For stability reasons (see \S\ref{DOM_nxt}),
+For stability reasons (see \S\ref{STP}),
 $\tau _u^{cen2}$ is evaluated  in (\ref{Eq_tra_adv_tvd}) using the \textit{now} tracer while $\tau _u^{ups}$ 
 is evaluated using the \textit{before} tracer. In other words, the advective part of 
@@ -337,5 +337,5 @@
 \np{ln\_traadv\_ubs}=true.
 
-For stability reasons  (see \S\ref{DOM_nxt}),
+For stability reasons  (see \S\ref{STP}),
 the first term  in \eqref{Eq_tra_adv_ubs} (which corresponds to a second order centred scheme) 
 is evaluated using the \textit{now} tracer (centred in time) while the 
@@ -451,5 +451,5 @@
 except for the pure vertical component that appears when a rotation tensor 
 is used. This latter term is solved implicitly together with the 
-vertical diffusion term (see \S\ref{DOM_nxt}).
+vertical diffusion term (see \S\ref{STP}).
 
 % -------------------------------------------------------------------------------------------------------------
Index: branches/2012/dev_MERGE_2012/DOC/TexFiles/Chapters/Chap_ZDF.tex
===================================================================
--- branches/2012/dev_MERGE_2012/DOC/TexFiles/Chapters/Chap_ZDF.tex	(revision 3759)
+++ branches/2012/dev_MERGE_2012/DOC/TexFiles/Chapters/Chap_ZDF.tex	(revision 3764)
@@ -120,5 +120,5 @@
 \end{equation}
 
-is computed from the wind stress vector $|\tau|$ and the reference dendity $ \rho_o$.
+is computed from the wind stress vector $|\tau|$ and the reference density $ \rho_o$.
 The final $h_{e}$ is further constrained by the adjustable bounds \np{rn\_mldmin} and \np{rn\_mldmax}.
 Once $h_{e}$ is computed, the vertical eddy coefficients within $h_{e}$ are set to 
@@ -1188,5 +1188,5 @@
 \includegraphics[width=0.90\textwidth]{./TexFiles/Figures/Fig_ZDF_M2_K1_tmx.pdf}
 \caption{  \label{Fig_ZDF_M2_K1_tmx} 
-(a) M2 and (b) K2 internal wave drag energy from \citet{Carrere_Lyard_GRL03} ($W/m^2$). }
+(a) M2 and (b) K1 internal wave drag energy from \citet{Carrere_Lyard_GRL03} ($W/m^2$). }
 \end{center}  	\end{figure}
 %>>>>>>>>>>>>>>>>>>>>>>>>>>>> 
@@ -1205,5 +1205,5 @@
 
 When \np{ln\_tmx\_itf}=true, the two key parameters $q$ and $F(z)$ are adjusted following 
-the parameterisation developed by \ref{Koch-Larrouy_al_GRL07}:
+the parameterisation developed by \citet{Koch-Larrouy_al_GRL07}:
 
 First, the Indonesian archipelago is a complex geographic region 
@@ -1219,5 +1219,5 @@
 Second, the vertical structure function, $F(z)$, is no more associated
 with a bottom intensification of the mixing, but with a maximum of 
-energy available within the thermocline. \ref{Koch-Larrouy_al_GRL07} 
+energy available within the thermocline. \citet{Koch-Larrouy_al_GRL07} 
 have suggested that the vertical distribution of the energy dissipation 
 proportional to $N^2$ below the core of the thermocline and to $N$ above. 
@@ -1236,5 +1236,5 @@
 and vertical distributions of the mixing are adequately prescribed 
 \citep{Koch-Larrouy_al_GRL07, Koch-Larrouy_al_OD08a, Koch-Larrouy_al_OD08b}.
-Note also that such a parameterisation has a sugnificant impact on the behaviour 
+Note also that such a parameterisation has a significant impact on the behaviour 
 of global coupled GCMs \citep{Koch-Larrouy_al_CD10}.
 
Index: branches/2012/dev_MERGE_2012/DOC/TexFiles/Namelist/namasm
===================================================================
--- branches/2012/dev_MERGE_2012/DOC/TexFiles/Namelist/namasm	(revision 3759)
+++ branches/2012/dev_MERGE_2012/DOC/TexFiles/Namelist/namasm	(revision 3764)
@@ -3,5 +3,4 @@
 !-----------------------------------------------------------------------
     ln_bkgwri = .false.    !  Logical switch for writing out background state 
-    ln_trjwri = .false.    !  Logical switch for writing out state trajectory
     ln_trainc = .false.    !  Logical switch for applying tracer increments
     ln_dyninc = .false.    !  Logical switch for applying velocity increments
@@ -14,5 +13,4 @@
     nitiaufin = 15         !  Timestep of end of IAU interval in [0,nitend-nit000-1]
     niaufn    = 0          !  Type of IAU weighting function
-    nittrjfrq = 0          !  Frequency of trajectory output for 4D-VAR
     ln_salfix = .false.    !  Logical switch for ensuring that the sa > salfixmin
     salfixmin = -9999      !  Minimum salinity after applying the increments
Index: branches/2012/dev_MERGE_2012/DOC/TexFiles/Namelist/namdyn_vor
===================================================================
--- branches/2012/dev_MERGE_2012/DOC/TexFiles/Namelist/namdyn_vor	(revision 3759)
+++ branches/2012/dev_MERGE_2012/DOC/TexFiles/Namelist/namdyn_vor	(revision 3764)
@@ -2,6 +2,6 @@
 &namdyn_vor    !   option of physics/algorithm (not control by CPP keys)
 !-----------------------------------------------------------------------
-   ln_dynvor_ene = .false. !  enstrophy conserving scheme  
-   ln_dynvor_ens = .false. !  energy conserving scheme    
+   ln_dynvor_ene = .false. !  energy    conserving scheme  
+   ln_dynvor_ens = .false. !  enstrophy conserving scheme    
    ln_dynvor_mix = .false. !  mixed scheme               
    ln_dynvor_een = .true.  !  energy & enstrophy scheme  
Index: branches/2012/dev_MERGE_2012/NEMOGCM/CONFIG/AMM12/EXP00/namelist
===================================================================
--- branches/2012/dev_MERGE_2012/NEMOGCM/CONFIG/AMM12/EXP00/namelist	(revision 3759)
+++ branches/2012/dev_MERGE_2012/NEMOGCM/CONFIG/AMM12/EXP00/namelist	(revision 3764)
@@ -3,5 +3,5 @@
 !! namelists    2 - Domain           (namzgr, namzgr_sco, namdom, namtsd)
 !!              3 - Surface boundary (namsbc, namsbc_ana, namsbc_flx, namsbc_clio, namsbc_core
-!!                                    namsbc_cpl, namtra_qsr, namsbc_rnf, 
+!!                                    namsbc_cpl, namtra_qsr, namsbc_rnf,
 !!                                    namsbc_apr, namsbc_ssr, namsbc_alb)
 !!              4 - lateral boundary (namlbc, namcla, namobc, namagrif, nambdy, nambdy_tide)
@@ -25,5 +25,5 @@
 !-----------------------------------------------------------------------
    nn_no       =       0   !  job number (no more used...)
-   cn_exp      =  "AMM12"  !  experience name 
+   cn_exp      =  "AMM12"  !  experience name
    nn_it000    =       1   !  first time step
    nn_itend    =    2880   !  last  time step (std 1 day = 288)
@@ -52,5 +52,5 @@
 !!   namzgr_sco   s-coordinate or hybrid z-s-coordinate
 !!   namdom       space and time domain (bathymetry, mesh, timestep)
-!!   namtsd       data: temperature & salinity                         
+!!   namtsd       data: temperature & salinity
 !!======================================================================
 !
@@ -107,5 +107,5 @@
 /
 !-----------------------------------------------------------------------
-&namtsd    !   data : Temperature  & Salinity                           
+&namtsd    !   data : Temperature  & Salinity
 !-----------------------------------------------------------------------
 !          ! file name ! frequency (hours)    ! variable ! time interp. ! clim  !'yearly' or ! weights  ! rotation !
@@ -142,6 +142,6 @@
    ln_ana      = .false    !  analytical formulation (T => fill namsbc_ana )
    ln_flx      = .true.    !  flux formulation       (T => fill namsbc_flx )
-   ln_blk_clio = .false.   !  CLIO bulk formulation                     (T => fill namsbc_clio) 
-   ln_blk_core = .false.   !  CORE bulk formulation                     (T => fill namsbc_core) 
+   ln_blk_clio = .false.   !  CLIO bulk formulation                     (T => fill namsbc_clio)
+   ln_blk_core = .false.   !  CORE bulk formulation                     (T => fill namsbc_core)
    ln_blk_mfs  = .false.   !  MFS bulk formulation                      (T => fill namsbc_mfs )
    ln_cpl      = .false.   !  Coupled formulation                       (T => fill namsbc_cpl )
@@ -156,6 +156,6 @@
    ln_rnf      = .true.    !  runoffs                                   (T => fill namsbc_rnf)
    ln_ssr      = .false.   !  Sea Surface Restoring on T and/or S       (T => fill namsbc_ssr)
-   nn_fwb      = 0         !  FreshWater Budget: =0 unchecked 
-                           !     =1 global mean of e-p-r set to zero at each time step 
+   nn_fwb      = 0         !  FreshWater Budget: =0 unchecked
+                           !     =1 global mean of e-p-r set to zero at each time step
                            !     =2 annual global mean of e-p-r set to zero
                            !     =3 global emp set to zero and spread out over erp area
@@ -185,5 +185,5 @@
    sn_emp      = 'amm12_flx'      ,          3        ,  'sowafldo'  ,  .true.      , .false. , 'daily'   ,  ''      ,  ''
    cn_dir      = './fluxes/'        !  root directory for the location of the flux files
-/      
+/
 !-----------------------------------------------------------------------
 &namsbc_clio   !   namsbc_clio  CLIO bulk formulae
@@ -242,20 +242,20 @@
 !                    !                       ! categories !  reference  !    orientation       ! grids  !
 ! send
-sn_snd_temp   =       'weighted oce and ice' ,    'no'    ,     ''      ,         ''           ,   ''    
-sn_snd_alb    =       'weighted ice'         ,    'no'    ,     ''      ,         ''           ,   ''    
-sn_snd_thick  =       'none'                 ,    'no'   ,     ''      ,         ''           ,   ''    
-sn_snd_crt    =       'none'                 ,    'no'    , 'spherical' , 'eastward-northward' ,  'T'       
-sn_snd_co2    =       'coupled'              ,    'no'    ,     ''      ,         ''           ,   ''        
+sn_snd_temp   =       'weighted oce and ice' ,    'no'    ,     ''      ,         ''           ,   ''
+sn_snd_alb    =       'weighted ice'         ,    'no'    ,     ''      ,         ''           ,   ''
+sn_snd_thick  =       'none'                 ,    'no'   ,     ''      ,         ''           ,   ''
+sn_snd_crt    =       'none'                 ,    'no'    , 'spherical' , 'eastward-northward' ,  'T'
+sn_snd_co2    =       'coupled'              ,    'no'    ,     ''      ,         ''           ,   ''
 ! receive
-sn_rcv_w10m   =       'none'                 ,    'no'    ,     ''      ,         ''          ,   ''    
-sn_rcv_taumod =       'coupled'              ,    'no'    ,     ''      ,         ''          ,   ''    
-sn_rcv_tau    =       'oce only'             ,    'no'    , 'cartesian' , 'eastward-northward',  'U,V'   
-sn_rcv_dqnsdt =       'coupled'              ,    'no'    ,     ''      ,         ''          ,   ''    
-sn_rcv_qsr    =       'oce and ice'          ,    'no'    ,     ''      ,         ''          ,   ''    
-sn_rcv_qns    =       'oce and ice'          ,    'no'    ,     ''      ,         ''          ,   ''    
-sn_rcv_emp    =       'conservative'         ,    'no'    ,     ''      ,         ''          ,   ''    
-sn_rcv_rnf    =       'coupled'              ,    'no'    ,     ''      ,         ''          ,   ''    
-sn_rcv_cal    =       'coupled'              ,    'no'    ,     ''      ,         ''          ,   ''    
-sn_rcv_co2    =       'coupled'              ,    'no'    ,     ''      ,         ''          ,   ''    
+sn_rcv_w10m   =       'none'                 ,    'no'    ,     ''      ,         ''          ,   ''
+sn_rcv_taumod =       'coupled'              ,    'no'    ,     ''      ,         ''          ,   ''
+sn_rcv_tau    =       'oce only'             ,    'no'    , 'cartesian' , 'eastward-northward',  'U,V'
+sn_rcv_dqnsdt =       'coupled'              ,    'no'    ,     ''      ,         ''          ,   ''
+sn_rcv_qsr    =       'oce and ice'          ,    'no'    ,     ''      ,         ''          ,   ''
+sn_rcv_qns    =       'oce and ice'          ,    'no'    ,     ''      ,         ''          ,   ''
+sn_rcv_emp    =       'conservative'         ,    'no'    ,     ''      ,         ''          ,   ''
+sn_rcv_rnf    =       'coupled'              ,    'no'    ,     ''      ,         ''          ,   ''
+sn_rcv_cal    =       'coupled'              ,    'no'    ,     ''      ,         ''          ,   ''
+sn_rcv_co2    =       'coupled'              ,    'no'    ,     ''      ,         ''          ,   ''
 /
 !-----------------------------------------------------------------------
@@ -323,12 +323,12 @@
    ln_sssr_bnd =   .true.  !  flag to bound erp term (associated with nn_sssr=2)
    rn_sssr_bnd =   4.e0    !  ABS(Max/Min) value of the damping erp term [mm/day]
-/      
+/
 !-----------------------------------------------------------------------
 &namsbc_alb    !   albedo parameters
 !-----------------------------------------------------------------------
-   rn_cloud    =    0.06   !  cloud correction to snow and ice albedo 
+   rn_cloud    =    0.06   !  cloud correction to snow and ice albedo
    rn_albice   =    0.53   !  albedo of melting ice in the arctic and antarctic
    rn_alphd    =    0.80   !  coefficients for linear interpolation used to
-   rn_alphc    =    0.65   !  compute albedo between two extremes values 
+   rn_alphc    =    0.65   !  compute albedo between two extremes values
    rn_alphdi   =    0.72   !  (Pyane, 1972)
 /
@@ -370,5 +370,5 @@
 !!   namcla        cross land advection
 !!   namobc        open boundaries parameters                           ("key_obc")
-!!   namagrif      agrif nested grid ( read by child model only )       ("key_agrif") 
+!!   namagrif      agrif nested grid ( read by child model only )       ("key_agrif")
 !!   nambdy        Unstructured open boundaries                         ("key_bdy")
 !!   namtide       Tidal forcing at open boundaries                     ("key_bdy_tides")
@@ -392,5 +392,5 @@
    ln_obc_clim = .false.   !  climatological obc data files (T) or not (F)
    ln_vol_cst  = .true.    !  impose the total volume conservation (T) or not (F)
-   ln_obc_fla  = .false.   !  Flather open boundary condition 
+   ln_obc_fla  = .false.   !  Flather open boundary condition
    nn_obcdta   =    1      !  = 0 the obc data are equal to the initial state
                            !  = 1 the obc data are read in 'obc.dta' files
@@ -439,5 +439,5 @@
 &nambdy        !  unstructured open boundaries                          ("key_bdy")
 !-----------------------------------------------------------------------
-    nb_bdy = 1                            !  number of open boundary sets       
+    nb_bdy = 1                            !  number of open boundary sets
     ln_coords_file = .true.               !  =T : read bdy coordinates from file
     cn_coords_file = 'coordinates.bdy.nc' !  bdy coordinates files
@@ -475,5 +475,5 @@
 /
 !-----------------------------------------------------------------------
-&nambdy_tide     ! tidal forcing at open boundaries              
+&nambdy_tide     ! tidal forcing at open boundaries
 !-----------------------------------------------------------------------
    filtide      = 'bdydta/amm12_bdytide_'         !  file name root of tidal forcing files
@@ -483,5 +483,5 @@
 !!======================================================================
 !!   nambfr        bottom friction
-!!   nambbc        bottom temperature boundary condition               
+!!   nambbc        bottom temperature boundary condition
 !!   nambbl        bottom boundary layer scheme                         ("key_trabbl")
 !!======================================================================
@@ -505,7 +505,7 @@
 !-----------------------------------------------------------------------
    ln_trabbc   = .false.   !  Apply a geothermal heating at the ocean bottom
-   nn_geoflx   =    2      !  geothermal heat flux: = 0 no flux 
+   nn_geoflx   =    2      !  geothermal heat flux: = 0 no flux
                            !     = 1 constant flux
-                           !     = 2 variable flux (read in geothermal_heating.nc in mW/m2) 
+                           !     = 2 variable flux (read in geothermal_heating.nc in mW/m2)
    rn_geoflx_cst = 86.4e-3 !  Constant value of geothermal heat flux [W/m2]
 /
@@ -525,5 +525,5 @@
 !!   namtra_adv    advection scheme
 !!   namtra_ldf    lateral diffusion scheme
-!!   namtra_dmp    T & S newtonian damping                        
+!!   namtra_dmp    T & S newtonian damping
 !!======================================================================
 !
@@ -539,12 +539,12 @@
 /
 !-----------------------------------------------------------------------
-&namtra_adv    !   advection scheme for tracer 
-!-----------------------------------------------------------------------
-   ln_traadv_cen2   =  .false.  !  2nd order centered scheme   
-   ln_traadv_tvd    =  .true.   !  TVD scheme                
-   ln_traadv_muscl  =  .false.  !  MUSCL scheme             
-   ln_traadv_muscl2 =  .false.  !  MUSCL2 scheme + cen2 at boundaries  
-   ln_traadv_ubs    =  .false.  !  UBS scheme                 
-   ln_traadv_qck    =  .false.  !  QUICKEST scheme                 
+&namtra_adv    !   advection scheme for tracer
+!-----------------------------------------------------------------------
+   ln_traadv_cen2   =  .false.  !  2nd order centered scheme
+   ln_traadv_tvd    =  .true.   !  TVD scheme
+   ln_traadv_muscl  =  .false.  !  MUSCL scheme
+   ln_traadv_muscl2 =  .false.  !  MUSCL2 scheme + cen2 at boundaries
+   ln_traadv_ubs    =  .false.  !  UBS scheme
+   ln_traadv_qck    =  .false.  !  QUICKEST scheme
    ln_traadv_msc_ups=  .false.  !  use upstream scheme within muscl
 /
@@ -574,5 +574,5 @@
 /
 !-----------------------------------------------------------------------
-&namtra_dmp    !   tracer: T & S newtonian damping                  
+&namtra_dmp    !   tracer: T & S newtonian damping
 !-----------------------------------------------------------------------
    ln_tradmp   =  .false.  !  add a damping termn (T) or not (F)
@@ -602,20 +602,20 @@
 &namdyn_adv    !   formulation of the momentum advection
 !-----------------------------------------------------------------------
-   ln_dynadv_vec = .true.  !  vector form (T) or flux form (F)  
+   ln_dynadv_vec = .true.  !  vector form (T) or flux form (F)
    ln_dynadv_cen2= .false. !  flux form - 2nd order centered scheme
-   ln_dynadv_ubs = .false. !  flux form - 3rd order UBS      scheme 
-/  
+   ln_dynadv_ubs = .false. !  flux form - 3rd order UBS      scheme
+/
 !-----------------------------------------------------------------------
 &namdyn_vor    !   option of physics/algorithm (not control by CPP keys)
 !-----------------------------------------------------------------------
-   ln_dynvor_ene = .false. !  enstrophy conserving scheme  
-   ln_dynvor_ens = .false. !  energy conserving scheme    
-   ln_dynvor_mix = .false. !  mixed scheme               
-   ln_dynvor_een = .true.  !  energy & enstrophy scheme  
+   ln_dynvor_ene = .false. !  energy    conserving scheme  
+   ln_dynvor_ens = .false. !  enstrophy conserving scheme    
+   ln_dynvor_mix = .false. !  mixed scheme
+   ln_dynvor_een = .true.  !  energy & enstrophy scheme
 /
 !-----------------------------------------------------------------------
 &namdyn_hpg    !   Hydrostatic pressure gradient option
 !-----------------------------------------------------------------------
-   ln_hpg_zco  = .false.   !  z-coordinate - full steps                   
+   ln_hpg_zco  = .false.   !  z-coordinate - full steps
    ln_hpg_zps  = .false.   !  z-coordinate - partial steps (interpolation)
    ln_hpg_sco  = .false.    !  s-coordinate (standard jacobian formulation)
@@ -635,12 +635,12 @@
 &namdyn_ldf    !   lateral diffusion on momentum
 !-----------------------------------------------------------------------
-   !                       !  Type of the operator : 
-   ln_dynldf_lap    =  .true.   !  laplacian operator         
+   !                       !  Type of the operator :
+   ln_dynldf_lap    =  .true.   !  laplacian operator
    ln_dynldf_bilap  =  .true.   !  bilaplacian operator
                            !  Direction of action  :
-   ln_dynldf_level  =  .false.  !  iso-level               
+   ln_dynldf_level  =  .false.  !  iso-level
    ln_dynldf_hor    =  .true.   !  horizontal (geopotential)            (require "key_ldfslp" in s-coord.)
    ln_dynldf_iso    =  .false.  !  iso-neutral                          (require "key_ldfslp")
-                           !  Coefficient 
+                           !  Coefficient
    rn_ahm_0_lap     = 60.0      !  horizontal laplacian eddy viscosity   [m2/s]
    rn_ahmb_0        =  0.0      !  background eddy viscosity for ldf_iso [m2/s]
@@ -718,11 +718,11 @@
 &namzdf_kpp    !   K-Profile Parameterization dependent vertical mixing  ("key_zdfkpp", and optionally:
 !------------------------------------------------------------------------ "key_kppcustom" or "key_kpplktb")
-   ln_kpprimix = .true.    !  shear instability mixing 
+   ln_kpprimix = .true.    !  shear instability mixing
    rn_difmiw   =  1.0e-04  !  constant internal wave viscosity [m2/s]
    rn_difsiw   =  0.1e-04  !  constant internal wave diffusivity [m2/s]
    rn_riinfty  =  0.8      !  local Richardson Number limit for shear instability
    rn_difri    =  0.0050   !  maximum shear mixing at Rig = 0    [m2/s]
-   rn_bvsqcon  = -0.01e-07 !  Brunt-Vaisala squared for maximum convection [1/s2] 
-   rn_difcon   =  1.       !  maximum mixing in interior convection [m2/s] 
+   rn_bvsqcon  = -0.01e-07 !  Brunt-Vaisala squared for maximum convection [1/s2]
+   rn_difcon   =  1.       !  maximum mixing in interior convection [m2/s]
    nn_avb      =  0        !  horizontal averaged (=1) or not (=0) on avt and amv
    nn_ave      =  1        !  constant (=0) or profile (=1) background on avt
@@ -758,5 +758,5 @@
    rn_n2min    = 1.e-8     !  threshold of the Brunt-Vaisala frequency (s-1)
    rn_tfe      = 0.333     !  tidal dissipation efficiency
-   rn_me       = 0.2       !  mixing efficiency 
+   rn_me       = 0.2       !  mixing efficiency
    ln_tmx_itf  = .FALSE.   !  ITF specific parameterisation
    rn_tfe_itf  = 1.        !  ITF tidal dissipation efficiency
@@ -768,9 +768,9 @@
 !!   nammpp            Massively Parallel Processing                    ("key_mpp_mpi)
 !!   namctl            Control prints & Benchmark
-!!   namsol            elliptic solver / island / free surface 
-!!======================================================================
-!
-!-----------------------------------------------------------------------
-&namsol        !   elliptic solver / island / free surface 
+!!   namsol            elliptic solver / island / free surface
+!!======================================================================
+!
+!-----------------------------------------------------------------------
+&namsol        !   elliptic solver / island / free surface
 !-----------------------------------------------------------------------
    nn_solv     =      1    !  elliptic solver: =1 preconditioned conjugate gradient (pcg)
@@ -818,5 +818,5 @@
 !!   namflo       float parameters                                      ("key_float")
 !!   namptr       Poleward Transport Diagnostics
-!!   namhsb       Heat and salt budgets 
+!!   namhsb       Heat and salt budgets
 !!======================================================================
 !
@@ -856,6 +856,6 @@
    jpnnewflo     = 0          !  number of floats for the restart
    ln_rstflo     = .false.    !  float restart (T) or not (F)
-   nn_writefl    =      75    !  frequency of writing in float output file 
-   nn_stockfl    =    5475    !  frequency of creation of the float restart file 
+   nn_writefl    =      75    !  frequency of writing in float output file
+   nn_stockfl    =    5475    !  frequency of creation of the float restart file
    ln_argo       = .false.    !  Argo type floats (stay at the surface each 10 days)
    ln_flork4     = .false.    !  trajectories computed with a 4th order Runge-Kutta (T)
@@ -869,5 +869,5 @@
    ln_diaptr  = .false.    !  Poleward heat and salt transport (T) or not (F)
    ln_diaznl  = .false.    !  Add zonal means and meridional stream functions
-   ln_subbas  = .false.    !  Atlantic/Pacific/Indian basins computation (T) or not 
+   ln_subbas  = .false.    !  Atlantic/Pacific/Indian basins computation (T) or not
                            !  (orca configuration only, need input basins mask file named "subbasins.nc"
    ln_ptrcomp = .false.    !  Add decomposition : overturning
@@ -876,5 +876,5 @@
 /
 !-----------------------------------------------------------------------
-&namhsb       !  Heat and salt budgets 
+&namhsb       !  Heat and salt budgets
 !-----------------------------------------------------------------------
    ln_diahsb  = .false.    !  check the heat and salt budgets (T) or not (F)
@@ -908,15 +908,15 @@
 &namobs       !  observation usage switch                               ('key_diaobs')
 !-----------------------------------------------------------------------
-   ln_t3d     = .false.    ! Logical switch for T profile observations         
-   ln_s3d     = .false.    ! Logical switch for S profile observations          
-   ln_ena     = .false.    ! Logical switch for ENACT insitu data set           
-   !                       !     ln_cor                  Logical switch for Coriolis insitu data set       
-   ln_profb   = .false.    ! Logical switch for feedback insitu data set     
-   ln_sla     = .false.    ! Logical switch for SLA observations               
-
-   ln_sladt   = .false.    ! Logical switch for AVISO SLA data              
-
-   ln_slafb   = .false.    ! Logical switch for feedback SLA data            
-                           !     ln_ssh                  Logical switch for SSH observations              
+   ln_t3d     = .false.    ! Logical switch for T profile observations
+   ln_s3d     = .false.    ! Logical switch for S profile observations
+   ln_ena     = .false.    ! Logical switch for ENACT insitu data set
+   !                       !     ln_cor                  Logical switch for Coriolis insitu data set
+   ln_profb   = .false.    ! Logical switch for feedback insitu data set
+   ln_sla     = .false.    ! Logical switch for SLA observations
+
+   ln_sladt   = .false.    ! Logical switch for AVISO SLA data
+
+   ln_slafb   = .false.    ! Logical switch for feedback SLA data
+                           !     ln_ssh                  Logical switch for SSH observations
 
    ln_sst     = .true.     ! Logical switch for SST observations
@@ -924,56 +924,55 @@
    ln_ghrsst  = .false.    !     ln_ghrsst               Logical switch for GHRSST observations      
 
-   ln_sstfb   = .false.    ! Logical switch for feedback SST data          
-                           !     ln_sss                  Logical switch for SSS observations              
-                           !     ln_seaice               Logical switch for Sea Ice observations        
-                           !     ln_vel3d                Logical switch for velocity observations         
-                           !     ln_velavcur             Logical switch for velocity daily av. cur.    
-                           !     ln_velhrcur             Logical switch for velocity high freq. cur.   
-                           !     ln_velavadcp            Logical switch for velocity daily av. ADCP  
+   ln_sstfb   = .false.    ! Logical switch for feedback SST data
+                           !     ln_sss                  Logical switch for SSS observations
+                           !     ln_seaice               Logical switch for Sea Ice observations
+                           !     ln_vel3d                Logical switch for velocity observations
+                           !     ln_velavcur             Logical switch for velocity daily av. cur.
+                           !     ln_velhrcur             Logical switch for velocity high freq. cur.
+                           !     ln_velavadcp            Logical switch for velocity daily av. ADCP
                            !     ln_velhradcp            Logical switch for velocity high freq. ADCP
-                           !     ln_velfb                Logical switch for feedback velocity data       
-                           !     ln_grid_global          Global distribtion of observations         
-                           !     ln_grid_search_lookup   Logical switch for obs grid search w/lookup table  
-                           !     grid_search_file        Grid search lookup file header 
-                           !     enactfiles              ENACT input observation file names 
-                           !     coriofiles              Coriolis input observation file name  
-   !                       ! profbfiles: Profile feedback input observation file name 
+                           !     ln_velfb                Logical switch for feedback velocity data
+                           !     ln_grid_global          Global distribtion of observations
+                           !     ln_grid_search_lookup   Logical switch for obs grid search w/lookup table
+                           !     grid_search_file        Grid search lookup file header
+                           !     enactfiles              ENACT input observation file names
+                           !     coriofiles              Coriolis input observation file name
+   !                       ! profbfiles: Profile feedback input observation file name
    profbfiles = 'profiles_01.nc'
-                           !     ln_profb_enatim         Enact feedback input time setting switch    
+                           !     ln_profb_enatim         Enact feedback input time setting switch
                            !     slafilesact             Active SLA input observation file name
-                           !     slafilespas             Passive SLA input observation file name 
-   !                       ! slafbfiles: Feedback SLA input observation file name 
+                           !     slafilespas             Passive SLA input observation file name
+   !                       ! slafbfiles: Feedback SLA input observation file name
    slafbfiles = 'sla_01.nc'
-                           !     sstfiles                GHRSST input observation file name       
-   !                       ! sstfbfiles: Feedback SST input observation file name 
+                           !     sstfiles                GHRSST input observation file name
+   !                       ! sstfbfiles: Feedback SST input observation file name
    sstfbfiles = 'sst_01.nc' 'sst_02.nc' 'sst_03.nc' 'sst_04.nc' 'sst_05.nc'
-                           !     seaicefiles             Sea Ice input observation file name 
-                           !     velavcurfiles           Vel. cur. daily av. input file name  
-                           !     velhvcurfiles           Vel. cur. high freq. input file name  
-                           !     velavadcpfiles          Vel. ADCP daily av. input file name    
-                           !     velhvadcpfiles          Vel. ADCP high freq. input file name 
-                           !     velfbfiles              Vel. feedback input observation file name 
-                           !     dobsini                 Initial date in window YYYYMMDD.HHMMSS       
-                           !     dobsend                 Final date in window YYYYMMDD.HHMMSS         
-                           !     n1dint                  Type of vertical interpolation method        
-                           !     n2dint                  Type of horizontal interpolation method       
-                           !     ln_nea                  Rejection of observations near land switch    
-   nmsshc     = 0          ! MSSH correction scheme                         
-                           !     mdtcorr                 MDT  correction                               
-                           !     mdtcutoff               MDT cutoff for computed correction          
-   ln_altbias = .false.    ! Logical switch for alt bias                
-   ln_ignmis  = .true.     ! Logical switch for ignoring missing files   
-                           !     endailyavtypes   ENACT daily average types                    
+                           !     seaicefiles             Sea Ice input observation file name
+                           !     velavcurfiles           Vel. cur. daily av. input file name
+                           !     velhvcurfiles           Vel. cur. high freq. input file name
+                           !     velavadcpfiles          Vel. ADCP daily av. input file name
+                           !     velhvadcpfiles          Vel. ADCP high freq. input file name
+                           !     velfbfiles              Vel. feedback input observation file name
+                           !     dobsini                 Initial date in window YYYYMMDD.HHMMSS
+                           !     dobsend                 Final date in window YYYYMMDD.HHMMSS
+                           !     n1dint                  Type of vertical interpolation method
+                           !     n2dint                  Type of horizontal interpolation method
+                           !     ln_nea                  Rejection of observations near land switch
+   nmsshc     = 0          ! MSSH correction scheme
+                           !     mdtcorr                 MDT  correction
+                           !     mdtcutoff               MDT cutoff for computed correction
+   ln_altbias = .false.    ! Logical switch for alt bias
+   ln_ignmis  = .true.     ! Logical switch for ignoring missing files
+                           !     endailyavtypes   ENACT daily average types
    ln_grid_global = .true.
    ln_grid_search_lookup = .false.
-/ 
+/
 !-----------------------------------------------------------------------
 &nam_asminc   !   assimilation increments                               ('key_asminc')
 !-----------------------------------------------------------------------
-    ln_bkgwri = .false.    !  Logical switch for writing out background state 
-    ln_trjwri = .false.    !  Logical switch for writing out state trajectory
+    ln_bkgwri = .false.    !  Logical switch for writing out background state
     ln_trainc = .false.    !  Logical switch for applying tracer increments
     ln_dyninc = .false.    !  Logical switch for applying velocity increments
-    ln_sshinc = .false.    !  Logical switch for applying SSH increments 
+    ln_sshinc = .false.    !  Logical switch for applying SSH increments
     ln_asmdin = .false.    !  Logical switch for Direct Initialization (DI)
     ln_asmiau = .false.    !  Logical switch for Incremental Analysis Updating (IAU)
@@ -983,5 +982,4 @@
     nitiaufin = 15         !  Timestep of end of IAU interval in [0,nitend-nit000-1]
     niaufn    = 0          !  Type of IAU weighting function
-    nittrjfrq = 0          !  Frequency of trajectory output for 4D-VAR
     ln_salfix = .false.    !  Logical switch for ensuring that the sa > salfixmin
     salfixmin = -9999      !  Minimum salinity after applying the increments
Index: branches/2012/dev_MERGE_2012/NEMOGCM/CONFIG/GYRE/EXP00/namelist
===================================================================
--- branches/2012/dev_MERGE_2012/NEMOGCM/CONFIG/GYRE/EXP00/namelist	(revision 3759)
+++ branches/2012/dev_MERGE_2012/NEMOGCM/CONFIG/GYRE/EXP00/namelist	(revision 3764)
@@ -3,5 +3,5 @@
 !! namelists    2 - Domain           (namzgr, namzgr_sco, namdom, namtsd)
 !!              3 - Surface boundary (namsbc, namsbc_ana, namsbc_flx, namsbc_clio, namsbc_core
-!!                                    namsbc_cpl, namtra_qsr, namsbc_rnf, 
+!!                                    namsbc_cpl, namtra_qsr, namsbc_rnf,
 !!                                    namsbc_apr, namsbc_ssr, namsbc_alb)
 !!              4 - lateral boundary (namlbc, namcla, namobc, namagrif, nambdy, nambdy_tide)
@@ -25,5 +25,5 @@
 !-----------------------------------------------------------------------
    nn_no       =       0   !  job number (no more used...)
-   cn_exp      =  "GYRE"   !  experience name 
+   cn_exp      =  "GYRE"   !  experience name
    nn_it000    =       1   !  first time step
    nn_itend    =    4320   !  last  time step
@@ -52,5 +52,5 @@
 !!   namzgr_sco   s-coordinate or hybrid z-s-coordinate
 !!   namdom       space and time domain (bathymetry, mesh, timestep)
-!!   namtsd       data: temperature & salinity         
+!!   namtsd       data: temperature & salinity
 !!======================================================================
 !
@@ -107,5 +107,5 @@
 /
 !-----------------------------------------------------------------------
-&namtsd    !   data : Temperature  & Salinity                           
+&namtsd    !   data : Temperature  & Salinity
 !-----------------------------------------------------------------------
 !          ! file name ! frequency (hours)    ! variable ! time interp. ! clim  !'yearly' or ! weights  ! rotation !
@@ -138,10 +138,10 @@
 &namsbc        !   Surface Boundary Condition (surface module)
 !-----------------------------------------------------------------------
-   nn_fsbc     = 1         !  frequency of surface boundary condition computation 
+   nn_fsbc     = 1         !  frequency of surface boundary condition computation
                            !     (also = the frequency of sea-ice model call)
-   ln_ana      = .true.    !  analytical formulation                    (T => fill namsbc_ana ) 
+   ln_ana      = .true.    !  analytical formulation                    (T => fill namsbc_ana )
    ln_flx      = .false.   !  flux formulation                          (T => fill namsbc_flx )
-   ln_blk_clio = .false.   !  CLIO bulk formulation                     (T => fill namsbc_clio) 
-   ln_blk_core = .false.   !  CORE bulk formulation                     (T => fill namsbc_core) 
+   ln_blk_clio = .false.   !  CLIO bulk formulation                     (T => fill namsbc_clio)
+   ln_blk_core = .false.   !  CORE bulk formulation                     (T => fill namsbc_core)
    ln_blk_mfs  = .false.   !  MFS bulk formulation                      (T => fill namsbc_mfs )
    ln_cpl      = .false.   !  Coupled formulation                       (T => fill namsbc_cpl )
@@ -156,6 +156,6 @@
    ln_rnf      = .false.   !  runoffs                                   (T => fill namsbc_rnf)
    ln_ssr      = .false.   !  Sea Surface Restoring on T and/or S       (T => fill namsbc_ssr)
-   nn_fwb      = 0         !  FreshWater Budget: =0 unchecked 
-                           !     =1 global mean of e-p-r set to zero at each time step 
+   nn_fwb      = 0         !  FreshWater Budget: =0 unchecked
+                           !     =1 global mean of e-p-r set to zero at each time step
                            !     =2 annual global mean of e-p-r set to zero
                            !     =3 global emp set to zero and spread out over erp area
@@ -186,5 +186,5 @@
 
    cn_dir      = './'      !  root directory for the location of the flux files
-/      
+/
 !-----------------------------------------------------------------------
 &namsbc_clio   !   namsbc_clio  CLIO bulk formulae
@@ -243,20 +243,20 @@
 !                    !                       ! categories !  reference  !    orientation       ! grids  !
 ! send
-sn_snd_temp   =       'weighted oce and ice' ,    'no'    ,     ''      ,         ''           ,   ''    
-sn_snd_alb    =       'weighted ice'         ,    'no'    ,     ''      ,         ''           ,   ''    
-sn_snd_thick  =       'none'                 ,    'no'   ,     ''      ,         ''           ,   ''    
-sn_snd_crt    =       'none'                 ,    'no'    , 'spherical' , 'eastward-northward' ,  'T'       
-sn_snd_co2    =       'coupled'              ,    'no'    ,     ''      ,         ''           ,   ''        
+sn_snd_temp   =       'weighted oce and ice' ,    'no'    ,     ''      ,         ''           ,   ''
+sn_snd_alb    =       'weighted ice'         ,    'no'    ,     ''      ,         ''           ,   ''
+sn_snd_thick  =       'none'                 ,    'no'   ,     ''      ,         ''           ,   ''
+sn_snd_crt    =       'none'                 ,    'no'    , 'spherical' , 'eastward-northward' ,  'T'
+sn_snd_co2    =       'coupled'              ,    'no'    ,     ''      ,         ''           ,   ''
 ! receive
-sn_rcv_w10m   =       'none'                 ,    'no'    ,     ''      ,         ''          ,   ''    
-sn_rcv_taumod =       'coupled'              ,    'no'    ,     ''      ,         ''          ,   ''    
-sn_rcv_tau    =       'oce only'             ,    'no'    , 'cartesian' , 'eastward-northward',  'U,V'   
-sn_rcv_dqnsdt =       'coupled'              ,    'no'    ,     ''      ,         ''          ,   ''    
-sn_rcv_qsr    =       'oce and ice'          ,    'no'    ,     ''      ,         ''          ,   ''    
-sn_rcv_qns    =       'oce and ice'          ,    'no'    ,     ''      ,         ''          ,   ''    
-sn_rcv_emp    =       'conservative'         ,    'no'    ,     ''      ,         ''          ,   ''    
-sn_rcv_rnf    =       'coupled'              ,    'no'    ,     ''      ,         ''          ,   ''    
-sn_rcv_cal    =       'coupled'              ,    'no'    ,     ''      ,         ''          ,   ''    
-sn_rcv_co2    =       'coupled'              ,    'no'    ,     ''      ,         ''          ,   ''    
+sn_rcv_w10m   =       'none'                 ,    'no'    ,     ''      ,         ''          ,   ''
+sn_rcv_taumod =       'coupled'              ,    'no'    ,     ''      ,         ''          ,   ''
+sn_rcv_tau    =       'oce only'             ,    'no'    , 'cartesian' , 'eastward-northward',  'U,V'
+sn_rcv_dqnsdt =       'coupled'              ,    'no'    ,     ''      ,         ''          ,   ''
+sn_rcv_qsr    =       'oce and ice'          ,    'no'    ,     ''      ,         ''          ,   ''
+sn_rcv_qns    =       'oce and ice'          ,    'no'    ,     ''      ,         ''          ,   ''
+sn_rcv_emp    =       'conservative'         ,    'no'    ,     ''      ,         ''          ,   ''
+sn_rcv_rnf    =       'coupled'              ,    'no'    ,     ''      ,         ''          ,   ''
+sn_rcv_cal    =       'coupled'              ,    'no'    ,     ''      ,         ''          ,   ''
+sn_rcv_co2    =       'coupled'              ,    'no'    ,     ''      ,         ''          ,   ''
 /
 !-----------------------------------------------------------------------
@@ -266,5 +266,5 @@
 !              !             !  (if <0  months)  !   name    !   (logical)  !  (T/F) ! 'monthly' ! filename ! pairing  !
    sn_chl      ='chlorophyll',        -1         , 'CHLA'    ,   .true.     , .true. , 'yearly'  , ''       , ''
- 
+
    cn_dir      = './'      !  root directory for the location of the runoff files
    ln_traqsr   = .true.    !  Light penetration (T) or not (F)
@@ -315,5 +315,5 @@
    sn_sst      = 'sst_data'  ,        24         ,  'sst'    ,    .false.   , .false., 'yearly'  , ''       , ''
    sn_sss      = 'sss_data'  ,        -1         ,  'sss'    ,    .true.    , .true. , 'yearly'  , ''       , ''
-    
+
    cn_dir      = './'      !  root directory for the location of the runoff files
    nn_sstr     =     0     !  add a retroaction term in the surface heat       flux (=1) or not (=0)
@@ -324,12 +324,12 @@
    ln_sssr_bnd =   .false. !  flag to bound erp term (associated with nn_sssr=2)
    rn_sssr_bnd =   4.e0    !  ABS(Max/Min) value of the damping erp term [mm/day]
-/      
+/
 !-----------------------------------------------------------------------
 &namsbc_alb    !   albedo parameters
 !-----------------------------------------------------------------------
-   rn_cloud    =    0.06   !  cloud correction to snow and ice albedo 
+   rn_cloud    =    0.06   !  cloud correction to snow and ice albedo
    rn_albice   =    0.53   !  albedo of melting ice in the arctic and antarctic
    rn_alphd    =    0.80   !  coefficients for linear interpolation used to
-   rn_alphc    =    0.65   !  compute albedo between two extremes values 
+   rn_alphc    =    0.65   !  compute albedo between two extremes values
    rn_alphdi   =    0.72   !  (Pyane, 1972)
 /
@@ -375,5 +375,5 @@
 !!   namcla        cross land advection
 !!   namobc        open boundaries parameters                           ("key_obc")
-!!   namagrif      agrif nested grid ( read by child model only )       ("key_agrif") 
+!!   namagrif      agrif nested grid ( read by child model only )       ("key_agrif")
 !!   nambdy        Unstructured open boundaries                         ("key_bdy")
 !!   namtide       Tidal forcing at open boundaries                     ("key_bdy_tides")
@@ -397,5 +397,5 @@
    ln_obc_clim = .false.   !  climatological obc data files (T) or not (F)
    ln_vol_cst  = .true.    !  impose the total volume conservation (T) or not (F)
-   ln_obc_fla  = .false.   !  Flather open boundary condition 
+   ln_obc_fla  = .false.   !  Flather open boundary condition
    nn_obcdta   =    1      !  = 0 the obc data are equal to the initial state
                            !  = 1 the obc data are read in 'obc.dta' files
@@ -446,5 +446,5 @@
 &nambdy        !  unstructured open boundaries                          ("key_bdy")
 !-----------------------------------------------------------------------
-    nb_bdy = 1                            !  number of open boundary sets       
+    nb_bdy = 1                            !  number of open boundary sets
     ln_coords_file = .true.               !  =T : read bdy coordinates from file
     cn_coords_file = 'coordinates.bdy.nc' !  bdy coordinates files
@@ -482,5 +482,5 @@
 /
 !-----------------------------------------------------------------------
-&nambdy_tide     ! tidal forcing at open boundaries              
+&nambdy_tide     ! tidal forcing at open boundaries
 !-----------------------------------------------------------------------
    filtide      = 'bdydta/amm12_bdytide_'         !  file name root of tidal forcing files
@@ -521,5 +521,5 @@
 !!======================================================================
 !!   nambfr        bottom friction
-!!   nambbc        bottom temperature boundary condition               
+!!   nambbc        bottom temperature boundary condition
 !!   nambbl        bottom boundary layer scheme                         ("key_trabbl")
 !!======================================================================
@@ -541,7 +541,7 @@
 !-----------------------------------------------------------------------
    ln_trabbc   = .false.   !  Apply a geothermal heating at the ocean bottom
-   nn_geoflx   =    0      !  geothermal heat flux: = 0 no flux 
+   nn_geoflx   =    0      !  geothermal heat flux: = 0 no flux
                            !     = 1 constant flux
-                           !     = 2 variable flux (read in geothermal_heating.nc in mW/m2) 
+                           !     = 2 variable flux (read in geothermal_heating.nc in mW/m2)
    rn_geoflx_cst = 86.4e-3 !  Constant value of geothermal heat flux [W/m2]
 /
@@ -561,5 +561,5 @@
 !!   namtra_adv    advection scheme
 !!   namtra_ldf    lateral diffusion scheme
-!!   namtra_dmp    T & S newtonian damping                        
+!!   namtra_dmp    T & S newtonian damping
 !!======================================================================
 !
@@ -575,12 +575,12 @@
 /
 !-----------------------------------------------------------------------
-&namtra_adv    !   advection scheme for tracer 
-!-----------------------------------------------------------------------
-   ln_traadv_cen2   =  .false.  !  2nd order centered scheme   
-   ln_traadv_tvd    =  .true.   !  TVD scheme                
-   ln_traadv_muscl  =  .false.  !  MUSCL scheme             
-   ln_traadv_muscl2 =  .false.  !  MUSCL2 scheme + cen2 at boundaries  
-   ln_traadv_ubs    =  .false.  !  UBS scheme                 
-   ln_traadv_qck    =  .false.  !  QUICKEST scheme                 
+&namtra_adv    !   advection scheme for tracer
+!-----------------------------------------------------------------------
+   ln_traadv_cen2   =  .false.  !  2nd order centered scheme
+   ln_traadv_tvd    =  .true.   !  TVD scheme
+   ln_traadv_muscl  =  .false.  !  MUSCL scheme
+   ln_traadv_muscl2 =  .false.  !  MUSCL2 scheme + cen2 at boundaries
+   ln_traadv_ubs    =  .false.  !  UBS scheme
+   ln_traadv_qck    =  .false.  !  QUICKEST scheme
    ln_traadv_msc_ups=  .false.  !  use upstream scheme within muscl 
 /
@@ -610,5 +610,5 @@
 /
 !-----------------------------------------------------------------------
-&namtra_dmp    !   tracer: T & S newtonian damping                      
+&namtra_dmp    !   tracer: T & S newtonian damping
 !-----------------------------------------------------------------------
    ln_tradmp   =  .false.  !  add a damping termn (T) or not (F)
@@ -638,20 +638,20 @@
 &namdyn_adv    !   formulation of the momentum advection
 !-----------------------------------------------------------------------
-   ln_dynadv_vec = .true.  !  vector form (T) or flux form (F)  
+   ln_dynadv_vec = .true.  !  vector form (T) or flux form (F)
    ln_dynadv_cen2= .false. !  flux form - 2nd order centered scheme
-   ln_dynadv_ubs = .false. !  flux form - 3rd order UBS      scheme 
-/  
+   ln_dynadv_ubs = .false. !  flux form - 3rd order UBS      scheme
+/
 !-----------------------------------------------------------------------
 &namdyn_vor    !   option of physics/algorithm (not control by CPP keys)
 !-----------------------------------------------------------------------
-   ln_dynvor_ene = .true.  !  enstrophy conserving scheme  
-   ln_dynvor_ens = .false. !  energy conserving scheme    
-   ln_dynvor_mix = .false. !  mixed scheme               
-   ln_dynvor_een = .false. !  energy & enstrophy scheme  
+   ln_dynvor_ene = .true.  !  energy    conserving scheme  
+   ln_dynvor_ens = .false. !  enstrophy conserving scheme    
+   ln_dynvor_mix = .false. !  mixed scheme
+   ln_dynvor_een = .false. !  energy & enstrophy scheme
 /
 !-----------------------------------------------------------------------
 &namdyn_hpg    !   Hydrostatic pressure gradient option
 !-----------------------------------------------------------------------
-   ln_hpg_zco  = .true.    !  z-coordinate - full steps                   
+   ln_hpg_zco  = .true.    !  z-coordinate - full steps
    ln_hpg_zps  = .false.   !  z-coordinate - partial steps (interpolation)
    ln_hpg_sco  = .false.   !  s-coordinate (standard jacobian formulation)
@@ -671,9 +671,9 @@
 &namdyn_ldf    !   lateral diffusion on momentum
 !-----------------------------------------------------------------------
-   !                       !  Type of the operator : 
-   ln_dynldf_lap    =  .true.   !  laplacian operator         
-   ln_dynldf_bilap  =  .false.  !  bilaplacian operator    
-   !                       !  Direction of action  : 
-   ln_dynldf_level  =  .false.  !  iso-level               
+   !                       !  Type of the operator :
+   ln_dynldf_lap    =  .true.   !  laplacian operator
+   ln_dynldf_bilap  =  .false.  !  bilaplacian operator
+   !                       !  Direction of action  :
+   ln_dynldf_level  =  .false.  !  iso-level
    ln_dynldf_hor    =  .true.   !  horizontal (geopotential)            (require "key_ldfslp" in s-coord.)
    ln_dynldf_iso    =  .false.  !  iso-neutral                          (require "key_ldfslp")
@@ -754,11 +754,11 @@
 &namzdf_kpp    !   K-Profile Parameterization dependent vertical mixing  ("key_zdfkpp", and optionally:
 !------------------------------------------------------------------------ "key_kppcustom" or "key_kpplktb")
-   ln_kpprimix = .true.    !  shear instability mixing 
+   ln_kpprimix = .true.    !  shear instability mixing
    rn_difmiw   =  1.0e-04  !  constant internal wave viscosity [m2/s]
    rn_difsiw   =  0.1e-04  !  constant internal wave diffusivity [m2/s]
    rn_riinfty  =  0.8      !  local Richardson Number limit for shear instability
    rn_difri    =  0.0050   !  maximum shear mixing at Rig = 0    [m2/s]
-   rn_bvsqcon  = -0.01e-07 !  Brunt-Vaisala squared for maximum convection [1/s2] 
-   rn_difcon   =  1.       !  maximum mixing in interior convection [m2/s] 
+   rn_bvsqcon  = -0.01e-07 !  Brunt-Vaisala squared for maximum convection [1/s2]
+   rn_difcon   =  1.       !  maximum mixing in interior convection [m2/s]
    nn_avb      =  0        !  horizontal averaged (=1) or not (=0) on avt and amv
    nn_ave      =  1        !  constant (=0) or profile (=1) background on avt
@@ -794,5 +794,5 @@
    rn_n2min    = 1.e-8     !  threshold of the Brunt-Vaisala frequency (s-1)
    rn_tfe      = 0.333     !  tidal dissipation efficiency
-   rn_me       = 0.2       !  mixing efficiency 
+   rn_me       = 0.2       !  mixing efficiency
    ln_tmx_itf  = .false.   !  ITF specific parameterisation
    rn_tfe_itf  = 1.        !  ITF tidal dissipation efficiency
@@ -804,9 +804,9 @@
 !!   nammpp            Massively Parallel Processing                    ("key_mpp_mpi)
 !!   namctl            Control prints & Benchmark
-!!   namsol            elliptic solver / island / free surface 
-!!======================================================================
-!
-!-----------------------------------------------------------------------
-&namsol        !   elliptic solver / island / free surface 
+!!   namsol            elliptic solver / island / free surface
+!!======================================================================
+!
+!-----------------------------------------------------------------------
+&namsol        !   elliptic solver / island / free surface
 !-----------------------------------------------------------------------
    nn_solv     =      2    !  elliptic solver: =1 preconditioned conjugate gradient (pcg)
@@ -827,7 +827,7 @@
    nn_buffer   =   0       !  size in bytes of exported buffer ('B' case), 0 no exportation
    ln_nnogather=  .false.  !  activate code to avoid mpi_allgather use at the northfold
-   jpni        =   0       !  jpni   number of processors following i (set automatically if < 1)     
-   jpnj        =   0       !  jpnj   number of processors following j (set automatically if < 1)     
-   jpnij       =   0       !  jpnij  number of local domains (set automatically if < 1)              
+   jpni        =   0       !  jpni   number of processors following i (set automatically if < 1)
+   jpnj        =   0       !  jpnj   number of processors following j (set automatically if < 1)
+   jpnij       =   0       !  jpnij  number of local domains (set automatically if < 1)
 /
 !-----------------------------------------------------------------------
@@ -854,5 +854,5 @@
 !!   namflo       float parameters                                      ("key_float")
 !!   namptr       Poleward Transport Diagnostics
-!!   namhsb       Heat and salt budgets 
+!!   namhsb       Heat and salt budgets
 !!======================================================================
 !
@@ -899,5 +899,5 @@
    ln_diaptr  = .false.    !  Poleward heat and salt transport (T) or not (F)
    ln_diaznl  = .true.     !  Add zonal means and meridional stream functions
-   ln_subbas  = .true.     !  Atlantic/Pacific/Indian basins computation (T) or not 
+   ln_subbas  = .true.     !  Atlantic/Pacific/Indian basins computation (T) or not
                            !  (orca configuration only, need input basins mask file named "subbasins.nc"
    ln_ptrcomp = .true.     !  Add decomposition : overturning
@@ -906,5 +906,5 @@
 /
 !-----------------------------------------------------------------------
-&namhsb       !  Heat and salt budgets 
+&namhsb       !  Heat and salt budgets
 !-----------------------------------------------------------------------
    ln_diahsb  = .false.    !  check the heat and salt budgets (T) or not (F)
@@ -918,5 +918,5 @@
                            !     -1 : debug all section
                            !  0 < n : debug section number n
-/ 
+/
 
 !!======================================================================
@@ -930,15 +930,15 @@
 &namobs       !  observation usage switch                               ('key_diaobs')
 !-----------------------------------------------------------------------
-   ln_t3d     = .false.    ! Logical switch for T profile observations         
-   ln_s3d     = .false.    ! Logical switch for S profile observations          
-   ln_ena     = .false.    ! Logical switch for ENACT insitu data set           
-   !                       !     ln_cor                  Logical switch for Coriolis insitu data set       
-   ln_profb   = .false.    ! Logical switch for feedback insitu data set     
-   ln_sla     = .false.    ! Logical switch for SLA observations               
-
-   ln_sladt   = .false.    ! Logical switch for AVISO SLA data              
-
-   ln_slafb   = .false.    ! Logical switch for feedback SLA data            
-                           !     ln_ssh                  Logical switch for SSH observations              
+   ln_t3d     = .false.    ! Logical switch for T profile observations
+   ln_s3d     = .false.    ! Logical switch for S profile observations
+   ln_ena     = .false.    ! Logical switch for ENACT insitu data set
+   !                       !     ln_cor                  Logical switch for Coriolis insitu data set
+   ln_profb   = .false.    ! Logical switch for feedback insitu data set
+   ln_sla     = .false.    ! Logical switch for SLA observations
+
+   ln_sladt   = .false.    ! Logical switch for AVISO SLA data
+
+   ln_slafb   = .false.    ! Logical switch for feedback SLA data
+                           !     ln_ssh                  Logical switch for SSH observations
 
    ln_sst     = .true.     ! Logical switch for SST observations              
@@ -946,56 +946,55 @@
    ln_ghrsst  = .false.    !     ln_ghrsst               Logical switch for GHRSST observations          
 
-   ln_sstfb   = .false.    ! Logical switch for feedback SST data          
-                           !     ln_sss                  Logical switch for SSS observations              
-                           !     ln_seaice               Logical switch for Sea Ice observations        
-                           !     ln_vel3d                Logical switch for velocity observations         
-                           !     ln_velavcur             Logical switch for velocity daily av. cur.    
-                           !     ln_velhrcur             Logical switch for velocity high freq. cur.   
-                           !     ln_velavadcp            Logical switch for velocity daily av. ADCP  
+   ln_sstfb   = .false.    ! Logical switch for feedback SST data
+                           !     ln_sss                  Logical switch for SSS observations
+                           !     ln_seaice               Logical switch for Sea Ice observations
+                           !     ln_vel3d                Logical switch for velocity observations
+                           !     ln_velavcur             Logical switch for velocity daily av. cur.
+                           !     ln_velhrcur             Logical switch for velocity high freq. cur.
+                           !     ln_velavadcp            Logical switch for velocity daily av. ADCP
                            !     ln_velhradcp            Logical switch for velocity high freq. ADCP
-                           !     ln_velfb                Logical switch for feedback velocity data       
-                           !     ln_grid_global          Global distribtion of observations         
-                           !     ln_grid_search_lookup   Logical switch for obs grid search w/lookup table  
-                           !     grid_search_file        Grid search lookup file header 
-                           !     enactfiles              ENACT input observation file names 
-                           !     coriofiles              Coriolis input observation file name  
-   !                       ! profbfiles: Profile feedback input observation file name 
+                           !     ln_velfb                Logical switch for feedback velocity data
+                           !     ln_grid_global          Global distribtion of observations
+                           !     ln_grid_search_lookup   Logical switch for obs grid search w/lookup table
+                           !     grid_search_file        Grid search lookup file header
+                           !     enactfiles              ENACT input observation file names
+                           !     coriofiles              Coriolis input observation file name
+   !                       ! profbfiles: Profile feedback input observation file name
    profbfiles = 'profiles_01.nc'
-                           !     ln_profb_enatim         Enact feedback input time setting switch    
+                           !     ln_profb_enatim         Enact feedback input time setting switch
                            !     slafilesact             Active SLA input observation file name
-                           !     slafilespas             Passive SLA input observation file name 
-   !                       ! slafbfiles: Feedback SLA input observation file name 
+                           !     slafilespas             Passive SLA input observation file name
+   !                       ! slafbfiles: Feedback SLA input observation file name
    slafbfiles = 'sla_01.nc'
-                           !     sstfiles                GHRSST input observation file name       
-   !                       ! sstfbfiles: Feedback SST input observation file name 
+                           !     sstfiles                GHRSST input observation file name
+   !                       ! sstfbfiles: Feedback SST input observation file name
    sstfbfiles = 'sst_01.nc' 'sst_02.nc' 'sst_03.nc' 'sst_04.nc' 'sst_05.nc'
-                           !     seaicefiles             Sea Ice input observation file name 
-                           !     velavcurfiles           Vel. cur. daily av. input file name  
-                           !     velhvcurfiles           Vel. cur. high freq. input file name  
-                           !     velavadcpfiles          Vel. ADCP daily av. input file name    
-                           !     velhvadcpfiles          Vel. ADCP high freq. input file name 
-                           !     velfbfiles              Vel. feedback input observation file name 
-                           !     dobsini                 Initial date in window YYYYMMDD.HHMMSS       
-                           !     dobsend                 Final date in window YYYYMMDD.HHMMSS         
-                           !     n1dint                  Type of vertical interpolation method        
-                           !     n2dint                  Type of horizontal interpolation method       
-                           !     ln_nea                  Rejection of observations near land switch    
-   nmsshc     = 0          ! MSSH correction scheme                         
-                           !     mdtcorr                 MDT  correction                               
-                           !     mdtcutoff               MDT cutoff for computed correction          
-   ln_altbias = .false.    ! Logical switch for alt bias                
-   ln_ignmis  = .true.     ! Logical switch for ignoring missing files   
-                           !     endailyavtypes   ENACT daily average types                    
+                           !     seaicefiles             Sea Ice input observation file name
+                           !     velavcurfiles           Vel. cur. daily av. input file name
+                           !     velhvcurfiles           Vel. cur. high freq. input file name
+                           !     velavadcpfiles          Vel. ADCP daily av. input file name
+                           !     velhvadcpfiles          Vel. ADCP high freq. input file name
+                           !     velfbfiles              Vel. feedback input observation file name
+                           !     dobsini                 Initial date in window YYYYMMDD.HHMMSS
+                           !     dobsend                 Final date in window YYYYMMDD.HHMMSS
+                           !     n1dint                  Type of vertical interpolation method
+                           !     n2dint                  Type of horizontal interpolation method
+                           !     ln_nea                  Rejection of observations near land switch
+   nmsshc     = 0          ! MSSH correction scheme
+                           !     mdtcorr                 MDT  correction
+                           !     mdtcutoff               MDT cutoff for computed correction
+   ln_altbias = .false.    ! Logical switch for alt bias
+   ln_ignmis  = .true.     ! Logical switch for ignoring missing files
+                           !     endailyavtypes   ENACT daily average types
    ln_grid_global = .true.
    ln_grid_search_lookup = .false.
-/ 
+/
 !-----------------------------------------------------------------------
 &nam_asminc   !   assimilation increments                               ('key_asminc')
 !-----------------------------------------------------------------------
-    ln_bkgwri = .false.    !  Logical switch for writing out background state 
-    ln_trjwri = .false.    !  Logical switch for writing out state trajectory
+    ln_bkgwri = .false.    !  Logical switch for writing out background state
     ln_trainc = .false.    !  Logical switch for applying tracer increments
     ln_dyninc = .false.    !  Logical switch for applying velocity increments
-    ln_sshinc = .false.    !  Logical switch for applying SSH increments 
+    ln_sshinc = .false.    !  Logical switch for applying SSH increments
     ln_asmdin = .false.    !  Logical switch for Direct Initialization (DI)
     ln_asmiau = .false.    !  Logical switch for Incremental Analysis Updating (IAU)
@@ -1005,5 +1004,4 @@
     nitiaufin = 15         !  Timestep of end of IAU interval in [0,nitend-nit000-1]
     niaufn    = 0          !  Type of IAU weighting function
-    nittrjfrq = 0          !  Frequency of trajectory output for 4D-VAR
     ln_salfix = .false.    !  Logical switch for ensuring that the sa > salfixmin
     salfixmin = -9999      !  Minimum salinity after applying the increments
Index: branches/2012/dev_MERGE_2012/NEMOGCM/CONFIG/GYRE_BFM/EXP00/namelist
===================================================================
--- branches/2012/dev_MERGE_2012/NEMOGCM/CONFIG/GYRE_BFM/EXP00/namelist	(revision 3759)
+++ branches/2012/dev_MERGE_2012/NEMOGCM/CONFIG/GYRE_BFM/EXP00/namelist	(revision 3764)
@@ -935,5 +935,4 @@
 !-----------------------------------------------------------------------
     ln_bkgwri = .false.    !  Logical switch for writing out background state 
-    ln_trjwri = .false.    !  Logical switch for writing out state trajectory
     ln_trainc = .false.    !  Logical switch for applying tracer increments
     ln_dyninc = .false.    !  Logical switch for applying velocity increments
@@ -946,5 +945,4 @@
     nitiaufin = 15         !  Timestep of end of IAU interval in [0,nitend-nit000-1]
     niaufn    = 0          !  Type of IAU weighting function
-    nittrjfrq = 0          !  Frequency of trajectory output for 4D-VAR
     ln_salfix = .false.    !  Logical switch for ensuring that the sa > salfixmin
     salfixmin = -9999      !  Minimum salinity after applying the increments
Index: branches/2012/dev_MERGE_2012/NEMOGCM/CONFIG/ORCA2_LIM/EXP00/1_namelist
===================================================================
--- branches/2012/dev_MERGE_2012/NEMOGCM/CONFIG/ORCA2_LIM/EXP00/1_namelist	(revision 3759)
+++ branches/2012/dev_MERGE_2012/NEMOGCM/CONFIG/ORCA2_LIM/EXP00/1_namelist	(revision 3764)
@@ -592,6 +592,6 @@
 &namdyn_vor    !   option of physics/algorithm (not control by CPP keys)
 !-----------------------------------------------------------------------
-   ln_dynvor_ene = .false. !  enstrophy conserving scheme  
-   ln_dynvor_ens = .false. !  energy conserving scheme    
+   ln_dynvor_ene = .false. !  energy    conserving scheme  
+   ln_dynvor_ens = .false. !  enstrophy conserving scheme    
    ln_dynvor_mix = .false. !  mixed scheme               
    ln_dynvor_een = .true.  !  energy & enstrophy scheme  
@@ -930,5 +930,4 @@
 !-----------------------------------------------------------------------
     ln_bkgwri = .false.    !  Logical switch for writing out background state 
-    ln_trjwri = .false.    !  Logical switch for writing out state trajectory
     ln_trainc = .false.    !  Logical switch for applying tracer increments
     ln_dyninc = .false.    !  Logical switch for applying velocity increments
@@ -941,5 +940,4 @@
     nitiaufin = 15         !  Timestep of end of IAU interval in [0,nitend-nit000-1]
     niaufn    = 0          !  Type of IAU weighting function
-    nittrjfrq = 0          !  Frequency of trajectory output for 4D-VAR
     ln_salfix = .false.    !  Logical switch for ensuring that the sa > salfixmin
     salfixmin = -9999      !  Minimum salinity after applying the increments
Index: branches/2012/dev_MERGE_2012/NEMOGCM/CONFIG/ORCA2_LIM/EXP00/namelist
===================================================================
--- branches/2012/dev_MERGE_2012/NEMOGCM/CONFIG/ORCA2_LIM/EXP00/namelist	(revision 3759)
+++ branches/2012/dev_MERGE_2012/NEMOGCM/CONFIG/ORCA2_LIM/EXP00/namelist	(revision 3764)
@@ -3,5 +3,5 @@
 !! namelists    2 - Domain           (namzgr, namzgr_sco, namdom, namtsd)
 !!              3 - Surface boundary (namsbc, namsbc_ana, namsbc_flx, namsbc_clio, namsbc_core
-!!                                    namsbc_cpl, namtra_qsr, namsbc_rnf, 
+!!                                    namsbc_cpl, namtra_qsr, namsbc_rnf,
 !!                                    namsbc_apr, namsbc_ssr, namsbc_alb)
 !!              4 - lateral boundary (namlbc, namcla, namobc, namagrif, nambdy, nambdy_tide)
@@ -25,5 +25,5 @@
 !-----------------------------------------------------------------------
    nn_no       =       0   !  job number (no more used...)
-   cn_exp      =  "ORCA2"  !  experience name 
+   cn_exp      =  "ORCA2"  !  experience name
    nn_it000    =       1   !  first time step
    nn_itend    =    5475   !  last  time step (std 5475)
@@ -52,5 +52,5 @@
 !!   namzgr_sco   s-coordinate or hybrid z-s-coordinate
 !!   namdom       space and time domain (bathymetry, mesh, timestep)
-!!   namtsd       data: temperature & salinity                         
+!!   namtsd       data: temperature & salinity
 !!======================================================================
 !
@@ -107,5 +107,5 @@
 /
 !-----------------------------------------------------------------------
-&namtsd    !   data : Temperature  & Salinity                           
+&namtsd    !   data : Temperature  & Salinity
 !-----------------------------------------------------------------------
 !          ! file name ! frequency (hours)    ! variable ! time interp. ! clim  !'yearly' or ! weights  ! rotation !
@@ -138,10 +138,10 @@
 &namsbc        !   Surface Boundary Condition (surface module)
 !-----------------------------------------------------------------------
-   nn_fsbc     = 5         !  frequency of surface boundary condition computation 
+   nn_fsbc     = 5         !  frequency of surface boundary condition computation
                            !     (also = the frequency of sea-ice model call)
-   ln_ana      = .false.   !  analytical formulation                    (T => fill namsbc_ana ) 
+   ln_ana      = .false.   !  analytical formulation                    (T => fill namsbc_ana )
    ln_flx      = .false.   !  flux formulation                          (T => fill namsbc_flx )
-   ln_blk_clio = .false.   !  CLIO bulk formulation                     (T => fill namsbc_clio) 
-   ln_blk_core = .true.    !  CORE bulk formulation                     (T => fill namsbc_core) 
+   ln_blk_clio = .false.   !  CLIO bulk formulation                     (T => fill namsbc_clio)
+   ln_blk_core = .true.    !  CORE bulk formulation                     (T => fill namsbc_core)
    ln_blk_mfs  = .false.   !  MFS bulk formulation                      (T => fill namsbc_mfs )
    ln_cpl      = .false.   !  Coupled formulation                       (T => fill namsbc_cpl )
@@ -156,6 +156,6 @@
    ln_rnf      = .true.    !  runoffs                                   (T => fill namsbc_rnf)
    ln_ssr      = .true.    !  Sea Surface Restoring on T and/or S       (T => fill namsbc_ssr)
-   nn_fwb      = 3         !  FreshWater Budget: =0 unchecked 
-                           !     =1 global mean of e-p-r set to zero at each time step 
+   nn_fwb      = 3         !  FreshWater Budget: =0 unchecked
+                           !     =1 global mean of e-p-r set to zero at each time step
                            !     =2 annual global mean of e-p-r set to zero
                            !     =3 global emp set to zero and spread out over erp area
@@ -186,5 +186,5 @@
 
    cn_dir      = './'      !  root directory for the location of the flux files
-/      
+/
 !-----------------------------------------------------------------------
 &namsbc_clio   !   namsbc_clio  CLIO bulk formulae
@@ -243,20 +243,20 @@
 !                    !                       ! categories !  reference  !    orientation       ! grids  !
 ! send
-sn_snd_temp   =       'weighted oce and ice' ,    'no'    ,     ''      ,         ''           ,   ''    
-sn_snd_alb    =       'weighted ice'         ,    'no'    ,     ''      ,         ''           ,   ''    
-sn_snd_thick  =       'none'                 ,    'no'   ,     ''      ,         ''           ,   ''    
-sn_snd_crt    =       'none'                 ,    'no'    , 'spherical' , 'eastward-northward' ,  'T'       
-sn_snd_co2    =       'coupled'              ,    'no'    ,     ''      ,         ''           ,   ''        
+sn_snd_temp   =       'weighted oce and ice' ,    'no'    ,     ''      ,         ''           ,   ''
+sn_snd_alb    =       'weighted ice'         ,    'no'    ,     ''      ,         ''           ,   ''
+sn_snd_thick  =       'none'                 ,    'no'   ,     ''      ,         ''           ,   ''
+sn_snd_crt    =       'none'                 ,    'no'    , 'spherical' , 'eastward-northward' ,  'T'
+sn_snd_co2    =       'coupled'              ,    'no'    ,     ''      ,         ''           ,   ''
 ! receive
-sn_rcv_w10m   =       'none'                 ,    'no'    ,     ''      ,         ''          ,   ''    
-sn_rcv_taumod =       'coupled'              ,    'no'    ,     ''      ,         ''          ,   ''    
-sn_rcv_tau    =       'oce only'             ,    'no'    , 'cartesian' , 'eastward-northward',  'U,V'   
-sn_rcv_dqnsdt =       'coupled'              ,    'no'    ,     ''      ,         ''          ,   ''    
-sn_rcv_qsr    =       'oce and ice'          ,    'no'    ,     ''      ,         ''          ,   ''    
-sn_rcv_qns    =       'oce and ice'          ,    'no'    ,     ''      ,         ''          ,   ''    
-sn_rcv_emp    =       'conservative'         ,    'no'    ,     ''      ,         ''          ,   ''    
-sn_rcv_rnf    =       'coupled'              ,    'no'    ,     ''      ,         ''          ,   ''    
-sn_rcv_cal    =       'coupled'              ,    'no'    ,     ''      ,         ''          ,   ''    
-sn_rcv_co2    =       'coupled'              ,    'no'    ,     ''      ,         ''          ,   ''    
+sn_rcv_w10m   =       'none'                 ,    'no'    ,     ''      ,         ''          ,   ''
+sn_rcv_taumod =       'coupled'              ,    'no'    ,     ''      ,         ''          ,   ''
+sn_rcv_tau    =       'oce only'             ,    'no'    , 'cartesian' , 'eastward-northward',  'U,V'
+sn_rcv_dqnsdt =       'coupled'              ,    'no'    ,     ''      ,         ''          ,   ''
+sn_rcv_qsr    =       'oce and ice'          ,    'no'    ,     ''      ,         ''          ,   ''
+sn_rcv_qns    =       'oce and ice'          ,    'no'    ,     ''      ,         ''          ,   ''
+sn_rcv_emp    =       'conservative'         ,    'no'    ,     ''      ,         ''          ,   ''
+sn_rcv_rnf    =       'coupled'              ,    'no'    ,     ''      ,         ''          ,   ''
+sn_rcv_cal    =       'coupled'              ,    'no'    ,     ''      ,         ''          ,   ''
+sn_rcv_co2    =       'coupled'              ,    'no'    ,     ''      ,         ''          ,   ''
 /
 !-----------------------------------------------------------------------
@@ -318,5 +318,5 @@
    cn_dir      = './'      !  root directory for the location of the runoff files
    nn_sstr     =     0     !  add a retroaction term in the surface heat       flux (=1) or not (=0)
-   nn_sssr     =     2     !  add a damping     term in the surface freshwater flux (=2) 
+   nn_sssr     =     2     !  add a damping     term in the surface freshwater flux (=2)
                            !  or to SSS only (=1) or no damping term (=0)
    rn_dqdt     =   -40.    !  magnitude of the retroaction on temperature   [W/m2/K]
@@ -324,12 +324,12 @@
    ln_sssr_bnd =   .true.  !  flag to bound erp term (associated with nn_sssr=2)
    rn_sssr_bnd =   4.e0    !  ABS(Max/Min) value of the damping erp term [mm/day]
-/      
+/
 !-----------------------------------------------------------------------
 &namsbc_alb    !   albedo parameters
 !-----------------------------------------------------------------------
-   rn_cloud    =    0.06   !  cloud correction to snow and ice albedo 
+   rn_cloud    =    0.06   !  cloud correction to snow and ice albedo
    rn_albice   =    0.53   !  albedo of melting ice in the arctic and antarctic
    rn_alphd    =    0.80   !  coefficients for linear interpolation used to
-   rn_alphc    =    0.65   !  compute albedo between two extremes values 
+   rn_alphc    =    0.65   !  compute albedo between two extremes values
    rn_alphdi   =    0.72   !  (Pyane, 1972)
 /
@@ -375,5 +375,5 @@
 !!   namcla        cross land advection
 !!   namobc        open boundaries parameters                           ("key_obc")
-!!   namagrif      agrif nested grid ( read by child model only )       ("key_agrif") 
+!!   namagrif      agrif nested grid ( read by child model only )       ("key_agrif")
 !!   nambdy        Unstructured open boundaries                         ("key_bdy")
 !!   namtide       Tidal forcing at open boundaries                     ("key_bdy_tides")
@@ -397,5 +397,5 @@
    ln_obc_clim = .false.   !  climatological obc data files (T) or not (F)
    ln_vol_cst  = .true.    !  impose the total volume conservation (T) or not (F)
-   ln_obc_fla  = .false.   !  Flather open boundary condition 
+   ln_obc_fla  = .false.   !  Flather open boundary condition
    nn_obcdta   =    1      !  = 0 the obc data are equal to the initial state
                            !  = 1 the obc data are read in 'obc.dta' files
@@ -441,5 +441,5 @@
 &nambdy        !  unstructured open boundaries                          ("key_bdy")
 !-----------------------------------------------------------------------
-    nb_bdy = 1                            !  number of open boundary sets       
+    nb_bdy = 1                            !  number of open boundary sets
     ln_coords_file = .true.               !  =T : read bdy coordinates from file
     cn_coords_file = 'coordinates.bdy.nc' !  bdy coordinates files
@@ -477,5 +477,5 @@
 /
 !-----------------------------------------------------------------------
-&nambdy_tide     ! tidal forcing at open boundaries              
+&nambdy_tide     ! tidal forcing at open boundaries
 !-----------------------------------------------------------------------
    filtide      = 'bdydta/amm12_bdytide_'         !  file name root of tidal forcing files
@@ -516,5 +516,5 @@
 !!======================================================================
 !!   nambfr        bottom friction
-!!   nambbc        bottom temperature boundary condition               
+!!   nambbc        bottom temperature boundary condition
 !!   nambbl        bottom boundary layer scheme                         ("key_trabbl")
 !!======================================================================
@@ -536,7 +536,7 @@
 !-----------------------------------------------------------------------
    ln_trabbc   = .true.    !  Apply a geothermal heating at the ocean bottom
-   nn_geoflx   =    2      !  geothermal heat flux: = 0 no flux 
+   nn_geoflx   =    2      !  geothermal heat flux: = 0 no flux
                            !     = 1 constant flux
-                           !     = 2 variable flux (read in geothermal_heating.nc in mW/m2) 
+                           !     = 2 variable flux (read in geothermal_heating.nc in mW/m2)
    rn_geoflx_cst = 86.4e-3 !  Constant value of geothermal heat flux [W/m2]
 /
@@ -556,5 +556,5 @@
 !!   namtra_adv    advection scheme
 !!   namtra_ldf    lateral diffusion scheme
-!!   namtra_dmp    T & S newtonian damping                        
+!!   namtra_dmp    T & S newtonian damping
 !!======================================================================
 !
@@ -570,12 +570,12 @@
 /
 !-----------------------------------------------------------------------
-&namtra_adv    !   advection scheme for tracer 
-!-----------------------------------------------------------------------
-   ln_traadv_cen2   =  .false.  !  2nd order centered scheme   
-   ln_traadv_tvd    =  .true.   !  TVD scheme                
-   ln_traadv_muscl  =  .false.  !  MUSCL scheme             
-   ln_traadv_muscl2 =  .false.  !  MUSCL2 scheme + cen2 at boundaries  
-   ln_traadv_ubs    =  .false.  !  UBS scheme                 
-   ln_traadv_qck    =  .false.  !  QUICKEST scheme                 
+&namtra_adv    !   advection scheme for tracer
+!-----------------------------------------------------------------------
+   ln_traadv_cen2   =  .false.  !  2nd order centered scheme
+   ln_traadv_tvd    =  .true.   !  TVD scheme
+   ln_traadv_muscl  =  .false.  !  MUSCL scheme
+   ln_traadv_muscl2 =  .false.  !  MUSCL2 scheme + cen2 at boundaries
+   ln_traadv_ubs    =  .false.  !  UBS scheme
+   ln_traadv_qck    =  .false.  !  QUICKEST scheme
    ln_traadv_msc_ups=  .false.  !  use upstream scheme within muscl
 /
@@ -605,5 +605,5 @@
 /
 !-----------------------------------------------------------------------
-&namtra_dmp    !   tracer: T & S newtonian damping                  
+&namtra_dmp    !   tracer: T & S newtonian damping
 !-----------------------------------------------------------------------
    ln_tradmp   =  .true.   !  add a damping termn (T) or not (F)
@@ -633,20 +633,20 @@
 &namdyn_adv    !   formulation of the momentum advection
 !-----------------------------------------------------------------------
-   ln_dynadv_vec = .true.  !  vector form (T) or flux form (F)  
+   ln_dynadv_vec = .true.  !  vector form (T) or flux form (F)
    ln_dynadv_cen2= .false. !  flux form - 2nd order centered scheme
-   ln_dynadv_ubs = .false. !  flux form - 3rd order UBS      scheme 
-/  
+   ln_dynadv_ubs = .false. !  flux form - 3rd order UBS      scheme
+/
 !-----------------------------------------------------------------------
 &namdyn_vor    !   option of physics/algorithm (not control by CPP keys)
 !-----------------------------------------------------------------------
-   ln_dynvor_ene = .false. !  enstrophy conserving scheme  
-   ln_dynvor_ens = .false. !  energy conserving scheme    
-   ln_dynvor_mix = .false. !  mixed scheme               
-   ln_dynvor_een = .true.  !  energy & enstrophy scheme  
+   ln_dynvor_ene = .false. !  enstrophy conserving scheme
+   ln_dynvor_ens = .false. !  energy conserving scheme
+   ln_dynvor_mix = .false. !  mixed scheme
+   ln_dynvor_een = .true.  !  energy & enstrophy scheme
 /
 !-----------------------------------------------------------------------
 &namdyn_hpg    !   Hydrostatic pressure gradient option
 !-----------------------------------------------------------------------
-   ln_hpg_zco  = .false.   !  z-coordinate - full steps                   
+   ln_hpg_zco  = .false.   !  z-coordinate - full steps
    ln_hpg_zps  = .true.    !  z-coordinate - partial steps (interpolation)
    ln_hpg_sco  = .false.   !  s-coordinate (standard jacobian formulation)
@@ -666,9 +666,9 @@
 &namdyn_ldf    !   lateral diffusion on momentum
 !-----------------------------------------------------------------------
-   !                       !  Type of the operator : 
-   ln_dynldf_lap    =  .true.   !  laplacian operator         
-   ln_dynldf_bilap  =  .false.  !  bilaplacian operator    
-   !                       !  Direction of action  : 
-   ln_dynldf_level  =  .false.  !  iso-level               
+   !                       !  Type of the operator :
+   ln_dynldf_lap    =  .true.   !  laplacian operator
+   ln_dynldf_bilap  =  .false.  !  bilaplacian operator
+   !                       !  Direction of action  :
+   ln_dynldf_level  =  .false.  !  iso-level
    ln_dynldf_hor    =  .true.   !  horizontal (geopotential)            (require "key_ldfslp" in s-coord.)
    ln_dynldf_iso    =  .false.  !  iso-neutral                          (require "key_ldfslp")
@@ -676,5 +676,5 @@
    rn_ahm_0_lap     = 40000.    !  horizontal laplacian eddy viscosity   [m2/s]
    rn_ahmb_0        =     0.    !  background eddy viscosity for ldf_iso [m2/s]
-   rn_ahm_0_blp     =     0.    !  horizontal bilaplacian eddy viscosity [m4/s] 
+   rn_ahm_0_blp     =     0.    !  horizontal bilaplacian eddy viscosity [m4/s]
 /
 
@@ -749,11 +749,11 @@
 &namzdf_kpp    !   K-Profile Parameterization dependent vertical mixing  ("key_zdfkpp", and optionally:
 !------------------------------------------------------------------------ "key_kppcustom" or "key_kpplktb")
-   ln_kpprimix = .true.    !  shear instability mixing 
+   ln_kpprimix = .true.    !  shear instability mixing
    rn_difmiw   =  1.0e-04  !  constant internal wave viscosity [m2/s]
    rn_difsiw   =  0.1e-04  !  constant internal wave diffusivity [m2/s]
    rn_riinfty  =  0.8      !  local Richardson Number limit for shear instability
    rn_difri    =  0.0050   !  maximum shear mixing at Rig = 0    [m2/s]
-   rn_bvsqcon  = -0.01e-07 !  Brunt-Vaisala squared for maximum convection [1/s2] 
-   rn_difcon   =  1.       !  maximum mixing in interior convection [m2/s] 
+   rn_bvsqcon  = -0.01e-07 !  Brunt-Vaisala squared for maximum convection [1/s2]
+   rn_difcon   =  1.       !  maximum mixing in interior convection [m2/s]
    nn_avb      =  0        !  horizontal averaged (=1) or not (=0) on avt and amv
    nn_ave      =  1        !  constant (=0) or profile (=1) background on avt
@@ -789,5 +789,5 @@
    rn_n2min    = 1.e-8     !  threshold of the Brunt-Vaisala frequency (s-1)
    rn_tfe      = 0.333     !  tidal dissipation efficiency
-   rn_me       = 0.2       !  mixing efficiency 
+   rn_me       = 0.2       !  mixing efficiency
    ln_tmx_itf  = .true.    !  ITF specific parameterisation
    rn_tfe_itf  = 1.        !  ITF tidal dissipation efficiency
@@ -799,9 +799,9 @@
 !!   nammpp            Massively Parallel Processing                    ("key_mpp_mpi)
 !!   namctl            Control prints & Benchmark
-!!   namsol            elliptic solver / island / free surface 
-!!======================================================================
-!
-!-----------------------------------------------------------------------
-&namsol        !   elliptic solver / island / free surface 
+!!   namsol            elliptic solver / island / free surface
+!!======================================================================
+!
+!-----------------------------------------------------------------------
+&namsol        !   elliptic solver / island / free surface
 !-----------------------------------------------------------------------
    nn_solv     =      1    !  elliptic solver: =1 preconditioned conjugate gradient (pcg)
@@ -849,5 +849,5 @@
 !!   namflo       float parameters                                      ("key_float")
 !!   namptr       Poleward Transport Diagnostics
-!!   namhsb       Heat and salt budgets 
+!!   namhsb       Heat and salt budgets
 !!======================================================================
 !
@@ -881,6 +881,6 @@
    jpnnewflo     = 0          !  number of floats for the restart
    ln_rstflo     = .false.    !  float restart (T) or not (F)
-   nn_writefl    =      75    !  frequency of writing in float output file 
-   nn_stockfl    =    5475    !  frequency of creation of the float restart file 
+   nn_writefl    =      75    !  frequency of writing in float output file
+   nn_stockfl    =    5475    !  frequency of creation of the float restart file
    ln_argo       = .false.    !  Argo type floats (stay at the surface each 10 days)
    ln_flork4     = .false.    !  trajectories computed with a 4th order Runge-Kutta (T)
@@ -894,5 +894,5 @@
    ln_diaptr  = .false.    !  Poleward heat and salt transport (T) or not (F)
    ln_diaznl  = .true.     !  Add zonal means and meridional stream functions
-   ln_subbas  = .true.     !  Atlantic/Pacific/Indian basins computation (T) or not 
+   ln_subbas  = .true.     !  Atlantic/Pacific/Indian basins computation (T) or not
                            !  (orca configuration only, need input basins mask file named "subbasins.nc"
    ln_ptrcomp = .true.     !  Add decomposition : overturning
@@ -901,5 +901,5 @@
 /
 !-----------------------------------------------------------------------
-&namhsb       !  Heat and salt budgets 
+&namhsb       !  Heat and salt budgets
 !-----------------------------------------------------------------------
    ln_diahsb  = .false.    !  check the heat and salt budgets (T) or not (F)
@@ -934,15 +934,15 @@
 &namobs       !  observation usage switch                               ('key_diaobs')
 !-----------------------------------------------------------------------
-   ln_t3d     = .false.    ! Logical switch for T profile observations         
-   ln_s3d     = .false.    ! Logical switch for S profile observations          
-   ln_ena     = .false.    ! Logical switch for ENACT insitu data set           
-   !                       !     ln_cor                  Logical switch for Coriolis insitu data set       
-   ln_profb   = .false.    ! Logical switch for feedback insitu data set     
-   ln_sla     = .false.    ! Logical switch for SLA observations               
-
-   ln_sladt   = .false.    ! Logical switch for AVISO SLA data              
-
-   ln_slafb   = .false.    ! Logical switch for feedback SLA data            
-                           !     ln_ssh                  Logical switch for SSH observations              
+   ln_t3d     = .false.    ! Logical switch for T profile observations
+   ln_s3d     = .false.    ! Logical switch for S profile observations
+   ln_ena     = .false.    ! Logical switch for ENACT insitu data set
+   !                       !     ln_cor                  Logical switch for Coriolis insitu data set
+   ln_profb   = .false.    ! Logical switch for feedback insitu data set
+   ln_sla     = .false.    ! Logical switch for SLA observations
+
+   ln_sladt   = .false.    ! Logical switch for AVISO SLA data
+
+   ln_slafb   = .false.    ! Logical switch for feedback SLA data
+                           !     ln_ssh                  Logical switch for SSH observations
 
    ln_sst     = .true.     ! Logical switch for SST observations
@@ -950,56 +950,55 @@
    ln_ghrsst  = .false.    !     ln_ghrsst               Logical switch for GHRSST observations      
 
-   ln_sstfb   = .false.    ! Logical switch for feedback SST data          
-                           !     ln_sss                  Logical switch for SSS observations              
-                           !     ln_seaice               Logical switch for Sea Ice observations        
-                           !     ln_vel3d                Logical switch for velocity observations         
-                           !     ln_velavcur             Logical switch for velocity daily av. cur.    
-                           !     ln_velhrcur             Logical switch for velocity high freq. cur.   
-                           !     ln_velavadcp            Logical switch for velocity daily av. ADCP  
+   ln_sstfb   = .false.    ! Logical switch for feedback SST data
+                           !     ln_sss                  Logical switch for SSS observations
+                           !     ln_seaice               Logical switch for Sea Ice observations
+                           !     ln_vel3d                Logical switch for velocity observations
+                           !     ln_velavcur             Logical switch for velocity daily av. cur.
+                           !     ln_velhrcur             Logical switch for velocity high freq. cur.
+                           !     ln_velavadcp            Logical switch for velocity daily av. ADCP
                            !     ln_velhradcp            Logical switch for velocity high freq. ADCP
-                           !     ln_velfb                Logical switch for feedback velocity data       
-                           !     ln_grid_global          Global distribtion of observations         
-                           !     ln_grid_search_lookup   Logical switch for obs grid search w/lookup table  
-                           !     grid_search_file        Grid search lookup file header 
-                           !     enactfiles              ENACT input observation file names 
-                           !     coriofiles              Coriolis input observation file name  
-   !                       ! profbfiles: Profile feedback input observation file name 
+                           !     ln_velfb                Logical switch for feedback velocity data
+                           !     ln_grid_global          Global distribtion of observations
+                           !     ln_grid_search_lookup   Logical switch for obs grid search w/lookup table
+                           !     grid_search_file        Grid search lookup file header
+                           !     enactfiles              ENACT input observation file names
+                           !     coriofiles              Coriolis input observation file name
+   !                       ! profbfiles: Profile feedback input observation file name
    profbfiles = 'profiles_01.nc'
-                           !     ln_profb_enatim         Enact feedback input time setting switch    
+                           !     ln_profb_enatim         Enact feedback input time setting switch
                            !     slafilesact             Active SLA input observation file name
-                           !     slafilespas             Passive SLA input observation file name 
-   !                       ! slafbfiles: Feedback SLA input observation file name 
+                           !     slafilespas             Passive SLA input observation file name
+   !                       ! slafbfiles: Feedback SLA input observation file name
    slafbfiles = 'sla_01.nc'
-                           !     sstfiles                GHRSST input observation file name       
-   !                       ! sstfbfiles: Feedback SST input observation file name 
+                           !     sstfiles                GHRSST input observation file name
+   !                       ! sstfbfiles: Feedback SST input observation file name
    sstfbfiles = 'sst_01.nc' 'sst_02.nc' 'sst_03.nc' 'sst_04.nc' 'sst_05.nc'
-                           !     seaicefiles             Sea Ice input observation file name 
-                           !     velavcurfiles           Vel. cur. daily av. input file name  
-                           !     velhvcurfiles           Vel. cur. high freq. input file name  
-                           !     velavadcpfiles          Vel. ADCP daily av. input file name    
-                           !     velhvadcpfiles          Vel. ADCP high freq. input file name 
-                           !     velfbfiles              Vel. feedback input observation file name 
-                           !     dobsini                 Initial date in window YYYYMMDD.HHMMSS       
-                           !     dobsend                 Final date in window YYYYMMDD.HHMMSS         
-                           !     n1dint                  Type of vertical interpolation method        
-                           !     n2dint                  Type of horizontal interpolation method       
-                           !     ln_nea                  Rejection of observations near land switch    
-   nmsshc     = 0          ! MSSH correction scheme                         
-                           !     mdtcorr                 MDT  correction                               
-                           !     mdtcutoff               MDT cutoff for computed correction          
-   ln_altbias = .false.    ! Logical switch for alt bias                
-   ln_ignmis  = .true.     ! Logical switch for ignoring missing files   
-                           !     endailyavtypes   ENACT daily average types                    
+                           !     seaicefiles             Sea Ice input observation file name
+                           !     velavcurfiles           Vel. cur. daily av. input file name
+                           !     velhvcurfiles           Vel. cur. high freq. input file name
+                           !     velavadcpfiles          Vel. ADCP daily av. input file name
+                           !     velhvadcpfiles          Vel. ADCP high freq. input file name
+                           !     velfbfiles              Vel. feedback input observation file name
+                           !     dobsini                 Initial date in window YYYYMMDD.HHMMSS
+                           !     dobsend                 Final date in window YYYYMMDD.HHMMSS
+                           !     n1dint                  Type of vertical interpolation method
+                           !     n2dint                  Type of horizontal interpolation method
+                           !     ln_nea                  Rejection of observations near land switch
+   nmsshc     = 0          ! MSSH correction scheme
+                           !     mdtcorr                 MDT  correction
+                           !     mdtcutoff               MDT cutoff for computed correction
+   ln_altbias = .false.    ! Logical switch for alt bias
+   ln_ignmis  = .true.     ! Logical switch for ignoring missing files
+                           !     endailyavtypes   ENACT daily average types
    ln_grid_global = .true.
    ln_grid_search_lookup = .false.
-/ 
+/
 !-----------------------------------------------------------------------
 &nam_asminc   !   assimilation increments                               ('key_asminc')
 !-----------------------------------------------------------------------
-    ln_bkgwri = .false.    !  Logical switch for writing out background state 
-    ln_trjwri = .false.    !  Logical switch for writing out state trajectory
+    ln_bkgwri = .false.    !  Logical switch for writing out background state
     ln_trainc = .false.    !  Logical switch for applying tracer increments
     ln_dyninc = .false.    !  Logical switch for applying velocity increments
-    ln_sshinc = .false.    !  Logical switch for applying SSH increments 
+    ln_sshinc = .false.    !  Logical switch for applying SSH increments
     ln_asmdin = .false.    !  Logical switch for Direct Initialization (DI)
     ln_asmiau = .false.    !  Logical switch for Incremental Analysis Updating (IAU)
@@ -1009,5 +1008,4 @@
     nitiaufin = 15         !  Timestep of end of IAU interval in [0,nitend-nit000-1]
     niaufn    = 0          !  Type of IAU weighting function
-    nittrjfrq = 0          !  Frequency of trajectory output for 4D-VAR
     ln_salfix = .false.    !  Logical switch for ensuring that the sa > salfixmin
     salfixmin = -9999      !  Minimum salinity after applying the increments
Index: branches/2012/dev_MERGE_2012/NEMOGCM/CONFIG/ORCA2_LIM_CFC_C14b/EXP00/1_namelist
===================================================================
--- branches/2012/dev_MERGE_2012/NEMOGCM/CONFIG/ORCA2_LIM_CFC_C14b/EXP00/1_namelist	(revision 3759)
+++ branches/2012/dev_MERGE_2012/NEMOGCM/CONFIG/ORCA2_LIM_CFC_C14b/EXP00/1_namelist	(revision 3764)
@@ -882,5 +882,4 @@
 !-----------------------------------------------------------------------
     ln_bkgwri = .false.    !  Logical switch for writing out background state 
-    ln_trjwri = .false.    !  Logical switch for writing out state trajectory
     ln_trainc = .false.    !  Logical switch for applying tracer increments
     ln_dyninc = .false.    !  Logical switch for applying velocity increments
@@ -893,5 +892,4 @@
     nitiaufin = 15         !  Timestep of end of IAU interval in [0,nitend-nit000-1]
     niaufn    = 0          !  Type of IAU weighting function
-    nittrjfrq = 0          !  Frequency of trajectory output for 4D-VAR
     ln_salfix = .false.    !  Logical switch for ensuring that the sa > salfixmin
     salfixmin = -9999      !  Minimum salinity after applying the increments
Index: branches/2012/dev_MERGE_2012/NEMOGCM/CONFIG/ORCA2_LIM_CFC_C14b/EXP00/namelist
===================================================================
--- branches/2012/dev_MERGE_2012/NEMOGCM/CONFIG/ORCA2_LIM_CFC_C14b/EXP00/namelist	(revision 3759)
+++ branches/2012/dev_MERGE_2012/NEMOGCM/CONFIG/ORCA2_LIM_CFC_C14b/EXP00/namelist	(revision 3764)
@@ -945,5 +945,4 @@
 !-----------------------------------------------------------------------
     ln_bkgwri = .false.    !  Logical switch for writing out background state 
-    ln_trjwri = .false.    !  Logical switch for writing out state trajectory
     ln_trainc = .false.    !  Logical switch for applying tracer increments
     ln_dyninc = .false.    !  Logical switch for applying velocity increments
@@ -956,5 +955,4 @@
     nitiaufin = 15         !  Timestep of end of IAU interval in [0,nitend-nit000-1]
     niaufn    = 0          !  Type of IAU weighting function
-    nittrjfrq = 0          !  Frequency of trajectory output for 4D-VAR
     ln_salfix = .false.    !  Logical switch for ensuring that the sa > salfixmin
     salfixmin = -9999      !  Minimum salinity after applying the increments
Index: branches/2012/dev_MERGE_2012/NEMOGCM/CONFIG/ORCA2_OFF_PISCES/EXP00/namelist
===================================================================
--- branches/2012/dev_MERGE_2012/NEMOGCM/CONFIG/ORCA2_OFF_PISCES/EXP00/namelist	(revision 3759)
+++ branches/2012/dev_MERGE_2012/NEMOGCM/CONFIG/ORCA2_OFF_PISCES/EXP00/namelist	(revision 3764)
@@ -616,6 +616,6 @@
 &namdyn_vor    !   option of physics/algorithm (not control by CPP keys)
 !-----------------------------------------------------------------------
-   ln_dynvor_ene = .false. !  enstrophy conserving scheme  
-   ln_dynvor_ens = .false. !  energy conserving scheme    
+   ln_dynvor_ene = .false. !  energy    conserving scheme  
+   ln_dynvor_ens = .false. !  enstrophy conserving scheme    
    ln_dynvor_mix = .false. !  mixed scheme               
    ln_dynvor_een = .true.  !  energy & enstrophy scheme  
@@ -990,5 +990,4 @@
 !-----------------------------------------------------------------------
     ln_bkgwri = .false.    !  Logical switch for writing out background state 
-    ln_trjwri = .false.    !  Logical switch for writing out state trajectory
     ln_trainc = .false.    !  Logical switch for applying tracer increments
     ln_dyninc = .false.    !  Logical switch for applying velocity increments
@@ -1001,5 +1000,4 @@
     nitiaufin = 15         !  Timestep of end of IAU interval in [0,nitend-nit000-1]
     niaufn    = 0          !  Type of IAU weighting function
-    nittrjfrq = 0          !  Frequency of trajectory output for 4D-VAR
     ln_salfix = .false.    !  Logical switch for ensuring that the sa > salfixmin
     salfixmin = -9999      !  Minimum salinity after applying the increments
Index: branches/2012/dev_MERGE_2012/NEMOGCM/CONFIG/ORCA2_SAS_LIM/EXP00/1_namelist
===================================================================
--- branches/2012/dev_MERGE_2012/NEMOGCM/CONFIG/ORCA2_SAS_LIM/EXP00/1_namelist	(revision 3759)
+++ branches/2012/dev_MERGE_2012/NEMOGCM/CONFIG/ORCA2_SAS_LIM/EXP00/1_namelist	(revision 3764)
@@ -895,5 +895,4 @@
 !-----------------------------------------------------------------------
     ln_bkgwri = .false.    !  Logical switch for writing out background state 
-    ln_trjwri = .false.    !  Logical switch for writing out state trajectory
     ln_trainc = .false.    !  Logical switch for applying tracer increments
     ln_dyninc = .false.    !  Logical switch for applying velocity increments
@@ -906,5 +905,4 @@
     nitiaufin = 15         !  Timestep of end of IAU interval in [0,nitend-nit000-1]
     niaufn    = 0          !  Type of IAU weighting function
-    nittrjfrq = 0          !  Frequency of trajectory output for 4D-VAR
     ln_salfix = .false.    !  Logical switch for ensuring that the sa > salfixmin
     salfixmin = -9999      !  Minimum salinity after applying the increments
Index: branches/2012/dev_MERGE_2012/NEMOGCM/CONFIG/ORCA2_SAS_LIM/EXP00/namelist
===================================================================
--- branches/2012/dev_MERGE_2012/NEMOGCM/CONFIG/ORCA2_SAS_LIM/EXP00/namelist	(revision 3759)
+++ branches/2012/dev_MERGE_2012/NEMOGCM/CONFIG/ORCA2_SAS_LIM/EXP00/namelist	(revision 3764)
@@ -994,5 +994,4 @@
 !-----------------------------------------------------------------------
     ln_bkgwri = .false.    !  Logical switch for writing out background state 
-    ln_trjwri = .false.    !  Logical switch for writing out state trajectory
     ln_trainc = .false.    !  Logical switch for applying tracer increments
     ln_dyninc = .false.    !  Logical switch for applying velocity increments
@@ -1005,5 +1004,4 @@
     nitiaufin = 15         !  Timestep of end of IAU interval in [0,nitend-nit000-1]
     niaufn    = 0          !  Type of IAU weighting function
-    nittrjfrq = 0          !  Frequency of trajectory output for 4D-VAR
     ln_salfix = .false.    !  Logical switch for ensuring that the sa > salfixmin
     salfixmin = -9999      !  Minimum salinity after applying the increments
Index: branches/2012/dev_MERGE_2012/NEMOGCM/CONFIG/makenemo
===================================================================
--- branches/2012/dev_MERGE_2012/NEMOGCM/CONFIG/makenemo	(revision 3759)
+++ branches/2012/dev_MERGE_2012/NEMOGCM/CONFIG/makenemo	(revision 3764)
@@ -2,5 +2,5 @@
 #set -x
 set -o posix
-#set -u 
+#set -u
 #set -e
 #+
@@ -29,5 +29,5 @@
 #
 # - to choose MYCONFIG
-# - to choose compiler options  
+# - to choose compiler options
 # - to create the CONFIG/MYCONFIG/WORK directory
 # - to compile this configuration
@@ -38,16 +38,16 @@
 #
 # - NEW_CONF    : configuration to be created
-# - REF_CONF    : reference configuration to build the new one 
-# - CMP_NAM     : compiler name 
-# - NBR_PRC     : number of processes used to compile  
+# - REF_CONF    : reference configuration to build the new one
+# - CMP_NAM     : compiler name
+# - NBR_PRC     : number of processes used to compile
 # - NEM_SUBDIR  : NEMO subdirectory used (specified)
 #
 #  Locally defined :
 #
-# - TAB         : NEMO subdirectory used (read)  
+# - TAB         : NEMO subdirectory used (read)
 # - MAIN_DIR    : self explaining
-# - CONFIG_DIR  :   "    "    "   
-# - MODELES_DIR :   "    "    " 
-# - TOOLS_DIR   :   "    "    " 
+# - CONFIG_DIR  :   "    "    "
+# - MODELES_DIR :   "    "    "
+# - TOOLS_DIR   :   "    "    "
 # - NEMO_DIR    :   "    "    "
 #
@@ -134,5 +134,5 @@
 	echo "makenemo -n MY_CONFIG -d \"OPA_SRC LIM_SRC_2\"";
 	echo "";
-	echo "Available configurations :"; cat ${CONFIG_DIR}/cfg.txt; 
+	echo "Available configurations :"; cat ${CONFIG_DIR}/cfg.txt;
 	echo "";
 	echo "Example to remove bad configuration ";
@@ -190,8 +190,8 @@
 	    ;;
 	*)
-	    echo " \"$1\" BAD OPTION" 
+	    echo " \"$1\" BAD OPTION"
 	    exit
 	    ;;
-	
+
     esac
     shift
@@ -216,5 +216,5 @@
 #- Check if the tool or the compiler exist or list it
 if [ "${NEW_CONF}" == help ] ; then
-    echo "Available configurations :" 
+    echo "Available configurations :"
     cat ${CONFIG_DIR}/cfg.txt
     exit
@@ -228,5 +228,5 @@
 #- Choose a default configuration if needed ---
 #- ORCA2_LIM or last one used ---
-. ${COMPIL_DIR}/Fcheck_config.sh cfg.txt ${NEW_CONF} || exit 
+. ${COMPIL_DIR}/Fcheck_config.sh cfg.txt ${NEW_CONF} || exit
 
 
@@ -235,10 +235,10 @@
 	echo "You are  installing a new configuration"
 	ind=0
-	. ${COMPIL_DIR}/Fread_dir.sh OPA_SRC	 YES 
-	. ${COMPIL_DIR}/Fread_dir.sh LIM_SRC_2   YES 
-	. ${COMPIL_DIR}/Fread_dir.sh LIM_SRC_3   NO  
-	. ${COMPIL_DIR}/Fread_dir.sh TOP_SRC	 NO  
-	. ${COMPIL_DIR}/Fread_dir.sh NST_SRC	 YES 
-	. ${COMPIL_DIR}/Fread_dir.sh OFF_SRC	 NO  
+	. ${COMPIL_DIR}/Fread_dir.sh OPA_SRC	 YES
+	. ${COMPIL_DIR}/Fread_dir.sh LIM_SRC_2   YES
+	. ${COMPIL_DIR}/Fread_dir.sh LIM_SRC_3   NO
+	. ${COMPIL_DIR}/Fread_dir.sh TOP_SRC	 NO
+	. ${COMPIL_DIR}/Fread_dir.sh NST_SRC	 YES
+	. ${COMPIL_DIR}/Fread_dir.sh OFF_SRC	 NO
 	REF_CONF=ORCA2_LIM
     elif [ ${#NEM_SUBDIR} -gt 0 ] && [ ${#REF_CONF} -eq 0 ]; then
@@ -248,5 +248,5 @@
     elif [ ${#NEM_SUBDIR} -eq 0 ] && [ ${#REF_CONF} -gt 0 ]; then
 	echo "You are  installing a new configuration based on ${REF_CONF}"
-	. ${COMPIL_DIR}/Fcopy_dir.sh ${REF_CONF}  
+	. ${COMPIL_DIR}/Fcopy_dir.sh ${REF_CONF}
     fi
     NEW_CONF=${x_n}
@@ -272,5 +272,5 @@
 #- We add or remove keys
 if [ ${#list_add_key} -ne 0 ] ; then
-    . ${COMPIL_DIR}/Fadd_keys.sh ${NEW_CONF} add_key ${list_add_key} 
+    . ${COMPIL_DIR}/Fadd_keys.sh ${NEW_CONF} add_key ${list_add_key}
 fi
 
Index: branches/2012/dev_MERGE_2012/NEMOGCM/EXTERNAL/fcm/lib/Fcm/CfgLine.pm
===================================================================
--- branches/2012/dev_MERGE_2012/NEMOGCM/EXTERNAL/fcm/lib/Fcm/CfgLine.pm	(revision 3759)
+++ branches/2012/dev_MERGE_2012/NEMOGCM/EXTERNAL/fcm/lib/Fcm/CfgLine.pm	(revision 3764)
@@ -205,5 +205,5 @@
 
     for my $i (0 .. $#fields) {
-      next if lc ($fields[$i]) eq lc ($all_fields[$i]);
+      next if lc ($fields[$i]) eq lc ($all_fields[$i] || '');
       $return = 0;
       last;
Index: branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/LIM_SRC_2/dom_ice_2.F90
===================================================================
--- branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/LIM_SRC_2/dom_ice_2.F90	(revision 3759)
+++ branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/LIM_SRC_2/dom_ice_2.F90	(revision 3764)
@@ -32,13 +32,10 @@
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:)         ::   tms    , tmu      !: temperature and velocity points masks
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:,:)     ::   wght              !: weight of the 4 neighbours to compute averages
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:)         ::   tmv               !: y-velocity mask used for evp rheology 
 
-
-# if defined key_lim2_vp
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:,:)     ::   akappa , bkappa   !: first and third group of metric coefficients
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:,:,:,:) ::   alambd            !: second group of metric coefficients
-# else
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:)         ::   tmv    , tmf      !: y-velocity and F-points masks
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:)         ::   tmf               !: F-points masks
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:)         ::   tmi               !: ice mask: =1 if ice thick > 0
-# endif
    !!----------------------------------------------------------------------
    CONTAINS
Index: branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/LIM_SRC_2/limtrp_2.F90
===================================================================
--- branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/LIM_SRC_2/limtrp_2.F90	(revision 3759)
+++ branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/LIM_SRC_2/limtrp_2.F90	(revision 3764)
@@ -31,4 +31,5 @@
    USE agrif_lim2_interp ! nesting
 # endif
+   USE lib_fortran     ! Fortran utilities (allows no signed zero when 'key_nosignedzero' defined)
 
    IMPLICIT NONE
Index: branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/LIM_SRC_2/limwri_2.F90
===================================================================
--- branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/LIM_SRC_2/limwri_2.F90	(revision 3759)
+++ branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/LIM_SRC_2/limwri_2.F90	(revision 3764)
@@ -105,5 +105,5 @@
       !!
       INTEGER  ::   ji, jj, jf                      ! dummy loop indices
-      CHARACTER(len = 40)  ::   clhstnam, clop
+      CHARACTER(len = 80)  ::   clhstnam, clop
       REAL(wp) ::   zsto, zjulian, zout,   &  ! temporary scalars
          &          zindh, zinda, zindb, ztmu
@@ -161,4 +161,5 @@
             zcmo(ji,jj,5)  = sist  (ji,jj)
             zcmo(ji,jj,6)  = fbif  (ji,jj)
+           IF (lk_lim2_vp) THEN
             zcmo(ji,jj,7)  = zindb * (  u_ice(ji,jj  ) * tmu(ji,jj  ) + u_ice(ji+1,jj  ) * tmu(ji+1,jj  )   &
                                       + u_ice(ji,jj+1) * tmu(ji,jj+1) + u_ice(ji+1,jj+1) * tmu(ji+1,jj+1) ) &
@@ -168,4 +169,14 @@
                                       + v_ice(ji,jj+1) * tmu(ji,jj+1) + v_ice(ji+1,jj+1) * tmu(ji+1,jj+1) ) &
                                   / ztmu
+           ELSE
+
+            zcmo(ji,jj,7)  = zindb * (  u_ice(ji,jj  ) * tmu(ji,jj)                       &
+             &                        + u_ice(ji-1,jj) * tmu(ji-1,jj) )                   &
+             &                    / 2.0
+            zcmo(ji,jj,8)  = zindb * (  v_ice(ji,jj  ) * tmv(ji,jj)                       &
+             &                        + v_ice(ji,jj-1) * tmv(ji,jj-1) )                   &
+             &                    / 2.0
+
+           ENDIF
             zcmo(ji,jj,9)  = sst_m(ji,jj)
             zcmo(ji,jj,10) = sss_m(ji,jj)
@@ -187,20 +198,16 @@
       niter = niter + 1
       DO jf = 1 , noumef
-         DO jj = 1 , jpj
-            DO ji = 1 , jpi
-               zfield(ji,jj) = zcmo(ji,jj,jf) * cmulti(jf) + cadd(jf)
-            END DO
-         END DO
-         
-         IF( jf == 7  .OR. jf == 8  .OR. jf == 15 .OR. jf == 16 ) THEN
+         zfield(:,:) = zcmo(:,:,jf) * cmulti(jf) + cadd(jf) * tmask(:,:,1)
+         SELECT CASE ( jf )
+         CASE ( 7, 8, 15, 16, 20, 21 )  ! velocity or stress fields (vectors)
             CALL lbc_lnk( zfield, 'T', -1. )
-         ELSE 
+         CASE DEFAULT                   ! scalar fields
             CALL lbc_lnk( zfield, 'T',  1. )
-         ENDIF
-         
+         END SELECT
+
          IF( nc(jf) == 1 )   CALL histwrite( nice, nam(jf), niter, zfield, ndim, ndex51 )
-         
+
       END DO
-      
+
       IF( ( nn_fsbc * niter ) >= nitend )   CALL histclo( nice ) 
 
@@ -209,5 +216,5 @@
    END SUBROUTINE lim_wri_2
      
-# endif
+#endif     
 
    SUBROUTINE lim_wri_init_2
Index: branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/LIM_SRC_2/limwri_dimg_2.h90
===================================================================
--- branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/LIM_SRC_2/limwri_dimg_2.h90	(revision 3759)
+++ branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/LIM_SRC_2/limwri_dimg_2.h90	(revision 3764)
@@ -20,5 +20,5 @@
     INTEGER , SAVE ::   nmoyice   !: counter for averaging
     INTEGER , SAVE ::   nwf       !: number of fields to write on disk
-    INTEGER , SAVE, DIMENSION(:), ALLOCATABLE  :: nsubindex   !: subindex to be saved
+    INTEGER, SAVE,DIMENSION (:), ALLOCATABLE  :: nsubindex   !: subindex to be saved
     INTEGER , SAVE ::   nice, nhorid, ndim, niter, ndepid
     REAL(wp), SAVE, DIMENSION(:,:,:), ALLOCATABLE :: rcmoy
@@ -30,7 +30,6 @@
     REAL(wp), DIMENSION(1) ::   zdept
     REAL(wp) ::   zsto, zsec, zjulian,zout
-    REAL(wp) ::   zindh,zinda,zindb, ztmu
-    REAL(wp), DIMENSION(jpi,jpj,jpnoumax) ::   zcmo   !ARPDBGWORK
-    REAL(wp), DIMENSION(jpi,jpj)          ::   zfield
+    REAL(wp) ::   zindh, zinda, zindb, ztmu
+    REAL(wp), POINTER, DIMENSION(:,:)     ::   zfield
 
 #if ! defined key_diainstant
@@ -45,8 +44,9 @@
        IF( lk_mpp      )   CALL mpp_sum ( ialloc  )
        IF( ialloc /= 0 )   CALL ctl_warn('lim_wri_2 (limwri_dimg_2.h90) : failed to allocate arrays')
-       rcmoy(:,:,:) = 0._wp
     ENDIF
 
-    IF( kt == nit000 ) THEN 
+    CALL wrk_alloc( jpi, jpj, zfield )
+
+    IF ( kt == nit000 ) THEN 
        !
        CALL lim_wri_init_2 
@@ -55,5 +55,5 @@
        ii  = 0
 
-       IF(lwp ) THEN
+       IF (lwp ) THEN
           WRITE(numout,*) 'lim_wri_2 : Write ice outputs in dimg'
           WRITE(numout,*) '~~~~~~~~'
@@ -79,4 +79,5 @@
        END DO
 
+       rcmoy(:,:,:) = 0.0_wp
        zsto     = rdt_ice
        zout     = nwrite * rdt_ice / nn_fsbc
@@ -89,13 +90,12 @@
 
 #if ! defined key_diainstant 
-    !-- calculs des valeurs instantanees
+    !-- Compute mean values
 
     zcmo(:,:, 1:jpnoumax ) = 0.e0 
     DO jj = 2 , jpjm1
-       DO ji = 2 , jpim1   ! NO vector opt.
+       DO ji = 2 , jpim1
           zindh  = MAX( zzero , SIGN( zone , hicif(ji,jj) * (1.0 - frld(ji,jj) ) - 0.10 ) )
           zinda  = MAX( zzero , SIGN( zone , ( 1.0 - frld(ji,jj) ) - 0.10 ) )
           zindb  = zindh * zinda
-          ztmu   = MAX( 0.5 * zone , ( tmu(ji,jj) + tmu(ji+1,jj) + tmu(ji,jj+1) + tmu(ji+1,jj+1) ) ) 
           zcmo(ji,jj,1)  = hsnif (ji,jj)
           zcmo(ji,jj,2)  = hicif (ji,jj)
@@ -104,11 +104,18 @@
           zcmo(ji,jj,5)  = sist  (ji,jj)
           zcmo(ji,jj,6)  = fbif  (ji,jj)
-          zcmo(ji,jj,7)  = zindb * (  u_ice(ji,jj  ) * tmu(ji,jj  ) + u_ice(ji+1,jj  ) * tmu(ji+1,jj  )   &
+          IF (lk_lim2_vp) THEN
+            ztmu   = MAX( 0.5 * zone , ( tmu(ji,jj) + tmu(ji+1,jj) + tmu(ji,jj+1) + tmu(ji+1,jj+1) ) ) 
+            zcmo(ji,jj,7)  = zindb * (  u_ice(ji,jj  ) * tmu(ji,jj  ) + u_ice(ji+1,jj  ) * tmu(ji+1,jj  )   &
              &                      + u_ice(ji,jj+1) * tmu(ji,jj+1) + u_ice(ji+1,jj+1) * tmu(ji+1,jj+1) ) &
                / ztmu 
 
-          zcmo(ji,jj,8)  = zindb * (  v_ice(ji,jj  ) * tmu(ji,jj  ) + v_ice(ji+1,jj  ) * tmu(ji+1,jj  )   &
+            zcmo(ji,jj,8)  = zindb * (  v_ice(ji,jj  ) * tmu(ji,jj  ) + v_ice(ji+1,jj  ) * tmu(ji+1,jj  )   &
              &                      + v_ice(ji,jj+1) * tmu(ji,jj+1) + v_ice(ji+1,jj+1) * tmu(ji+1,jj+1) ) &
                / ztmu
+           ELSE
+            zcmo(ji,jj,7)  = zindb * (  u_ice(ji,jj  ) * tmu(ji,jj) + u_ice(ji-1,jj) * tmu(ji-1,jj) )/ 2.0
+            zcmo(ji,jj,8)  = zindb * (  v_ice(ji,jj  ) * tmv(ji,jj) + v_ice(ji,jj-1) * tmv(ji,jj-1) )/ 2.0
+           ENDIF
+
           zcmo(ji,jj,9)  = sst_m(ji,jj)
           zcmo(ji,jj,10) = sss_m(ji,jj)
@@ -136,9 +143,8 @@
           !  case of instantaneaous output rcmoy(:,:, 1:jpnoumax ) = 0.e0
           DO jj = 2 , jpjm1
-             DO ji = 2 , jpim1   ! NO vector opt.
+             DO ji = 2 , jpim1
                 zindh  = MAX( zzero , SIGN( zone , hicif(ji,jj) * (1.0 - frld(ji,jj) ) - 0.10 ) )
                 zinda  = MAX( zzero , SIGN( zone , ( 1.0 - frld(ji,jj) ) - 0.10 ) )
                 zindb  = zindh * zinda
-                ztmu   = MAX( 0.5 * zone , ( tmu(ji,jj) + tmu(ji+1,jj) + tmu(ji,jj+1) + tmu(ji+1,jj+1) ) )
                 rcmoy(ji,jj,1)  = hsnif (ji,jj)
                 rcmoy(ji,jj,2)  = hicif (ji,jj)
@@ -147,11 +153,17 @@
                 rcmoy(ji,jj,5)  = sist  (ji,jj)
                 rcmoy(ji,jj,6)  = fbif  (ji,jj)
-                rcmoy(ji,jj,7)  = zindb * (  u_ice(ji,jj  ) * tmu(ji,jj  ) + u_ice(ji+1,jj  ) * tmu(ji+1,jj  )   &
-                   &                       + u_ice(ji,jj+1) * tmu(ji,jj+1) + u_ice(ji+1,jj+1) * tmu(ji+1,jj+1) ) &
-                     / ztmu
-
-                rcmoy(ji,jj,8)  = zindb * (  v_ice(ji,jj  ) * tmu(ji,jj  ) + v_ice(ji+1,jj  ) * tmu(ji+1,jj  )   &
-                   &                       + v_ice(ji,jj+1) * tmu(ji,jj+1) + v_ice(ji+1,jj+1) * tmu(ji+1,jj+1) ) &
-                     / ztmu
+                IF (lk_lim2_vp) THEN
+                   ztmu   = MAX( 0.5 * zone , ( tmu(ji,jj) + tmu(ji+1,jj) + tmu(ji,jj+1) + tmu(ji+1,jj+1) ) )
+                   rcmoy(ji,jj,7)  = zindb * (  u_ice(ji,jj  ) * tmu(ji,jj  ) + u_ice(ji+1,jj  ) * tmu(ji+1,jj  )   &
+                      &                      + u_ice(ji,jj+1) * tmu(ji,jj+1) + u_ice(ji+1,jj+1) * tmu(ji+1,jj+1) ) &
+                        / ztmu
+
+                   rcmoy(ji,jj,8)  = zindb * (  v_ice(ji,jj  ) * tmu(ji,jj  ) + v_ice(ji+1,jj  ) * tmu(ji+1,jj  )   &
+                      &                      + v_ice(ji,jj+1) * tmu(ji,jj+1) + v_ice(ji+1,jj+1) * tmu(ji+1,jj+1) ) &
+                       / ztmu
+                ELSE
+                   rcmoy(ji,jj,7)  = zindb * (  u_ice(ji,jj  ) * tmu(ji,jj) + u_ice(ji-1,jj) * tmu(ji-1,jj) )/ 2.0
+                   rcmoy(ji,jj,8)  = zindb * (  v_ice(ji,jj  ) * tmv(ji,jj) + v_ice(ji,jj-1) * tmv(ji,jj-1) )/ 2.0
+                ENDIF
                 rcmoy(ji,jj,9)  = sst_m(ji,jj)
                 rcmoy(ji,jj,10) = sss_m(ji,jj)
@@ -176,9 +188,10 @@
              zfield(:,:) = (rcmoy(:,:,jf) * cmulti(jf) + cadd(jf)) * tmask(:,:,1)
 
-             IF ( jf == 7  .OR. jf == 8  .OR. jf == 15 .OR. jf == 16 ) THEN 
+             SELECT CASE (jf) 
+             CASE ( 7, 8, 15, 16 ) ! velocity or stress fields (vectors)
                 CALL lbc_lnk( zfield, 'T', -1. )
-             ELSE 
+             CASE DEFAULT          ! scalar fields
                 CALL lbc_lnk( zfield, 'T',  1. )
-             ENDIF
+             END SELECT
              rcmoy(:,:,jf) = zfield(:,:)
           END DO
@@ -200,4 +213,5 @@
           nmoyice = 0 
        END IF     !  MOD(kt+nn_fsbc-1-nit000+1, nwrite == 0 ) !
+       CALL wrk_dealloc( jpi,jpj, zfield )
 
      END SUBROUTINE lim_wri_2
Index: branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/LIM_SRC_3/limadv.F90
===================================================================
--- branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/LIM_SRC_3/limadv.F90	(revision 3759)
+++ branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/LIM_SRC_3/limadv.F90	(revision 3764)
@@ -24,4 +24,5 @@
    USE wrk_nemo       ! work arrays
    USE lib_fortran    ! Fortran utilities (allows no signed zero when 'key_nosignedzero' defined)  
+   USE lib_fortran      ! Fortran utilities (allows no signed zero when 'key_nosignedzero' defined)
 
    IMPLICIT NONE
Index: branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/LIM_SRC_3/limitd_me.F90
===================================================================
--- branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/LIM_SRC_3/limitd_me.F90	(revision 3759)
+++ branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/LIM_SRC_3/limitd_me.F90	(revision 3764)
@@ -29,4 +29,5 @@
    USE prtctl         ! Print control
    USE lib_fortran    ! Fortran utilities (allows no signed zero when 'key_nosignedzero' defined)  
+   USE lib_fortran      ! Fortran utilities (allows no signed zero when 'key_nosignedzero' defined)
 
    IMPLICIT NONE
Index: branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/LIM_SRC_3/limitd_th.F90
===================================================================
--- branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/LIM_SRC_3/limitd_th.F90	(revision 3759)
+++ branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/LIM_SRC_3/limitd_th.F90	(revision 3764)
@@ -34,4 +34,5 @@
    USE wrk_nemo       ! work arrays
    USE lib_fortran    ! Fortran utilities (allows no signed zero when 'key_nosignedzero' defined)  
+   USE lib_fortran      ! Fortran utilities (allows no signed zero when 'key_nosignedzero' defined)
 
    IMPLICIT NONE
Index: branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/LIM_SRC_3/limwri_dimg.h90
===================================================================
--- branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/LIM_SRC_3/limwri_dimg.h90	(revision 3759)
+++ branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/LIM_SRC_3/limwri_dimg.h90	(revision 3764)
@@ -15,4 +15,6 @@
    !!-------------------------------------------------------------------
    USE  diawri, ONLY : dia_wri_dimg
+   USE lib_fortran    ! Fortran utilities (allows no signed zero when 'key_nosignedzero' defined)
+
    REAL(wp),DIMENSION(1) ::   zdept
 
Index: branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/OFF_SRC/nemogcm.F90
===================================================================
--- branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/OFF_SRC/nemogcm.F90	(revision 3759)
+++ branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/OFF_SRC/nemogcm.F90	(revision 3764)
@@ -45,4 +45,5 @@
    USE prtctl          ! Print control                    (prt_ctl_init routine)
    USE timing          ! Timing
+   USE lib_fortran     ! Fortran utilities (allows no signed zero when 'key_nosignedzero' defined)
 
    IMPLICIT NONE
@@ -342,4 +343,8 @@
          &                                               'Compile with key_iomput enabled' )
       !
+      IF( 1_wp /= SIGN(1._wp,-0._wp)  )   CALL ctl_stop( 'nemo_ctl: The intrinsec SIGN function follows ',  &
+         &                                               'f2003 standard. '                              ,  &
+         &                                               'Compile with key_nosignedzero enabled' )
+      !
    END SUBROUTINE nemo_ctl
 
Index: branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/OPA_SRC/ASM/asmbkg.F90
===================================================================
--- branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/OPA_SRC/ASM/asmbkg.F90	(revision 3764)
+++ branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/OPA_SRC/ASM/asmbkg.F90	(revision 3764)
@@ -0,0 +1,170 @@
+MODULE asmbkg
+   !!======================================================================
+   !!                       ***  MODULE asmtrj -> asmbkg  ***
+   !! Assimilation trajectory interface: Write to file the background state and the model state trajectory
+   !!======================================================================
+   !! History :       ! 2007-03 (M. Martin)  Met. Office version
+   !!                 ! 2007-04 (A. Weaver)  asm_trj_wri, original code
+   !!                 ! 2007-03 (K. Mogensen)  Adapt to NEMOVAR and use IOM instead of IOIPSL
+   !!                 ! 2007-04 (A. Weaver)  Name change (formally asmbkg.F90). Distinguish
+   !!                                        background states in Jb term and at analysis time.
+   !!                                        Include state trajectory routine (currently empty)
+   !!                 ! 2007-07 (A. Weaver)  Add tke_rst and flt_rst for case nitbkg=0 
+   !!                 ! 2009-03 (F. Vigilant)  Add hmlp (zdfmxl) for no tracer nmldp=2 
+   !!                 ! 2009-06 (F. Vigilant) asm_trj_wri: special case when kt=nit000-1
+   !!                 ! 2009-07 (F. Vigilant) asm_trj_wri: add computation of eiv at restart
+   !!                 ! 2010-01 (A. Vidard) split asm_trj_wri into tam_trj_wri and asm_bkg_wri
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   'key_asminc' : Switch on the assimilation increment interface
+   !!----------------------------------------------------------------------
+   !!   asm_bkg_wri  : Write out the background state
+   !!   asm_trj_wri  : Write out the model state trajectory (used with 4D-Var)
+   !!----------------------------------------------------------------------
+   USE oce                ! Dynamics and active tracers defined in memory
+   USE sbc_oce            ! Ocean surface boundary conditions
+   USE zdf_oce            ! Vertical mixing variables
+   USE zdfddm             ! Double diffusion mixing parameterization
+   USE ldftra_oce         ! Lateral tracer mixing coefficient defined in memory
+   USE ldfslp             ! Slopes of neutral surfaces
+   USE tradmp             ! Tracer damping
+#if defined key_zdftke
+   USE zdftke             ! TKE vertical physics
+#endif
+   USE eosbn2             ! Equation of state (eos_bn2 routine)
+   USE zdfmxl             ! Mixed layer depth
+   USE dom_oce, ONLY :   ndastp
+   USE sol_oce, ONLY :   gcx   ! Solver variables defined in memory
+   USE in_out_manager     ! I/O manager
+   USE iom                ! I/O module
+   USE asmpar             ! Parameters for the assmilation interface
+   USE zdfmxl             ! mixed layer depth
+#if defined key_traldf_c2d
+   USE ldfeiv             ! eddy induced velocity coef.      (ldf_eiv routine)
+#endif
+#if defined key_lim2
+   USE ice_2
+#endif
+#if defined key_lim3
+   USE ice
+#endif
+   IMPLICIT NONE
+   PRIVATE
+   
+   PUBLIC   asm_bkg_wri   !: Write out the background state
+
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.3 , NEMO Consortium (2010)
+   !! $Id: $
+   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+CONTAINS
+
+   SUBROUTINE asm_bkg_wri( kt )
+      !!-----------------------------------------------------------------------
+      !!                  ***  ROUTINE asm_bkg_wri ***
+      !!
+      !! ** Purpose : Write to file the background state for later use in the
+      !!              inner loop of data assimilation or for direct initialization
+      !!              in the outer loop.
+      !!
+      !! ** Method  : Write out the background state for use in the Jb term
+      !!              in the cost function and for use with direct initialization
+      !!              at analysis time.
+      !!-----------------------------------------------------------------------
+      INTEGER, INTENT( IN ) :: kt               ! Current time-step
+      !
+      CHARACTER (LEN=50) :: cl_asmbkg
+      CHARACTER (LEN=50) :: cl_asmdin
+      LOGICAL :: llok          ! Check if file exists
+      INTEGER :: inum          ! File unit number
+      REAL(wp) :: zdate        ! Date
+      !!-----------------------------------------------------------------------
+
+      !                                !-------------------------------------------
+      IF( kt == nitbkg_r ) THEN        ! Write out background at time step nitbkg_r
+         !                             !-----------------------------------========
+         !
+         WRITE(cl_asmbkg, FMT='(A,".nc")' ) TRIM( c_asmbkg )
+         cl_asmbkg = TRIM( cl_asmbkg )
+         INQUIRE( FILE = cl_asmbkg, EXIST = llok )
+         !
+         IF( .NOT. llok ) THEN
+            IF(lwp) WRITE(numout,*) ' Setting up assimilation background file '// TRIM( c_asmbkg )
+            !
+            !                                      ! Define the output file        
+            CALL iom_open( c_asmbkg, inum, ldwrt = .TRUE., kiolib = jprstlib)
+            !
+            IF( nitbkg_r == nit000 - 1 ) THEN      ! Treat special case when nitbkg = 0
+               zdate = REAL( ndastp )
+#if defined key_zdftke
+               ! lk_zdftke=T :   Read turbulent kinetic energy ( en )
+               IF(lwp) WRITE(numout,*) ' Reading TKE (en) from restart...'
+               CALL tke_rst( nit000, 'READ' )               ! lk_zdftke=T :   Read turbulent kinetic energy ( en )
+
+#endif
+            ELSE
+               zdate = REAL( ndastp )
+            ENDIF
+            !
+            !                                      ! Write the information
+            CALL iom_rstput( kt, nitbkg_r, inum, 'rdastp' , zdate             )
+            CALL iom_rstput( kt, nitbkg_r, inum, 'un'     , un                )
+            CALL iom_rstput( kt, nitbkg_r, inum, 'vn'     , vn                )
+            CALL iom_rstput( kt, nitbkg_r, inum, 'tn'     , tsn(:,:,:,jp_tem) )
+            CALL iom_rstput( kt, nitbkg_r, inum, 'sn'     , tsn(:,:,:,jp_sal) )
+            CALL iom_rstput( kt, nitbkg_r, inum, 'sshn'   , sshn              )
+#if defined key_zdftke
+            CALL iom_rstput( kt, nitbkg_r, inum, 'en'     , en                )
+#endif
+            CALL iom_rstput( kt, nitbkg_r, inum, 'gcx'    , gcx               )
+            !
+            CALL iom_close( inum )
+         ENDIF
+         !
+      ENDIF
+
+      !                                !-------------------------------------------
+      IF( kt == nitdin_r ) THEN        ! Write out background at time step nitdin_r
+         !                             !-----------------------------------========
+         !
+         WRITE(cl_asmdin, FMT='(A,".nc")' ) TRIM( c_asmdin )
+         cl_asmdin = TRIM( cl_asmdin )
+         INQUIRE( FILE = cl_asmdin, EXIST = llok )
+         !
+         IF( .NOT. llok ) THEN
+            IF(lwp) WRITE(numout,*) ' Setting up assimilation background file '// TRIM( c_asmdin )
+            !
+            !                                      ! Define the output file        
+            CALL iom_open( c_asmdin, inum, ldwrt = .TRUE., kiolib = jprstlib)
+            !
+            IF( nitdin_r == nit000 - 1 ) THEN      ! Treat special case when nitbkg = 0
+
+               zdate = REAL( ndastp )
+            ELSE
+               zdate = REAL( ndastp )
+            ENDIF
+            !
+            !                                      ! Write the information
+            CALL iom_rstput( kt, nitdin_r, inum, 'rdastp' , zdate             )
+            CALL iom_rstput( kt, nitdin_r, inum, 'un'     , un                )
+            CALL iom_rstput( kt, nitdin_r, inum, 'vn'     , vn                )
+            CALL iom_rstput( kt, nitdin_r, inum, 'tn'     , tsn(:,:,:,jp_tem) )
+            CALL iom_rstput( kt, nitdin_r, inum, 'sn'     , tsn(:,:,:,jp_sal) )
+            CALL iom_rstput( kt, nitdin_r, inum, 'sshn'   , sshn              )
+#if defined key_lim2 || defined key_lim3
+            IF(( nn_ice == 2 ) .OR. ( nn_ice == 3 )) THEN
+               CALL iom_rstput( kt, nitdin_r, inum, 'iceconc', 1.0 - frld(:,:)   )
+            ENDIF
+#endif
+            !
+            CALL iom_close( inum )
+         ENDIF
+         !
+      ENDIF
+      !                    
+   END SUBROUTINE asm_bkg_wri
+
+   !!======================================================================
+END MODULE asmbkg
Index: branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/OPA_SRC/ASM/asminc.F90
===================================================================
--- branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/OPA_SRC/ASM/asminc.F90	(revision 3759)
+++ branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/OPA_SRC/ASM/asminc.F90	(revision 3764)
@@ -10,4 +10,5 @@
    !!   NEMO     3.3  ! 2010-05  (D. Lea)  Update to work with NEMO v3.2
    !!             -   ! 2010-05  (D. Lea)  add calc_month_len routine based on day_init 
+   !!            3.4  ! 2012-10  (A. Weaver and K. Mogensen) Fix for direct initialization
    !!----------------------------------------------------------------------
 
@@ -20,4 +21,5 @@
    !!   dyn_asm_inc  : Apply the dynamic (u and v) increments
    !!   ssh_asm_inc  : Apply the SSH increment
+   !!   seaice_asm_inc  : Apply the seaice increment
    !!----------------------------------------------------------------------
    USE wrk_nemo         ! Memory Allocation
@@ -25,5 +27,4 @@
    USE dom_oce          ! Ocean space and time domain
    USE oce              ! Dynamics and active tracers defined in memory
-   USE divcur           ! Horizontal divergence and relative vorticity
    USE ldfdyn_oce       ! ocean dynamics: lateral physics
    USE eosbn2           ! Equation of state - in situ and potential density
@@ -33,5 +34,13 @@
    USE c1d              ! 1D initialization
    USE in_out_manager   ! I/O manager
-   USE lib_mpp           ! MPP library
+   USE lib_mpp          ! MPP library
+#if defined key_lim3
+   USE ice              ! LIM3
+#endif
+#if defined key_lim2
+   USE ice_2            ! LIM2
+#endif
+   USE sbc_oce          ! Surface boundary condition variables.
+   USE domvvl
 
    IMPLICIT NONE
@@ -43,4 +52,5 @@
    PUBLIC   dyn_asm_inc    !: Apply the dynamic (u and v) increments
    PUBLIC   ssh_asm_inc    !: Apply the SSH increment
+   PUBLIC   seaice_asm_inc !: Apply the seaice increment
 
 #if defined key_asminc
@@ -50,5 +60,4 @@
 #endif
    LOGICAL, PUBLIC :: ln_bkgwri = .FALSE. !: No output of the background state fields
-   LOGICAL, PUBLIC :: ln_trjwri = .FALSE. !: No output of the state trajectory fields
    LOGICAL, PUBLIC :: ln_asmiau = .FALSE. !: No applying forcing with an assimilation increment
    LOGICAL, PUBLIC :: ln_asmdin = .FALSE. !: No direct initialization
@@ -56,5 +65,7 @@
    LOGICAL, PUBLIC :: ln_dyninc = .FALSE. !: No dynamics (u and v) assimilation increments
    LOGICAL, PUBLIC :: ln_sshinc = .FALSE. !: No sea surface height assimilation increment
+   LOGICAL, PUBLIC :: ln_seaiceinc = .FALSE. !: No sea ice concentration increment
    LOGICAL, PUBLIC :: ln_salfix = .FALSE. !: Apply minimum salinity check
+   LOGICAL, PUBLIC :: ln_temnofreeze = .FALSE. !: Don't allow the temperature to drop below freezing
    INTEGER, PUBLIC :: nn_divdmp = 0       !: Apply divergence damping filter nn_divdmp times
 
@@ -78,4 +89,5 @@
 
    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::   ssh_bkg, ssh_bkginc   ! Background sea surface height and its increment
+   REAL(wp), DIMENSION(:,:), ALLOCATABLE ::   seaice_bkginc         ! Increment to the background sea ice conc
 
    !! * Substitutions
@@ -125,9 +137,9 @@
       REAL(wp), POINTER, DIMENSION(:,:) :: hdiv
       !!
-      NAMELIST/nam_asminc/ ln_bkgwri, ln_trjwri,                           &
+      NAMELIST/nam_asminc/ ln_bkgwri,                                      &
          &                 ln_trainc, ln_dyninc, ln_sshinc,                &
          &                 ln_asmdin, ln_asmiau,                           &
          &                 nitbkg, nitdin, nitiaustr, nitiaufin, niaufn,   &
-         &                 nittrjfrq, ln_salfix, salfixmin,                &
+         &                 ln_salfix, salfixmin,                &
          &                 nn_divdmp
       !!----------------------------------------------------------------------
@@ -139,11 +151,12 @@
       ! Set default values
       ln_bkgwri = .FALSE.
-      ln_trjwri = .FALSE.
       ln_trainc = .FALSE.
       ln_dyninc = .FALSE.
       ln_sshinc = .FALSE.
+      ln_seaiceinc = .FALSE.
       ln_asmdin = .FALSE.
       ln_asmiau = .TRUE.
       ln_salfix = .FALSE.
+      ln_temnofreeze = .FALSE.
       salfixmin = -9999
       nitbkg    = 0
@@ -152,5 +165,4 @@
       nitiaufin = 150      ! = 10 days with ORCA2
       niaufn    = 0
-      nittrjfrq = 1
 
       REWIND ( numnam )
@@ -164,9 +176,9 @@
          WRITE(numout,*) '   Namelist namasm : set assimilation increment parameters'
          WRITE(numout,*) '      Logical switch for writing out background state          ln_bkgwri = ', ln_bkgwri
-         WRITE(numout,*) '      Logical switch for writing out state trajectory          ln_trjwri = ', ln_trjwri
          WRITE(numout,*) '      Logical switch for applying tracer increments            ln_trainc = ', ln_trainc
          WRITE(numout,*) '      Logical switch for applying velocity increments          ln_dyninc = ', ln_dyninc
          WRITE(numout,*) '      Logical switch for applying SSH increments               ln_sshinc = ', ln_sshinc
          WRITE(numout,*) '      Logical switch for Direct Initialization (DI)            ln_asmdin = ', ln_asmdin
+         WRITE(numout,*) '      Logical switch for applying sea ice increments        ln_seaiceinc = ', ln_seaiceinc
          WRITE(numout,*) '      Logical switch for Incremental Analysis Updating (IAU)   ln_asmiau = ', ln_asmiau
          WRITE(numout,*) '      Timestep of background in [0,nitend-nit000-1]            nitbkg    = ', nitbkg
@@ -175,5 +187,4 @@
          WRITE(numout,*) '      Timestep of end of IAU interval in [0,nitend-nit000-1]   nitiaufin = ', nitiaufin
          WRITE(numout,*) '      Type of IAU weighting function                           niaufn    = ', niaufn
-         WRITE(numout,*) '      Frequency of trajectory output for 4D-VAR                nittrjfrq = ', nittrjfrq
          WRITE(numout,*) '      Logical switch for ensuring that the sa > salfixmin      ln_salfix = ', ln_salfix
          WRITE(numout,*) '      Minimum salinity after applying the increments           salfixmin = ', salfixmin
@@ -213,5 +224,4 @@
          WRITE(numout,*) '       nitiaustr_r = ', nitiaustr_r
          WRITE(numout,*) '       nitiaufin_r = ', nitiaufin_r
-         WRITE(numout,*) '       nittrjfrq   = ', nittrjfrq
          WRITE(numout,*)
          WRITE(numout,*) '   Dates referenced to current cycle:'
@@ -235,6 +245,6 @@
 
       IF (      ( ( .NOT. ln_asmdin ).AND.( .NOT. ln_asmiau ) ) &
-           .AND.( ( ln_trainc ).OR.( ln_dyninc ).OR.( ln_sshinc ) ) ) &
-         & CALL ctl_stop( ' One or more of ln_trainc, ln_dyninc and ln_sshinc is set to .true.', &
+           .AND.( ( ln_trainc ).OR.( ln_dyninc ).OR.( ln_sshinc ) .OR. ( ln_seaiceinc) )) &
+         & CALL ctl_stop( ' One or more of ln_trainc, ln_dyninc, ln_sshinc and ln_seaiceinc is set to .true.', &
          &                ' but ln_asmdin and ln_asmiau are both set to .false. :', &
          &                ' Inconsistent options')
@@ -248,7 +258,7 @@
          &                ' Type IAU weighting function is invalid')
 
-      IF ( ( .NOT. ln_trainc ).AND.( .NOT. ln_dyninc ).AND.( .NOT. ln_sshinc ) &
+      IF ( ( .NOT. ln_trainc ).AND.( .NOT. ln_dyninc ).AND.( .NOT. ln_sshinc ).AND.( .NOT. ln_seaiceinc ) &
          &                     )  &
-         & CALL ctl_warn( ' ln_trainc, ln_dyninc and ln_sshinc are set to .false. :', &
+         & CALL ctl_warn( ' ln_trainc, ln_dyninc, ln_sshinc and ln_seaiceinc are set to .false. :', &
          &                ' The assimilation increments are not applied')
 
@@ -353,4 +363,5 @@
       ALLOCATE( v_bkginc(jpi,jpj,jpk) )
       ALLOCATE( ssh_bkginc(jpi,jpj)   )
+      ALLOCATE( seaice_bkginc(jpi,jpj))
 #if defined key_asminc
       ALLOCATE( ssh_iau(jpi,jpj)      )
@@ -361,8 +372,9 @@
       v_bkginc(:,:,:) = 0.0
       ssh_bkginc(:,:) = 0.0
+      seaice_bkginc(:,:) = 0.0
 #if defined key_asminc
       ssh_iau(:,:)    = 0.0
 #endif
-      IF ( ( ln_trainc ).OR.( ln_dyninc ).OR.( ln_sshinc ) ) THEN
+      IF ( ( ln_trainc ).OR.( ln_dyninc ).OR.( ln_sshinc ).OR.( ln_seaiceinc ) ) THEN
 
          !--------------------------------------------------------------------
@@ -429,4 +441,13 @@
          ENDIF
 
+         IF ( ln_seaiceinc ) THEN
+            CALL iom_get( inum, jpdom_autoglo, 'bckinseaice', seaice_bkginc, 1 )
+            ! Apply the masks
+            seaice_bkginc(:,:) = seaice_bkginc(:,:) * tmask(:,:,1)
+            ! Set missing increments to 0.0 rather than 1e+20
+            ! to allow for differences in masks
+            WHERE( ABS( seaice_bkginc(:,:) ) > 1.0e+10 ) seaice_bkginc(:,:) = 0.0
+         ENDIF
+
          CALL iom_close( inum )
  
@@ -437,44 +458,43 @@
       !-----------------------------------------------------------------------
 
-
       IF ( ln_dyninc .AND. nn_divdmp > 0 ) THEN
 
-      CALL wrk_alloc(jpi,jpj,hdiv) 
-
-       DO  jt = 1, nn_divdmp
-
-           DO jk = 1, jpkm1
-
-                  hdiv(:,:) = 0._wp
-
-            DO jj = 2, jpjm1
-               DO ji = fs_2, fs_jpim1   ! vector opt.
-                  hdiv(ji,jj) =   &
-                     (  e2u(ji  ,jj)*fse3u(ji  ,jj,jk) * u_bkginc(ji  ,jj,jk)       &
-                      - e2u(ji-1,jj)*fse3u(ji-1,jj,jk) * u_bkginc(ji-1,jj,jk)       &
-                      + e1v(ji,jj  )*fse3v(ji,jj  ,jk) * v_bkginc(ji,jj  ,jk)       &
-                      - e1v(ji,jj-1)*fse3v(ji,jj-1,jk) * v_bkginc(ji,jj-1,jk)  )    &
-                      / ( e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,jk) )
+         CALL wrk_alloc(jpi,jpj,hdiv) 
+
+         DO  jt = 1, nn_divdmp
+
+            DO jk = 1, jpkm1
+
+               hdiv(:,:) = 0._wp
+
+               DO jj = 2, jpjm1
+                  DO ji = fs_2, fs_jpim1   ! vector opt.
+                     hdiv(ji,jj) =   &
+                        (  e2u(ji  ,jj  ) * fse3u(ji  ,jj  ,jk) * u_bkginc(ji  ,jj  ,jk)     &
+                         - e2u(ji-1,jj  ) * fse3u(ji-1,jj  ,jk) * u_bkginc(ji-1,jj  ,jk)     &
+                         + e1v(ji  ,jj  ) * fse3v(ji  ,jj  ,jk) * v_bkginc(ji  ,jj  ,jk)     &
+                         - e1v(ji  ,jj-1) * fse3v(ji  ,jj-1,jk) * v_bkginc(ji  ,jj-1,jk)  )  &
+                         / ( e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,jk) )
+                  END DO
                END DO
+
+               CALL lbc_lnk( hdiv, 'T', 1. )   ! lateral boundary cond. (no sign change)
+
+               DO jj = 2, jpjm1
+                  DO ji = fs_2, fs_jpim1   ! vector opt.
+                     u_bkginc(ji,jj,jk) = u_bkginc(ji,jj,jk) + 0.2_wp * ( e1t(ji+1,jj)*e2t(ji+1,jj) * hdiv(ji+1,jj)   &
+                                                                        - e1t(ji  ,jj)*e2t(ji  ,jj) * hdiv(ji  ,jj) ) &
+                                                                      / e1u(ji,jj) * umask(ji,jj,jk) 
+                     v_bkginc(ji,jj,jk) = v_bkginc(ji,jj,jk) + 0.2_wp * ( e1t(ji,jj+1)*e2t(ji,jj+1) * hdiv(ji,jj+1)   &
+                                                                        - e1t(ji,jj  )*e2t(ji,jj  ) * hdiv(ji,jj  ) ) &
+                                                                      / e2v(ji,jj) * vmask(ji,jj,jk) 
+                  END DO
+               END DO
+
             END DO
 
-            CALL lbc_lnk( hdiv, 'T', 1. )   ! lateral boundary cond. (no sign change)
-
-            DO jj = 2, jpjm1
-               DO ji = fs_2, fs_jpim1   ! vector opt.
-                  u_bkginc(ji,jj,jk) = u_bkginc(ji,jj,jk) + 0.2 * ( e1t(ji+1,jj)*e2t(ji+1,jj) * hdiv(ji+1,jj)   &
-                                                                  - e1t(ji  ,jj)*e2t(ji  ,jj) * hdiv(ji  ,jj) ) &
-                                                                / e1u(ji,jj) * umask(ji,jj,jk) 
-                  v_bkginc(ji,jj,jk) = v_bkginc(ji,jj,jk) + 0.2 * ( e1t(ji,jj+1)*e2t(ji,jj+1) * hdiv(ji,jj+1)   &
-                                                                  - e1t(ji,jj  )*e2t(ji,jj  ) * hdiv(ji,jj  ) ) &
-                                                                / e2v(ji,jj) * vmask(ji,jj,jk) 
-               END DO
-            END DO
-
-           END DO
-
-       END DO
-
-       CALL wrk_dealloc(jpi,jpj,hdiv) 
+         END DO
+
+         CALL wrk_dealloc(jpi,jpj,hdiv) 
 
       ENDIF
@@ -506,5 +526,5 @@
          CALL iom_open( c_asmdin, inum )
 
-         CALL iom_get( inum, 'zdate', zdate_bkg ) 
+         CALL iom_get( inum, 'rdastp', zdate_bkg ) 
         
          IF(lwp) THEN
@@ -662,5 +682,23 @@
       INTEGER :: it
       REAL(wp) :: zincwgt  ! IAU weight for current time step
-      !!----------------------------------------------------------------------
+      REAL (wp), DIMENSION(jpi,jpj,jpk) :: fzptnz ! 3d freezing point values
+      !!----------------------------------------------------------------------
+
+      ! freezing point calculation taken from oc_fz_pt (but calculated for all depths) 
+      ! 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 
 
       IF ( ln_asmiau ) THEN
@@ -684,18 +722,24 @@
             ! Update the tracer tendencies
             DO jk = 1, jpkm1
-               tsa(:,:,jk,jp_tem) = tsa(:,:,jk,jp_tem) + t_bkginc(:,:,jk) * zincwgt  
-               tsa(:,:,jk,jp_sal) = tsa(:,:,jk,jp_sal) + s_bkginc(:,:,jk) * zincwgt
+               IF (ln_temnofreeze) THEN
+                  ! Do not apply negative increments if the temperature will fall below freezing
+                  WHERE(t_bkginc(:,:,jk) > 0.0_wp .OR. &
+                     &   tsn(:,:,jk,jp_tem) + tsa(:,:,jk,jp_tem) + t_bkginc(:,:,jk) * wgtiau(it) > fzptnz(:,:,jk) ) 
+                     tsa(:,:,jk,jp_tem) = tsa(:,:,jk,jp_tem) + t_bkginc(:,:,jk) * zincwgt  
+                  END WHERE
+               ELSE
+                  tsa(:,:,jk,jp_tem) = tsa(:,:,jk,jp_tem) + t_bkginc(:,:,jk) * zincwgt  
+               ENDIF
+               IF (ln_salfix) THEN
+                  ! Do not apply negative increments if the salinity will fall below a specified
+                  ! minimum value salfixmin
+                  WHERE(s_bkginc(:,:,jk) > 0.0_wp .OR. &
+                     &   tsn(:,:,jk,jp_sal) + tsa(:,:,jk,jp_sal) + s_bkginc(:,:,jk) * wgtiau(it) > salfixmin ) 
+                     tsa(:,:,jk,jp_sal) = tsa(:,:,jk,jp_sal) + s_bkginc(:,:,jk) * zincwgt
+                  END WHERE
+               ELSE
+                  tsa(:,:,jk,jp_sal) = tsa(:,:,jk,jp_sal) + s_bkginc(:,:,jk) * zincwgt
+               ENDIF
             END DO
-
-            ! Salinity fix
-            IF (ln_salfix) THEN
-               DO jk = 1, jpkm1
-                  DO jj = 1, jpj
-                     DO ji= 1, jpi
-                        tsa(ji,jj,jk,jp_sal) = MAX( tsa(ji,jj,jk,jp_sal), salfixmin )
-                     END DO
-                  END DO
-               END DO
-            ENDIF
 
          ENDIF
@@ -718,26 +762,36 @@
 
             ! Initialize the now fields with the background + increment
-            tsn(:,:,:,jp_tem) = t_bkg(:,:,:) + t_bkginc(:,:,:)   
-            tsn(:,:,:,jp_sal) = s_bkg(:,:,:) + s_bkginc(:,:,:)   
-
-            ! Optional salinity fix
+            IF (ln_temnofreeze) THEN
+               ! Do not apply negative increments if the temperature will fall below freezing
+               WHERE(t_bkginc(:,:,:) > 0.0_wp .OR. &
+                  &   tsn(:,:,:,jp_tem) + t_bkginc(:,:,:) > fzptnz(:,:,:) ) 
+                  tsn(:,:,:,jp_tem) = t_bkg(:,:,:) + t_bkginc(:,:,:)   
+               END WHERE
+            ELSE
+               tsn(:,:,:,jp_tem) = t_bkg(:,:,:) + t_bkginc(:,:,:)   
+            ENDIF
             IF (ln_salfix) THEN
-               DO jk = 1, jpkm1
-                  DO jj = 1, jpj
-                     DO ji= 1, jpi
-                        tsn(ji,jj,jk,jp_sal) = MAX( tsn(ji,jj,jk,jp_sal), salfixmin )
-                     END DO
-                  END DO
-               END DO
+               ! Do not apply negative increments if the salinity will fall below a specified
+               ! minimum value salfixmin
+               WHERE(s_bkginc(:,:,:) > 0.0_wp .OR. &
+                  &   tsn(:,:,:,jp_sal) + s_bkginc(:,:,:) > salfixmin ) 
+                  tsn(:,:,:,jp_sal) = s_bkg(:,:,:) + s_bkginc(:,:,:)   
+               END WHERE
+            ELSE
+               tsn(:,:,:,jp_sal) = s_bkg(:,:,:) + s_bkginc(:,:,:)   
             ENDIF
 
-            tsb(:,:,:,:) = tsn(:,:,:,:)                        ! Update before fields
+            tsb(:,:,:,:) = tsn(:,:,:,:)               ! Update before fields
 
             CALL eos( tsb, rhd, rhop )                ! Before potential and in situ densities
          
             IF( ln_zps .AND. .NOT. lk_c1d ) &
-               &  CALL zps_hde( nit000, jpts, tsb,   &  ! Partial steps: before horizontal derivative
-               &                gtsu, gtsv, rhd,        &  ! of T, S, rd at the bottom ocean level
+               &  CALL zps_hde( nit000, jpts, tsb, &  ! Partial steps: before horizontal derivative
+               &                gtsu, gtsv, rhd,   &  ! of T, S, rd at the bottom ocean level
                &                gru , grv )
+
+#if defined key_zdfkpp
+            CALL eos( tsn, rhd )                      ! Compute rhd
+#endif
 
             DEALLOCATE( t_bkginc )
@@ -748,4 +802,6 @@
          !  
       ENDIF
+      ! Perhaps the following call should be in step
+      IF   ( ln_seaiceinc  )   CALL seaice_asm_inc ( kt )   ! apply sea ice concentration increment
       !
    END SUBROUTINE tra_asm_inc
@@ -817,9 +873,4 @@
             vb(:,:,:) = vn(:,:,:)
  
-            CALL div_cur( kt )            ! Compute divergence and curl for now fields
-
-            rotb (:,:,:) = rotn (:,:,:)   ! Update before fields
-            hdivb(:,:,:) = hdivn(:,:,:)
-
             DEALLOCATE( u_bkg    )
             DEALLOCATE( v_bkg    )
@@ -846,4 +897,5 @@
       !
       INTEGER :: it
+      INTEGER :: jk
       REAL(wp) :: zincwgt  ! IAU weight for current time step
       !!----------------------------------------------------------------------
@@ -891,5 +943,12 @@
             sshn(:,:) = ssh_bkg(:,:) + ssh_bkginc(:,:)  
 
-            sshb(:,:) = sshn(:,:)         ! Update before fields
+            ! Update before fields
+            sshb(:,:) = sshn(:,:)         
+
+            IF( lk_vvl ) THEN
+               DO jk = 1, jpk
+                  fse3t_b(:,:,jk) = fse3t_n(:,:,jk)
+               END DO
+            ENDIF
 
             DEALLOCATE( ssh_bkg    )
@@ -902,4 +961,242 @@
    END SUBROUTINE ssh_asm_inc
 
+   SUBROUTINE seaice_asm_inc( kt, kindic )
+      !!----------------------------------------------------------------------
+      !!                    ***  ROUTINE seaice_asm_inc  ***
+      !!          
+      !! ** Purpose : Apply the sea ice assimilation increment.
+      !!
+      !! ** Method  : Direct initialization or Incremental Analysis Updating.
+      !!
+      !! ** Action  : 
+      !!
+      !! History :
+      !!        !  07-2011  (D. Lea)  Initial version based on ssh_asm_inc
+      !!----------------------------------------------------------------------
+
+      IMPLICIT NONE
+
+      !! * Arguments
+      INTEGER, INTENT(IN) :: kt   ! Current time step
+      INTEGER, OPTIONAL, INTENT(IN) :: kindic ! flag for disabling the deallocation
+
+      !! * Local declarations
+      INTEGER :: it
+      REAL(wp) :: zincwgt  ! IAU weight for current time step
+
+#if defined key_lim3 || defined key_lim2
+      REAL(wp), DIMENSION(jpi,jpj) :: zofrld, zohicif, zseaicendg, zhicifinc  ! LIM
+      REAL(wp) :: zhicifmin=0.5_wp      ! ice minimum depth in metres
+
+#endif
+
+
+      IF ( ln_asmiau ) THEN
+
+         !--------------------------------------------------------------------
+         ! Incremental Analysis Updating
+         !--------------------------------------------------------------------
+
+         IF ( ( kt >= nitiaustr_r ).AND.( kt <= nitiaufin_r ) ) THEN
+
+            it = kt - nit000 + 1
+            zincwgt = wgtiau(it)      ! IAU weight for the current time step 
+            ! note this is not a tendency so should not be divided by rdt (as with the tracer and other increments)
+
+            IF(lwp) THEN
+               WRITE(numout,*) 
+               WRITE(numout,*) 'seaice_asm_inc : sea ice conc IAU at time step = ', &
+                  &  kt,' with IAU weight = ', wgtiau(it)
+               WRITE(numout,*) '~~~~~~~~~~~~'
+            ENDIF
+
+#if defined key_lim3 || defined key_lim2
+
+            zofrld(:,:)=frld(:,:)
+            zohicif(:,:)=hicif(:,:)
+
+            frld = MIN( MAX( frld(:,:) - seaice_bkginc(:,:) * zincwgt, 0.0_wp), 1.0_wp)
+            pfrld = MIN( MAX( pfrld(:,:) - seaice_bkginc(:,:) * zincwgt, 0.0_wp), 1.0_wp)
+            fr_i(:,:) = 1.0_wp - frld(:,:)        ! adjust ice fraction
+
+            zseaicendg(:,:)=zofrld(:,:) - frld(:,:)         ! find out actual sea ice nudge applied
+
+            ! Nudge sea ice depth to bring it up to a required minimum depth
+
+            WHERE( zseaicendg(:,:) > 0.0_wp .AND. hicif(:,:) < zhicifmin ) 
+               zhicifinc(:,:) = (zhicifmin - hicif(:,:)) * zincwgt    
+            ELSEWHERE
+               zhicifinc(:,:) = 0.0_wp
+            END WHERE
+
+! nudge ice depth
+            hicif(:,:)=hicif(:,:) + zhicifinc(:,:)
+            phicif(:,:)=phicif(:,:) + zhicifinc(:,:)       
+
+! seaice salinity balancing (to add)
+
+#endif
+
+#if defined key_cice
+
+! Pass ice increment tendency into CICE
+            ndaice_da(:,:) = seaice_bkginc(:,:) * zincwgt / rdt
+
+#endif
+
+            IF ( kt == nitiaufin_r ) THEN
+               DEALLOCATE( seaice_bkginc )
+            ENDIF
+
+         ELSE
+
+#if defined key_cice
+
+! Zero ice increment tendency into CICE
+            ndaice_da(:,:) = 0.0_wp
+
+#endif
+
+         ENDIF
+
+      ELSEIF ( ln_asmdin ) THEN
+
+         !--------------------------------------------------------------------
+         ! Direct Initialization
+         !--------------------------------------------------------------------
+
+         IF ( kt == nitdin_r ) THEN
+
+            neuler = 0                    ! Force Euler forward step
+
+#if defined key_lim3 || defined key_lim2
+
+            zofrld(:,:)=frld(:,:)
+            zohicif(:,:)=hicif(:,:)
+ 
+            ! Initialize the now fields the background + increment
+
+            frld(:,:) = MIN( MAX( frld(:,:) - seaice_bkginc(:,:), 0.0_wp), 1.0_wp)
+            pfrld(:,:) = frld(:,:) 
+            fr_i(:,:) = 1.0_wp - frld(:,:)        ! adjust ice fraction
+
+            zseaicendg(:,:)=zofrld(:,:) - frld(:,:)         ! find out actual sea ice nudge applied
+
+            ! Nudge sea ice depth to bring it up to a required minimum depth
+
+            WHERE( zseaicendg(:,:) > 0.0_wp .AND. hicif(:,:) < zhicifmin ) 
+               zhicifinc(:,:) = (zhicifmin - hicif(:,:)) * zincwgt    
+            ELSEWHERE
+               zhicifinc(:,:) = 0.0_wp
+            END WHERE
+
+! nudge ice depth
+            hicif(:,:)=hicif(:,:) + zhicifinc(:,:)
+            phicif(:,:)=phicif(:,:)       
+
+! seaice salinity balancing (to add)
+  
+#endif
+ 
+#if defined key_cice
+
+! Pass ice increment tendency into CICE - is this correct?
+           ndaice_da(:,:) = seaice_bkginc(:,:) / rdt
+
+#endif
+           IF ( .NOT. PRESENT(kindic) ) THEN
+              DEALLOCATE( seaice_bkginc )
+           END IF
+
+         ELSE
+
+#if defined key_cice
+
+! Zero ice increment tendency into CICE 
+            ndaice_da(:,:) = 0.0_wp
+
+#endif
+         
+         ENDIF
+
+!#if defined key_lim3 || defined key_lim2 || defined key_cice
+!
+!            IF (ln_seaicebal ) THEN       
+!             !! balancing salinity increments
+!             !! simple case from limflx.F90 (doesn't include a mass flux)
+!             !! assumption is that as ice concentration is reduced or increased
+!             !! the snow and ice depths remain constant
+!             !! note that snow is being created where ice concentration is being increased
+!             !! - could be more sophisticated and
+!             !! not do this (but would need to alter h_snow)
+!
+!             usave(:,:,:)=sb(:,:,:)   ! use array as a temporary store
+!
+!             DO jj = 1, jpj
+!               DO ji = 1, jpi 
+!           ! calculate change in ice and snow mass per unit area
+!           ! positive values imply adding salt to the ocean (results from ice formation)
+!           ! fwf : ice formation and melting
+!
+!                 zfons = ( -nfresh_da(ji,jj)*soce + nfsalt_da(ji,jj) )*rdt
+!
+!           ! change salinity down to mixed layer depth
+!                 mld=hmld_kara(ji,jj)
+!
+!           ! prevent small mld
+!           ! less than 10m can cause salinity instability 
+!                 IF (mld < 10) mld=10
+!
+!           ! set to bottom of a level 
+!                 DO jk = jpk-1, 2, -1
+!                   IF ((mld > gdepw(ji,jj,jk)) .and. (mld < gdepw(ji,jj,jk+1))) THEN 
+!                     mld=gdepw(ji,jj,jk+1)
+!                     jkmax=jk
+!                   ENDIF
+!                 ENDDO
+!
+!            ! avoid applying salinity balancing in shallow water or on land
+!            ! 
+!
+!            ! dsal_ocn (psu kg m^-2) / (kg m^-3 * m)
+!
+!                 dsal_ocn=0.0_wp
+!                 sal_thresh=5.0_wp        ! minimum salinity threshold for salinity balancing
+!
+!                 if (tmask(ji,jj,1) > 0 .AND. tmask(ji,jj,jkmax) > 0 ) &
+!                              dsal_ocn = zfons / (rhop(ji,jj,1) * mld)
+!
+!           ! put increments in for levels in the mixed layer
+!           ! but prevent salinity below a threshold value 
+!
+!                   DO jk = 1, jkmax              
+!
+!                     IF (dsal_ocn > 0.0_wp .or. sb(ji,jj,jk)+dsal_ocn > sal_thresh) THEN 
+!                           sb(ji,jj,jk) = sb(ji,jj,jk) + dsal_ocn
+!                           sn(ji,jj,jk) = sn(ji,jj,jk) + dsal_ocn
+!                     ENDIF
+!
+!                   ENDDO
+!
+!      !            !  salt exchanges at the ice/ocean interface
+!      !            zpmess         = zfons / rdt_ice    ! rdt_ice is ice timestep
+!      !
+!      !! Adjust fsalt. A +ve fsalt means adding salt to ocean
+!      !!           fsalt(ji,jj) =  fsalt(ji,jj) + zpmess     ! adjust fsalt  
+!      !!               
+!      !!           emps(ji,jj) = emps(ji,jj) + zpmess        ! or adjust emps (see icestp1d) 
+!      !!                                                     ! E-P (kg m-2 s-2)
+!      !            emp(ji,jj) = emp(ji,jj) + zpmess          ! E-P (kg m-2 s-2)
+!               ENDDO !ji
+!             ENDDO !jj!
+!
+!            ENDIF !ln_seaicebal
+!
+!#endif
+
+
+      ENDIF
+
+   END SUBROUTINE seaice_asm_inc
    !!======================================================================
 END MODULE asminc
Index: branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/OPA_SRC/ASM/asmtrj.F90
===================================================================
--- branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/OPA_SRC/ASM/asmtrj.F90	(revision 3759)
+++ 	(revision )
@@ -1,250 +1,0 @@
-MODULE asmtrj
-   !!======================================================================
-   !!                       ***  MODULE asmtrj  ***
-   !! Assimilation trajectory interface: Write to file the background state and the model state trajectory
-   !!======================================================================
-   !! History :       ! 2007-03 (M. Martin)  Met. Office version
-   !!                 ! 2007-04 (A. Weaver)  asm_trj_wri, original code
-   !!                 ! 2007-03 (K. Mogensen)  Adapt to NEMOVAR and use IOM instead of IOIPSL
-   !!                 ! 2007-04 (A. Weaver)  Name change (formally asmbkg.F90). Distinguish
-   !!                                        background states in Jb term and at analysis time.
-   !!                                        Include state trajectory routine (currently empty)
-   !!                 ! 2007-07 (A. Weaver)  Add tke_rst and flt_rst for case nitbkg=0 
-   !!                 ! 2009-03 (F. Vigilant)  Add hmlp (zdfmxl) for no tracer nmldp=2 
-   !!                 ! 2009-06 (F. Vigilant) asm_trj_wri: special case when kt=nit000-1
-   !!                 ! 2009-07 (F. Vigilant) asm_trj_wri: add computation of eiv at restart
-   !!----------------------------------------------------------------------
-
-   !!----------------------------------------------------------------------
-   !!   'key_asminc' : Switch on the assimilation increment interface
-   !!----------------------------------------------------------------------
-   !!   asm_bkg_wri  : Write out the background state
-   !!   asm_trj_wri  : Write out the model state trajectory (used with 4D-Var)
-   !!----------------------------------------------------------------------
-   USE oce                ! Dynamics and active tracers defined in memory
-   USE sbc_oce            ! Ocean surface boundary conditions
-   USE zdf_oce            ! Vertical mixing variables
-   USE zdfddm             ! Double diffusion mixing parameterization
-   USE ldftra_oce         ! Lateral tracer mixing coefficient defined in memory
-   USE ldfslp             ! Slopes of neutral surfaces
-   USE tradmp             ! Tracer damping
-#if defined key_zdftke
-   USE zdftke             ! TKE vertical physics
-#endif
-   USE eosbn2             ! Equation of state (eos_bn2 routine)
-   USE zdfmxl             ! Mixed layer depth
-   USE dom_oce, ONLY :   ndastp
-   USE sol_oce, ONLY :   gcx   ! Solver variables defined in memory
-   USE in_out_manager     ! I/O manager
-   USE iom                ! I/O module
-   USE asmpar             ! Parameters for the assmilation interface
-   USE zdfmxl             ! mixed layer depth
-#if defined key_traldf_c2d
-   USE ldfeiv             ! eddy induced velocity coef.      (ldf_eiv routine)
-#endif
-
-   IMPLICIT NONE
-   PRIVATE
-   
-   PUBLIC   asm_bkg_wri   !: Write out the background state
-   PUBLIC   asm_trj_wri   !: Write out the background state
-
-   !!----------------------------------------------------------------------
-   !! NEMO/OPA 3.3 , NEMO Consortium (2010)
-   !! $Id$
-   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
-   !!----------------------------------------------------------------------
-CONTAINS
-
-   SUBROUTINE asm_bkg_wri( kt )
-      !!-----------------------------------------------------------------------
-      !!                  ***  ROUTINE asm_bkg_wri ***
-      !!
-      !! ** Purpose : Write to file the background state for later use in the
-      !!              inner loop of data assimilation or for direct initialization
-      !!              in the outer loop.
-      !!
-      !! ** Method  : Write out the background state for use in the Jb term
-      !!              in the cost function and for use with direct initialization
-      !!              at analysis time.
-      !!-----------------------------------------------------------------------
-      INTEGER, INTENT( IN ) :: kt               ! Current time-step
-      !
-      CHARACTER (LEN=50) :: cl_asmbkg
-      CHARACTER (LEN=50) :: cl_asmdin
-      LOGICAL :: llok          ! Check if file exists
-      INTEGER :: inum          ! File unit number
-      REAL(wp) :: zdate        ! Date
-      !!-----------------------------------------------------------------------
-
-      !                                !-------------------------------------------
-      IF( kt == nitbkg_r ) THEN        ! Write out background at time step nitbkg_r
-         !                             !-----------------------------------========
-         !
-         WRITE(cl_asmbkg, FMT='(A,".nc")' ) TRIM( c_asmbkg )
-         cl_asmbkg = TRIM( cl_asmbkg )
-         INQUIRE( FILE = cl_asmbkg, EXIST = llok )
-         !
-         IF( .NOT. llok ) THEN
-            IF(lwp) WRITE(numout,*) ' Setting up assimilation background file '// TRIM( c_asmbkg )
-            !
-            !                                      ! Define the output file        
-            CALL iom_open( c_asmbkg, inum, ldwrt = .TRUE., kiolib = jprstlib)
-            !
-            IF( nitbkg_r == nit000 - 1 ) THEN      ! Treat special case when nitbkg = 0
-               zdate = REAL( ndastp )
-#if defined key_zdftke
-               ! lk_zdftke=T :   Read turbulent kinetic energy ( en )
-               IF(lwp) WRITE(numout,*) ' Reading TKE (en) from restart...'
-               CALL tke_rst( nit000, 'READ' )               ! lk_zdftke=T :   Read turbulent kinetic energy ( en )
-
-#endif
-            ELSE
-               zdate = REAL( ndastp )
-            ENDIF
-            !
-            !                                      ! Write the information
-            CALL iom_rstput( kt, nitbkg_r, inum, 'rdastp' , zdate             )
-            CALL iom_rstput( kt, nitbkg_r, inum, 'un'     , un                )
-            CALL iom_rstput( kt, nitbkg_r, inum, 'vn'     , vn                )
-            CALL iom_rstput( kt, nitbkg_r, inum, 'tn'     , tsn(:,:,:,jp_tem) )
-            CALL iom_rstput( kt, nitbkg_r, inum, 'sn'     , tsn(:,:,:,jp_sal) )
-            CALL iom_rstput( kt, nitbkg_r, inum, 'sshn'   , sshn              )
-#if defined key_zdftke
-            CALL iom_rstput( kt, nitbkg_r, inum, 'en'     , en                )
-#endif
-            CALL iom_rstput( kt, nitbkg_r, inum, 'gcx'    , gcx               )
-            !
-            CALL iom_close( inum )
-         ENDIF
-         !
-      ENDIF
-
-      !                                !-------------------------------------------
-      IF( kt == nitdin_r ) THEN        ! Write out background at time step nitdin_r
-         !                             !-----------------------------------========
-         !
-         WRITE(cl_asmdin, FMT='(A,".nc")' ) TRIM( c_asmdin )
-         cl_asmdin = TRIM( cl_asmdin )
-         INQUIRE( FILE = cl_asmdin, EXIST = llok )
-         !
-         IF( .NOT. llok ) THEN
-            IF(lwp) WRITE(numout,*) ' Setting up assimilation background file '// TRIM( c_asmdin )
-            !
-            !                                      ! Define the output file        
-            CALL iom_open( c_asmdin, inum, ldwrt = .TRUE., kiolib = jprstlib)
-            !
-            IF( nitdin_r == nit000 - 1 ) THEN      ! Treat special case when nitbkg = 0
-
-               zdate = REAL( ndastp )
-            ELSE
-               zdate = REAL( ndastp )
-            ENDIF
-            !
-            !                                      ! Write the information
-            CALL iom_rstput( kt, nitdin_r, inum, 'rdastp' , zdate             )
-            CALL iom_rstput( kt, nitdin_r, inum, 'un'     , un                )
-            CALL iom_rstput( kt, nitdin_r, inum, 'vn'     , vn                )
-            CALL iom_rstput( kt, nitdin_r, inum, 'tn'     , tsn(:,:,:,jp_tem) )
-            CALL iom_rstput( kt, nitdin_r, inum, 'sn'     , tsn(:,:,:,jp_sal) )
-            CALL iom_rstput( kt, nitdin_r, inum, 'sshn'   , sshn              )
-            !
-            CALL iom_close( inum )
-         ENDIF
-         !
-      ENDIF
-      !                    
-   END SUBROUTINE asm_bkg_wri
-
-
-   SUBROUTINE asm_trj_wri( kt )
-      !!-----------------------------------------------------------------------
-      !!                  ***  ROUTINE asm_trj_wri ***
-      !!
-      !! ** Purpose :   Write to file the model state trajectory for use with 4D-Var.
-      !!-----------------------------------------------------------------------
-      INTEGER, INTENT( IN ) :: kt             ! Current time-step
-      !
-      INTEGER :: inum                  ! File unit number
-      INTEGER :: it
-      CHARACTER (LEN=50) :: cl_asmtrj
-      REAL(wp) :: zdate            ! Date
-      !!-----------------------------------------------------------------------
-
-      !------------------------------------------------------------------------
-      ! Write a single file for each trajectory time step
-      !------------------------------------------------------------------------
-      IF( ( MOD( kt - nit000 + 1, nittrjfrq ) == 0 ) .OR. ( kt == nitend ) ) THEN
-         
-         IF( kt == nit000 - 1 ) THEN         ! Treat special case when kt = nit000-1
-            !
-#if defined key_zdftke
-            IF(lwp) WRITE(numout,*) ' Computing  zdf_tke coeff. form restart...'
-            ! Compute the vertical eddy viscosity and diffusivity coefficients
-            CALL zdf_tke( nit000 )
-#endif
-#if defined key_zdfddm
-            IF(lwp) WRITE(numout,*) ' Computing zdf_ddm coeff. from restart...'
-            ! Compute the vertical eddy viscosity and diffusivity coefficients (salt effect)
-            CALL zdf_ddm( nit000 )
-#endif
-            IF(lwp) WRITE(numout,*) ' Computing zdf_mxl coeff. from restart...'
-            ! Compute the turbocline depth and the mixed layer depth
-            CALL zdf_mxl( nit000 ) 
-#if defined key_ldfslp
-            IF(lwp) WRITE(numout,*) ' Compute the slopes of neutral surface...'
-            CALL bn2( tsb, rn2 ) 
-            CALL ldf_slp( nit000, rhd, rn2 )
-#endif
-#if defined key_traldf_c2d
-            IF(lwp) WRITE(numout,*) ' Computing ldf_eiv coeff. from restart...'
-            ! Compute eddy induced velocity coefficient
-            IF( lk_traldf_eiv )   CALL ldf_eiv( nit000 )
-#endif
-         ENDIF
-         !
-         it = kt - nit000 + 1
-         !
-         !                                   ! Define the output file        
-         WRITE(cl_asmtrj, FMT='(A,A,I5.5)' ) TRIM( c_asmtrj ), '_', it
-         cl_asmtrj = TRIM( cl_asmtrj )
-         CALL iom_open( cl_asmtrj, inum, ldwrt = .TRUE., kiolib = jprstlib)
-         !
-         !                                   ! Output trajectory fields
-         CALL iom_rstput( it, it, inum, 'emp'   , emp    )
-         CALL iom_rstput( it, it, inum, 'sfx'   , sfx    )
-         CALL iom_rstput( it, it, inum, 'un'    , un     )
-         CALL iom_rstput( it, it, inum, 'vn'    , vn     )
-         CALL iom_rstput( it, it, inum, 'tn'    , tsn(:,:,:,jp_tem) )
-         CALL iom_rstput( it, it, inum, 'sn'    , tsn(:,:,:,jp_sal) )
-         CALL iom_rstput( it, it, inum, 'avmu'  , avmu   )
-         CALL iom_rstput( it, it, inum, 'avmv'  , avmv   )
-         CALL iom_rstput( it, it, inum, 'avt'   , avt    )
-#if defined key_ldfslp
-         CALL iom_rstput( it, it, inum, 'uslp'  , uslp   )
-         CALL iom_rstput( it, it, inum, 'vslp'  , vslp   )
-         CALL iom_rstput( it, it, inum, 'wslpi' , wslpi  )
-         CALL iom_rstput( it, it, inum, 'wslpj' , wslpj  )
-#endif
-#if defined key_zdfddm
-         CALL iom_rstput( it, it, inum, 'avs'   , avs    )
-#endif
-         CALL iom_rstput( it, it, inum, 'ta'    , tsa(:,:,:,jp_tem) )
-         CALL iom_rstput( it, it, inum, 'sa'    , tsa(:,:,:,jp_sal) )
-         CALL iom_rstput( it, it, inum, 'tb'    , tsb(:,:,:,jp_tem) )
-         CALL iom_rstput( it, it, inum, 'sb'    , tsb(:,:,:,jp_sal) )
-         IF( ln_tradmp ) THEN
-            CALL iom_rstput( it, it, inum, 'strdmp', strdmp )
-            CALL iom_rstput( it, it, inum, 'hmlp'  , hmlp   )
-         END IF
-         CALL iom_rstput( it, it, inum, 'aeiu'  , aeiu   )
-         CALL iom_rstput( it, it, inum, 'aeiv'  , aeiv   )
-         CALL iom_rstput( it, it, inum, 'aeiw'  , aeiw   )
-         !
-         CALL iom_close( inum )
-      ENDIF
-      !
-   END SUBROUTINE asm_trj_wri
-
-   !!======================================================================
-END MODULE asmtrj
Index: branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/OPA_SRC/DIA/diahth.F90
===================================================================
--- branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/OPA_SRC/DIA/diahth.F90	(revision 3759)
+++ branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/OPA_SRC/DIA/diahth.F90	(revision 3764)
@@ -313,5 +313,5 @@
       ! surface boundary condition
       IF( lk_vvl ) THEN   ;   zthick(:,:) = 0._wp       ;   htc3(:,:) = 0._wp                                   
-      ELSE                ;   zthick(:,:) = sshn(:,:)   ;   htc3(:,:) = tsn(:,:,jk,jp_tem) * sshn(:,:) * tmask(:,:,jk)   
+      ELSE                ;   zthick(:,:) = sshn(:,:)   ;   htc3(:,:) = tsn(:,:,1,jp_tem) * sshn(:,:) * tmask(:,:,1)   
       ENDIF
       ! integration down to ilevel
Index: branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/OPA_SRC/DIA/diaptr.F90
===================================================================
--- branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/OPA_SRC/DIA/diaptr.F90	(revision 3759)
+++ branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/OPA_SRC/DIA/diaptr.F90	(revision 3764)
@@ -455,5 +455,4 @@
       NAMELIST/namptr/ ln_diaptr, ln_diaznl, ln_subbas, ln_ptrcomp, nn_fptr, nn_fwri
       !!----------------------------------------------------------------------
-      IF( nn_timing == 1 )   CALL timing_start('dia_ptr_init')
 
       REWIND( numnam )                 ! Read Namelist namptr : poleward transport parameters
@@ -474,4 +473,6 @@
       
       IF( ln_diaptr) THEN  
+     
+         IF( nn_timing == 1 )   CALL timing_start('dia_ptr_init')
       
          IF( ln_subbas ) THEN   ;   nptr = 5       ! Global, Atlantic, Pacific, Indian, Indo-Pacific
@@ -528,7 +529,7 @@
          nidom_ptr = FLIO_DOM_NONE
 #endif
+      IF( nn_timing == 1 )   CALL timing_stop('dia_ptr_init')
+      !
       ENDIF 
-      ! 
-      IF( nn_timing == 1 )   CALL timing_stop('dia_ptr_init')
       ! 
    END SUBROUTINE dia_ptr_init
Index: branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/OPA_SRC/DIA/diawri_dimg.h90
===================================================================
--- branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/OPA_SRC/DIA/diawri_dimg.h90	(revision 3759)
+++ branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/OPA_SRC/DIA/diawri_dimg.h90	(revision 3764)
@@ -165,6 +165,8 @@
        fsel(:,:,6 ) = fsel(:,:,6 ) + sshn(:,:) 
        fsel(:,:,7 ) = fsel(:,:,7 ) + qsr(:,:)
-       fsel(:,:,8 ) = fsel(:,:,8 ) + qrp (:,:)
-       fsel(:,:,9 ) = fsel(:,:,9 ) + erp (:,:)
+       IF( ln_ssr ) THEN
+          IF( nn_sstr /= 0 )   fsel(:,:,8 ) = fsel(:,:,8 ) + qrp (:,:)
+          IF( nn_sssr /= 0 )   fsel(:,:,9 ) = fsel(:,:,9 ) + erp (:,:)
+       ENDIF
        fsel(:,:,10) = fsel(:,:,10) + hmld(:,:)
        fsel(:,:,11) = fsel(:,:,11) + hmlp(:,:)
@@ -234,6 +236,8 @@
           fsel(:,:,6 ) = sshn(:,:)
           fsel(:,:,7 ) = qsr (:,:) * tmask(:,:,1)
-          fsel(:,:,8 ) = qrp (:,:) * tmask(:,:,1)
-          fsel(:,:,9 ) = erp (:,:) * tmask(:,:,1)
+          IF( ln_ssr ) THEN
+             IF( nn_sstr /= 0 )   fsel(:,:,8 ) = qrp (:,:) * tmask(:,:,1)
+             IF( nn_sssr /= 0 )   fsel(:,:,9 ) = erp (:,:) * tmask(:,:,1)
+          ENDIF
           fsel(:,:,10) = hmld(:,:) * tmask(:,:,1)
           fsel(:,:,11) = hmlp(:,:) * tmask(:,:,1)
Index: branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/OPA_SRC/DOM/daymod.F90
===================================================================
--- branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/OPA_SRC/DOM/daymod.F90	(revision 3759)
+++ branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/OPA_SRC/DOM/daymod.F90	(revision 3764)
@@ -2,18 +2,18 @@
    !!======================================================================
    !!                       ***  MODULE  daymod  ***
-   !! Ocean        :  calendar 
+   !! Ocean        :  calendar
    !!=====================================================================
    !! History :  OPA  ! 1994-09  (M. Pontaud M. Imbard)  Original code
    !!                 ! 1997-03  (O. Marti)
-   !!                 ! 1997-05  (G. Madec) 
+   !!                 ! 1997-05  (G. Madec)
    !!                 ! 1997-08  (M. Imbard)
    !!   NEMO     1.0  ! 2003-09  (G. Madec)  F90 + nyear, nmonth, nday
    !!                 ! 2004-01  (A.M. Treguier) new calculation based on adatrj
    !!                 ! 2006-08  (G. Madec)  surface module major update
-   !!----------------------------------------------------------------------      
+   !!----------------------------------------------------------------------
 
    !!----------------------------------------------------------------------
    !!   day        : calendar
-   !!  
+   !!
    !!           -------------------------------
    !!           ----------- WARNING -----------
@@ -24,10 +24,10 @@
    !!           ----------- WARNING -----------
    !!           -------------------------------
-   !!  
+   !!
    !!----------------------------------------------------------------------
    USE dom_oce         ! ocean space and time domain
    USE phycst          ! physical constants
    USE in_out_manager  ! I/O manager
-   USE iom             ! 
+   USE iom             !
    USE ioipsl, ONLY :   ymds2ju   ! for calendar
    USE prtctl          ! Print control
@@ -41,6 +41,7 @@
    PUBLIC   day        ! called by step.F90
    PUBLIC   day_init   ! called by istate.F90
-
-   INTEGER ::   nsecd, nsecd05, ndt, ndt05
+   PUBLIC   day_mth    ! Needed by TAM
+
+   INTEGER, PUBLIC ::   nsecd, nsecd05, ndt, ndt05 ! (PUBLIC for TAM)
 
    !!----------------------------------------------------------------------
@@ -54,6 +55,6 @@
       !!----------------------------------------------------------------------
       !!                   ***  ROUTINE day_init  ***
-      !! 
-      !! ** Purpose :   Initialization of the calendar values to their values 1 time step before nit000 
+      !!
+      !! ** Purpose :   Initialization of the calendar values to their values 1 time step before nit000
       !!                because day will be called at the beginning of step
       !!
@@ -81,5 +82,5 @@
       ndt05   = NINT(0.5 * rdttra(1))
 
-      IF( .NOT. lk_offline ) CALL day_rst( nit000, 'READ' ) 
+      IF( .NOT. lk_offline ) CALL day_rst( nit000, 'READ' )
 
       ! set the calandar from ndastp (read in restart file and namelist)
@@ -87,5 +88,5 @@
       nyear   =   ndastp / 10000
       nmonth  = ( ndastp - (nyear * 10000) ) / 100
-      nday    =   ndastp - (nyear * 10000) - ( nmonth * 100 ) 
+      nday    =   ndastp - (nyear * 10000) - ( nmonth * 100 )
 
       CALL ymds2ju( nyear, nmonth, nday, 0.0, fjulday )  ! we assume that we start run at 00:00
@@ -95,7 +96,7 @@
       nsec1jan000 = 0
       CALL day_mth
-      
+
       IF ( nday == 0 ) THEN     !   for ex if ndastp = ndate0 - 1
-         nmonth = nmonth - 1  
+         nmonth = nmonth - 1
          nday = nmonth_len(nmonth)
       ENDIF
@@ -106,12 +107,12 @@
          IF( nleapy == 1 )   CALL day_mth
       ENDIF
-      
+
       ! day since january 1st
       nday_year = nday + SUM( nmonth_len(1:nmonth - 1) )
 
-      !compute number of days between last monday and today      
+      !compute number of days between last monday and today
       CALL ymds2ju( 1900, 01, 01, 0.0, zjul )  ! compute julian day value of 01.01.1900 (our reference that was a Monday)
-      inbday = NINT(fjulday - zjul)            ! compute nb day between  01.01.1900 and current day  
-      idweek = MOD(inbday, 7)                  ! compute nb day between last monday and current day  
+      inbday = NINT(fjulday - zjul)            ! compute nb day between  01.01.1900 and current day
+      idweek = MOD(inbday, 7)                  ! compute nb day between last monday and current day
 
       ! number of seconds since the beginning of current year/month/week/day at the middle of the time-step
@@ -135,5 +136,5 @@
       !!----------------------------------------------------------------------
       !!                   ***  ROUTINE day_init  ***
-      !! 
+      !!
       !! ** Purpose :   calendar values related to the months
       !!
@@ -147,5 +148,5 @@
 
       ! length of the month of the current year (from nleapy, read in namelist)
-      IF ( nleapy < 2 ) THEN 
+      IF ( nleapy < 2 ) THEN
          nmonth_len(:) = (/ 31, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 31 /)
          nyear_len(:) = 365
@@ -167,5 +168,5 @@
       ! time since Jan 1st   0     1     2    ...    11    12    13
       !          ---------*--|--*--|--*--| ... |--*--|--*--|--*--|--------------------------------------
-      !                 <---> <---> <--->  ...  <---> <---> <--->        
+      !                 <---> <---> <--->  ...  <---> <---> <--->
       ! month number      0     1     2    ...    11    12    13
       !
@@ -180,6 +181,6 @@
          nmonth_end(jm) = nmonth_end(jm-1) + nsecd * nmonth_len(jm)
       END DO
-      !           
-   END SUBROUTINE 
+      !
+   END SUBROUTINE
 
 
@@ -187,5 +188,5 @@
       !!----------------------------------------------------------------------
       !!                      ***  ROUTINE day  ***
-      !! 
+      !!
       !! ** Purpose :   Compute the date with a day iteration IF necessary.
       !!
@@ -199,5 +200,5 @@
       !!              - adatrj    : date in days since the beginning of the run
       !!              - nsec_year : current time of the year (in second since 00h, jan 1st)
-      !!----------------------------------------------------------------------      
+      !!----------------------------------------------------------------------
       INTEGER, INTENT(in) ::   kt        ! ocean time-step indices
       !
@@ -210,13 +211,13 @@
       zprec = 0.1 / rday
       !                                                 ! New time-step
-      nsec_year  = nsec_year  + ndt 
-      nsec_month = nsec_month + ndt                 
+      nsec_year  = nsec_year  + ndt
+      nsec_month = nsec_month + ndt
       nsec_week  = nsec_week  + ndt
-      nsec_day   = nsec_day   + ndt                
+      nsec_day   = nsec_day   + ndt
       adatrj  = adatrj  + rdttra(1) / rday
       fjulday = fjulday + rdttra(1) / rday
       IF( ABS(fjulday - REAL(NINT(fjulday),wp)) < zprec )   fjulday = REAL(NINT(fjulday),wp)   ! avoid truncation error
       IF( ABS(adatrj  - REAL(NINT(adatrj ),wp)) < zprec )   adatrj  = REAL(NINT(adatrj ),wp)   ! avoid truncation error
-      
+
       IF( nsec_day > nsecd ) THEN                       ! New day
          !
@@ -251,5 +252,5 @@
 
       IF( nsec_week > 7*nsecd )   nsec_week = ndt05     ! New week
-      
+
       IF(ln_ctl) THEN
          WRITE(charout,FMT="('kt =', I4,'  d/m/y =',I2,I2,I4)") kt, nday, nmonth, nyear
@@ -268,14 +269,14 @@
       !!---------------------------------------------------------------------
       !!                   ***  ROUTINE ts_rst  ***
-      !! 
+      !!
       !!  ** Purpose : Read or write calendar in restart file:
-      !! 
+      !!
       !!  WRITE(READ) mode:
-      !!       kt        : number of time step since the begining of the experiment at the 
+      !!       kt        : number of time step since the begining of the experiment at the
       !!                   end of the current(previous) run
-      !!       adatrj(0) : number of elapsed days since the begining of the experiment at the 
+      !!       adatrj(0) : number of elapsed days since the begining of the experiment at the
       !!                   end of the current(previous) run (REAL -> keep fractions of day)
       !!       ndastp    : date at the end of the current(previous) run (coded as yyyymmdd integer)
-      !! 
+      !!
       !!   According to namelist parameter nrstdt,
       !!       nrstdt = 0  no control on the date (nit000 is  arbitrary).
@@ -295,5 +296,5 @@
       REAL(wp) ::   zkt, zndastp
       !!----------------------------------------------------------------------
-      
+
       IF( TRIM(cdrw) == 'READ' ) THEN
 
@@ -312,24 +313,24 @@
                WRITE(numout,*)
             ENDIF
-            ! Control of date 
-            IF( nit000 - NINT( zkt ) /= 1 .AND. nrstdt /= 0 )                                         & 
-                 &   CALL ctl_stop( ' ===>>>> : problem with nit000 for the restart',                 & 
+            ! Control of date
+            IF( nit000 - NINT( zkt ) /= 1 .AND. nrstdt /= 0 )                                         &
+                 &   CALL ctl_stop( ' ===>>>> : problem with nit000 for the restart',                 &
                  &                  ' verify the restart file or rerun with nrstdt = 0 (namelist)' )
             ! define ndastp and adatrj
-            IF ( nrstdt == 2 ) THEN 
+            IF ( nrstdt == 2 ) THEN
                ! read the parameters correspondting to nit000 - 1 (last time step of previous run)
                CALL iom_get( numror, 'ndastp', zndastp )
                ndastp = NINT( zndastp )
                CALL iom_get( numror, 'adatrj', adatrj  )
-            ELSE 
+            ELSE
                ! parameters correspondting to nit000 - 1 (as we start the step loop with a call to day)
                ndastp = ndate0 - 1     ! ndate0 read in the namelist in dom_nam, we assume that we start run at 00:00
-               adatrj = ( REAL( nit000-1, wp ) * rdttra(1) ) / rday 
-               ! note this is wrong if time step has changed during run 
+               adatrj = ( REAL( nit000-1, wp ) * rdttra(1) ) / rday
+               ! note this is wrong if time step has changed during run
             ENDIF
          ELSE
             ! parameters correspondting to nit000 - 1 (as we start the step loop with a call to day)
             ndastp = ndate0 - 1        ! ndate0 read in the namelist in dom_nam, we assume that we start run at 00:00
-            adatrj = ( REAL( nit000-1, wp ) * rdttra(1) ) / rday 
+            adatrj = ( REAL( nit000-1, wp ) * rdttra(1) ) / rday
          ENDIF
          IF( ABS(adatrj  - REAL(NINT(adatrj),wp)) < 0.1 / rday )   adatrj = REAL(NINT(adatrj),wp)   ! avoid truncation error
@@ -347,8 +348,8 @@
             IF(lwp) WRITE(numout,*)
             IF(lwp) WRITE(numout,*) 'rst_write : write oce restart file  kt =', kt
-            IF(lwp) WRITE(numout,*) '~~~~~~~'         
+            IF(lwp) WRITE(numout,*) '~~~~~~~'
          ENDIF
          ! calendar control
-         CALL iom_rstput( kt, nitrst, numrow, 'kt'     , REAL( kt    , wp) )   ! time-step 
+         CALL iom_rstput( kt, nitrst, numrow, 'kt'     , REAL( kt    , wp) )   ! time-step
          CALL iom_rstput( kt, nitrst, numrow, 'ndastp' , REAL( ndastp, wp) )   ! date
          CALL iom_rstput( kt, nitrst, numrow, 'adatrj' , adatrj            )   ! number of elapsed days since
Index: branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/OPA_SRC/DOM/domain.F90
===================================================================
--- branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/OPA_SRC/DOM/domain.F90	(revision 3759)
+++ branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/OPA_SRC/DOM/domain.F90	(revision 3764)
@@ -68,9 +68,9 @@
       !!              - 1D configuration, move Coriolis, u and v at T-point
       !!----------------------------------------------------------------------
-      INTEGER ::   jk                ! dummy loop argument
-      INTEGER ::   iconf = 0         ! temporary integers
-      !!----------------------------------------------------------------------
-      !
-      IF( nn_timing == 1 )  CALL timing_start('dom_init')
+      INTEGER ::   jk          ! dummy loop argument
+      INTEGER ::   iconf = 0   ! local integers
+      !!----------------------------------------------------------------------
+      !
+      IF( nn_timing == 1 )   CALL timing_start('dom_init')
       !
       IF(lwp) THEN
@@ -88,12 +88,8 @@
       IF( lk_vvl         )   CALL dom_vvl      ! Vertical variable mesh
       !
-      IF( lk_c1d ) THEN                        ! 1D configuration 
-         CALL cor_c1d                          ! Coriolis set at T-point
-         umask(:,:,:) = tmask(:,:,:)           ! U, V moved at T-point
-         vmask(:,:,:) = tmask(:,:,:)
-      END IF
-      !
-      hu(:,:) = 0.e0                           ! Ocean depth at U- and V-points
-      hv(:,:) = 0.e0
+      IF( lk_c1d         )   CALL cor_c1d      ! 1D configuration: Coriolis set at T-point
+      !
+      hu(:,:) = 0._wp                          ! Ocean depth at U- and V-points
+      hv(:,:) = 0._wp
       DO jk = 1, jpk
          hu(:,:) = hu(:,:) + fse3u(:,:,jk) * umask(:,:,jk)
@@ -101,6 +97,6 @@
       END DO
       !                                        ! Inverse of the local depth
-      hur(:,:) = 1. / ( hu(:,:) + 1.e0 - umask(:,:,1) ) * umask(:,:,1)
-      hvr(:,:) = 1. / ( hv(:,:) + 1.e0 - vmask(:,:,1) ) * vmask(:,:,1)
+      hur(:,:) = 1._wp / ( hu(:,:) + 1._wp - umask(:,:,1) ) * umask(:,:,1)
+      hvr(:,:) = 1._wp / ( hv(:,:) + 1._wp - vmask(:,:,1) ) * vmask(:,:,1)
 
                              CALL dom_stp      ! time step
@@ -108,5 +104,5 @@
       IF( .NOT.ln_rstart )   CALL dom_ctl      ! Domain control
       !
-      IF( nn_timing == 1 )  CALL timing_stop('dom_init')
+      IF( nn_timing == 1 )   CALL timing_stop('dom_init')
       !
    END SUBROUTINE dom_init
@@ -294,19 +290,19 @@
          CALL mpp_maxloc( e2t(:,:), tmask(:,:,1), ze2max, iima2,ijma2 )
       ELSE
-         ze1min = MINVAL( e1t(:,:), mask = tmask(:,:,1) == 1.e0 )    
-         ze2min = MINVAL( e2t(:,:), mask = tmask(:,:,1) == 1.e0 )    
-         ze1max = MAXVAL( e1t(:,:), mask = tmask(:,:,1) == 1.e0 )    
-         ze2max = MAXVAL( e2t(:,:), mask = tmask(:,:,1) == 1.e0 )    
-
-         iloc  = MINLOC( e1t(:,:), mask = tmask(:,:,1) == 1.e0 )
+         ze1min = MINVAL( e1t(:,:), mask = tmask(:,:,1) == 1._wp )    
+         ze2min = MINVAL( e2t(:,:), mask = tmask(:,:,1) == 1._wp )    
+         ze1max = MAXVAL( e1t(:,:), mask = tmask(:,:,1) == 1._wp )    
+         ze2max = MAXVAL( e2t(:,:), mask = tmask(:,:,1) == 1._wp )    
+
+         iloc  = MINLOC( e1t(:,:), mask = tmask(:,:,1) == 1._wp )
          iimi1 = iloc(1) + nimpp - 1
          ijmi1 = iloc(2) + njmpp - 1
-         iloc  = MINLOC( e2t(:,:), mask = tmask(:,:,1) == 1.e0 )
+         iloc  = MINLOC( e2t(:,:), mask = tmask(:,:,1) == 1._wp )
          iimi2 = iloc(1) + nimpp - 1
          ijmi2 = iloc(2) + njmpp - 1
-         iloc  = MAXLOC( e1t(:,:), mask = tmask(:,:,1) == 1.e0 )
+         iloc  = MAXLOC( e1t(:,:), mask = tmask(:,:,1) == 1._wp )
          iima1 = iloc(1) + nimpp - 1
          ijma1 = iloc(2) + njmpp - 1
-         iloc  = MAXLOC( e2t(:,:), mask = tmask(:,:,1) == 1.e0 )
+         iloc  = MAXLOC( e2t(:,:), mask = tmask(:,:,1) == 1._wp )
          iima2 = iloc(1) + nimpp - 1
          ijma2 = iloc(2) + njmpp - 1
Index: branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/OPA_SRC/DOM/domzgr.F90
===================================================================
--- branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/OPA_SRC/DOM/domzgr.F90	(revision 3759)
+++ branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/OPA_SRC/DOM/domzgr.F90	(revision 3764)
@@ -16,4 +16,5 @@
    !!            3.3  ! 2010-11  (G. Madec) add mbk. arrays associated to the deepest ocean level
    !!            3.4  ! 2012-08  (J. Siddorn) added Siddorn and Furner stretching function
+   !!            3.4  ! 2012-12  (R. Bourdalle-Badie and G. Reffray)  modify C1D case  
    !!----------------------------------------------------------------------
 
@@ -40,6 +41,6 @@
    USE lbclnk            ! ocean lateral boundary conditions (or mpp link)
    USE lib_mpp           ! distributed memory computing library
-   USE wrk_nemo        ! Memory allocation
-   USE timing          ! Timing
+   USE wrk_nemo          ! Memory allocation
+   USE timing            ! Timing
 
    IMPLICIT NONE
@@ -84,6 +85,6 @@
       !!                ***  ROUTINE dom_zgr  ***
       !!                   
-      !! ** Purpose :  set the depth of model levels and the resulting 
-      !!      vertical scale factors.
+      !! ** Purpose :   set the depth of model levels and the resulting 
+      !!              vertical scale factors.
       !!
       !! ** Method  : - reference 1D vertical coordinate (gdep._0, e3._0)
@@ -97,10 +98,10 @@
       !! ** Action  :   define gdep., e3., mbathy and bathy
       !!----------------------------------------------------------------------
-      INTEGER ::   ioptio = 0   ! temporary integer
+      INTEGER ::   ioptio, ibat   ! local integer
       !
       NAMELIST/namzgr/ ln_zco, ln_zps, ln_sco
       !!----------------------------------------------------------------------
       !
-      IF( nn_timing == 1 )  CALL timing_start('dom_zgr')
+      IF( nn_timing == 1 )   CALL timing_start('dom_zgr')
       !
       REWIND( numnam )                 ! Read Namelist namzgr : vertical coordinate'
@@ -118,7 +119,7 @@
 
       ioptio = 0                       ! Check Vertical coordinate options
-      IF( ln_zco ) ioptio = ioptio + 1
-      IF( ln_zps ) ioptio = ioptio + 1
-      IF( ln_sco ) ioptio = ioptio + 1
+      IF( ln_zco      )   ioptio = ioptio + 1
+      IF( ln_zps      )   ioptio = ioptio + 1
+      IF( ln_sco      )   ioptio = ioptio + 1
       IF( ioptio /= 1 )   CALL ctl_stop( ' none or several vertical coordinate options used' )
       !
@@ -127,4 +128,5 @@
                           CALL zgr_z            ! Reference z-coordinate system (always called)
                           CALL zgr_bat          ! Bathymetry fields (levels and meters)
+      IF( lk_c1d      )   CALL lbc_lnk( bathy , 'T', 1._wp )   ! 1D config.: same bathy value over the 3x3 domain
       IF( ln_zco      )   CALL zgr_zco          ! z-coordinate
       IF( ln_zps      )   CALL zgr_zps          ! Partial step z-coordinate
@@ -134,9 +136,12 @@
       ! -----------------------------------
       IF( lzoom       )   CALL zgr_bat_zoom     ! correct mbathy in case of zoom subdomain
-      IF( .NOT.lk_c1d )   CALL zgr_bat_ctl      ! check bathymetry (mbathy) and suppress isoated ocean points
+      IF( .NOT.lk_c1d )   CALL zgr_bat_ctl      ! check bathymetry (mbathy) and suppress isolated ocean points
                           CALL zgr_bot_level    ! deepest ocean level for t-, u- and v-points
       !
-      !
-
+      IF( lk_c1d ) THEN                         ! 1D config.: same mbathy value over the 3x3 domain
+         ibat = mbathy(2,2)
+         mbathy(:,:) = ibat
+      END IF
+      !
       IF( nprint == 1 .AND. lwp )   THEN
          WRITE(numout,*) ' MIN val mbathy ', MINVAL( mbathy(:,:) ), ' MAX ', MAXVAL( mbathy(:,:) )
@@ -478,5 +483,5 @@
                     END DO
                  END DO
-                 IF(lwp) WRITE(numout,*)
+                 IF(lwp) WRITE(numout,*)     
                  IF(lwp) WRITE(numout,*) '      orca_r2: Gibraltar strait open at i=',ii0,' j=',ij0
                  !
@@ -742,4 +747,5 @@
       !
       mbkt(:,:) = MAX( mbathy(:,:) , 1 )    ! bottom k-index of T-level (=1 over land)
+ 
       !                                     ! bottom k-index of W-level = mbkt+1
       DO jj = 1, jpjm1                      ! bottom k-index of u- (v-) level
@@ -1220,5 +1226,5 @@
          END DO
          !
-         ! Apply lateral boundary condition   CAUTION: kept the value when the lbc field is zero
+         ! 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
@@ -1231,5 +1237,14 @@
       !                                                     ! ================ !
       !
-      !                                        ! envelop bathymetry saved in hbatt
+      ! 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
Index: branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/OPA_SRC/DOM/istate.F90
===================================================================
--- branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/OPA_SRC/DOM/istate.F90	(revision 3759)
+++ branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/OPA_SRC/DOM/istate.F90	(revision 3764)
@@ -41,4 +41,5 @@
    USE dynspg_exp      ! pressure gradient schemes
    USE dynspg_ts       ! pressure gradient schemes
+   USE sol_oce         ! ocean solver variables
    USE lib_mpp         ! MPP library
    USE restart         ! restart
@@ -106,7 +107,4 @@
          hdivb(:,:,:) = 0._wp   ;   hdivn(:,:,:) = 0._wp
          !
-         !                                       ! define e3u_b, e3v_b from e3t_b initialized in domzgr
-         CALL dom_vvl_2( nit000, fse3u_b(:,:,:), fse3v_b(:,:,:) )
-         !
          IF( cp_cfg == 'eel' ) THEN
             CALL istate_eel                      ! EEL   configuration : start from pre-defined U,V T-S fields
@@ -133,4 +131,6 @@
             ENDDO
          ENDIF
+         !                                       ! define e3u_b, e3v_b from e3t_b initialized in domzgr
+         CALL dom_vvl_2( nit000, fse3u_b(:,:,:), fse3v_b(:,:,:) )
          ! 
       ENDIF
@@ -138,7 +138,10 @@
       IF( lk_agrif ) THEN                  ! read free surface arrays in restart file
          IF( ln_rstart ) THEN
-            IF( lk_dynspg_flt )   CALL flt_rst( nit000, 'READ' )      ! read or initialize the following fields
-            !                                                         ! gcx, gcxb for agrif_opa_init
-         ENDIF                                                        ! explicit case not coded yet with AGRIF
+            IF( lk_dynspg_flt )  THEN      ! read or initialize the following fields
+               !                           ! gcx, gcxb for agrif_opa_init
+               IF( sol_oce_alloc()  > 0 )   CALL ctl_stop('agrif sol_oce_alloc: allocation of arrays failed')
+               CALL flt_rst( nit000, 'READ' )
+            ENDIF
+         ENDIF                             ! explicit case not coded yet with AGRIF
       ENDIF
       !
Index: branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/OPA_SRC/DYN/dynhpg.F90
===================================================================
--- branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/OPA_SRC/DYN/dynhpg.F90	(revision 3759)
+++ branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/OPA_SRC/DYN/dynhpg.F90	(revision 3764)
@@ -11,5 +11,5 @@
    !!            8.5  !  2002-08  (A. Bozec)  hpg_zps: Original code
    !!   NEMO     1.0  !  2005-10  (A. Beckmann, B.W. An)  various s-coordinate options
-   !!                 !         Original code for hpg_ctl, hpg_hel hpg_wdj, hpg_djc, hpg_rot 
+   !!                 !         Original code for hpg_ctl, hpg_hel hpg_wdj, hpg_djc, hpg_rot
    !!             -   !  2005-11  (G. Madec) style & small optimisation
    !!            3.3  !  2010-10  (C. Ethe, G. Madec) reorganisation of initialisation phase
@@ -31,9 +31,9 @@
    USE dom_oce         ! ocean space and time domain
    USE phycst          ! physical constants
-   USE trdmod          ! ocean dynamics trends 
+   USE trdmod          ! ocean dynamics trends
    USE trdmod_oce      ! ocean variables trends
    USE in_out_manager  ! I/O manager
    USE prtctl          ! Print control
-   USE lbclnk          ! lateral boundary condition 
+   USE lbclnk          ! lateral boundary condition
    USE lib_mpp         ! MPP library
    USE wrk_nemo        ! Memory Allocation
@@ -46,5 +46,5 @@
    PUBLIC   dyn_hpg_init   ! routine called by opa module
 
-   !                                              !!* Namelist namdyn_hpg : hydrostatic pressure gradient 
+   !                                              !!* Namelist namdyn_hpg : hydrostatic pressure gradient
    LOGICAL , PUBLIC ::   ln_hpg_zco    = .TRUE.    !: z-coordinate - full steps
    LOGICAL , PUBLIC ::   ln_hpg_zps    = .FALSE.   !: z-coordinate - partial steps (interpolation)
@@ -54,5 +54,5 @@
    LOGICAL , PUBLIC ::   ln_dynhpg_imp = .FALSE.   !: semi-implicite hpg flag
 
-   INTEGER  ::   nhpg  =  0   ! = 0 to 7, type of pressure gradient scheme used ! (deduced from ln_hpg_... flags)
+   INTEGER , PUBLIC ::   nhpg  =  0   ! = 0 to 7, type of pressure gradient scheme used ! (deduced from ln_hpg_... flags) (PUBLIC for TAM)
 
    !! * Substitutions
@@ -70,7 +70,7 @@
       !!                  ***  ROUTINE dyn_hpg  ***
       !!
-      !! ** Method  :   Call the hydrostatic pressure gradient routine 
+      !! ** Method  :   Call the hydrostatic pressure gradient routine
       !!              using the scheme defined in the namelist
-      !!   
+      !!
       !! ** Action : - Update (ua,va) with the now hydrastatic pressure trend
       !!             - Save the trend (l_trddyn=T)
@@ -84,7 +84,7 @@
       IF( l_trddyn ) THEN                    ! Temporary saving of ua and va trends (l_trddyn)
          CALL wrk_alloc( jpi,jpj,jpk, ztrdu, ztrdv )
-         ztrdu(:,:,:) = ua(:,:,:)  
-         ztrdv(:,:,:) = va(:,:,:) 
-      ENDIF      
+         ztrdu(:,:,:) = ua(:,:,:)
+         ztrdv(:,:,:) = va(:,:,:)
+      ENDIF
       !
       SELECT CASE ( nhpg )      ! Hydrostatic pressure gradient computation
@@ -101,5 +101,5 @@
          CALL trd_mod( ztrdu, ztrdv, jpdyn_trd_hpg, 'DYN', kt )
          CALL wrk_dealloc( jpi,jpj,jpk, ztrdu, ztrdv )
-      ENDIF          
+      ENDIF
       !
       IF(ln_ctl)   CALL prt_ctl( tab3d_1=ua, clinfo1=' hpg  - Ua: ', mask1=umask,   &
@@ -161,5 +161,5 @@
       !
       !                               ! Consistency check
-      ioptio = 0 
+      ioptio = 0
       IF( ln_hpg_zco )   ioptio = ioptio + 1
       IF( ln_hpg_zps )   ioptio = ioptio + 1
@@ -185,5 +185,5 @@
       !!            ua = ua - 1/e1u * zhpi
       !!            va = va - 1/e2v * zhpj
-      !! 
+      !!
       !! ** Action : - Update (ua,va) with the now hydrastatic pressure trend
       !!----------------------------------------------------------------------
@@ -192,7 +192,7 @@
       INTEGER  ::   ji, jj, jk       ! dummy loop indices
       REAL(wp) ::   zcoef0, zcoef1   ! temporary scalars
-      REAL(wp), POINTER, DIMENSION(:,:,:) ::  zhpi, zhpj 
-      !!----------------------------------------------------------------------
-      !  
+      REAL(wp), POINTER, DIMENSION(:,:,:) ::  zhpi, zhpj
+      !!----------------------------------------------------------------------
+      !
       CALL wrk_alloc( jpi,jpj,jpk, zhpi, zhpj )
       !
@@ -202,6 +202,6 @@
          IF(lwp) WRITE(numout,*) '~~~~~~~~~~~   z-coordinate case '
       ENDIF
-      
-      zcoef0 = - grav * 0.5_wp      ! Local constant initialization 
+
+      zcoef0 = - grav * 0.5_wp      ! Local constant initialization
 
       ! Surface value
@@ -247,9 +247,9 @@
       !!---------------------------------------------------------------------
       !!                 ***  ROUTINE hpg_zps  ***
-      !!                    
+      !!
       !! ** Method  :   z-coordinate plus partial steps case.  blahblah...
-      !! 
+      !!
       !! ** Action  : - Update (ua,va) with the now hydrastatic pressure trend
-      !!---------------------------------------------------------------------- 
+      !!----------------------------------------------------------------------
       INTEGER, INTENT(in) ::   kt    ! ocean time-step index
       !!
@@ -257,5 +257,5 @@
       INTEGER  ::   iku, ikv                         ! temporary integers
       REAL(wp) ::   zcoef0, zcoef1, zcoef2, zcoef3   ! temporary scalars
-      REAL(wp), POINTER, DIMENSION(:,:,:) ::  zhpi, zhpj 
+      REAL(wp), POINTER, DIMENSION(:,:,:) ::  zhpi, zhpj
       !!----------------------------------------------------------------------
       !
@@ -363,5 +363,5 @@
       INTEGER  ::   ji, jj, jk                 ! dummy loop indices
       REAL(wp) ::   zcoef0, zuap, zvap, znad   ! temporary scalars
-      REAL(wp), POINTER, DIMENSION(:,:,:) ::  zhpi, zhpj 
+      REAL(wp), POINTER, DIMENSION(:,:,:) ::  zhpi, zhpj
       !!----------------------------------------------------------------------
       !
@@ -383,5 +383,5 @@
       ! Surface value
       DO jj = 2, jpjm1
-         DO ji = fs_2, fs_jpim1   ! vector opt.   
+         DO ji = fs_2, fs_jpim1   ! vector opt.
             ! hydrostatic pressure gradient along s-surfaces
             zhpi(ji,jj,1) = zcoef0 / e1u(ji,jj) * ( fse3w(ji+1,jj  ,1) * ( znad + rhd(ji+1,jj  ,1) )   &
@@ -397,14 +397,14 @@
             ua(ji,jj,1) = ua(ji,jj,1) + zhpi(ji,jj,1) + zuap
             va(ji,jj,1) = va(ji,jj,1) + zhpj(ji,jj,1) + zvap
-         END DO  
-      END DO   
-            
+         END DO
+      END DO
+
       ! interior value (2=<jk=<jpkm1)
-      DO jk = 2, jpkm1                                  
-         DO jj = 2, jpjm1     
-            DO ji = fs_2, fs_jpim1   ! vector opt.      
+      DO jk = 2, jpkm1
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
                ! hydrostatic pressure gradient along s-surfaces
-               zhpi(ji,jj,jk) = zhpi(ji,jj,jk-1) + zcoef0 / e1u(ji,jj)   & 
-                  &           * (  fse3w(ji+1,jj,jk) * ( rhd(ji+1,jj,jk) + rhd(ji+1,jj,jk-1) + 2*znad )   & 
+               zhpi(ji,jj,jk) = zhpi(ji,jj,jk-1) + zcoef0 / e1u(ji,jj)   &
+                  &           * (  fse3w(ji+1,jj,jk) * ( rhd(ji+1,jj,jk) + rhd(ji+1,jj,jk-1) + 2*znad )   &
                   &              - fse3w(ji  ,jj,jk) * ( rhd(ji  ,jj,jk) + rhd(ji  ,jj,jk-1) + 2*znad )  )
                zhpj(ji,jj,jk) = zhpj(ji,jj,jk-1) + zcoef0 / e2v(ji,jj)   &
@@ -432,5 +432,5 @@
       !!
       !! ** Method  :   Density Jacobian with Cubic polynomial scheme
-      !! 
+      !!
       !! Reference: Shchepetkin and McWilliams, J. Geophys. Res., 108(C3), 3090, 2003
       !!----------------------------------------------------------------------
@@ -441,5 +441,5 @@
       REAL(wp) ::   z1_10, cffu, cffx   !    "         "
       REAL(wp) ::   z1_12, cffv, cffy   !    "         "
-      REAL(wp), POINTER, DIMENSION(:,:,:) ::  zhpi, zhpj 
+      REAL(wp), POINTER, DIMENSION(:,:,:) ::  zhpi, zhpj
       REAL(wp), POINTER, DIMENSION(:,:,:) ::  dzx, dzy, dzz, dzu, dzv, dzw
       REAL(wp), POINTER, DIMENSION(:,:,:) ::  drhox, drhoy, drhoz, drhou, drhov, drhow
@@ -447,7 +447,7 @@
       !!----------------------------------------------------------------------
       !
-      CALL wrk_alloc( jpi, jpj, jpk, dzx  , dzy  , dzz  , dzu  , dzv  , dzw   ) 
-      CALL wrk_alloc( jpi, jpj, jpk, drhox, drhoy, drhoz, drhou, drhov, drhow ) 
-      CALL wrk_alloc( jpi, jpj, jpk, rho_i, rho_j, rho_k,  zhpi,  zhpj        ) 
+      CALL wrk_alloc( jpi, jpj, jpk, dzx  , dzy  , dzz  , dzu  , dzv  , dzw   )
+      CALL wrk_alloc( jpi, jpj, jpk, drhox, drhoy, drhoz, drhou, drhov, drhow )
+      CALL wrk_alloc( jpi, jpj, jpk, rho_i, rho_j, rho_k,  zhpi,  zhpj        )
       !
 
@@ -497,5 +497,5 @@
                cffu = 2._wp * drhox(ji+1,jj  ,jk) * drhox(ji,jj,jk  )
                cffx = 2._wp * dzx  (ji+1,jj  ,jk) * dzx  (ji,jj,jk  )
-  
+
                cffv = 2._wp * drhoy(ji  ,jj+1,jk) * drhoy(ji,jj,jk  )
                cffy = 2._wp * dzy  (ji  ,jj+1,jk) * dzy  (ji,jj,jk  )
@@ -568,5 +568,5 @@
                &                     + 0.5_wp * ( rhd(ji,jj,2) - rhd(ji,jj,1) )         &
                &                              * ( fse3w (ji,jj,1) - fsde3w(ji,jj,1) )   &
-               &                              / ( fsde3w(ji,jj,2) - fsde3w(ji,jj,1) )  ) 
+               &                              / ( fsde3w(ji,jj,2) - fsde3w(ji,jj,1) )  )
          END DO
       END DO
@@ -631,5 +631,5 @@
       ! ----------------
       DO jk = 2, jpkm1
-         DO jj = 2, jpjm1 
+         DO jj = 2, jpjm1
             DO ji = fs_2, fs_jpim1   ! vector opt.
                ! hydrostatic pressure gradient along s-surfaces
@@ -647,7 +647,7 @@
       END DO
       !
-      CALL wrk_dealloc( jpi, jpj, jpk, dzx  , dzy  , dzz  , dzu  , dzv  , dzw   ) 
-      CALL wrk_dealloc( jpi, jpj, jpk, drhox, drhoy, drhoz, drhou, drhov, drhow ) 
-      CALL wrk_dealloc( jpi, jpj, jpk, rho_i, rho_j, rho_k,  zhpi,  zhpj        ) 
+      CALL wrk_dealloc( jpi, jpj, jpk, dzx  , dzy  , dzz  , dzu  , dzv  , dzw   )
+      CALL wrk_dealloc( jpi, jpj, jpk, drhox, drhoy, drhoz, drhou, drhov, drhow )
+      CALL wrk_dealloc( jpi, jpj, jpk, rho_i, rho_j, rho_k,  zhpi,  zhpj        )
       !
    END SUBROUTINE hpg_djc
@@ -676,12 +676,12 @@
       INTEGER  :: jk1, jis, jid, jjs, jjd
       REAL(wp) :: zuijk, zvijk, zpwes, zpwed, zpnss, zpnsd, zdeps
-      REAL(wp) :: zrhdt1 
+      REAL(wp) :: zrhdt1
       REAL(wp) :: zdpdx1, zdpdx2, zdpdy1, zdpdy2
-      REAL(wp), POINTER, DIMENSION(:,:,:) ::   zdept, 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, zdept, zrhh ) 
+      CALL wrk_alloc( jpi,jpj,jpk, zhpi, zu, zv, fsp, xsp, asp, bsp, csp, dsp )
+      CALL wrk_alloc( jpi,jpj,jpk, zdept, zrhh )
       !
       IF( kt == nit000 ) THEN
@@ -693,5 +693,5 @@
       !!----------------------------------------------------------------------
       ! Local constant initialization
-      zcoef0 = - grav 
+      zcoef0 = - grav
       znad = 0.0_wp
       IF( lk_vvl ) znad = 1._wp
@@ -700,8 +700,8 @@
       zhpi(:,:,:) = 0._wp
       zrhh(:,:,:) = rhd(:,:,:)
-      
+
       ! Preparing vertical density profile "zrhh(:,:,:)" for hybrid-sco coordinate
       DO jj = 1, jpj
-        DO ji = 1, jpi   
+        DO ji = 1, jpi
           jk = mbathy(ji,jj)
           IF( jk <= 0 ) THEN; zrhh(ji,jj,:) = 0._wp
@@ -711,5 +711,5 @@
                 zrhh(ji,jj,jkk) = interp1(fsde3w(ji,jj,jkk),   fsde3w(ji,jj,jkk-1), &
                                          fsde3w(ji,jj,jkk-2), rhd(ji,jj,jkk-1), rhd(ji,jj,jkk-2))
-             END DO 
+             END DO
           ENDIF
         END DO
@@ -728,12 +728,12 @@
       xsp(:,:,:) = zdept(:,:,:)
 
-      ! Construct the vertical density profile with the 
+      ! Construct the vertical density profile with the
       ! constrained cubic spline interpolation
       ! rho(z) = asp + bsp*z + csp*z^2 + dsp*z^3
-      CALL cspline(fsp,xsp,asp,bsp,csp,dsp,polynomial_type)      
+      CALL cspline(fsp,xsp,asp,bsp,csp,dsp,polynomial_type)
 
       ! Integrate the hydrostatic pressure "zhpi(:,:,:)" at "T(ji,jj,1)"
       DO jj = 2, jpj
-        DO ji = 2, jpi 
+        DO ji = 2, jpi
           zrhdt1 = zrhh(ji,jj,1) - interp3(zdept(ji,jj,1),asp(ji,jj,1), &
                                          bsp(ji,jj,1),   csp(ji,jj,1), &
@@ -741,11 +741,11 @@
 
           ! assuming linear profile across the top half surface layer
-          zhpi(ji,jj,1) =  0.5_wp * fse3w(ji,jj,1) * zrhdt1  
+          zhpi(ji,jj,1) =  0.5_wp * fse3w(ji,jj,1) * zrhdt1
         END DO
       END DO
 
       ! Calculate the pressure "zhpi(:,:,:)" at "T(ji,jj,2:jpkm1)"
-      DO jk = 2, jpkm1                                  
-        DO jj = 2, jpj     
+      DO jk = 2, jpkm1
+        DO jj = 2, jpj
           DO ji = 2, jpi
             zhpi(ji,jj,jk) = zhpi(ji,jj,jk-1) +                          &
@@ -758,6 +758,6 @@
 
       ! Z coordinate of U(ji,jj,1:jpkm1) and V(ji,jj,1:jpkm1)
-      DO jj = 2, jpjm1     
-        DO ji = 2, jpim1  
+      DO jj = 2, jpjm1
+        DO ji = 2, jpim1
           zu(ji,jj,1) = - ( fse3u(ji,jj,1) - sshu_n(ji,jj) * znad)
           zv(ji,jj,1) = - ( fse3v(ji,jj,1) - sshv_n(ji,jj) * znad)
@@ -765,7 +765,7 @@
       END DO
 
-      DO jk = 2, jpkm1                                  
-        DO jj = 2, jpjm1     
-          DO ji = 2, jpim1  
+      DO jk = 2, jpkm1
+        DO jj = 2, jpjm1
+          DO ji = 2, jpim1
             zu(ji,jj,jk) = zu(ji,jj,jk-1)- fse3u(ji,jj,jk)
             zv(ji,jj,jk) = zv(ji,jj,jk-1)- fse3v(ji,jj,jk)
@@ -773,8 +773,8 @@
         END DO
       END DO
-               
-      DO jk = 1, jpkm1                                  
-        DO jj = 2, jpjm1     
-          DO ji = 2, jpim1  
+
+      DO jk = 1, jpkm1
+        DO jj = 2, jpjm1
+          DO ji = 2, jpim1
             zu(ji,jj,jk) = zu(ji,jj,jk) + 0.5_wp * fse3u(ji,jj,jk)
             zv(ji,jj,jk) = zv(ji,jj,jk) + 0.5_wp * fse3v(ji,jj,jk)
@@ -795,7 +795,7 @@
 
 
-      DO jk = 1, jpkm1                                  
-        DO jj = 2, jpjm1     
-          DO ji = 2, jpim1  
+      DO jk = 1, jpkm1
+        DO jj = 2, jpjm1
+          DO ji = 2, jpim1
             zpwes = 0._wp; zpwed = 0._wp
             zpnss = 0._wp; zpnsd = 0._wp
@@ -812,5 +812,5 @@
 
                ! integrate the pressure on the shallow side
-               jk1 = jk 
+               jk1 = jk
                DO WHILE ( -zdept(jis,jj,jk1) > zuijk )
                  IF( jk1 == mbku(ji,jj) ) THEN
@@ -819,5 +819,5 @@
                  ENDIF
                  zdeps = MIN(zdept(jis,jj,jk1+1), -zuijk)
-                 zpwes = zpwes +                                    & 
+                 zpwes = zpwes +                                    &
                       integ_spline(zdept(jis,jj,jk1), zdeps,            &
                              asp(jis,jj,jk1),    bsp(jis,jj,jk1), &
@@ -825,7 +825,7 @@
                  jk1 = jk1 + 1
                END DO
-            
+
                ! integrate the pressure on the deep side
-               jk1 = jk 
+               jk1 = jk
                DO WHILE ( -zdept(jid,jj,jk1) < zuijk )
                  IF( jk1 == 1 ) THEN
@@ -838,5 +838,5 @@
                  ENDIF
                  zdeps = MAX(zdept(jid,jj,jk1-1), -zuijk)
-                 zpwed = zpwed +                                        & 
+                 zpwed = zpwed +                                        &
                         integ_spline(zdeps,              zdept(jid,jj,jk1), &
                                asp(jid,jj,jk1-1), bsp(jid,jj,jk1-1),  &
@@ -844,13 +844,13 @@
                  jk1 = jk1 - 1
                END DO
-            
+
                ! update the momentum trends in u direction
 
                zdpdx1 = zcoef0 / e1u(ji,jj) * (zhpi(ji+1,jj,jk) - zhpi(ji,jj,jk))
                IF( lk_vvl ) THEN
-                 zdpdx2 = zcoef0 / e1u(ji,jj) * & 
-                         ( REAL(jis-jid, wp) * (zpwes + zpwed) + (sshn(ji+1,jj)-sshn(ji,jj)) ) 
+                 zdpdx2 = zcoef0 / e1u(ji,jj) * &
+                         ( REAL(jis-jid, wp) * (zpwes + zpwed) + (sshn(ji+1,jj)-sshn(ji,jj)) )
                 ELSE
-                 zdpdx2 = zcoef0 / e1u(ji,jj) * REAL(jis-jid, wp) * (zpwes + zpwed) 
+                 zdpdx2 = zcoef0 / e1u(ji,jj) * REAL(jis-jid, wp) * (zpwes + zpwed)
                ENDIF
 
@@ -858,5 +858,5 @@
                &           umask(ji,jj,jk) * tmask(ji,jj,jk) * tmask(ji+1,jj,jk)
             ENDIF
-  
+
             !!!!!     for v equation
             IF( jk <= mbkv(ji,jj) ) THEN
@@ -868,5 +868,5 @@
 
                ! integrate the pressure on the shallow side
-               jk1 = jk 
+               jk1 = jk
                DO WHILE ( -zdept(ji,jjs,jk1) > zvijk )
                  IF( jk1 == mbkv(ji,jj) ) THEN
@@ -875,5 +875,5 @@
                  ENDIF
                  zdeps = MIN(zdept(ji,jjs,jk1+1), -zvijk)
-                 zpnss = zpnss +                                      & 
+                 zpnss = zpnss +                                      &
                         integ_spline(zdept(ji,jjs,jk1), zdeps,            &
                                asp(ji,jjs,jk1),    bsp(ji,jjs,jk1), &
@@ -881,7 +881,7 @@
                  jk1 = jk1 + 1
                END DO
-            
+
                ! integrate the pressure on the deep side
-               jk1 = jk 
+               jk1 = jk
                DO WHILE ( -zdept(ji,jjd,jk1) < zvijk )
                  IF( jk1 == 1 ) THEN
@@ -894,5 +894,5 @@
                  ENDIF
                  zdeps = MAX(zdept(ji,jjd,jk1-1), -zvijk)
-                 zpnsd = zpnsd +                                        & 
+                 zpnsd = zpnsd +                                        &
                         integ_spline(zdeps,              zdept(ji,jjd,jk1), &
                                asp(ji,jjd,jk1-1), bsp(ji,jjd,jk1-1), &
@@ -900,5 +900,5 @@
                  jk1 = jk1 - 1
                END DO
-            
+
 
                ! update the momentum trends in v direction
@@ -907,7 +907,7 @@
                IF( lk_vvl ) THEN
                    zdpdy2 = zcoef0 / e2v(ji,jj) * &
-                           ( REAL(jjs-jjd, wp) * (zpnss + zpnsd) + (sshn(ji,jj+1)-sshn(ji,jj)) ) 
+                           ( REAL(jjs-jjd, wp) * (zpnss + zpnsd) + (sshn(ji,jj+1)-sshn(ji,jj)) )
                ELSE
-                   zdpdy2 = zcoef0 / e2v(ji,jj) * REAL(jjs-jjd, wp) * (zpnss + zpnsd ) 
+                   zdpdy2 = zcoef0 / e2v(ji,jj) * REAL(jjs-jjd, wp) * (zpnss + zpnsd )
                ENDIF
 
@@ -916,11 +916,11 @@
             ENDIF
 
-                    
+
            END DO
         END DO
       END DO
       !
-      CALL wrk_dealloc( jpi,jpj,jpk, zhpi, zu, zv, fsp, xsp, asp, bsp, csp, dsp ) 
-      CALL wrk_dealloc( jpi,jpj,jpk, zdept, zrhh ) 
+      CALL wrk_dealloc( jpi,jpj,jpk, zhpi, zu, zv, fsp, xsp, asp, bsp, csp, dsp )
+      CALL wrk_dealloc( jpi,jpj,jpk, zdept, zrhh )
       !
    END SUBROUTINE hpg_prj
@@ -929,8 +929,8 @@
       !!----------------------------------------------------------------------
       !!                 ***  ROUTINE cspline  ***
-      !!       
+      !!
       !! ** Purpose :   constrained cubic spline interpolation
-      !!          
-      !! ** Method  :   f(x) = asp + bsp*x + csp*x^2 + dsp*x^3 
+      !!
+      !! ** Method  :   f(x) = asp + bsp*x + csp*x^2 + dsp*x^3
       !! Reference: CJC Kruger, Constrained Cubic Spline Interpoltation
       !!
@@ -938,10 +938,10 @@
       IMPLICIT NONE
       REAL(wp), DIMENSION(:,:,:), INTENT(in)  :: fsp, xsp           ! value and coordinate
-      REAL(wp), DIMENSION(:,:,:), INTENT(out) :: asp, bsp, csp, dsp ! coefficients of 
+      REAL(wp), DIMENSION(:,:,:), INTENT(out) :: asp, bsp, csp, dsp ! coefficients of
                                                                     ! the interpoated function
-      INTEGER, INTENT(in) :: polynomial_type                        ! 1: cubic spline 
+      INTEGER, INTENT(in) :: polynomial_type                        ! 1: cubic spline
                                                                     ! 2: Linear
 
-      ! Local Variables      
+      ! Local Variables
       INTEGER  ::   ji, jj, jk                 ! dummy loop indices
       INTEGER  ::   jpi, jpj, jpkm1
@@ -955,17 +955,17 @@
       jpkm1 = size(fsp,3) - 1
 
-      
+
       IF (polynomial_type == 1) THEN     ! Constrained Cubic Spline
          DO ji = 1, jpi
             DO jj = 1, jpj
-           !!Fritsch&Butland's method, 1984 (preferred, but more computation)              
+           !!Fritsch&Butland's method, 1984 (preferred, but more computation)
            !    DO jk = 2, jpkm1-1
-           !       zdxtmp1 = xsp(ji,jj,jk)   - xsp(ji,jj,jk-1)  
-           !       zdxtmp2 = xsp(ji,jj,jk+1) - xsp(ji,jj,jk)  
+           !       zdxtmp1 = xsp(ji,jj,jk)   - xsp(ji,jj,jk-1)
+           !       zdxtmp2 = xsp(ji,jj,jk+1) - xsp(ji,jj,jk)
            !       zdf1    = ( fsp(ji,jj,jk)   - fsp(ji,jj,jk-1) ) / zdxtmp1
            !       zdf2    = ( fsp(ji,jj,jk+1) - fsp(ji,jj,jk)   ) / zdxtmp2
            !
            !       zalpha = ( zdxtmp1 + 2._wp * zdxtmp2 ) / ( zdxtmp1 + zdxtmp2 ) / 3._wp
-           !     
+           !
            !       IF(zdf1 * zdf2 <= 0._wp) THEN
            !           zdf(jk) = 0._wp
@@ -974,10 +974,10 @@
            !       ENDIF
            !    END DO
-           
+
            !!Simply geometric average
                DO jk = 2, jpkm1-1
                   zdf1 = (fsp(ji,jj,jk) - fsp(ji,jj,jk-1)) / (xsp(ji,jj,jk) - xsp(ji,jj,jk-1))
                   zdf2 = (fsp(ji,jj,jk+1) - fsp(ji,jj,jk)) / (xsp(ji,jj,jk+1) - xsp(ji,jj,jk))
-            
+
                   IF(zdf1 * zdf2 <= 0._wp) THEN
                      zdf(jk) = 0._wp
@@ -986,5 +986,5 @@
                   ENDIF
                END DO
-           
+
                zdf(1)     = 1.5_wp * ( fsp(ji,jj,2) - fsp(ji,jj,1) ) / &
                           &          ( xsp(ji,jj,2) - xsp(ji,jj,1) ) -  0.5_wp * zdf(2)
@@ -992,16 +992,16 @@
                           &          ( xsp(ji,jj,jpkm1) - xsp(ji,jj,jpkm1-1) ) - &
                           & 0.5_wp * zdf(jpkm1 - 1)
-   
+
                DO jk = 1, jpkm1 - 1
-                 zdxtmp = xsp(ji,jj,jk+1) - xsp(ji,jj,jk) 
+                 zdxtmp = xsp(ji,jj,jk+1) - xsp(ji,jj,jk)
                  ztmp1  = (zdf(jk+1) + 2._wp * zdf(jk)) / zdxtmp
                  ztmp2  =  6._wp * (fsp(ji,jj,jk+1) - fsp(ji,jj,jk)) / zdxtmp / zdxtmp
-                 zddf1  = -2._wp * ztmp1 + ztmp2 
+                 zddf1  = -2._wp * ztmp1 + ztmp2
                  ztmp1  = (2._wp * zdf(jk+1) + zdf(jk)) / zdxtmp
-                 zddf2  =  2._wp * ztmp1 - ztmp2 
-      
+                 zddf2  =  2._wp * ztmp1 - ztmp2
+
                  dsp(ji,jj,jk) = (zddf2 - zddf1) / 6._wp / zdxtmp
                  csp(ji,jj,jk) = ( xsp(ji,jj,jk+1) * zddf1 - xsp(ji,jj,jk)*zddf2 ) / 2._wp / zdxtmp
-                 bsp(ji,jj,jk) = ( fsp(ji,jj,jk+1) - fsp(ji,jj,jk) ) / zdxtmp - & 
+                 bsp(ji,jj,jk) = ( fsp(ji,jj,jk+1) - fsp(ji,jj,jk) ) / zdxtmp - &
                                & csp(ji,jj,jk) * ( xsp(ji,jj,jk+1) + xsp(ji,jj,jk) ) - &
                                & dsp(ji,jj,jk) * ((xsp(ji,jj,jk+1) + xsp(ji,jj,jk))**2 - &
@@ -1013,12 +1013,12 @@
             END DO
          END DO
- 
+
       ELSE IF (polynomial_type == 2) THEN     ! Linear
          DO ji = 1, jpi
             DO jj = 1, jpj
                DO jk = 1, jpkm1-1
-                  zdxtmp =xsp(ji,jj,jk+1) - xsp(ji,jj,jk) 
+                  zdxtmp =xsp(ji,jj,jk+1) - xsp(ji,jj,jk)
                   ztmp1 = fsp(ji,jj,jk+1) - fsp(ji,jj,jk)
-   
+
                   dsp(ji,jj,jk) = 0._wp
                   csp(ji,jj,jk) = 0._wp
@@ -1033,21 +1033,21 @@
       ENDIF
 
-      
+
    END SUBROUTINE cspline
 
 
-   FUNCTION interp1(x, xl, xr, fl, fr)  RESULT(f) 
+   FUNCTION interp1(x, xl, xr, fl, fr)  RESULT(f)
       !!----------------------------------------------------------------------
       !!                 ***  ROUTINE interp1  ***
-      !!       
+      !!
       !! ** Purpose :   1-d linear interpolation
-      !!          
-      !! ** Method  :  
+      !!
+      !! ** Method  :
       !!                interpolation is straight forward
-      !!                extrapolation is also permitted (no value limit) 
+      !!                extrapolation is also permitted (no value limit)
       !!
       !!----------------------------------------------------------------------
       IMPLICIT NONE
-      REAL(wp), INTENT(in) ::  x, xl, xr, fl, fr   
+      REAL(wp), INTENT(in) ::  x, xl, xr, fl, fr
       REAL(wp)             ::  f ! result of the interpolation (extrapolation)
       REAL(wp)             ::  zdeltx
@@ -1060,38 +1060,38 @@
         f = ( (x - xl ) * fr - ( x - xr ) * fl ) / zdeltx
       ENDIF
-      
+
    END FUNCTION interp1
 
-   FUNCTION interp2(x, a, b, c, d)  RESULT(f) 
+   FUNCTION interp2(x, a, b, c, d)  RESULT(f)
       !!----------------------------------------------------------------------
       !!                 ***  ROUTINE interp1  ***
-      !!       
+      !!
       !! ** Purpose :   1-d constrained cubic spline interpolation
-      !!          
+      !!
       !! ** Method  :  cubic spline interpolation
       !!
       !!----------------------------------------------------------------------
       IMPLICIT NONE
-      REAL(wp), INTENT(in) ::  x, a, b, c, d   
+      REAL(wp), INTENT(in) ::  x, a, b, c, d
       REAL(wp)             ::  f ! value from the interpolation
       !!----------------------------------------------------------------------
 
-      f = a + x* ( b + x * ( c + d * x ) ) 
+      f = a + x* ( b + x * ( c + d * x ) )
 
    END FUNCTION interp2
 
 
-   FUNCTION interp3(x, a, b, c, d)  RESULT(f) 
+   FUNCTION interp3(x, a, b, c, d)  RESULT(f)
       !!----------------------------------------------------------------------
       !!                 ***  ROUTINE interp1  ***
-      !!       
+      !!
       !! ** Purpose :   Calculate the first order of deriavtive of
       !!                a cubic spline function y=a+b*x+c*x^2+d*x^3
-      !!          
+      !!
       !! ** Method  :   f=dy/dx=b+2*c*x+3*d*x^2
       !!
       !!----------------------------------------------------------------------
       IMPLICIT NONE
-      REAL(wp), INTENT(in) ::  x, a, b, c, d   
+      REAL(wp), INTENT(in) ::  x, a, b, c, d
       REAL(wp)             ::  f ! value from the interpolation
       !!----------------------------------------------------------------------
@@ -1101,23 +1101,23 @@
    END FUNCTION interp3
 
-   
-   FUNCTION integ_spline(xl, xr, a, b, c, d)  RESULT(f) 
+
+   FUNCTION integ_spline(xl, xr, a, b, c, d)  RESULT(f)
       !!----------------------------------------------------------------------
       !!                 ***  ROUTINE interp1  ***
-      !!       
+      !!
       !! ** Purpose :   1-d constrained cubic spline integration
-      !!          
-      !! ** Method  :  integrate polynomial a+bx+cx^2+dx^3 from xl to xr 
+      !!
+      !! ** Method  :  integrate polynomial a+bx+cx^2+dx^3 from xl to xr
       !!
       !!----------------------------------------------------------------------
       IMPLICIT NONE
-      REAL(wp), INTENT(in) ::  xl, xr, a, b, c, d   
-      REAL(wp)             ::  za1, za2, za3      
+      REAL(wp), INTENT(in) ::  xl, xr, a, b, c, d
+      REAL(wp)             ::  za1, za2, za3
       REAL(wp)             ::  f                   ! integration result
       !!----------------------------------------------------------------------
 
-      za1 = 0.5_wp * b 
-      za2 = c / 3.0_wp 
-      za3 = 0.25_wp * d 
+      za1 = 0.5_wp * b
+      za2 = c / 3.0_wp
+      za3 = 0.25_wp * d
 
       f  = xr * ( a + xr * ( za1 + xr * ( za2 + za3 * xr ) ) ) - &
Index: branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/OPA_SRC/DYN/dynnxt.F90
===================================================================
--- branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/OPA_SRC/DYN/dynnxt.F90	(revision 3759)
+++ branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/OPA_SRC/DYN/dynnxt.F90	(revision 3764)
@@ -156,5 +156,5 @@
 # if defined key_obc
       !                                !* OBC open boundaries
-      CALL obc_dyn( kt )
+      IF( lk_obc ) CALL obc_dyn( kt )
       !
       IF( .NOT. lk_dynspg_flt ) THEN
@@ -163,10 +163,10 @@
          !                                       sshn_b (= after ssha_b) for time-splitting case (lk_dynspg_ts=T)
          !                              - Correct the barotropic velocities
-         CALL obc_dyn_bt( kt )
+         IF( lk_obc ) CALL obc_dyn_bt( kt )
          !
 !!gm ERROR - potential BUG: sshn should not be modified at this stage !!   ssh_nxt not alrady called
          CALL lbc_lnk( sshn, 'T', 1. )         ! Boundary conditions on sshn
          !
-         IF( ln_vol_cst )   CALL obc_vol( kt )
+         IF( lk_obc .AND. ln_vol_cst )   CALL obc_vol( kt )
          !
          IF(ln_ctl)   CALL prt_ctl( tab2d_1=sshn, clinfo1=' ssh      : ', mask1=tmask )
@@ -175,6 +175,6 @@
 # elif defined key_bdy
       !                                !* BDY open boundaries
-      IF( lk_dynspg_exp ) CALL bdy_dyn( kt )
-      IF( lk_dynspg_ts )  CALL bdy_dyn( kt, dyn3d_only=.true. )
+      IF( lk_bdy .AND. lk_dynspg_exp ) CALL bdy_dyn( kt )
+      IF( lk_bdy .AND. lk_dynspg_ts  ) CALL bdy_dyn( kt, dyn3d_only=.true. )
 
 !!$   Do we need a call to bdy_vol here??
@@ -248,5 +248,5 @@
                DO jk = 1, jpkm1                       ! Leap-Frog - Asselin filter and swap: 
                   DO jj = 1, jpj                      !                   applied on thickness weighted velocity
-                     DO ji = 1, jpim1                 !                              ---------------------------
+                     DO ji = 1, jpi                   !                              ---------------------------
                         zue3a = ua(ji,jj,jk) * fse3u_a(ji,jj,jk)
                         zve3a = va(ji,jj,jk) * fse3v_a(ji,jj,jk)
@@ -268,6 +268,4 @@
                fse3u_b(:,:,1:jpkm1) = ze3u_f(:,:,1:jpkm1)      ! e3u_b <-- filtered scale factor
                fse3v_b(:,:,1:jpkm1) = ze3v_f(:,:,1:jpkm1)
-               CALL lbc_lnk( ub, 'U', -1. )                    ! lateral boundary conditions
-               CALL lbc_lnk( vb, 'V', -1. )
             ENDIF
             !
Index: branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/OPA_SRC/DYN/dynspg_flt.F90
===================================================================
--- branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/OPA_SRC/DYN/dynspg_flt.F90	(revision 3759)
+++ branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/OPA_SRC/DYN/dynspg_flt.F90	(revision 3764)
@@ -187,10 +187,10 @@
 
 #if defined key_obc
-      CALL obc_dyn( kt )      ! Update velocities on each open boundary with the radiation algorithm
-      CALL obc_vol( kt )      ! Correction of the barotropic componant velocity to control the volume of the system
+      IF( lk_obc ) CALL obc_dyn( kt )   ! Update velocities on each open boundary with the radiation algorithm
+      IF( lk_obc ) CALL obc_vol( kt )   ! Correction of the barotropic componant velocity to control the volume of the system
 #endif
 #if defined key_bdy
-      CALL bdy_dyn( kt )      ! Update velocities on each open boundary
-      CALL bdy_vol( kt )      ! Correction of the barotropic component velocity to control the volume of the system
+      IF( lk_bdy ) CALL bdy_dyn( kt )   ! Update velocities on each open boundary
+      IF( lk_bdy ) CALL bdy_vol( kt )   ! Correction of the barotropic component velocity to control the volume of the system
 #endif
 #if defined key_agrif
Index: branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/OPA_SRC/DYN/sshwzv.F90
===================================================================
--- branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/OPA_SRC/DYN/sshwzv.F90	(revision 3759)
+++ branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/OPA_SRC/DYN/sshwzv.F90	(revision 3764)
@@ -181,7 +181,13 @@
 #if defined key_bdy
       ssha(:,:) = ssha(:,:) * bdytmask(:,:)
-      CALL lbc_lnk( ssha, 'T', 1. )                 ! absolutly compulsory !! (jmm)
-#endif
-
+      CALL lbc_lnk( ssha, 'T', 1. )                    ! absolutly compulsory !! (jmm)
+#endif
+#if defined key_asminc
+      !                                                ! Include the IAU weighted SSH increment
+      IF( lk_asminc .AND. ln_sshinc .AND. ln_asmiau ) THEN
+         CALL ssh_asm_inc( kt )
+         ssha(:,:) = ssha(:,:) + z2dt * ssh_iau(:,:)
+      ENDIF
+#endif
       !                                                ! Sea Surface Height at u-,v- and f-points (vvl case only)
       IF( lk_vvl ) THEN                                ! (required only in key_vvl case)
@@ -198,12 +204,4 @@
          CALL lbc_lnk( sshu_a, 'U', 1. )   ;   CALL lbc_lnk( sshv_a, 'V', 1. )      ! Boundaries conditions
       ENDIF
-      
-#if defined key_asminc
-      !                                                ! Include the IAU weighted SSH increment
-      IF( lk_asminc .AND. ln_sshinc .AND. ln_asmiau ) THEN
-         CALL ssh_asm_inc( kt )
-         ssha(:,:) = ssha(:,:) + z2dt * ssh_iau(:,:)
-      ENDIF
-#endif
 
       !                                           !------------------------------!
Index: branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/OPA_SRC/IOM/iom.F90
===================================================================
--- branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/OPA_SRC/IOM/iom.F90	(revision 3759)
+++ branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/OPA_SRC/IOM/iom.F90	(revision 3764)
@@ -4,9 +4,9 @@
    !! Input/Output manager :  Library to read input files
    !!====================================================================
-   !! History :  9.0  ! 05 12  (J. Belier) Original code
-   !!            9.0  ! 06 02  (S. Masson) Adaptation to NEMO
-   !!             "   ! 07 07  (D. Storkey) Changes to iom_gettime
+   !! History :  2.0  ! 2005-12  (J. Belier) Original code
+   !!            2.0  ! 2006-02  (S. Masson) Adaptation to NEMO
+   !!            3.0  ! 2007-07  (D. Storkey) Changes to iom_gettime
+   !!            3.4  ! 2012-12  (R. Bourdalle-Badie and G. Reffray)  add C1D case  
    !!--------------------------------------------------------------------
-   !!gm  caution add !DIR nec: improved performance to be checked as well as no result changes
 
    !!--------------------------------------------------------------------
@@ -19,4 +19,5 @@
    !!--------------------------------------------------------------------
    USE dom_oce         ! ocean space and time domain
+   USE c1d             ! 1D vertical configuration
    USE flo_oce         ! floats module declarations
    USE lbclnk          ! lateal boundary condition / mpp exchanges
@@ -761,4 +762,8 @@
             ENDIF
             
+            ! C1D case : always call lbc_lnk to replicate the central value over the whole 3X3 domain
+            IF( lk_c1d .AND. PRESENT(pv_r2d) )   CALL lbc_lnk( pv_r2d,'Z',1. )
+            IF( lk_c1d .AND. PRESENT(pv_r3d) )   CALL lbc_lnk( pv_r3d,'Z',1. )
+    
             !--- Apply scale_factor and offset
             zscf = iom_file(kiomid)%scf(idvar)      ! scale factor
Index: branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/OPA_SRC/LBC/lbclnk.F90
===================================================================
--- branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/OPA_SRC/LBC/lbclnk.F90	(revision 3759)
+++ branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/OPA_SRC/LBC/lbclnk.F90	(revision 3764)
@@ -10,6 +10,7 @@
    !!                            and lbc_obc_lnk' routine to optimize  
    !!                            the BDY/OBC communications
-   !!----------------------------------------------------------------------
-#if   defined key_mpp_mpi
+   !!            3.4  ! 2012-12  (R. Bourdalle-Badie and G. Reffray)  add a C1D case  
+   !!----------------------------------------------------------------------
+#if defined key_mpp_mpi
    !!----------------------------------------------------------------------
    !!   'key_mpp_mpi'             MPI massively parallel processing library
@@ -93,4 +94,81 @@
 CONTAINS
 
+# if defined key_c1d
+   !!----------------------------------------------------------------------
+   !!   'key_c1d'                                          1D configuration
+   !!----------------------------------------------------------------------
+
+   SUBROUTINE lbc_lnk_3d_gather( pt3d1, cd_type1, pt3d2, cd_type2, psgn )
+      !!---------------------------------------------------------------------
+      !!                  ***  ROUTINE lbc_lnk_3d_gather  ***
+      !!
+      !! ** Purpose :   set lateral boundary conditions on two 3D arrays (C1D case)
+      !!
+      !! ** Method  :   call lbc_lnk_3d on pt3d1 and pt3d2
+      !!----------------------------------------------------------------------
+      CHARACTER(len=1)                , INTENT(in   ) ::   cd_type1, cd_type2   ! nature of pt3d grid-points
+      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(inout) ::   pt3d1   , pt3d2      ! 3D array on which the lbc is applied
+      REAL(wp)                        , INTENT(in   ) ::   psgn                 ! control of the sign 
+      !!----------------------------------------------------------------------
+      !
+      CALL lbc_lnk_3d( pt3d1, cd_type1, psgn)
+      CALL lbc_lnk_3d( pt3d2, cd_type2, psgn)
+      !
+   END SUBROUTINE lbc_lnk_3d_gather
+
+
+   SUBROUTINE lbc_lnk_3d( pt3d, cd_type, psgn, cd_mpp, pval )
+      !!---------------------------------------------------------------------
+      !!                  ***  ROUTINE lbc_lnk_3d  ***
+      !!
+      !! ** Purpose :   set lateral boundary conditions on a 3D array (C1D case)
+      !!
+      !! ** Method  :   1D case, the central water column is set everywhere
+      !!----------------------------------------------------------------------
+      CHARACTER(len=1)                , INTENT(in   )           ::   cd_type   ! nature of pt3d grid-points
+      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(inout)           ::   pt3d      ! 3D array on which the lbc is applied
+      REAL(wp)                        , INTENT(in   )           ::   psgn      ! control of the sign 
+      CHARACTER(len=3)                , INTENT(in   ), OPTIONAL ::   cd_mpp    ! MPP only (here do nothing)
+      REAL(wp)                        , INTENT(in   ), OPTIONAL ::   pval      ! background value (for closed boundaries)
+      !
+      INTEGER  ::   jk     ! dummy loop index
+      REAL(wp) ::   ztab   ! local scalar
+      !!----------------------------------------------------------------------
+      !
+      DO jk = 1, jpk
+         ztab = pt3d(2,2,jk)
+         pt3d(:,:,jk) = ztab
+      END DO
+      !
+   END SUBROUTINE lbc_lnk_3d
+
+
+   SUBROUTINE lbc_lnk_2d( pt2d, cd_type, psgn, cd_mpp, pval )
+      !!---------------------------------------------------------------------
+      !!                 ***  ROUTINE lbc_lnk_2d  ***
+      !!
+      !! ** Purpose :   set lateral boundary conditions on a 2D array (non mpp case)
+      !!
+      !! ** Method  :   1D case, the central water column is set everywhere
+      !!----------------------------------------------------------------------
+      CHARACTER(len=1)            , INTENT(in   )           ::   cd_type   ! nature of pt3d grid-points
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(inout)           ::   pt2d      ! 2D array on which the lbc is applied
+      REAL(wp)                    , INTENT(in   )           ::   psgn      ! control of the sign 
+      CHARACTER(len=3)            , INTENT(in   ), OPTIONAL ::   cd_mpp    ! MPP only (here do nothing)
+      REAL(wp)                    , INTENT(in   ), OPTIONAL ::   pval      ! background value (for closed boundaries)
+      !
+      REAL(wp) ::   ztab   ! local scalar
+      !!----------------------------------------------------------------------
+      !
+      ztab = pt2d(2,2)
+      pt2d(:,:) = ztab
+      !
+   END SUBROUTINE lbc_lnk_2d
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Default option                           3D shared memory computing
+   !!----------------------------------------------------------------------
+
    SUBROUTINE lbc_lnk_3d_gather( pt3d1, cd_type1, pt3d2, cd_type2, psgn )
       !!---------------------------------------------------------------------
@@ -138,5 +216,5 @@
 
       IF( PRESENT( pval ) ) THEN   ;   zland = pval      ! set land value (zero by default)
-      ELSE                         ;   zland = 0.e0
+      ELSE                         ;   zland = 0._wp
       ENDIF
 
@@ -261,5 +339,5 @@
 
       IF( PRESENT( pval ) ) THEN   ;   zland = pval      ! set land value (zero by default)
-      ELSE                         ;   zland = 0.e0
+      ELSE                         ;   zland = 0._wp
       ENDIF
 
Index: branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/OPA_SRC/LBC/lib_mpp.F90
===================================================================
--- branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/OPA_SRC/LBC/lib_mpp.F90	(revision 3759)
+++ branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/OPA_SRC/LBC/lib_mpp.F90	(revision 3764)
@@ -17,5 +17,5 @@
    !!             -   !  2008  (R. Benshila) add mpp_ini_ice
    !!            3.2  !  2009  (R. Benshila) SHMEM suppression, north fold in lbc_nfd
-   !!            3.2  !  2009  (O. Marti)    add mpp_ini_znl 
+   !!            3.2  !  2009  (O. Marti)    add mpp_ini_znl
    !!            4.0  !  2011  (G. Madec)  move ctl_ routines from in_out_manager
    !!            3.5  !  2012  (S.Mocavero, I. Epicoco) Add 'mpp_lnk_bdy_3d', 'mpp_lnk_obc_3d', 
@@ -30,5 +30,5 @@
    !!   get_unit    : give the index of an unused logical unit
    !!----------------------------------------------------------------------
-#if   defined key_mpp_mpi  
+#if   defined key_mpp_mpi
    !!----------------------------------------------------------------------
    !!   'key_mpp_mpi'             MPI massively parallel processing library
@@ -55,5 +55,5 @@
    !!   mpp_lbc_north_e : variant of mpp_lbc_north for extra outer halo
    !!----------------------------------------------------------------------
-   USE dom_oce        ! ocean space and time domain 
+   USE dom_oce        ! ocean space and time domain
    USE lbcnfd         ! north fold treatment
    USE in_out_manager ! I/O manager
@@ -61,5 +61,5 @@
    IMPLICIT NONE
    PRIVATE
-   
+
    PUBLIC   ctl_stop, ctl_warn, get_unit, ctl_opn
    PUBLIC   mynode, mppstop, mppsync, mpp_comm_free
@@ -70,5 +70,5 @@
    PUBLIC   mppobc, mpp_ini_ice, mpp_ini_znl
    PUBLIC   mppsize
-   PUBLIC   mppsend, mpprecv                          ! needed by ICB routines
+   PUBLIC   mppsend, mpprecv                          ! needed by TAM and ICB routines
    PUBLIC   lib_mpp_alloc   ! Called in nemogcm.F90
    PUBLIC   mpp_lnk_bdy_2d, mpp_lnk_bdy_3d
@@ -90,5 +90,5 @@
    END INTERFACE
    INTERFACE mpp_lbc_north
-      MODULE PROCEDURE mpp_lbc_north_3d, mpp_lbc_north_2d 
+      MODULE PROCEDURE mpp_lbc_north_3d, mpp_lbc_north_2d
    END INTERFACE
    INTERFACE mpp_minloc
@@ -98,5 +98,5 @@
       MODULE PROCEDURE mpp_maxloc2d ,mpp_maxloc3d
    END INTERFACE
-   
+
    !! ========================= !!
    !!  MPI  variable definition !!
@@ -105,9 +105,9 @@
    INCLUDE 'mpif.h'
 !$AGRIF_END_DO_NOT_TREAT
-   
+
    LOGICAL, PUBLIC, PARAMETER ::   lk_mpp = .TRUE.    !: mpp flag
 
    INTEGER, PARAMETER         ::   nprocmax = 2**10   ! maximun dimension (required to be a power of 2)
-   
+
    INTEGER ::   mppsize        ! number of process
    INTEGER ::   mpprank        ! process number  [ 0 - size-1 ]
@@ -132,20 +132,20 @@
    INTEGER ::   ndim_rank_znl   ! number of processors on the same zonal average
    INTEGER, DIMENSION(:), ALLOCATABLE, SAVE ::   nrank_znl  ! dimension ndim_rank_znl, number of the procs into the same znl domain
-   
-   ! North fold condition in mpp_mpi with jpni > 1
-   INTEGER ::   ngrp_world        ! group ID for the world processors
-   INTEGER ::   ngrp_opa          ! group ID for the opa processors
-   INTEGER ::   ngrp_north        ! group ID for the northern processors (to be fold)
-   INTEGER ::   ncomm_north       ! communicator made by the processors belonging to ngrp_north
-   INTEGER ::   ndim_rank_north   ! number of 'sea' processor in the northern line (can be /= jpni !)
-   INTEGER ::   njmppmax          ! value of njmpp for the processors of the northern line
-   INTEGER ::   north_root        ! number (in the comm_opa) of proc 0 in the northern comm
-   INTEGER, DIMENSION(:), ALLOCATABLE, SAVE ::   nrank_north   ! dimension ndim_rank_north
+
+   ! North fold condition in mpp_mpi with jpni > 1 (PUBLIC for TAM)
+   INTEGER, PUBLIC ::   ngrp_world        ! group ID for the world processors
+   INTEGER, PUBLIC ::   ngrp_opa          ! group ID for the opa processors
+   INTEGER, PUBLIC ::   ngrp_north        ! group ID for the northern processors (to be fold)
+   INTEGER, PUBLIC ::   ncomm_north       ! communicator made by the processors belonging to ngrp_north
+   INTEGER, PUBLIC ::   ndim_rank_north   ! number of 'sea' processor in the northern line (can be /= jpni !)
+   INTEGER, PUBLIC ::   njmppmax          ! value of njmpp for the processors of the northern line
+   INTEGER, PUBLIC ::   north_root        ! number (in the comm_opa) of proc 0 in the northern comm
+   INTEGER, DIMENSION(:), ALLOCATABLE, SAVE, PUBLIC ::   nrank_north   ! dimension ndim_rank_north
 
    ! Type of send : standard, buffered, immediate
-   CHARACTER(len=1)         ::   cn_mpi_send = 'S'    ! type od mpi send/recieve (S=standard, B=bsend, I=isend)
-   LOGICAL         , PUBLIC ::   l_isend = .FALSE.   ! isend use indicator (T if cn_mpi_send='I')
-   INTEGER                  ::   nn_buffer = 0       ! size of the buffer in case of mpi_bsend 
-      
+   CHARACTER(len=1), PUBLIC ::   cn_mpi_send = 'S'    ! type od mpi send/recieve (S=standard, B=bsend, I=isend)
+   LOGICAL, PUBLIC          ::   l_isend = .FALSE.   ! isend use indicator (T if cn_mpi_send='I')
+   INTEGER, PUBLIC          ::   nn_buffer = 0       ! size of the buffer in case of mpi_bsend
+
    REAL(wp), DIMENSION(:), ALLOCATABLE, SAVE :: tampon  ! buffer in case of bsend
 
@@ -177,5 +177,5 @@
    ! North fold arrays used to minimise the use of allgather operations. Set in nemo_northcomms (nemogcm) so need to be public
    INTEGER, PUBLIC,  PARAMETER :: jpmaxngh = 8                 ! Assumed maximum number of active neighbours
-   INTEGER, PUBLIC,  PARAMETER :: jptyps   = 5                 ! Number of different neighbour lists to be used for northfold exchanges 
+   INTEGER, PUBLIC,  PARAMETER :: jptyps   = 5                 ! Number of different neighbour lists to be used for northfold exchanges
    INTEGER, PUBLIC,  DIMENSION (jpmaxngh,jptyps)    ::   isendto
    INTEGER, PUBLIC,  DIMENSION (jptyps)             ::   nsndto
@@ -228,10 +228,10 @@
       !!----------------------------------------------------------------------
       !!                  ***  routine mynode  ***
-      !!                    
+      !!
       !! ** Purpose :   Find processor unit
       !!----------------------------------------------------------------------
-      CHARACTER(len=*),DIMENSION(:), INTENT(  out) ::   ldtxt 
-      INTEGER                      , INTENT(in   ) ::   kumnam       ! namelist logical unit 
-      INTEGER                      , INTENT(inout) ::   kstop        ! stop indicator 
+      CHARACTER(len=*),DIMENSION(:), INTENT(  out) ::   ldtxt
+      INTEGER                      , INTENT(in   ) ::   kumnam       ! namelist logical unit
+      INTEGER                      , INTENT(inout) ::   kstop        ! stop indicator
       INTEGER, OPTIONAL            , INTENT(in   ) ::   localComm
       !
@@ -257,5 +257,5 @@
 #if defined key_agrif
       IF( .NOT. Agrif_Root() ) THEN
-         jpni  = Agrif_Parent(jpni ) 
+         jpni  = Agrif_Parent(jpni )
          jpnj  = Agrif_Parent(jpnj )
          jpnij = Agrif_Parent(jpnij)
@@ -281,7 +281,7 @@
       CALL mpi_initialized ( mpi_was_called, code )
       IF( code /= MPI_SUCCESS ) THEN
-         DO ji = 1, SIZE(ldtxt) 
+         DO ji = 1, SIZE(ldtxt)
             IF( TRIM(ldtxt(ji)) /= '' )   WRITE(*,*) ldtxt(ji)      ! control print of mynode
-         END DO         
+         END DO
          WRITE(*, cform_err)
          WRITE(*, *) 'lib_mpp: Error in routine mpi_initialized'
@@ -296,5 +296,5 @@
          CASE ( 'B' )                ! Buffer mpi send (blocking)
             WRITE(ldtxt(ii),*) '           Buffer blocking mpi send (bsend)'                      ;   ii = ii + 1
-            IF( Agrif_Root() )   CALL mpi_init_opa( ldtxt, ii, ierr ) 
+            IF( Agrif_Root() )   CALL mpi_init_opa( ldtxt, ii, ierr )
          CASE ( 'I' )                ! Immediate mpi send (non-blocking send)
             WRITE(ldtxt(ii),*) '           Immediate non-blocking send (isend)'                   ;   ii = ii + 1
@@ -329,5 +329,5 @@
       ENDIF
 
-      IF( PRESENT(localComm) ) THEN 
+      IF( PRESENT(localComm) ) THEN
          IF( Agrif_Root() ) THEN
             mpi_comm_opa = localComm
@@ -336,5 +336,5 @@
          CALL mpi_comm_dup( mpi_comm_world, mpi_comm_opa, code)
          IF( code /= MPI_SUCCESS ) THEN
-            DO ji = 1, SIZE(ldtxt) 
+            DO ji = 1, SIZE(ldtxt)
                IF( TRIM(ldtxt(ji)) /= '' )   WRITE(*,*) ldtxt(ji)      ! control print of mynode
             END DO
@@ -343,10 +343,10 @@
             CALL mpi_abort( mpi_comm_world, code, ierr )
          ENDIF
-      ENDIF 
+      ENDIF
 
       CALL mpi_comm_rank( mpi_comm_opa, mpprank, ierr )
       CALL mpi_comm_size( mpi_comm_opa, mppsize, ierr )
       mynode = mpprank
-      ! 
+      !
       CALL MPI_OP_CREATE(DDPDD_MPI, .TRUE., MPI_SUMDD, ierr)
       !
@@ -721,5 +721,5 @@
       !! ** Purpose :   Message passing manadgement
       !!
-      !! ** Method  :   Use mppsend and mpprecv function for passing mask 
+      !! ** Method  :   Use mppsend and mpprecv function for passing mask
       !!      between processors following neighboring subdomains.
       !!            domain parameters
@@ -728,5 +728,5 @@
       !!                    nbondi : mark for "east-west local boundary"
       !!                    nbondj : mark for "north-south local boundary"
-      !!                    noea   : number for local neighboring processors 
+      !!                    noea   : number for local neighboring processors
       !!                    nowe   : number for local neighboring processors
       !!                    noso   : number for local neighboring processors
@@ -741,5 +741,5 @@
       REAL(wp)                        , INTENT(in   ) ::   psgn     ! =-1 the sign change across the north fold boundary
       !                                                             ! =  1. , the sign is kept
-      CHARACTER(len=3), OPTIONAL      , INTENT(in   ) ::   cd_mpp   ! fill the overlap area only 
+      CHARACTER(len=3), OPTIONAL      , INTENT(in   ) ::   cd_mpp   ! fill the overlap area only
       REAL(wp)        , OPTIONAL      , INTENT(in   ) ::   pval     ! background value (used at closed boundaries)
       !!
@@ -762,5 +762,5 @@
          DO jk = 1, jpk
             DO jj = nlcj+1, jpj                 ! added line(s)   (inner only)
-               ptab(nldi  :nlei  , jj          ,jk) = ptab(nldi:nlei,     nlej,jk)   
+               ptab(nldi  :nlei  , jj          ,jk) = ptab(nldi:nlei,     nlej,jk)
                ptab(1     :nldi-1, jj          ,jk) = ptab(nldi     ,     nlej,jk)
                ptab(nlei+1:nlci  , jj          ,jk) = ptab(     nlei,     nlej,jk)
@@ -773,5 +773,5 @@
          END DO
          !
-      ELSE                              ! standard close or cyclic treatment 
+      ELSE                              ! standard close or cyclic treatment
          !
          !                                   ! East-West boundaries
@@ -792,5 +792,5 @@
       ! 2. East and west directions exchange
       ! ------------------------------------
-      ! we play with the neigbours AND the row number because of the periodicity 
+      ! we play with the neigbours AND the row number because of the periodicity
       !
       SELECT CASE ( nbondi )      ! Read Dirichlet lateral conditions
@@ -801,10 +801,10 @@
             t3we(:,jl,:,1) = ptab(iihom +jl,:,:)
          END DO
-      END SELECT  
+      END SELECT
       !
       !                           ! Migrations
       imigr = jpreci * jpj * jpk
       !
-      SELECT CASE ( nbondi ) 
+      SELECT CASE ( nbondi )
       CASE ( -1 )
          CALL mppsend( 2, t3we(1,1,1,1), imigr, noea, ml_req1 )
@@ -832,5 +832,5 @@
             ptab(iihom+jl,:,:) = t3ew(:,jl,:,2)
          END DO
-      CASE ( 0 ) 
+      CASE ( 0 )
          DO jl = 1, jpreci
             ptab(jl      ,:,:) = t3we(:,jl,:,2)
@@ -859,5 +859,5 @@
       imigr = jprecj * jpi * jpk
       !
-      SELECT CASE ( nbondj )     
+      SELECT CASE ( nbondj )
       CASE ( -1 )
          CALL mppsend( 4, t3sn(1,1,1,1), imigr, nono, ml_req1 )
@@ -871,5 +871,5 @@
          IF(l_isend) CALL mpi_wait(ml_req1, ml_stat, ml_err)
          IF(l_isend) CALL mpi_wait(ml_req2, ml_stat, ml_err)
-      CASE ( 1 ) 
+      CASE ( 1 )
          CALL mppsend( 3, t3ns(1,1,1,1), imigr, noso, ml_req1 )
          CALL mpprecv( 4, t3sn(1,1,1,2), imigr, noso )
@@ -885,5 +885,5 @@
             ptab(:,ijhom+jl,:) = t3ns(:,jl,:,2)
          END DO
-      CASE ( 0 ) 
+      CASE ( 0 )
          DO jl = 1, jprecj
             ptab(:,jl      ,:) = t3sn(:,jl,:,2)
@@ -915,8 +915,8 @@
       !!----------------------------------------------------------------------
       !!                  ***  routine mpp_lnk_2d  ***
-      !!                  
+      !!
       !! ** Purpose :   Message passing manadgement for 2d array
       !!
-      !! ** Method  :   Use mppsend and mpprecv function for passing mask 
+      !! ** Method  :   Use mppsend and mpprecv function for passing mask
       !!      between processors following neighboring subdomains.
       !!            domain parameters
@@ -925,5 +925,5 @@
       !!                    nbondi : mark for "east-west local boundary"
       !!                    nbondj : mark for "north-south local boundary"
-      !!                    noea   : number for local neighboring processors 
+      !!                    noea   : number for local neighboring processors
       !!                    nowe   : number for local neighboring processors
       !!                    noso   : number for local neighboring processors
@@ -936,5 +936,5 @@
       REAL(wp)                    , INTENT(in   ) ::   psgn     ! =-1 the sign change across the north fold boundary
       !                                                         ! =  1. , the sign is kept
-      CHARACTER(len=3), OPTIONAL  , INTENT(in   ) ::   cd_mpp   ! fill the overlap area only 
+      CHARACTER(len=3), OPTIONAL  , INTENT(in   ) ::   cd_mpp   ! fill the overlap area only
       REAL(wp)        , OPTIONAL  , INTENT(in   ) ::   pval     ! background value (used at closed boundaries)
       !!
@@ -957,5 +957,5 @@
          ! WARNING pt2d is defined only between nld and nle
          DO jj = nlcj+1, jpj                 ! added line(s)   (inner only)
-            pt2d(nldi  :nlei  , jj          ) = pt2d(nldi:nlei,     nlej)   
+            pt2d(nldi  :nlei  , jj          ) = pt2d(nldi:nlei,     nlej)
             pt2d(1     :nldi-1, jj          ) = pt2d(nldi     ,     nlej)
             pt2d(nlei+1:nlci  , jj          ) = pt2d(     nlei,     nlej)
@@ -967,5 +967,5 @@
          END DO
          !
-      ELSE                              ! standard close or cyclic treatment 
+      ELSE                              ! standard close or cyclic treatment
          !
          !                                   ! East-West boundaries
@@ -986,5 +986,5 @@
       ! 2. East and west directions exchange
       ! ------------------------------------
-      ! we play with the neigbours AND the row number because of the periodicity 
+      ! we play with the neigbours AND the row number because of the periodicity
       !
       SELECT CASE ( nbondi )      ! Read Dirichlet lateral conditions
@@ -1084,5 +1084,5 @@
             pt2d(:,ijhom+jl) = t2ns(:,jl,2)
          END DO
-      CASE ( 1 ) 
+      CASE ( 1 )
          DO jl = 1, jprecj
             pt2d(:,jl      ) = t2sn(:,jl,2)
@@ -1112,5 +1112,5 @@
       !! ** Purpose :   Message passing manadgement for two 3D arrays
       !!
-      !! ** Method  :   Use mppsend and mpprecv function for passing mask 
+      !! ** Method  :   Use mppsend and mpprecv function for passing mask
       !!      between processors following neighboring subdomains.
       !!            domain parameters
@@ -1119,5 +1119,5 @@
       !!                    nbondi : mark for "east-west local boundary"
       !!                    nbondj : mark for "north-south local boundary"
-      !!                    noea   : number for local neighboring processors 
+      !!                    noea   : number for local neighboring processors
       !!                    nowe   : number for local neighboring processors
       !!                    noso   : number for local neighboring processors
@@ -1127,7 +1127,7 @@
       !!
       !!----------------------------------------------------------------------
-      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(inout) ::   ptab1     ! first and second 3D array on which 
+      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(inout) ::   ptab1     ! first and second 3D array on which
       REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(inout) ::   ptab2     ! the boundary condition is applied
-      CHARACTER(len=1)                , INTENT(in   ) ::   cd_type1  ! nature of ptab1 and ptab2 arrays 
+      CHARACTER(len=1)                , INTENT(in   ) ::   cd_type1  ! nature of ptab1 and ptab2 arrays
       CHARACTER(len=1)                , INTENT(in   ) ::   cd_type2  ! i.e. grid-points = T , U , V , F or W points
       REAL(wp)                        , INTENT(in   ) ::   psgn      ! =-1 the sign change across the north fold boundary
@@ -1155,5 +1155,5 @@
       ENDIF
 
-      
+
       !                                      ! North-South boundaries
       IF( .NOT. cd_type1 == 'F' )   ptab1(:,     1       :jprecj,:) = 0.e0    ! south except at F-point
@@ -1165,5 +1165,5 @@
       ! 2. East and west directions exchange
       ! ------------------------------------
-      ! we play with the neigbours AND the row number because of the periodicity 
+      ! we play with the neigbours AND the row number because of the periodicity
       !
       SELECT CASE ( nbondi )      ! Read Dirichlet lateral conditions
@@ -1181,5 +1181,5 @@
       imigr = jpreci * jpj * jpk *2
       !
-      SELECT CASE ( nbondi ) 
+      SELECT CASE ( nbondi )
       CASE ( -1 )
          CALL mppsend( 2, t4we(1,1,1,1,1), imigr, noea, ml_req1 )
@@ -1208,5 +1208,5 @@
             ptab2(iihom+jl,:,:) = t4ew(:,jl,:,2,2)
          END DO
-      CASE ( 0 ) 
+      CASE ( 0 )
          DO jl = 1, jpreci
             ptab1(jl      ,:,:) = t4we(:,jl,:,1,2)
@@ -1240,5 +1240,5 @@
       imigr = jprecj * jpi * jpk * 2
       !
-      SELECT CASE ( nbondj )     
+      SELECT CASE ( nbondj )
       CASE ( -1 )
          CALL mppsend( 4, t4sn(1,1,1,1,1), imigr, nono, ml_req1 )
@@ -1252,5 +1252,5 @@
          IF(l_isend) CALL mpi_wait(ml_req1, ml_stat, ml_err)
          IF(l_isend) CALL mpi_wait(ml_req2, ml_stat, ml_err)
-      CASE ( 1 ) 
+      CASE ( 1 )
          CALL mppsend( 3, t4ns(1,1,1,1,1), imigr, noso, ml_req1 )
          CALL mpprecv( 4, t4sn(1,1,1,1,2), imigr, noso )
@@ -1267,5 +1267,5 @@
             ptab2(:,ijhom+jl,:) = t4ns(:,jl,:,2,2)
          END DO
-      CASE ( 0 ) 
+      CASE ( 0 )
          DO jl = 1, jprecj
             ptab1(:,jl      ,:) = t4sn(:,jl,:,1,2)
@@ -1287,5 +1287,5 @@
          !
          SELECT CASE ( jpni )
-         CASE ( 1 )                                           
+         CASE ( 1 )
             CALL lbc_nfd      ( ptab1, cd_type1, psgn )   ! only for northern procs.
             CALL lbc_nfd      ( ptab2, cd_type2, psgn )
@@ -1293,5 +1293,5 @@
             CALL mpp_lbc_north( ptab1, cd_type1, psgn )   ! for all northern procs.
             CALL mpp_lbc_north (ptab2, cd_type2, psgn)
-         END SELECT 
+         END SELECT
          !
       ENDIF
@@ -1303,8 +1303,8 @@
       !!----------------------------------------------------------------------
       !!                  ***  routine mpp_lnk_2d_e  ***
-      !!                  
+      !!
       !! ** Purpose :   Message passing manadgement for 2d array (with halo)
       !!
-      !! ** Method  :   Use mppsend and mpprecv function for passing mask 
+      !! ** Method  :   Use mppsend and mpprecv function for passing mask
       !!      between processors following neighboring subdomains.
       !!            domain parameters
@@ -1315,5 +1315,5 @@
       !!                    nbondi : mark for "east-west local boundary"
       !!                    nbondj : mark for "north-south local boundary"
-      !!                    noea   : number for local neighboring processors 
+      !!                    noea   : number for local neighboring processors
       !!                    nowe   : number for local neighboring processors
       !!                    noso   : number for local neighboring processors
@@ -1351,5 +1351,5 @@
       IF( .NOT. cd_type == 'F' )   pt2d(:,  1-jprj   :  jprecj  ) = 0.e0    ! south except at F-point
                                    pt2d(:,nlcj-jprecj+1:jpj+jprj) = 0.e0    ! north
-                                
+
       !                                      ! East-West boundaries
       !                                           !* Cyclic east-west
@@ -1371,5 +1371,5 @@
          CASE ( 1 )     ;   CALL lbc_nfd        ( pt2d(1:jpi,1:jpj+jprj), cd_type, psgn, pr2dj=jprj )
          CASE DEFAULT   ;   CALL mpp_lbc_north_e( pt2d                    , cd_type, psgn               )
-         END SELECT 
+         END SELECT
          !
       ENDIF
@@ -1377,5 +1377,5 @@
       ! 2. East and west directions exchange
       ! ------------------------------------
-      ! we play with the neigbours AND the row number because of the periodicity 
+      ! we play with the neigbours AND the row number because of the periodicity
       !
       SELECT CASE ( nbondi )      ! Read Dirichlet lateral conditions
@@ -1463,5 +1463,5 @@
       !
       !                           ! Write Dirichlet lateral conditions
-      ijhom = nlcj - jprecj  
+      ijhom = nlcj - jprecj
       !
       SELECT CASE ( nbondj )
@@ -1475,5 +1475,5 @@
             pt2d(:,ijhom+jl ) = r2dns(:,jl,2)
          END DO
-      CASE ( 1 ) 
+      CASE ( 1 )
          DO jl = 1, iprecj
             pt2d(:,jl-jprj) = r2dsn(:,jl,2)
@@ -1487,5 +1487,5 @@
       !!----------------------------------------------------------------------
       !!                  ***  routine mppsend  ***
-      !!                   
+      !!
       !! ** Purpose :   Send messag passing array
       !!
@@ -1523,5 +1523,5 @@
       INTEGER , INTENT(in   ) ::   kbytes     ! suze of the array pmess
       INTEGER , INTENT(in   ) ::   ktyp       ! Tag of the recevied message
-      INTEGER, OPTIONAL, INTENT(in) :: ksource    ! source process number 
+      INTEGER, OPTIONAL, INTENT(in) :: ksource    ! source process number
       !!
       INTEGER :: istatus(mpi_status_size)
@@ -1531,5 +1531,5 @@
       !
 
-      ! If a specific process number has been passed to the receive call, 
+      ! If a specific process number has been passed to the receive call,
       ! use that one. Default is to use mpi_any_source
       use_source=mpi_any_source
@@ -1546,6 +1546,6 @@
       !!----------------------------------------------------------------------
       !!                   ***  routine mppgather  ***
-      !!                   
-      !! ** Purpose :   Transfert between a local subdomain array and a work 
+      !!
+      !! ** Purpose :   Transfert between a local subdomain array and a work
       !!     array which is distributed following the vertical level.
       !!
@@ -1560,5 +1560,5 @@
       itaille = jpi * jpj
       CALL mpi_gather( ptab, itaille, mpi_double_precision, pio, itaille     ,   &
-         &                            mpi_double_precision, kp , mpi_comm_opa, ierror ) 
+         &                            mpi_double_precision, kp , mpi_comm_opa, ierror )
       !
    END SUBROUTINE mppgather
@@ -1569,5 +1569,5 @@
       !!                  ***  routine mppscatter  ***
       !!
-      !! ** Purpose :   Transfert between awork array which is distributed 
+      !! ** Purpose :   Transfert between awork array which is distributed
       !!      following the vertical level and the local subdomain array.
       !!
@@ -1591,5 +1591,5 @@
       !!----------------------------------------------------------------------
       !!                  ***  routine mppmax_a_int  ***
-      !! 
+      !!
       !! ** Purpose :   Find maximum value in an integer layout array
       !!
@@ -1597,5 +1597,5 @@
       INTEGER , INTENT(in   )                  ::   kdim   ! size of array
       INTEGER , INTENT(inout), DIMENSION(kdim) ::   ktab   ! input array
-      INTEGER , INTENT(in   ), OPTIONAL        ::   kcom   ! 
+      INTEGER , INTENT(in   ), OPTIONAL        ::   kcom   !
       !!
       INTEGER :: ierror, localcomm   ! temporary integer
@@ -1622,9 +1622,9 @@
       INTEGER, INTENT(inout)           ::   ktab      ! ???
       INTEGER, INTENT(in   ), OPTIONAL ::   kcom      ! ???
-      !! 
+      !!
       INTEGER ::   ierror, iwork, localcomm   ! temporary integer
       !!----------------------------------------------------------------------
       !
-      localcomm = mpi_comm_opa 
+      localcomm = mpi_comm_opa
       IF( PRESENT(kcom) )   localcomm = kcom
       !
@@ -1639,5 +1639,5 @@
       !!----------------------------------------------------------------------
       !!                  ***  routine mppmin_a_int  ***
-      !! 
+      !!
       !! ** Purpose :   Find minimum value in an integer layout array
       !!
@@ -1687,5 +1687,5 @@
       !!----------------------------------------------------------------------
       !!                  ***  routine mppsum_a_int  ***
-      !!                    
+      !!
       !! ** Purpose :   Global integer sum, 1D array case
       !!
@@ -1708,10 +1708,10 @@
       !!----------------------------------------------------------------------
       !!                 ***  routine mppsum_int  ***
-      !!                  
+      !!
       !! ** Purpose :   Global integer sum
       !!
       !!----------------------------------------------------------------------
       INTEGER, INTENT(inout) ::   ktab
-      !! 
+      !!
       INTEGER :: ierror, iwork
       !!----------------------------------------------------------------------
@@ -1727,5 +1727,5 @@
       !!----------------------------------------------------------------------
       !!                 ***  routine mppmax_a_real  ***
-      !!                  
+      !!
       !! ** Purpose :   Maximum
       !!
@@ -1751,5 +1751,5 @@
       !!----------------------------------------------------------------------
       !!                  ***  routine mppmax_real  ***
-      !!                    
+      !!
       !! ** Purpose :   Maximum
       !!
@@ -1762,5 +1762,5 @@
       !!----------------------------------------------------------------------
       !
-      localcomm = mpi_comm_opa 
+      localcomm = mpi_comm_opa
       IF( PRESENT(kcom) )   localcomm = kcom
       !
@@ -1774,5 +1774,5 @@
       !!----------------------------------------------------------------------
       !!                 ***  routine mppmin_a_real  ***
-      !!                  
+      !!
       !! ** Purpose :   Minimum of REAL, array case
       !!
@@ -1786,5 +1786,5 @@
       !!-----------------------------------------------------------------------
       !
-      localcomm = mpi_comm_opa 
+      localcomm = mpi_comm_opa
       IF( PRESENT(kcom) ) localcomm = kcom
       !
@@ -1798,9 +1798,9 @@
       !!----------------------------------------------------------------------
       !!                  ***  routine mppmin_real  ***
-      !! 
+      !!
       !! ** Purpose :   minimum of REAL, scalar case
       !!
       !!-----------------------------------------------------------------------
-      REAL(wp), INTENT(inout)           ::   ptab        ! 
+      REAL(wp), INTENT(inout)           ::   ptab        !
       INTEGER , INTENT(in   ), OPTIONAL :: kcom
       !!
@@ -1810,5 +1810,5 @@
       !!-----------------------------------------------------------------------
       !
-      localcomm = mpi_comm_opa 
+      localcomm = mpi_comm_opa
       IF( PRESENT(kcom) )   localcomm = kcom
       !
@@ -1822,5 +1822,5 @@
       !!----------------------------------------------------------------------
       !!                  ***  routine mppsum_a_real  ***
-      !! 
+      !!
       !! ** Purpose :   global sum, REAL ARRAY argument case
       !!
@@ -1831,9 +1831,9 @@
       !!
       INTEGER                   ::   ierror    ! temporary integer
-      INTEGER                   ::   localcomm 
-      REAL(wp), DIMENSION(kdim) ::   zwork     ! temporary workspace 
+      INTEGER                   ::   localcomm
+      REAL(wp), DIMENSION(kdim) ::   zwork     ! temporary workspace
       !!-----------------------------------------------------------------------
       !
-      localcomm = mpi_comm_opa 
+      localcomm = mpi_comm_opa
       IF( PRESENT(kcom) )   localcomm = kcom
       !
@@ -1847,5 +1847,5 @@
       !!----------------------------------------------------------------------
       !!                  ***  routine mppsum_real  ***
-      !!              
+      !!
       !! ** Purpose :   global sum, SCALAR argument case
       !!
@@ -1854,9 +1854,9 @@
       INTEGER , INTENT(in   ), OPTIONAL ::   kcom
       !!
-      INTEGER  ::   ierror, localcomm 
+      INTEGER  ::   ierror, localcomm
       REAL(wp) ::   zwork
       !!-----------------------------------------------------------------------
       !
-      localcomm = mpi_comm_opa 
+      localcomm = mpi_comm_opa
       IF( PRESENT(kcom) ) localcomm = kcom
       !
@@ -1891,6 +1891,6 @@
 
    END SUBROUTINE mppsum_realdd
-  
-  
+
+
    SUBROUTINE mppsum_a_realdd( ytab, kdim, kcom )
       !!----------------------------------------------------------------------
@@ -1918,5 +1918,5 @@
 
    END SUBROUTINE mppsum_a_realdd
-   
+
    SUBROUTINE mpp_minloc2d( ptab, pmask, pmin, ki,kj )
       !!------------------------------------------------------------------------
@@ -2013,5 +2013,5 @@
       REAL(wp)                     , INTENT(  out) ::   pmax     ! Global maximum of ptab
       INTEGER                      , INTENT(  out) ::   ki, kj   ! index of maximum in global frame
-      !!  
+      !!
       INTEGER  :: ierror
       INTEGER, DIMENSION (2)   ::   ilocs
@@ -2052,5 +2052,5 @@
       REAL(wp)                         , INTENT(  out) ::   pmax         ! Global maximum of ptab
       INTEGER                          , INTENT(  out) ::   ki, kj, kk   ! index of maximum in global frame
-      !!   
+      !!
       REAL(wp) :: zmax   ! local maximum
       REAL(wp), DIMENSION(2,1) ::   zain, zaout
@@ -2082,5 +2082,5 @@
       !!----------------------------------------------------------------------
       !!                  ***  routine mppsync  ***
-      !!                   
+      !!
       !! ** Purpose :   Massively parallel processors, synchroneous
       !!
@@ -2097,5 +2097,5 @@
       !!----------------------------------------------------------------------
       !!                  ***  routine mppstop  ***
-      !!                   
+      !!
       !! ** purpose :   Stop massively parallel processors method
       !!
@@ -2113,5 +2113,5 @@
       !!----------------------------------------------------------------------
       !!                  ***  routine mppobc  ***
-      !! 
+      !!
       !! ** Purpose :   Message passing manadgement for open boundary
       !!     conditions array
@@ -2124,5 +2124,5 @@
       !!                    nbondi : mark for "east-west local boundary"
       !!                    nbondj : mark for "north-south local boundary"
-      !!                    noea   : number for local neighboring processors 
+      !!                    noea   : number for local neighboring processors
       !!                    nowe   : number for local neighboring processors
       !!                    noso   : number for local neighboring processors
@@ -2307,5 +2307,5 @@
       !
    END SUBROUTINE mppobc
-   
+
 
    SUBROUTINE mpp_comm_free( kcom )
@@ -2366,10 +2366,10 @@
       kice = 0
       DO jjproc = 1, jpnij
-         IF( jjproc == narea .AND. pindic .GT. 0 )   kice(jjproc) = 1    
+         IF( jjproc == narea .AND. pindic .GT. 0 )   kice(jjproc) = 1
       END DO
       !
       zwork = 0
       CALL MPI_ALLREDUCE( kice, zwork, jpnij, mpi_integer, mpi_sum, mpi_comm_opa, ierr )
-      ndim_rank_ice = SUM( zwork )          
+      ndim_rank_ice = SUM( zwork )
 
       ! Allocate the right size to nrank_north
@@ -2377,10 +2377,10 @@
       ALLOCATE( nrank_ice(ndim_rank_ice) )
       !
-      ii = 0     
+      ii = 0
       nrank_ice = 0
       DO jjproc = 1, jpnij
          IF( zwork(jjproc) == 1) THEN
             ii = ii + 1
-            nrank_ice(ii) = jjproc -1 
+            nrank_ice(ii) = jjproc -1
          ENDIF
       END DO
@@ -2464,10 +2464,10 @@
          IF (ALLOCATED (nrank_znl)) DEALLOCATE(nrank_znl)
          ALLOCATE(nrank_znl(ndim_rank_znl))
-         ii = 0     
+         ii = 0
          nrank_znl (:) = 0
          DO jproc=1,jpnij
             IF ( kwork(jproc) == njmpp) THEN
                ii = ii + 1
-               nrank_znl(ii) = jproc -1 
+               nrank_znl(ii) = jproc -1
             ENDIF
          END DO
@@ -2493,5 +2493,5 @@
 
       ! Determines if processor if the first (starting from i=1) on the row
-      IF ( jpni == 1 ) THEN 
+      IF ( jpni == 1 ) THEN
          l_znl_root = .TRUE.
       ELSE
@@ -2511,5 +2511,5 @@
       !!               ***  routine mpp_ini_north  ***
       !!
-      !! ** Purpose :   Initialize special communicator for north folding 
+      !! ** Purpose :   Initialize special communicator for north folding
       !!      condition together with global variables needed in the mpp folding
       !!
@@ -2572,9 +2572,9 @@
       !!                   ***  routine mpp_lbc_north_3d  ***
       !!
-      !! ** Purpose :   Ensure proper north fold horizontal bondary condition 
+      !! ** Purpose :   Ensure proper north fold horizontal bondary condition
       !!              in mpp configuration in case of jpn1 > 1
       !!
       !! ** Method  :   North fold condition and mpp with more than one proc
-      !!              in i-direction require a specific treatment. We gather 
+      !!              in i-direction require a specific treatment. We gather
       !!              the 4 northern lines of the global domain on 1 processor
       !!              and apply lbc north-fold on this sub array. Then we
@@ -2585,5 +2585,5 @@
       CHARACTER(len=1)                , INTENT(in   ) ::   cd_type   ! nature of pt3d grid-points
       !                                                              !   = T ,  U , V , F or W  gridpoints
-      REAL(wp)                        , INTENT(in   ) ::   psgn      ! = -1. the sign change across the north fold 
+      REAL(wp)                        , INTENT(in   ) ::   psgn      ! = -1. the sign change across the north fold
       !!                                                             ! =  1. , the sign is kept
       INTEGER ::   ji, jj, jr
@@ -2594,5 +2594,5 @@
       INTEGER, DIMENSION(MPI_STATUS_SIZE)    ::   ml_stat            ! for mpi_isend when avoiding mpi_allgather
       !!----------------------------------------------------------------------
-      !   
+      !
       ijpj   = 4
       ityp = -1
@@ -2609,5 +2609,5 @@
       IF ( l_north_nogather ) THEN
          !
-         ! Avoid the use of mpi_allgather by exchanging only with the processes already identified 
+         ! Avoid the use of mpi_allgather by exchanging only with the processes already identified
          ! (in nemo_northcomms) as being  involved in this process' northern boundary exchange
          !
@@ -2634,5 +2634,5 @@
                ityp = 5
             CASE DEFAULT
-               ityp = -1                    ! Set a default value for unsupported types which 
+               ityp = -1                    ! Set a default value for unsupported types which
                                             ! will cause a fallback to the mpi_allgather method
          END SELECT
@@ -2683,7 +2683,7 @@
       ! The ztab array has been either:
       !  a. Fully populated by the mpi_allgather operation or
-      !  b. Had the active points for this domain and northern neighbours populated 
+      !  b. Had the active points for this domain and northern neighbours populated
       !     by peer to peer exchanges
-      ! Either way the array may be folded by lbc_nfd and the result for the span of 
+      ! Either way the array may be folded by lbc_nfd and the result for the span of
       ! this domain will be identical.
       !
@@ -2704,9 +2704,9 @@
       !!                   ***  routine mpp_lbc_north_2d  ***
       !!
-      !! ** Purpose :   Ensure proper north fold horizontal bondary condition 
+      !! ** Purpose :   Ensure proper north fold horizontal bondary condition
       !!              in mpp configuration in case of jpn1 > 1 (for 2d array )
       !!
       !! ** Method  :   North fold condition and mpp with more than one proc
-      !!              in i-direction require a specific treatment. We gather 
+      !!              in i-direction require a specific treatment. We gather
       !!              the 4 northern lines of the global domain on 1 processor
       !!              and apply lbc north-fold on this sub array. Then we
@@ -2717,5 +2717,5 @@
       CHARACTER(len=1)            , INTENT(in   ) ::   cd_type   ! nature of pt3d grid-points
       !                                                          !   = T ,  U , V , F or W  gridpoints
-      REAL(wp)                    , INTENT(in   ) ::   psgn      ! = -1. the sign change across the north fold 
+      REAL(wp)                    , INTENT(in   ) ::   psgn      ! = -1. the sign change across the north fold
       !!                                                             ! =  1. , the sign is kept
       INTEGER ::   ji, jj, jr
@@ -2741,5 +2741,5 @@
       IF ( l_north_nogather ) THEN
          !
-         ! Avoid the use of mpi_allgather by exchanging only with the processes already identified 
+         ! Avoid the use of mpi_allgather by exchanging only with the processes already identified
          ! (in nemo_northcomms) as being  involved in this process' northern boundary exchange
          !
@@ -2766,5 +2766,5 @@
                ityp = 5
             CASE DEFAULT
-               ityp = -1                    ! Set a default value for unsupported types which 
+               ityp = -1                    ! Set a default value for unsupported types which
                                             ! will cause a fallback to the mpi_allgather method
          END SELECT
@@ -2816,7 +2816,7 @@
       ! The ztab array has been either:
       !  a. Fully populated by the mpi_allgather operation or
-      !  b. Had the active points for this domain and northern neighbours populated 
+      !  b. Had the active points for this domain and northern neighbours populated
       !     by peer to peer exchanges
-      ! Either way the array may be folded by lbc_nfd and the result for the span of 
+      ! Either way the array may be folded by lbc_nfd and the result for the span of
       ! this domain will be identical.
       !
@@ -2838,12 +2838,12 @@
       !!                   ***  routine mpp_lbc_north_2d  ***
       !!
-      !! ** Purpose :   Ensure proper north fold horizontal bondary condition 
-      !!              in mpp configuration in case of jpn1 > 1 and for 2d 
+      !! ** Purpose :   Ensure proper north fold horizontal bondary condition
+      !!              in mpp configuration in case of jpn1 > 1 and for 2d
       !!              array with outer extra halo
       !!
       !! ** Method  :   North fold condition and mpp with more than one proc
-      !!              in i-direction require a specific treatment. We gather 
-      !!              the 4+2*jpr2dj northern lines of the global domain on 1 
-      !!              processor and apply lbc north-fold on this sub array. 
+      !!              in i-direction require a specific treatment. We gather
+      !!              the 4+2*jpr2dj northern lines of the global domain on 1
+      !!              processor and apply lbc north-fold on this sub array.
       !!              Then we scatter the north fold array back to the processors.
       !!
@@ -2852,5 +2852,5 @@
       CHARACTER(len=1)                                            , INTENT(in   ) ::   cd_type  ! nature of pt3d grid-points
       !                                                                                         !   = T ,  U , V , F or W -points
-      REAL(wp)                                                    , INTENT(in   ) ::   psgn     ! = -1. the sign change across the  
+      REAL(wp)                                                    , INTENT(in   ) ::   psgn     ! = -1. the sign change across the
       !!                                                                                        ! north fold, =  1. otherwise
       INTEGER ::   ji, jj, jr
@@ -2895,5 +2895,5 @@
       !! Scatter back to pt2d
       DO jj = nlcj - ijpj + 1 , nlcj +jpr2dj
-      ij  = ij +1 
+      ij  = ij +1
          DO ji= 1, nlci
             pt2d(ji,jj) = ztab_e(ji+nimpp-1,ij)
@@ -3339,9 +3339,9 @@
       !! ** Method  :: define buffer size in namelist, if 0 no buffer attachment
       !!            but classical mpi_init
-      !! 
-      !! History :: 01/11 :: IDRIS initial version for IBM only  
+      !!
+      !! History :: 01/11 :: IDRIS initial version for IBM only
       !!            08/04 :: R. Benshila, generalisation
       !!---------------------------------------------------------------------
-      CHARACTER(len=*),DIMENSION(:), INTENT(  out) ::   ldtxt 
+      CHARACTER(len=*),DIMENSION(:), INTENT(  out) ::   ldtxt
       INTEGER                      , INTENT(inout) ::   ksft
       INTEGER                      , INTENT(  out) ::   code
@@ -3352,7 +3352,7 @@
       CALL mpi_initialized( mpi_was_called, code )      ! MPI initialization
       IF ( code /= MPI_SUCCESS ) THEN
-         DO ji = 1, SIZE(ldtxt) 
+         DO ji = 1, SIZE(ldtxt)
             IF( TRIM(ldtxt(ji)) /= '' )   WRITE(*,*) ldtxt(ji)      ! control print of mynode
-         END DO         
+         END DO
          WRITE(*, cform_err)
          WRITE(*, *) ' lib_mpp: Error in routine mpi_initialized'
@@ -3364,5 +3364,5 @@
          CALL mpi_comm_dup( mpi_comm_world, mpi_comm_opa, code )
          IF ( code /= MPI_SUCCESS ) THEN
-            DO ji = 1, SIZE(ldtxt) 
+            DO ji = 1, SIZE(ldtxt)
                IF( TRIM(ldtxt(ji)) /= '' )   WRITE(*,*) ldtxt(ji)      ! control print of mynode
             END DO
@@ -3377,6 +3377,6 @@
          ! Buffer allocation and attachment
          ALLOCATE( tampon(nn_buffer), stat = ierr )
-         IF( ierr /= 0 ) THEN 
-            DO ji = 1, SIZE(ldtxt) 
+         IF( ierr /= 0 ) THEN
+            DO ji = 1, SIZE(ldtxt)
                IF( TRIM(ldtxt(ji)) /= '' )   WRITE(*,*) ldtxt(ji)      ! control print of mynode
             END DO
@@ -3457,5 +3457,5 @@
    FUNCTION mynode( ldtxt, kumnam, kstop, localComm ) RESULT (function_value)
       INTEGER, OPTIONAL            , INTENT(in   ) ::   localComm
-      CHARACTER(len=*),DIMENSION(:) ::   ldtxt 
+      CHARACTER(len=*),DIMENSION(:) ::   ldtxt
       INTEGER ::   kumnam, kstop
       IF( PRESENT( localComm ) .OR. .NOT.PRESENT( localComm ) )   function_value = 0
@@ -3469,5 +3469,5 @@
       REAL   , DIMENSION(:) :: parr
       INTEGER               :: kdim
-      INTEGER, OPTIONAL     :: kcom 
+      INTEGER, OPTIONAL     :: kcom
       WRITE(*,*) 'mpp_sum_as: You should not have seen this print! error?', kdim, parr(1), kcom
    END SUBROUTINE mpp_sum_as
@@ -3476,5 +3476,5 @@
       REAL   , DIMENSION(:,:) :: parr
       INTEGER               :: kdim
-      INTEGER, OPTIONAL     :: kcom 
+      INTEGER, OPTIONAL     :: kcom
       WRITE(*,*) 'mpp_sum_a2s: You should not have seen this print! error?', kdim, parr(1,1), kcom
    END SUBROUTINE mpp_sum_a2s
@@ -3483,5 +3483,5 @@
       INTEGER, DIMENSION(:) :: karr
       INTEGER               :: kdim
-      INTEGER, OPTIONAL     :: kcom 
+      INTEGER, OPTIONAL     :: kcom
       WRITE(*,*) 'mpp_sum_ai: You should not have seen this print! error?', kdim, karr(1), kcom
    END SUBROUTINE mpp_sum_ai
@@ -3489,5 +3489,5 @@
    SUBROUTINE mpp_sum_s( psca, kcom )            ! Dummy routine
       REAL                  :: psca
-      INTEGER, OPTIONAL     :: kcom 
+      INTEGER, OPTIONAL     :: kcom
       WRITE(*,*) 'mpp_sum_s: You should not have seen this print! error?', psca, kcom
    END SUBROUTINE mpp_sum_s
@@ -3495,5 +3495,5 @@
    SUBROUTINE mpp_sum_i( kint, kcom )            ! Dummy routine
       integer               :: kint
-      INTEGER, OPTIONAL     :: kcom 
+      INTEGER, OPTIONAL     :: kcom
       WRITE(*,*) 'mpp_sum_i: You should not have seen this print! error?', kint, kcom
    END SUBROUTINE mpp_sum_i
@@ -3504,5 +3504,5 @@
       WRITE(*,*) 'mppsum_realdd: You should not have seen this print! error?', ytab
    END SUBROUTINE mppsum_realdd
- 
+
    SUBROUTINE mppsum_a_realdd( ytab, kdim, kcom )
       INTEGER , INTENT( in )                        ::   kdim      ! size of ytab
@@ -3515,5 +3515,5 @@
       REAL   , DIMENSION(:) :: parr
       INTEGER               :: kdim
-      INTEGER, OPTIONAL     :: kcom 
+      INTEGER, OPTIONAL     :: kcom
       WRITE(*,*) 'mppmax_a_real: You should not have seen this print! error?', kdim, parr(1), kcom
    END SUBROUTINE mppmax_a_real
@@ -3521,5 +3521,5 @@
    SUBROUTINE mppmax_real( psca, kcom )
       REAL                  :: psca
-      INTEGER, OPTIONAL     :: kcom 
+      INTEGER, OPTIONAL     :: kcom
       WRITE(*,*) 'mppmax_real: You should not have seen this print! error?', psca, kcom
    END SUBROUTINE mppmax_real
@@ -3528,5 +3528,5 @@
       REAL   , DIMENSION(:) :: parr
       INTEGER               :: kdim
-      INTEGER, OPTIONAL     :: kcom 
+      INTEGER, OPTIONAL     :: kcom
       WRITE(*,*) 'mppmin_a_real: You should not have seen this print! error?', kdim, parr(1), kcom
    END SUBROUTINE mppmin_a_real
@@ -3534,5 +3534,5 @@
    SUBROUTINE mppmin_real( psca, kcom )
       REAL                  :: psca
-      INTEGER, OPTIONAL     :: kcom 
+      INTEGER, OPTIONAL     :: kcom
       WRITE(*,*) 'mppmin_real: You should not have seen this print! error?', psca, kcom
    END SUBROUTINE mppmin_real
@@ -3541,5 +3541,5 @@
       INTEGER, DIMENSION(:) :: karr
       INTEGER               :: kdim
-      INTEGER, OPTIONAL     :: kcom 
+      INTEGER, OPTIONAL     :: kcom
       WRITE(*,*) 'mppmax_a_int: You should not have seen this print! error?', kdim, karr(1), kcom
    END SUBROUTINE mppmax_a_int
@@ -3547,5 +3547,5 @@
    SUBROUTINE mppmax_int( kint, kcom)
       INTEGER               :: kint
-      INTEGER, OPTIONAL     :: kcom 
+      INTEGER, OPTIONAL     :: kcom
       WRITE(*,*) 'mppmax_int: You should not have seen this print! error?', kint, kcom
    END SUBROUTINE mppmax_int
@@ -3554,5 +3554,5 @@
       INTEGER, DIMENSION(:) :: karr
       INTEGER               :: kdim
-      INTEGER, OPTIONAL     :: kcom 
+      INTEGER, OPTIONAL     :: kcom
       WRITE(*,*) 'mppmin_a_int: You should not have seen this print! error?', kdim, karr(1), kcom
    END SUBROUTINE mppmin_a_int
@@ -3560,5 +3560,5 @@
    SUBROUTINE mppmin_int( kint, kcom )
       INTEGER               :: kint
-      INTEGER, OPTIONAL     :: kcom 
+      INTEGER, OPTIONAL     :: kcom
       WRITE(*,*) 'mppmin_int: You should not have seen this print! error?', kint, kcom
    END SUBROUTINE mppmin_int
@@ -3647,5 +3647,5 @@
       !!                  ***  ROUTINE  stop_opa  ***
       !!
-      !! ** Purpose :   print in ocean.outpput file a error message and 
+      !! ** Purpose :   print in ocean.outpput file a error message and
       !!                increment the error number (nstop) by one.
       !!----------------------------------------------------------------------
@@ -3654,5 +3654,5 @@
       !!----------------------------------------------------------------------
       !
-      nstop = nstop + 1 
+      nstop = nstop + 1
       IF(lwp) THEN
          WRITE(numout,cform_err)
@@ -3686,5 +3686,5 @@
       !!                  ***  ROUTINE  stop_warn  ***
       !!
-      !! ** Purpose :   print in ocean.outpput file a error message and 
+      !! ** Purpose :   print in ocean.outpput file a error message and
       !!                increment the warning number (nwarn) by one.
       !!----------------------------------------------------------------------
@@ -3692,6 +3692,6 @@
       CHARACTER(len=*), INTENT(in), OPTIONAL ::  cd6, cd7, cd8, cd9, cd10
       !!----------------------------------------------------------------------
-      ! 
-      nwarn = nwarn + 1 
+      !
+      nwarn = nwarn + 1
       IF(lwp) THEN
          WRITE(numout,cform_war)
@@ -3779,5 +3779,5 @@
          STOP 'ctl_opn bad opening'
       ENDIF
-      
+
    END SUBROUTINE ctl_opn
 
@@ -3789,5 +3789,5 @@
       !! ** Purpose :   return the index of an unused logical unit
       !!----------------------------------------------------------------------
-      LOGICAL :: llopn 
+      LOGICAL :: llopn
       !!----------------------------------------------------------------------
       !
Index: branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/OPA_SRC/OBC/obcdta.F90
===================================================================
--- branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/OPA_SRC/OBC/obcdta.F90	(revision 3759)
+++ branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/OPA_SRC/OBC/obcdta.F90	(revision 3764)
@@ -121,6 +121,6 @@
       ALLOCATE( ltemsk(jpj,jpk) , luemsk(jpj,jpk) , lvemsk(jpj,jpk) ,     &
          &      ltwmsk(jpj,jpk) , luwmsk(jpj,jpk) , lvwmsk(jpj,jpk) ,     &
-         &      ltnmsk(jpj,jpk) , lunmsk(jpj,jpk) , lvnmsk(jpj,jpk) ,     &
-         &      ltsmsk(jpj,jpk) , lusmsk(jpj,jpk) , lvsmsk(jpj,jpk) , STAT=ierr(2) )
+         &      ltnmsk(jpi,jpk) , lunmsk(jpi,jpk) , lvnmsk(jpi,jpk) ,     &
+         &      ltsmsk(jpi,jpk) , lusmsk(jpi,jpk) , lvsmsk(jpi,jpk) , STAT=ierr(2) )
 
       obc_dta_alloc = MAXVAL( ierr )
Index: branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/OPA_SRC/SBC/fldread.F90
===================================================================
--- branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/OPA_SRC/SBC/fldread.F90	(revision 3759)
+++ branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/OPA_SRC/SBC/fldread.F90	(revision 3764)
@@ -854,5 +854,5 @@
          IF( LEN( TRIM(sdf_n(jf)%wname) ) > 0 )   sdf(jf)%wgtname = TRIM( cdir )//TRIM( sdf_n(jf)%wname )
          sdf(jf)%vcomp   = sdf_n(jf)%vcomp
-         sdf(jf)%rotn    = .FALSE.
+         sdf(jf)%rotn    = .TRUE.
       END DO
 
Index: branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/OPA_SRC/SBC/sbcdcy.F90
===================================================================
--- branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/OPA_SRC/SBC/sbcdcy.F90	(revision 3759)
+++ branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/OPA_SRC/SBC/sbcdcy.F90	(revision 3764)
@@ -105,6 +105,6 @@
          rcc(:,:) = zconvrad * glamt(:,:) - rpi
          ! time of midday
-         rtmd(:,:) = 0.5 - glamt(:,:) / 360.
-         rtmd(:,:) = MOD( (rtmd(:,:) + 1.), 1. )
+         rtmd(:,:) = 0.5_wp - glamt(:,:) / 360._wp
+         rtmd(:,:) = MOD( (rtmd(:,:) + 1._wp) , 1._wp)
       ENDIF
 
@@ -121,5 +121,5 @@
          zdsws = REAL(11 + nday_year, wp)
          ! declination of the earths orbit
-         zdecrad = (-23.5 * zconvrad) * COS( zdsws * ztwopi / REAL(nyear_len(1),wp) )
+         zdecrad = (-23.5_wp * zconvrad) * COS( zdsws * ztwopi / REAL(nyear_len(1),wp) )
          ! Compute A and B needed to compute the time integral of the diurnal cycle
 
@@ -138,10 +138,10 @@
          DO jj = 1, jpj
             DO ji = 1, jpi
-               IF ( ABS(rab(ji,jj)) < 1 ) THEN         ! day duration is less than 24h
+               IF ( ABS(rab(ji,jj)) < 1._wp ) THEN         ! day duration is less than 24h
          ! When is it night?
                   ztx = zinvtwopi * (ACOS(rab(ji,jj)) - rcc(ji,jj))
                   ztest = -rbb(ji,jj) * SIN( rcc(ji,jj) + ztwopi * ztx )
          ! is it dawn or dusk?
-                  IF ( ztest > 0 ) THEN
+                  IF ( ztest > 0._wp ) THEN
                      rdawn(ji,jj) = ztx
                      rdusk(ji,jj) = rtmd(ji,jj) + ( rtmd(ji,jj) - rdawn(ji,jj) )
@@ -151,5 +151,5 @@
                   ENDIF
                ELSE
-                  rdawn(ji,jj) = rtmd(ji,jj) + 0.5
+                  rdawn(ji,jj) = rtmd(ji,jj) + 0.5_wp
                   rdusk(ji,jj) = rdawn(ji,jj)
                ENDIF
@@ -158,23 +158,30 @@
          rdawn(:,:) = MOD( (rdawn(:,:) + 1._wp), 1._wp )
          rdusk(:,:) = MOD( (rdusk(:,:) + 1._wp), 1._wp )
-         !     2.2 Compute the scalling function:
-         !         S* = the inverse of the time integral of the diurnal cycle from dawm to dusk
+         !     2.2 Compute the scaling function:
+         !         S* = the inverse of the time integral of the diurnal cycle from dawn to dusk
+         !         Avoid possible infinite scaling factor, associated with very short daylight
+         !         periods, by ignoring periods less than 1/1000th of a day (ticket #1040)
          DO jj = 1, jpj
             DO ji = 1, jpi
-               IF ( ABS(rab(ji,jj)) < 1 ) THEN         ! day duration is less than 24h
+               IF ( ABS(rab(ji,jj)) < 1._wp ) THEN         ! day duration is less than 24h
+                  rscal(ji,jj) = 0.0_wp
                   IF ( rdawn(ji,jj) < rdusk(ji,jj) ) THEN      ! day time in one part
-                     rscal(ji,jj) = fintegral(rdawn(ji,jj), rdusk(ji,jj), raa(ji,jj), rbb(ji,jj), rcc(ji,jj)) 
-                     rscal(ji,jj) = 1. / rscal(ji,jj)
+                     IF( (rdusk(ji,jj) - rdawn(ji,jj) ) .ge. 0.001_wp ) THEN
+                       rscal(ji,jj) = fintegral(rdawn(ji,jj), rdusk(ji,jj), raa(ji,jj), rbb(ji,jj), rcc(ji,jj)) 
+                       rscal(ji,jj) = 1._wp / rscal(ji,jj)
+                     ENDIF
                   ELSE                                         ! day time in two parts
-                     rscal(ji,jj) = fintegral(0., rdusk(ji,jj), raa(ji,jj), rbb(ji,jj), rcc(ji,jj))   &
-                        &         + fintegral(rdawn(ji,jj), 1., raa(ji,jj), rbb(ji,jj), rcc(ji,jj)) 
-                     rscal(ji,jj) = 1. / rscal(ji,jj)
+                     IF( (rdusk(ji,jj) + (1._wp - rdawn(ji,jj)) ) .ge. 0.001_wp ) THEN
+                       rscal(ji,jj) = fintegral(0._wp, rdusk(ji,jj), raa(ji,jj), rbb(ji,jj), rcc(ji,jj))   &
+                          &         + fintegral(rdawn(ji,jj), 1._wp, raa(ji,jj), rbb(ji,jj), rcc(ji,jj)) 
+                       rscal(ji,jj) = 1. / rscal(ji,jj)
+                     ENDIF
                   ENDIF
                ELSE
                   IF ( raa(ji,jj) > rbb(ji,jj) ) THEN         ! 24h day
-                     rscal(ji,jj) = fintegral(0., 1., raa(ji,jj), rbb(ji,jj), rcc(ji,jj)) 
-                     rscal(ji,jj) = 1. / rscal(ji,jj)
+                     rscal(ji,jj) = fintegral(0._wp, 1._wp, raa(ji,jj), rbb(ji,jj), rcc(ji,jj)) 
+                     rscal(ji,jj) = 1._wp / rscal(ji,jj)
                   ELSE                                          ! No day
-                     rscal(ji,jj) = 0.e0
+                     rscal(ji,jj) = 0.0_wp
                   ENDIF
                ENDIF
@@ -193,5 +200,5 @@
          DO ji = 1, jpi
             ztmpm = 0.0
-            IF( ABS(rab(ji,jj)) < 1 ) THEN         ! day duration is less than 24h
+            IF( ABS(rab(ji,jj)) < 1. ) THEN         ! day duration is less than 24h
                !
                IF( rdawn(ji,jj) < rdusk(ji,jj) ) THEN       ! day time in one part
@@ -227,5 +234,5 @@
                   !
                ELSE                                         ! No day
-                  zqsrout(ji,jj) = 0.e0
+                  zqsrout(ji,jj) = 0.0_wp
                   imask_night(ji,jj) = 1
                ENDIF
Index: branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/OPA_SRC/SBC/sbcmod.F90
===================================================================
--- branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/OPA_SRC/SBC/sbcmod.F90	(revision 3759)
+++ branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/OPA_SRC/SBC/sbcmod.F90	(revision 3764)
@@ -218,14 +218,9 @@
          IF( nsbc ==  6 )   WRITE(numout,*) '              MFS Bulk formulation'
       ENDIF
-
-      !!----------------------------------------------------------------------
-      !!   Other SBC modules to initialise come here
-      !!----------------------------------------------------------------------
-
-      CALL sbc_ssm_init
-
-      IF( nn_ice == 4 )   CALL cice_sbc_init (nsbc)
-      !
-      !!----------------------------------------------------------------------
+      !
+      IF( ln_ssr      )   CALL sbc_ssr_init               ! Sea-Surface Restoring initialisation
+      !
+      IF( nn_ice == 4 )   CALL cice_sbc_init( nsbc )      ! CICE initialisation
+      !
    END SUBROUTINE sbc_init
 
@@ -397,13 +392,12 @@
    END SUBROUTINE sbc
 
+
    SUBROUTINE sbc_final
       !!---------------------------------------------------------------------
       !!                    ***  ROUTINE sbc_final  ***
+      !!
+      !! ** Purpose :   Finalize CICE (if used)
       !!---------------------------------------------------------------------
-
-      !-----------------------------------------------------------------
-      ! Finalize CICE (if used)
-      !-----------------------------------------------------------------
-
+      !
       IF( nn_ice == 4 )   CALL cice_sbc_final
       !
Index: branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/OPA_SRC/SBC/sbcrnf.F90
===================================================================
--- branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/OPA_SRC/SBC/sbcrnf.F90	(revision 3759)
+++ branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/OPA_SRC/SBC/sbcrnf.F90	(revision 3764)
@@ -6,5 +6,5 @@
    !! History :  OPA  ! 2000-11  (R. Hordoir, E. Durand)  NetCDF FORMAT
    !!   NEMO     1.0  ! 2002-09  (G. Madec)  F90: Free form and module
-   !!            3.0  ! 2006-07  (G. Madec)  Surface module 
+   !!            3.0  ! 2006-07  (G. Madec)  Surface module
    !!            3.2  ! 2009-04  (B. Lemaire)  Introduce iom_put
    !!            3.3  ! 2010-10  (R. Furner, G. Madec) runoff distributed over ocean levels
@@ -31,15 +31,15 @@
    PUBLIC   sbc_rnf_div   ! routine called in sshwzv module
    PUBLIC   sbc_rnf_alloc ! routine call in sbcmod module
-
+   PUBLIC   sbc_rnf_init  ! (PUBLIC for TAM)
    !                                                     !!* namsbc_rnf namelist *
    CHARACTER(len=100), PUBLIC ::   cn_dir       = './'    !: Root directory for location of ssr files
    LOGICAL           , PUBLIC ::   ln_rnf_depth = .false. !: depth       river runoffs attribute specified in a file
-   LOGICAL           , PUBLIC ::   ln_rnf_tem   = .false. !: temperature river runoffs attribute specified in a file 
-   LOGICAL           , PUBLIC ::   ln_rnf_sal   = .false. !: salinity    river runoffs attribute specified in a file 
+   LOGICAL           , PUBLIC ::   ln_rnf_tem   = .false. !: temperature river runoffs attribute specified in a file
+   LOGICAL           , PUBLIC ::   ln_rnf_sal   = .false. !: salinity    river runoffs attribute specified in a file
    LOGICAL           , PUBLIC ::   ln_rnf_emp   = .false. !: runoffs into a file to be read or already into precipitation
    TYPE(FLD_N)       , PUBLIC ::   sn_rnf                 !: information about the runoff file to be read
    TYPE(FLD_N)       , PUBLIC ::   sn_cnf                 !: information about the runoff mouth file to be read
-   TYPE(FLD_N)                ::   sn_s_rnf               !: information about the salinities of runoff file to be read  
-   TYPE(FLD_N)                ::   sn_t_rnf               !: information about the temperatures of runoff file to be read  
+   TYPE(FLD_N)                ::   sn_s_rnf               !: information about the salinities of runoff file to be read
+   TYPE(FLD_N)                ::   sn_t_rnf               !: information about the temperatures of runoff file to be read
    TYPE(FLD_N)                ::   sn_dep_rnf             !: information about the depth which river inflow affects
    LOGICAL           , PUBLIC ::   ln_rnf_mouth = .false. !: specific treatment in mouths vicinity
@@ -53,6 +53,5 @@
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:)   ::   h_rnf               !: depth of runoff in m
    INTEGER,  PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:)   ::   nk_rnf              !: depth of runoff in model levels
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   rnf_tsc_b, rnf_tsc  !: before and now T & S runoff contents   [K.m/s & PSU.m/s]
-   
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   rnf_tsc_b, rnf_tsc  !: before and now T & S runoff contents   [K.m/s & PSU.m/s]   
 
    TYPE(FLD), PUBLIC, ALLOCATABLE, DIMENSION(:) ::   sf_rnf       ! structure: river runoff (file information, fields read)
@@ -85,8 +84,8 @@
       !!----------------------------------------------------------------------
       !!                  ***  ROUTINE sbc_rnf  ***
-      !!       
+      !!
       !! ** Purpose :   Introduce a climatological run off forcing
       !!
-      !! ** Method  :   Set each river mouth with a monthly climatology 
+      !! ** Method  :   Set each river mouth with a monthly climatology
       !!                provided from different data.
       !!                CAUTION : upward water flux, runoff forced to be < 0
@@ -98,5 +97,5 @@
       INTEGER  ::   ji, jj   ! dummy loop indices
       !!----------------------------------------------------------------------
-      !                                   
+      !
       IF( kt == nit000 )   CALL sbc_rnf_init                           ! Read namelist and allocate structures
 
@@ -113,5 +112,5 @@
          !                                                !-------------------!
          !
-                             CALL fld_read ( kt, nn_fsbc, sf_rnf   )    ! Read Runoffs data and provide it at kt 
+                             CALL fld_read ( kt, nn_fsbc, sf_rnf   )    ! Read Runoffs data and provide it at kt
          IF( ln_rnf_tem  )   CALL fld_read ( kt, nn_fsbc, sf_t_rnf )    ! idem for runoffs temperature if required
          IF( ln_rnf_sal  )   CALL fld_read ( kt, nn_fsbc, sf_s_rnf )    ! idem for runoffs salinity    if required
@@ -132,16 +131,16 @@
             IF( ln_rnf_tem ) THEN                                       ! use runoffs temperature data
                rnf_tsc(:,:,jp_tem) = ( sf_t_rnf(1)%fnow(:,:,1) ) * rnf(:,:) * r1_rau0
-               WHERE( sf_t_rnf(1)%fnow(:,:,1) == -999 )                 ! if missing data value use SST as runoffs temperature  
+               WHERE( sf_t_rnf(1)%fnow(:,:,1) == -999 )                 ! if missing data value use SST as runoffs temperature
                    rnf_tsc(:,:,jp_tem) = sst_m(:,:) * rnf(:,:) * r1_rau0
                END WHERE
             ELSE                                                        ! use SST as runoffs temperature
                rnf_tsc(:,:,jp_tem) = sst_m(:,:) * rnf(:,:) * r1_rau0
-            ENDIF  
-            !                                                           ! use runoffs salinity data 
+            ENDIF
+            !                                                           ! use runoffs salinity data
             IF( ln_rnf_sal )   rnf_tsc(:,:,jp_sal) = ( sf_s_rnf(1)%fnow(:,:,1) ) * rnf(:,:) * r1_rau0
             !                                                           ! else use S=0 for runoffs (done one for all in the init)
             !
             IF( ln_rnf_tem .OR. ln_rnf_sal ) THEN                 ! runoffs as outflow: use ocean SST and SSS
-               WHERE( rnf(:,:) < 0._wp )                                 ! example baltic model when flow is out of domain 
+               WHERE( rnf(:,:) < 0._wp )                                 ! example baltic model when flow is out of domain
                   rnf_tsc(:,:,jp_tem) = sst_m(:,:) * rnf(:,:) * r1_rau0
                   rnf_tsc(:,:,jp_sal) = sss_m(:,:) * rnf(:,:) * r1_rau0
@@ -157,5 +156,5 @@
          !                                             ! ---------------------------------------- !
          IF( ln_rstart .AND.    &                               !* Restart: read in restart file
-            & iom_varid( numror, 'rnf_b', ldstop = .FALSE. ) > 0 ) THEN 
+            & iom_varid( numror, 'rnf_b', ldstop = .FALSE. ) > 0 ) THEN
             IF(lwp) WRITE(numout,*) '          nit000-1 runoff forcing fields red in the restart file'
             CALL iom_get( numror, jpdom_autoglo, 'rnf_b', rnf_b )     ! before runoff
@@ -164,6 +163,6 @@
          ELSE                                                   !* no restart: set from nit000 values
             IF(lwp) WRITE(numout,*) '          nit000-1 runoff forcing fields set to nit000'
-             rnf_b    (:,:  ) = rnf    (:,:  )  
-             rnf_tsc_b(:,:,:) = rnf_tsc(:,:,:)   
+             rnf_b    (:,:  ) = rnf    (:,:  )
+             rnf_tsc_b(:,:,:) = rnf_tsc(:,:,:)
          ENDIF
       ENDIF
@@ -186,9 +185,9 @@
       !!----------------------------------------------------------------------
       !!                  ***  ROUTINE sbc_rnf  ***
-      !!       
+      !!
       !! ** Purpose :   update the horizontal divergence with the runoff inflow
       !!
-      !! ** Method  :   
-      !!                CAUTION : rnf is positive (inflow) decreasing the 
+      !! ** Method  :
+      !!                CAUTION : rnf is positive (inflow) decreasing the
       !!                          divergence and expressed in m/s
       !!
@@ -204,11 +203,11 @@
       !
       IF( ln_rnf_depth ) THEN      !==   runoff distributed over several levels   ==!
-         IF( lk_vvl ) THEN             ! variable volume case 
+         IF( lk_vvl ) THEN             ! variable volume case
             DO jj = 1, jpj                   ! update the depth over which runoffs are distributed
                DO ji = 1, jpi
-                  h_rnf(ji,jj) = 0._wp 
+                  h_rnf(ji,jj) = 0._wp
                   DO jk = 1, nk_rnf(ji,jj)                           ! recalculates h_rnf to be the depth in metres
-                     h_rnf(ji,jj) = h_rnf(ji,jj) + fse3t(ji,jj,jk)   ! to the bottom of the relevant grid box 
-                  END DO 
+                     h_rnf(ji,jj) = h_rnf(ji,jj) + fse3t(ji,jj,jk)   ! to the bottom of the relevant grid box
+                  END DO
                   !                          ! apply the runoff input flow
                   DO jk = 1, nk_rnf(ji,jj)
@@ -246,11 +245,11 @@
       !! ** Action  : - read parameters
       !!----------------------------------------------------------------------
-      CHARACTER(len=32) ::   rn_dep_file   ! runoff file name  
+      CHARACTER(len=32) ::   rn_dep_file   ! runoff file name
       INTEGER           ::   ji, jj, jk    ! dummy loop indices
       INTEGER           ::   ierror, inum  ! temporary integer
       !
       NAMELIST/namsbc_rnf/ cn_dir, ln_rnf_emp, ln_rnf_depth, ln_rnf_tem, ln_rnf_sal,   &
-         &                 sn_rnf, sn_cnf    , sn_s_rnf    , sn_t_rnf  , sn_dep_rnf,   &  
-         &                 ln_rnf_mouth      , rn_hrnf     , rn_avt_rnf, rn_rfact  
+         &                 sn_rnf, sn_cnf    , sn_s_rnf    , sn_t_rnf  , sn_dep_rnf,   &
+         &                 ln_rnf_mouth      , rn_hrnf     , rn_avt_rnf, rn_rfact
       !!----------------------------------------------------------------------
       !
@@ -264,7 +263,7 @@
       sn_cnf = FLD_N( 'runoffs',     0     , 'sorunoff' ,  .FALSE.   , .true. ,   'yearly'  , ''       , ''         )
 
-      sn_s_rnf = FLD_N( 'runoffs',  24.  , 'rosaline' ,  .TRUE.    , .true. ,   'yearly'  , ''    , ''  )  
-      sn_t_rnf = FLD_N( 'runoffs',  24.  , 'rotemper' ,  .TRUE.    , .true. ,   'yearly'  , ''    , ''  )  
-      sn_dep_rnf = FLD_N( 'runoffs',   0.  , 'rodepth'  ,  .FALSE.   , .true. ,   'yearly'  , ''    , ''  )  
+      sn_s_rnf = FLD_N( 'runoffs',  24.  , 'rosaline' ,  .TRUE.    , .true. ,   'yearly'  , ''    , ''  )
+      sn_t_rnf = FLD_N( 'runoffs',  24.  , 'rotemper' ,  .TRUE.    , .true. ,   'yearly'  , ''    , ''  )
+      sn_dep_rnf = FLD_N( 'runoffs',   0.  , 'rodepth'  ,  .FALSE.   , .true. ,   'yearly'  , ''    , ''  )
       !
       REWIND ( numnam )                         ! Read Namelist namsbc_rnf
@@ -281,5 +280,5 @@
          WRITE(numout,*) '      river mouth additional Kz                  rn_avt_rnf   = ', rn_avt_rnf
          WRITE(numout,*) '      depth of river mouth additional mixing     rn_hrnf      = ', rn_hrnf
-         WRITE(numout,*) '      multiplicative factor for runoff           rn_rfact     = ', rn_rfact    
+         WRITE(numout,*) '      multiplicative factor for runoff           rn_rfact     = ', rn_rfact
       ENDIF
       !
@@ -294,5 +293,5 @@
          IF(lwp) WRITE(numout,*) '          runoffs directly provided in the precipitations'
          IF( ln_rnf_depth .OR. ln_rnf_tem .OR. ln_rnf_sal ) THEN
-           CALL ctl_warn( 'runoffs already included in precipitations, so runoff (T,S, depth) attributes will not be used' ) 
+           CALL ctl_warn( 'runoffs already included in precipitations, so runoff (T,S, depth) attributes will not be used' )
            ln_rnf_depth = .FALSE.   ;   ln_rnf_tem = .FALSE.   ;   ln_rnf_sal = .FALSE.
          ENDIF
@@ -320,5 +319,5 @@
             ALLOCATE( sf_t_rnf(1)%fnow(jpi,jpj,1)   )
             IF( sn_t_rnf%ln_tint ) ALLOCATE( sf_t_rnf(1)%fdta(jpi,jpj,1,2) )
-            CALL fld_fill (sf_t_rnf, (/ sn_t_rnf /), cn_dir, 'sbc_rnf_init', 'read runoff temperature data', 'namsbc_rnf' )  
+            CALL fld_fill (sf_t_rnf, (/ sn_t_rnf /), cn_dir, 'sbc_rnf_init', 'read runoff temperature data', 'namsbc_rnf' )
          ENDIF
          !
@@ -332,43 +331,43 @@
             ALLOCATE( sf_s_rnf(1)%fnow(jpi,jpj,1)   )
             IF( sn_s_rnf%ln_tint ) ALLOCATE( sf_s_rnf(1)%fdta(jpi,jpj,1,2) )
-            CALL fld_fill (sf_s_rnf, (/ sn_s_rnf /), cn_dir, 'sbc_rnf_init', 'read runoff salinity data', 'namsbc_rnf' )  
-         ENDIF
-         !
-         IF( ln_rnf_depth ) THEN                    ! depth of runoffs set from a file 
+            CALL fld_fill (sf_s_rnf, (/ sn_s_rnf /), cn_dir, 'sbc_rnf_init', 'read runoff salinity data', 'namsbc_rnf' )
+         ENDIF
+         !
+         IF( ln_rnf_depth ) THEN                    ! depth of runoffs set from a file
             IF(lwp) WRITE(numout,*)
             IF(lwp) WRITE(numout,*) '          runoffs depth read in a file'
-            rn_dep_file = TRIM( cn_dir )//TRIM( sn_dep_rnf%clname )  
-            CALL iom_open ( rn_dep_file, inum )                           ! open file  
-            CALL iom_get  ( inum, jpdom_data, sn_dep_rnf%clvar, h_rnf )   ! read the river mouth array  
-            CALL iom_close( inum )                                        ! close file  
+            rn_dep_file = TRIM( cn_dir )//TRIM( sn_dep_rnf%clname )
+            CALL iom_open ( rn_dep_file, inum )                           ! open file
+            CALL iom_get  ( inum, jpdom_data, sn_dep_rnf%clvar, h_rnf )   ! read the river mouth array
+            CALL iom_close( inum )                                        ! close file
             !
             nk_rnf(:,:) = 0                               ! set the number of level over which river runoffs are applied
-            DO jj = 1, jpj  
-               DO ji = 1, jpi  
-                  IF( h_rnf(ji,jj) > 0._wp ) THEN  
-                     jk = 2  
-                     DO WHILE ( jk /= mbkt(ji,jj) .AND. fsdept(ji,jj,jk) < h_rnf(ji,jj) ) ;  jk = jk + 1 ;  END DO  
-                     nk_rnf(ji,jj) = jk  
-                  ELSEIF( h_rnf(ji,jj) == -1   ) THEN   ;  nk_rnf(ji,jj) = 1  
-                  ELSEIF( h_rnf(ji,jj) == -999 ) THEN   ;  nk_rnf(ji,jj) = mbkt(ji,jj)
-                  ELSEIF( h_rnf(ji,jj) /=  0   ) THEN  
-                     CALL ctl_stop( 'runoff depth not positive, and not -999 or -1, rnf value in file fort.999'  )  
-                     WRITE(999,*) 'ji, jj, rnf(ji,jj) :', ji, jj, rnf(ji,jj)  
-                  ENDIF  
-               END DO  
-            END DO  
-            DO jj = 1, jpj                                ! set the associated depth 
-               DO ji = 1, jpi 
+            DO jj = 1, jpj
+               DO ji = 1, jpi
+                  IF( h_rnf(ji,jj) > 0._wp ) THEN
+                     jk = 2
+                     DO WHILE ( jk /= mbkt(ji,jj) .AND. fsdept(ji,jj,jk) < h_rnf(ji,jj) ) ;  jk = jk + 1 ;  END DO
+                     nk_rnf(ji,jj) = jk
+                  ELSEIF( h_rnf(ji,jj) == -1._wp   ) THEN   ;  nk_rnf(ji,jj) = 1
+                  ELSEIF( h_rnf(ji,jj) == -999._wp ) THEN   ;  nk_rnf(ji,jj) = mbkt(ji,jj)
+                  ELSE
+                     CALL ctl_stop( 'runoff depth not positive, and not -999 or -1, rnf value in file fort.999'  )
+                     WRITE(999,*) 'ji, jj, rnf(ji,jj) :', ji, jj, rnf(ji,jj)
+                  ENDIF
+               END DO
+            END DO
+            DO jj = 1, jpj                                ! set the associated depth
+               DO ji = 1, jpi
                   h_rnf(ji,jj) = 0._wp
-                  DO jk = 1, nk_rnf(ji,jj)                        
-                     h_rnf(ji,jj) = h_rnf(ji,jj) + fse3t(ji,jj,jk)  
+                  DO jk = 1, nk_rnf(ji,jj)
+                     h_rnf(ji,jj) = h_rnf(ji,jj) + fse3t(ji,jj,jk)
                   END DO
                END DO
             END DO
-         ELSE                                       ! runoffs applied at the surface 
-            nk_rnf(:,:) = 1  
+         ELSE                                       ! runoffs applied at the surface
+            nk_rnf(:,:) = 1
             h_rnf (:,:) = fse3t(:,:,1)
-         ENDIF  
-         ! 
+         ENDIF
+         !
       ENDIF
       !
@@ -386,5 +385,5 @@
          !
          IF ( ln_rnf_depth )   CALL ctl_warn( 'sbc_rnf_init: increased mixing turned on but effects may already',   &
-            &                                              'be spread through depth by ln_rnf_depth'               ) 
+            &                                              'be spread through depth by ln_rnf_depth'               )
          !
          nkrnf = 0                                  ! Number of level over which Kz increase
@@ -406,5 +405,5 @@
          IF(lwp) WRITE(numout,*)
          IF(lwp) WRITE(numout,*) '          No specific treatment at river mouths'
-         rnfmsk  (:,:) = 0._wp 
+         rnfmsk  (:,:) = 0._wp
          rnfmsk_z(:)   = 0._wp
          nkrnf = 0
@@ -417,15 +416,15 @@
       !!----------------------------------------------------------------------
       !!                  ***  ROUTINE rnf_mouth  ***
-      !!       
+      !!
       !! ** Purpose :   define the river mouths mask
       !!
       !! ** Method  :   read the river mouth mask (=0/1) in the river runoff
-      !!                climatological file. Defined a given vertical structure. 
-      !!                CAUTION, the vertical structure is hard coded on the 
+      !!                climatological file. Defined a given vertical structure.
+      !!                CAUTION, the vertical structure is hard coded on the
       !!                first 5 levels.
       !!                This fields can be used to:
-      !!                 - set an upstream advection scheme  
+      !!                 - set an upstream advection scheme
       !!                   (ln_rnf_mouth=T and ln_traadv_cen2=T)
-      !!                 - increase vertical on the top nn_krnf vertical levels 
+      !!                 - increase vertical on the top nn_krnf vertical levels
       !!                   at river runoff input grid point (nn_krnf>=2, see step.F90)
       !!                 - set to zero SSS restoring flux at river mouth grid points
@@ -437,5 +436,5 @@
       CHARACTER(len=140) ::   cl_rnfile   ! runoff file name
       !!----------------------------------------------------------------------
-      ! 
+      !
       IF(lwp) WRITE(numout,*)
       IF(lwp) WRITE(numout,*) 'rnf_mouth : river mouth mask'
@@ -454,5 +453,5 @@
       IF( nn_closea == 1 )   CALL clo_rnf( rnfmsk )               ! closed sea inflow set as ruver mouth
       !
-      rnfmsk_z(:)   = 0._wp                                       ! vertical structure 
+      rnfmsk_z(:)   = 0._wp                                       ! vertical structure
       rnfmsk_z(1)   = 1.0
       rnfmsk_z(2)   = 1.0                                         ! **********
@@ -460,7 +459,7 @@
       rnfmsk_z(4)   = 0.25                                        ! **********
       rnfmsk_z(5)   = 0.125
-      !         
+      !
    END SUBROUTINE rnf_mouth
-   
+
    !!======================================================================
 END MODULE sbcrnf
Index: branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/OPA_SRC/SBC/sbcssr.F90
===================================================================
--- branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/OPA_SRC/SBC/sbcssr.F90	(revision 3759)
+++ branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/OPA_SRC/SBC/sbcssr.F90	(revision 3764)
@@ -27,5 +27,6 @@
    PRIVATE
 
-   PUBLIC   sbc_ssr    ! routine called in sbcmod
+   PUBLIC   sbc_ssr        ! routine called in sbcmod
+   PUBLIC   sbc_ssr_init   ! routine called in sbcmod
 
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   erp   !: evaporation damping   [kg/m2/s]
@@ -83,69 +84,4 @@
       IF( nn_timing == 1 )  CALL timing_start('sbc_ssr')
       !
-      !                                               ! -------------------- !
-      IF( kt == nit000 ) THEN                         ! First call kt=nit000 !
-         !                                            ! -------------------- !
-         !                            !* set file information
-         cn_dir  = './'            ! directory in which the model is executed
-         ! ... default values (NB: frequency positive => hours, negative => months)
-         !            !   file    ! frequency !  variable  ! time intep !  clim   ! 'yearly' or ! weights  ! rotation   !
-         !            !   name    !  (hours)  !   name     !   (T/F)    !  (T/F)  !  'monthly'  ! filename ! pairs      !
-         sn_sst = FLD_N( 'sst'    ,    24     ,  'sst'     ,  .false.   , .false. ,   'yearly'  , ''       , ''         )
-         sn_sss = FLD_N( 'sss'    ,    -1     ,  'sss'     ,  .true.    , .false. ,   'yearly'  , ''       , ''         )
-
-         REWIND ( numnam )            !* read in namlist namflx
-         READ( numnam, namsbc_ssr ) 
-
-         IF(lwp) THEN                 !* control print
-            WRITE(numout,*)
-            WRITE(numout,*) 'sbc_ssr : SST and/or SSS damping term '
-            WRITE(numout,*) '~~~~~~~ '
-            WRITE(numout,*) '   Namelist namsbc_ssr :'
-            WRITE(numout,*) '      SST restoring term (Yes=1)             nn_sstr     = ', nn_sstr
-            WRITE(numout,*) '      SSS damping term (Yes=1, salt flux)    nn_sssr     = ', nn_sssr
-            WRITE(numout,*) '                       (Yes=2, volume flux) '
-            WRITE(numout,*) '      dQ/dT (restoring magnitude on SST)     rn_dqdt     = ', rn_dqdt, ' W/m2/K'
-            WRITE(numout,*) '      dE/dS (restoring magnitude on SST)     rn_deds     = ', rn_deds, ' mm/day'
-            WRITE(numout,*) '      flag to bound erp term                 ln_sssr_bnd = ', ln_sssr_bnd
-            WRITE(numout,*) '      ABS(Max./Min.) erp threshold           rn_sssr_bnd = ', rn_sssr_bnd, ' mm/day'
-         ENDIF
-
-         ! Allocate erp and qrp array
-         ALLOCATE( qrp(jpi,jpj), erp(jpi,jpj), STAT=ierror )
-         IF( ierror > 0 )   CALL ctl_stop( 'STOP', 'sbc_ssr: unable to allocate erp and qrp array' )
-
-         IF( nn_sstr == 1 ) THEN      !* set sf_sst structure & allocate arrays
-            !
-            ALLOCATE( sf_sst(1), STAT=ierror )
-            IF( ierror > 0 )   CALL ctl_stop( 'STOP', 'sbc_ssr: unable to allocate sf_sst structure' )
-            ALLOCATE( sf_sst(1)%fnow(jpi,jpj,1), STAT=ierror )
-            IF( ierror > 0 )   CALL ctl_stop( 'STOP', 'sbc_ssr: unable to allocate sf_sst now array' )
-            !
-            ! fill sf_sst with sn_sst and control print
-            CALL fld_fill( sf_sst, (/ sn_sst /), cn_dir, 'sbc_ssr', 'SST restoring term toward SST data', 'namsbc_ssr' )
-            IF( sf_sst(1)%ln_tint )   ALLOCATE( sf_sst(1)%fdta(jpi,jpj,1,2), STAT=ierror )
-            IF( ierror > 0 )   CALL ctl_stop( 'STOP', 'sbc_ssr: unable to allocate sf_sst data array' )
-            !
-         ENDIF
-         !
-         IF( nn_sssr >= 1 ) THEN      ! set sf_sss structure & allocate arrays
-            !
-            ALLOCATE( sf_sss(1), STAT=ierror )
-            IF( ierror > 0 )   CALL ctl_stop( 'STOP', 'sbc_ssr: unable to allocate sf_sss structure' )
-            ALLOCATE( sf_sss(1)%fnow(jpi,jpj,1), STAT=ierror )
-            IF( ierror > 0 )   CALL ctl_stop( 'STOP', 'sbc_ssr: unable to allocate sf_sss now array' )
-            !
-            ! fill sf_sss with sn_sss and control print
-            CALL fld_fill( sf_sss, (/ sn_sss /), cn_dir, 'sbc_ssr', 'SSS restoring term toward SSS data', 'namsbc_ssr' )
-            IF( sf_sss(1)%ln_tint )   ALLOCATE( sf_sss(1)%fdta(jpi,jpj,1,2), STAT=ierror )
-            IF( ierror > 0 )   CALL ctl_stop( 'STOP', 'sbc_ssr: unable to allocate sf_sss data array' )
-            !
-         ENDIF
-         !
-         ! Initialize qrp and erp if no restoring 
-         IF( nn_sstr /= 1                   )   qrp(:,:) = 0.e0 
-         IF( nn_sssr /= 1 .OR. nn_sssr /= 2 )   erp(:,:) = 0.e0 
-      ENDIF
-
       IF( nn_sstr + nn_sssr /= 0 ) THEN
          !
@@ -207,4 +143,89 @@
       !
    END SUBROUTINE sbc_ssr
+
+ 
+   SUBROUTINE sbc_ssr_init
+      !!---------------------------------------------------------------------
+      !!                  ***  ROUTINE sbc_ssr_init  ***
+      !!
+      !! ** Purpose :   initialisation of surface damping term
+      !!
+      !! ** Method  : - Read namelist namsbc_ssr
+      !!              - Read observed SST and/or SSS if required
+      !!---------------------------------------------------------------------
+      INTEGER  ::   ji, jj   ! dummy loop indices
+      REAL(wp) ::   zerp     ! local scalar for evaporation damping
+      REAL(wp) ::   zqrp     ! local scalar for heat flux damping
+      REAL(wp) ::   zsrp     ! local scalar for unit conversion of rn_deds factor
+      REAL(wp) ::   zerp_bnd ! local scalar for unit conversion of rn_epr_max factor
+      INTEGER  ::   ierror   ! return error code
+      !!
+      CHARACTER(len=100) ::  cn_dir          ! Root directory for location of ssr files
+      TYPE(FLD_N) ::   sn_sst, sn_sss        ! informations about the fields to be read
+      NAMELIST/namsbc_ssr/ cn_dir, nn_sstr, nn_sssr, rn_dqdt, rn_deds, sn_sst, sn_sss, ln_sssr_bnd, rn_sssr_bnd
+      !!----------------------------------------------------------------------
+      !
+      !                            !* set file information
+      cn_dir  = './'            ! directory in which the model is executed
+      ! ... default values (NB: frequency positive => hours, negative => months)
+      !            !   file    ! frequency !  variable  ! time intep !  clim   ! 'yearly' or ! weights  ! rotation   !
+      !            !   name    !  (hours)  !   name     !   (T/F)    !  (T/F)  !  'monthly'  ! filename ! pairs      !
+      sn_sst = FLD_N( 'sst'    ,    24     ,  'sst'     ,  .false.   , .false. ,   'yearly'  , ''       , ''         )
+      sn_sss = FLD_N( 'sss'    ,    -1     ,  'sss'     ,  .true.    , .false. ,   'yearly'  , ''       , ''         )
+
+      REWIND( numnam )             !* read in namlist namflx
+      READ  ( numnam, namsbc_ssr ) 
+
+      IF(lwp) THEN                 !* control print
+         WRITE(numout,*)
+         WRITE(numout,*) 'sbc_ssr : SST and/or SSS damping term '
+         WRITE(numout,*) '~~~~~~~ '
+         WRITE(numout,*) '   Namelist namsbc_ssr :'
+         WRITE(numout,*) '      SST restoring term (Yes=1)             nn_sstr     = ', nn_sstr
+         WRITE(numout,*) '      SSS damping term (Yes=1, salt flux)    nn_sssr     = ', nn_sssr
+         WRITE(numout,*) '                       (Yes=2, volume flux) '
+         WRITE(numout,*) '      dQ/dT (restoring magnitude on SST)     rn_dqdt     = ', rn_dqdt, ' W/m2/K'
+         WRITE(numout,*) '      dE/dS (restoring magnitude on SST)     rn_deds     = ', rn_deds, ' mm/day'
+         WRITE(numout,*) '      flag to bound erp term                 ln_sssr_bnd = ', ln_sssr_bnd
+         WRITE(numout,*) '      ABS(Max./Min.) erp threshold           rn_sssr_bnd = ', rn_sssr_bnd, ' mm/day'
+      ENDIF
+      !
+      !                            !* Allocate erp and qrp array
+      ALLOCATE( qrp(jpi,jpj), erp(jpi,jpj), STAT=ierror )
+      IF( ierror > 0 )   CALL ctl_stop( 'STOP', 'sbc_ssr: unable to allocate erp and qrp array' )
+      !
+      IF( nn_sstr == 1 ) THEN      !* set sf_sst structure & allocate arrays
+         !
+         ALLOCATE( sf_sst(1), STAT=ierror )
+         IF( ierror > 0 )   CALL ctl_stop( 'STOP', 'sbc_ssr: unable to allocate sf_sst structure' )
+         ALLOCATE( sf_sst(1)%fnow(jpi,jpj,1), STAT=ierror )
+         IF( ierror > 0 )   CALL ctl_stop( 'STOP', 'sbc_ssr: unable to allocate sf_sst now array' )
+         !
+         ! fill sf_sst with sn_sst and control print
+         CALL fld_fill( sf_sst, (/ sn_sst /), cn_dir, 'sbc_ssr', 'SST restoring term toward SST data', 'namsbc_ssr' )
+         IF( sf_sst(1)%ln_tint )   ALLOCATE( sf_sst(1)%fdta(jpi,jpj,1,2), STAT=ierror )
+         IF( ierror > 0 )   CALL ctl_stop( 'STOP', 'sbc_ssr: unable to allocate sf_sst data array' )
+         !
+      ENDIF
+      !
+      IF( nn_sssr >= 1 ) THEN      !* set sf_sss structure & allocate arrays
+         !
+         ALLOCATE( sf_sss(1), STAT=ierror )
+         IF( ierror > 0 )   CALL ctl_stop( 'STOP', 'sbc_ssr: unable to allocate sf_sss structure' )
+         ALLOCATE( sf_sss(1)%fnow(jpi,jpj,1), STAT=ierror )
+         IF( ierror > 0 )   CALL ctl_stop( 'STOP', 'sbc_ssr: unable to allocate sf_sss now array' )
+         !
+         ! fill sf_sss with sn_sss and control print
+         CALL fld_fill( sf_sss, (/ sn_sss /), cn_dir, 'sbc_ssr', 'SSS restoring term toward SSS data', 'namsbc_ssr' )
+         IF( sf_sss(1)%ln_tint )   ALLOCATE( sf_sss(1)%fdta(jpi,jpj,1,2), STAT=ierror )
+         IF( ierror > 0 )   CALL ctl_stop( 'STOP', 'sbc_ssr: unable to allocate sf_sss data array' )
+         !
+      ENDIF
+      !
+      !                            !* Initialize qrp and erp if no restoring 
+      IF( nn_sstr /= 1                   )   qrp(:,:) = 0._wp
+      IF( nn_sssr /= 1 .OR. nn_sssr /= 2 )   erp(:,:) = 0._wp
+      !
+   END SUBROUTINE sbc_ssr_init
       
    !!======================================================================
Index: branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/OPA_SRC/SOL/solver.F90
===================================================================
--- branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/OPA_SRC/SOL/solver.F90	(revision 3759)
+++ branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/OPA_SRC/SOL/solver.F90	(revision 3764)
@@ -83,5 +83,7 @@
 
       !                              ! allocate solver arrays
-      IF( sol_oce_alloc() /= 0 )   CALL ctl_stop( 'STOP', 'solver_init : unable to allocate sol_oce arrays' )
+      IF( .NOT. lk_agrif .OR. .NOT. ln_rstart) THEN
+         IF( sol_oce_alloc() /= 0 )   CALL ctl_stop( 'STOP', 'solver_init : unable to allocate sol_oce arrays' )
+      ENDIF
 
       SELECT CASE( nn_solv )          !* parameter check
Index: branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/OPA_SRC/TRA/trabbl.F90
===================================================================
--- branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/OPA_SRC/TRA/trabbl.F90	(revision 3759)
+++ branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/OPA_SRC/TRA/trabbl.F90	(revision 3764)
@@ -8,6 +8,6 @@
    !!   NEMO     1.0  ! 2002-08  (G. Madec)  free form + modules
    !!             -   ! 2004-01  (A. de Miranda, G. Madec, J.M. Molines ) add advective bbl
-   !!            3.3  ! 2009-11  (G. Madec)  merge trabbl and trabbl_adv + style + optimization 
-   !!             -   ! 2010-04  (G. Madec)  Campin & Goosse advective bbl 
+   !!            3.3  ! 2009-11  (G. Madec)  merge trabbl and trabbl_adv + style + optimization
+   !!             -   ! 2010-04  (G. Madec)  Campin & Goosse advective bbl
    !!             -   ! 2010-06  (C. Ethe, G. Madec)  merge TRA-TRC
    !!             -   ! 2010-11  (G. Madec) add mbk. arrays associated to the deepest ocean level
@@ -30,5 +30,5 @@
    USE trdmod_oce     ! trends: ocean variables
    USE trdtra         ! trends: active tracers
-   USE iom            ! IOM server               
+   USE iom            ! IOM server
    USE in_out_manager ! I/O manager
    USE lbclnk         ! ocean lateral boundary conditions
@@ -49,5 +49,5 @@
    LOGICAL, PUBLIC, PARAMETER ::   lk_trabbl = .TRUE.    !: bottom boundary layer flag
 
-   !                                           !!* Namelist nambbl * 
+   !                                           !!* Namelist nambbl *
    INTEGER , PUBLIC ::   nn_bbl_ldf = 0         !: =1   : diffusive bbl or not (=0)
    INTEGER , PUBLIC ::   nn_bbl_adv = 0         !: =1/2 : advective bbl or not (=0)
@@ -58,13 +58,13 @@
 
    LOGICAL , PUBLIC ::   l_bbl                  !: flag to compute bbl diffu. flux coef and transport
-   
+
    REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:), PUBLIC ::   utr_bbl  , vtr_bbl   ! u- (v-) transport in the bottom boundary layer
    REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:), PUBLIC ::   ahu_bbl  , ahv_bbl   ! masked diffusive bbl coeff. at u & v-pts
 
-   INTEGER , ALLOCATABLE, SAVE, DIMENSION(:,:) ::   mbku_d   , mbkv_d      ! vertical index of the "lower" bottom ocean U/V-level
-   INTEGER , ALLOCATABLE, SAVE, DIMENSION(:,:) ::   mgrhu    , mgrhv       ! = +/-1, sign of grad(H) in u-(v-)direction
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) ::   ahu_bbl_0, ahv_bbl_0   ! diffusive bbl flux coefficients at u and v-points
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) ::   e3u_bbl_0, e3v_bbl_0   ! thichness of the bbl (e3) at u and v-points
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) ::   r1_e1e2t               ! inverse of the cell surface at t-point      [1/m2]
+   INTEGER , ALLOCATABLE, SAVE, DIMENSION(:,:), PUBLIC ::   mbku_d   , mbkv_d      ! vertical index of the "lower" bottom ocean U/V-level (PUBLIC for TAM)
+   INTEGER , ALLOCATABLE, SAVE, DIMENSION(:,:), PUBLIC ::   mgrhu    , mgrhv       ! = +/-1, sign of grad(H) in u-(v-)direction (PUBLIC for TAM)
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:)         ::   ahu_bbl_0, ahv_bbl_0   ! diffusive bbl flux coefficients at u and v-points
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:), PUBLIC ::   e3u_bbl_0, e3v_bbl_0   ! thichness of the bbl (e3) at u and v-points (PUBLIC for TAM)
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:), PUBLIC ::   r1_e1e2t               ! inverse of the cell surface at t-point      [1/m2] (PUBLIC for TAM)
 
    !! * Substitutions
@@ -95,6 +95,6 @@
       !!----------------------------------------------------------------------
       !!                  ***  ROUTINE bbl  ***
-      !!                   
-      !! ** Purpose :   Compute the before tracer (t & s) trend associated 
+      !!
+      !! ** Purpose :   Compute the before tracer (t & s) trend associated
       !!              with the bottom boundary layer and add it to the general
       !!              trend of tracer equations.
@@ -103,6 +103,6 @@
       !!              diffusive and/or advective contribution to the tracer trend
       !!              is added to the general tracer trend
-      !!----------------------------------------------------------------------  
-      INTEGER, INTENT( in ) ::   kt   ! ocean time-step 
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT( in ) ::   kt   ! ocean time-step
       !!
       REAL(wp), POINTER, DIMENSION(:,:,:) ::  ztrdt, ztrds
@@ -112,11 +112,11 @@
       !
       IF( l_trdtra )   THEN                        !* Save ta and sa trends
-         CALL wrk_alloc( jpi, jpj, jpk, ztrdt, ztrds ) 
-         ztrdt(:,:,:) = tsa(:,:,:,jp_tem) 
+         CALL wrk_alloc( jpi, jpj, jpk, ztrdt, ztrds )
+         ztrdt(:,:,:) = tsa(:,:,:,jp_tem)
          ztrds(:,:,:) = tsa(:,:,:,jp_sal)
       ENDIF
 
       IF( l_bbl )  CALL bbl( kt, nit000, 'TRA' )   !* bbl coef. and transport (only if not already done in trcbbl)
- 
+
       IF( nn_bbl_ldf == 1 ) THEN                   !* Diffusive bbl
          !
@@ -125,7 +125,7 @@
          CALL prt_ctl( tab3d_1=tsa(:,:,:,jp_tem), clinfo1=' bbl_ldf  - Ta: ', mask1=tmask, &
          &             tab3d_2=tsa(:,:,:,jp_sal), clinfo2=           ' Sa: ', mask2=tmask, clinfo3='tra' )
-         ! lateral boundary conditions ; just need for outputs                          
+         ! lateral boundary conditions ; just need for outputs
          CALL lbc_lnk( ahu_bbl, 'U', 1. )     ;     CALL lbc_lnk( ahv_bbl, 'V', 1. )
-         CALL iom_put( "ahu_bbl", ahu_bbl )   ! bbl diffusive flux i-coef     
+         CALL iom_put( "ahu_bbl", ahu_bbl )   ! bbl diffusive flux i-coef
          CALL iom_put( "ahv_bbl", ahv_bbl )   ! bbl diffusive flux j-coef
          !
@@ -138,7 +138,7 @@
          CALL prt_ctl( tab3d_1=tsa(:,:,:,jp_tem), clinfo1=' bbl_adv  - Ta: ', mask1=tmask,   &
          &             tab3d_2=tsa(:,:,:,jp_sal), clinfo2=           ' Sa: ', mask2=tmask, clinfo3='tra' )
-         ! lateral boundary conditions ; just need for outputs                          
+         ! lateral boundary conditions ; just need for outputs
          CALL lbc_lnk( utr_bbl, 'U', 1. )     ;   CALL lbc_lnk( vtr_bbl, 'V', 1. )
-         CALL iom_put( "uoce_bbl", utr_bbl )  ! bbl i-transport     
+         CALL iom_put( "uoce_bbl", utr_bbl )  ! bbl i-transport
          CALL iom_put( "voce_bbl", vtr_bbl )  ! bbl j-transport
          !
@@ -150,5 +150,5 @@
          CALL trd_tra( kt, 'TRA', jp_tem, jptra_trd_bbl, ztrdt )
          CALL trd_tra( kt, 'TRA', jp_sal, jptra_trd_bbl, ztrds )
-         CALL wrk_dealloc( jpi, jpj, jpk, ztrdt, ztrds ) 
+         CALL wrk_dealloc( jpi, jpj, jpk, ztrdt, ztrds )
       ENDIF
       !
@@ -161,9 +161,9 @@
       !!----------------------------------------------------------------------
       !!                  ***  ROUTINE tra_bbl_dif  ***
-      !!                   
+      !!
       !! ** Purpose :   Computes the bottom boundary horizontal and vertical
-      !!                advection terms. 
-      !!
-      !! ** Method  :   
+      !!                advection terms.
+      !!
+      !! ** Method  :
       !!        * diffusive bbl (nn_bbl_ldf=1) :
       !!        When the product grad( rho) * grad(h) < 0 (where grad is an
@@ -179,9 +179,9 @@
       !! References : Beckmann, A., and R. Doscher, 1997, J. Phys.Oceanogr., 581-591.
       !!              Campin, J.-M., and H. Goosse, 1999, Tellus, 412-430.
-      !!----------------------------------------------------------------------  
+      !!----------------------------------------------------------------------
       !
       INTEGER                              , INTENT(in   ) ::   kjpt   ! number of tracers
       REAL(wp), DIMENSION(jpi,jpj,jpk,kjpt), INTENT(in   ) ::   ptb    ! before and now tracer fields
-      REAL(wp), DIMENSION(jpi,jpj,jpk,kjpt), INTENT(inout) ::   pta    ! tracer trend 
+      REAL(wp), DIMENSION(jpi,jpj,jpk,kjpt), INTENT(inout) ::   pta    ! tracer trend
       !
       INTEGER  ::   ji, jj, jn   ! dummy loop indices
@@ -202,5 +202,5 @@
 #else
          DO jj = 1, jpj
-            DO ji = 1, jpi 
+            DO ji = 1, jpi
 #endif
                ik = mbkt(ji,jj)                        ! bottom T-level index
@@ -233,5 +233,5 @@
       !
    END SUBROUTINE tra_bbl_dif
-   
+
 
    SUBROUTINE tra_bbl_adv( ptb, pta, kjpt )
@@ -239,18 +239,18 @@
       !!                  ***  ROUTINE trc_bbl  ***
       !!
-      !! ** Purpose :   Compute the before passive tracer trend associated 
+      !! ** Purpose :   Compute the before passive tracer trend associated
       !!     with the bottom boundary layer and add it to the general trend
       !!     of tracer equations.
       !! ** Method  :   advective bbl (nn_bbl_adv = 1 or 2) :
       !!      nn_bbl_adv = 1   use of the ocean near bottom velocity as bbl velocity
-      !!      nn_bbl_adv = 2   follow Campin and Goosse (1999) implentation i.e. 
-      !!                       transport proportional to the along-slope density gradient                   
+      !!      nn_bbl_adv = 2   follow Campin and Goosse (1999) implentation i.e.
+      !!                       transport proportional to the along-slope density gradient
       !!
       !! References : Beckmann, A., and R. Doscher, 1997, J. Phys.Oceanogr., 581-591.
       !!              Campin, J.-M., and H. Goosse, 1999, Tellus, 412-430.
-      !!----------------------------------------------------------------------  
+      !!----------------------------------------------------------------------
       INTEGER                              , INTENT(in   ) ::   kjpt   ! number of tracers
       REAL(wp), DIMENSION(jpi,jpj,jpk,kjpt), INTENT(in   ) ::   ptb    ! before and now tracer fields
-      REAL(wp), DIMENSION(jpi,jpj,jpk,kjpt), INTENT(inout) ::   pta    ! tracer trend 
+      REAL(wp), DIMENSION(jpi,jpj,jpk,kjpt), INTENT(inout) ::   pta    ! tracer trend
       !
       INTEGER  ::   ji, jj, jk, jn           ! dummy loop indices
@@ -264,5 +264,5 @@
       !                                                          ! ===========
       DO jn = 1, kjpt                                            ! tracer loop
-         !                                                       ! ===========         
+         !                                                       ! ===========
 # if defined key_vectopt_loop
          DO jj = 1, 1
@@ -282,5 +282,5 @@
                   ztra = zu_bbl * ( ptb(iid,jj,ikus,jn) - ptb(iis,jj,ikus,jn) ) * zbtr
                   pta(iis,jj,ikus,jn) = pta(iis,jj,ikus,jn) + ztra
-                  !                   
+                  !
                   DO jk = ikus, ikud-1                            ! down-slope upper to down T-point (deep column)
                      zbtr = r1_e1e2t(iid,jj) / fse3t(iid,jj,jk)
@@ -288,5 +288,5 @@
                      pta(iid,jj,jk,jn) = pta(iid,jj,jk,jn) + ztra
                   END DO
-                  ! 
+                  !
                   zbtr = r1_e1e2t(iid,jj) / fse3t(iid,jj,ikud)
                   ztra = zu_bbl * ( ptb(iis,jj,ikus,jn) - ptb(iid,jj,ikud,jn) ) * zbtr
@@ -299,10 +299,10 @@
                   ikvd = mbkv_d(ji,jj)                   ;   ikvs = mbkv(ji,jj)
                   zv_bbl = ABS( vtr_bbl(ji,jj) )
-                  ! 
+                  !
                   ! up  -slope T-point (shelf bottom point)
                   zbtr = r1_e1e2t(ji,ijs) / fse3t(ji,ijs,ikvs)
                   ztra = zv_bbl * ( ptb(ji,ijd,ikvs,jn) - ptb(ji,ijs,ikvs,jn) ) * zbtr
                   pta(ji,ijs,ikvs,jn) = pta(ji,ijs,ikvs,jn) + ztra
-                  !                   
+                  !
                   DO jk = ikvs, ikvd-1                            ! down-slope upper to down T-point (deep column)
                      zbtr = r1_e1e2t(ji,ijd) / fse3t(ji,ijd,jk)
@@ -330,9 +330,9 @@
       !!----------------------------------------------------------------------
       !!                  ***  ROUTINE bbl  ***
-      !!                   
+      !!
       !! ** Purpose :   Computes the bottom boundary horizontal and vertical
-      !!                advection terms. 
-      !!
-      !! ** Method  :   
+      !!                advection terms.
+      !!
+      !! ** Method  :
       !!        * diffusive bbl (nn_bbl_ldf=1) :
       !!        When the product grad( rho) * grad(h) < 0 (where grad is an
@@ -353,5 +353,5 @@
       !! References : Beckmann, A., and R. Doscher, 1997, J. Phys.Oceanogr., 581-591.
       !!              Campin, J.-M., and H. Goosse, 1999, Tellus, 412-430.
-      !!----------------------------------------------------------------------  
+      !!----------------------------------------------------------------------
       !
       INTEGER         , INTENT(in   ) ::   kt       ! ocean time-step index
@@ -399,11 +399,11 @@
                                           - 0.121555e-07 ) * pfh
       !!----------------------------------------------------------------------
-      
+
       !
       IF( nn_timing == 1 )  CALL timing_start( 'bbl')
       !
-      CALL wrk_alloc( jpi, jpj, zub, zvb, ztb, zsb, zdep ) 
-      !
-     
+      CALL wrk_alloc( jpi, jpj, zub, zvb, ztb, zsb, zdep )
+      !
+
       IF( kt == kit000 )  THEN
          IF(lwp)  WRITE(numout,*)
@@ -411,5 +411,5 @@
          IF(lwp)  WRITE(numout,*) '~~~~~~~~~~'
       ENDIF
-      
+
       !                                        !* bottom temperature, salinity, velocity and depth
 #if defined key_vectopt_loop
@@ -426,14 +426,14 @@
             !
             zub(ji,jj) = un(ji,jj,mbku(ji,jj))      ! bottom velocity
-            zvb(ji,jj) = vn(ji,jj,mbkv(ji,jj)) 
+            zvb(ji,jj) = vn(ji,jj,mbkv(ji,jj))
          END DO
       END DO
-      
+
       !                                   !-------------------!
       IF( nn_bbl_ldf == 1 ) THEN          !   diffusive bbl   !
          !                                !-------------------!
          DO jj = 1, jpjm1                      ! (criteria for non zero flux: grad(rho).grad(h) < 0 )
-            DO ji = 1, jpim1              
-               !                                                ! i-direction 
+            DO ji = 1, jpim1
+               !                                                ! i-direction
                zt = 0.5 * ( ztb (ji,jj) + ztb (ji+1,jj) )  ! T, S anomalie, and depth
                zs = 0.5 * ( zsb (ji,jj) + zsb (ji+1,jj) ) - 35.0
@@ -442,9 +442,9 @@
                zgdrho = (  fsalbt( zt, zs, zh ) * ( ztb(ji+1,jj) - ztb(ji,jj) )    &
                   &                             - ( zsb(ji+1,jj) - zsb(ji,jj) )  ) * umask(ji,jj,1)
-               !                                                     
+               !
                zsign          = SIGN(  0.5, - zgdrho * REAL( mgrhu(ji,jj) )  )    ! sign of ( i-gradient * i-slope )
                ahu_bbl(ji,jj) = ( 0.5 - zsign ) * ahu_bbl_0(ji,jj)                  ! masked diffusive flux coeff.
                !
-               !                                                ! j-direction 
+               !                                                ! j-direction
                zt = 0.5 * ( ztb (ji,jj+1) + ztb (ji,jj) )                ! T, S anomalie, and depth
                zs = 0.5 * ( zsb (ji,jj+1) + zsb (ji,jj) ) - 35.0
@@ -453,5 +453,5 @@
                zgdrho = (  fsalbt( zt, zs, zh ) * ( ztb(ji,jj+1) - ztb(ji,jj) )    &
                   &                             - ( zsb(ji,jj+1) - zsb(ji,jj) )  ) * vmask(ji,jj,1)
-               !                                                    
+               !
                zsign          = SIGN(  0.5, -zgdrho * REAL( mgrhv(ji,jj) )  )     ! sign of ( j-gradient * j-slope )
                ahv_bbl(ji,jj) = ( 0.5 - zsign ) * ahv_bbl_0(ji,jj)
@@ -475,7 +475,7 @@
                   zh = 0.5 * ( zdep(ji,jj) + zdep(ji+1,jj) )
                   !                                                           ! masked bbl i-gradient of density
-                  zgdrho = (  fsalbt( zt, zs, zh ) * ( ztb(ji+1,jj) - ztb(ji,jj) )    &  
+                  zgdrho = (  fsalbt( zt, zs, zh ) * ( ztb(ji+1,jj) - ztb(ji,jj) )    &
                      &                             - ( zsb(ji+1,jj) - zsb(ji,jj) )  ) * umask(ji,jj,1)
-                  !                                                         
+                  !
                   zsign = SIGN(  0.5, - zgdrho   * REAL( mgrhu(ji,jj) )  )    ! sign of i-gradient * i-slope
                   zsigna= SIGN(  0.5, zub(ji,jj) * REAL( mgrhu(ji,jj) )  )    ! sign of u * i-slope
@@ -489,5 +489,5 @@
                   zh = 0.5 * ( zdep(ji,jj+1) + zdep(ji,jj) )
                   !                                                           ! masked bbl j-gradient of density
-                  zgdrho = (  fsalbt( zt, zs, zh ) * ( ztb(ji,jj+1) - ztb(ji,jj) )    &  
+                  zgdrho = (  fsalbt( zt, zs, zh ) * ( ztb(ji,jj+1) - ztb(ji,jj) )    &
                      &                             - ( zsb(ji,jj+1) - zsb(ji,jj) )  ) * vmask(ji,jj,1)
                   zsign = SIGN(  0.5, - zgdrho   * REAL( mgrhv(ji,jj) )  )    ! sign of j-gradient * j-slope
@@ -513,5 +513,5 @@
                   zh = 0.5 * ( zdep(ji,jj) + zdep(ji+1,jj) )
                   zgdrho =    fsbeta( zt, zs, zh )                                    &
-                     &   * (  fsalbt( zt, zs, zh ) * ( ztb(iid,jj) - ztb(iis,jj) )    &  
+                     &   * (  fsalbt( zt, zs, zh ) * ( ztb(iid,jj) - ztb(iis,jj) )    &
                      &                             - ( zsb(iid,jj) - zsb(iis,jj) )  ) * umask(ji,jj,1)
                   zgdrho = MAX( 0.e0, zgdrho )                         ! only if shelf is denser than deep
@@ -530,5 +530,5 @@
                   zh = 0.5 * ( zdep(ji,jj) + zdep(ji,jj+1) )
                   zgdrho =    fsbeta( zt, zs, zh )                                    &
-                     &   * (  fsalbt( zt, zs, zh ) * ( ztb(ji,ijd) - ztb(ji,ijs) )    &  
+                     &   * (  fsalbt( zt, zs, zh ) * ( ztb(ji,ijd) - ztb(ji,ijs) )    &
                      &                             - ( zsb(ji,ijd) - zsb(ji,ijs) )  ) * vmask(ji,jj,1)
                   zgdrho = MAX( 0.e0, zgdrho )                         ! only if shelf is denser than deep
@@ -542,5 +542,5 @@
       ENDIF
       !
-      CALL wrk_dealloc( jpi, jpj, zub, zvb, ztb, zsb, zdep ) 
+      CALL wrk_dealloc( jpi, jpj, zub, zvb, ztb, zsb, zdep )
       !
       IF( nn_timing == 1 )  CALL timing_stop( 'bbl')
@@ -567,5 +567,5 @@
       IF( nn_timing == 1 )  CALL timing_start( 'tra_bbl_init')
       !
-      CALL wrk_alloc( jpi, jpj, zmbk ) 
+      CALL wrk_alloc( jpi, jpj, zmbk )
       !
 
@@ -588,5 +588,5 @@
       !                              ! allocate trabbl arrays
       IF( tra_bbl_alloc() /= 0 )   CALL ctl_stop( 'STOP', 'tra_bbl_init : unable to allocate arrays' )
-     
+
       IF( nn_bbl_adv == 1 )    WRITE(numout,*) '       * Advective BBL using upper velocity'
       IF( nn_bbl_adv == 2 )    WRITE(numout,*) '       * Advective BBL using velocity = F( delta rho)'
@@ -597,5 +597,5 @@
       !                             !* inverse of surface of T-cells
       r1_e1e2t(:,:) = 1._wp / ( e1t(:,:) * e2t(:,:) )
-      
+
       !                             !* vertical index of  "deep" bottom u- and v-points
       DO jj = 1, jpjm1                    ! (the "shelf" bottom k-indices are mbku and mbkv)
@@ -605,5 +605,5 @@
          END DO
       END DO
-      ! converte into REAL to use lbc_lnk ; impose a min value of 1 as a zero can be set in lbclnk 
+      ! converte into REAL to use lbc_lnk ; impose a min value of 1 as a zero can be set in lbclnk
       zmbk(:,:) = REAL( mbku_d(:,:), wp )   ;   CALL lbc_lnk(zmbk,'U',1.)   ;   mbku_d(:,:) = MAX( INT( zmbk(:,:) ), 1 )
       zmbk(:,:) = REAL( mbkv_d(:,:), wp )   ;   CALL lbc_lnk(zmbk,'V',1.)   ;   mbkv_d(:,:) = MAX( INT( zmbk(:,:) ), 1 )
@@ -611,5 +611,5 @@
                                         !* sign of grad(H) at u- and v-points
       mgrhu(jpi,:) = 0.    ;    mgrhu(:,jpj) = 0.   ;    mgrhv(jpi,:) = 0.    ;    mgrhv(:,jpj) = 0.
-      DO jj = 1, jpjm1                
+      DO jj = 1, jpjm1
          DO ji = 1, jpim1
             mgrhu(ji,jj) = INT(  SIGN( 1.e0, fsdept_0(ji+1,jj,mbkt(ji+1,jj)) - fsdept_0(ji,jj,mbkt(ji,jj)) )  )
@@ -618,13 +618,13 @@
       END DO
 
-      DO jj = 1, jpjm1              !* bbl thickness at u- (v-) point 
+      DO jj = 1, jpjm1              !* bbl thickness at u- (v-) point
          DO ji = 1, jpim1                 ! minimum of top & bottom e3u_0 (e3v_0)
-            e3u_bbl_0(ji,jj) = MIN( fse3u_0(ji,jj,mbkt(ji+1,jj  )), fse3u_0(ji,jj,mbkt(ji,jj)) )  
-            e3v_bbl_0(ji,jj) = MIN( fse3v_0(ji,jj,mbkt(ji  ,jj+1)), fse3v_0(ji,jj,mbkt(ji,jj)) )  
-         END DO 
+            e3u_bbl_0(ji,jj) = MIN( fse3u_0(ji,jj,mbkt(ji+1,jj  )), fse3u_0(ji,jj,mbkt(ji,jj)) )
+            e3v_bbl_0(ji,jj) = MIN( fse3v_0(ji,jj,mbkt(ji  ,jj+1)), fse3v_0(ji,jj,mbkt(ji,jj)) )
+         END DO
       END DO
       CALL lbc_lnk( e3u_bbl_0, 'U', 1. )   ;   CALL lbc_lnk( e3v_bbl_0, 'V', 1. )      ! lateral boundary conditions
 
-      !                             !* masked diffusive flux coefficients 
+      !                             !* masked diffusive flux coefficients
       ahu_bbl_0(:,:) = rn_ahtbbl * e2u(:,:) * e3u_bbl_0(:,:) / e1u(:,:)  * umask(:,:,1)
       ahv_bbl_0(:,:) = rn_ahtbbl * e1v(:,:) * e3v_bbl_0(:,:) / e2v(:,:)  * vmask(:,:,1)
@@ -636,5 +636,5 @@
          CASE ( 2 )                          ! ORCA_R2
             ij0 = 102   ;   ij1 = 102              ! Gibraltar enhancement of BBL
-            ii0 = 139   ;   ii1 = 140  
+            ii0 = 139   ;   ii1 = 140
             ahu_bbl_0(mi0(ii0):mi1(ii1),mj0(ij0):mj1(ij1)) =  4.e0*ahu_bbl_0(mi0(ii0):mi1(ii1),mj0(ij0):mj1(ij1))
             ahv_bbl_0(mi0(ii0):mi1(ii1),mj0(ij0):mj1(ij1)) =  4.e0*ahv_bbl_0(mi0(ii0):mi1(ii1),mj0(ij0):mj1(ij1))
@@ -647,5 +647,5 @@
          CASE ( 4 )                          ! ORCA_R4
             ij0 =  52   ;   ij1 =  52              ! Gibraltar enhancement of BBL
-            ii0 =  70   ;   ii1 =  71  
+            ii0 =  70   ;   ii1 =  71
             ahu_bbl_0(mi0(ii0):mi1(ii1),mj0(ij0):mj1(ij1)) =  4.e0*ahu_bbl_0(mi0(ii0):mi1(ii1),mj0(ij0):mj1(ij1))
             ahv_bbl_0(mi0(ii0):mi1(ii1),mj0(ij0):mj1(ij1)) =  4.e0*ahv_bbl_0(mi0(ii0):mi1(ii1),mj0(ij0):mj1(ij1))
@@ -654,5 +654,5 @@
       ENDIF
       !
-      CALL wrk_dealloc( jpi, jpj, zmbk ) 
+      CALL wrk_dealloc( jpi, jpj, zmbk )
       !
       IF( nn_timing == 1 )  CALL timing_stop( 'tra_bbl_init')
Index: branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/OPA_SRC/TRA/trasbc.F90
===================================================================
--- branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/OPA_SRC/TRA/trasbc.F90	(revision 3759)
+++ branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/OPA_SRC/TRA/trasbc.F90	(revision 3764)
@@ -209,13 +209,10 @@
       !----------------------------------------
       !
-      zfact = 0.5e0
-
-      ! Effect on (t,s) due to river runoff (dilution effect automatically applied via vertical tracer advection) 
-      IF( ln_rnf ) THEN  
+      IF( ln_rnf ) THEN         ! input of heat and salt due to river runoff 
+         zfact = 0.5_wp
          DO jj = 2, jpj 
             DO ji = fs_2, fs_jpim1
-               zdep = 1. / h_rnf(ji,jj)
-               zdep = zfact * zdep  
-               IF ( rnf(ji,jj) /= 0._wp ) THEN
+               IF( rnf(ji,jj) /= 0._wp ) THEN
+                  zdep = zfact / h_rnf(ji,jj)
                   DO jk = 1, nk_rnf(ji,jj)
                                         tsa(ji,jj,jk,jp_tem) = tsa(ji,jj,jk,jp_tem)   &
@@ -227,8 +224,6 @@
             END DO  
          END DO  
-      ENDIF  
-!!gm  It should be useless
-      CALL lbc_lnk( tsa(:,:,:,jp_tem), 'T', 1. )    ;    CALL lbc_lnk( tsa(:,:,:,jp_sal), 'T', 1. )
-
+      ENDIF
+ 
       IF( l_trdtra )   THEN                      ! save the horizontal diffusive trends for further diagnostics
          ztrdt(:,:,:) = tsa(:,:,:,jp_tem) - ztrdt(:,:,:)
Index: branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/OPA_SRC/ZDF/zdfbfr.F90
===================================================================
--- branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/OPA_SRC/ZDF/zdfbfr.F90	(revision 3759)
+++ branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/OPA_SRC/ZDF/zdfbfr.F90	(revision 3764)
@@ -18,5 +18,5 @@
    !!----------------------------------------------------------------------
    USE oce             ! ocean dynamics and tracers variables
-   USE dom_oce         ! ocean space and time domain variables 
+   USE dom_oce         ! ocean space and time domain variables
    USE zdf_oce         ! ocean vertical physics variables
    USE in_out_manager  ! I/O manager
@@ -35,14 +35,14 @@
 
    !                                    !!* Namelist nambfr: bottom friction namelist *
-   INTEGER  ::   nn_bfr      = 0           ! = 0/1/2/3 type of bottom friction 
-   REAL(wp) ::   rn_bfri1    = 4.0e-4_wp   ! bottom drag coefficient (linear case) 
-   REAL(wp) ::   rn_bfri2    = 1.0e-3_wp   ! bottom drag coefficient (non linear case)
-   REAL(wp) ::   rn_bfeb2    = 2.5e-3_wp   ! background bottom turbulent kinetic energy  [m2/s2]
-   REAL(wp) ::   rn_bfrien   = 30._wp      ! local factor to enhance coefficient bfri
-   LOGICAL  ::   ln_bfr2d    = .false.     ! logical switch for 2D enhancement
-   LOGICAL  ::   ln_loglayer = .false.     ! switch for log layer bfr coeff.
-   REAL(wp) ::   rn_bfrz0    = 0.003_wp    ! bottom roughness for loglayer bfr coeff
-   LOGICAL , PUBLIC                            ::  ln_bfrimp   = .false.  ! switch for implicit bottom friction
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) ::  bfrcoef2d              ! 2D bottom drag coefficient
+   INTEGER , PUBLIC ::   nn_bfr      = 0           ! = 0/1/2/3 type of bottom friction  (PUBLIC for TAM)
+   REAL(wp), PUBLIC ::   rn_bfri1    = 4.0e-4_wp   ! bottom drag coefficient (linear case)  (PUBLIC for TAM)
+   REAL(wp), PUBLIC ::   rn_bfri2    = 1.0e-3_wp   ! bottom drag coefficient (non linear case) (PUBLIC for TAM)
+   REAL(wp), PUBLIC ::   rn_bfeb2    = 2.5e-3_wp   ! background bottom turbulent kinetic energy  [m2/s2] (PUBLIC for TAM)
+   REAL(wp), PUBLIC ::   rn_bfrien   = 30._wp      ! local factor to enhance coefficient bfri (PUBLIC for TAM)
+   LOGICAL , PUBLIC ::   ln_bfr2d    = .false.     ! logical switch for 2D enhancement (PUBLIC for TAM)
+   LOGICAL , PUBLIC ::   ln_loglayer = .false.     ! switch for log layer bfr coeff. (PUBLIC for TAM)
+   REAL(wp), PUBLIC ::   rn_bfrz0    = 0.003_wp    ! bottom roughness for loglayer bfr coeff (PUBLIC for TAM)
+   LOGICAL , PUBLIC                                    ::  ln_bfrimp = .false.  ! logical switch for implicit bottom friction
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:), PUBLIC ::  bfrcoef2d            ! 2D bottom drag coefficient (PUBLIC for TAM)
 
    !! * Substitutions
@@ -70,9 +70,9 @@
       !!----------------------------------------------------------------------
       !!                   ***  ROUTINE zdf_bfr  ***
-      !!                 
+      !!
       !! ** Purpose :   compute the bottom friction coefficient.
       !!
-      !! ** Method  :   Calculate and store part of the momentum trend due    
-      !!              to bottom friction following the chosen friction type 
+      !! ** Method  :   Calculate and store part of the momentum trend due
+      !!              to bottom friction following the chosen friction type
       !!              (free-slip, linear, or quadratic). The component
       !!              calculated here is multiplied by the bottom velocity in
@@ -124,5 +124,5 @@
             DO ji = 2, jpim1
 # endif
-               ikbu = mbku(ji,jj)         ! ocean bottom level at u- and v-points 
+               ikbu = mbku(ji,jj)         ! ocean bottom level at u- and v-points
                ikbv = mbkv(ji,jj)         ! (deepest ocean u- and v-points)
                !
@@ -135,5 +135,5 @@
                zecv = SQRT(  vn(ji,jj,ikbv) * vn(ji,jj,ikbv) + zuv*zuv + rn_bfeb2  )
                !
-               bfrua(ji,jj) = - 0.5_wp * ( bfrcoef2d(ji,jj) + bfrcoef2d(ji+1,jj  ) ) * zecu 
+               bfrua(ji,jj) = - 0.5_wp * ( bfrcoef2d(ji,jj) + bfrcoef2d(ji+1,jj  ) ) * zecu
                bfrva(ji,jj) = - 0.5_wp * ( bfrcoef2d(ji,jj) + bfrcoef2d(ji  ,jj+1) ) * zecv
             END DO
@@ -156,5 +156,5 @@
       !!----------------------------------------------------------------------
       !!                  ***  ROUTINE zdf_bfr_init  ***
-      !!                    
+      !!
       !! ** Purpose :   Initialization of the bottom friction
       !!
@@ -217,5 +217,5 @@
          bfrcoef2d(:,:) = rn_bfri1  ! initialize bfrcoef2d to the namelist variable
          !
-         IF(ln_bfr2d) THEN 
+         IF(ln_bfr2d) THEN
             ! bfr_coef is a coefficient in [0,1] giving the mask where to apply the bfr enhancement
             CALL iom_open('bfr_coef.nc',inum)
@@ -238,5 +238,5 @@
 
          !
-         IF(ln_bfr2d) THEN 
+         IF(ln_bfr2d) THEN
             ! bfr_coef is a coefficient in [0,1] giving the mask where to apply the bfr enhancement
             CALL iom_open('bfr_coef.nc',inum)
Index: branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/OPA_SRC/ZDF/zdfkpp.F90
===================================================================
--- branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/OPA_SRC/ZDF/zdfkpp.F90	(revision 3759)
+++ branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/OPA_SRC/ZDF/zdfkpp.F90	(revision 3764)
@@ -247,8 +247,8 @@
 #if defined key_zdfddm
       REAL(wp) ::   zrrau, zds, zavdds, zavddt,zinr   ! double diffusion mixing
-      REAL(wp), POINTER, DIMENSION(:,:) ::     zdifs
-      REAL(wp), POINTER, DIMENSION(:)   ::   za2s, za3s, zkmps
+      REAL(wp), POINTER, DIMENSION(:,:)   ::     zdifs
+      REAL(wp), POINTER, DIMENSION(:)     ::   za2s, za3s, zkmps
       REAL(wp) ::                            zkm1s
-      REAL(wp), POINTER, DIMENSION(:,:) ::   zblcs
+      REAL(wp), POINTER, DIMENSION(:,:)   ::   zblcs
       REAL(wp), POINTER, DIMENSION(:,:,:) ::   zdiffus
 #endif
@@ -266,5 +266,5 @@
       CALL wrk_alloc( jpi,4, zdepw, zdift, zvisc )
       CALL wrk_alloc( jpi,jpj, zBo, zBosol, zustar )
-      CALL wrk_alloc( jpi,jpk, zmask, zblcm, zblct, zblcs )
+      CALL wrk_alloc( jpi,jpk, zmask, zblcm, zblct )
 #if defined key_zdfddm
       CALL wrk_alloc( jpi,4, zdifs )
@@ -1081,8 +1081,7 @@
                zdiffut(ji,jj,jk) = zdiffut(ji,jj,jk) * tmask(ji,jj,jk) 
 #if defined key_zdfddm
-               zdiffus(ji,jj,jk) = ( 1.0 - zmask(ji,jk) )          * avs (ji,jj,jk) & ! interior diffusivities 
+               zdiffus(ji,jj,jk) = ( 1.0 - zmask(ji,jk) )         * avs (ji,jj,jk) & ! interior diffusivities 
                   &              +                        zflag   * zblcs(ji,jk   ) & ! boundary layer diffusivities
                   &              + zmask(ji,jk) * ( 1.0 - zflag ) * zkmps(ji      )   ! diffusivity enhancement at W_level near zhbl
-                       
                zdiffus(ji,jj,jk) = zdiffus(ji,jj,jk) * tmask(ji,jj,jk) 
 #endif               
@@ -1212,5 +1211,5 @@
       CALL wrk_dealloc( jpi,4, zdepw, zdift, zvisc )
       CALL wrk_dealloc( jpi,jpj, zBo, zBosol, zustar )
-      CALL wrk_dealloc( jpi,jpk, zmask, zblcm, zblct, zblcs )
+      CALL wrk_dealloc( jpi,jpk, zmask, zblcm, zblct )
 #if defined key_zdfddm
       CALL wrk_dealloc( jpi,4, zdifs )
Index: branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/OPA_SRC/lib_fortran.F90
===================================================================
--- branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/OPA_SRC/lib_fortran.F90	(revision 3759)
+++ branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/OPA_SRC/lib_fortran.F90	(revision 3764)
@@ -8,7 +8,7 @@
 
    !!----------------------------------------------------------------------
-   !!   glob_sum    : generic interface for global masked summation over 
+   !!   glob_sum    : generic interface for global masked summation over
    !!                 the interior domain for 1 or 2 2D or 3D arrays
-   !!                 it works only for T points   
+   !!                 it works only for T points
    !!   SIGN        : generic interface for SIGN to overwrite f95 behaviour
    !!                 of intrinsinc sign function
@@ -29,12 +29,13 @@
 
    INTERFACE glob_sum
-      MODULE PROCEDURE glob_sum_2d, glob_sum_3d,glob_sum_2d_a, glob_sum_3d_a 
+      MODULE PROCEDURE glob_sum_1d, glob_sum_2d, glob_sum_3d, &
+         &             glob_sum_2d_a, glob_sum_3d_a
    END INTERFACE
 
-#if defined key_nosignedzero   
+#if defined key_nosignedzero
    INTERFACE SIGN
       MODULE PROCEDURE SIGN_SCALAR, SIGN_ARRAY_1D, SIGN_ARRAY_2D, SIGN_ARRAY_3D,   &
-         &             SIGN_ARRAY_1D_A, SIGN_ARRAY_2D_A, SIGN_ARRAY_3D_A,          & 
-         &             SIGN_ARRAY_1D_B, SIGN_ARRAY_2D_B, SIGN_ARRAY_3D_B 
+         &             SIGN_ARRAY_1D_A, SIGN_ARRAY_2D_A, SIGN_ARRAY_3D_A,          &
+         &             SIGN_ARRAY_1D_B, SIGN_ARRAY_2D_B, SIGN_ARRAY_3D_B
    END INTERFACE
 #endif
@@ -42,12 +43,27 @@
    !!----------------------------------------------------------------------
    !! NEMO/OPA 3.3 , NEMO Consortium (2010)
-   !! $Id$ 
+   !! $Id$
    !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
    !!----------------------------------------------------------------------
-CONTAINS 
+CONTAINS
 
 #if ! defined key_mpp_rep
-
-   FUNCTION glob_sum_2d( ptab ) 
+   FUNCTION glob_sum_1d( ptab, kdim )
+      !!-----------------------------------------------------------------------
+      !!                  ***  FUNCTION  glob_sum_1D  ***
+      !!
+      !! ** Purpose : perform a masked sum on the inner global domain of a 1D array
+      !!-----------------------------------------------------------------------
+      INTEGER :: kdim
+      REAL(wp), INTENT(in), DIMENSION(kdim) ::   ptab        ! input 1D array
+      REAL(wp)                              ::   glob_sum_1d ! global sum
+      !!-----------------------------------------------------------------------
+      !
+      glob_sum_1d = SUM( ptab(:) )
+      IF( lk_mpp )   CALL mpp_sum( glob_sum_1d )
+      !
+   END FUNCTION glob_sum_1d
+
+   FUNCTION glob_sum_2d( ptab )
       !!-----------------------------------------------------------------------
       !!                  ***  FUNCTION  glob_sum_2D  ***
@@ -63,7 +79,7 @@
       !
    END FUNCTION glob_sum_2d
-   
-   
-   FUNCTION glob_sum_3d( ptab ) 
+
+
+   FUNCTION glob_sum_3d( ptab )
       !!-----------------------------------------------------------------------
       !!                  ***  FUNCTION  glob_sum_3D  ***
@@ -86,5 +102,5 @@
 
 
-   FUNCTION glob_sum_2d_a( ptab1, ptab2 ) 
+   FUNCTION glob_sum_2d_a( ptab1, ptab2 )
       !!-----------------------------------------------------------------------
       !!                  ***  FUNCTION  glob_sum_2D _a ***
@@ -95,5 +111,5 @@
       REAL(wp)            , DIMENSION(2)   ::   glob_sum_2d_a   ! global masked sum
       !!-----------------------------------------------------------------------
-      !             
+      !
       glob_sum_2d_a(1) = SUM( ptab1(:,:)*tmask_i(:,:) )
       glob_sum_2d_a(2) = SUM( ptab2(:,:)*tmask_i(:,:) )
@@ -101,7 +117,7 @@
       !
    END FUNCTION glob_sum_2d_a
- 
- 
-   FUNCTION glob_sum_3d_a( ptab1, ptab2 ) 
+
+
+   FUNCTION glob_sum_3d_a( ptab1, ptab2 )
       !!-----------------------------------------------------------------------
       !!                  ***  FUNCTION  glob_sum_3D_a ***
@@ -124,10 +140,36 @@
    END FUNCTION glob_sum_3d_a
 
-#else  
+#else
    !!----------------------------------------------------------------------
    !!   'key_mpp_rep'                                   MPP reproducibility
    !!----------------------------------------------------------------------
-   
-   FUNCTION glob_sum_2d( ptab ) 
+
+   FUNCTION glob_sum_1d( ptab, kdim )
+      !!----------------------------------------------------------------------
+      !!                  ***  FUNCTION  glob_sum_1d ***
+      !!
+      !! ** Purpose : perform a sum in calling DDPDD routine
+      !!----------------------------------------------------------------------
+      INTEGER , INTENT(in) :: kdim
+      REAL(wp), INTENT(in), DIMENSION(kdim) ::   ptab
+      REAL(wp)                              ::   glob_sum_1d   ! global sum
+      !!
+      COMPLEX(wp)::   ctmp
+      REAL(wp)   ::   ztmp
+      INTEGER    ::   ji   ! dummy loop indices
+      !!-----------------------------------------------------------------------
+      !
+      ztmp = 0.e0
+      ctmp = CMPLX( 0.e0, 0.e0, wp )
+      DO ji = 1, kdim
+         ztmp =  ptab(ji)
+         CALL DDPDD( CMPLX( ztmp, 0.e0, wp ), ctmp )
+         END DO
+      IF( lk_mpp )   CALL mpp_sum( ctmp )   ! sum over the global domain
+      glob_sum_1d = REAL(ctmp,wp)
+      !
+   END FUNCTION glob_sum_1d
+
+   FUNCTION glob_sum_2d( ptab )
       !!----------------------------------------------------------------------
       !!                  ***  FUNCTION  glob_sum_2d ***
@@ -154,8 +196,8 @@
       glob_sum_2d = REAL(ctmp,wp)
       !
-   END FUNCTION glob_sum_2d   
-
-
-   FUNCTION glob_sum_3d( ptab ) 
+   END FUNCTION glob_sum_2d
+
+
+   FUNCTION glob_sum_3d( ptab )
       !!----------------------------------------------------------------------
       !!                  ***  FUNCTION  glob_sum_3d ***
@@ -179,13 +221,13 @@
             CALL DDPDD( CMPLX( ztmp, 0.e0, wp ), ctmp )
             END DO
-         END DO    
+         END DO
       END DO
       IF( lk_mpp )   CALL mpp_sum( ctmp )   ! sum over the global domain
       glob_sum_3d = REAL(ctmp,wp)
       !
-   END FUNCTION glob_sum_3d   
-
-
-   FUNCTION glob_sum_2d_a( ptab1, ptab2 ) 
+   END FUNCTION glob_sum_3d
+
+
+   FUNCTION glob_sum_2d_a( ptab1, ptab2 )
       !!----------------------------------------------------------------------
       !!                  ***  FUNCTION  glob_sum_2d_a ***
@@ -214,8 +256,8 @@
       glob_sum_2d_a = REAL(ctmp,wp)
       !
-   END FUNCTION glob_sum_2d_a   
-
-
-   FUNCTION glob_sum_3d_a( ptab1, ptab2 ) 
+   END FUNCTION glob_sum_2d_a
+
+
+   FUNCTION glob_sum_3d_a( ptab1, ptab2 )
       !!----------------------------------------------------------------------
       !!                  ***  FUNCTION  glob_sum_3d_a ***
@@ -241,10 +283,10 @@
             CALL DDPDD( CMPLX( ztmp, 0.e0, wp ), ctmp )
             END DO
-         END DO    
+         END DO
       END DO
       IF( lk_mpp )   CALL mpp_sum( ctmp )   ! sum over the global domain
       glob_sum_3d_a = REAL(ctmp,wp)
       !
-   END FUNCTION glob_sum_3d_a   
+   END FUNCTION glob_sum_3d_a
 
 #endif
@@ -253,17 +295,17 @@
       !!----------------------------------------------------------------------
       !!               ***  ROUTINE DDPDD ***
-      !!          
+      !!
       !! ** Purpose : Add a scalar element to a sum
-      !!             
-      !!
-      !! ** Method  : The code uses the compensated summation with doublet 
+      !!
+      !!
+      !! ** Method  : The code uses the compensated summation with doublet
       !!              (sum,error) emulated useing complex numbers. ydda is the
-      !!               scalar to add to the summ yddb 
-      !! 
-      !! ** Action  : This does only work for MPI. 
+      !!               scalar to add to the summ yddb
+      !!
+      !! ** Action  : This does only work for MPI.
       !!
       !! References : Using Acurate Arithmetics to Improve Numerical
       !!              Reproducibility and Sability in Parallel Applications
-      !!              Yun HE and Chris H. Q. DING, Journal of Supercomputing 18, 259-277, 2001 
+      !!              Yun HE and Chris H. Q. DING, Journal of Supercomputing 18, 259-277, 2001
       !!----------------------------------------------------------------------
       COMPLEX(wp), INTENT(in   ) ::   ydda
@@ -288,5 +330,5 @@
    !!   'key_nosignedzero'                                         F90 SIGN
    !!----------------------------------------------------------------------
-   
+
    FUNCTION SIGN_SCALAR( pa, pb )
       !!-----------------------------------------------------------------------
@@ -304,5 +346,5 @@
 
 
-   FUNCTION SIGN_ARRAY_1D( pa, pb ) 
+   FUNCTION SIGN_ARRAY_1D( pa, pb )
       !!-----------------------------------------------------------------------
       !!                  ***  FUNCTION SIGN_ARRAY_1D  ***
@@ -319,5 +361,5 @@
 
 
-   FUNCTION SIGN_ARRAY_2D(pa,pb) 
+   FUNCTION SIGN_ARRAY_2D(pa,pb)
       !!-----------------------------------------------------------------------
       !!                  ***  FUNCTION SIGN_ARRAY_2D  ***
@@ -333,5 +375,5 @@
    END FUNCTION SIGN_ARRAY_2D
 
-   FUNCTION SIGN_ARRAY_3D(pa,pb) 
+   FUNCTION SIGN_ARRAY_3D(pa,pb)
       !!-----------------------------------------------------------------------
       !!                  ***  FUNCTION SIGN_ARRAY_3D  ***
@@ -348,5 +390,5 @@
 
 
-   FUNCTION SIGN_ARRAY_1D_A(pa,pb) 
+   FUNCTION SIGN_ARRAY_1D_A(pa,pb)
       !!-----------------------------------------------------------------------
       !!                  ***  FUNCTION SIGN_ARRAY_1D_A  ***
@@ -363,5 +405,5 @@
 
 
-   FUNCTION SIGN_ARRAY_2D_A(pa,pb) 
+   FUNCTION SIGN_ARRAY_2D_A(pa,pb)
       !!-----------------------------------------------------------------------
       !!                  ***  FUNCTION SIGN_ARRAY_2D_A  ***
@@ -378,5 +420,5 @@
 
 
-   FUNCTION SIGN_ARRAY_3D_A(pa,pb) 
+   FUNCTION SIGN_ARRAY_3D_A(pa,pb)
       !!-----------------------------------------------------------------------
       !!                  ***  FUNCTION SIGN_ARRAY_3D_A  ***
@@ -393,5 +435,5 @@
 
 
-   FUNCTION SIGN_ARRAY_1D_B(pa,pb) 
+   FUNCTION SIGN_ARRAY_1D_B(pa,pb)
       !!-----------------------------------------------------------------------
       !!                  ***  FUNCTION SIGN_ARRAY_1D_B  ***
@@ -408,5 +450,5 @@
 
 
-   FUNCTION SIGN_ARRAY_2D_B(pa,pb) 
+   FUNCTION SIGN_ARRAY_2D_B(pa,pb)
       !!-----------------------------------------------------------------------
       !!                  ***  FUNCTION SIGN_ARRAY_2D_B  ***
@@ -423,5 +465,5 @@
 
 
-   FUNCTION SIGN_ARRAY_3D_B(pa,pb) 
+   FUNCTION SIGN_ARRAY_3D_B(pa,pb)
       !!-----------------------------------------------------------------------
       !!                  ***  FUNCTION SIGN_ARRAY_3D_B  ***
Index: branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/OPA_SRC/nemogcm.F90
===================================================================
--- branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/OPA_SRC/nemogcm.F90	(revision 3759)
+++ branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/OPA_SRC/nemogcm.F90	(revision 3764)
@@ -6,13 +6,13 @@
    !! History :  OPA  ! 1990-10  (C. Levy, G. Madec)  Original code
    !!            7.0  ! 1991-11  (M. Imbard, C. Levy, G. Madec)
-   !!            7.1  ! 1993-03  (M. Imbard, C. Levy, G. Madec, O. Marti, M. Guyon, A. Lazar, 
-   !!                             P. Delecluse, C. Perigaud, G. Caniaux, B. Colot, C. Maes) release 7.1 
+   !!            7.1  ! 1993-03  (M. Imbard, C. Levy, G. Madec, O. Marti, M. Guyon, A. Lazar,
+   !!                             P. Delecluse, C. Perigaud, G. Caniaux, B. Colot, C. Maes) release 7.1
    !!             -   ! 1992-06  (L.Terray)  coupling implementation
-   !!             -   ! 1993-11  (M.A. Filiberti) IGLOO sea-ice 
-   !!            8.0  ! 1996-03  (M. Imbard, C. Levy, G. Madec, O. Marti, M. Guyon, A. Lazar, 
+   !!             -   ! 1993-11  (M.A. Filiberti) IGLOO sea-ice
+   !!            8.0  ! 1996-03  (M. Imbard, C. Levy, G. Madec, O. Marti, M. Guyon, A. Lazar,
    !!                             P. Delecluse, L.Terray, M.A. Filiberti, J. Vialar, A.M. Treguier, M. Levy) release 8.0
    !!            8.1  ! 1997-06  (M. Imbard, G. Madec)
-   !!            8.2  ! 1999-11  (M. Imbard, H. Goosse)  LIM sea-ice model 
-   !!                 ! 1999-12  (V. Thierry, A-M. Treguier, M. Imbard, M-A. Foujols)  OPEN-MP 
+   !!            8.2  ! 1999-11  (M. Imbard, H. Goosse)  LIM sea-ice model
+   !!                 ! 1999-12  (V. Thierry, A-M. Treguier, M. Imbard, M-A. Foujols)  OPEN-MP
    !!                 ! 2000-07  (J-M Molines, M. Imbard)  Open Boundary Conditions  (CLIPPER)
    !!   NEMO     1.0  ! 2002-08  (G. Madec)  F90: Free form and modules
@@ -25,5 +25,5 @@
    !!             -   ! 2007-07  (J. Chanut, A. Sellar) Unstructured open boundaries (BDY)
    !!            3.2  ! 2009-08  (S. Masson)  open/write in the listing file in mpp
-   !!            3.3  ! 2010-05  (K. Mogensen, A. Weaver, M. Martin, D. Lea) Assimilation interface 
+   !!            3.3  ! 2010-05  (K. Mogensen, A. Weaver, M. Martin, D. Lea) Assimilation interface
    !!             -   ! 2010-10  (C. Ethe, G. Madec) reorganisation of initialisation phase
    !!            3.3.1! 2011-01  (A. R. Porter, STFC Daresbury) dynamical allocation
@@ -34,5 +34,5 @@
    !!   nemo_gcm       : solve ocean dynamics, tracer, biogeochemistry and/or sea-ice
    !!   nemo_init      : initialization of the NEMO system
-   !!   nemo_ctl       : initialisation of the contol print 
+   !!   nemo_ctl       : initialisation of the contol print
    !!   nemo_closefile : close remaining open files
    !!   nemo_alloc     : dynamical allocation
@@ -64,4 +64,5 @@
    USE diadct          ! sections transports           (dia_dct_init routine)
    USE diaobs          ! Observation diagnostics       (dia_obs_init routine)
+   USE lib_fortran     ! Fortran utilities (allows no signed zero when 'key_nosignedzero' defined)
    USE step            ! NEMO time-stepping                 (stp     routine)
    USE icbini          ! handle bergs, initialisation
@@ -83,5 +84,4 @@
    USE sbctide, ONLY: lk_tide
 
-
    IMPLICIT NONE
    PRIVATE
@@ -89,4 +89,5 @@
    PUBLIC   nemo_gcm    ! called by model.F90
    PUBLIC   nemo_init   ! needed by AGRIF
+   PUBLIC   nemo_alloc  ! needed by TAM
 
    CHARACTER(lc) ::   cform_aaa="( /, 'AAAAAAAA', / ) "     ! flag for output listing
@@ -103,5 +104,5 @@
       !!                     ***  ROUTINE nemo_gcm  ***
       !!
-      !! ** Purpose :   NEMO solves the primitive equations on an orthogonal 
+      !! ** Purpose :   NEMO solves the primitive equations on an orthogonal
       !!              curvilinear mesh on the sphere.
       !!
@@ -151,15 +152,11 @@
           IF( lk_asminc ) THEN
              IF( ln_bkgwri ) CALL asm_bkg_wri( nit000 - 1 )    ! Output background fields
-             IF( ln_trjwri ) CALL asm_trj_wri( nit000 - 1 )    ! Output trajectory fields
              IF( ln_asmdin ) THEN                        ! Direct initialization
                 IF( ln_trainc ) CALL tra_asm_inc( nit000 - 1 )    ! Tracers
-                IF( ln_dyninc ) THEN 
-                   CALL dyn_asm_inc( nit000 - 1 )    ! Dynamics
-                   IF ( ln_asmdin ) CALL ssh_wzv ( nit000 - 1 )      ! update vertical velocity 
-                ENDIF
+                IF( ln_dyninc ) CALL dyn_asm_inc( nit000 - 1 )    ! Dynamics
                 IF( ln_sshinc ) CALL ssh_asm_inc( nit000 - 1 )    ! SSH
              ENDIF
           ENDIF
-        
+
          DO WHILE ( istp <= nitend .AND. nstop == 0 )
 #if defined key_agrif
@@ -176,5 +173,5 @@
       !
       IF( ln_icebergs )   CALL icb_end( nitend )
-       
+
       !                            !------------------------!
       !                            !==  finalize the run  ==!
@@ -184,5 +181,5 @@
       IF( nstop /= 0 .AND. lwp ) THEN   ! error print
          WRITE(numout,cform_err)
-         WRITE(numout,*) nstop, ' error have been found' 
+         WRITE(numout,*) nstop, ' error have been found'
       ENDIF
       !
@@ -261,5 +258,5 @@
       lwp = (narea == 1) .OR. ln_ctl                        ! control of all listing output print
 
-      ! If dimensions of processor grid weren't specified in the namelist file 
+      ! If dimensions of processor grid weren't specified in the namelist file
       ! then we calculate them here now that we have our communicator size
       IF( (jpni < 1) .OR. (jpnj < 1) )THEN
@@ -302,5 +299,5 @@
          WRITE(numout,*)
          WRITE(numout,*)
-         DO ji = 1, SIZE(cltxt) 
+         DO ji = 1, SIZE(cltxt)
             IF( TRIM(cltxt(ji)) /= '' )   WRITE(numout,*) cltxt(ji)      ! control print of mynode
          END DO
@@ -309,5 +306,5 @@
       ENDIF
 
-      ! Now we know the dimensions of the grid and numout has been set we can 
+      ! Now we know the dimensions of the grid and numout has been set we can
       ! allocate arrays
       CALL nemo_alloc()
@@ -336,5 +333,5 @@
       IF( ln_ctl        )   CALL prt_ctl_init   ! Print control
 
-      IF( lk_obc        )   CALL     obc_init   ! Open boundaries 
+      IF( lk_obc        )   CALL     obc_init   ! Open boundaries
 
                             CALL  istate_init   ! ocean initial state (Dynamics and tracers)
@@ -349,5 +346,5 @@
 
       !                                     ! Ocean physics
-                            CALL     sbc_init   ! Forcings : surface module 
+                            CALL     sbc_init   ! Forcings : surface module
       !                                         ! Vertical physics
                             CALL     zdf_init      ! namelist read
@@ -358,5 +355,5 @@
       IF( lk_zdfkpp     )   CALL zdf_kpp_init      ! KPP closure scheme
       IF( lk_zdftmx     )   CALL zdf_tmx_init      ! tidal vertical mixing
-      IF( lk_zdfddm .AND. .NOT. lk_zdfkpp )   & 
+      IF( lk_zdfddm .AND. .NOT. lk_zdfkpp )   &
          &                  CALL zdf_ddm_init      ! double diffusive mixing
       !                                         ! Lateral physics
@@ -381,5 +378,5 @@
                             CALL dyn_zdf_init   ! vertical diffusion
                             CALL dyn_spg_init   ! surface pressure gradient
-                            
+
       !                                     ! Misc. options
       IF( nn_cla == 1   )   CALL cla_init       ! Cross Land Advection
@@ -401,5 +398,5 @@
                             CALL dia_obs_init            ! Initialize observational data
                             CALL dia_obs( nit000 - 1 )   ! Observation operator for restart
-      ENDIF      
+      ENDIF
       !                                     ! Assimilation increments
       IF( lk_asminc     )   CALL asm_inc_init   ! Initialize assimilation increments
@@ -413,5 +410,5 @@
       !!                     ***  ROUTINE nemo_ctl  ***
       !!
-      !! ** Purpose :   control print setting 
+      !! ** Purpose :   control print setting
       !!
       !! ** Method  : - print namctl information and check some consistencies
@@ -460,5 +457,5 @@
          !                              ! indices used for the SUM control
          IF( nictls+nictle+njctls+njctle == 0 )   THEN    ! print control done over the default area
-            lsp_area = .FALSE.                        
+            lsp_area = .FALSE.
          ELSE                                             ! print control done over a specific  area
             lsp_area = .TRUE.
@@ -482,5 +479,5 @@
       ENDIF
       !
-      IF( nbench == 1 ) THEN              ! Benchmark 
+      IF( nbench == 1 ) THEN              ! Benchmark
          SELECT CASE ( cp_cfg )
          CASE ( 'gyre' )   ;   CALL ctl_warn( ' The Benchmark is activated ' )
@@ -493,4 +490,8 @@
          &                                               'with the IOM Input/Output manager. '         ,   &
          &                                               'Compile with key_iomput enabled' )
+      !
+      IF( 1_wp /= SIGN(1._wp,-0._wp)  )   CALL ctl_stop( 'nemo_ctl: The intrinsec SIGN function follows ',  &
+         &                                               'f2003 standard. '                              ,  &
+         &                                               'Compile with key_nosignedzero enabled' )
       !
    END SUBROUTINE nemo_ctl
@@ -544,5 +545,5 @@
       !!----------------------------------------------------------------------
       !
-      ierr =        oce_alloc       ()          ! ocean 
+      ierr =        oce_alloc       ()          ! ocean
       ierr = ierr + dia_wri_alloc   ()
       ierr = ierr + dom_oce_alloc   ()          ! ocean domain
@@ -568,5 +569,5 @@
       !!                 ***  ROUTINE nemo_partition  ***
       !!
-      !! ** Purpose :   
+      !! ** Purpose :
       !!
       !! ** Method  :
@@ -616,5 +617,5 @@
       !!
       !! ** Purpose :   return the prime factors of n.
-      !!                knfax factors are returned in array kfax which is of 
+      !!                knfax factors are returned in array kfax which is of
       !!                maximum dimension kmaxfax.
       !! ** Method  :
@@ -684,8 +685,8 @@
       !!=====================================================================
       !!----------------------------------------------------------------------
-      !! 
+      !!
       !! ** Purpose :   Initialization of the northern neighbours lists.
       !!----------------------------------------------------------------------
-      !!    1.0  ! 2011-10  (A. C. Coward, NOCS & J. Donners, PRACE) 
+      !!    1.0  ! 2011-10  (A. C. Coward, NOCS & J. Donners, PRACE)
       !!----------------------------------------------------------------------
 
@@ -769,5 +770,5 @@
       jtyp = 5
       lrankset = .FALSE.
-      znnbrs = narea 
+      znnbrs = narea
       CALL lbc_lnk( znnbrs, 'J', 1. ) ! first ice U-V point
 
@@ -782,5 +783,5 @@
       ENDIF
 
-      znnbrs = narea 
+      znnbrs = narea
       CALL lbc_lnk( znnbrs, 'K', 1. ) ! second ice U-V point
 
@@ -805,5 +806,5 @@
          END DO
          !
-         ! For northern row areas, set l_north_nogather so that all subsequent exchanges 
+         ! For northern row areas, set l_north_nogather so that all subsequent exchanges
          ! can use peer to peer communications at the north fold
          !
Index: branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/OPA_SRC/step.F90
===================================================================
--- branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/OPA_SRC/step.F90	(revision 3759)
+++ branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/OPA_SRC/step.F90	(revision 3764)
@@ -29,5 +29,5 @@
    !!   stp             : OPA system time-stepping
    !!----------------------------------------------------------------------
-   USE step_oce         ! time stepping definition modules 
+   USE step_oce         ! time stepping definition modules
 #if defined key_top
    USE trcstp           ! passive tracer time-stepping      (trc_stp routine)
@@ -62,13 +62,13 @@
       !!----------------------------------------------------------------------
       !!                     ***  ROUTINE stp  ***
-      !!                      
+      !!
       !! ** Purpose : - Time stepping of OPA (momentum and active tracer eqs.)
       !!              - Time stepping of LIM (dynamic and thermodynamic eqs.)
       !!              - Tme stepping  of TRC (passive tracer eqs.)
-      !! 
-      !! ** Method  : -1- Update forcings and data  
-      !!              -2- Update ocean physics 
-      !!              -3- Compute the t and s trends 
-      !!              -4- Update t and s 
+      !!
+      !! ** Method  : -1- Update forcings and data
+      !!              -2- Update ocean physics
+      !!              -3- Compute the t and s trends
+      !!              -4- Update t and s
       !!              -5- Compute the momentum trends
       !!              -6- Update the horizontal velocity
@@ -86,6 +86,6 @@
 # if defined key_iomput
       IF( Agrif_Nbstepint() == 0 )   CALL iom_swap
-# endif   
-#endif   
+# endif
+#endif
                              indic = 0                ! reset to no error condition
       IF( kstp /= nit000 )   CALL day( kstp )         ! Calendar (day was already called at nit000 in day_init)
@@ -113,7 +113,7 @@
                          CALL bn2( tsn, rn2  )        ! now    Brunt-Vaisala frequency
       !
-      !  VERTICAL PHYSICS   
+      !  VERTICAL PHYSICS
                          CALL zdf_bfr( kstp )         ! bottom friction
-                         
+
       !                                               ! Vertical eddy viscosity and diffusivity coefficients
       IF( lk_zdfric  )   CALL zdf_ric( kstp )            ! Richardson number dependent Kz
@@ -135,5 +135,5 @@
       IF( lk_zdfddm .AND. .NOT. lk_zdfkpp )   &
          &               CALL zdf_ddm( kstp )         ! double diffusive mixing
-         
+
                          CALL zdf_mxl( kstp )         ! mixed layer depth
 
@@ -142,5 +142,5 @@
       IF( lrst_oce .AND. lk_zdfgls )   CALL gls_rst( kstp, 'WRITE' )
       !
-      !  LATERAL  PHYSICS 
+      !  LATERAL  PHYSICS
       !
       IF( lk_ldfslp ) THEN                            ! slope of lateral mixing
@@ -211,5 +211,5 @@
          IF( ln_zps      )   CALL zps_hde( kstp, jpts, tsa, gtsu, gtsv,  &    ! zps: time filtered hor. derivative
             &                                          rhd, gru , grv  )      ! of t, s, rd at the last ocean level
-         
+
       ELSE                                                  ! centered hpg  (eos then time stepping)
                              CALL eos    ( tsn, rhd, rhop )      ! now in situ density for hpg computation
@@ -218,5 +218,5 @@
          IF( ln_zdfnpc   )   CALL tra_npc( kstp )                ! update after fields by non-penetrative convection
                              CALL tra_nxt( kstp )                ! tracer fields at next time step
-      ENDIF 
+      ENDIF
 
       !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
@@ -228,4 +228,5 @@
       IF(  ln_asmiau .AND. &
          & ln_dyninc       )   CALL dyn_asm_inc( kstp )     ! apply dynamics assimilation increment
+      IF( ln_bkgwri )          CALL asm_bkg_wri( kstp )     ! output background fields
       IF( ln_neptsimp )        CALL dyn_nept_cor( kstp )    ! subtract Neptune velocities (simplified)
       IF( lk_bdy           )   CALL bdy_dyn3d_dmp(kstp )    ! bdy damping trends
@@ -238,5 +239,5 @@
 #endif
                                CALL dyn_hpg( kstp )         ! horizontal gradient of Hydrostatic pressure
-                               CALL dyn_bfr( kstp )         ! bottom friction   
+                               CALL dyn_bfr( kstp )         ! bottom friction
                                CALL dyn_zdf( kstp )         ! vertical diffusion
                                CALL dyn_spg( kstp, indic )  ! surface pressure gradient
@@ -263,8 +264,8 @@
       ! Trends                              (ua, va, tsa used as workspace)
       !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
-      IF( nstop == 0 ) THEN                         
-         IF( lk_trddyn     )   CALL trd_dwr( kstp )         ! trends: dynamics 
+      IF( nstop == 0 ) THEN
+         IF( lk_trddyn     )   CALL trd_dwr( kstp )         ! trends: dynamics
          IF( lk_trdtra     )   CALL trd_twr( kstp )         ! trends: active tracers
-         IF( lk_trdmld     )   CALL trd_mld( kstp )         ! trends: Mixed-layer 
+         IF( lk_trdmld     )   CALL trd_mld( kstp )         ! trends: Mixed-layer
          IF( lk_trdvor     )   CALL trd_vor( kstp )         ! trends: vorticity budget
       ENDIF
Index: branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/OPA_SRC/step_oce.F90
===================================================================
--- branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/OPA_SRC/step_oce.F90	(revision 3759)
+++ branches/2012/dev_MERGE_2012/NEMOGCM/NEMO/OPA_SRC/step_oce.F90	(revision 3764)
@@ -7,5 +7,5 @@
    !!----------------------------------------------------------------------
    USE oce              ! ocean dynamics and tracers variables
-   USE dom_oce          ! ocean space and time domain variables 
+   USE dom_oce          ! ocean space and time domain variables
    USE zdf_oce          ! ocean vertical physics variables
    USE ldftra_oce       ! ocean tracer   - trends
@@ -84,5 +84,5 @@
    USE trdmld_rst       ! restart for mixed-layer trends
    USE trdmod_oce       ! ocean momentum/tracers trends
-   USE trdmod           ! momentum/tracers trends   
+   USE trdmod           ! momentum/tracers trends
    USE trdvor           ! vorticity budget                 (trd_vor routine)
    USE diaptr           ! poleward transports              (dia_ptr routine)
@@ -98,5 +98,5 @@
    USE asminc           ! assimilation increments      (tra_asm_inc routine)
    !                                                   (dyn_asm_inc routine)
-
+   USE asmbkg
    USE stpctl           ! time stepping control            (stp_ctl routine)
    USE prtctl           ! Print control                    (prt_ctl routine)
@@ -104,5 +104,5 @@
    USE diaobs           ! Observation operator
 
-   USE timing           ! Timing            
+   USE timing           ! Timing
 
 #if defined key_agrif
Index: branches/2012/dev_MERGE_2012/NEMOGCM/SETTE/iodef_sette.xml
===================================================================
--- branches/2012/dev_MERGE_2012/NEMOGCM/SETTE/iodef_sette.xml	(revision 3759)
+++ branches/2012/dev_MERGE_2012/NEMOGCM/SETTE/iodef_sette.xml	(revision 3764)
@@ -67,5 +67,4 @@
   </context>
   
-
   <context id="xios">
 
