Index: branches/2013/dev_r3858_NOC_ZTC/NEMOGCM/NEMO/OPA_SRC/BDY/bdydta.F90
===================================================================
--- branches/2013/dev_r3858_NOC_ZTC/NEMOGCM/NEMO/OPA_SRC/BDY/bdydta.F90	(revision 3859)
+++ branches/2013/dev_r3858_NOC_ZTC/NEMOGCM/NEMO/OPA_SRC/BDY/bdydta.F90	(revision 4105)
@@ -29,4 +29,5 @@
    USE iom             ! IOM library
    USE in_out_manager  ! I/O logical units
+   USE dynspg_oce, ONLY: lk_dynspg_ts ! Split-explicit free surface flag
 #if defined key_lim2
    USE ice_2
@@ -93,6 +94,6 @@
          CALL wrk_alloc(jpi,jpj,pu2d,pv2d) 
 
-         pu2d(:,:) = 0.e0
-         pv2d(:,:) = 0.e0
+         pu2d(:,:) = 0._wp
+         pv2d(:,:) = 0._wp
 
          DO ik = 1, jpkm1   !! Vertically integrated momentum trends
@@ -195,7 +196,7 @@
                IF( nn_dyn2d(ib_bdy) .gt. 0 ) THEN
                   IF( nn_dyn2d_dta(ib_bdy) .eq. 2 ) THEN ! tidal harmonic forcing ONLY: initialise arrays
-                     dta_bdy(ib_bdy)%ssh(:) = 0.0
-                     dta_bdy(ib_bdy)%u2d(:) = 0.0
-                     dta_bdy(ib_bdy)%v2d(:) = 0.0
+                     dta_bdy(ib_bdy)%ssh(:) = 0._wp
+                     dta_bdy(ib_bdy)%u2d(:) = 0._wp
+                     dta_bdy(ib_bdy)%v2d(:) = 0._wp
                   ENDIF
                   IF (nn_tra(ib_bdy).ne.4) THEN
@@ -216,5 +217,5 @@
 
                            igrd = 2                      ! zonal velocity
-                           dta_bdy(ib_bdy)%u2d(:) = 0.0
+                           dta_bdy(ib_bdy)%u2d(:) = 0._wp
                            DO ib = 1, idx_bdy(ib_bdy)%nblen(igrd)
                               ii   = idx_bdy(ib_bdy)%nbi(ib,igrd)
@@ -230,5 +231,5 @@
                            END DO
                            igrd = 3                      ! meridional velocity
-                           dta_bdy(ib_bdy)%v2d(:) = 0.0
+                           dta_bdy(ib_bdy)%v2d(:) = 0._wp
                            DO ib = 1, idx_bdy(ib_bdy)%nblen(igrd)
                               ii   = idx_bdy(ib_bdy)%nbi(ib,igrd)
@@ -272,7 +273,7 @@
                ELSE
                   IF( nn_dyn2d(ib_bdy) .gt. 0 .and. nn_dyn2d_dta(ib_bdy) .eq. 2 ) THEN ! tidal harmonic forcing ONLY: initialise arrays
-                     dta_bdy(ib_bdy)%ssh(:) = 0.0
-                     dta_bdy(ib_bdy)%u2d(:) = 0.0
-                     dta_bdy(ib_bdy)%v2d(:) = 0.0
+                     dta_bdy(ib_bdy)%ssh(:) = 0._wp
+                     dta_bdy(ib_bdy)%u2d(:) = 0._wp
+                     dta_bdy(ib_bdy)%v2d(:) = 0._wp
                   ENDIF
                   IF( nb_bdy_fld(ib_bdy) .gt. 0 ) THEN ! update external data
@@ -286,5 +287,5 @@
                     &   nn_dyn3d_dta(ib_bdy) .EQ. 1 ) ) THEN
                      igrd = 2                      ! zonal velocity
-                     dta_bdy(ib_bdy)%u2d(:) = 0.0
+                     dta_bdy(ib_bdy)%u2d(:) = 0._wp
                      DO ib = 1, idx_bdy(ib_bdy)%nblen(igrd)
                         ii   = idx_bdy(ib_bdy)%nbi(ib,igrd)
@@ -300,5 +301,5 @@
                      END DO
                      igrd = 3                      ! meridional velocity
-                     dta_bdy(ib_bdy)%v2d(:) = 0.0
+                     dta_bdy(ib_bdy)%v2d(:) = 0._wp
                      DO ib = 1, idx_bdy(ib_bdy)%nblen(igrd)
                         ii   = idx_bdy(ib_bdy)%nbi(ib,igrd)
@@ -314,8 +315,4 @@
                      END DO
                   ENDIF
-                  IF( nn_dyn2d(ib_bdy) .gt. 0 .and. nn_dyn2d_dta(ib_bdy) .ge. 2 ) THEN ! update tidal harmonic forcing
-                     CALL bdytide_update( kt=kt, idx=idx_bdy(ib_bdy), dta=dta_bdy(ib_bdy),  &
-                                        & td=tides(ib_bdy), time_offset=time_offset )
-                  ENDIF
                ENDIF
             ENDIF
@@ -324,4 +321,8 @@
       END DO  ! ib_bdy
 
+#if defined key_tide
+      ! Add tides if not split-explicit free surface else this is done in ts loop
+      IF (.NOT.lk_dynspg_ts) CALL bdy_dta_tides( kt=kt, time_offset=time_offset )
+#endif
       IF ( ln_apr_obc ) THEN
          DO ib_bdy = 1, nb_bdy
@@ -476,5 +477,5 @@
             IF( nn_dyn2d(ib_bdy) .gt. 0 .and. ( nn_dyn2d_dta(ib_bdy) .eq. 1 .or. nn_dyn2d_dta(ib_bdy) .eq. 3 ) ) THEN 
 
-               IF( nn_tra(ib_bdy) .ne. 4 ) THEN ! runoff condition : no ssh reading
+               IF( nn_dyn2d(ib_bdy) .ne. jp_frs .and. nn_tra(ib_bdy) .ne. 4 ) THEN ! runoff condition : no ssh reading
                   jfld = jfld + 1
                   blf_i(jfld) = bn_ssh
@@ -572,6 +573,6 @@
             ! Recalculate field counts
             !-------------------------
-            nb_bdy_fld_sum = 0
             IF( ib_bdy .eq. 1 ) THEN 
+               nb_bdy_fld_sum = 0
                nb_bdy_fld(ib_bdy) = jfld
                nb_bdy_fld_sum     = jfld              
@@ -616,5 +617,5 @@
                ALLOCATE( dta_bdy(ib_bdy)%u2d(ilen0(2)) )
                ALLOCATE( dta_bdy(ib_bdy)%v2d(ilen0(3)) )
-               IF (nn_dyn2d_dta(ib_bdy).eq.1.or.nn_dyn2d_dta(ib_bdy).eq.3) THEN
+               IF ( nn_dyn2d(ib_bdy) .ne. jp_frs .and. (nn_dyn2d_dta(ib_bdy).eq.1.or.nn_dyn2d_dta(ib_bdy).eq.3) ) THEN
                   jfld = jfld + 1
                   dta_bdy(ib_bdy)%ssh => bf(jfld)%fnow(:,1,1)
