Index: /branches/2016/dev_r6393_NOC_WAD/NEMOGCM/NEMO/OPA_SRC/DYN/dynhpg.F90
===================================================================
--- /branches/2016/dev_r6393_NOC_WAD/NEMOGCM/NEMO/OPA_SRC/DYN/dynhpg.F90	(revision 7156)
+++ /branches/2016/dev_r6393_NOC_WAD/NEMOGCM/NEMO/OPA_SRC/DYN/dynhpg.F90	(revision 7157)
@@ -432,5 +432,5 @@
       INTEGER  ::   ji, jj, jk, jii, jjj                 ! dummy loop indices
       REAL(wp) ::   zcoef0, zuap, zvap, znad, ztmp       ! temporary scalars
-      LOGICAL  ::   ll_tmp1, ll_tmp2, ll_tmp3            ! local logical variables
+      LOGICAL  ::   ll_tmp1, ll_tmp2                     ! local logical variables
       REAL(wp), POINTER, DIMENSION(:,:,:) ::  zhpi, zhpj
       REAL(wp), POINTER, DIMENSION(:,:)   ::  zcpx, zcpy !W/D pressure filter
@@ -438,5 +438,5 @@
       !
       CALL wrk_alloc( jpi,jpj,jpk, zhpi, zhpj )
-      IF(ln_wd) CALL wrk_alloc( jpi,jpj, zcpx, zcpy )
+      IF( ln_wd ) CALL wrk_alloc( jpi,jpj, zcpx, zcpy )
       !
       IF( kt == nit000 ) THEN
@@ -451,33 +451,37 @@
       ENDIF
       !
-      IF(ln_wd) THEN
+      IF( ln_wd ) THEN
         DO jj = 2, jpjm1
            DO ji = 2, jpim1 
-             ll_tmp1 = MIN(sshn(ji,jj), sshn(ji+1,jj)) > MAX(-bathy(ji,jj), -bathy(ji+1,jj)) 
-             ll_tmp2 = MAX(sshn(ji,jj) + bathy(ji,jj), sshn(ji+1,jj) + bathy(ji+1,jj)) > rn_wdmin1 + rn_wdmin2
-             ll_tmp3 = MAX(sshn(ji,jj), sshn(ji+1,jj)) > MAX(-bathy(ji,jj), -bathy(ji+1,jj)) + &
-                                                       & rn_wdmin1 + rn_wdmin2
-
-             IF(ll_tmp1.AND.ll_tmp2) THEN
+             ll_tmp1 = MIN(   sshn(ji,jj)               ,   sshn(ji+1,jj) ) >                &
+                  &    MAX( -bathy(ji,jj)               , -bathy(ji+1,jj) ) .AND.            &
+                  &    MAX(   sshn(ji,jj) + bathy(ji,jj),   sshn(ji+1,jj) + bathy(ji+1,jj) ) &
+                  &                                                         > rn_wdmin1 + rn_wdmin2
+             ll_tmp2 = MAX(   sshn(ji,jj)               ,   sshn(ji+1,jj) ) >                &
+                  &    MAX( -bathy(ji,jj)               , -bathy(ji+1,jj) ) + rn_wdmin1 + rn_wdmin2
+
+             IF(ll_tmp1) THEN
                zcpx(ji,jj) = 1.0_wp
-             ELSE IF(ll_tmp3) THEN
-               ! no worries about sshn(ji+1,jj)-sshn(ji,jj) = 0, it won't happen ! here
-               zcpx(ji,jj) = ABS((sshn(ji+1,jj) + bathy(ji+1,jj) - sshn(ji,jj) - bathy(ji,jj)) / &
-                           &     (sshn(ji+1,jj) - sshn(ji,jj)))
+             ELSE IF(ll_tmp2) THEN
+               ! no worries about  sshn(ji+1,jj) -  sshn(ji  ,jj) = 0, it won't happen ! here
+               zcpx(ji,jj) = ABS( (sshn(ji+1,jj) + bathy(ji+1,jj) - sshn(ji,jj) - bathy(ji,jj)) &
+                           &    / (sshn(ji+1,jj) -  sshn(ji  ,jj)) )
              ELSE
                zcpx(ji,jj) = 0._wp
              END IF
       
