Index: branches/UKMO/AMM15_v3_6_STABLE_package/NEMOGCM/NEMO/OPA_SRC/ASM/asminc.F90
===================================================================
--- branches/UKMO/AMM15_v3_6_STABLE_package/NEMOGCM/NEMO/OPA_SRC/ASM/asminc.F90	(revision 9180)
+++ branches/UKMO/AMM15_v3_6_STABLE_package/NEMOGCM/NEMO/OPA_SRC/ASM/asminc.F90	(revision 9181)
@@ -40,4 +40,16 @@
 #endif
    USE sbc_oce          ! Surface boundary condition variables.
+   USE zdfmxl, ONLY :  &  
+   &  hmld_tref,       &   
+#if defined key_karaml
+   &  hmld_kara,       &
+   &  ln_kara,         &
+#endif   
+   &  hmld,            & 
+   &  hmlp,            &
+   &  hmlpt
+#if defined key_bdy 
+   USE bdy_oce, ONLY: bdytmask  
+#endif  
 
    IMPLICIT NONE
@@ -90,4 +102,11 @@
    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::   seaice_bkginc         ! Increment to the background sea ice conc
 
+   INTEGER :: mld_choice        = 4   !: choice of mld criteria to use for physics assimilation
+                                      !: 1) hmld      - Turbocline/mixing depth                           [W points]
+                                      !: 2) hmlp      - Density criterion (0.01 kg/m^3 change from 10m)   [W points]
+                                      !: 3) hmld_kara - Kara MLD                                          [Interpolated]
+                                      !: 4) hmld_tref - Temperature criterion (0.2 K change from surface) [T points]
+
+
    !! * Substitutions
 #  include "domzgr_substitute.h90"
@@ -121,4 +140,5 @@
       INTEGER :: iitiaustr_date  ! Date YYYYMMDD of IAU interval start time step
       INTEGER :: iitiaufin_date  ! Date YYYYMMDD of IAU interval final time step
+      INTEGER :: isurfstat       ! Local integer for status of reading surft variable
       INTEGER :: iitavgbkg_date  ! Date YYYYMMDD of end of assim bkg averaging period
       !
@@ -130,5 +150,14 @@
       REAL(wp) :: zdate_inc    ! Time axis in increments file
       !
+      REAL(wp), ALLOCATABLE, DIMENSION(:,:) :: & 
+          &       t_bkginc_2d  ! file for reading in 2D  
+      !                        ! temperature increments 
+      REAL(wp), ALLOCATABLE, DIMENSION(:,:) :: & 
+          &       z_mld     ! Mixed layer depth 
+          
       REAL(wp), POINTER, DIMENSION(:,:) ::   hdiv   ! 2D workspace
+      !
+      LOGICAL :: lk_surft      ! Logical: T => Increments file contains surft variable 
+                               !               so only apply surft increments.
       !!
       NAMELIST/nam_asminc/ ln_bkgwri, ln_avgbkg,                           &
@@ -136,5 +165,5 @@
          &                 ln_asmdin, ln_asmiau,                           &
          &                 nitbkg, nitdin, nitiaustr, nitiaufin, niaufn,   &
-         &                 ln_salfix, salfixmin, nn_divdmp, nitavgbkg
+         &                 ln_salfix, salfixmin, nn_divdmp, nitavgbkg, mld_choice
       !!----------------------------------------------------------------------
 
@@ -193,4 +222,5 @@
          WRITE(numout,*) '      Logical switch for ensuring that the sa > salfixmin      ln_salfix = ', ln_salfix
          WRITE(numout,*) '      Minimum salinity after applying the increments           salfixmin = ', salfixmin
+         WRITE(numout,*) '      Choice of MLD for physics assimilation                  mld_choice = ', mld_choice
       ENDIF
 
@@ -358,20 +388,26 @@
       !--------------------------------------------------------------------
 
-      ALLOCATE( t_bkginc(jpi,jpj,jpk) )
-      ALLOCATE( s_bkginc(jpi,jpj,jpk) )
-      ALLOCATE( u_bkginc(jpi,jpj,jpk) )
-      ALLOCATE( v_bkginc(jpi,jpj,jpk) )
-      ALLOCATE( ssh_bkginc(jpi,jpj)   )
-      ALLOCATE( seaice_bkginc(jpi,jpj))
+      IF ( ln_trainc ) THEN
+         ALLOCATE( t_bkginc(jpi,jpj,jpk) )
+         ALLOCATE( s_bkginc(jpi,jpj,jpk) )
+         t_bkginc(:,:,:) = 0.0
+         s_bkginc(:,:,:) = 0.0
+      ENDIF
+      IF ( ln_dyninc ) THEN 
+         ALLOCATE( u_bkginc(jpi,jpj,jpk) )
+         ALLOCATE( v_bkginc(jpi,jpj,jpk) )
+         u_bkginc(:,:,:) = 0.0
+         v_bkginc(:,:,:) = 0.0
+      ENDIF
+      IF ( ln_sshinc ) THEN
+         ALLOCATE( ssh_bkginc(jpi,jpj)   )
+         ssh_bkginc(:,:) = 0.0
+      ENDIF
+      IF ( ln_seaiceinc ) THEN 
+         ALLOCATE( seaice_bkginc(jpi,jpj))
+         seaice_bkginc(:,:) = 0.0
+      ENDIF
 #if defined key_asminc
       ALLOCATE( ssh_iau(jpi,jpj)      )
