1 | MODULE usrdef_hgr |
---|
2 | !!====================================================================== |
---|
3 | !! *** MODULE usrdef_hgr *** |
---|
4 | !! |
---|
5 | !! === SWG configuration === |
---|
6 | !! |
---|
7 | !! User defined : mesh and Coriolis parameter of a user configuration |
---|
8 | !!====================================================================== |
---|
9 | !! History : 4.0 ! 2016-03 (S. Flavoni) |
---|
10 | !! - ! 2020-03 (A. Nasser) Shallow Water Eq. configuration |
---|
11 | !!---------------------------------------------------------------------- |
---|
12 | |
---|
13 | !!---------------------------------------------------------------------- |
---|
14 | !! usr_def_hgr : initialize the horizontal mesh |
---|
15 | !!---------------------------------------------------------------------- |
---|
16 | USE dom_oce , ONLY: nimpp, njmpp ! ocean space and time domain |
---|
17 | USE par_oce ! ocean space and time domain |
---|
18 | USE phycst ! physical constants |
---|
19 | USE usrdef_nam ! |
---|
20 | ! |
---|
21 | USE in_out_manager ! I/O manager |
---|
22 | USE lib_mpp ! MPP library |
---|
23 | |
---|
24 | IMPLICIT NONE |
---|
25 | PRIVATE |
---|
26 | |
---|
27 | PUBLIC usr_def_hgr ! called in domhgr.F90 |
---|
28 | |
---|
29 | !!---------------------------------------------------------------------- |
---|
30 | !! NEMO/OCE 4.0 , NEMO Consortium (2018) |
---|
31 | !! $Id: usrdef_hgr.F90 10069 2018-08-28 14:12:24Z nicolasmartin $ |
---|
32 | !! Software governed by the CeCILL license (see ./LICENSE) |
---|
33 | !!---------------------------------------------------------------------- |
---|
34 | CONTAINS |
---|
35 | |
---|
36 | SUBROUTINE usr_def_hgr( plamt , plamu , plamv , plamf , & ! geographic position (required) |
---|
37 | & pphit , pphiu , pphiv , pphif , & ! |
---|
38 | & kff , pff_f , pff_t , & ! Coriolis parameter (if domain not on the sphere) |
---|
39 | & pe1t , pe1u , pe1v , pe1f , & ! scale factors (required) |
---|
40 | & pe2t , pe2u , pe2v , pe2f , & ! |
---|
41 | & ke1e2u_v , pe1e2u , pe1e2v ) ! u- & v-surfaces (if gridsize reduction is used in strait(s)) |
---|
42 | !!---------------------------------------------------------------------- |
---|
43 | !! *** ROUTINE usr_def_hgr *** |
---|
44 | !! |
---|
45 | !! ** Purpose : user defined mesh and Coriolis parameter |
---|
46 | !! |
---|
47 | !! ** Method : set all intent(out) argument to a proper value |
---|
48 | !! |
---|
49 | !! Here SWG configuration : |
---|
50 | !! Rectangular mid-latitude domain |
---|
51 | !! - with axes rotated by 45 degrees |
---|
52 | !! - a constant horizontal resolution of 106 km |
---|
53 | !! - on a beta-plane |
---|
54 | !! |
---|
55 | !! ** Action : - define longitude & latitude of t-, u-, v- and f-points (in degrees) |
---|
56 | !! - define coriolis parameter at f-point if the domain in not on the sphere (on beta-plane) |
---|
57 | !! - define i- & j-scale factors at t-, u-, v- and f-points (in meters) |
---|
58 | !! - define u- & v-surfaces (if gridsize reduction is used in some straits) (in m2) |
---|
59 | !!---------------------------------------------------------------------- |
---|
60 | REAL(wp), DIMENSION(:,:), INTENT(out) :: plamt, plamu, plamv, plamf ! longitude outputs [degrees] |
---|
61 | REAL(wp), DIMENSION(:,:), INTENT(out) :: pphit, pphiu, pphiv, pphif ! latitude outputs [degrees] |
---|
62 | INTEGER , INTENT(out) :: kff ! =1 Coriolis parameter computed here, =0 otherwise |
---|
63 | REAL(wp), DIMENSION(:,:), INTENT(out) :: pff_f, pff_t ! Coriolis factor at f-point [1/s] |
---|
64 | REAL(wp), DIMENSION(:,:), INTENT(out) :: pe1t, pe1u, pe1v, pe1f ! i-scale factors [m] |
---|
65 | REAL(wp), DIMENSION(:,:), INTENT(out) :: pe2t, pe2u, pe2v, pe2f ! j-scale factors [m] |
---|
66 | INTEGER , INTENT(out) :: ke1e2u_v ! =1 u- & v-surfaces computed here, =0 otherwise |
---|
67 | REAL(wp), DIMENSION(:,:), INTENT(out) :: pe1e2u, pe1e2v ! u- & v-surfaces (if reduction in strait) [m2] |
---|
68 | ! |
---|
69 | INTEGER :: ji, jj ! dummy loop indices |
---|
70 | REAL(wp) :: zlam1, zlam0, zcos_theta, zim1 , zjm1 , ze1 , ze1deg ! local scalars |
---|
71 | REAL(wp) :: zphi1, zphi0, zsin_theta, zim05, zjm05, znorme ! - - |
---|
72 | REAL(wp) :: zgl, zbl ! - - |
---|
73 | |
---|
74 | !!------------------------------------------------------------------------------- |
---|
75 | ! |
---|
76 | ! !== beta-plane with regular grid-spacing and rotated domain ==! (SWG configuration) |
---|
77 | ! |
---|
78 | IF(lwp) WRITE(numout,*) |
---|
79 | IF(lwp) WRITE(numout,*) 'usr_def_hgr : SWG configuration (beta-plane with rotated regular grid-spacing)' |
---|
80 | IF(lwp) WRITE(numout,*) '~~~~~~~~~~~' |
---|
81 | ! |
---|
82 | ! |
---|
83 | ! !== grid point position ==! |
---|
84 | ! |
---|
85 | ze1 = rn_dx / REAL(nn_SWG, wp) ! [m] gridspacing used |
---|
86 | zgl = rn_domsiz + 2._wp * REAL(nn_gc, wp) * ze1 ! [m] length of the square with ghostcells |
---|
87 | ! fit the best square around the square + ghost cells |
---|
88 | zbl = zgl * ( COS( rn_theta * rad ) + SIN( rn_theta * rad ) ) ! length side bigger domain [m] |
---|
89 | |
---|
90 | ! unrotated (0deg) |
---|
91 | !zcos_theta = 1._wp |
---|
92 | !zsin_theta = 0._wp |
---|
93 | ! rotated case (45deg) |
---|
94 | !zcos_theta = 1._wp / SQRT( 2._wp ) |
---|
95 | !zsin_theta = 1._wp / SQRT( 2._wp ) |
---|
96 | ! rotation angle |
---|
97 | zcos_theta = COS( rn_theta * rad) |
---|
98 | zsin_theta = SIN( rn_theta * rad) |
---|
99 | |
---|
100 | ! exact origin in meters |
---|
101 | zlam1 = zbl * COS((rn_theta + 45 )* rad ) / SQRT( 2._wp ) - rn_domsiz/2._wp |
---|
102 | zphi1 = zbl * SIN((rn_theta + 45 )* rad ) / SQRT( 2._wp ) - rn_domsiz/2._wp |
---|
103 | ! origin put in the true corner of a cell so there will be no cropping |
---|
104 | ! of the edge cells |
---|
105 | zlam0 = REAL( anint( zlam1 / ze1 ), wp ) * ze1 |
---|
106 | zphi0 = REAl( anint( zphi1 / ze1 ), wp ) * ze1 |
---|
107 | |
---|
108 | IF(lwp) WRITE(numout,*) ' origin position zlam0 = ', zlam0/1000, ' km' |
---|
109 | IF(lwp) WRITE(numout,*) ' origin position zphi0 = ', zphi0/1000, ' km' |
---|
110 | |
---|
111 | ! O1M = OM x rotation_theta + OO1 |
---|
112 | ! zim1, zim05, zjm1, zjm05 fit for 2 ghost cells on each side |
---|
113 | DO jj = 1, jpj |
---|
114 | DO ji = 1, jpi |
---|
115 | zim1 = REAL( ji + nimpp - nn_hls ) ; zim05 = REAL( ji + nimpp - nn_hls ) - 0.5 |
---|
116 | zjm1 = REAL( jj + njmpp - nn_hls ) ; zjm05 = REAL( jj + njmpp - nn_hls ) - 0.5 |
---|
117 | ! |
---|
118 | !glamt(i,j) position (meters) at T-point |
---|
119 | !gphit(i,j) position (meters) at T-point |
---|
120 | plamt(ji,jj) = zim05 * ze1 * zcos_theta - zjm05 * ze1 * zsin_theta - zlam0 |
---|
121 | pphit(ji,jj) = + zim05 * ze1 * zsin_theta + zjm05 * ze1 * zcos_theta - zphi0 |
---|
122 | ! |
---|
123 | !glamu(i,j) position (meters) at U-point |
---|
124 | !gphiu(i,j) position (meters) at U-point |
---|
125 | plamu(ji,jj) = zim1 * ze1 * zcos_theta - zjm05 * ze1 * zsin_theta - zlam0 |
---|
126 | pphiu(ji,jj) = + zim1 * ze1 * zsin_theta + zjm05 * ze1 * zcos_theta - zphi0 |
---|
127 | ! |
---|
128 | !glamv(i,j) position (meters) at V-point |
---|
129 | !gphiv(i,j) position (meters) at V-point |
---|
130 | plamv(ji,jj) = zim05 * ze1 * zcos_theta - zjm1 * ze1 * zsin_theta - zlam0 |
---|
131 | pphiv(ji,jj) = + zim05 * ze1 * zsin_theta + zjm1 * ze1 * zcos_theta - zphi0 |
---|
132 | ! |
---|
133 | !glamf(i,j) position (meters) at F-point |
---|
134 | !gphif(i,j) position (meters) at F-point |
---|
135 | plamf(ji,jj) = zim1 * ze1 * zcos_theta - zjm1 * ze1 * zsin_theta - zlam0 |
---|
136 | pphif(ji,jj) = + zim1 * ze1 * zsin_theta + zjm1 * ze1 * zcos_theta - zphi0 |
---|
137 | END DO |
---|
138 | END DO |
---|
139 | ! |
---|
140 | ! !== Horizontal scale factors ==! (in meters) |
---|
141 | ! |
---|
142 | ! ! constant grid spacing |
---|
143 | pe1t(:,:) = ze1 ; pe2t(:,:) = ze1 |
---|
144 | pe1u(:,:) = ze1 ; pe2u(:,:) = ze1 |
---|
145 | pe1v(:,:) = ze1 ; pe2v(:,:) = ze1 |
---|
146 | pe1f(:,:) = ze1 ; pe2f(:,:) = ze1 |
---|
147 | ! |
---|
148 | ! ! NO reduction of grid size in some straits |
---|
149 | ke1e2u_v = 0 ! ==>> u_ & v_surfaces will be computed in dom_ghr routine |
---|
150 | pe1e2u(:,:) = 0._wp ! CAUTION: set to zero to avoid error with some compilers that |
---|
151 | pe1e2v(:,:) = 0._wp ! require an initialization of INTENT(out) arguments |
---|
152 | ! |
---|
153 | ! |
---|
154 | ! !== Coriolis parameter ==! |
---|
155 | kff = 1 ! indicate not to compute ff afterward |
---|
156 | ! |
---|
157 | pff_f(:,:) = REAL( rn_f0, wp ) + REAL( rn_beta, wp ) * ABS( pphif(:,:) ) ! f = f0 +beta* y |
---|
158 | pff_t(:,:) = REAL( rn_f0, wp ) + REAL( rn_beta, wp ) * ABS( pphit(:,:) ) ! f = f0 +beta* y |
---|
159 | ! |
---|
160 | IF(lwp) WRITE(numout,*) ' beta-plane used. f0 = ', rn_f0 , ' 1/s' |
---|
161 | IF(lwp) WRITE(numout,*) ' beta-plane used. beta = ', rn_beta, ' 1/(s.m)' |
---|
162 | ! |
---|
163 | END SUBROUTINE usr_def_hgr |
---|
164 | |
---|
165 | !!====================================================================== |
---|
166 | END MODULE usrdef_hgr |
---|