-             ll_tmp1 = MIN(sshn(ji,jj), sshn(ji,jj+1)) > MAX(-bathy(ji,jj), -bathy(ji,jj+1)) 
-             ll_tmp2 = MAX(sshn(ji,jj) + bathy(ji,jj), sshn(ji,jj+1) + bathy(ji,jj+1)) > rn_wdmin1 + rn_wdmin2
-             ll_tmp3 = MAX(sshn(ji,jj), sshn(ji,jj+1)) > MAX(-bathy(ji,jj), -bathy(ji,jj+1)) + &
-                                                       & rn_wdmin1 + rn_wdmin2
-
-             IF(ll_tmp1.AND.ll_tmp2) THEN
+             ll_tmp1 = MIN(   sshn(ji,jj)               ,   sshn(ji,jj+1) ) >                &
+                  &    MAX( -bathy(ji,jj)               , -bathy(ji,jj+1) ) .AND.            &
+                  &    MAX(   sshn(ji,jj) + bathy(ji,jj),   sshn(ji,jj+1) + bathy(ji,jj+1) ) &
+                  &                                                         > rn_wdmin1 + rn_wdmin2
+             ll_tmp2 = MAX(   sshn(ji,jj)               ,   sshn(ji,jj+1) ) >                &
+                  &    MAX( -bathy(ji,jj)               , -bathy(ji,jj+1) ) + rn_wdmin1 + rn_wdmin2
+
+             IF(ll_tmp1) THEN
                zcpy(ji,jj) = 1.0_wp
-             ELSE IF(ll_tmp3) THEN
-               ! no worries about sshn(ji,jj+1)-sshn(ji,jj) = 0, it won't happen ! here
-               zcpy(ji,jj) = ABS((sshn(ji,jj+1) + bathy(ji,jj+1) - sshn(ji,jj) - bathy(ji,jj)) / &
-                           &     (sshn(ji,jj+1) - sshn(ji,jj)))
+             ELSE IF(ll_tmp2) THEN
+               ! no worries about  sshn(ji,jj+1) -  sshn(ji,jj  ) = 0, it won't happen ! here
+               zcpy(ji,jj) = ABS( (sshn(ji,jj+1) + bathy(ji,jj+1) - sshn(ji,jj) - bathy(ji,jj)) &
+                           &    / (sshn(ji,jj+1) -  sshn(ji,jj  )) )
              ELSE
                zcpy(ji,jj) = 0._wp
@@ -486,6 +490,5 @@
         END DO
         CALL lbc_lnk( zcpx, 'U', 1._wp )    ;   CALL lbc_lnk( zcpy, 'V', 1._wp )
-      ENDIF
-
+      END IF
 
       ! Surface value
@@ -504,5 +507,5 @@
 
 
-            IF(ln_wd) THEN
+            IF( ln_wd ) THEN
 
               zhpi(ji,jj,1) = zhpi(ji,jj,1) * zcpx(ji,jj)
@@ -535,5 +538,5 @@
                   &           * ( gde3w_n(ji  ,jj+1,jk) - gde3w_n(ji,jj,jk) ) * r1_e2v(ji,jj)
 
-               IF(ln_wd) THEN
+               IF( ln_wd ) THEN
                  zhpi(ji,jj,jk) = zhpi(ji,jj,jk) * zcpx(ji,jj)
                  zhpj(ji,jj,jk) = zhpj(ji,jj,jk) * zcpy(ji,jj) 
@@ -550,5 +553,5 @@
       !
       CALL wrk_dealloc( jpi,jpj,jpk, zhpi, zhpj )
-      IF(ln_wd) CALL wrk_dealloc( jpi,jpj, zcpx, zcpy )
+      IF( ln_wd ) CALL wrk_dealloc( jpi,jpj, zcpx, zcpy )
       !
    END SUBROUTINE hpg_sco
@@ -695,38 +698,40 @@
       CALL wrk_alloc( jpi, jpj, jpk, drhox, drhoy, drhoz, drhou, drhov, drhow )
       CALL wrk_alloc( jpi, jpj, jpk, rho_i, rho_j, rho_k,  zhpi,  zhpj        )
-      IF(ln_wd) CALL wrk_alloc( jpi,jpj, zcpx, zcpy )
-      !
-      !
-      IF(ln_wd) THEN
+      IF( ln_wd ) CALL wrk_alloc( jpi,jpj, zcpx, zcpy )
+      !
+      !
+      IF( ln_wd ) THEN
         DO jj = 2, jpjm1
            DO ji = 2, jpim1 