-#endif
-      t_bkginc(:,:,:) = 0.0
-      s_bkginc(:,:,:) = 0.0
-      u_bkginc(:,:,:) = 0.0
-      v_bkginc(:,:,:) = 0.0
-      ssh_bkginc(:,:) = 0.0
-      seaice_bkginc(:,:) = 0.0
-#if defined key_asminc
       ssh_iau(:,:)    = 0.0
 #endif
@@ -409,13 +445,72 @@
 
          IF ( ln_trainc ) THEN   
-            CALL iom_get( inum, jpdom_autoglo, 'bckint', t_bkginc, 1 )
-            CALL iom_get( inum, jpdom_autoglo, 'bckins', s_bkginc, 1 )
-            ! Apply the masks
-            t_bkginc(:,:,:) = t_bkginc(:,:,:) * tmask(:,:,:)
-            s_bkginc(:,:,:) = s_bkginc(:,:,:) * tmask(:,:,:)
-            ! Set missing increments to 0.0 rather than 1e+20
-            ! to allow for differences in masks
-            WHERE( ABS( t_bkginc(:,:,:) ) > 1.0e+10 ) t_bkginc(:,:,:) = 0.0
-            WHERE( ABS( s_bkginc(:,:,:) ) > 1.0e+10 ) s_bkginc(:,:,:) = 0.0
+
+            !Test if the increments file contains the surft variable.
+            isurfstat = iom_varid( inum, 'bckinsurft', ldstop = .FALSE. )
+            IF ( isurfstat == -1 ) THEN
+               lk_surft = .FALSE.
+            ELSE
+               lk_surft = .TRUE.
+               CALL ctl_warn( ' Applying 2D temperature increment to bottom of ML: ', &
+            &                 ' bckinsurft found in increments file.' )
+            ENDIF             
+
+            IF (lk_surft) THEN 
+                
+               ALLOCATE(z_mld(jpi,jpj)) 
+               SELECT CASE(mld_choice) 
+               CASE(1) 
+                  z_mld = hmld 
+               CASE(2) 
+                  z_mld = hmlp 
+               CASE(3) 
+#if defined key_karaml
+                  IF ( ln_kara ) THEN
+                     z_mld = hmld_kara
+                  ELSE
+                     CALL ctl_stop("Kara mixed layer not calculated as ln_kara=.false.")
+                  ENDIF
+#else
+                  CALL ctl_stop("Kara mixed layer not defined in current version of NEMO")  ! JW: Safety feature, should be removed
+                                                                                            ! once the Kara mixed layer is available 
+#endif
+               CASE(4) 
+                  z_mld = hmld_tref 
+               END SELECT       
+                      
+               ALLOCATE( t_bkginc_2d(jpi,jpj) ) 
+               CALL iom_get( inum, jpdom_autoglo, 'bckinsurft', t_bkginc_2d, 1) 
+#if defined key_bdy                
+               DO jk = 1,jpkm1 
+                  WHERE( z_mld(:,:) > fsdepw(:,:,jk) ) 
+                     t_bkginc(:,:,jk) = t_bkginc_2d(:,:) * 0.5 * &
+                     &       ( 1 + cos( (fsdept(:,:,jk)/z_mld(:,:) ) * rpi ) )
+                     
+                     t_bkginc(:,:,jk) = t_bkginc(:,:,jk) * bdytmask(:,:) 
+                  ELSEWHERE 
+                     t_bkginc(:,:,jk) = 0. 
+                  ENDWHERE 
+               ENDDO 
+#else 
+               t_bkginc(:,:,:) = 0. 
+#endif                
+               s_bkginc(:,:,:) = 0. 
+                
+               DEALLOCATE(z_mld, t_bkginc_2d) 
+            
+            ELSE 
+               
+               CALL iom_get( inum, jpdom_autoglo, 'bckint', t_bkginc, 1 )
+               CALL iom_get( inum, jpdom_autoglo, 'bckins', s_bkginc, 1 )
+               ! Apply the masks
+               t_bkginc(:,:,:) = t_bkginc(:,:,:) * tmask(:,:,:)
+               s_bkginc(:,:,:) = s_bkginc(:,:,:) * tmask(:,:,:)
+               ! Set missing increments to 0.0 rather than 1e+20
+               ! to allow for differences in masks
+               WHERE( ABS( t_bkginc(:,:,:) ) > 1.0e+10 ) t_bkginc(:,:,:) = 0.0
+               WHERE( ABS( s_bkginc(:,:,:) ) > 1.0e+10 ) s_bkginc(:,:,:) = 0.0
+         
+            ENDIF
+
          ENDIF
 
