1 | MODULE usrdef_zgr |
---|
2 | !!====================================================================== |
---|
3 | !! *** MODULE usrdef_zgr *** |
---|
4 | !! |
---|
5 | !! === OVERFLOW case === |
---|
6 | !! |
---|
7 | !! user defined : vertical coordinate system of a user configuration |
---|
8 | !!====================================================================== |
---|
9 | !! History : 4.0 ! 2016-08 (G. Madec, S. Flavoni) Original code |
---|
10 | !!---------------------------------------------------------------------- |
---|
11 | |
---|
12 | !!---------------------------------------------------------------------- |
---|
13 | !! usr_def_zgr : user defined vertical coordinate system (required) |
---|
14 | !! zgr_z1d : reference 1D z-coordinate |
---|
15 | !!--------------------------------------------------------------------- |
---|
16 | USE oce ! ocean variables |
---|
17 | USE dom_oce , ONLY: mi0, mi1, nimpp, njmpp ! ocean space and time domain |
---|
18 | USE dom_oce , ONLY: glamt ! ocean space and time domain |
---|
19 | USE usrdef_nam ! User defined : namelist variables |
---|
20 | ! |
---|
21 | USE in_out_manager ! I/O manager |
---|
22 | USE lbclnk ! ocean lateral boundary conditions (or mpp link) |
---|
23 | USE lib_mpp ! distributed memory computing library |
---|
24 | USE timing ! Timing |
---|
25 | |
---|
26 | IMPLICIT NONE |
---|
27 | PRIVATE |
---|
28 | |
---|
29 | PUBLIC usr_def_zgr ! called by domzgr.F90 |
---|
30 | |
---|
31 | !! * Substitutions |
---|
32 | # include "vectopt_loop_substitute.h90" |
---|
33 | !!---------------------------------------------------------------------- |
---|
34 | !! NEMO/OCE 4.0 , NEMO Consortium (2018) |
---|
35 | !! $Id$ |
---|
36 | !! Software governed by the CeCILL license (see ./LICENSE) |
---|
37 | !!---------------------------------------------------------------------- |
---|
38 | CONTAINS |
---|
39 | |
---|
40 | SUBROUTINE usr_def_zgr( ld_zco , ld_zps , ld_sco , ld_isfcav, & ! type of vertical coordinate |
---|
41 | & pdept_1d, pdepw_1d, pe3t_1d , pe3w_1d , & ! 1D reference vertical coordinate |
---|
42 | & pdept , pdepw , & ! 3D t & w-points depth |
---|
43 | & pe3t , pe3u , pe3v , pe3f , & ! vertical scale factors |
---|
44 | & pe3w , pe3uw , pe3vw, & ! - - - |
---|
45 | & k_top , k_bot ) ! top & bottom ocean level |
---|
46 | !!--------------------------------------------------------------------- |
---|
47 | !! *** ROUTINE usr_def_zgr *** |
---|
48 | !! |
---|
49 | !! ** Purpose : User defined the vertical coordinates |
---|
50 | !! |
---|
51 | !!---------------------------------------------------------------------- |
---|
52 | LOGICAL , INTENT(in ) :: ld_zco, ld_zps, ld_sco ! vertical coordinate flags ( read in namusr_def ) |
---|
53 | LOGICAL , INTENT( out) :: ld_isfcav ! under iceshelf cavity flag |
---|
54 | REAL(wp), DIMENSION(:) , INTENT( out) :: pdept_1d, pdepw_1d ! 1D grid-point depth [m] |
---|
55 | REAL(wp), DIMENSION(:) , INTENT( out) :: pe3t_1d , pe3w_1d ! 1D grid-point depth [m] |
---|
56 | REAL(wp), DIMENSION(:,:,:), INTENT( out) :: pdept, pdepw ! grid-point depth [m] |
---|
57 | REAL(wp), DIMENSION(:,:,:), INTENT( out) :: pe3t , pe3u , pe3v , pe3f ! vertical scale factors [m] |
---|
58 | REAL(wp), DIMENSION(:,:,:), INTENT( out) :: pe3w , pe3uw, pe3vw ! i-scale factors |
---|
59 | INTEGER , DIMENSION(:,:) , INTENT( out) :: k_top, k_bot ! first & last ocean level |
---|
60 | ! |
---|
61 | INTEGER :: ji, jj, jk ! dummy indices |
---|
62 | INTEGER :: ik ! local integers |
---|
63 | REAL(wp) :: zfact, z1_jpkm1 ! local scalar |
---|
64 | REAL(wp) :: ze3min ! local scalar |
---|
65 | REAL(wp), DIMENSION(jpi,jpj) :: zht, zhu, z2d ! 2D workspace |
---|
66 | !!---------------------------------------------------------------------- |
---|
67 | ! |
---|
68 | IF(lwp) WRITE(numout,*) |
---|
69 | IF(lwp) WRITE(numout,*) 'usr_def_zgr : OVERFLOW configuration (z(ps)- or s-coordinate closed box ocean without cavities)' |
---|
70 | IF(lwp) WRITE(numout,*) '~~~~~~~~~~~' |
---|
71 | ! |
---|
72 | ! |
---|
73 | ! type of vertical coordinate |
---|
74 | ! --------------------------- |
---|
75 | ! already set in usrdef_nam.F90 by reading the namusr_def namelist except for ISF |
---|
76 | ld_isfcav = .FALSE. |
---|
77 | ! |
---|
78 | ! |
---|
79 | ! Build the vertical coordinate system |
---|
80 | ! ------------------------------------ |
---|
81 | ! |
---|
82 | ! !== UNmasked meter bathymetry ==! |
---|
83 | ! |
---|
84 | ! western continental shelf (500m deep) and eastern deep ocean (2000m deep) |
---|
85 | ! (set through the jpk and jpi (see userdef_nam.F90)) |
---|
86 | ! with a hyperbolic tangent transition centered at 40km |
---|
87 | ! NB: here glamt is in kilometers |
---|
88 | ! |
---|
89 | zht(:,:) = + ( 500. + 0.5 * 1500. * ( 1.0 + tanh( (glamt(:,:) - 40.) / 7. ) ) ) |
---|
90 | ! |
---|
91 | ! at u-point: averaging zht |
---|
92 | DO ji = 1, jpim1 |
---|
93 | zhu(ji,:) = 0.5_wp * ( zht(ji,:) + zht(ji+1,:) ) |
---|
94 | END DO |
---|
95 | CALL lbc_lnk( 'usrdef_zgr', zhu, 'U', 1. ) ! boundary condition: this mask the surrouding grid-points |
---|
96 | ! ! ==>>> set by hand non-zero value on first/last columns & rows |
---|
97 | DO ji = mi0(1), mi1(1) ! first row of global domain only |
---|
98 | zhu(ji,2) = zht(ji,2) |
---|
99 | END DO |
---|
100 | DO ji = mi0(jpiglo), mi1(jpiglo) ! last row of global domain only |
---|
101 | zhu(ji,2) = zht(ji,2) |
---|
102 | END DO |
---|
103 | zhu(:,1) = zhu(:,2) |
---|
104 | zhu(:,3) = zhu(:,2) |
---|
105 | ! |
---|
106 | CALL zgr_z1d( pdept_1d, pdepw_1d, pe3t_1d , pe3w_1d ) ! Reference z-coordinate system |
---|
107 | ! |
---|
108 | ! |
---|
109 | ! !== top masked level bathymetry ==! (all coordinates) |
---|
110 | ! |
---|
111 | ! no ocean cavities : top ocean level is ONE, except over land |
---|
112 | ! the ocean basin surrounded by land (1 grid-point) set through lbc_lnk call as jperio=0 |
---|
113 | z2d(:,:) = 1._wp ! surface ocean is the 1st level |
---|
114 | CALL lbc_lnk( 'usrdef_zgr', z2d, 'T', 1. ) ! closed basin since jperio = 0 (see userdef_nam.F90) |
---|
115 | k_top(:,:) = NINT( z2d(:,:) ) |
---|
116 | ! |
---|
117 | ! |
---|
118 | ! |
---|
119 | IF ( ld_sco ) THEN !== s-coordinate ==! (terrain-following coordinate) |
---|
120 | ! |
---|
121 | k_bot(:,:) = jpkm1 * k_top(:,:) !* bottom ocean = jpk-1 (here use k_top as a land mask) |
---|
122 | ! |
---|
123 | ! !* terrain-following coordinate with e3.(k)=cst) |
---|
124 | ! ! OVERFLOW case : identical with j-index (T=V, U=F) |
---|
125 | z1_jpkm1 = 1._wp / REAL( jpkm1 , wp) |
---|
126 | DO jk = 1, jpk |
---|
127 | pdept(:,:,jk) = zht(:,:) * z1_jpkm1 * ( REAL( jk , wp ) - 0.5_wp ) |
---|
128 | pdepw(:,:,jk) = zht(:,:) * z1_jpkm1 * ( REAL( jk-1 , wp ) ) |
---|
129 | pe3t (:,:,jk) = zht(:,:) * z1_jpkm1 |
---|
130 | pe3u (:,:,jk) = zhu(:,:) * z1_jpkm1 |
---|
131 | pe3v (:,:,jk) = zht(:,:) * z1_jpkm1 |
---|
132 | pe3f (:,:,jk) = zhu(:,:) * z1_jpkm1 |
---|
133 | pe3w (:,:,jk) = zht(:,:) * z1_jpkm1 |
---|
134 | pe3uw(:,:,jk) = zhu(:,:) * z1_jpkm1 |
---|
135 | pe3vw(:,:,jk) = zht(:,:) * z1_jpkm1 |
---|
136 | END DO |
---|
137 | ENDIF |
---|
138 | ! |
---|
139 | ! |
---|
140 | IF ( ld_zco ) THEN !== z-coordinate ==! (step-like topography) |
---|
141 | ! |
---|
142 | ! !* bottom ocean compute from the depth of grid-points |
---|
143 | k_bot(:,:) = jpkm1 * k_top(:,:) ! here use k_top as a land mask |
---|
144 | DO jk = 1, jpkm1 |
---|
145 | WHERE( pdept_1d(jk) < zht(:,:) .AND. zht(:,:) <= pdept_1d(jk+1) ) k_bot(:,:) = jk * k_top(:,:) |
---|
146 | END DO |
---|
147 | ! !* horizontally uniform coordinate (reference z-co everywhere) |
---|
148 | DO jk = 1, jpk |
---|
149 | pdept(:,:,jk) = pdept_1d(jk) |
---|
150 | pdepw(:,:,jk) = pdepw_1d(jk) |
---|
151 | pe3t (:,:,jk) = pe3t_1d (jk) |
---|
152 | pe3u (:,:,jk) = pe3t_1d (jk) |
---|
153 | pe3v (:,:,jk) = pe3t_1d (jk) |
---|
154 | pe3f (:,:,jk) = pe3t_1d (jk) |
---|
155 | pe3w (:,:,jk) = pe3w_1d (jk) |
---|
156 | pe3uw(:,:,jk) = pe3w_1d (jk) |
---|
157 | pe3vw(:,:,jk) = pe3w_1d (jk) |
---|
158 | END DO |
---|
159 | ENDIF |
---|
160 | ! |
---|
161 | ! |
---|
162 | IF ( ld_zps ) THEN !== zps-coordinate ==! (partial bottom-steps) |
---|
163 | ! |
---|
164 | ze3min = 0.1_wp * rn_dz |
---|
165 | IF(lwp) WRITE(numout,*) ' minimum thickness of the partial cells = 10 % of e3 = ', ze3min |
---|
166 | ! |
---|
167 | ! |
---|
168 | ! !* bottom ocean compute from the depth of grid-points |
---|
169 | k_bot(:,:) = jpkm1 |
---|
170 | DO jk = jpkm1, 1, -1 |
---|
171 | WHERE( zht(:,:) < pdepw_1d(jk) + ze3min ) k_bot(:,:) = jk-1 |
---|
172 | END DO |
---|
173 | ! |
---|
174 | ! !* vertical coordinate system |
---|
175 | DO jk = 1, jpk ! initialization to the reference z-coordinate |
---|
176 | pdept(:,:,jk) = pdept_1d(jk) |
---|
177 | pdepw(:,:,jk) = pdepw_1d(jk) |
---|
178 | pe3t (:,:,jk) = pe3t_1d (jk) |
---|
179 | pe3u (:,:,jk) = pe3t_1d (jk) |
---|
180 | pe3v (:,:,jk) = pe3t_1d (jk) |
---|
181 | pe3f (:,:,jk) = pe3t_1d (jk) |
---|
182 | pe3w (:,:,jk) = pe3w_1d (jk) |
---|
183 | pe3uw(:,:,jk) = pe3w_1d (jk) |
---|
184 | pe3vw(:,:,jk) = pe3w_1d (jk) |
---|
185 | END DO |
---|
186 | DO jj = 1, jpj ! bottom scale factors and depth at T- and W-points |
---|
187 | DO ji = 1, jpi |
---|
188 | ik = k_bot(ji,jj) |
---|
189 | pdepw(ji,jj,ik+1) = MIN( zht(ji,jj) , pdepw_1d(ik+1) ) |
---|
190 | pe3t (ji,jj,ik ) = pdepw(ji,jj,ik+1) - pdepw(ji,jj,ik) |
---|
191 | pe3t (ji,jj,ik+1) = pe3t (ji,jj,ik ) |
---|
192 | ! |
---|
193 | pdept(ji,jj,ik ) = pdepw(ji,jj,ik ) + pe3t (ji,jj,ik ) * 0.5_wp |
---|
194 | pdept(ji,jj,ik+1) = pdepw(ji,jj,ik+1) + pe3t (ji,jj,ik+1) * 0.5_wp |
---|
195 | pe3w (ji,jj,ik+1) = pdept(ji,jj,ik+1) - pdept(ji,jj,ik) ! = pe3t (ji,jj,ik ) |
---|
196 | END DO |
---|
197 | END DO |
---|
198 | ! ! bottom scale factors and depth at U-, V-, UW and VW-points |
---|
199 | ! ! usually Computed as the minimum of neighbooring scale factors |
---|
200 | pe3u (:,:,:) = pe3t(:,:,:) ! HERE OVERFLOW configuration : |
---|
201 | pe3v (:,:,:) = pe3t(:,:,:) ! e3 increases with i-index and identical with j-index |
---|
202 | pe3f (:,:,:) = pe3t(:,:,:) ! so e3 minimum of (i,i+1) points is (i) point |
---|
203 | pe3uw(:,:,:) = pe3w(:,:,:) ! in j-direction e3v=e3t and e3f=e3v |
---|
204 | pe3vw(:,:,:) = pe3w(:,:,:) ! ==>> no need of lbc_lnk calls |
---|
205 | ! |
---|
206 | ENDIF |
---|
207 | ! |
---|
208 | END SUBROUTINE usr_def_zgr |
---|
209 | |
---|
210 | |
---|
211 | SUBROUTINE zgr_z1d( pdept_1d, pdepw_1d, pe3t_1d , pe3w_1d ) ! 1D reference vertical coordinate |
---|
212 | !!---------------------------------------------------------------------- |
---|
213 | !! *** ROUTINE zgr_z1d *** |
---|
214 | !! |
---|
215 | !! ** Purpose : set the depth of model levels and the resulting |
---|
216 | !! vertical scale factors. |
---|
217 | !! |
---|
218 | !! ** Method : 1D z-coordinate system (use in all type of coordinate) |
---|
219 | !! The depth of model levels is set from dep(k), an analytical function: |
---|
220 | !! w-level: depw_1d = dep(k) |
---|
221 | !! t-level: dept_1d = dep(k+0.5) |
---|
222 | !! The scale factors are the discrete derivative of the depth: |
---|
223 | !! e3w_1d(jk) = dk[ dept_1d ] |
---|
224 | !! e3t_1d(jk) = dk[ depw_1d ] |
---|
225 | !! |
---|
226 | !! === Here constant vertical resolution === |
---|
227 | !! |
---|
228 | !! ** Action : - pdept_1d, pdepw_1d : depth of T- and W-point (m) |
---|
229 | !! - pe3t_1d , pe3w_1d : scale factors at T- and W-levels (m) |
---|
230 | !!---------------------------------------------------------------------- |
---|
231 | REAL(wp), DIMENSION(:), INTENT(out) :: pdept_1d, pdepw_1d ! 1D grid-point depth [m] |
---|
232 | REAL(wp), DIMENSION(:), INTENT(out) :: pe3t_1d , pe3w_1d ! 1D vertical scale factors [m] |
---|
233 | ! |
---|
234 | INTEGER :: jk ! dummy loop indices |
---|
235 | REAL(wp) :: zt, zw ! local scalar |
---|
236 | !!---------------------------------------------------------------------- |
---|
237 | ! |
---|
238 | IF(lwp) THEN ! Parameter print |
---|
239 | WRITE(numout,*) |
---|
240 | WRITE(numout,*) ' zgr_z1d : Reference vertical z-coordinates: uniform dz = ', rn_dz |
---|
241 | WRITE(numout,*) ' ~~~~~~~' |
---|
242 | ENDIF |
---|
243 | ! |
---|
244 | ! Reference z-coordinate (depth - scale factor at T- and W-points) ! Madec & Imbard 1996 function |
---|
245 | ! ---------------------- |
---|
246 | DO jk = 1, jpk |
---|
247 | zw = REAL( jk , wp ) |
---|
248 | zt = REAL( jk , wp ) + 0.5_wp |
---|
249 | pdepw_1d(jk) = rn_dz * REAL( jk-1 , wp ) |
---|
250 | pdept_1d(jk) = rn_dz * ( REAL( jk-1 , wp ) + 0.5_wp ) |
---|
251 | pe3w_1d (jk) = rn_dz |
---|
252 | pe3t_1d (jk) = rn_dz |
---|
253 | END DO |
---|
254 | ! |
---|
255 | IF(lwp) THEN ! control print |
---|
256 | WRITE(numout,*) |
---|
257 | WRITE(numout,*) ' Reference 1D z-coordinate depth and scale factors:' |
---|
258 | WRITE(numout, "(9x,' level gdept_1d gdepw_1d e3t_1d e3w_1d ')" ) |
---|
259 | WRITE(numout, "(10x, i4, 4f9.2)" ) ( jk, pdept_1d(jk), pdepw_1d(jk), pe3t_1d(jk), pe3w_1d(jk), jk = 1, jpk ) |
---|
260 | ENDIF |
---|
261 | ! |
---|
262 | END SUBROUTINE zgr_z1d |
---|
263 | |
---|
264 | !!====================================================================== |
---|
265 | END MODULE usrdef_zgr |
---|