-             ll_tmp1 = MIN(sshn(ji,jj), sshn(ji+1,jj)) > MAX(-bathy(ji,jj), -bathy(ji+1,jj)) &
-                     & .and. MAX(sshn(ji,jj) + bathy(ji,jj), sshn(ji+1,jj) + bathy(ji+1,jj)) &
-                     &  > rn_wdmin1 + rn_wdmin2
-             ll_tmp2 = MAX(sshn(ji,jj), sshn(ji+1,jj)) > MAX(-bathy(ji,jj), -bathy(ji+1,jj)) +&
-                                                       & rn_wdmin1 + rn_wdmin2
+             ll_tmp1 = MIN(   sshn(ji,jj)               ,   sshn(ji+1,jj) ) >                &
+                  &    MAX( -bathy(ji,jj)               , -bathy(ji+1,jj) ) .AND.            &
+                  &    MAX(   sshn(ji,jj) + bathy(ji,jj),   sshn(ji+1,jj) + bathy(ji+1,jj) ) &
+                  &                                                         > rn_wdmin1 + rn_wdmin2
+             ll_tmp2 = MAX(   sshn(ji,jj)               ,   sshn(ji+1,jj) ) >                &
+                  &    MAX( -bathy(ji,jj)               , -bathy(ji+1,jj) ) + rn_wdmin1 + rn_wdmin2
 
              IF(ll_tmp1) THEN
                zcpx(ji,jj) = 1.0_wp
              ELSE IF(ll_tmp2) THEN
-               ! no worries about sshn(ji+1,jj)-sshn(ji,jj) = 0, it won't happen ! here
-               zcpx(ji,jj) = ABS((sshn(ji+1,jj) + bathy(ji+1,jj) - sshn(ji,jj) - bathy(ji,jj)) /&
-                           &     (sshn(ji+1,jj) - sshn(ji,jj)))
+               ! no worries about  sshn(ji+1,jj) -  sshn(ji  ,jj) = 0, it won't happen ! here
+               zcpx(ji,jj) = ABS( (sshn(ji+1,jj) + bathy(ji+1,jj) - sshn(ji,jj) - bathy(ji,jj)) &
+                           &    / (sshn(ji+1,jj) -  sshn(ji  ,jj)) )
              ELSE
                zcpx(ji,jj) = 0._wp
              END IF
       
-             ll_tmp1 = MIN(sshn(ji,jj), sshn(ji,jj+1)) > MAX(-bathy(ji,jj), -bathy(ji,jj+1)) &
-                     & .and. MAX(sshn(ji,jj) + bathy(ji,jj), sshn(ji,jj+1) + bathy(ji,jj+1)) &
-                     &  > rn_wdmin1 + rn_wdmin2
-             ll_tmp2 = MAX(sshn(ji,jj), sshn(ji,jj+1)) > MAX(-bathy(ji,jj), -bathy(ji,jj+1)) +&
-                                                       & rn_wdmin1 + rn_wdmin2
+             ll_tmp1 = MIN(   sshn(ji,jj)               ,   sshn(ji,jj+1) ) >                &
+                  &    MAX( -bathy(ji,jj)               , -bathy(ji,jj+1) ) .AND.            &
+                  &    MAX(   sshn(ji,jj) + bathy(ji,jj),   sshn(ji,jj+1) + bathy(ji,jj+1) ) &
+                  &                                                         > rn_wdmin1 + rn_wdmin2
+             ll_tmp2 = MAX(   sshn(ji,jj)               ,   sshn(ji,jj+1) ) >                &
+                  &    MAX( -bathy(ji,jj)               , -bathy(ji,jj+1) ) + rn_wdmin1 + rn_wdmin2
 
              IF(ll_tmp1) THEN
                zcpy(ji,jj) = 1.0_wp
              ELSE IF(ll_tmp2) THEN
-               ! no worries about sshn(ji,jj+1)-sshn(ji,jj) = 0, it won't happen ! here
-               zcpy(ji,jj) = ABS((sshn(ji,jj+1) + bathy(ji,jj+1) - sshn(ji,jj) - bathy(ji,jj)) /&
-                           &     (sshn(ji,jj+1) - sshn(ji,jj)))
+               ! no worries about  sshn(ji,jj+1) -  sshn(ji,jj  ) = 0, it won't happen ! here
+               zcpy(ji,jj) = ABS( (sshn(ji,jj+1) + bathy(ji,jj+1) - sshn(ji,jj) - bathy(ji,jj)) &
+                           &    / (sshn(ji,jj+1) -  sshn(ji,jj  )) )
              ELSE
                zcpy(ji,jj) = 0._wp
@@ -735,6 +740,5 @@
         END DO
         CALL lbc_lnk( zcpx, 'U', 1._wp )    ;   CALL lbc_lnk( zcpy, 'V', 1._wp )
