Index: branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/NEMO/OPA_SRC/usrdef.F90
===================================================================
--- branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/NEMO/OPA_SRC/usrdef.F90	(revision 6579)
+++ branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/NEMO/OPA_SRC/usrdef.F90	(revision 6583)
@@ -2,5 +2,5 @@
    !!==============================================================================
    !!                       ***  MODULE usrdef   ***
-   !! User defined module: used like example to define init, sbc, bathy, ...
+   !! User defined module: used like example to define domain, init, sbc, ...
    !!==============================================================================
    !! History :  NEMO ! 2016-03  (S. Flavoni) 
@@ -10,5 +10,4 @@
    !!   usr_def_hgr       : initialize the horizontal mesh 
    !!   usr_def_ini       : initial state 
-   !!   usr_def_sbc       : initialize the surface bounday conditions
    !!----------------------------------------------------------------------
    USE step_oce       ! module used in the ocean time stepping module (step.F90)
@@ -29,11 +28,11 @@
 CONTAINS
 
-   SUBROUTINE usr_def_hgr( nbench, jp_cfg, kff    , pff   , & ! Coriolis parameter  (if domain not on the sphere)
-           &               pglamt, pglamu, pglamv , pglamf, & ! gridpoints position (required)
-           &               pgphit, pgphiu, pgphiv , pgphif, & !         
-           &               pe1t  , pe1u  , pe1v   , pe1f  , & ! scale factors (required)
-           &               pe2t  , pe2u  , pe2v   , pe2f  , & !
-           &               ke1e2u_v                       )   ! u- & v-surfaces (if gridsize reduction is used in strait(s))
-      !!-------------------------------------------------------------------------------------------------
+   SUBROUTINE usr_def_hgr( kbench, k_cfg , kff    , pff   , & ! Coriolis parameter  (if domain not on the sphere)
+      &                    pglamt, pglamu, pglamv , pglamf, & ! gridpoints position (required)
+      &                    pgphit, pgphiu, pgphiv , pgphif, & !         
+      &                    pe1t  , pe1u  , pe1v   , pe1f  , & ! scale factors (required)
+      &                    pe2t  , pe2u  , pe2v   , pe2f  , & !
+      &                    ke1e2u_v                       )   ! u- & v-surfaces (if gridsize reduction is used in strait(s))
+      !!----------------------------------------------------------------------
       !!                  ***  ROUTINE usr_def_hgr  ***
       !!
@@ -52,10 +51,8 @@
       !!              - define i- & j-scale factors at t-, u-, v- and f-points (in meters)
       !!              - define u- & v-surfaces (if gridsize reduction is used in some straits) (in m2)
-      !!-------------------------------------------------------------------------------------------------
-
-      !!----------------------------------------------------------------------
-      INTEGER                 , INTENT(in   ) ::   nbench, jp_cfg   ! parameter of namelist for benchmark, and dimension of GYRE
-      INTEGER                 , INTENT(  out) ::   kff              ! =1 Coriolis parameter computed here, =0 otherwise
-      REAL(wp), DIMENSION(:,:), INTENT(  out) ::   pff              ! Coriolis factor at f-point                  [1/s]
+      !!----------------------------------------------------------------------
+      INTEGER                 , INTENT(in   ) ::   kbench, k_cfg   ! parameter of namelist for benchmark, and dimension of GYRE
+      INTEGER                 , INTENT(  out) ::   kff             ! =1 Coriolis parameter computed here, =0 otherwise
+      REAL(wp), DIMENSION(:,:), INTENT(  out) ::   pff             ! Coriolis factor at f-point                  [1/s]
       REAL(wp), DIMENSION(:,:), INTENT(  out) ::   pglamt, pglamu, pglamv, pglamf !  longitude outputs        [degrees]
       REAL(wp), DIMENSION(:,:), INTENT(  out) ::   pgphit, pgphiu, pgphiv, pgphif !  latitude outputs         [degrees]
@@ -76,10 +73,77 @@
       IF(lwp) WRITE(numout,*) '          beta-plane with regular grid-spacing and rotated domain (GYRE configuration)'
       !
-      ! angle 45deg and ze1=106.e+3 / jp_cfg forced -> zlam1 = -85deg, zphi1 = 29degN
+      ! angle 45deg and ze1=106.e+3 / k_cfg forced -> zlam1 = -85deg, zphi1 = 29degN
       zlam1 = -85._wp
       zphi1 =  29._wp
       ! resolution in meters
-      ze1 = 106000. / REAL( jp_cfg , wp )
+      ze1 = 106000. / REAL( k_cfg , wp )
       ! benchmark: forced the resolution to be about 100 km
