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 NEMO/branches/2019/dev_r10984_HPC-13_IRRMANN_BDY_optimization/src/OCE/USR – NEMO

source: NEMO/branches/2019/dev_r10984_HPC-13_IRRMANN_BDY_optimization/src/OCE/USR/usrdef_hgr.F90 @ 11048

Last change on this file since 11048 was 10069, checked in by nicolasmartin, 6 years ago

Fix mistakes of previous commit on SVN keywords property

  • Property svn:keywords set to Id
File size: 9.6 KB
Line 
1MODULE usrdef_hgr
2   !!======================================================================
3   !!                     ***  MODULE usrdef_hgr   ***
4   !!
5   !!                     ===  GYRE configuration  ===
6   !!
7   !! User defined :   mesh and Coriolis parameter of a user configuration
8   !!======================================================================
9   !! History :  4.0 ! 2016-03  (S. Flavoni)
10   !!----------------------------------------------------------------------
11
12   !!----------------------------------------------------------------------
13   !!   usr_def_hgr   : initialize the horizontal mesh
14   !!----------------------------------------------------------------------
15   USE dom_oce  , ONLY: nimpp, njmpp       ! ocean space and time domain
16   USE par_oce        ! ocean space and time domain
17   USE phycst         ! physical constants
18   USE usrdef_nam     !
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 in domhgr.F90
27
28   !!----------------------------------------------------------------------
29   !! NEMO/OCE 4.0 , NEMO Consortium (2018)
30   !! $Id$
31   !! Software governed by the CeCILL license (see ./LICENSE)
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      !!
48      !!                Here GYRE configuration :
49      !!          Rectangular mid-latitude domain
50      !!          - with axes rotated by 45 degrees
51      !!          - a constant horizontal resolution of 106 km
52      !!          - on a beta-plane
53      !!
54      !! ** Action  : - define longitude & latitude of t-, u-, v- and f-points (in degrees)
55      !!              - define coriolis parameter at f-point if the domain in not on the sphere (on beta-plane)
56      !!              - define i- & j-scale factors at t-, u-, v- and f-points (in meters)
57      !!              - define u- & v-surfaces (if gridsize reduction is used in some straits) (in m2)
58      !!----------------------------------------------------------------------
59      REAL(wp), DIMENSION(:,:), INTENT(out) ::   plamt, plamu, plamv, plamf   ! longitude outputs                     [degrees]
60      REAL(wp), DIMENSION(:,:), INTENT(out) ::   pphit, pphiu, pphiv, pphif   ! latitude outputs                      [degrees]
61      INTEGER                 , INTENT(out) ::   kff                          ! =1 Coriolis parameter computed here, =0 otherwise
62      REAL(wp), DIMENSION(:,:), INTENT(out) ::   pff_f, pff_t                 ! Coriolis factor at f-point                [1/s]
63      REAL(wp), DIMENSION(:,:), INTENT(out) ::   pe1t, pe1u, pe1v, pe1f       ! i-scale factors                             [m]
64      REAL(wp), DIMENSION(:,:), INTENT(out) ::   pe2t, pe2u, pe2v, pe2f       ! j-scale factors                             [m]
65      INTEGER                 , INTENT(out) ::   ke1e2u_v                     ! =1 u- & v-surfaces computed here, =0 otherwise
66      REAL(wp), DIMENSION(:,:), INTENT(out) ::   pe1e2u, pe1e2v               ! u- & v-surfaces (if reduction in strait)   [m2]
67      !
68      INTEGER  ::   ji, jj               ! dummy loop indices
69      REAL(wp) ::   zlam1, zlam0, zcos_alpha, zim1 , zjm1 , ze1  , ze1deg, zf0 ! local scalars
70      REAL(wp) ::   zphi1, zphi0, zsin_alpha, zim05, zjm05, zbeta, znorme      !   -      -
71      !!-------------------------------------------------------------------------------
72      !
73      !     !==  beta-plane with regular grid-spacing and rotated domain ==!  (GYRE configuration)
74      !
75      IF(lwp) WRITE(numout,*)
76      IF(lwp) WRITE(numout,*) 'usr_def_hgr : GYRE configuration (beta-plane with rotated regular grid-spacing)'
77      IF(lwp) WRITE(numout,*) '~~~~~~~~~~~'
78      !
79      !
80      !                       !==  grid point position  ==!
81      !
82      zlam1 = -85._wp                           ! position of gridpoint (i,j) = (1,jpjglo)
83      zphi1 =  29._wp
84      !
85      ze1 = 106000._wp / REAL( nn_GYRE , wp )   ! gridspacing in meters
86      !
87      zsin_alpha = - SQRT( 2._wp ) * 0.5_wp     ! angle: 45 degrees
88      zcos_alpha =   SQRT( 2._wp ) * 0.5_wp
89      ze1deg = ze1 / (ra * rad)
90      zlam0 = zlam1 + zcos_alpha * ze1deg * REAL( jpjglo-2 , wp )
91      zphi0 = zphi1 + zsin_alpha * ze1deg * REAL( jpjglo-2 , wp )
92
93#if defined key_agrif
94      ! ! Upper left longitude and latitude from parent:
95      IF (.NOT.Agrif_root()) THEN
96         zlam0 = zlam1 + Agrif_irhox() * REAL(Agrif_Parent(jpjglo)-2 , wp) * ze1deg * zcos_alpha  &
97                   &   + ( Agrif_Ix()*Agrif_irhox()-(0.5_wp+nbghostcells)) * ze1deg * zcos_alpha  &
98                   &   + ( Agrif_Iy()*Agrif_irhoy()-(0.5_wp+nbghostcells)) * ze1deg * zsin_alpha
99         zphi0 = zphi1 + Agrif_irhoy() * REAL(Agrif_Parent(jpjglo)-2 , wp) * ze1deg * zsin_alpha  &
100                   &   - ( Agrif_Ix()*Agrif_irhox()-nbghostcells )         * ze1deg * zsin_alpha  &
101                   &   + ( Agrif_Iy()*Agrif_irhoy()-nbghostcells )         * ze1deg * zcos_alpha
102      ENDIF 
103#endif
104      !   
105      IF( ln_bench ) THEN     ! benchmark: forced the resolution to be 106 km
106         ze1 = 106000._wp     ! but keep (lat,lon) at the right nn_GYRE resolution
107         CALL ctl_warn( ' GYRE used as Benchmark: e1=e2=106km, no need to adjust rdt, ahm,aht ' )
108      ENDIF
109      IF( nprint==1 .AND. lwp )   THEN
110         WRITE(numout,*) 'ze1', ze1, 'cosalpha', zcos_alpha, 'sinalpha', zsin_alpha
111         WRITE(numout,*) 'ze1deg', ze1deg, 'zlam0', zlam0, 'zphi0', zphi0
112      ENDIF
113      !   
114      DO jj = 1, jpj 
115         DO ji = 1, jpi 
116            zim1 = REAL( ji + nimpp - 1 ) - 1.   ;   zim05 = REAL( ji + nimpp - 1 ) - 1.5 
117            zjm1 = REAL( jj + njmpp - 1 ) - 1.   ;   zjm05 = REAL( jj + njmpp - 1 ) - 1.5 
118            !   
119            !glamt(i,j) longitude at T-point
120            !gphit(i,j) latitude at T-point 
121            plamt(ji,jj) = zlam0 + zim05 * ze1deg * zcos_alpha + zjm05 * ze1deg * zsin_alpha
122            pphit(ji,jj) = zphi0 - zim05 * ze1deg * zsin_alpha + zjm05 * ze1deg * zcos_alpha
123            !   
124            !glamu(i,j) longitude at U-point
125            !gphiu(i,j) latitude at U-point
126            plamu(ji,jj) = zlam0 + zim1  * ze1deg * zcos_alpha + zjm05 * ze1deg * zsin_alpha
127            pphiu(ji,jj) = zphi0 - zim1  * ze1deg * zsin_alpha + zjm05 * ze1deg * zcos_alpha
128            !   
129            !glamv(i,j) longitude at V-point
130            !gphiv(i,j) latitude at V-point
131            plamv(ji,jj) = zlam0 + zim05 * ze1deg * zcos_alpha + zjm1  * ze1deg * zsin_alpha
132            pphiv(ji,jj) = zphi0 - zim05 * ze1deg * zsin_alpha + zjm1  * ze1deg * zcos_alpha
133            !
134            !glamf(i,j) longitude at F-point
135            !gphif(i,j) latitude at F-point
136            plamf(ji,jj) = zlam0 + zim1  * ze1deg * zcos_alpha + zjm1  * ze1deg * zsin_alpha
137            pphif(ji,jj) = zphi0 - zim1  * ze1deg * zsin_alpha + zjm1  * ze1deg * zcos_alpha
138         END DO
139      END DO
140      !
141      !                       !== Horizontal scale factors ==! (in meters)
142      !                     
143      !                                         ! constant grid spacing
144      pe1t(:,:) =  ze1     ;      pe2t(:,:) = ze1
145      pe1u(:,:) =  ze1     ;      pe2u(:,:) = ze1
146      pe1v(:,:) =  ze1     ;      pe2v(:,:) = ze1
147      pe1f(:,:) =  ze1     ;      pe2f(:,:) = ze1
148      !
149      !                                         ! NO reduction of grid size in some straits
150      ke1e2u_v = 0                              !    ==>> u_ & v_surfaces will be computed in dom_ghr routine
151      pe1e2u(:,:) = 0._wp                       !    CAUTION: set to zero to avoid error with some compilers that
152      pe1e2v(:,:) = 0._wp                       !             require an initialization of INTENT(out) arguments
153      !
154      !
155      !                       !==  Coriolis parameter  ==!
156      kff = 1                                            !  indicate not to compute ff afterward
157      !
158      zbeta = 2. * omega * COS( rad * zphi1 ) / ra       ! beta at latitude zphi1
159      !SF we overwrite zphi0 (south point in latitude) used just above to define pphif (value of zphi0=15.5190567531966)
160      !SF for computation of Coriolis we keep the parameter of Hazeleger, W., and S. S. Drijfhout, JPO 1998.
161      zphi0 = 15._wp                                     !  latitude of the most southern grid point 
162      zf0   = 2. * omega * SIN( rad * zphi0 )            !  compute f0 1st point south
163      !
164      pff_f(:,:) = ( zf0 + zbeta * ABS( pphif(:,:) - zphi0 ) * rad * ra ) ! f = f0 +beta* y ( y=0 at south)
165      pff_t(:,:) = ( zf0 + zbeta * ABS( pphit(:,:) - zphi0 ) * rad * ra ) ! f = f0 +beta* y ( y=0 at south)
166      !
167      IF(lwp) WRITE(numout,*) '                           beta-plane used. beta = ', zbeta, ' 1/(s.m)'
168      !
169   END SUBROUTINE usr_def_hgr
170
171   !!======================================================================
172END MODULE usrdef_hgr
Note: See TracBrowser for help on using the repository browser.