New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
usrdef_hgr.F90 in branches/2017/dev_merge_2017/NEMOGCM/CONFIG/TEST_CASES/SAS_BIPER/MY_SRC – NEMO

source: branches/2017/dev_merge_2017/NEMOGCM/CONFIG/TEST_CASES/SAS_BIPER/MY_SRC/usrdef_hgr.F90 @ 9154

Last change on this file since 9154 was 9154, checked in by clem, 6 years ago

SAS_BIPER test case: change the position of the grid to match Jerome's changes in VORTEX test case

File size: 9.1 KB
Line 
1MODULE usrdef_hgr
2   !!======================================================================
3   !!                       ***  MODULE  usrdef_hgr  ***
4   !!
5   !!                     ===  SAS_BIPER configuration  ===
6   !!
7   !! User defined :   mesh and Coriolis parameter of a user configuration
8   !!======================================================================
9   !! History :  NEMO  ! 2016-08  (S. Flavoni, G. Madec)  Original code
10   !!----------------------------------------------------------------------
11
12   !!----------------------------------------------------------------------
13   !!   usr_def_hgr    : initialize the horizontal mesh for SAS_BIPER configuration
14   !!----------------------------------------------------------------------
15   USE dom_oce         ! ocean space and time domain
16   USE par_oce         ! ocean space and time domain
17   USE phycst          ! physical constants
18   USE usrdef_nam, ONLY: rn_dx, rn_dy   ! horizontal resolution in meters
19   !
20   USE in_out_manager  ! I/O manager
21   USE lib_mpp         ! MPP library
22   
23   IMPLICIT NONE
24   PRIVATE
25
26   PUBLIC   usr_def_hgr   ! called by domhgr.F90
27
28   !!----------------------------------------------------------------------
29   !! NEMO/OPA 4.0 , NEMO Consortium (2016)
30   !! $Id:$
31   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
32   !!----------------------------------------------------------------------
33CONTAINS
34
35   SUBROUTINE usr_def_hgr( plamt , plamu , plamv  , plamf  ,   &   ! geographic position (required)
36      &                    pphit , pphiu , pphiv  , pphif  ,   &   !
37      &                    kff   , pff_f , pff_t  ,            &   ! Coriolis parameter  (if domain not on the sphere)
38      &                    pe1t  , pe1u  , pe1v   , pe1f   ,   &   ! scale factors       (required)
39      &                    pe2t  , pe2u  , pe2v   , pe2f   ,   &   !
40      &                    ke1e2u_v      , pe1e2u , pe1e2v     )   ! u- & v-surfaces (if gridsize reduction is used in strait(s))
41      !!----------------------------------------------------------------------
42      !!                  ***  ROUTINE usr_def_hgr  ***
43      !!
44      !! ** Purpose :   user defined mesh and Coriolis parameter
45      !!
46      !! ** Method  :   set all intent(out) argument to a proper value
47      !!                SAS_BIPER configuration : uniform grid spacing (rn_dx)
48      !!                without Coriolis force (f=0)
49      !!
50      !! ** Action  : - define longitude & latitude of t-, u-, v- and f-points (in degrees)
51      !!              - define coriolis parameter at f-point if the domain in not on the sphere (on beta-plane)
52      !!              - define i- & j-scale factors at t-, u-, v- and f-points (in meters)
53      !!              - define u- & v-surfaces (if gridsize reduction is used in some straits) (in m2)
54      !!----------------------------------------------------------------------
55      REAL(wp), DIMENSION(:,:), INTENT(out) ::   plamt, plamu, plamv, plamf   ! longitude outputs                     [degrees]
56      REAL(wp), DIMENSION(:,:), INTENT(out) ::   pphit, pphiu, pphiv, pphif   ! latitude outputs                      [degrees]
57      INTEGER                 , INTENT(out) ::   kff                          ! =1 Coriolis parameter computed here, =0 otherwise
58      REAL(wp), DIMENSION(:,:), INTENT(out) ::   pff_f, pff_t                 ! Coriolis factor at f-point                [1/s]
59      REAL(wp), DIMENSION(:,:), INTENT(out) ::   pe1t, pe1u, pe1v, pe1f       ! i-scale factors                             [m]
60      REAL(wp), DIMENSION(:,:), INTENT(out) ::   pe2t, pe2u, pe2v, pe2f       ! j-scale factors                             [m]
61      INTEGER                 , INTENT(out) ::   ke1e2u_v                     ! =1 u- & v-surfaces computed here, =0 otherwise
62      REAL(wp), DIMENSION(:,:), INTENT(out) ::   pe1e2u, pe1e2v               ! u- & v-surfaces (if reduction in strait)   [m2]
63      !
64      INTEGER  ::   ji, jj   ! dummy loop indices
65      REAL(wp) ::   zphi0, zlam0, zbeta, zf0
66      REAL(wp) ::   zti, zui, zvi, zfi   ! local scalars
67      REAL(wp) ::   ztj, zuj, zvj, zfj   !   -      -
68      !!-------------------------------------------------------------------------------
69      !
70      IF(lwp) WRITE(numout,*)
71      IF(lwp) WRITE(numout,*) 'usr_def_hgr : SAS_BIPER configuration bassin'
72      IF(lwp) WRITE(numout,*)
73      IF(lwp) WRITE(numout,*) '          f-plane with irregular grid-spacing (+- 10%)'
74      IF(lwp) WRITE(numout,*) '          the max is given by rn_dx and rn_dy' 
75
76      !                          ==========
77!clem      zlam0 = 0._wp
78!clem      zphi0 = 0._wp
79      zlam0 = -(jpiglo-1)/2 * 1.e-3 * rn_dx
80      zphi0 = -(jpjglo-1)/2 * 1.e-3 * rn_dy
81
82#if defined key_agrif 
83      IF( .NOT. Agrif_Root() ) THEN
84!clem         zlam0  = Agrif_Parent(zlam0) + (Agrif_ix())*Agrif_Parent(rn_dx) * 1.e-5
85!clem         zphi0  = Agrif_Parent(zphi0) + (Agrif_iy())*Agrif_Parent(rn_dy) * 1.e-5
86         zlam0 = ( 0.5_wp - ( Agrif_parent(jpiglo) - 1 ) / 2 ) * 1.e-3 * Agrif_irhox() * rn_dx  &
87            &  + ( Agrif_Ix() + nbghostcells - 1 ) * Agrif_irhox() * rn_dx * 1.e-3 - ( 0.5_wp + nbghostcells ) * rn_dx * 1.e-3
88         zphi0 = ( 0.5_wp - ( Agrif_parent(jpjglo) - 1 ) / 2 ) * 1.e-3 * Agrif_irhoy() * rn_dy  &
89            &  + ( Agrif_Iy() + nbghostcells - 1 ) * Agrif_irhoy() * rn_dy * 1.e-3 - ( 0.5_wp + nbghostcells ) * rn_dy * 1.e-3
90         rn_dx = Agrif_Parent(rn_dx)/Agrif_Rhox()
91         rn_dy = Agrif_Parent(rn_dy)/Agrif_Rhoy()         
92      ENDIF
93#endif         
94
95      DO jj = 1, jpj
96         DO ji = 1, jpi
97            zti = FLOAT( ji - 1 + nimpp - 1 )         ;   ztj = FLOAT( jj - 1 + njmpp - 1 )
98            zui = FLOAT( ji - 1 + nimpp - 1 ) + 0.5   ;   zuj = FLOAT( jj - 1 + njmpp - 1 )
99            zvi = FLOAT( ji - 1 + nimpp - 1 )         ;   zvj = FLOAT( jj - 1 + njmpp - 1 ) + 0.5
100            zfi = FLOAT( ji - 1 + nimpp - 1 ) + 0.5   ;   zfj = FLOAT( jj - 1 + njmpp - 1 ) + 0.5
101
102            plamt(ji,jj) = zlam0 + rn_dx * 1.e-5 * zti
103            plamu(ji,jj) = zlam0 + rn_dx * 1.e-5 * zui
104            plamv(ji,jj) = zlam0 + rn_dx * 1.e-5 * zvi
105            plamf(ji,jj) = zlam0 + rn_dx * 1.e-5 * zfi
106   
107            pphit(ji,jj) = zphi0 + rn_dy * 1.e-5 * ztj
108            pphiu(ji,jj) = zphi0 + rn_dy * 1.e-5 * zuj
109            pphiv(ji,jj) = zphi0 + rn_dy * 1.e-5 * zvj
110            pphif(ji,jj) = zphi0 + rn_dy * 1.e-5 * zfj
111         END DO
112      END DO
113         
114         ! Horizontal scale factors (in meters)
115         !                              ======
116!! ==> EITHER 1) variable scale factors
117         DO jj = 1, jpj
118            DO ji = 1, jpi
119               !!pe1t(ji,jj) = rn_dx * EXP( -0.8/REAL(jpiglo**2) * (mi0(ji)-REAL(jpiglo+1)*0.5)**2 )  ! gaussian shape
120               !!pe2t(ji,jj) = rn_dy * EXP( -0.8/REAL(jpjglo**2) * (mj0(jj)-REAL(jpjglo+1)*0.5)**2 )  ! gaussian shape
121               pe1t(ji,jj) = rn_dx * ( 1. -0.1 * ABS(REAL(mi0(ji))-REAL(jpiglo+1)*0.5) / (1.-REAL(jpiglo+1)*0.5) ) ! linear shape
122               pe2t(ji,jj) = rn_dy * ( 1. -0.1 * ABS(REAL(mj0(jj))-REAL(jpjglo+1)*0.5) / (1.-REAL(jpjglo+1)*0.5) ) ! linear shape
123            END DO
124         END DO
125#if defined key_agrif 
126         IF( .NOT. Agrif_Root() ) THEN ! only works if the zoom is positioned at the center of the parent grid
127            DO jj = 1, jpj
128               DO ji = 1, jpi
129                  pe1t(ji,jj) = rn_dx * ( 1. -0.1 * ABS(REAL(mi0(ji))-REAL(jpiglo+1)*0.5) / (1.-REAL(jpiglo+1)*0.5)  &
130                     &                            * REAL(jpiglo) / REAL(Agrif_Parent(jpiglo) * Agrif_Rhox()) )       ! factor to match parent grid
131                  pe2t(ji,jj) = rn_dy * ( 1. -0.1 * ABS(REAL(mj0(jj))-REAL(jpjglo+1)*0.5) / (1.-REAL(jpjglo+1)*0.5)  &
132                     &                            * REAL(jpjglo) / REAL(Agrif_Parent(jpjglo) * Agrif_Rhoy()) )       ! factor to match parent grid
133               END DO
134            END DO
135         ENDIF
136#endif
137!! ==> OR 2) constant scale factors
138!!         pe1t(:,:) = rn_dx
139!!         pe2t(:,:) = rn_dy
140         
141         pe1u(:,:) = pe1t(:,:)      ;      pe2u(:,:) = pe2t(:,:)
142         pe1v(:,:) = pe1t(:,:)      ;      pe2v(:,:) = pe2t(:,:)
143         pe1f(:,:) = pe1t(:,:)      ;      pe2f(:,:) = pe2t(:,:)
144
145      !                             ! NO reduction of grid size in some straits
146      ke1e2u_v = 0                  !    ==>> u_ & v_surfaces will be computed in dom_ghr routine
147      pe1e2u(:,:) = 0._wp           !    CAUTION: set to zero to avoid error with some compilers that
148      pe1e2v(:,:) = 0._wp           !             require an initialization of INTENT(out) arguments
149      !
150      !
151      !                       !==  Coriolis parameter  ==!
152      kff = 1                       !  indicate not to compute Coriolis parameter afterward
153      !
154!!jerome      zbeta = 2._wp * omega * COS( rad * rn_ppgphi0 ) / ra
155!!      zf0   = 2._wp * omega * SIN( rad * rn_ppgphi0 )
156!!      pff_f(:,:) = zf0 + zbeta * pphif(:,:) * 1.e+3
157!!jerome      pff_t(:,:) = zf0 + zbeta * pphit(:,:) * 1.e+3
158      pff_f(:,:) = 0._wp            ! here No earth rotation: f=0
159      pff_t(:,:) = 0._wp
160      !
161   END SUBROUTINE usr_def_hgr
162
163   !!======================================================================
164END MODULE usrdef_hgr
Note: See TracBrowser for help on using the repository browser.