+            IF( kbench /= 0 )   ze1 = 106000._wp   
+      zsin_alpha = - SQRT( 2._wp ) * 0.5_wp
+      zcos_alpha =   SQRT( 2._wp ) * 0.5_wp
+      ze1deg = ze1 / (ra * rad)
+      IF( kbench /= 0 )   ze1deg = ze1deg / REAL( jp_cfg , wp )   ! benchmark: keep the lat/+lon
+      !                                                           ! at the right jp_cfg resolution
+      zlam0 = zlam1 + zcos_alpha * ze1deg * REAL( jpjglo-2 , wp )
+      zphi0 = zphi1 + zsin_alpha * ze1deg * REAL( jpjglo-2 , wp )
+      !   
+      IF( nprint==1 .AND. lwp )   THEN
+         WRITE(numout,*) '          ze1', ze1, 'cosalpha', zcos_alpha, 'sinalpha', zsin_alpha
+         WRITE(numout,*) '          ze1deg', ze1deg, 'zlam0', zlam0, 'zphi0', zphi0
+      ENDIF
+      !   
+      DO jj = 1, jpj 
+         DO ji = 1, jpi 
+            zim1 = REAL( ji + nimpp - 1 ) - 1.   ;   zim05 = REAL( ji + nimpp - 1 ) - 1.5 
+            zjm1 = REAL( jj + njmpp - 1 ) - 1.   ;   zjm05 = REAL( jj + njmpp - 1 ) - 1.5 
+            !   
+            !glamt(i,j) longitude at T-point
+            !gphit(i,j) latitude at T-point  
+            pglamt(ji,jj) = zlam0 + zim05 * ze1deg * zcos_alpha + zjm05 * ze1deg * zsin_alpha
+            pgphit(ji,jj) = zphi0 - zim05 * ze1deg * zsin_alpha + zjm05 * ze1deg * zcos_alpha
+            !   
+            !glamu(i,j) longitude at U-point
+            !gphiu(i,j) latitude at U-point
+            pglamu(ji,jj) = zlam0 + zim1  * ze1deg * zcos_alpha + zjm05 * ze1deg * zsin_alpha
+            pgphiu(ji,jj) = zphi0 - zim1  * ze1deg * zsin_alpha + zjm05 * ze1deg * zcos_alpha
+            !   
+            !glamv(i,j) longitude at V-point
+            !gphiv(i,j) latitude at V-point
+            pglamv(ji,jj) = zlam0 + zim05 * ze1deg * zcos_alpha + zjm1  * ze1deg * zsin_alpha
+            pgphiv(ji,jj) = zphi0 - zim05 * ze1deg * zsin_alpha + zjm1  * ze1deg * zcos_alpha
+            !
+            !glamf(i,j) longitude at F-point
+            !gphif(i,j) latitude at F-point 
+            pglamf(ji,jj) = zlam0 + zim1  * ze1deg * zcos_alpha + zjm1  * ze1deg * zsin_alpha
+            pgphif(ji,jj) = zphi0 - zim1  * ze1deg * zsin_alpha + zjm1  * ze1deg * zcos_alpha
+         END DO
+      END DO
+      !
+      !       !== Horizontal scale factors ==! (in meters)
+      !                     
+      !                             ! constant grid spacing
+      pe1t(:,:) =  ze1     ;      pe2t(:,:) = ze1
+      pe1u(:,:) =  ze1     ;      pe2u(:,:) = ze1
+      pe1v(:,:) =  ze1     ;      pe2v(:,:) = ze1
+      pe1f(:,:) =  ze1     ;      pe2f(:,:) = ze1
+      !                             ! NO reduction of grid size in some straits 
+      ke1e2u_v = 0                  !    ==>> u_ & v_surfaces will be computed in dom_ghr routine
+      !
+      !
+
+      !                      !==  Coriolis parameter  ==!
+      kff = 1                                                           !  indicate not to compute ff afterward
+      !
+      zbeta = 2. * omega * COS( rad * zphi1 ) / ra                      ! beta at latitude zphi1
+      !SF we overwrite zphi0 (south point in latitude) used just above to define pgphif (value of zphi0=15.5190567531966)
+      !SF for computation of coriolis we keep the parameter of Hazeleger, W., and S. S. Drijfhout, JPO 1998.
+      zphi0 = 15._wp                                                    !  latitude of the most southern grid point  
+      zf0   = 2. * omega * SIN( rad * zphi0 )                           !  compute f0 1st point south
+      !
+      pff(:,:) = ( zf0 + zbeta * ABS( gphif(:,:) - zphi0 ) * rad * ra ) ! f = f0 +beta* y ( y=0 at south)
+      !
+      IF(lwp) WRITE(numout,*) '                           beta-plane used. beta = ', zbeta, ' 1/(s.m)'
+      !
+      IF( nn_timing == 1 )  CALL timing_stop('usr_def_hgr')
       !
    END SUBROUTINE usr_def_hgr
@@ -101,5 +165,5 @@
       !!              - set salinity   field
       !!----------------------------------------------------------------------
-      REAL(wp), DIMENSION(jpi,jpj,jpk,jpts), INTENT(  out) ::   ptsd   ! T & S data
+      REAL(wp), DIMENSION(jpi,jpj,jpk,jpts), INTENT(  out) ::   pts   ! T & S data
       !
       INTEGER :: ji, jj, jk  ! dummy loop indices
