Index: NEMO/branches/2020/dev_r12527_Gurvan_ShallowWater/cfgs/AM98/EXPREF/file_def_nemo-oce.xml
===================================================================
--- NEMO/branches/2020/dev_r12527_Gurvan_ShallowWater/cfgs/AM98/EXPREF/file_def_nemo-oce.xml	(revision 12666)
+++ NEMO/branches/2020/dev_r12527_Gurvan_ShallowWater/cfgs/AM98/EXPREF/file_def_nemo-oce.xml	(revision 12667)
@@ -17,11 +17,9 @@
       <file_group id="6h" output_freq="6h"  output_level="10" enabled=".TRUE."/> <!-- 6h files -->
      
-      <file_group id="1d" output_freq="1d"  output_level="10" enabled=".TRUE."/> <!-- 1d files -->
+      <file_group id="1d" output_freq="1d"  output_level="10" enabled=".TRUE."/> <!-- 1d files -->      
       <file_group id="3d" output_freq="3d"  output_level="10" enabled=".TRUE."/> <!-- 3d files -->    
-      <file_group id="5d" output_freq="5d"  output_level="10" enabled=".TRUE."/> <!-- 5d files -->   
-     
-      <file_group id="1m" output_freq="1mo" output_level="10" enabled=".TRUE."> <!-- real monthly files -->
+      <file_group id="5d" output_freq="5d"  output_level="10" enabled=".TRUE."> <!-- 5d files --> 
       
-        <file id="file1" name_suffix="_grid_T" description="ocean T grid variables" >
+      <file id="file1" name_suffix="_grid_T" description="ocean T grid variables" >
           <field field_ref="ht"           name="ht"       operation = "instant" />
           <field field_ref="sKE"          name="sKE"      operation = "instant" />
@@ -53,5 +51,6 @@
       
       </file_group>
-
+        
+      <file_group id="1m" output_freq="1mo" output_level="10" enabled=".TRUE."/> <!-- real monthly files -->
       <file_group id="2m" output_freq="2mo" output_level="10" enabled=".TRUE."/> <!-- real 2m files -->
       <file_group id="3m" output_freq="3mo" output_level="10" enabled=".TRUE."/> <!-- real 3m files -->
Index: NEMO/branches/2020/dev_r12527_Gurvan_ShallowWater/cfgs/AM98/EXPREF/namelist_cfg
===================================================================
--- NEMO/branches/2020/dev_r12527_Gurvan_ShallowWater/cfgs/AM98/EXPREF/namelist_cfg	(revision 12666)
+++ NEMO/branches/2020/dev_r12527_Gurvan_ShallowWater/cfgs/AM98/EXPREF/namelist_cfg	(revision 12667)
@@ -51,6 +51,6 @@
    rn_rfr           = 1.e-7   ! layer drag coefficient        [1/s] 
    !
-   rn_beta = 2.E-11   ! beta-plan coriolis parameter  [1/m.s] 
-   rn_f0   = 0.7E-4   ! f-plan coriolis parameter     [1/s] 
+   rn_beta = 2.e-11   ! beta-plan coriolis parameter  [1/m.s] 
+   rn_f0   = 0.7e-4   ! f-plan coriolis parameter     [1/s] 
 /
 !-----------------------------------------------------------------------
@@ -147,6 +147,11 @@
 &namdyn_vor    !   Vorticity / Coriolis scheme                          (default: NO selection)
 !-----------------------------------------------------------------------
-   ln_dynvor_ene = .true.  !  energy conserving scheme
-!   ln_dynvor_ens = .true.   !  enstrophy conserving scheme
+   ln_dynvor_ene = .true.   !  energy conserving scheme
+   ln_dynvor_ens = .false.  !  enstrophy conserving scheme
+   ln_dynvor_een = .false.  !  energy & enstrophy scheme
+      nn_een_e3f = 0          ! =0  e3f = mi(mj(e3t))/4
+      !                       ! =1  e3f = mi(mj(e3t))/mi(mj( tmask))
+   ln_dynvor_msk = .false.  !  vorticity multiplied by fmask (=T)
+      !                     !  (f-point vorticity schemes only)
 /
 !-----------------------------------------------------------------------
Index: NEMO/branches/2020/dev_r12527_Gurvan_ShallowWater/src/SWE/diawri.F90
===================================================================
--- NEMO/branches/2020/dev_r12527_Gurvan_ShallowWater/src/SWE/diawri.F90	(revision 12666)
+++ NEMO/branches/2020/dev_r12527_Gurvan_ShallowWater/src/SWE/diawri.F90	(revision 12667)
@@ -180,4 +180,5 @@
               &                     + e3t(ji,jj  ,1,Kmm) * e1e2t(ji,jj  ) + e3t(ji+1,jj  ,1,Kmm) * e1e2t(ji+1,jj  )  ) * r1_e1e2f(ji,jj)
          END_2D
+         z2d(:,:) = z2d(:,:) * ssfmask(:,:)
          CALL lbc_lnk( 'diawri', z2d, 'F', 1._wp )
          CALL iom_put( "hf", z2d )   