-      ENDIF
-
+      END IF
 
       IF( kt == nit000 ) THEN
@@ -907,5 +911,5 @@
             zhpi(ji,jj,1) = ( rho_k(ji+1,jj  ,1) - rho_k(ji,jj,1) - rho_i(ji,jj,1) ) * r1_e1u(ji,jj)
             zhpj(ji,jj,1) = ( rho_k(ji  ,jj+1,1) - rho_k(ji,jj,1) - rho_j(ji,jj,1) ) * r1_e2v(ji,jj)
-            IF(ln_wd) THEN
+            IF( ln_wd ) THEN
               zhpi(ji,jj,1) = zhpi(ji,jj,1) * zcpx(ji,jj)
               zhpj(ji,jj,1) = zhpj(ji,jj,1) * zcpy(ji,jj) 
@@ -930,5 +934,5 @@
                   &           + (  ( rho_k(ji,jj+1,jk) - rho_k(ji,jj,jk  ) )    &
                   &               -( rho_j(ji,jj  ,jk) - rho_j(ji,jj,jk-1) )  ) * r1_e2v(ji,jj)
-               IF(ln_wd) THEN
+               IF( ln_wd ) THEN
                  zhpi(ji,jj,jk) = zhpi(ji,jj,jk) * zcpx(ji,jj)
                  zhpj(ji,jj,jk) = zhpj(ji,jj,jk) * zcpy(ji,jj) 
@@ -944,5 +948,5 @@
       CALL wrk_dealloc( jpi, jpj, jpk, drhox, drhoy, drhoz, drhou, drhov, drhow )
       CALL wrk_dealloc( jpi, jpj, jpk, rho_i, rho_j, rho_k,  zhpi,  zhpj        )
-      IF(ln_wd) CALL wrk_dealloc( jpi,jpj, zcpx, zcpy )
+      IF( ln_wd ) CALL wrk_dealloc( jpi,jpj, zcpx, zcpy )
       !
    END SUBROUTINE hpg_djc
@@ -981,5 +985,5 @@
       CALL wrk_alloc( jpi,jpj,jpk,   zdept, zrhh )
       CALL wrk_alloc( jpi,jpj,       zsshu_n, zsshv_n )
-      IF(ln_wd) CALL wrk_alloc( jpi,jpj, zcpx, zcpy )
+      IF( ln_wd ) CALL wrk_alloc( jpi,jpj, zcpx, zcpy )
       !
       IF( kt == nit000 ) THEN
@@ -994,35 +998,37 @@
       IF( ln_linssh )   znad = 0._wp
 
-      IF(ln_wd) THEN
+      IF( ln_wd ) THEN
         DO jj = 2, jpjm1
            DO ji = 2, jpim1 
-             ll_tmp1 = MIN(sshn(ji,jj), sshn(ji+1,jj)) > MAX(-bathy(ji,jj), -bathy(ji+1,jj)) &
-                     & .and. MAX(sshn(ji,jj) + bathy(ji,jj), sshn(ji+1,jj) + bathy(ji+1,jj)) &
-                     &  > rn_wdmin1 + rn_wdmin2
-             ll_tmp2 = MAX(sshn(ji,jj), sshn(ji+1,jj)) > MAX(-bathy(ji,jj), -bathy(ji+1,jj)) +&
-                                                       & rn_wdmin1 + rn_wdmin2
+             ll_tmp1 = MIN(   sshn(ji,jj)               ,   sshn(ji+1,jj) ) >                &
+                  &    MAX( -bathy(ji,jj)               , -bathy(ji+1,jj) ) .AND.            &
+                  &    MAX(   sshn(ji,jj) + bathy(ji,jj),   sshn(ji+1,jj) + bathy(ji+1,jj) ) &
+                  &                                                         > rn_wdmin1 + rn_wdmin2
+             ll_tmp2 = MAX(   sshn(ji,jj)               ,   sshn(ji+1,jj) ) >                &
+                  &    MAX( -bathy(ji,jj)               , -bathy(ji+1,jj) ) + rn_wdmin1 + rn_wdmin2
 
              IF(ll_tmp1) THEN
                zcpx(ji,jj) = 1.0_wp
              ELSE IF(ll_tmp2) THEN
