Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/OBC/obcfla.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/OBC/obcfla.F90	(revision 2588)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/OBC/obcfla.F90	(revision 2618)
@@ -5,5 +5,6 @@
    !!======================================================================
    !! History :  2.0  ! 2005-12  (V. Garnier) original code
-   !!            3.3  ! 2010-11  (G. Madec)
+   !!            3.3  ! 2010-11  (G. Madec) 
+   !!            4.0  ! 2011-02  (G. Madec) velocity & ssh passed in argument
    !!----------------------------------------------------------------------
 #if defined key_obc && defined key_dynspg_ts
@@ -31,5 +32,5 @@
 
    !!----------------------------------------------------------------------
-   !! NEMO/OPA 3.3 , NEMO Consortium (2010)
+   !! NEMO/OPA 4.0 , NEMO Consortium (2011)
    !! $Id$
    !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
@@ -37,5 +38,5 @@
 CONTAINS
 
-   SUBROUTINE obc_fla_ts
+   SUBROUTINE obc_fla_ts( pua, pva, p_sshn, p_ssha )
       !!----------------------------------------------------------------------
       !!                      SUBROUTINE obc_fla_ts
@@ -52,20 +53,26 @@
       !! ** Reference : Flather, R. A., 1976, Mem. Soc. R. Sci. Liege, Ser. 6, 10, 141-164
       !!----------------------------------------------------------------------
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(inout) ::   pua   , pva      ! after barotropic velocities
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(inout) ::   p_sshn, p_ssha   ! before, now, after sea surface height
+      !!----------------------------------------------------------------------
       !
-      IF( lp_obc_east  )   CALL obc_fla_ts_east 
-      IF( lp_obc_west  )   CALL obc_fla_ts_west 
-      IF( lp_obc_north )   CALL obc_fla_ts_north
-      IF( lp_obc_south )   CALL obc_fla_ts_south
+      IF( lp_obc_east  )   CALL obc_fla_ts_east ( pua, pva, p_sshn, p_ssha ) 
+      IF( lp_obc_west  )   CALL obc_fla_ts_west ( pua, pva, p_sshn, p_ssha )
+      IF( lp_obc_north )   CALL obc_fla_ts_north( pua, pva, p_sshn, p_ssha )
+      IF( lp_obc_south )   CALL obc_fla_ts_south( pua, pva, p_sshn, p_ssha ) 
       !
    END SUBROUTINE obc_fla_ts
 
 
-   SUBROUTINE obc_fla_ts_east
+   SUBROUTINE obc_fla_ts_east( pua, pva, p_sshn, p_ssha ) 
       !!----------------------------------------------------------------------
       !!                  ***  SUBROUTINE obc_fla_ts_east  ***
       !!
       !! ** Purpose :   Apply Flather's algorithm on east OBC velocities ua, va
-      !!              Fix sea surface height (sshn_e) on east open boundary
+      !!              Fix sea surface height (p_sshn) on east open boundary
       !!----------------------------------------------------------------------
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(inout) ::   pua   , pva      ! after barotropic velocities
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(inout) ::   p_sshn, p_ssha   ! before, now, after sea surface height
+      !
       INTEGER ::   ji, jj ! dummy loop indices
       !!----------------------------------------------------------------------
@@ -73,14 +80,14 @@
       DO ji = nie0, nie1
          DO jj = 1, jpj
-            ua_e    (ji,jj) = (  ubtfoe(jj) * hur(ji,jj) + SQRT( grav*hur(ji,jj) )          &
-               &            * ( ( sshn_e(ji,jj) + sshn_e(ji+1,jj) ) * 0.5 - sshfoe(jj) )  ) * uemsk(jj,1)
+            pua     (ji,jj) = (  ubtfoe(jj) * hur(ji,jj) + SQRT( grav*hur(ji,jj) )          &
+               &            * ( ( p_sshn(ji,jj) + p_sshn(ji+1,jj) ) * 0.5 - sshfoe(jj) )  ) * uemsk(jj,1)
             sshfoe_b(ji,jj) =    sshfoe_b(ji,jj)         + SQRT( grav*hur(ji,jj) )          &
-               &            * ( ( sshn_e(ji,jj) + sshn_e(ji+1,jj) ) * 0.5 - sshfoe(jj) )    * uemsk(jj,1)
+               &            * ( ( p_sshn(ji,jj) + p_sshn(ji+1,jj) ) * 0.5 - sshfoe(jj) )    * uemsk(jj,1)
          END DO
       END DO
       DO ji = nie0p1, nie1p1
          DO jj = 1, jpj
