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/2020/dev_r12527_Gurvan_ShallowWater/cfgs/AM98/MY_SRC – NEMO

source: NEMO/branches/2020/dev_r12527_Gurvan_ShallowWater/cfgs/AM98/MY_SRC/usrdef_hgr.F90 @ 12614

Last change on this file since 12614 was 12614, checked in by gm, 4 years ago

first Shallow Water Eq. update

File size: 9.6 KB
Line 
1MODULE usrdef_hgr
2   !!======================================================================
3   !!                     ***  MODULE usrdef_hgr   ***
4   !!
5   !!                     ===  AM98 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: usrdef_hgr.F90 10069 2018-08-28 14:12:24Z nicolasmartin $
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 AM98 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_theta, zim1 , zjm1 , ze1  , ze1deg ! local scalars
70      REAL(wp) ::   zphi1, zphi0, zsin_theta, zim05, zjm05, znorme      !   -      -
71      REAL(wp) ::   zl, zgl, zbl      !   -      -
72      !!-------------------------------------------------------------------------------
73      !
74      !     !==  beta-plane with regular grid-spacing and rotated domain ==!  (AM98 configuration)
75      !
76      IF(lwp) WRITE(numout,*)
77      IF(lwp) WRITE(numout,*) 'usr_def_hgr : AM98 configuration (beta-plane with rotated regular grid-spacing)'
78      IF(lwp) WRITE(numout,*) '~~~~~~~~~~~'
79      !
80      !
81      !                       !==  grid point position  ==!
82      !
83      ze1 =  100000._wp / REAL(nn_AM98, wp)       ! (100km) gridspacing              [m]
84       zl = 2000000._wp                           ! lentgh side square domain        [m] 
85      zgl = 2000000._wp + 4._wp*ze1               ! length side square + ghost cells [m]
86                                                  !    2000km x 2000km + 2 cells around sides
87      !
88      ! biggest L = 3500 km (worst case)
89      !zbl = 3500000._wp                           ! length side bigger domain [m]
90      ! non rotated (0deg) - worst case (centered in the 3500kmx3500km)
91      !zlam0 = 875000._wp    ! m
92      !zphi0 = 875000._wp    ! m
93      ! rotated case (45eg)
94      ! origin (in meters)  of the 2000km x 2000km domain
95      !zlam0 = - 1000000._wp            ! - 1000km
96      !zphi0 =   1474873.7341529163_wp  ! 3500*sin(45deg) - 1000km
97
98
99      ! fit the best square around the square + ghost cells
100      zbl = zgl * ( COS( rn_theta * rad ) + SIN( rn_theta * rad ) )   ! length side bigger domain [m]                                 
101
102      ! unrotated (0deg)
103      !zcos_theta = 1._wp
104      !zsin_theta = 0._wp
105      ! rotated case (45deg)
106      !zcos_theta =   1._wp / SQRT( 2._wp )
107      !zsin_theta =   1._wp / SQRT( 2._wp ) 
108      ! rotation angle
109      zcos_theta = COS( rn_theta * rad)
110      zsin_theta = SIN( rn_theta * rad)   
111
112      ! exact origin in meters
113      zlam1 =  zbl * COS((rn_theta + 45 )* rad ) / SQRT( 2._wp )  - zl/2._wp 
114      zphi1 =  zbl * SIN((rn_theta + 45 )* rad ) / SQRT( 2._wp )  - zl/2._wp 
115      ! origin put in the true corner of a cell so there will be no cropping
116      ! of the edge cells
117      zlam0 = REAL( anint( zlam1 / ze1 ) + 1, wp ) * ze1
118      zphi0 = REAl( anint( zphi1 / ze1 ) + 1, wp ) * ze1
119
120      IF(lwp) WRITE(numout,*) '                  origin position    zlam0   = ', zlam0/1000,   ' km'
121      IF(lwp) WRITE(numout,*) '                  origin position    zphi0   = ', zphi0/1000,   ' km'
122
123      ! O1M = OM x rotation_theta + OO1
124      ! zim1, zim05, zjm1, zjm05 fit for 2 ghost cells on each side
125      DO jj = 1, jpj 
126         DO ji = 1, jpi 
127            zim1 = REAL( ji + nimpp - 1 )   ;   zim05 = REAL( ji + nimpp - 1 ) - 0.5 
128            zjm1 = REAL( jj + njmpp - 1 )   ;   zjm05 = REAL( jj + njmpp - 1 ) - 0.5 
129            !   
130            !glamt(i,j) position (meters) at T-point
131            !gphit(i,j) position (meters) at T-point 
132            plamt(ji,jj) =   zim05 * ze1 * zcos_theta - zjm05 * ze1 * zsin_theta - zlam0
133            pphit(ji,jj) = + zim05 * ze1 * zsin_theta + zjm05 * ze1 * zcos_theta - zphi0
134            !   
135            !glamu(i,j) position (meters) at U-point
136            !gphiu(i,j) position (meters) at U-point
137            plamu(ji,jj) =   zim1  * ze1 * zcos_theta - zjm05 * ze1 * zsin_theta - zlam0
138            pphiu(ji,jj) = + zim1  * ze1 * zsin_theta + zjm05 * ze1 * zcos_theta - zphi0
139            !   
140            !glamv(i,j) position (meters) at V-point
141            !gphiv(i,j) position (meters) at V-point
142            plamv(ji,jj) =   zim05 * ze1 * zcos_theta - zjm1  * ze1 * zsin_theta - zlam0
143            pphiv(ji,jj) = + zim05 * ze1 * zsin_theta + zjm1  * ze1 * zcos_theta - zphi0
144            !
145            !glamf(i,j) position (meters) at F-point
146            !gphif(i,j) position (meters) at F-point
147            plamf(ji,jj) =   zim1  * ze1 * zcos_theta - zjm1  * ze1 * zsin_theta - zlam0
148            pphif(ji,jj) = + zim1  * ze1 * zsin_theta + zjm1  * ze1 * zcos_theta - zphi0
149         END DO
150      END DO
151      !
152      !                       !== Horizontal scale factors ==! (in meters)
153      !                     
154      !                                         ! constant grid spacing
155      pe1t(:,:) =  ze1     ;      pe2t(:,:) = ze1
156      pe1u(:,:) =  ze1     ;      pe2u(:,:) = ze1
157      pe1v(:,:) =  ze1     ;      pe2v(:,:) = ze1
158      pe1f(:,:) =  ze1     ;      pe2f(:,:) = ze1
159      !
160      !                                         ! NO reduction of grid size in some straits
161      ke1e2u_v = 0                              !    ==>> u_ & v_surfaces will be computed in dom_ghr routine
162      pe1e2u(:,:) = 0._wp                       !    CAUTION: set to zero to avoid error with some compilers that
163      pe1e2v(:,:) = 0._wp                       !             require an initialization of INTENT(out) arguments
164      !
165      !
166      !                       !==  Coriolis parameter  ==!
167      kff = 1                                            !  indicate not to compute ff afterward
168      !
169      pff_f(:,:) =  REAL( rn_f0, wp ) + REAL( rn_beta, wp ) * ABS( pphif(:,:) ) ! f = f0 +beta* y
170      pff_t(:,:) =  REAL( rn_f0, wp ) + REAL( rn_beta, wp ) * ABS( pphit(:,:) ) ! f = f0 +beta* y
171      !
172      IF(lwp) WRITE(numout,*) '                           beta-plane used. f0   = ', rn_f0 ,  ' 1/s'
173      IF(lwp) WRITE(numout,*) '                           beta-plane used. beta = ', rn_beta, ' 1/(s.m)'
174      !
175   END SUBROUTINE usr_def_hgr
176
177   !!======================================================================
178END MODULE usrdef_hgr
Note: See TracBrowser for help on using the repository browser.