-               ! no worries about sshn(ji+1,jj)-sshn(ji,jj) = 0, it won't happen ! here
-               zcpx(ji,jj) = ABS((sshn(ji+1,jj) + bathy(ji+1,jj) - sshn(ji,jj) - bathy(ji,jj)) /&
-                           &     (sshn(ji+1,jj) - sshn(ji,jj)))
+               ! no worries about  sshn(ji+1,jj) -  sshn(ji  ,jj) = 0, it won't happen ! here
+               zcpx(ji,jj) = ABS( (sshn(ji+1,jj) + bathy(ji+1,jj) - sshn(ji,jj) - bathy(ji,jj)) &
+                           &    / (sshn(ji+1,jj) -  sshn(ji  ,jj)) )
              ELSE
                zcpx(ji,jj) = 0._wp
              END IF
       
-             ll_tmp1 = MIN(sshn(ji,jj), sshn(ji,jj+1)) > MAX(-bathy(ji,jj), -bathy(ji,jj+1)) &
-                     & .and. MAX(sshn(ji,jj) + bathy(ji,jj), sshn(ji,jj+1) + bathy(ji,jj+1)) &
-                     &  > rn_wdmin1 + rn_wdmin2
-             ll_tmp2 = MAX(sshn(ji,jj), sshn(ji,jj+1)) > MAX(-bathy(ji,jj), -bathy(ji,jj+1)) +&
-                                                       & rn_wdmin1 + rn_wdmin2
-
-             IF(ll_tmp1.OR.ll_tmp2) THEN
+             ll_tmp1 = MIN(   sshn(ji,jj)               ,   sshn(ji,jj+1) ) >                &
+                  &    MAX( -bathy(ji,jj)               , -bathy(ji,jj+1) ) .AND.            &
+                  &    MAX(   sshn(ji,jj) + bathy(ji,jj),   sshn(ji,jj+1) + bathy(ji,jj+1) ) &
+                  &                                                         > rn_wdmin1 + rn_wdmin2
+             ll_tmp2 = MAX(   sshn(ji,jj)               ,   sshn(ji,jj+1) ) >                &
+                  &    MAX( -bathy(ji,jj)               , -bathy(ji,jj+1) ) + rn_wdmin1 + rn_wdmin2
+
+             IF(ll_tmp1) THEN
                zcpy(ji,jj) = 1.0_wp
              ELSE IF(ll_tmp2) THEN
-               ! no worries about sshn(ji,jj+1)-sshn(ji,jj) = 0, it won't happen ! here
-               zcpy(ji,jj) = ABS((sshn(ji,jj+1) + bathy(ji,jj+1) - sshn(ji,jj) - bathy(ji,jj)) /&
-                           &     (sshn(ji,jj+1) - sshn(ji,jj)))
+               ! no worries about  sshn(ji,jj+1) -  sshn(ji,jj  ) = 0, it won't happen ! here
+               zcpy(ji,jj) = ABS( (sshn(ji,jj+1) + bathy(ji,jj+1) - sshn(ji,jj) - bathy(ji,jj)) &
+                           &    / (sshn(ji,jj+1) -  sshn(ji,jj  )) )
              ELSE
                zcpy(ji,jj) = 0._wp
@@ -1031,5 +1037,5 @@
         END DO
         CALL lbc_lnk( zcpx, 'U', 1._wp )    ;   CALL lbc_lnk( zcpy, 'V', 1._wp )
-      ENDIF
+      END IF
 
       ! Clean 3-D work arrays
@@ -1215,5 +1221,5 @@
                  zdpdx2 = zcoef0 * r1_e1u(ji,jj) * REAL(jis-jid, wp) * (zpwes + zpwed)
                ENDIF
-               IF(ln_wd) THEN
+               IF( ln_wd ) THEN
                   zdpdx1 = zdpdx1 * zcpx(ji,jj)
                   zdpdx2 = zdpdx2 * zcpx(ji,jj)
@@ -1274,5 +1280,5 @@
                   zdpdy2 = zcoef0 * r1_e2v(ji,jj) * REAL(jjs-jjd, wp) * (zpnss + zpnsd )
                ENDIF
-               IF(ln_wd) THEN
+               IF( ln_wd ) THEN
                   zdpdy1 = zdpdy1 * zcpy(ji,jj)
                   zdpdy2 = zdpdy2 * zcpy(ji,jj)
@@ -1289,5 +1295,5 @@
       CALL wrk_dealloc( jpi,jpj,jpk,   zdept, zrhh )
       CALL wrk_dealloc( jpi,jpj,       zsshu_n, zsshv_n )
-      IF(ln_wd) CALL wrk_dealloc( jpi,jpj, zcpx, zcpy )
+      IF( ln_wd ) CALL wrk_dealloc( jpi,jpj, zcpx, zcpy )
       !
    END SUBROUTINE hpg_prj
