Index: branches/UKMO/dev_r5518_GO6_package/NEMOGCM/CONFIG/SHARED/namelist_ref
===================================================================
--- branches/UKMO/dev_r5518_GO6_package/NEMOGCM/CONFIG/SHARED/namelist_ref	(revision 8401)
+++ branches/UKMO/dev_r5518_GO6_package/NEMOGCM/CONFIG/SHARED/namelist_ref	(revision 8427)
@@ -971,4 +971,5 @@
                            !        = 0  constant 10 m length scale
                            !        = 1  0.5m at the equator to 30m poleward of 40 degrees
+   rn_c        =   0.8     !  Default value only used when nn_htau = 2 (typically never!)
 /
 !------------------------------------------------------------------------
Index: branches/UKMO/dev_r5518_GO6_package/NEMOGCM/CONFIG/SHARED/namelist_top_MEDUSA_et_al_cfg
===================================================================
--- branches/UKMO/dev_r5518_GO6_package/NEMOGCM/CONFIG/SHARED/namelist_top_MEDUSA_et_al_cfg	(revision 8401)
+++ 	(revision )
@@ -1,119 +1,0 @@
-!!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-!! NEMO/TOP1 :   - tracer run information                (namtrc_run)
-!!               - tracer definition                     (namtrc    )
-!!               - tracer data initialisation            (namtrc_dta)
-!!               - tracer advection                      (namtrc_adv)
-!!               - tracer lateral diffusion              (namtrc_ldf)
-!!               - tracer vertical physics               (namtrc_zdf)
-!!               - tracer newtonian damping              (namtrc_dmp)
-!!               - dynamical tracer trends               (namtrc_trd)
-!!               - tracer output diagonstics             (namtrc_dia)
-!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-!-----------------------------------------------------------------------
-&namtrc_run     !   run information
-!-----------------------------------------------------------------------
-   nn_dttrc      =  1        !  time step frequency for passive sn_tracers
-   nn_writetrc   =  640     !  time step frequency for sn_tracer outputs
-   ln_top_euler  = .false.    !  use Euler time-stepping for TOP
-   ln_rsttr      = .false.   !  start from a restart file (T) or not (F)
-   nn_rsttr      =   0       !  restart control = 0 initial time step is not compared to the restart file value
-                           !                  = 1 do not use the value in the restart file
-                           !                  = 2 calendar parameters read in the restart file
-   cn_trcrst_in  = "restart_trc"   !  suffix of pass. sn_tracer restart name (input)
-   cn_trcrst_indir = "."           !  directory from which to read input passive tracer restarts
-   cn_trcrst_out = "restart_trc"   !  suffix of pass. sn_tracer restart name (output)
-   cn_trcrst_outdir = "."          !  directory to which to write output passive tracer restarts
-/
-!-----------------------------------------------------------------------
-&namtrc     !   tracers definition
-!-----------------------------------------------------------------------
-   ln_trcdta     =  .false.  !  Initialisation from data input file (T) or not (F)
-   ln_trcdmp     =  .false.  !  add a damping termn (T) or not (F)
-   ln_trcdmp_clo =  .false.  !  damping term (T) or not (F) on closed seas
-/
-!-----------------------------------------------------------------------
-&namtrc_dta      !    Initialisation from data input file
-!-----------------------------------------------------------------------
-!
-   cn_dir        =  './'      !  root directory for the location of the data files
-/
-!-----------------------------------------------------------------------
-&namtrc_adv    !   advection scheme for passive tracer 
-!-----------------------------------------------------------------------
-   ln_trcadv_cen2    =  .false.  !  2nd order centered scheme   
-   ln_trcadv_tvd     =  .true.  !  TVD scheme
-   ln_trcadv_muscl   =  .false.   !  MUSCL scheme
-   ln_trcadv_muscl2  =  .false.  !  MUSCL2 scheme + cen2 at boundaries
-   ln_trcadv_ubs     =  .false.  !  UBS scheme
-   ln_trcadv_qck     =  .false.  !  QUICKEST scheme
-   ln_trcadv_msc_ups =  .false.  !  use upstream scheme within muscl
-/
-!-----------------------------------------------------------------------
-&namtrc_ldf    !   lateral diffusion scheme for passive tracer 
-!-----------------------------------------------------------------------
-!                               !  Type of the operator : 
-   ln_trcldf_lap    =  .true.   !     laplacian operator       
-   ln_trcldf_bilap  =  .false.  !     bilaplacian operator     
-                                !  Direction of action  :
-   ln_trcldf_level  =  .false.  !     iso-level                
-   ln_trcldf_hor    =  .false.  !     horizontal (geopotential)         (require "key_ldfslp" when ln_sco=T)
-   ln_trcldf_iso    =  .true.   !     iso-neutral                       (require "key_ldfslp")
-!                               !  Coefficient
-   rn_ahtrc_0       =  2000.    !  horizontal eddy diffusivity for tracers [m2/s]
-   rn_ahtrb_0       =     0.    !     background eddy diffusivity for ldf_iso [m2/s]
-/
-!-----------------------------------------------------------------------
-&namtrc_zdf        !   vertical physics
-!-----------------------------------------------------------------------
-   ln_trczdf_exp   =  .false.  !  split explicit (T) or implicit (F) time stepping
-   nn_trczdf_exp   =   3       !  number of sub-timestep for ln_trczdfexp=T
-/
-!-----------------------------------------------------------------------
-&namtrc_rad        !  treatment of negative concentrations 
-!-----------------------------------------------------------------------
-   ln_trcrad   =  .true.  !  artificially correct negative concentrations (T) or not (F)
-/
-!-----------------------------------------------------------------------
-&namtrc_dmp    !   passive tracer newtonian damping   
-!-----------------------------------------------------------------------
-   nn_zdmp_tr  =    1      !  vertical   shape =0    damping throughout the water column
-                           !                   =1 no damping in the mixing layer (kz  criteria)
-                           !                   =2 no damping in the mixed  layer (rho crieria)
-   cn_resto_tr  = 'resto_tr.nc'    !  create a damping.coeff NetCDF file (=1) or not (=0)
-/
-!-----------------------------------------------------------------------
-&namtrc_ice       !    Representation of sea ice growth & melt effects
-!-----------------------------------------------------------------------
-   nn_ice_tr   =  -1        !  tracer concentration in sea ice 
-                           !    =-1 (no vvl: identical cc in ice and ocean / vvl: cc_ice = 0)
-                           !    = 0 (no vvl: cc_ice = zero / vvl: cc_ice = )
-                           !    = 1 prescribed to a namelist value (implemented in pisces only)
-/
-!-----------------------------------------------------------------------
-&namtrc_trd       !   diagnostics on tracer trends        ('key_trdtrc')
-!                          or mixed-layer trends          ('key_trdmld_trc')
-!----------------------------------------------------------------------
-   nn_trd_trc  =  640       !  time step frequency and tracers trends
-   nn_ctls_trc =   0        !  control surface type in mixed-layer trends (0,1 or n<jpk)
-   rn_ucf_trc  =   1        !  unit conversion factor (=1 -> /seconds ; =86400. -> /day)
-   ln_trdmld_trc_restart = .false.  !  restart for ML diagnostics
-   ln_trdmld_trc_instant = .true.  !  flag to diagnose trends of instantantaneous or mean ML T/S
-   ln_trdtrc(1)  =   .true.
-   ln_trdtrc(2)  =   .true.
-   ln_trdtrc(23) =   .true.
-/
-!-----------------------------------------------------------------------
-&namtrc_dia       !   parameters for passive tracer additional diagnostics
-!----------------------------------------------------------------------
-   ln_diatrc     =  .false.  !  save additional diag. (T) or not (F)
-   ln_diabio     =  .true.   !  output biological trends
-   nn_writedia   =  640      !  time step frequency for diagnostics
-   nn_writebio   =  640      !: frequency of biological outputs
-/
-!----------------------------------------------------------------------
-! namtrc_bc       !   data for boundary conditions
-!-----------------------------------------------------------------------
-&namtrc_bc
-!
-   cn_dir        =  './'      !  root directory for the location of the data files
-/
Index: branches/UKMO/dev_r5518_GO6_package/NEMOGCM/CONFIG/SHARED/namelist_top_MEDUSA_et_al_ref
===================================================================
--- branches/UKMO/dev_r5518_GO6_package/NEMOGCM/CONFIG/SHARED/namelist_top_MEDUSA_et_al_ref	(revision 8401)
+++ branches/UKMO/dev_r5518_GO6_package/NEMOGCM/CONFIG/SHARED/namelist_top_MEDUSA_et_al_ref	(revision 8427)
@@ -62,4 +62,5 @@
    rn_ahtrc_0       =  2000.    !  horizontal eddy diffusivity for tracers [m2/s]
    rn_ahtrb_0       =     0.    !     background eddy diffusivity for ldf_iso [m2/s]
