1 | MODULE dynadv_ubs |
---|
2 | !!====================================================================== |
---|
3 | !! *** MODULE dynadv_ubs *** |
---|
4 | !! Ocean dynamics: Update the momentum trend with the flux form advection |
---|
5 | !! trend using a 3rd order upstream biased scheme |
---|
6 | !!====================================================================== |
---|
7 | !! History : 2.0 ! 2006-08 (R. Benshila, L. Debreu) Original code |
---|
8 | !! 3.2 ! 2009-07 (R. Benshila) Suppression of rigid-lid option |
---|
9 | !!---------------------------------------------------------------------- |
---|
10 | |
---|
11 | !!---------------------------------------------------------------------- |
---|
12 | !! dyn_adv_ubs : flux form momentum advection using (ln_dynadv=T) |
---|
13 | !! an 3rd order Upstream Biased Scheme or Quick scheme |
---|
14 | !! combined with 2nd or 4th order finite differences |
---|
15 | !!---------------------------------------------------------------------- |
---|
16 | USE oce ! ocean dynamics and tracers |
---|
17 | USE dom_oce ! ocean space and time domain |
---|
18 | USE trd_oce ! trends: ocean variables |
---|
19 | USE trddyn ! trend manager: dynamics |
---|
20 | ! |
---|
21 | USE in_out_manager ! I/O manager |
---|
22 | USE prtctl ! Print control |
---|
23 | USE lbclnk ! ocean lateral boundary conditions (or mpp link) |
---|
24 | USE lib_mpp ! MPP library |
---|
25 | USE wrk_nemo ! Memory Allocation |
---|
26 | USE timing ! Timing |
---|
27 | |
---|
28 | IMPLICIT NONE |
---|
29 | PRIVATE |
---|
30 | |
---|
31 | REAL(wp), PARAMETER :: gamma1 = 1._wp/3._wp ! =1/4 quick ; =1/3 3rd order UBS |
---|
32 | REAL(wp), PARAMETER :: gamma2 = 1._wp/32._wp ! =0 2nd order ; =1/32 4th order centred |
---|
33 | |
---|
34 | PUBLIC dyn_adv_ubs ! routine called by step.F90 |
---|
35 | |
---|
36 | !! * Substitutions |
---|
37 | # include "domzgr_substitute.h90" |
---|
38 | # include "vectopt_loop_substitute.h90" |
---|
39 | !!---------------------------------------------------------------------- |
---|
40 | !! NEMO/OPA 4.0 , NEMO Consortium (2011) |
---|
41 | !! $Id$ |
---|
42 | !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt) |
---|
43 | !!---------------------------------------------------------------------- |
---|
44 | CONTAINS |
---|
45 | |
---|
46 | SUBROUTINE dyn_adv_ubs( kt ) |
---|
47 | !!---------------------------------------------------------------------- |
---|
48 | !! *** ROUTINE dyn_adv_ubs *** |
---|
49 | !! |
---|
50 | !! ** Purpose : Compute the now momentum advection trend in flux form |
---|
51 | !! and the general trend of the momentum equation. |
---|
52 | !! |
---|
53 | !! ** Method : The scheme is the one implemeted in ROMS. It depends |
---|
54 | !! on two parameter gamma1 and gamma2. The former control the |
---|
55 | !! upstream baised part of the scheme and the later the centred |
---|
56 | !! part: gamma1 = 0 pure centered (no diffusive part) |
---|
57 | !! = 1/4 Quick scheme |
---|
58 | !! = 1/3 3rd order Upstream biased scheme |
---|
59 | !! gamma2 = 0 2nd order finite differencing |
---|
60 | !! = 1/32 4th order finite differencing |
---|
61 | !! For stability reasons, the first term of the fluxes which cor- |
---|
62 | !! responds to a second order centered scheme is evaluated using |
---|
63 | !! the now velocity (centered in time) while the second term which |
---|
64 | !! is the diffusive part of the scheme, is evaluated using the |
---|
65 | !! before velocity (forward in time). |
---|
66 | !! Default value (hard coded in the begining of the module) are |
---|
67 | !! gamma1=1/3 and gamma2=1/32. |
---|
68 | !! |
---|
69 | !! ** Action : - (ua,va) updated with the 3D advective momentum trends |
---|
70 | !! |
---|
71 | !! Reference : Shchepetkin & McWilliams, 2005, Ocean Modelling. |
---|
72 | !!---------------------------------------------------------------------- |
---|
73 | INTEGER, INTENT(in) :: kt ! ocean time-step index |
---|
74 | ! |
---|
75 | INTEGER :: ji, jj, jk ! dummy loop indices |
---|
76 | REAL(wp) :: zbu, zbv ! temporary scalars |
---|
77 | REAL(wp) :: zui, zvj, zfuj, zfvi, zl_u, zl_v ! temporary scalars |
---|
78 | REAL(wp), POINTER, DIMENSION(:,:,: ) :: zfu, zfv |
---|
79 | REAL(wp), POINTER, DIMENSION(:,:,: ) :: zfu_t, zfv_t, zfu_f, zfv_f, zfu_uw, zfv_vw, zfw |
---|
80 | REAL(wp), POINTER, DIMENSION(:,:,:,:) :: zlu_uu, zlv_vv, zlu_uv, zlv_vu |
---|
81 | !!---------------------------------------------------------------------- |
---|
82 | ! |
---|
83 | IF( nn_timing == 1 ) CALL timing_start('dyn_adv_ubs') |
---|
84 | ! |
---|
85 | CALL wrk_alloc( jpi, jpj, jpk, zfu_t , zfv_t , zfu_f , zfv_f, zfu_uw, zfv_vw, zfu, zfv, zfw ) |
---|
86 | CALL wrk_alloc( jpi, jpj, jpk, jpts, zlu_uu, zlv_vv, zlu_uv, zlv_vu ) |
---|
87 | ! |
---|
88 | IF( kt == nit000 ) THEN |
---|
89 | IF(lwp) WRITE(numout,*) |
---|
90 | IF(lwp) WRITE(numout,*) 'dyn_adv_ubs : UBS flux form momentum advection' |
---|
91 | IF(lwp) WRITE(numout,*) '~~~~~~~~~~~' |
---|
92 | ENDIF |
---|
93 | ! |
---|
94 | zfu_t(:,:,:) = 0._wp |
---|
95 | zfv_t(:,:,:) = 0._wp |
---|
96 | zfu_f(:,:,:) = 0._wp |
---|
97 | zfv_f(:,:,:) = 0._wp |
---|
98 | ! |
---|
99 | zlu_uu(:,:,:,:) = 0._wp |
---|
100 | zlv_vv(:,:,:,:) = 0._wp |
---|
101 | zlu_uv(:,:,:,:) = 0._wp |
---|
102 | zlv_vu(:,:,:,:) = 0._wp |
---|
103 | |
---|
104 | IF( l_trddyn ) THEN ! Save ua and va trends |
---|
105 | zfu_uw(:,:,:) = ua(:,:,:) |
---|
106 | zfv_vw(:,:,:) = va(:,:,:) |
---|
107 | ENDIF |
---|
108 | |
---|
109 | ! ! =========================== ! |
---|
110 | DO jk = 1, jpkm1 ! Laplacian of the velocity ! |
---|
111 | ! ! =========================== ! |
---|
112 | ! ! horizontal volume fluxes |
---|
113 | zfu(:,:,jk) = e2u(:,:) * fse3u(:,:,jk) * un(:,:,jk) |
---|
114 | zfv(:,:,jk) = e1v(:,:) * fse3v(:,:,jk) * vn(:,:,jk) |
---|
115 | ! |
---|
116 | DO jj = 2, jpjm1 ! laplacian |
---|
117 | DO ji = fs_2, fs_jpim1 ! vector opt. |
---|
118 | ! |
---|
119 | zlu_uu(ji,jj,jk,1) = ( ub (ji+1,jj ,jk) - 2.*ub (ji,jj,jk) + ub (ji-1,jj ,jk) ) * umask(ji,jj,jk) |
---|
120 | zlv_vv(ji,jj,jk,1) = ( vb (ji ,jj+1,jk) - 2.*vb (ji,jj,jk) + vb (ji ,jj-1,jk) ) * vmask(ji,jj,jk) |
---|
121 | zlu_uv(ji,jj,jk,1) = ( ub (ji ,jj+1,jk) - ub (ji ,jj ,jk) ) * fmask(ji ,jj ,jk) & |
---|
122 | & - ( ub (ji ,jj ,jk) - ub (ji ,jj-1,jk) ) * fmask(ji ,jj-1,jk) |
---|
123 | zlv_vu(ji,jj,jk,1) = ( vb (ji+1,jj ,jk) - vb (ji ,jj ,jk) ) * fmask(ji ,jj ,jk) & |
---|
124 | & - ( vb (ji ,jj ,jk) - vb (ji-1,jj ,jk) ) * fmask(ji-1,jj ,jk) |
---|
125 | ! |
---|
126 | zlu_uu(ji,jj,jk,2) = ( zfu(ji+1,jj ,jk) - 2.*zfu(ji,jj,jk) + zfu(ji-1,jj ,jk) ) * umask(ji,jj,jk) |
---|
127 | zlv_vv(ji,jj,jk,2) = ( zfv(ji ,jj+1,jk) - 2.*zfv(ji,jj,jk) + zfv(ji ,jj-1,jk) ) * vmask(ji,jj,jk) |
---|
128 | zlu_uv(ji,jj,jk,2) = ( zfu(ji ,jj+1,jk) - zfu(ji ,jj ,jk) ) * fmask(ji ,jj ,jk) & |
---|
129 | & - ( zfu(ji ,jj ,jk) - zfu(ji ,jj-1,jk) ) * fmask(ji ,jj-1,jk) |
---|
130 | zlv_vu(ji,jj,jk,2) = ( zfv(ji+1,jj ,jk) - zfv(ji ,jj ,jk) ) * fmask(ji ,jj ,jk) & |
---|
131 | & - ( zfv(ji ,jj ,jk) - zfv(ji-1,jj ,jk) ) * fmask(ji-1,jj ,jk) |
---|
132 | END DO |
---|
133 | END DO |
---|
134 | END DO |
---|
135 | CALL lbc_lnk( zlu_uu(:,:,:,1), 'U', 1. ) ; CALL lbc_lnk( zlu_uv(:,:,:,1), 'U', 1. ) |
---|
136 | CALL lbc_lnk( zlu_uu(:,:,:,2), 'U', 1. ) ; CALL lbc_lnk( zlu_uv(:,:,:,2), 'U', 1. ) |
---|
137 | CALL lbc_lnk( zlv_vv(:,:,:,1), 'V', 1. ) ; CALL lbc_lnk( zlv_vu(:,:,:,1), 'V', 1. ) |
---|
138 | CALL lbc_lnk( zlv_vv(:,:,:,2), 'V', 1. ) ; CALL lbc_lnk( zlv_vu(:,:,:,2), 'V', 1. ) |
---|
139 | |
---|
140 | ! ! ====================== ! |
---|
141 | ! ! Horizontal advection ! |
---|
142 | DO jk = 1, jpkm1 ! ====================== ! |
---|
143 | ! ! horizontal volume fluxes |
---|
144 | zfu(:,:,jk) = 0.25 * e2u(:,:) * fse3u(:,:,jk) * un(:,:,jk) |
---|
145 | zfv(:,:,jk) = 0.25 * e1v(:,:) * fse3v(:,:,jk) * vn(:,:,jk) |
---|
146 | ! |
---|
147 | DO jj = 1, jpjm1 ! horizontal momentum fluxes at T- and F-point |
---|
148 | DO ji = 1, fs_jpim1 ! vector opt. |
---|
149 | zui = ( un(ji,jj,jk) + un(ji+1,jj ,jk) ) |
---|
150 | zvj = ( vn(ji,jj,jk) + vn(ji ,jj+1,jk) ) |
---|
151 | ! |
---|
152 | IF (zui > 0) THEN ; zl_u = zlu_uu(ji ,jj,jk,1) |
---|
153 | ELSE ; zl_u = zlu_uu(ji+1,jj,jk,1) |
---|
154 | ENDIF |
---|
155 | IF (zvj > 0) THEN ; zl_v = zlv_vv(ji,jj ,jk,1) |
---|
156 | ELSE ; zl_v = zlv_vv(ji,jj+1,jk,1) |
---|
157 | ENDIF |
---|
158 | ! |
---|
159 | zfu_t(ji+1,jj ,jk) = ( zfu(ji,jj,jk) + zfu(ji+1,jj ,jk) & |
---|
160 | & - gamma2 * ( zlu_uu(ji,jj,jk,2) + zlu_uu(ji+1,jj ,jk,2) ) ) & |
---|
161 | & * ( zui - gamma1 * zl_u) |
---|
162 | zfv_t(ji ,jj+1,jk) = ( zfv(ji,jj,jk) + zfv(ji ,jj+1,jk) & |
---|
163 | & - gamma2 * ( zlv_vv(ji,jj,jk,2) + zlv_vv(ji ,jj+1,jk,2) ) ) & |
---|
164 | & * ( zvj - gamma1 * zl_v) |
---|
165 | ! |
---|
166 | zfuj = ( zfu(ji,jj,jk) + zfu(ji ,jj+1,jk) ) |
---|
167 | zfvi = ( zfv(ji,jj,jk) + zfv(ji+1,jj ,jk) ) |
---|
168 | IF (zfuj > 0) THEN ; zl_v = zlv_vu( ji ,jj ,jk,1) |
---|
169 | ELSE ; zl_v = zlv_vu( ji+1,jj,jk,1) |
---|
170 | ENDIF |
---|
171 | IF (zfvi > 0) THEN ; zl_u = zlu_uv( ji,jj ,jk,1) |
---|
172 | ELSE ; zl_u = zlu_uv( ji,jj+1,jk,1) |
---|
173 | ENDIF |
---|
174 | ! |
---|
175 | zfv_f(ji ,jj ,jk) = ( zfvi - gamma2 * ( zlv_vu(ji,jj,jk,2) + zlv_vu(ji+1,jj ,jk,2) ) ) & |
---|
176 | & * ( un(ji,jj,jk) + un(ji ,jj+1,jk) - gamma1 * zl_u ) |
---|
177 | zfu_f(ji ,jj ,jk) = ( zfuj - gamma2 * ( zlu_uv(ji,jj,jk,2) + zlu_uv(ji ,jj+1,jk,2) ) ) & |
---|
178 | & * ( vn(ji,jj,jk) + vn(ji+1,jj ,jk) - gamma1 * zl_v ) |
---|
179 | END DO |
---|
180 | END DO |
---|
181 | DO jj = 2, jpjm1 ! divergence of horizontal momentum fluxes |
---|
182 | DO ji = fs_2, fs_jpim1 ! vector opt. |
---|
183 | zbu = e1u(ji,jj) * e2u(ji,jj) * fse3u(ji,jj,jk) |
---|
184 | zbv = e1v(ji,jj) * e2v(ji,jj) * fse3v(ji,jj,jk) |
---|
185 | ! |
---|
186 | ua(ji,jj,jk) = ua(ji,jj,jk) - ( zfu_t(ji+1,jj ,jk) - zfu_t(ji ,jj ,jk) & |
---|
187 | & + zfv_f(ji ,jj ,jk) - zfv_f(ji ,jj-1,jk) ) / zbu |
---|
188 | va(ji,jj,jk) = va(ji,jj,jk) - ( zfu_f(ji ,jj ,jk) - zfu_f(ji-1,jj ,jk) & |
---|
189 | & + zfv_t(ji ,jj+1,jk) - zfv_t(ji ,jj ,jk) ) / zbv |
---|
190 | END DO |
---|
191 | END DO |
---|
192 | END DO |
---|
193 | IF( l_trddyn ) THEN ! save the horizontal advection trend for diagnostic |
---|
194 | zfu_uw(:,:,:) = ua(:,:,:) - zfu_uw(:,:,:) |
---|
195 | zfv_vw(:,:,:) = va(:,:,:) - zfv_vw(:,:,:) |
---|
196 | CALL trd_dyn( zfu_uw, zfv_vw, jpdyn_keg, kt ) |
---|
197 | zfu_t(:,:,:) = ua(:,:,:) |
---|
198 | zfv_t(:,:,:) = va(:,:,:) |
---|
199 | ENDIF |
---|
200 | |
---|
201 | ! ! ==================== ! |
---|
202 | ! ! Vertical advection ! |
---|
203 | DO jk = 1, jpkm1 ! ==================== ! |
---|
204 | ! ! Vertical volume fluxesÊ |
---|
205 | zfw(:,:,jk) = 0.25 * e1t(:,:) * e2t(:,:) * wn(:,:,jk) |
---|
206 | ! |
---|
207 | IF( jk == 1 ) THEN ! surface/bottom advective fluxes |
---|
208 | zfu_uw(:,:,jpk) = 0.e0 ! Bottom value : flux set to zero |
---|
209 | zfv_vw(:,:,jpk) = 0.e0 |
---|
210 | ! ! Surface value : |
---|
211 | IF( lk_vvl ) THEN ! variable volume : flux set to zero |
---|
212 | zfu_uw(:,:, 1 ) = 0.e0 |
---|
213 | zfv_vw(:,:, 1 ) = 0.e0 |
---|
214 | ELSE ! constant volume : advection through the surface |
---|
215 | DO jj = 2, jpjm1 |
---|
216 | DO ji = fs_2, fs_jpim1 |
---|
217 | zfu_uw(ji,jj, 1 ) = 2.e0 * ( zfw(ji,jj,1) + zfw(ji+1,jj ,1) ) * un(ji,jj,1) |
---|
218 | zfv_vw(ji,jj, 1 ) = 2.e0 * ( zfw(ji,jj,1) + zfw(ji ,jj+1,1) ) * vn(ji,jj,1) |
---|
219 | END DO |
---|
220 | END DO |
---|
221 | ENDIF |
---|
222 | ELSE ! interior fluxes |
---|
223 | DO jj = 2, jpjm1 |
---|
224 | DO ji = fs_2, fs_jpim1 ! vector opt. |
---|
225 | zfu_uw(ji,jj,jk) = ( zfw(ji,jj,jk)+ zfw(ji+1,jj ,jk) ) * ( un(ji,jj,jk) + un(ji,jj,jk-1) ) |
---|
226 | zfv_vw(ji,jj,jk) = ( zfw(ji,jj,jk)+ zfw(ji ,jj+1,jk) ) * ( vn(ji,jj,jk) + vn(ji,jj,jk-1) ) |
---|
227 | END DO |
---|
228 | END DO |
---|
229 | ENDIF |
---|
230 | END DO |
---|
231 | DO jk = 1, jpkm1 ! divergence of vertical momentum flux divergence |
---|
232 | DO jj = 2, jpjm1 |
---|
233 | DO ji = fs_2, fs_jpim1 ! vector opt. |
---|
234 | ua(ji,jj,jk) = ua(ji,jj,jk) - ( zfu_uw(ji,jj,jk) - zfu_uw(ji,jj,jk+1) ) & |
---|
235 | & / ( e1u(ji,jj) * e2u(ji,jj) * fse3u(ji,jj,jk) ) |
---|
236 | va(ji,jj,jk) = va(ji,jj,jk) - ( zfv_vw(ji,jj,jk) - zfv_vw(ji,jj,jk+1) ) & |
---|
237 | & / ( e1v(ji,jj) * e2v(ji,jj) * fse3v(ji,jj,jk) ) |
---|
238 | END DO |
---|
239 | END DO |
---|
240 | END DO |
---|
241 | ! |
---|
242 | IF( l_trddyn ) THEN ! save the vertical advection trend for diagnostic |
---|
243 | zfu_t(:,:,:) = ua(:,:,:) - zfu_t(:,:,:) |
---|
244 | zfv_t(:,:,:) = va(:,:,:) - zfv_t(:,:,:) |
---|
245 | CALL trd_dyn( zfu_t, zfv_t, jpdyn_zad, kt ) |
---|
246 | ENDIF |
---|
247 | ! ! Control print |
---|
248 | IF(ln_ctl) CALL prt_ctl( tab3d_1=ua, clinfo1=' ubs2 adv - Ua: ', mask1=umask, & |
---|
249 | & tab3d_2=va, clinfo2= ' Va: ', mask2=vmask, clinfo3='dyn' ) |
---|
250 | ! |
---|
251 | CALL wrk_dealloc( jpi, jpj, jpk, zfu_t , zfv_t , zfu_f , zfv_f, zfu_uw, zfv_vw, zfu, zfv, zfw ) |
---|
252 | CALL wrk_dealloc( jpi, jpj, jpk, jpts, zlu_uu, zlv_vv, zlu_uv, zlv_vu ) |
---|
253 | ! |
---|
254 | IF( nn_timing == 1 ) CALL timing_stop('dyn_adv_ubs') |
---|
255 | ! |
---|
256 | END SUBROUTINE dyn_adv_ubs |
---|
257 | |
---|
258 | !!============================================================================== |
---|
259 | END MODULE dynadv_ubs |
---|