Index: /branches/2016/dev_r6393_NOC_WAD/NEMOGCM/NEMO/OPA_SRC/DYN/dynspg_ts.F90
===================================================================
--- /branches/2016/dev_r6393_NOC_WAD/NEMOGCM/NEMO/OPA_SRC/DYN/dynspg_ts.F90	(revision 7156)
+++ /branches/2016/dev_r6393_NOC_WAD/NEMOGCM/NEMO/OPA_SRC/DYN/dynspg_ts.F90	(revision 7157)
@@ -373,46 +373,48 @@
       IF( .NOT.ln_linssh ) THEN                 ! Variable volume : remove surface pressure gradient
         IF( ln_wd ) THEN                        ! Calculating and applying W/D gravity filters
-          DO jj = 2, jpjm1
-             DO ji = 2, jpim1
-                ll_tmp1 = MIN(sshn(ji,jj), sshn(ji+1,jj)) > MAX(-bathy(ji,jj), -bathy(ji+1,jj))   &
-                        & .and. MAX(sshn(ji,jj) + bathy(ji,jj), sshn(ji+1,jj) + bathy(ji+1,jj))   &
-                        &  > rn_wdmin1 + rn_wdmin2
-                ll_tmp2 = MAX(sshn(ji,jj), sshn(ji+1,jj)) > MAX(-bathy(ji,jj), -bathy(ji+1,jj))   &
-                        &                                   + rn_wdmin1 + rn_wdmin2
+           DO jj = 2, jpjm1
+              DO ji = 2, jpim1 
+                ll_tmp1 = MIN(   sshn(ji,jj)               ,   sshn(ji+1,jj) ) >                &
+                     &    MAX( -bathy(ji,jj)               , -bathy(ji+1,jj) ) .AND.            &
+                     &    MAX(   sshn(ji,jj) + bathy(ji,jj),   sshn(ji+1,jj) + bathy(ji+1,jj) ) &
+                     &                                                         > rn_wdmin1 + rn_wdmin2
+                ll_tmp2 = MAX(   sshn(ji,jj)               ,   sshn(ji+1,jj) ) >                &
+                     &    MAX( -bathy(ji,jj)               , -bathy(ji+1,jj) ) + rn_wdmin1 + rn_wdmin2
+   
                 IF(ll_tmp1) THEN
-                  zcpx(ji,jj)    = 1.0_wp
-                ELSEIF(ll_tmp2) THEN
-                   ! no worries about sshn(ji+1,jj)-sshn(ji,jj) = 0, it won't happen here
-                  zcpx(ji,jj) = ABS((sshn(ji+1,jj) + bathy(ji+1,jj) - sshn(ji,jj) - bathy(ji,jj)) &
-                        &          /(sshn(ji+1,jj) - sshn(ji,jj)))
+                  zcpx(ji,jj) = 1.0_wp
+                ELSE IF(ll_tmp2) THEN
+                  ! no worries about  sshn(ji+1,jj) -  sshn(ji  ,jj) = 0, it won't happen ! here
+                  zcpx(ji,jj) = ABS( (sshn(ji+1,jj) + bathy(ji+1,jj) - sshn(ji,jj) - bathy(ji,jj)) &
+                              &    / (sshn(ji+1,jj) -  sshn(ji  ,jj)) )
                 ELSE
-                  zcpx(ji,jj)    = 0._wp
+                  zcpx(ji,jj) = 0._wp
                 END IF
-
-                ll_tmp1 = MIN(sshn(ji,jj), sshn(ji,jj+1)) > MAX(-bathy(ji,jj), -bathy(ji,jj+1))   &
-                        & .and. MAX(sshn(ji,jj) + bathy(ji,jj), sshn(ji,jj+1) + bathy(ji,jj+1))   &
-                        &  > rn_wdmin1 + rn_wdmin2
-                ll_tmp2 = MAX(sshn(ji,jj), sshn(ji,jj+1)) > MAX(-bathy(ji,jj), -bathy(ji,jj+1))   &
-                        &                                   + rn_wdmin1 + rn_wdmin2
+         
+                ll_tmp1 = MIN(   sshn(ji,jj)               ,   sshn(ji,jj+1) ) >                &
+                     &    MAX( -bathy(ji,jj)               , -bathy(ji,jj+1) ) .AND.            &
+                     &    MAX(   sshn(ji,jj) + bathy(ji,jj),   sshn(ji,jj+1) + bathy(ji,jj+1) ) &
+                     &                                                         > rn_wdmin1 + rn_wdmin2
+                ll_tmp2 = MAX(   sshn(ji,jj)               ,   sshn(ji,jj+1) ) >                &
+                     &    MAX( -bathy(ji,jj)               , -bathy(ji,jj+1) ) + rn_wdmin1 + rn_wdmin2
+   
                 IF(ll_tmp1) THEN
