Index: NEMO/trunk/src/OCE/TRD/trdvor.F90
===================================================================
--- NEMO/trunk/src/OCE/TRD/trdvor.F90	(revision 14433)
+++ NEMO/trunk/src/OCE/TRD/trdvor.F90	(revision 15033)
@@ -95,4 +95,6 @@
       !!----------------------------------------------------------------------
 
+      CALL lbc_lnk( 'trdvor', putrd, 'U', -1.0_wp , pvtrd, 'V', -1.0_wp )      ! lateral boundary condition
+
       SELECT CASE( ktrd ) 
       CASE( jpdyn_hpg )   ;   CALL trd_vor_zint( putrd, pvtrd, jpvor_prg, Kmm )   ! Hydrostatique Pressure Gradient 
@@ -104,10 +106,8 @@
       CASE( jpdyn_spg )   ;   CALL trd_vor_zint( putrd, pvtrd, jpvor_spg, Kmm )   ! Surface Pressure Grad. 
       CASE( jpdyn_zdf )                                                           ! Vertical Diffusion 
-         ztswu(:,:) = 0.e0   ;   ztswv(:,:) = 0.e0
-         DO_2D( 0, 0, 0, 0 )                                                               ! wind stress trends
+         DO_2D( nn_hls, nn_hls, nn_hls, nn_hls )                                                               ! wind stress trends
             ztswu(ji,jj) = 0.5 * ( utau_b(ji,jj) + utau(ji,jj) ) / ( e3u(ji,jj,1,Kmm) * rho0 )
             ztswv(ji,jj) = 0.5 * ( vtau_b(ji,jj) + vtau(ji,jj) ) / ( e3v(ji,jj,1,Kmm) * rho0 )
          END_2D
-         !
          CALL trd_vor_zint( putrd, pvtrd, jpvor_zdf, Kmm )                             ! zdf trend including surf./bot. stresses 
          CALL trd_vor_zint( ztswu, ztswv, jpvor_swf, Kmm )                             ! surface wind stress 
@@ -142,5 +142,5 @@
       !!                  vortrd (,, 9) = Beta V
       !!                  vortrd (,,10) = forcing term
-      !!		              vortrd (,,11) = bottom friction term
+      !!		  vortrd (,,11) = bottom friction term
       !!                  rotot(,) : total cumulative trends over nn_write-1 time steps
       !!                  vor_avrtot(,) : first membre of vrticity equation
@@ -149,8 +149,8 @@
       !!      trends output in netCDF format using ioipsl
       !!----------------------------------------------------------------------
-      INTEGER                     , INTENT(in   ) ::   ktrd       ! ocean trend index
-      INTEGER                     , INTENT(in   ) ::   Kmm        ! time level index
-      REAL(wp), DIMENSION(jpi,jpj), INTENT(inout) ::   putrdvor   ! u vorticity trend 
-      REAL(wp), DIMENSION(jpi,jpj), INTENT(inout) ::   pvtrdvor   ! v vorticity trend
+      INTEGER                     , INTENT(in) ::   ktrd       ! ocean trend index
+      INTEGER                     , INTENT(in) ::   Kmm        ! time level index
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(in) ::   putrdvor   ! u vorticity trend 
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(in) ::   pvtrdvor   ! v vorticity trend
       !
       INTEGER ::   ji, jj       ! dummy loop indices
@@ -159,10 +159,4 @@
       !!----------------------------------------------------------------------
 
-      !
-
-      zudpvor(:,:) = 0._wp                 ;   zvdpvor(:,:) = 0._wp                    ! Initialisation
-      CALL lbc_lnk( 'trdvor', putrdvor, 'U', -1.0_wp , pvtrdvor, 'V', -1.0_wp )      ! lateral boundary condition
-      
-
       !  =====================================
       !  I vertical integration of 2D trends
@@ -172,5 +166,5 @@
       !
       CASE( jpvor_bfr )        ! bottom friction
-         DO_2D( 0, 0, 0, 0 )
+         DO_2D( nn_hls, nn_hls, nn_hls, nn_hls )
             ikbu = mbkv(ji,jj)
             ikbv = mbkv(ji,jj)            
@@ -190,12 +184,9 @@
    
       ! Curl
-      DO ji = 1, jpim1
-         DO jj = 1, jpjm1
-            vortrd(ji,jj,ktrd) = (    zvdpvor(ji+1,jj) - zvdpvor(ji,jj)       &
-                 &                - ( zudpvor(ji,jj+1) - zudpvor(ji,jj) )   ) &
-                 &                  / ( e1f(ji,jj) * e2f(ji,jj) )
-         END DO
-      END DO
-      vortrd(:,:,ktrd) = vortrd(:,:,ktrd) * fmask(:,:,1)      ! Surface mask
+      DO_2D( 0, 0, 0, 0 )
+         vortrd(ji,jj,ktrd) = (    zvdpvor(ji+1,jj) - zvdpvor(ji,jj)       &
+            &                  - ( zudpvor(ji,jj+1) - zudpvor(ji,jj) )   ) &
+            &                  / ( e1f(ji,jj) * e2f(ji,jj) ) * fmask(ji,jj,1)
+      END_2D
 
       IF( ndebug /= 0 ) THEN