+   rn_fact_lap      =     1.    !     enhanced zonal eddy diffusivity
 /
 !-----------------------------------------------------------------------
Index: branches/UKMO/dev_r5518_GO6_package/NEMOGCM/NEMO/OPA_SRC/DOM/dom_oce.F90
===================================================================
--- branches/UKMO/dev_r5518_GO6_package/NEMOGCM/NEMO/OPA_SRC/DOM/dom_oce.F90	(revision 8401)
+++ branches/UKMO/dev_r5518_GO6_package/NEMOGCM/NEMO/OPA_SRC/DOM/dom_oce.F90	(revision 8427)
@@ -355,4 +355,7 @@
          &      gdept_0 (jpi,jpj,jpk) , e3t_0(jpi,jpj,jpk) , e3u_0 (jpi,jpj,jpk) ,                         &
          &      gdepw_0 (jpi,jpj,jpk) , e3w_0(jpi,jpj,jpk) , e3vw_0(jpi,jpj,jpk) , e3uw_0(jpi,jpj,jpk) , STAT=ierr(4) )
+
+      ! Initilaise key variables at risk of being intercepted before properly set up. 
+      e3t_0(:,:,:) = 0.0
          !
 #if defined key_vvl
@@ -368,4 +371,7 @@
          &      ehu_b    (jpi,jpj)    , ehv_b  (jpi,jpj),                                                     &
          &      ehur_b   (jpi,jpj)    , ehvr_b (jpi,jpj),                                  STAT=ierr(5) )                          
+
+      ! Initilaise key variables at risk of being intercepted before properly set up. 
+      e3t_n(:,:,:) = 0.0
 #endif
          !
Index: branches/UKMO/dev_r5518_GO6_package/NEMOGCM/NEMO/OPA_SRC/SBC/sbccpl.F90
===================================================================
--- branches/UKMO/dev_r5518_GO6_package/NEMOGCM/NEMO/OPA_SRC/SBC/sbccpl.F90	(revision 8401)
+++ branches/UKMO/dev_r5518_GO6_package/NEMOGCM/NEMO/OPA_SRC/SBC/sbccpl.F90	(revision 8427)
@@ -2137,4 +2137,5 @@
       REAL(wp) ::   zumax, zvmax
       REAL(wp), POINTER, DIMENSION(:,:)   ::   zfr_l, ztmp1, ztmp2, zotx1, zoty1, zotz1, zitx1, zity1, zitz1
+      REAL(wp), POINTER, DIMENSION(:,:)   ::   zotx1_in, zoty1_in
       REAL(wp), POINTER, DIMENSION(:,:,:) ::   ztmp3, ztmp4   
       !!----------------------------------------------------------------------
@@ -2143,4 +2144,5 @@
       !
       CALL wrk_alloc( jpi,jpj, zfr_l, ztmp1, ztmp2, zotx1, zoty1, zotz1, zitx1, zity1, zitz1 )
+      CALL wrk_alloc( jpi,jpj, zotx1_in, zoty1_in)
       CALL wrk_alloc( jpi,jpj,jpl, ztmp3, ztmp4 )
 
@@ -2411,5 +2413,5 @@
             zotx1(:,:) = un(:,:,1)  
             zoty1(:,:) = vn(:,:,1)  
-         ELSE        
+         ELSE
             SELECT CASE( TRIM( sn_snd_crt%cldes ) )
             CASE( 'oce only'             )      ! C-grid ==> T
@@ -2547,11 +2549,15 @@
                   ENDDO
                ENDDO
-               
+
                ! Ensure any N fold and wrap columns are updated
                CALL lbc_lnk(ztmp1, 'V', -1.0)
                CALL lbc_lnk(ztmp2, 'U', -1.0)
-               
+                            
                ikchoix = -1
-               CALL repcmo (zotx1,ztmp2,ztmp1,zoty1,zotx1,zoty1,ikchoix)
+               ! We need copies of zotx1 and zoty2 in order to avoid problems 
+               ! caused by INTENTs used in the following subroutine. 
+               zotx1_in(:,:) = zotx1(:,:)
+               zoty1_in(:,:) = zoty1(:,:)
+               CALL repcmo (zotx1_in,ztmp2,ztmp1,zoty1_in,zotx1,zoty1,ikchoix)
            ENDIF
          ENDIF
@@ -2622,4 +2628,5 @@
       !
       CALL wrk_dealloc( jpi,jpj, zfr_l, ztmp1, ztmp2, zotx1, zoty1, zotz1, zitx1, zity1, zitz1 )
+      CALL wrk_dealloc( jpi,jpj, zotx1_in, zoty1_in )
       CALL wrk_dealloc( jpi,jpj,jpl, ztmp3, ztmp4 )
       !
Index: branches/UKMO/dev_r5518_GO6_package/NEMOGCM/NEMO/OPA_SRC/TRA/eosbn2.F90
===================================================================
--- branches/UKMO/dev_r5518_GO6_package/NEMOGCM/NEMO/OPA_SRC/TRA/eosbn2.F90	(revision 8401)
+++ branches/UKMO/dev_r5518_GO6_package/NEMOGCM/NEMO/OPA_SRC/TRA/eosbn2.F90	(revision 8427)
@@ -312,6 +312,6 @@
       REAL(wp), DIMENSION(jpi,jpj,jpk,jpts), INTENT(in   ) ::   pts    ! 1 : potential temperature  [Celcius]
       !                                                                ! 2 : salinity               [psu]
-      REAL(wp), DIMENSION(jpi,jpj,jpk     ), INTENT(  out) ::   prd    ! in situ density            [-]
-      REAL(wp), DIMENSION(jpi,jpj,jpk     ), INTENT(  out) ::   prhop  ! potential density (surface referenced)
+      REAL(wp), DIMENSION(jpi,jpj,jpk     ), INTENT(inout) ::   prd    ! in situ density            [-]
+      REAL(wp), DIMENSION(jpi,jpj,jpk     ), INTENT(inout) ::   prhop  ! potential density (surface referenced)
       REAL(wp), DIMENSION(jpi,jpj,jpk     ), INTENT(in   ) ::   pdep   ! depth                      [m]
       !
@@ -902,5 +902,5 @@
       REAL(wp), DIMENSION(jpi,jpj,jpk,jpts), INTENT(in   ) ::  pts   ! pot. temperature and salinity   [Celcius,psu]
       REAL(wp), DIMENSION(jpi,jpj,jpk,jpts), INTENT(in   ) ::  pab   ! thermal/haline expansion coef.  [Celcius-1,psu-1]
-      REAL(wp), DIMENSION(jpi,jpj,jpk     ), INTENT(  out) ::  pn2   ! Brunt-Vaisala frequency squared [1/s^2]
+      REAL(wp), DIMENSION(jpi,jpj,jpk     ), INTENT(inout) ::  pn2   ! Brunt-Vaisala frequency squared [1/s^2]
       !
       INTEGER  ::   ji, jj, jk      ! dummy loop indices
Index: branches/UKMO/dev_r5518_GO6_package/NEMOGCM/NEMO/TOP_SRC/trcrst.F90
===================================================================
--- branches/UKMO/dev_r5518_GO6_package/NEMOGCM/NEMO/TOP_SRC/trcrst.F90	(revision 8401)
+++ branches/UKMO/dev_r5518_GO6_package/NEMOGCM/NEMO/TOP_SRC/trcrst.F90	(revision 8427)
@@ -745,4 +745,5 @@
       !!---------------------------------------------------------------------
       INTEGER  :: jk, jn
+      CHARACTER (LEN=18) :: text_zmean
       REAL(wp) :: ztraf, zmin, zmax, zmean, areasf
       REAL(wp), DIMENSION(jpi,jpj) :: zvol
@@ -750,5 +751,10 @@
 
       IF( lwp )  WRITE(numout,*) 'STAT- ', names
-      !
+      
+      ! fse3t_a will be undefined at the start of a run, but this routine
+      ! may be called at any stage! Hence we MUST make sure it is 
+      ! initialised to zero when allocated to enable us to test for 
+      ! zero content here and avoid potentially dangerous and non-portable 
+      ! operations (e.g. divide by zero, global sums of junk values etc.)   
       zvol(:,:) = e1e2t(:,:) * fse3t_a(:,:,1) * tmask(:,:,1)
       ztraf = glob_sum( dgtr(:,:) * zvol(:,:) )
@@ -761,9 +767,15 @@
          CALL mpp_max( zmax )      ! max over the global domain
       END IF
-      zmean  = ztraf / areasf
-      IF(lwp) WRITE(numout,9002) TRIM( names ), zmean, zmin, zmax
-      !
-      IF(lwp) WRITE(numout,*)
-9002  FORMAT(' tracer name :',a10,'    mean :',e18.10,'    min :',e18.10, &
+
+      text_zmean = "N/A"
+      ! Avoid divide by zero. areasf must be positive.
+      IF  (areasf > 0.0) THEN 
+         zmean = ztraf / areasf
+         WRITE(text_zmean,'(e18.10)') zmean
+      ENDIF
+
+      IF(lwp) WRITE(numout,9002) TRIM( names ), text_zmean, zmin, zmax
+
+  9002  FORMAT(' tracer name :',A,'    mean :',A,'    min :',e18.10, &
       &      '    max :',e18.10 )
       !