-                   zcpy(ji,jj)    = 1.0_wp
-                ELSEIF(ll_tmp2) THEN
-                   ! no worries about sshn(ji,jj+1)-sshn(ji,jj) = 0, it won't happen here
-                  zcpy(ji,jj) = ABS((sshn(ji,jj+1) + bathy(ji,jj+1) - sshn(ji,jj) - bathy(ji,jj)) &
-                        &          /(sshn(ji,jj+1) - sshn(ji,jj)))
+                  zcpy(ji,jj) = 1.0_wp
+                ELSE IF(ll_tmp2) THEN
+                  ! no worries about  sshn(ji,jj+1) -  sshn(ji,jj  ) = 0, it won't happen ! here
+                  zcpy(ji,jj) = ABS( (sshn(ji,jj+1) + bathy(ji,jj+1) - sshn(ji,jj) - bathy(ji,jj)) &
+                              &    / (sshn(ji,jj+1) -  sshn(ji,jj  )) )
                 ELSE
-                  zcpy(ji,jj)    = 0._wp
-                ENDIF
-
-             END DO
+                  zcpy(ji,jj) = 0._wp
+                END IF
+              END DO
            END DO
-
-
+ 
            DO jj = 2, jpjm1
               DO ji = 2, jpim1
-                 zu_trd(ji,jj) = ( zu_trd(ji,jj) - grav * ( sshn(ji+1,jj  ) - sshn(ji  ,jj ) )   &
-                        &                        * r1_e1u(ji,jj) ) * zcpx(ji,jj)
-                 zv_trd(ji,jj) = ( zv_trd(ji,jj) - grav * ( sshn(ji  ,jj+1) - sshn(ji  ,jj ) )   &
-                        &                        * r1_e2v(ji,jj) ) * zcpy(ji,jj)
+                 zu_trd(ji,jj) = zu_trd(ji,jj) - grav * ( sshn(ji+1,jj  ) - sshn(ji  ,jj ) )   &
+                        &                        * r1_e1u(ji,jj) * zcpx(ji,jj)
+                 zv_trd(ji,jj) = zv_trd(ji,jj) - grav * ( sshn(ji  ,jj+1) - sshn(ji  ,jj ) )   &
+                        &                        * r1_e2v(ji,jj) * zcpy(ji,jj)
               END DO
            END DO
@@ -735,39 +737,44 @@
          zsshp2_e(:,:) = za0 *  ssha_e(:,:) + za1 *  sshn_e (:,:) &
           &            + za2 *  sshb_e(:,:) + za3 *  sshbb_e(:,:)
+
          IF( ln_wd ) THEN                   ! Calculating and applying W/D gravity filters
            DO jj = 2, jpjm1