-            ssha_e(ji,jj) = ssha_e(ji,jj) * ( 1. - temsk(jj,1) ) + temsk(jj,1) * sshfoe(jj)
-            va_e  (ji,jj) = vbtfoe(jj) * hvr(ji,jj) * uemsk(jj,1)
+            p_ssha(ji,jj) = p_ssha(ji,jj) * ( 1. - temsk(jj,1) ) + temsk(jj,1) * sshfoe(jj)
+            pva   (ji,jj) = vbtfoe(jj) * hvr(ji,jj) * uemsk(jj,1)
          END DO
       END DO
@@ -89,11 +96,14 @@
 
 
-   SUBROUTINE obc_fla_ts_west
+   SUBROUTINE obc_fla_ts_west( pua, pva, p_sshn, p_ssha )
       !!----------------------------------------------------------------------
       !!                  ***  SUBROUTINE obc_fla_ts_west  ***
       !! 
       !! ** Purpose :   Apply Flather's algorithm on west OBC velocities ua, va
-      !!              Fix sea surface height (sshn_e) on west open boundary
+      !!              Fix sea surface height (p_sshn) on west open boundary
       !!----------------------------------------------------------------------
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(inout) ::   pua   , pva      ! after barotropic velocities
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(inout) ::   p_sshn, p_ssha   ! before, now, after sea surface height
+      !
       INTEGER ::   ji, jj ! dummy loop indices
       !!----------------------------------------------------------------------
@@ -101,10 +111,10 @@
       DO ji = niw0, niw1
          DO jj = 1, jpj
-            ua_e    (ji,jj) = ( ubtfow(jj) * hur(ji,jj) - sqrt( grav * hur(ji,jj) )            &
-               &                * ( ( sshn_e(ji,jj) + sshn_e(ji+1,jj) ) * 0.5 - sshfow(jj) ) ) * uwmsk(jj,1)
-            va_e    (ji,jj) =   vbtfow(jj) * hvr(ji,jj) * uwmsk(jj,1)
+            pua     (ji,jj) = ( ubtfow(jj) * hur(ji,jj) - sqrt( grav * hur(ji,jj) )            &
+               &            * ( ( p_sshn(ji,jj) + p_sshn(ji+1,jj) ) * 0.5 - sshfow(jj) ) ) * uwmsk(jj,1)
+            pva     (ji,jj) =   vbtfow(jj) * hvr(ji,jj) * uwmsk(jj,1)
             sshfow_b(ji,jj) =   sshfow_b(ji,jj) - SQRT( grav * hur(ji,jj) )                    &
-               &                * ( ( sshn_e(ji,jj) + sshn_e(ji+1,jj) ) * 0.5 - sshfow(jj) )   * uwmsk(jj,1)
-            ssha_e  (ji,jj) = ssha_e(ji,jj) * ( 1. - twmsk(jj,1) ) + twmsk(jj,1)*sshfow(jj)
+               &            * ( ( p_sshn(ji,jj) + p_sshn(ji+1,jj) ) * 0.5 - sshfow(jj) )   * uwmsk(jj,1)
+            p_ssha  (ji,jj) = p_ssha(ji,jj) * ( 1. - twmsk(jj,1) ) + twmsk(jj,1)*sshfow(jj)
          END DO
       END DO
@@ -113,11 +123,14 @@
 
 
-   SUBROUTINE obc_fla_ts_north
+   SUBROUTINE obc_fla_ts_north( pua, pva, p_sshn, p_ssha )
       !!----------------------------------------------------------------------
       !!                     SUBROUTINE obc_fla_ts_north
       !!
       !! ** Purpose :   Apply Flather's algorithm on north OBC velocities ua, va
-      !!              Fix sea surface height (sshn_e) on north open boundary
+      !!              Fix sea surface height (p_sshn) on north open boundary
       !!----------------------------------------------------------------------
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(inout) ::   pua   , pva      ! after barotropic velocities
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(inout) ::   p_sshn, p_ssha   ! before, now, after sea surface height
+      !
       INTEGER ::   ji, jj ! dummy loop indices
       !!----------------------------------------------------------------------
@@ -125,14 +138,14 @@
       DO jj = njn0, njn1
          DO ji = 1, jpi
-            va_e    (ji,jj) = ( vbtfon(ji) * hvr(ji,jj) + sqrt( grav * hvr(ji,jj) )            &
-               &                * ( ( sshn_e(ji,jj) + sshn_e(ji,jj+1) ) * 0.5 - sshfon(ji) ) ) * vnmsk(ji,1)
+            pva     (ji,jj) = ( vbtfon(ji) * hvr(ji,jj) + sqrt( grav * hvr(ji,jj) )            &
+               &                * ( ( p_sshn(ji,jj) + p_sshn(ji,jj+1) ) * 0.5 - sshfon(ji) ) ) * vnmsk(ji,1)
             sshfon_b(ji,jj) =   sshfon_b(ji,jj) + sqrt( grav * hvr(ji,jj) )                    &