Index: NEMO/branches/2020/dev_r12527_Gurvan_ShallowWater/src/SWE/dynvor.F90
===================================================================
--- NEMO/branches/2020/dev_r12527_Gurvan_ShallowWater/src/SWE/dynvor.F90	(revision 12666)
+++ NEMO/branches/2020/dev_r12527_Gurvan_ShallowWater/src/SWE/dynvor.F90	(revision 12667)
@@ -21,4 +21,5 @@
    !!             -   ! 2018-03  (G. Madec)  add two new schemes (ln_dynvor_enT and ln_dynvor_eet)
    !!             -   ! 2018-04  (G. Madec)  add pre-computed gradient for metric term calculation
+   !!            4.x  ! 2020-03  (G. Madec, A. Nasser)  make ln_dynvor_msk truly efficient on relative vorticity
    !!----------------------------------------------------------------------
 
@@ -226,12 +227,12 @@
       !
       !
-      SELECT CASE( kvor )                 !==  volume weighted vorticity considered  ==!
-      CASE ( np_RVO )                           !* relative vorticity
-         DO jk = 1, jpkm1                                 ! Horizontal slab
+      SELECT CASE( kvor )                 !== relative vorticity considered  ==!
+      CASE ( np_RVO , np_CRV )                  !* relative vorticity at f-point is used
+         DO jk = 1, jpkm1                                ! Horizontal slab
             DO_2D_10_10
                zwz(ji,jj,jk) = (  e2v(ji+1,jj) * pv(ji+1,jj,jk) - e2v(ji,jj) * pv(ji,jj,jk)  &
                   &             - e1u(ji,jj+1) * pu(ji,jj+1,jk) + e1u(ji,jj) * pu(ji,jj,jk)  ) * r1_e1e2f(ji,jj)
             END_2D
-            IF( ln_dynvor_msk ) THEN                     ! mask/unmask relative vorticity 
+            IF( ln_dynvor_msk ) THEN                     ! mask relative vorticity 
                DO_2D_10_10
                   zwz(ji,jj,jk) = zwz(ji,jj,jk) * fmask(ji,jj,jk)
@@ -239,29 +240,14 @@
             ENDIF
          END DO
-
          CALL lbc_lnk( 'dynvor', zwz, 'F', 1. )
-
-      CASE ( np_CRV )                           !* Coriolis + relative vorticity
-         DO jk = 1, jpkm1                                 ! Horizontal slab
-            DO_2D_10_10
-               zwz(ji,jj,jk) = (   e2v(ji+1,jj) * pv(ji+1,jj,jk) - e2v(ji,jj) * pv(ji,jj,jk)   &
-                  &              - e1u(ji,jj+1) * pu(ji,jj+1,jk) + e1u(ji,jj) * pu(ji,jj,jk)   ) * r1_e1e2f(ji,jj)
-            END_2D
-            IF( ln_dynvor_msk ) THEN                     ! mask/unmask relative vorticity 
-               DO_2D_10_10
-                  zwz(ji,jj,jk) = zwz(ji,jj,jk) * fmask(ji,jj,jk)
-               END_2D
-            ENDIF
-         END DO
-
-         CALL lbc_lnk( 'dynvor', zwz, 'F', 1. )
-
+         !
       END SELECT
 
       !                                                ! ===============
       DO jk = 1, jpkm1                                 ! Horizontal slab
-      !                                                ! ===============
-
+         !                                             ! ===============
+         !
          SELECT CASE( kvor )                 !==  volume weighted vorticity considered  ==!
+         !
          CASE ( np_COR )                           !* Coriolis (planetary vorticity)
             zwt(:,:) = ff_t(:,:) * e1e2t(:,:)*e3t(:,:,jk,Kmm)
@@ -356,4 +342,9 @@
                   &          - e1u(ji  ,jj+1) * pu(ji  ,jj+1,jk) + e1u(ji,jj) * pu(ji,jj,jk)  ) * r1_e1e2f(ji,jj)
             END_2D
+            IF( ln_dynvor_msk ) THEN                     ! mask the relative vorticity
+               DO_2D_10_10
+                  zwz(ji,jj) = zwz(ji,jj) * fmask(ji,jj,jk)
+               END_2D
+            ENDIF
          CASE ( np_MET )                           !* metric term
             DO_2D_10_10
@@ -366,4 +357,9 @@
                   &                        - e1u(ji,jj+1) * pu(ji,jj+1,jk) + e1u(ji,jj) * pu(ji,jj,jk)  ) * r1_e1e2f(ji,jj)
             END_2D
+            IF( ln_dynvor_msk ) THEN                     ! mask the relative vorticity (NOT the Coriolis term)
+               DO_2D_10_10
+                  zwz(ji,jj) = ( zwz(ji,jj) - ff_f(ji,jj) ) * fmask(ji,jj,jk) + ff_f(ji,jj)
+               END_2D
+            ENDIF
          CASE ( np_CME )                           !* Coriolis + metric
             DO_2D_10_10
@@ -375,18 +371,9 @@
          END SELECT
          !