-              DO ji = 2, jpim1
-                 ll_tmp1 = MIN( zsshp2_e(ji,jj), zsshp2_e(ji+1,jj) ) > MAX( -bathy(ji,jj), -bathy(ji+1,jj) ) &
-                        & .AND. MAX( zsshp2_e(ji,jj) + bathy(ji,jj), zsshp2_e(ji+1,jj) + bathy(ji+1,jj) )    &
-                        &                                  > rn_wdmin1 + rn_wdmin2
-                 ll_tmp2 = MAX( zsshp2_e(ji,jj), zsshp2_e(ji+1,jj) ) > MAX( -bathy(ji,jj), -bathy(ji+1,jj) ) &
-                        &                                  + rn_wdmin1 + rn_wdmin2
-                 IF(ll_tmp1) THEN
-                    zcpx(ji,jj) = 1._wp
-                 ELSE IF(ll_tmp2) THEN
-                    ! no worries about zsshp2_e(ji+1,jj)-zsshp2_e(ji,jj) = 0, it won't happen here
-                    zcpx(ji,jj) = ABS( (zsshp2_e(ji+1,jj) + bathy(ji+1,jj) - zsshp2_e(ji,jj) - bathy(ji,jj)) &
-                        &             / (zsshp2_e(ji+1,jj) - zsshp2_e(ji,jj)) )
-                 ELSE
-                    zcpx(ji,jj)    = 0._wp
-                 END IF
-
-                 ll_tmp1 = MIN( zsshp2_e(ji,jj), zsshp2_e(ji,jj+1) ) > MAX( -bathy(ji,jj), -bathy(ji,jj+1) ) &
-                        & .AND. MAX( zsshp2_e(ji,jj) + bathy(ji,jj), zsshp2_e(ji,jj+1) + bathy(ji,jj+1) )    &
-                        &                                  > rn_wdmin1 + rn_wdmin2
-                 ll_tmp2 = MAX( zsshp2_e(ji,jj), zsshp2_e(ji,jj+1) ) > MAX( -bathy(ji,jj), -bathy(ji,jj+1) ) &
-                        &                                  + rn_wdmin1 + rn_wdmin2
-                 IF(ll_tmp1) THEN
-                    zcpy(ji,jj) = 1._wp
-                 ELSE IF(ll_tmp2) THEN
-                    ! no worries about zsshp2_e(ji,jj+1)-zsshp2_e(ji,jj) = 0, it won't happen here
-                    zcpy(ji,jj) = ABS( (zsshp2_e(ji,jj+1) + bathy(ji,jj+1) - zsshp2_e(ji,jj) - bathy(ji,jj)) &
-                        &             / (zsshp2_e(ji,jj+1) - zsshp2_e(ji,jj)) )
-                 ELSE
-                    zcpy(ji,jj)    = 0._wp
-                 END IF
+              DO ji = 2, jpim1 
+                ll_tmp1 = MIN( zsshp2_e(ji,jj)               , zsshp2_e(ji+1,jj) ) >                &
+                     &    MAX(   -bathy(ji,jj)               ,   -bathy(ji+1,jj) ) .AND.            &
+                     &    MAX( zsshp2_e(ji,jj) + bathy(ji,jj), zsshp2_e(ji+1,jj) + bathy(ji+1,jj) ) &
+                     &                                                             > rn_wdmin1 + rn_wdmin2
+                ll_tmp2 = MAX( zsshp2_e(ji,jj)               , zsshp2_e(ji+1,jj) ) >                &
+                     &    MAX(   -bathy(ji,jj)               ,   -bathy(ji+1,jj) ) + rn_wdmin1 + rn_wdmin2
+   
+                IF(ll_tmp1) THEN
+                  zcpx(ji,jj) = 1.0_wp
+                ELSE IF(ll_tmp2) THEN
+                  ! no worries about  zsshp2_e(ji+1,jj) - zsshp2_e(ji  ,jj) = 0, it won't happen ! here
+                  zcpx(ji,jj) = ABS( (zsshp2_e(ji+1,jj) +    bathy(ji+1,jj) - zsshp2_e(ji,jj) - bathy(ji,jj)) &
+                              &    / (zsshp2_e(ji+1,jj) - zsshp2_e(ji  ,jj)) )
+                ELSE
+                  zcpx(ji,jj) = 0._wp
+                END IF
+         
+                ll_tmp1 = MIN( zsshp2_e(ji,jj)               , zsshp2_e(ji,jj+1) ) >                &
+                     &    MAX(   -bathy(ji,jj)               ,   -bathy(ji,jj+1) ) .AND.            &
+                     &    MAX( zsshp2_e(ji,jj) + bathy(ji,jj), zsshp2_e(ji,jj+1) + bathy(ji,jj+1) ) &
+                     &                                                             > rn_wdmin1 + rn_wdmin2
+                ll_tmp2 = MAX( zsshp2_e(ji,jj)               , zsshp2_e(ji,jj+1) ) >                &
+                     &    MAX(   -bathy(ji,jj)               ,   -bathy(ji,jj+1) ) + rn_wdmin1 + rn_wdmin2
+   
+                IF(ll_tmp1) THEN
+                  zcpy(ji,jj) = 1.0_wp
+                ELSE IF(ll_tmp2) THEN
+                  ! no worries about  zsshp2_e(ji,jj+1) - zsshp2_e(ji,jj  ) = 0, it won't happen ! here
+                  zcpy(ji,jj) = ABS( (zsshp2_e(ji,jj+1) +    bathy(ji,jj+1) - zsshp2_e(ji,jj) - bathy(ji,jj)) &
+                              &    / (zsshp2_e(ji,jj+1) - zsshp2_e(ji,jj  )) )
+                ELSE
+                  zcpy(ji,jj) = 0._wp
+                END IF
               END DO
-            END DO
-         ENDIF
+           END DO
+         END IF
          !
          ! Compute associated depths at U and V points:
