Index: branches/UKMO/r6232_HZG_WAVE-coupling/NEMOGCM/NEMO/OPA_SRC/SBC/sbcflx.F90
===================================================================
--- branches/UKMO/r6232_HZG_WAVE-coupling/NEMOGCM/NEMO/OPA_SRC/SBC/sbcflx.F90	(revision 8115)
+++ branches/UKMO/r6232_HZG_WAVE-coupling/NEMOGCM/NEMO/OPA_SRC/SBC/sbcflx.F90	(revision 8415)
@@ -20,7 +20,8 @@
    USE iom             ! IOM library
    USE in_out_manager  ! I/O manager
+   USE sbcwave         ! wave physics
    USE lib_mpp         ! distribued memory computing library
    USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
-   USE sbcwave         ! wave physics
+   USE wrk_nemo        ! work arrays
 
    IMPLICIT NONE
@@ -37,4 +38,6 @@
    TYPE(FLD), ALLOCATABLE, DIMENSION(:) ::   sf    ! structure of input fields (file informations, fields read)
    LOGICAL , PUBLIC    ::   ln_shelf_flx = .FALSE. ! UKMO SHELF specific flux flag
+   LOGICAL , PUBLIC    ::   ln_rel_wind = .FALSE.  ! UKMO SHELF specific flux flag - relative winds
+   REAL(wp)            ::   rn_wfac                ! multiplication factor for ice/ocean velocity in the calculation of wind stress (clem)
    INTEGER             ::   jpfld_local   ! maximum number of files to read (locally modified depending on ln_shelf_flx) 
 
@@ -88,5 +91,5 @@
       !!
       CHARACTER(len=100) ::  cn_dir                               ! Root directory for location of flx files
-      NAMELIST/namsbc_flx/ ln_shelf_flx                           ! Put here to allow merging with another UKMO branch
+      NAMELIST/namsbc_flx/ ln_shelf_flx, ln_rel_wind, rn_wfac     ! Put here to allow merging with another UKMO branch
       TYPE(FLD_N), DIMENSION(jpfld) ::   slf_i                    ! array of namelist information structures
       TYPE(FLD_N) ::   sn_utau, sn_vtau, sn_qtot, sn_qsr, sn_emp  ! informations about the fields to be read
@@ -132,4 +135,23 @@
      
       IF( MOD( kt-1, nn_fsbc ) == 0 ) THEN                        ! update ocean fluxes at each SBC frequency
+
+         !!UKMO SHELF wind speed relative to surface currents - put here to allow merging with coupling branch
+         IF( ln_shelf_flx ) THEN
+            CALL wrk_alloc( jpi,jpj, zwnd_i, zwnd_j )
+
+            IF( ln_rel_wind ) THEN
+               DO jj = 2, jpjm1
+                  DO ji = fs_2, fs_jpim1   ! vect. opt.
+                     zwnd_i(ji,jj) = ( sf(jp_utau)%fnow(ji,jj,1) - rn_wfac * 0.5 * ( ssu_m(ji-1,jj  ) + ssu_m(ji,jj) ))
+                     zwnd_j(ji,jj) = ( sf(jp_vtau)%fnow(ji,jj,1) - rn_wfac * 0.5 * ( ssv_m(ji  ,jj-1) + ssv_m(ji,jj) ))
+                  END DO
+               END DO
+               CALL lbc_lnk( zwnd_i(:,:) , 'T', -1. )
+               CALL lbc_lnk( zwnd_j(:,:) , 'T', -1. )
+            ELSE
+               zwnd_i(:,:) = sf(jp_utau)%fnow(:,:,1)
+               zwnd_j(:,:) = sf(jp_vtau)%fnow(:,:,1)
+            ENDIF
+         ENDIF
 
          IF( ln_dm2dc ) THEN   ;   qsr(:,:) = sbc_dcy( sf(jp_qsr)%fnow(:,:,1) )   ! modify now Qsr to include the diurnal cycle
@@ -154,6 +176,6 @@
                   DO jj = 1, jpj
                      DO ji = 1, jpi
-                        utau(ji,jj) = sf(jp_utau)%fnow(ji,jj,1)
-                        vtau(ji,jj) = sf(jp_vtau)%fnow(ji,jj,1)
+                        utau(ji,jj) = zwnd_i(ji,jj)
+                        vtau(ji,jj) = zwnd_i(ji,jj)
                      END DO
                   END DO
@@ -161,7 +183,7 @@
                   DO jj = 1, jpj
                      DO ji = 1, jpi
-                        totwind = sqrt((sf(jp_utau)%fnow(ji,jj,1))**2.0 + (sf(jp_vtau)%fnow(ji,jj,1))**2.0)
-                        utau(ji,jj) = zrhoa * cdn_wave(ji,jj) * sf(jp_utau)%fnow(ji,jj,1) * totwind
-                        vtau(ji,jj) = zrhoa * cdn_wave(ji,jj) * sf(jp_vtau)%fnow(ji,jj,1) * totwind
+                        totwind = sqrt(zwnd_i(ji,jj)*zwnd_i(ji,jj) + zwnd_j(ji,jj)*zwnd_j(ji,jj))
+                        utau(ji,jj) = zrhoa * cdn_wave(ji,jj) * zwnd_i(ji,jj) * totwind
+                        vtau(ji,jj) = zrhoa * cdn_wave(ji,jj) * zwnd_j(ji,jj) * totwind
                      END DO
                   END DO
@@ -170,7 +192,7 @@
                DO jj = 1, jpj
                   DO ji = 1, jpi
-                     totwind = sqrt((sf(jp_utau)%fnow(ji,jj,1))**2.0 + (sf(jp_vtau)%fnow(ji,jj,1))**2.0)
-                     utau(ji,jj) = zrhoa * zcdrag * sf(jp_utau)%fnow(ji,jj,1) * totwind
-                     vtau(ji,jj) = zrhoa * zcdrag * sf(jp_vtau)%fnow(ji,jj,1) * totwind
+                     totwind = sqrt(zwnd_i(ji,jj)*zwnd_i(ji,jj) + zwnd_j(ji,jj)*zwnd_j(ji,jj))
+                     utau(ji,jj) = zrhoa * zcdrag * zwnd_i(ji,jj) * totwind
+                     vtau(ji,jj) = zrhoa * zcdrag * zwnd_j(ji,jj) * totwind
                   END DO
                END DO
@@ -191,4 +213,5 @@
                taum(ji,jj) = zmod
                IF( ln_shelf_flx ) THEN
+                  ! winds as received, not relative to the current
                   ztx = sf(jp_utau)%fnow(ji-1,jj  ) + sf(jp_utau)%fnow(ji,jj)
                   zty = sf(jp_vtau)%fnow(ji  ,jj-1) + sf(jp_vtau)%fnow(ji,jj)
@@ -216,4 +239,8 @@
          ENDIF
          !
+         IF( ln_shelf_flx ) THEN
+            CALL wrk_dealloc( jpi,jpj, zwnd_i, zwnd_j )
+         ENDIF
+         !
       ENDIF
       !