@@ -235,21 +226,12 @@
       !!----------------------------------------------------------------------
       !
-      INTEGER                         , INTENT(in   ) ::   ktrd       ! ocean trend index
-      INTEGER                         , INTENT(in   ) ::   Kmm        ! time level index
-      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(inout) ::   putrdvor   ! u vorticity trend 
-      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(inout) ::   pvtrdvor   ! v vorticity trend
+      INTEGER                         , INTENT(in) ::   ktrd       ! ocean trend index
+      INTEGER                         , INTENT(in) ::   Kmm        ! time level index
+      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(in) ::   putrdvor   ! u vorticity trend 
+      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(in) ::   pvtrdvor   ! v vorticity trend
       !
       INTEGER ::   ji, jj, jk   ! dummy loop indices
-      REAL(wp), DIMENSION(jpi,jpj) :: zubet  , zvbet    ! Beta.V   
       REAL(wp), DIMENSION(jpi,jpj) :: zudpvor, zvdpvor  ! total cmulative trends
       !!----------------------------------------------------------------------
-     
-      ! Initialization
-      zubet  (:,:) = 0._wp
-      zvbet  (:,:) = 0._wp
-      zudpvor(:,:) = 0._wp
-      zvdpvor(:,:) = 0._wp
-      !                            ! lateral boundary condition on input momentum trends
-      CALL lbc_lnk( 'trdvor', putrdvor, 'U', -1.0_wp , pvtrdvor, 'V', -1.0_wp )
 
       !  =====================================
@@ -265,15 +247,9 @@
       ! as Beta.V term need intergration, not average
       IF( ktrd == jpvor_pvo ) THEN 
-         zubet(:,:) = zudpvor(:,:)
-         zvbet(:,:) = zvdpvor(:,:)
-         DO ji = 1, jpim1
-            DO jj = 1, jpjm1
-               vortrd(ji,jj,jpvor_bev) = (    zvbet(ji+1,jj) - zvbet(ji,jj)     &
-                  &                       - ( zubet(ji,jj+1) - zubet(ji,jj) ) ) &
-                  &                           / ( e1f(ji,jj) * e2f(ji,jj) )
-            END DO
-         END DO
-         ! Average of the Curl and Surface mask
-         vortrd(:,:,jpvor_bev) = vortrd(:,:,jpvor_bev) * r1_hu(:,:,Kmm) * fmask(:,:,1)
+         DO_2D( 0, 0, 0, 0 )
+            vortrd(ji,jj,jpvor_bev) = (    zvdpvor(ji+1,jj) - zvdpvor(ji,jj)     &
+               &                       - ( zudpvor(ji,jj+1) - zudpvor(ji,jj) ) ) &
+               &                           / ( e1f(ji,jj) * e2f(ji,jj) ) * r1_hu(ji,jj,Kmm) * fmask(ji,jj,1)
+         END_2D
       ENDIF
       !
@@ -283,13 +259,9 @@
       !
       ! Curl
-      DO ji=1,jpim1
-         DO jj=1,jpjm1
-            vortrd(ji,jj,ktrd) = (    zvdpvor(ji+1,jj) - zvdpvor(ji,jj)     &
-               &                  - ( zudpvor(ji,jj+1) - zudpvor(ji,jj) ) ) &
-               &                         / ( e1f(ji,jj) * e2f(ji,jj) )
-         END DO
-      END DO
-      ! Surface mask
-      vortrd(:,:,ktrd) = vortrd(:,:,ktrd) * fmask(:,:,1)
+      DO_2D( 0, 0, 0, 0 )
+         vortrd(ji,jj,ktrd) = (    zvdpvor(ji+1,jj) - zvdpvor(ji,jj)     &
+            &                  - ( zudpvor(ji,jj+1) - zudpvor(ji,jj) ) ) &
+            &                         / ( e1f(ji,jj) * e2f(ji,jj) ) * fmask(ji,jj,1)
+      END_2D
    
       IF( ndebug /= 0 ) THEN
@@ -346,11 +318,9 @@
 
       ! Curl
-      DO ji = 1, jpim1
-         DO jj = 1, jpjm1
-            vor_avr(ji,jj) = (  ( zvv(ji+1,jj) - zvv(ji,jj) )    &
-               &              - ( zuu(ji,jj+1) - zuu(ji,jj) ) )  &
-               &             / ( e1f(ji,jj) * e2f(ji,jj) ) * fmask(ji,jj,1)
-         END DO
-      END DO
+      DO_2D( 0, 0, 0, 0 )
+         vor_avr(ji,jj) = (  ( zvv(ji+1,jj) - zvv(ji,jj) )    &
+            &              - ( zuu(ji,jj+1) - zuu(ji,jj) ) )  &
+            &             / ( e1f(ji,jj) * e2f(ji,jj) ) * fmask(ji,jj,1)
+      END_2D
       
       !  =================================