-               &                * ( ( sshn_e(ji,jj) + sshn_e(ji,jj+1) ) * 0.5 - sshfon(ji) )   * vnmsk(ji,1)
+               &                * ( ( p_sshn(ji,jj) + p_sshn(ji,jj+1) ) * 0.5 - sshfon(ji) )   * vnmsk(ji,1)
          END DO
       END DO
       DO jj = njn0p1, njn1p1
          DO ji = 1, jpi
-            ssha_e(ji,jj) = ssha_e(ji,jj) * ( 1. - tnmsk(ji,1) ) + sshfon(ji) * tnmsk(ji,1)
-            ua_e  (ji,jj) = ubtfon(ji) * hur(ji,jj) * vnmsk(ji,1)
+            p_ssha(ji,jj) = p_ssha(ji,jj) * ( 1. - tnmsk(ji,1) ) + sshfon(ji) * tnmsk(ji,1)
+            pua   (ji,jj) = ubtfon(ji) * hur(ji,jj) * vnmsk(ji,1)
          END DO
       END DO
@@ -141,11 +154,14 @@
 
 
-   SUBROUTINE obc_fla_ts_south
+   SUBROUTINE obc_fla_ts_south( pua, pva, p_sshn, p_ssha )
       !!----------------------------------------------------------------------
       !!                     SUBROUTINE obc_fla_ts_south
       !!
       !! ** Purpose :   Apply Flather's algorithm on south OBC velocities ua, va
-      !!              Fix sea surface height (sshn_e) on south open boundary
+      !!              Fix sea surface height (p_sshn) on south open boundary
       !!----------------------------------------------------------------------
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(inout) ::   pua   , pva      ! after barotropic velocities
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(inout) ::   p_sshn, p_ssha   ! before, now, after sea surface height
+      !
       INTEGER ::   ji, jj ! dummy loop indices
       !!----------------------------------------------------------------------
@@ -153,10 +169,10 @@
       DO jj = njs0, njs1
          DO ji = 1, jpi
-            va_e    (ji,jj) = ( vbtfos(ji) * hvr(ji,jj) - sqrt( grav * hvr(ji,jj) )            &
-               &                * ( ( sshn_e(ji,jj) + sshn_e(ji,jj+1) ) * 0.5 - sshfos(ji) ) ) * vsmsk(ji,1)
-            ua_e    (ji,jj) =   ubtfos(ji) * hur(ji,jj) * vsmsk(ji,1)
+            pva     (ji,jj) = ( vbtfos(ji) * hvr(ji,jj) - sqrt( grav * hvr(ji,jj) )            &
+               &                * ( ( p_sshn(ji,jj) + p_sshn(ji,jj+1) ) * 0.5 - sshfos(ji) ) ) * vsmsk(ji,1)
+            pua     (ji,jj) =   ubtfos(ji) * hur(ji,jj) * vsmsk(ji,1)
             sshfos_b(ji,jj) =   sshfos_b(ji,jj) - sqrt( grav * hvr(ji,jj) )                    &
-               &                * ( ( sshn_e(ji,jj) + sshn_e(ji,jj+1) ) * 0.5 - sshfos(ji) )   * vsmsk(ji,1)
-            ssha_e  (ji,jj) = ssha_e(ji,jj) * (1. - tsmsk(ji,1) ) + tsmsk(ji,1) * sshfos(ji)
+               &                * ( ( p_sshn(ji,jj) + p_sshn(ji,jj+1) ) * 0.5 - sshfos(ji) )   * vsmsk(ji,1)
+            p_ssha  (ji,jj) = p_ssha(ji,jj) * (1. - tsmsk(ji,1) ) + tsmsk(ji,1) * sshfos(ji)
          END DO
       END DO
@@ -170,6 +186,7 @@
 CONTAINS
 
-   SUBROUTINE obc_fla_ts
-      WRITE(*,*) 'obc_fla_ts: You should not have seen this print! error?'
+   SUBROUTINE obc_fla_ts( pua, pva, p_sshn, p_ssha )
+      REAL, DIMENSION(:,:)::   pua, pva, p_sshn, p_ssha
+      WRITE(*,*) 'obc_fla_ts: You should not have seen this print! error?', pua(1,1), pva(1,1), p_sshn(1,1), p_ssha(1,1)
    END SUBROUTINE obc_fla_ts
 #endif