-         IF( ln_dynvor_msk ) THEN          !==  mask/unmask vorticity ==!
-            DO_2D_10_10
-               zwz(ji,jj) = zwz(ji,jj) * fmask(ji,jj,jk)
-            END_2D
-         ENDIF
-
-         IF( ln_sco ) THEN
-            zwz(:,:) = zwz(:,:) / e3f(:,:,jk)
-            zwx(:,:) = e2u(:,:) * e3u(:,:,jk,Kmm) * pu(:,:,jk)
-            zwy(:,:) = e1v(:,:) * e3v(:,:,jk,Kmm) * pv(:,:,jk)
-         ELSE
-            zwx(:,:) = e2u(:,:) * pu(:,:,jk)
-            zwy(:,:) = e1v(:,:) * pv(:,:,jk)
-         ENDIF
+         !                                   !==  horizontal fluxes and potential vorticity ==!
+         zwx(:,:) = e2u(:,:) * e3u(:,:,jk,Kmm) * pu(:,:,jk)
+         zwy(:,:) = e1v(:,:) * e3v(:,:,jk,Kmm) * pv(:,:,jk)
+         zwz(:,:) = zwz(:,:) / e3f(:,:,jk)
+         !
          !                                   !==  compute and add the vorticity term trend  =!
          DO_2D_00_00
@@ -452,4 +439,9 @@
                   &          - e1u(ji  ,jj+1) * pu(ji  ,jj+1,jk) + e1u(ji,jj) * pu(ji,jj,jk)  ) * r1_e1e2f(ji,jj)
             END_2D
+            IF( ln_dynvor_msk ) THEN                     ! mask the relative vorticity
+               DO_2D_10_10
+                  zwz(ji,jj) = ff_f(ji,jj) * fmask(ji,jj,jk)
+               END_2D
+            ENDIF
          CASE ( np_MET )                           !* metric term
             DO_2D_10_10
@@ -461,6 +453,10 @@
                zwz(ji,jj) = ff_f(ji,jj) + (  e2v(ji+1,jj  ) * pv(ji+1,jj  ,jk) - e2v(ji,jj) * pv(ji,jj,jk)  &
                   &                        - e1u(ji  ,jj+1) * pu(ji  ,jj+1,jk) + e1u(ji,jj) * pu(ji,jj,jk)  ) * r1_e1e2f(ji,jj)
-!!an                  &                        * fmask(ji,jj,jk)
-            END_2D
+            END_2D
+            IF( ln_dynvor_msk ) THEN                     ! mask the relative vorticity (NOT the Coriolis term)
+               DO_2D_10_10
+                  zwz(ji,jj) = ( zwz(ji,jj) - ff_f(ji,jj) ) * fmask(ji,jj,jk) + ff_f(ji,jj)
+               END_2D
+            ENDIF
          CASE ( np_CME )                           !* Coriolis + metric
             DO_2D_10_10
@@ -472,18 +468,10 @@
          END SELECT
          !
-         IF( ln_dynvor_msk ) THEN           !==  mask/unmask vorticity ==!
-            DO_2D_10_10
-               zwz(ji,jj) = zwz(ji,jj) * fmask(ji,jj,jk)
-            END_2D
-         ENDIF
-         !
-         IF( ln_sco ) THEN                   !==  horizontal fluxes  ==!
-            zwz(:,:) = zwz(:,:) / e3f(:,:,jk)
-            zwx(:,:) = e2u(:,:) * e3u(:,:,jk,Kmm) * pu(:,:,jk)
-            zwy(:,:) = e1v(:,:) * e3v(:,:,jk,Kmm) * pv(:,:,jk)
-         ELSE
-            zwx(:,:) = e2u(:,:) * pu(:,:,jk)
-            zwy(:,:) = e1v(:,:) * pv(:,:,jk)
-         ENDIF
+         !
+         !                                   !==  horizontal fluxes and potential vorticity ==!
+         zwx(:,:) = e2u(:,:) * e3u(:,:,jk,Kmm) * pu(:,:,jk)
+         zwy(:,:) = e1v(:,:) * e3v(:,:,jk,Kmm) * pv(:,:,jk)
+         zwz(:,:) = zwz(:,:) / e3f(:,:,jk)
+         !
          !                                   !==  compute and add the vorticity term trend  =!
          DO_2D_00_00
@@ -725,6 +713,6 @@
       !
       DO jk = 1, jpkm1                                 ! Horizontal slab
-
-      !                                   !==  horizontal fluxes  ==!
+         !
+         !                                   !==  horizontal fluxes  ==!
          zwx(:,:) = e2u(:,:) * e3u(:,:,jk,Kmm) * pu(:,:,jk)
          zwy(:,:) = e1v(:,:) * e3v(:,:,jk,Kmm) * pv(:,:,jk)
@@ -801,5 +789,5 @@
       ENDIF
 
-      IF( ln_dynvor_msk )   CALL ctl_stop( 'dyn_vor_init:   masked vorticity is not currently not available')
+!!an      IF( ln_dynvor_msk )   CALL ctl_stop( 'dyn_vor_init:   masked vorticity is not currently not available')
 
 !!gm  this should be removed when choosing a unique strategy for fmask at the coast
