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/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/NEMO/OPA_SRC/USR – NEMO

source: branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/NEMO/OPA_SRC/USR/usrdef_hgr.F90 @ 6717

Last change on this file since 6717 was 6717, checked in by gm, 8 years ago

#1692 - branch SIMPLIF_2_usrdef: numerous improvement in the user defined interface

File size: 8.8 KB
Line 
1MODULE usrdef_hgr
2   !!==============================================================================
3   !!                       ***  MODULE usrdef_hgr   ***
4   !! User defined module: used like example to define domain, init, sbc, ...
5   !!==============================================================================
6   !! History :  NEMO ! 2016-03  (S. Flavoni)
7   !!----------------------------------------------------------------------
8
9   !!----------------------------------------------------------------------
10   !!   usr_def_hgr   : initialize the horizontal mesh
11   !!----------------------------------------------------------------------
12   USE dom_oce  , ONLY: nimpp, njmpp       ! ocean space and time domain
13   USE par_oce        ! ocean space and time domain
14   USE phycst         ! physical constants
15   USE usrdef_nam     !
16   !
17   USE in_out_manager ! I/O manager
18   USE lib_mpp        ! MPP library
19   USE timing         ! Timing
20   
21   IMPLICIT NONE
22   PRIVATE
23
24   PUBLIC   usr_def_hgr   ! called in domhgr.F90  module
25
26   !!----------------------------------------------------------------------
27   !! NEMO/OPA 4.0 , NEMO Consortium (2016)
28   !! $Id: $
29   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
30   !!----------------------------------------------------------------------
31CONTAINS
32
33   SUBROUTINE usr_def_hgr( plamt , plamu , plamv  , plamf  ,   &   ! geographic position (required)
34      &                    pphit , pphiu , pphiv  , pphif  ,   &   !
35      &                    kff   , pff_f , pff_t  ,            &   ! Coriolis parameter  (if domain not on the sphere)
36      &                    pe1t  , pe1u  , pe1v   , pe1f   ,   &   ! scale factors       (required)
37      &                    pe2t  , pe2u  , pe2v   , pe2f   ,   &   !
38      &                    ke1e2u_v      , pe1e2u , pe1e2v     )   ! u- & v-surfaces (if gridsize reduction is used in strait(s))
39      !!----------------------------------------------------------------------
40      !!                  ***  ROUTINE usr_def_hgr  ***
41      !!
42      !! ** Purpose :   user defined mesh and Coriolis parameter
43      !!
44      !! ** Method  :   set all intent(out) argument to a proper value
45      !!
46      !!                Here GYRE configuration :
47      !!          Rectangular mid-latitude domain
48      !!          - with axes rotated by 45 degrees
49      !!          - a constant horizontal resolution of 106 km
50      !!          - on a beta-plane
51      !!
52      !! ** Action  : - define longitude & latitude of t-, u-, v- and f-points (in degrees)
53      !!              - define coriolis parameter at f-point if the domain in not on the sphere (on beta-plane)
54      !!              - define i- & j-scale factors at t-, u-, v- and f-points (in meters)
55      !!              - define u- & v-surfaces (if gridsize reduction is used in some straits) (in m2)
56      !!----------------------------------------------------------------------
57      REAL(wp), DIMENSION(:,:), INTENT(out) ::   plamt, plamu, plamv, plamf   ! longitude outputs                     [degrees]
58      REAL(wp), DIMENSION(:,:), INTENT(out) ::   pphit, pphiu, pphiv, pphif   ! latitude outputs                      [degrees]
59      INTEGER                 , INTENT(out) ::   kff                          ! =1 Coriolis parameter computed here, =0 otherwise
60      REAL(wp), DIMENSION(:,:), INTENT(out) ::   pff_f, pff_t                 ! Coriolis factor at f-point                [1/s]
61      REAL(wp), DIMENSION(:,:), INTENT(out) ::   pe1t, pe1u, pe1v, pe1f       ! i-scale factors                             [m]
62      REAL(wp), DIMENSION(:,:), INTENT(out) ::   pe2t, pe2u, pe2v, pe2f       ! j-scale factors                             [m]
63      INTEGER                 , INTENT(out) ::   ke1e2u_v                     ! =1 u- & v-surfaces computed here, =0 otherwise
64      REAL(wp), DIMENSION(:,:), INTENT(out) ::   pe1e2u, pe1e2v               ! u- & v-surfaces (if reduction in strait)   [m2]
65      !
66      INTEGER  ::   ji, jj               ! dummy loop indices
67      REAL(wp) ::   zlam1, zlam0, zcos_alpha, zim1 , zjm1 , ze1  , ze1deg, zf0 ! local scalars
68      REAL(wp) ::   zphi1, zphi0, zsin_alpha, zim05, zjm05, zbeta, znorme      !   -      -
69      !!-------------------------------------------------------------------------------
70      !
71      IF( nn_timing == 1 )  CALL timing_start('usr_def_hgr')
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( ln_bench ) THEN     ! benchmark: forced the resolution to be 106 km
94         ze1 = 106000._wp     ! but keep (lat,lon) at the right nn_GYRE resolution
95         CALL ctl_warn( ' GYRE used as Benchmark: e1=e2=106km, no need to adjust rdt, ahm,aht ' )
96      ENDIF
97      IF( nprint==1 .AND. lwp )   THEN
98         WRITE(numout,*) 'ze1', ze1, 'cosalpha', zcos_alpha, 'sinalpha', zsin_alpha
99         WRITE(numout,*) 'ze1deg', ze1deg, 'zlam0', zlam0, 'zphi0', zphi0
100      ENDIF
101      !   
102      DO jj = 1, jpj 
103         DO ji = 1, jpi 
104            zim1 = REAL( ji + nimpp - 1 ) - 1.   ;   zim05 = REAL( ji + nimpp - 1 ) - 1.5 
105            zjm1 = REAL( jj + njmpp - 1 ) - 1.   ;   zjm05 = REAL( jj + njmpp - 1 ) - 1.5 
106            !   
107            !glamt(i,j) longitude at T-point
108            !gphit(i,j) latitude at T-point 
109            plamt(ji,jj) = zlam0 + zim05 * ze1deg * zcos_alpha + zjm05 * ze1deg * zsin_alpha
110            pphit(ji,jj) = zphi0 - zim05 * ze1deg * zsin_alpha + zjm05 * ze1deg * zcos_alpha
111            !   
112            !glamu(i,j) longitude at U-point
113            !gphiu(i,j) latitude at U-point
114            plamu(ji,jj) = zlam0 + zim1  * ze1deg * zcos_alpha + zjm05 * ze1deg * zsin_alpha
115            pphiu(ji,jj) = zphi0 - zim1  * ze1deg * zsin_alpha + zjm05 * ze1deg * zcos_alpha
116            !   
117            !glamv(i,j) longitude at V-point
118            !gphiv(i,j) latitude at V-point
119            plamv(ji,jj) = zlam0 + zim05 * ze1deg * zcos_alpha + zjm1  * ze1deg * zsin_alpha
120            pphiv(ji,jj) = zphi0 - zim05 * ze1deg * zsin_alpha + zjm1  * ze1deg * zcos_alpha
121            !
122            !glamf(i,j) longitude at F-point
123            !gphif(i,j) latitude at F-point
124            plamf(ji,jj) = zlam0 + zim1  * ze1deg * zcos_alpha + zjm1  * ze1deg * zsin_alpha
125            pphif(ji,jj) = zphi0 - zim1  * ze1deg * zsin_alpha + zjm1  * ze1deg * zcos_alpha
126         END DO
127      END DO
128      !
129      !                       !== Horizontal scale factors ==! (in meters)
130      !                     
131      !                                         ! constant grid spacing
132      pe1t(:,:) =  ze1     ;      pe2t(:,:) = ze1
133      pe1u(:,:) =  ze1     ;      pe2u(:,:) = ze1
134      pe1v(:,:) =  ze1     ;      pe2v(:,:) = ze1
135      pe1f(:,:) =  ze1     ;      pe2f(:,:) = ze1
136      !
137      !                                         ! NO reduction of grid size in some straits
138      ke1e2u_v = 0                              !    ==>> u_ & v_surfaces will be computed in dom_ghr routine
139      !
140      !
141      !                       !==  Coriolis parameter  ==!
142      kff = 1                                            !  indicate not to compute ff afterward
143      !
144      zbeta = 2. * omega * COS( rad * zphi1 ) / ra       ! beta at latitude zphi1
145      !SF we overwrite zphi0 (south point in latitude) used just above to define pphif (value of zphi0=15.5190567531966)
146      !SF for computation of Coriolis we keep the parameter of Hazeleger, W., and S. S. Drijfhout, JPO 1998.
147      zphi0 = 15._wp                                     !  latitude of the most southern grid point 
148      zf0   = 2. * omega * SIN( rad * zphi0 )            !  compute f0 1st point south
149      !
150      pff_f(:,:) = ( zf0 + zbeta * ABS( pphif(:,:) - zphi0 ) * rad * ra ) ! f = f0 +beta* y ( y=0 at south)
151      pff_t(:,:) = ( zf0 + zbeta * ABS( pphit(:,:) - zphi0 ) * rad * ra ) ! f = f0 +beta* y ( y=0 at south)
152      !
153      IF(lwp) WRITE(numout,*) '                           beta-plane used. beta = ', zbeta, ' 1/(s.m)'
154      !
155      IF( nn_timing == 1 )  CALL timing_stop('usr_def_hgr')
156      !
157   END SUBROUTINE usr_def_hgr
158
159   !!======================================================================
160END MODULE usrdef_hgr
Note: See TracBrowser for help on using the repository browser.