Index: /NEMO/branches/NERC/dev_r11078_OSMOSIS_IMMERSE_Nurser_4.0/src/OCE/ZDF/zdfosm.F90
===================================================================
--- /NEMO/branches/NERC/dev_r11078_OSMOSIS_IMMERSE_Nurser_4.0/src/OCE/ZDF/zdfosm.F90	(revision 14533)
+++ /NEMO/branches/NERC/dev_r11078_OSMOSIS_IMMERSE_Nurser_4.0/src/OCE/ZDF/zdfosm.F90	(revision 14534)
@@ -1055,4 +1055,5 @@
        WRITE(narea+100,'(a,*(g11.3))') ' ghamu[imld-1..ibld+2] =', ( ghamu(ji,jj,jk), jk=jl,jm )
        WRITE(narea+100,'(a,*(g11.3))') ' ghamv[imld-1..ibld+2] =', ( ghamv(ji,jj,jk), jk=jl,jm )
+       WRITE(narea+100,*)
        FLUSH(narea+100)
     END IF
@@ -1203,4 +1204,5 @@
        WRITE(narea+100,'(a,*(g11.3))') ' ghamu[imld-1..ibld+2] =', ( ghamu(ji,jj,jk), jk=jl,jm )
        WRITE(narea+100,'(a,*(g11.3))') ' ghamv[imld-1..ibld+2] =', ( ghamv(ji,jj,jk), jk=jl,jm )
+       WRITE(narea+100,*)
        FLUSH(narea+100)
     END IF
@@ -1316,4 +1318,23 @@
        END DO
     END DO
+#ifdef key_osm_debug
+    IF(narea==nn_narea_db) THEN
+       ji=iloc_db; jj=jloc_db
+       jl = imld(ji,jj) - 1; jm = MIN(ibld(ji,jj) + 2, mbkt(ji,jj) )
+       WRITE(narea+100,'(2(a,g11.3))')'Stokes + buoy + pyc + transport contribs to ghamt/contrib to ghamt/s:  zsc_wth_1=',zsc_wth_1(ji,jj), '  zsc_ws_1=',zsc_ws_1(ji,jj)
+       IF (lpyc(ji,jj)) WRITE(narea+100,'(2(a,g11.3))') 'zsc_wth_pyc=', zsc_wth_pyc(ji,jj), '  zsc_wth_pyc=',zsc_wth_pyc(ji,jj)
+       WRITE(narea+100,'(a,*(g11.3))') ' ghamt[imld-1..ibld+2] =', ( ghamt(ji,jj,jk), jk=jl,jm )
+       WRITE(narea+100,'(a,*(g11.3))') ' ghams[imld-1..ibld+2] =', ( ghams(ji,jj,jk), jk=jl,jm )
+       IF( lconv(ji,jj) ) THEN
+          WRITE(narea+100,'(2(a,g11.3))')'Unstable; transport contrib to ghamu/v:  zsc_uw_1=',zsc_uw_1(ji,jj), '  zsc_vw_1=',zsc_vw_1(ji,jj)
+       ELSE
+          WRITE(narea+100,'(3(a,g11.3))')'Stable; transport contrib to ghamu/v:  zsc_uw_1=',zsc_uw_1(ji,jj), '  zsc_vw_1=',zsc_vw_1(ji,jj), &
+               &' zsc_uw_2=',zsc_uw_2(ji,jj)
+       END IF
+       WRITE(narea+100,'(a,*(g11.3))') ' ghamu[imld-1..ibld+2] =', ( ghamu(ji,jj,jk), jk=jl,jm )
+       WRITE(narea+100,*)
+       FLUSH(narea+100)
+    END IF
+#endif
 
     IF(ln_dia_osm) THEN
@@ -1376,4 +1397,17 @@
        END DO       ! ji loop
     END DO          ! jj loop
+#ifdef key_osm_debug
+    IF(narea==nn_narea_db) THEN
+       ji=iloc_db; jj=jloc_db
+       jl = imld(ji,jj) - 1; jm = MIN(ibld(ji,jj) + 2, mbkt(ji,jj) )
+       WRITE(narea+100,'(a)')'Tweak gham[uv] to go to zero near surface, add pycnocline viscosity/diffusivity  & set=0 at ibld'
+       WRITE(narea+100,'(a,*(g11.3))') ' ghamt[imld-1..ibld+2] =', ( ghamt(ji,jj,jk), jk=jl,jm )
+       WRITE(narea+100,'(a,*(g11.3))') ' ghams[imld-1..ibld+2] =', ( ghams(ji,jj,jk), jk=jl,jm )
+       WRITE(narea+100,'(a,*(g11.3))') ' ghamu[imld-1..ibld+2] =', ( ghamu(ji,jj,jk), jk=jl,jm )
+       WRITE(narea+100,'(a,*(g11.3))') ' ghamv[imld-1..ibld+2] =', ( ghamv(ji,jj,jk), jk=jl,jm )
+       WRITE(narea+100,*)
+       FLUSH(narea+100)
+    END IF
+#endif
 
     IF(ln_dia_osm) THEN
@@ -1462,4 +1496,15 @@
        END DO
     END IF ! ln_convmix = .true.
+#ifdef key_osm_debug
+    IF(narea==nn_narea_db) THEN
+       ji=iloc_db; jj=jloc_db
+       jl = imld(ji,jj) - 1; jm = MIN(ibld(ji,jj) + 2, mbkt(ji,jj) )
+       WRITE(narea+100,'(a)') ' After including KPP Ri# diffusivity & viscosity'
+       WRITE(narea+100,'(a,*(g11.3))') ' zdiffut[imld-1..ibld+2] =', ( zdiffut(ji,jj,jk), jk=jl,jm )
+       WRITE(narea+100,'(a,*(g11.3))') ' zviscos[imld-1..ibld+2] =', ( zviscos(ji,jj,jk), jk=jl,jm )
+       WRITE(narea+100,*)
+       FLUSH(narea+100)
+    END IF
+#endif
 
 
@@ -1495,4 +1540,16 @@
           END DO
        END DO
+#ifdef key_osm_debug
+       IF(narea==nn_narea_db) THEN
+          ji=iloc_db; jj=jloc_db
+          jl = imld(ji,jj) - 1; jm = MIN(ibld(ji,jj) + 2, mbkt(ji,jj) )
+          WRITE(narea+100,'(a)') ' After including FK diffusivity & non-local terms'
+          WRITE(narea+100,'(a,*(g11.3))') ' zdiffut[imld-1..ibld+2] =', ( zdiffut(ji,jj,jk), jk=jl,jm )
+          WRITE(narea+100,'(a,*(g11.3))') ' ghamt[imld-1..ibld+2] =', ( ghamt(ji,jj,jk), jk=jl,jm )
+          WRITE(narea+100,'(a,*(g11.3))') ' ghams[imld-1..ibld+2] =', ( ghams(ji,jj,jk), jk=jl,jm )
+          WRITE(narea+100,*)
+          FLUSH(narea+100)
+       END IF
+#endif
     ENDIF
 
@@ -1540,4 +1597,19 @@
     CALL lbc_lnk_multi( 'zdfosm', ghamt, 'W', 1. , ghams, 'W', 1.,   &
          &                  ghamu, 'U', -1. , ghamv, 'V', -1. )
+#ifdef key_osm_debug
+    IF(narea==nn_narea_db) THEN
+       ji=iloc_db; jj=jloc_db
+       jl = imld(ji,jj) - 1; jm = MIN(ibld(ji,jj) + 2, mbkt(ji,jj) )
+       WRITE(narea+100,'(a)') ' Final diffusivity & viscosity, & non-local terms'
+       WRITE(narea+100,'(a,*(g11.3))') ' p_avt[imld-1..ibld+2] =', ( p_avt(ji,jj,jk), jk=jl,jm )
+       WRITE(narea+100,'(a,*(g11.3))') ' p_avm[imld-1..ibld+2] =', ( p_avm(ji,jj,jk), jk=jl,jm )
+       WRITE(narea+100,'(a,*(g11.3))') ' ghamt[imld-1..ibld+2] =', ( ghamt(ji,jj,jk), jk=jl,jm )
+       WRITE(narea+100,'(a,*(g11.3))') ' ghams[imld-1..ibld+2] =', ( ghams(ji,jj,jk), jk=jl,jm )
+       WRITE(narea+100,'(a,*(g11.3))') ' ghamu[imld-1..ibld+2] =', ( ghamu(ji,jj,jk), jk=jl,jm )
+       WRITE(narea+100,'(a,*(g11.3))') ' ghamv[imld-1..ibld+2] =', ( ghamv(ji,jj,jk), jk=jl,jm )
+       WRITE(narea+100,*)
+       FLUSH(narea+100)
+    END IF
+#endif
 
     IF(ln_dia_osm) THEN