Index: branches/UKMO/AMM15_v3_6_STABLE_package/NEMOGCM/NEMO/OPA_SRC/ZDF/zdfmxl.F90
===================================================================
--- branches/UKMO/AMM15_v3_6_STABLE_package/NEMOGCM/NEMO/OPA_SRC/ZDF/zdfmxl.F90	(revision 9180)
+++ branches/UKMO/AMM15_v3_6_STABLE_package/NEMOGCM/NEMO/OPA_SRC/ZDF/zdfmxl.F90	(revision 9181)
@@ -27,6 +27,8 @@
    PRIVATE
 
+   PUBLIC   zdf_mxl_tref  ! called by asminc.F90
    PUBLIC   zdf_mxl       ! called by step.F90
 
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   hmld_tref  !: mixed layer depth at t-points - temperature criterion [m]
    INTEGER , PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   nmln    !: number of level in the mixed layer (used by TOP)
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   hmld    !: mixing layer depth (turbocline)      [m]
@@ -78,4 +80,5 @@
         &          ll_found(jpi,jpj), ll_belowml(jpi,jpj,jpk), STAT= zdf_mxl_alloc )
          !
+         ALLOCATE(hmld_tref(jpi,jpj))
          IF( lk_mpp             )   CALL mpp_sum ( zdf_mxl_alloc )
          IF( zdf_mxl_alloc /= 0 )   CALL ctl_warn('zdf_mxl_alloc: failed to allocate arrays.')
@@ -84,4 +87,47 @@
    END FUNCTION zdf_mxl_alloc
 
+
+   SUBROUTINE zdf_mxl_tref()
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE zdf_mxl_tref  ***
+      !!                   
+      !! ** Purpose :   Compute the mixed layer depth with temperature criteria.
+      !!
+      !! ** Method  :   The temperature-defined mixed layer depth is required
+      !!                   when assimilating SST in a 2D analysis. 
+      !!
+      !! ** Action  :   hmld_tref
+      !!----------------------------------------------------------------------
+      !
+      INTEGER  ::   ji, jj, jk   ! dummy loop indices
+      REAL(wp) ::   t_ref               ! Reference temperature  
+      REAL(wp) ::   temp_c = 0.2        ! temperature criterion for mixed layer depth  
+      !!----------------------------------------------------------------------
+      !
+      ! Initialise array
+      IF( zdf_mxl_alloc() /= 0 )   CALL ctl_stop( 'STOP', 'zdf_mxl_tref : unable to allocate arrays' )
+      
+      !For the AMM model assimiation uses a temperature based mixed layer depth  
+      !This is defined here  
+      DO jj = 1, jpj  
+         DO ji = 1, jpi  
+           hmld_tref(ji,jj)=fsdept(ji,jj,1  )   
+           IF(ssmask(ji,jj) > 0.)THEN  
+             t_ref=tsn(ji,jj,1,jp_tem) 
+             DO jk=2,jpk  
+               IF(ssmask(ji,jj)==0.)THEN  
+                  hmld_tref(ji,jj)=fsdept(ji,jj,jk )  
+                  EXIT  
+               ELSEIF( ABS(tsn(ji,jj,jk,jp_tem)-t_ref) < temp_c)THEN  
+                  hmld_tref(ji,jj)=fsdept(ji,jj,jk )  
+               ELSE  
+                  EXIT  
+               ENDIF  
+             ENDDO  
+           ENDIF  
+         ENDDO  
+      ENDDO
+
+   END SUBROUTINE zdf_mxl_tref
 
    SUBROUTINE zdf_mxl( kt )
Index: branches/UKMO/AMM15_v3_6_STABLE_package/NEMOGCM/NEMO/OPA_SRC/nemogcm.F90
===================================================================
--- branches/UKMO/AMM15_v3_6_STABLE_package/NEMOGCM/NEMO/OPA_SRC/nemogcm.F90	(revision 9180)
+++ branches/UKMO/AMM15_v3_6_STABLE_package/NEMOGCM/NEMO/OPA_SRC/nemogcm.F90	(revision 9181)
@@ -480,5 +480,11 @@
 
       !                                     ! Assimilation increments
-      IF( lk_asminc     )   CALL asm_inc_init   ! Initialize assimilation increments
+      IF( lk_asminc ) THEN 
+#if defined key_shelf 
+         CALL  zdf_mxl_tref()     ! Initialization of hmld_tref
+#endif 
+         CALL asm_inc_init     ! Initialize assimilation increments 
+      ENDIF
+
       IF(lwp) WRITE(numout,*) 'Euler time step switch is ', neuler
                             CALL dia_tmb_init  ! TMB outputs
