1 | MODULE dynhpg |
---|
2 | !!====================================================================== |
---|
3 | !! *** MODULE dynhpg *** |
---|
4 | !! Ocean dynamics: hydrostatic pressure gradient trend |
---|
5 | !!====================================================================== |
---|
6 | !! History : OPA ! 1987-09 (P. Andrich, M.-A. Foujols) hpg_zco: Original code |
---|
7 | !! 5.0 ! 1991-11 (G. Madec) |
---|
8 | !! 7.0 ! 1996-01 (G. Madec) hpg_sco: Original code for s-coordinates |
---|
9 | !! 8.0 ! 1997-05 (G. Madec) split dynber into dynkeg and dynhpg |
---|
10 | !! 8.5 ! 2002-07 (G. Madec) F90: Free form and module |
---|
11 | !! 8.5 ! 2002-08 (A. Bozec) hpg_zps: Original code |
---|
12 | !! NEMO 1.0 ! 2005-10 (A. Beckmann, B.W. An) various s-coordinate options |
---|
13 | !! ! Original code for hpg_ctl, hpg_hel hpg_wdj, hpg_djc, hpg_rot |
---|
14 | !! - ! 2005-11 (G. Madec) style & small optimisation |
---|
15 | !! 3.3 ! 2010-10 (C. Ethe, G. Madec) reorganisation of initialisation phase |
---|
16 | !! 3.4 ! 2011-11 (H. Liu) hpg_prj: Original code for s-coordinates |
---|
17 | !! ! (A. Coward) suppression of hel, wdj and rot options |
---|
18 | !! 3.6 ! 2014-11 (P. Mathiot) hpg_isf: original code for ice shelf cavity |
---|
19 | !!---------------------------------------------------------------------- |
---|
20 | |
---|
21 | !!---------------------------------------------------------------------- |
---|
22 | !! dyn_hpg : update the momentum trend with the now horizontal |
---|
23 | !! gradient of the hydrostatic pressure |
---|
24 | !! dyn_hpg_init : initialisation and control of options |
---|
25 | !! hpg_zco : z-coordinate scheme |
---|
26 | !! hpg_zps : z-coordinate plus partial steps (interpolation) |
---|
27 | !! hpg_sco : s-coordinate (standard jacobian formulation) |
---|
28 | !! hpg_isf : s-coordinate (sco formulation) adapted to ice shelf |
---|
29 | !! hpg_djc : s-coordinate (Density Jacobian with Cubic polynomial) |
---|
30 | !! hpg_prj : s-coordinate (Pressure Jacobian with Cubic polynomial) |
---|
31 | !!---------------------------------------------------------------------- |
---|
32 | USE oce ! ocean dynamics and tracers |
---|
33 | USE sbc_oce ! surface variable (only for the flag with ice shelf) |
---|
34 | USE dom_oce ! ocean space and time domain |
---|
35 | USE phycst ! physical constants |
---|
36 | USE trd_oce ! trends: ocean variables |
---|
37 | USE trddyn ! trend manager: dynamics |
---|
38 | ! |
---|
39 | USE in_out_manager ! I/O manager |
---|
40 | USE prtctl ! Print control |
---|
41 | USE lbclnk ! lateral boundary condition |
---|
42 | USE lib_mpp ! MPP library |
---|
43 | USE eosbn2 ! compute density |
---|
44 | USE wrk_nemo ! Memory Allocation |
---|
45 | USE timing ! Timing |
---|
46 | |
---|
47 | IMPLICIT NONE |
---|
48 | PRIVATE |
---|
49 | |
---|
50 | PUBLIC dyn_hpg ! routine called by step module |
---|
51 | PUBLIC dyn_hpg_init ! routine called by opa module |
---|
52 | |
---|
53 | ! !!* Namelist namdyn_hpg : hydrostatic pressure gradient |
---|
54 | LOGICAL , PUBLIC :: ln_hpg_zco !: z-coordinate - full steps |
---|
55 | LOGICAL , PUBLIC :: ln_hpg_zps !: z-coordinate - partial steps (interpolation) |
---|
56 | LOGICAL , PUBLIC :: ln_hpg_sco !: s-coordinate (standard jacobian formulation) |
---|
57 | LOGICAL , PUBLIC :: ln_hpg_djc !: s-coordinate (Density Jacobian with Cubic polynomial) |
---|
58 | LOGICAL , PUBLIC :: ln_hpg_prj !: s-coordinate (Pressure Jacobian scheme) |
---|
59 | LOGICAL , PUBLIC :: ln_hpg_isf !: s-coordinate similar to sco modify for isf |
---|
60 | LOGICAL , PUBLIC :: ln_dynhpg_imp !: semi-implicite hpg flag |
---|
61 | |
---|
62 | INTEGER , PUBLIC :: nhpg = 0 ! = 0 to 7, type of pressure gradient scheme used ! (deduced from ln_hpg_... flags) (PUBLIC for TAM) |
---|
63 | |
---|
64 | !! * Substitutions |
---|
65 | # include "domzgr_substitute.h90" |
---|
66 | # include "vectopt_loop_substitute.h90" |
---|
67 | !!---------------------------------------------------------------------- |
---|
68 | !! NEMO/OPA 3.3 , NEMO Consortium (2010) |
---|
69 | !! $Id$ |
---|
70 | !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt) |
---|
71 | !!---------------------------------------------------------------------- |
---|
72 | CONTAINS |
---|
73 | |
---|
74 | SUBROUTINE dyn_hpg( kt ) |
---|
75 | !!--------------------------------------------------------------------- |
---|
76 | !! *** ROUTINE dyn_hpg *** |
---|
77 | !! |
---|
78 | !! ** Method : Call the hydrostatic pressure gradient routine |
---|
79 | !! using the scheme defined in the namelist |
---|
80 | !! |
---|
81 | !! ** Action : - Update (ua,va) with the now hydrastatic pressure trend |
---|
82 | !! - send trends to trd_dyn for futher diagnostics (l_trddyn=T) |
---|
83 | !!---------------------------------------------------------------------- |
---|
84 | INTEGER, INTENT(in) :: kt ! ocean time-step index |
---|
85 | REAL(wp), POINTER, DIMENSION(:,:,:) :: ztrdu, ztrdv |
---|
86 | !!---------------------------------------------------------------------- |
---|
87 | ! |
---|
88 | IF( nn_timing == 1 ) CALL timing_start('dyn_hpg') |
---|
89 | ! |
---|
90 | IF( l_trddyn ) THEN ! Temporary saving of ua and va trends (l_trddyn) |
---|
91 | CALL wrk_alloc( jpi,jpj,jpk, ztrdu, ztrdv ) |
---|
92 | ztrdu(:,:,:) = ua(:,:,:) |
---|
93 | ztrdv(:,:,:) = va(:,:,:) |
---|
94 | ENDIF |
---|
95 | ! |
---|
96 | SELECT CASE ( nhpg ) ! Hydrostatic pressure gradient computation |
---|
97 | CASE ( 0 ) ; CALL hpg_zco ( kt ) ! z-coordinate |
---|
98 | CASE ( 1 ) ; CALL hpg_zps ( kt ) ! z-coordinate plus partial steps (interpolation) |
---|
99 | CASE ( 2 ) ; CALL hpg_sco ( kt ) ! s-coordinate (standard jacobian formulation) |
---|
100 | CASE ( 3 ) ; CALL hpg_djc ( kt ) ! s-coordinate (Density Jacobian with Cubic polynomial) |
---|
101 | CASE ( 4 ) ; CALL hpg_prj ( kt ) ! s-coordinate (Pressure Jacobian scheme) |
---|
102 | CASE ( 5 ) ; CALL hpg_isf ( kt ) ! s-coordinate similar to sco modify for ice shelf |
---|
103 | END SELECT |
---|
104 | ! |
---|
105 | IF( l_trddyn ) THEN ! save the hydrostatic pressure gradient trends for momentum trend diagnostics |
---|
106 | ztrdu(:,:,:) = ua(:,:,:) - ztrdu(:,:,:) |
---|
107 | ztrdv(:,:,:) = va(:,:,:) - ztrdv(:,:,:) |
---|
108 | CALL trd_dyn( ztrdu, ztrdv, jpdyn_hpg, kt ) |
---|
109 | CALL wrk_dealloc( jpi,jpj,jpk, ztrdu, ztrdv ) |
---|
110 | ENDIF |
---|
111 | ! |
---|
112 | IF(ln_ctl) CALL prt_ctl( tab3d_1=ua, clinfo1=' hpg - Ua: ', mask1=umask, & |
---|
113 | & tab3d_2=va, clinfo2= ' Va: ', mask2=vmask, clinfo3='dyn' ) |
---|
114 | ! |
---|
115 | IF( nn_timing == 1 ) CALL timing_stop('dyn_hpg') |
---|
116 | ! |
---|
117 | END SUBROUTINE dyn_hpg |
---|
118 | |
---|
119 | |
---|
120 | SUBROUTINE dyn_hpg_init |
---|
121 | !!---------------------------------------------------------------------- |
---|
122 | !! *** ROUTINE dyn_hpg_init *** |
---|
123 | !! |
---|
124 | !! ** Purpose : initializations for the hydrostatic pressure gradient |
---|
125 | !! computation and consistency control |
---|
126 | !! |
---|
127 | !! ** Action : Read the namelist namdyn_hpg and check the consistency |
---|
128 | !! with the type of vertical coordinate used (zco, zps, sco) |
---|
129 | !!---------------------------------------------------------------------- |
---|
130 | INTEGER :: ioptio = 0 ! temporary integer |
---|
131 | INTEGER :: ios ! Local integer output status for namelist read |
---|
132 | !! |
---|
133 | NAMELIST/namdyn_hpg/ ln_hpg_zco, ln_hpg_zps, ln_hpg_sco, & |
---|
134 | & ln_hpg_djc, ln_hpg_prj, ln_hpg_isf, ln_dynhpg_imp |
---|
135 | !!---------------------------------------------------------------------- |
---|
136 | ! |
---|
137 | REWIND( numnam_ref ) ! Namelist namdyn_hpg in reference namelist : Hydrostatic pressure gradient |
---|
138 | READ ( numnam_ref, namdyn_hpg, IOSTAT = ios, ERR = 901) |
---|
139 | 901 IF( ios /= 0 ) CALL ctl_nam ( ios , 'namdyn_hpg in reference namelist', lwp ) |
---|
140 | |
---|
141 | REWIND( numnam_cfg ) ! Namelist namdyn_hpg in configuration namelist : Hydrostatic pressure gradient |
---|
142 | READ ( numnam_cfg, namdyn_hpg, IOSTAT = ios, ERR = 902 ) |
---|
143 | 902 IF( ios /= 0 ) CALL ctl_nam ( ios , 'namdyn_hpg in configuration namelist', lwp ) |
---|
144 | IF(lwm) WRITE ( numond, namdyn_hpg ) |
---|
145 | ! |
---|
146 | IF(lwp) THEN ! Control print |
---|
147 | WRITE(numout,*) |
---|
148 | WRITE(numout,*) 'dyn_hpg_init : hydrostatic pressure gradient initialisation' |
---|
149 | WRITE(numout,*) '~~~~~~~~~~~~' |
---|
150 | WRITE(numout,*) ' Namelist namdyn_hpg : choice of hpg scheme' |
---|
151 | WRITE(numout,*) ' z-coord. - full steps ln_hpg_zco = ', ln_hpg_zco |
---|
152 | WRITE(numout,*) ' z-coord. - partial steps (interpolation) ln_hpg_zps = ', ln_hpg_zps |
---|
153 | WRITE(numout,*) ' s-coord. (standard jacobian formulation) ln_hpg_sco = ', ln_hpg_sco |
---|
154 | WRITE(numout,*) ' s-coord. (standard jacobian formulation) for isf ln_hpg_isf = ', ln_hpg_isf |
---|
155 | WRITE(numout,*) ' s-coord. (Density Jacobian: Cubic polynomial) ln_hpg_djc = ', ln_hpg_djc |
---|
156 | WRITE(numout,*) ' s-coord. (Pressure Jacobian: Cubic polynomial) ln_hpg_prj = ', ln_hpg_prj |
---|
157 | WRITE(numout,*) ' time stepping: centered (F) or semi-implicit (T) ln_dynhpg_imp = ', ln_dynhpg_imp |
---|
158 | ENDIF |
---|
159 | ! |
---|
160 | IF( ln_hpg_djc ) & |
---|
161 | & CALL ctl_stop('dyn_hpg_init : Density Jacobian: Cubic polynominal method & |
---|
162 | & currently disabled (bugs under investigation). Please select & |
---|
163 | & either ln_hpg_sco or ln_hpg_prj instead') |
---|
164 | ! |
---|
165 | IF( lk_vvl .AND. .NOT. (ln_hpg_sco.OR.ln_hpg_prj.OR.ln_hpg_isf) ) & |
---|
166 | & CALL ctl_stop('dyn_hpg_init : variable volume key_vvl requires:& |
---|
167 | & the standard jacobian formulation hpg_sco or & |
---|
168 | & the pressure jacobian formulation hpg_prj') |
---|
169 | |
---|
170 | IF( ln_hpg_isf .AND. .NOT. ln_isfcav ) & |
---|
171 | & CALL ctl_stop( ' hpg_isf not available if ln_isfcav = false ' ) |
---|
172 | IF( .NOT. ln_hpg_isf .AND. ln_isfcav ) & |
---|
173 | & CALL ctl_stop( 'Only hpg_isf has been corrected to work with ice shelf cavity.' ) |
---|
174 | ! |
---|
175 | ! ! Set nhpg from ln_hpg_... flags |
---|
176 | IF( ln_hpg_zco ) nhpg = 0 |
---|
177 | IF( ln_hpg_zps ) nhpg = 1 |
---|
178 | IF( ln_hpg_sco ) nhpg = 2 |
---|
179 | IF( ln_hpg_djc ) nhpg = 3 |
---|
180 | IF( ln_hpg_prj ) nhpg = 4 |
---|
181 | IF( ln_hpg_isf ) nhpg = 5 |
---|
182 | ! |
---|
183 | ! ! Consistency check |
---|
184 | ioptio = 0 |
---|
185 | IF( ln_hpg_zco ) ioptio = ioptio + 1 |
---|
186 | IF( ln_hpg_zps ) ioptio = ioptio + 1 |
---|
187 | IF( ln_hpg_sco ) ioptio = ioptio + 1 |
---|
188 | IF( ln_hpg_djc ) ioptio = ioptio + 1 |
---|
189 | IF( ln_hpg_prj ) ioptio = ioptio + 1 |
---|
190 | IF( ln_hpg_isf ) ioptio = ioptio + 1 |
---|
191 | IF( ioptio /= 1 ) CALL ctl_stop( 'NO or several hydrostatic pressure gradient options used' ) |
---|
192 | ! |
---|
193 | ! initialisation of ice load |
---|
194 | riceload(:,:)=0.0 |
---|
195 | ! |
---|
196 | END SUBROUTINE dyn_hpg_init |
---|
197 | |
---|
198 | |
---|
199 | SUBROUTINE hpg_zco( kt ) |
---|
200 | !!--------------------------------------------------------------------- |
---|
201 | !! *** ROUTINE hpg_zco *** |
---|
202 | !! |
---|
203 | !! ** Method : z-coordinate case, levels are horizontal surfaces. |
---|
204 | !! The now hydrostatic pressure gradient at a given level, jk, |
---|
205 | !! is computed by taking the vertical integral of the in-situ |
---|
206 | !! density gradient along the model level from the suface to that |
---|
207 | !! level: zhpi = grav ..... |
---|
208 | !! zhpj = grav ..... |
---|
209 | !! add it to the general momentum trend (ua,va). |
---|
210 | !! ua = ua - 1/e1u * zhpi |
---|
211 | !! va = va - 1/e2v * zhpj |
---|
212 | !! |
---|
213 | !! ** Action : - Update (ua,va) with the now hydrastatic pressure trend |
---|
214 | !!---------------------------------------------------------------------- |
---|
215 | INTEGER, INTENT(in) :: kt ! ocean time-step index |
---|
216 | !! |
---|
217 | INTEGER :: ji, jj, jk ! dummy loop indices |
---|
218 | REAL(wp) :: zcoef0, zcoef1 ! temporary scalars |
---|
219 | REAL(wp), POINTER, DIMENSION(:,:,:) :: zhpi, zhpj |
---|
220 | !!---------------------------------------------------------------------- |
---|
221 | ! |
---|
222 | CALL wrk_alloc( jpi,jpj,jpk, zhpi, zhpj ) |
---|
223 | ! |
---|
224 | IF( kt == nit000 ) THEN |
---|
225 | IF(lwp) WRITE(numout,*) |
---|
226 | IF(lwp) WRITE(numout,*) 'dyn:hpg_zco : hydrostatic pressure gradient trend' |
---|
227 | IF(lwp) WRITE(numout,*) '~~~~~~~~~~~ z-coordinate case ' |
---|
228 | ENDIF |
---|
229 | |
---|
230 | zcoef0 = - grav * 0.5_wp ! Local constant initialization |
---|
231 | |
---|
232 | ! Surface value |
---|
233 | DO jj = 2, jpjm1 |
---|
234 | DO ji = fs_2, fs_jpim1 ! vector opt. |
---|
235 | zcoef1 = zcoef0 * fse3w(ji,jj,1) |
---|
236 | ! hydrostatic pressure gradient |
---|
237 | zhpi(ji,jj,1) = zcoef1 * ( rhd(ji+1,jj,1) - rhd(ji,jj,1) ) / e1u(ji,jj) |
---|
238 | zhpj(ji,jj,1) = zcoef1 * ( rhd(ji,jj+1,1) - rhd(ji,jj,1) ) / e2v(ji,jj) |
---|
239 | ! add to the general momentum trend |
---|
240 | ua(ji,jj,1) = ua(ji,jj,1) + zhpi(ji,jj,1) |
---|
241 | va(ji,jj,1) = va(ji,jj,1) + zhpj(ji,jj,1) |
---|
242 | END DO |
---|
243 | END DO |
---|
244 | |
---|
245 | ! |
---|
246 | ! interior value (2=<jk=<jpkm1) |
---|
247 | DO jk = 2, jpkm1 |
---|
248 | DO jj = 2, jpjm1 |
---|
249 | DO ji = fs_2, fs_jpim1 ! vector opt. |
---|
250 | zcoef1 = zcoef0 * fse3w(ji,jj,jk) |
---|
251 | ! hydrostatic pressure gradient |
---|
252 | zhpi(ji,jj,jk) = zhpi(ji,jj,jk-1) & |
---|
253 | & + zcoef1 * ( ( rhd(ji+1,jj,jk)+rhd(ji+1,jj,jk-1) ) & |
---|
254 | & - ( rhd(ji ,jj,jk)+rhd(ji ,jj,jk-1) ) ) / e1u(ji,jj) |
---|
255 | |
---|
256 | zhpj(ji,jj,jk) = zhpj(ji,jj,jk-1) & |
---|
257 | & + zcoef1 * ( ( rhd(ji,jj+1,jk)+rhd(ji,jj+1,jk-1) ) & |
---|
258 | & - ( rhd(ji,jj, jk)+rhd(ji,jj ,jk-1) ) ) / e2v(ji,jj) |
---|
259 | ! add to the general momentum trend |
---|
260 | ua(ji,jj,jk) = ua(ji,jj,jk) + zhpi(ji,jj,jk) |
---|
261 | va(ji,jj,jk) = va(ji,jj,jk) + zhpj(ji,jj,jk) |
---|
262 | END DO |
---|
263 | END DO |
---|
264 | END DO |
---|
265 | ! |
---|
266 | CALL wrk_dealloc( jpi,jpj,jpk, zhpi, zhpj ) |
---|
267 | ! |
---|
268 | END SUBROUTINE hpg_zco |
---|
269 | |
---|
270 | |
---|
271 | SUBROUTINE hpg_zps( kt ) |
---|
272 | !!--------------------------------------------------------------------- |
---|
273 | !! *** ROUTINE hpg_zps *** |
---|
274 | !! |
---|
275 | !! ** Method : z-coordinate plus partial steps case. blahblah... |
---|
276 | !! |
---|
277 | !! ** Action : - Update (ua,va) with the now hydrastatic pressure trend |
---|
278 | !!---------------------------------------------------------------------- |
---|
279 | INTEGER, INTENT(in) :: kt ! ocean time-step index |
---|
280 | !! |
---|
281 | INTEGER :: ji, jj, jk ! dummy loop indices |
---|
282 | INTEGER :: iku, ikv ! temporary integers |
---|
283 | REAL(wp) :: zcoef0, zcoef1, zcoef2, zcoef3 ! temporary scalars |
---|
284 | REAL(wp), POINTER, DIMENSION(:,:,:) :: zhpi, zhpj |
---|
285 | !!---------------------------------------------------------------------- |
---|
286 | ! |
---|
287 | CALL wrk_alloc( jpi,jpj,jpk, zhpi, zhpj ) |
---|
288 | ! |
---|
289 | IF( kt == nit000 ) THEN |
---|
290 | IF(lwp) WRITE(numout,*) |
---|
291 | IF(lwp) WRITE(numout,*) 'dyn:hpg_zps : hydrostatic pressure gradient trend' |
---|
292 | IF(lwp) WRITE(numout,*) '~~~~~~~~~~~ z-coordinate with partial steps - vector optimization' |
---|
293 | ENDIF |
---|
294 | |
---|
295 | |
---|
296 | ! Local constant initialization |
---|
297 | zcoef0 = - grav * 0.5_wp |
---|
298 | |
---|
299 | ! Surface value (also valid in partial step case) |
---|
300 | DO jj = 2, jpjm1 |
---|
301 | DO ji = fs_2, fs_jpim1 ! vector opt. |
---|
302 | zcoef1 = zcoef0 * fse3w(ji,jj,1) |
---|
303 | ! hydrostatic pressure gradient |
---|
304 | zhpi(ji,jj,1) = zcoef1 * ( rhd(ji+1,jj ,1) - rhd(ji,jj,1) ) / e1u(ji,jj) |
---|
305 | zhpj(ji,jj,1) = zcoef1 * ( rhd(ji ,jj+1,1) - rhd(ji,jj,1) ) / e2v(ji,jj) |
---|
306 | ! add to the general momentum trend |
---|
307 | ua(ji,jj,1) = ua(ji,jj,1) + zhpi(ji,jj,1) |
---|
308 | va(ji,jj,1) = va(ji,jj,1) + zhpj(ji,jj,1) |
---|
309 | END DO |
---|
310 | END DO |
---|
311 | |
---|
312 | |
---|
313 | ! interior value (2=<jk=<jpkm1) |
---|
314 | DO jk = 2, jpkm1 |
---|
315 | DO jj = 2, jpjm1 |
---|
316 | DO ji = fs_2, fs_jpim1 ! vector opt. |
---|
317 | zcoef1 = zcoef0 * fse3w(ji,jj,jk) |
---|
318 | ! hydrostatic pressure gradient |
---|
319 | zhpi(ji,jj,jk) = zhpi(ji,jj,jk-1) & |
---|
320 | & + zcoef1 * ( ( rhd(ji+1,jj,jk) + rhd(ji+1,jj,jk-1) ) & |
---|
321 | & - ( rhd(ji ,jj,jk) + rhd(ji ,jj,jk-1) ) ) / e1u(ji,jj) |
---|
322 | |
---|
323 | zhpj(ji,jj,jk) = zhpj(ji,jj,jk-1) & |
---|
324 | & + zcoef1 * ( ( rhd(ji,jj+1,jk) + rhd(ji,jj+1,jk-1) ) & |
---|
325 | & - ( rhd(ji,jj, jk) + rhd(ji,jj ,jk-1) ) ) / e2v(ji,jj) |
---|
326 | ! add to the general momentum trend |
---|
327 | ua(ji,jj,jk) = ua(ji,jj,jk) + zhpi(ji,jj,jk) |
---|
328 | va(ji,jj,jk) = va(ji,jj,jk) + zhpj(ji,jj,jk) |
---|
329 | END DO |
---|
330 | END DO |
---|
331 | END DO |
---|
332 | |
---|
333 | |
---|
334 | ! partial steps correction at the last level (use gru & grv computed in zpshde.F90) |
---|
335 | DO jj = 2, jpjm1 |
---|
336 | DO ji = 2, jpim1 |
---|
337 | iku = mbku(ji,jj) |
---|
338 | ikv = mbkv(ji,jj) |
---|
339 | zcoef2 = zcoef0 * MIN( fse3w(ji,jj,iku), fse3w(ji+1,jj ,iku) ) |
---|
340 | zcoef3 = zcoef0 * MIN( fse3w(ji,jj,ikv), fse3w(ji ,jj+1,ikv) ) |
---|
341 | IF( iku > 1 ) THEN ! on i-direction (level 2 or more) |
---|
342 | ua (ji,jj,iku) = ua(ji,jj,iku) - zhpi(ji,jj,iku) ! subtract old value |
---|
343 | zhpi(ji,jj,iku) = zhpi(ji,jj,iku-1) & ! compute the new one |
---|
344 | & + zcoef2 * ( rhd(ji+1,jj,iku-1) - rhd(ji,jj,iku-1) + gru(ji,jj) ) / e1u(ji,jj) |
---|
345 | ua (ji,jj,iku) = ua(ji,jj,iku) + zhpi(ji,jj,iku) ! add the new one to the general momentum trend |
---|
346 | ENDIF |
---|
347 | IF( ikv > 1 ) THEN ! on j-direction (level 2 or more) |
---|
348 | va (ji,jj,ikv) = va(ji,jj,ikv) - zhpj(ji,jj,ikv) ! subtract old value |
---|
349 | zhpj(ji,jj,ikv) = zhpj(ji,jj,ikv-1) & ! compute the new one |
---|
350 | & + zcoef3 * ( rhd(ji,jj+1,ikv-1) - rhd(ji,jj,ikv-1) + grv(ji,jj) ) / e2v(ji,jj) |
---|
351 | va (ji,jj,ikv) = va(ji,jj,ikv) + zhpj(ji,jj,ikv) ! add the new one to the general momentum trend |
---|
352 | ENDIF |
---|
353 | END DO |
---|
354 | END DO |
---|
355 | ! |
---|
356 | CALL wrk_dealloc( jpi,jpj,jpk, zhpi, zhpj ) |
---|
357 | ! |
---|
358 | END SUBROUTINE hpg_zps |
---|
359 | |
---|
360 | SUBROUTINE hpg_sco( kt ) |
---|
361 | !!--------------------------------------------------------------------- |
---|
362 | !! *** ROUTINE hpg_sco *** |
---|
363 | !! |
---|
364 | !! ** Method : s-coordinate case. Jacobian scheme. |
---|
365 | !! The now hydrostatic pressure gradient at a given level, jk, |
---|
366 | !! is computed by taking the vertical integral of the in-situ |
---|
367 | !! density gradient along the model level from the suface to that |
---|
368 | !! level. s-coordinates (ln_sco): a corrective term is added |
---|
369 | !! to the horizontal pressure gradient : |
---|
370 | !! zhpi = grav ..... + 1/e1u mi(rhd) di[ grav dep3w ] |
---|
371 | !! zhpj = grav ..... + 1/e2v mj(rhd) dj[ grav dep3w ] |
---|
372 | !! add it to the general momentum trend (ua,va). |
---|
373 | !! ua = ua - 1/e1u * zhpi |
---|
374 | !! va = va - 1/e2v * zhpj |
---|
375 | !! |
---|
376 | !! ** Action : - Update (ua,va) with the now hydrastatic pressure trend |
---|
377 | !!---------------------------------------------------------------------- |
---|
378 | INTEGER, INTENT(in) :: kt ! ocean time-step index |
---|
379 | !! |
---|
380 | INTEGER :: ji, jj, jk ! dummy loop indices |
---|
381 | REAL(wp) :: zcoef0, zuap, zvap, znad ! temporary scalars |
---|
382 | REAL(wp), POINTER, DIMENSION(:,:,:) :: zhpi, zhpj |
---|
383 | !!---------------------------------------------------------------------- |
---|
384 | ! |
---|
385 | CALL wrk_alloc( jpi,jpj,jpk, zhpi, zhpj ) |
---|
386 | ! |
---|
387 | IF( kt == nit000 ) THEN |
---|
388 | IF(lwp) WRITE(numout,*) |
---|
389 | IF(lwp) WRITE(numout,*) 'dyn:hpg_sco : hydrostatic pressure gradient trend' |
---|
390 | IF(lwp) WRITE(numout,*) '~~~~~~~~~~~ s-coordinate case, OPA original scheme used' |
---|
391 | ENDIF |
---|
392 | |
---|
393 | ! Local constant initialization |
---|
394 | zcoef0 = - grav * 0.5_wp |
---|
395 | ! To use density and not density anomaly |
---|
396 | IF ( lk_vvl ) THEN ; znad = 1._wp ! Variable volume |
---|
397 | ELSE ; znad = 0._wp ! Fixed volume |
---|
398 | ENDIF |
---|
399 | |
---|
400 | ! Surface value |
---|
401 | DO jj = 2, jpjm1 |
---|
402 | DO ji = fs_2, fs_jpim1 ! vector opt. |
---|
403 | ! hydrostatic pressure gradient along s-surfaces |
---|
404 | zhpi(ji,jj,1) = zcoef0 / e1u(ji,jj) * ( fse3w(ji+1,jj ,1) * ( znad + rhd(ji+1,jj ,1) ) & |
---|
405 | & - fse3w(ji ,jj ,1) * ( znad + rhd(ji ,jj ,1) ) ) |
---|
406 | zhpj(ji,jj,1) = zcoef0 / e2v(ji,jj) * ( fse3w(ji ,jj+1,1) * ( znad + rhd(ji ,jj+1,1) ) & |
---|
407 | & - fse3w(ji ,jj ,1) * ( znad + rhd(ji ,jj ,1) ) ) |
---|
408 | ! s-coordinate pressure gradient correction |
---|
409 | zuap = -zcoef0 * ( rhd (ji+1,jj,1) + rhd (ji,jj,1) + 2._wp * znad ) & |
---|
410 | & * ( fsde3w(ji+1,jj,1) - fsde3w(ji,jj,1) ) / e1u(ji,jj) |
---|
411 | zvap = -zcoef0 * ( rhd (ji,jj+1,1) + rhd (ji,jj,1) + 2._wp * znad ) & |
---|
412 | & * ( fsde3w(ji,jj+1,1) - fsde3w(ji,jj,1) ) / e2v(ji,jj) |
---|
413 | ! add to the general momentum trend |
---|
414 | ua(ji,jj,1) = ua(ji,jj,1) + zhpi(ji,jj,1) + zuap |
---|
415 | va(ji,jj,1) = va(ji,jj,1) + zhpj(ji,jj,1) + zvap |
---|
416 | END DO |
---|
417 | END DO |
---|
418 | |
---|
419 | ! interior value (2=<jk=<jpkm1) |
---|
420 | DO jk = 2, jpkm1 |
---|
421 | DO jj = 2, jpjm1 |
---|
422 | DO ji = fs_2, fs_jpim1 ! vector opt. |
---|
423 | ! hydrostatic pressure gradient along s-surfaces |
---|
424 | zhpi(ji,jj,jk) = zhpi(ji,jj,jk-1) + zcoef0 / e1u(ji,jj) & |
---|
425 | & * ( fse3w(ji+1,jj,jk) * ( rhd(ji+1,jj,jk) + rhd(ji+1,jj,jk-1) + 2*znad ) & |
---|
426 | & - fse3w(ji ,jj,jk) * ( rhd(ji ,jj,jk) + rhd(ji ,jj,jk-1) + 2*znad ) ) |
---|
427 | zhpj(ji,jj,jk) = zhpj(ji,jj,jk-1) + zcoef0 / e2v(ji,jj) & |
---|
428 | & * ( fse3w(ji,jj+1,jk) * ( rhd(ji,jj+1,jk) + rhd(ji,jj+1,jk-1) + 2*znad ) & |
---|
429 | & - fse3w(ji,jj ,jk) * ( rhd(ji,jj, jk) + rhd(ji,jj ,jk-1) + 2*znad ) ) |
---|
430 | ! s-coordinate pressure gradient correction |
---|
431 | zuap = -zcoef0 * ( rhd (ji+1,jj ,jk) + rhd (ji,jj,jk) + 2._wp * znad ) & |
---|
432 | & * ( fsde3w(ji+1,jj ,jk) - fsde3w(ji,jj,jk) ) / e1u(ji,jj) |
---|
433 | zvap = -zcoef0 * ( rhd (ji ,jj+1,jk) + rhd (ji,jj,jk) + 2._wp * znad ) & |
---|
434 | & * ( fsde3w(ji ,jj+1,jk) - fsde3w(ji,jj,jk) ) / e2v(ji,jj) |
---|
435 | ! add to the general momentum trend |
---|
436 | ua(ji,jj,jk) = ua(ji,jj,jk) + zhpi(ji,jj,jk) + zuap |
---|
437 | va(ji,jj,jk) = va(ji,jj,jk) + zhpj(ji,jj,jk) + zvap |
---|
438 | END DO |
---|
439 | END DO |
---|
440 | END DO |
---|
441 | ! |
---|
442 | CALL wrk_dealloc( jpi,jpj,jpk, zhpi, zhpj ) |
---|
443 | ! |
---|
444 | END SUBROUTINE hpg_sco |
---|
445 | |
---|
446 | SUBROUTINE hpg_isf( kt ) |
---|
447 | !!--------------------------------------------------------------------- |
---|
448 | !! *** ROUTINE hpg_sco *** |
---|
449 | !! |
---|
450 | !! ** Method : s-coordinate case. Jacobian scheme. |
---|
451 | !! The now hydrostatic pressure gradient at a given level, jk, |
---|
452 | !! is computed by taking the vertical integral of the in-situ |
---|
453 | !! density gradient along the model level from the suface to that |
---|
454 | !! level. s-coordinates (ln_sco): a corrective term is added |
---|
455 | !! to the horizontal pressure gradient : |
---|
456 | !! zhpi = grav ..... + 1/e1u mi(rhd) di[ grav dep3w ] |
---|
457 | !! zhpj = grav ..... + 1/e2v mj(rhd) dj[ grav dep3w ] |
---|
458 | !! add it to the general momentum trend (ua,va). |
---|
459 | !! ua = ua - 1/e1u * zhpi |
---|
460 | !! va = va - 1/e2v * zhpj |
---|
461 | !! iceload is added and partial cell case are added to the top and bottom |
---|
462 | !! |
---|
463 | !! ** Action : - Update (ua,va) with the now hydrastatic pressure trend |
---|
464 | !!---------------------------------------------------------------------- |
---|
465 | INTEGER, INTENT(in) :: kt ! ocean time-step index |
---|
466 | !! |
---|
467 | INTEGER :: ji, jj, jk, iku, ikv, ikt, iktp1i, iktp1j ! dummy loop indices |
---|
468 | REAL(wp) :: zcoef0, zuap, zvap, znad, ze3wu, ze3wv, zuapint, zvapint, zhpjint, zhpiint, zdzwt, zdzwtjp1, zdzwtip1 ! temporary scalars |
---|
469 | REAL(wp), POINTER, DIMENSION(:,:,:) :: zhpi, zhpj, zrhd |
---|
470 | REAL(wp), POINTER, DIMENSION(:,:,:) :: ztstop |
---|
471 | REAL(wp), POINTER, DIMENSION(:,:) :: ze3w, zp, zrhdtop_isf, zrhdtop_oce, ziceload, zdept, zpshpi, zpshpj |
---|
472 | !!---------------------------------------------------------------------- |
---|
473 | ! |
---|
474 | CALL wrk_alloc( jpi,jpj, 2, ztstop) |
---|
475 | CALL wrk_alloc( jpi,jpj,jpk, zhpi, zhpj, zrhd) |
---|
476 | CALL wrk_alloc( jpi,jpj, ze3w, zp, zrhdtop_isf, zrhdtop_oce, ziceload, zdept, zpshpi, zpshpj) |
---|
477 | ! |
---|
478 | IF( kt == nit000 ) THEN |
---|
479 | IF(lwp) WRITE(numout,*) |
---|
480 | IF(lwp) WRITE(numout,*) 'dyn:hpg_isf : hydrostatic pressure gradient trend for ice shelf' |
---|
481 | IF(lwp) WRITE(numout,*) '~~~~~~~~~~~ s-coordinate case, OPA original scheme used' |
---|
482 | ENDIF |
---|
483 | |
---|
484 | ! Local constant initialization |
---|
485 | zcoef0 = - grav * 0.5_wp |
---|
486 | ! To use density and not density anomaly |
---|
487 | ! IF ( lk_vvl ) THEN ; znad = 1._wp ! Variable volume |
---|
488 | ! ELSE ; znad = 0._wp ! Fixed volume |
---|
489 | ! ENDIF |
---|
490 | znad=1._wp |
---|
491 | ! iniitialised to 0. zhpi zhpi |
---|
492 | zhpi(:,:,:)=0._wp ; zhpj(:,:,:)=0._wp |
---|
493 | |
---|
494 | !================================================================================== |
---|
495 | !=====Compute iceload and contribution of the half first wet layer ================= |
---|
496 | !=================================================================================== |
---|
497 | |
---|
498 | ! assume water displaced by the ice shelf is at T=-1.9 and S=34.4 (rude) |
---|
499 | ztstop(:,:,1)=-1.9_wp ; ztstop(:,:,2)=34.4_wp |
---|
500 | |
---|
501 | ! compute density of the water displaced by the ice shelf |
---|
502 | zrhd = rhd ! save rhd |
---|
503 | DO jk = 1, jpk |
---|
504 | zdept(:,:)=gdept_1d(jk) |
---|
505 | CALL eos(ztstop(:,:,:),zdept(:,:),rhd(:,:,jk)) |
---|
506 | END DO |
---|
507 | WHERE ( tmask(:,:,:) == 1._wp) |
---|
508 | rhd(:,:,:) = zrhd(:,:,:) ! replace wet cell by the saved rhd |
---|
509 | END WHERE |
---|
510 | |
---|
511 | ! compute rhd at the ice/oce interface (ice shelf side) |
---|
512 | CALL eos(ztstop,risfdep,zrhdtop_isf) |
---|
513 | |
---|
514 | ! compute rhd at the ice/oce interface (ocean side) |
---|
515 | DO ji=1,jpi |
---|
516 | DO jj=1,jpj |
---|
517 | ikt=mikt(ji,jj) |
---|
518 | ztstop(ji,jj,1)=tsn(ji,jj,ikt,1) |
---|
519 | ztstop(ji,jj,2)=tsn(ji,jj,ikt,2) |
---|
520 | END DO |
---|
521 | END DO |
---|
522 | CALL eos(ztstop,risfdep,zrhdtop_oce) |
---|
523 | ! |
---|
524 | ! Surface value + ice shelf gradient |
---|
525 | ! compute pressure due to ice shelf load (used to compute hpgi/j for all the level from 1 to miku/v) |
---|
526 | ziceload = 0._wp |
---|
527 | DO jj = 1, jpj |
---|
528 | DO ji = 1, jpi ! vector opt. |
---|
529 | ikt=mikt(ji,jj) |
---|
530 | ziceload(ji,jj) = ziceload(ji,jj) + (znad + rhd(ji,jj,1) ) * fse3w(ji,jj,1) * (1._wp - tmask(ji,jj,1)) |
---|
531 | DO jk=2,ikt-1 |
---|
532 | ziceload(ji,jj) = ziceload(ji,jj) + (2._wp * znad + rhd(ji,jj,jk-1) + rhd(ji,jj,jk)) * fse3w(ji,jj,jk) & |
---|
533 | & * (1._wp - tmask(ji,jj,jk)) |
---|
534 | END DO |
---|
535 | IF (ikt .GE. 2) ziceload(ji,jj) = ziceload(ji,jj) + (2._wp * znad + zrhdtop_isf(ji,jj) + rhd(ji,jj,ikt-1)) & |
---|
536 | & * ( risfdep(ji,jj) - gdept_1d(ikt-1) ) |
---|
537 | END DO |
---|
538 | END DO |
---|
539 | riceload(:,:) = 0.0_wp ; riceload(:,:)=ziceload(:,:) ! need to be saved for diaar5 |
---|
540 | ! compute zp from z=0 to first T wet point (correction due to zps not yet applied) |
---|
541 | DO jj = 2, jpjm1 |
---|
542 | DO ji = fs_2, fs_jpim1 ! vector opt. |
---|
543 | ikt=mikt(ji,jj) ; iktp1i=mikt(ji+1,jj); iktp1j=mikt(ji,jj+1) |
---|
544 | ! hydrostatic pressure gradient along s-surfaces and ice shelf pressure |
---|
545 | ! we assume ISF is in isostatic equilibrium |
---|
546 | zhpi(ji,jj,1) = zcoef0 / e1u(ji,jj) * ( 0.5_wp * fse3w(ji+1,jj ,iktp1i) & |
---|
547 | & * ( 2._wp * znad + rhd(ji+1,jj ,iktp1i) + zrhdtop_oce(ji+1,jj ) ) & |
---|
548 | & - 0.5_wp * fse3w(ji ,jj ,ikt ) & |
---|
549 | & * ( 2._wp * znad + rhd(ji ,jj ,ikt ) + zrhdtop_oce(ji ,jj ) ) & |
---|
550 | & + ( ziceload(ji+1,jj) - ziceload(ji,jj)) ) |
---|
551 | zhpj(ji,jj,1) = zcoef0 / e2v(ji,jj) * ( 0.5_wp * fse3w(ji ,jj+1,iktp1j) & |
---|
552 | & * ( 2._wp * znad + rhd(ji ,jj+1,iktp1j) + zrhdtop_oce(ji ,jj+1) ) & |
---|
553 | & - 0.5_wp * fse3w(ji ,jj ,ikt ) & |
---|
554 | & * ( 2._wp * znad + rhd(ji ,jj ,ikt ) + zrhdtop_oce(ji ,jj ) ) & |
---|
555 | & + ( ziceload(ji,jj+1) - ziceload(ji,jj) ) ) |
---|
556 | ! s-coordinate pressure gradient correction (=0 if z coordinate) |
---|
557 | zuap = -zcoef0 * ( rhd (ji+1,jj,1) + rhd (ji,jj,1) + 2._wp * znad ) & |
---|
558 | & * ( fsde3w(ji+1,jj,1) - fsde3w(ji,jj,1) ) / e1u(ji,jj) |
---|
559 | zvap = -zcoef0 * ( rhd (ji,jj+1,1) + rhd (ji,jj,1) + 2._wp * znad ) & |
---|
560 | & * ( fsde3w(ji,jj+1,1) - fsde3w(ji,jj,1) ) / e2v(ji,jj) |
---|
561 | ! add to the general momentum trend |
---|
562 | ua(ji,jj,1) = ua(ji,jj,1) + (zhpi(ji,jj,1) + zuap) * umask(ji,jj,1) |
---|
563 | va(ji,jj,1) = va(ji,jj,1) + (zhpj(ji,jj,1) + zvap) * vmask(ji,jj,1) |
---|
564 | END DO |
---|
565 | END DO |
---|
566 | !================================================================================== |
---|
567 | !===== Compute partial cell contribution for the top cell ========================= |
---|
568 | !================================================================================== |
---|
569 | DO jj = 2, jpjm1 |
---|
570 | DO ji = fs_2, fs_jpim1 ! vector opt. |
---|
571 | iku = miku(ji,jj) ; |
---|
572 | zpshpi(ji,jj)=0.0_wp ; zpshpj(ji,jj)=0.0_wp |
---|
573 | ze3wu = (gdepw_0(ji+1,jj,iku+1) - gdept_0(ji+1,jj,iku)) - (gdepw_0(ji,jj,iku+1) - gdept_0(ji,jj,iku)) |
---|
574 | ! u direction |
---|
575 | IF ( iku .GT. 1 ) THEN |
---|
576 | ! case iku |
---|
577 | zhpi(ji,jj,iku) = zcoef0 / e1u(ji,jj) * ze3wu & |
---|
578 | & * ( rhd (ji+1,jj,iku) + rhd (ji,jj,iku) & |
---|
579 | & + SIGN(1._wp,ze3wu) * grui(ji,jj) + 2._wp * znad ) |
---|
580 | ! corrective term ( = 0 if z coordinate ) |
---|
581 | zuap = -zcoef0 * ( arui(ji,jj) + 2._wp * znad ) * gzui(ji,jj) / e1u(ji,jj) |
---|
582 | ! zhpi will be added in interior loop |
---|
583 | ua(ji,jj,iku) = ua(ji,jj,iku) + zuap |
---|
584 | ! in case of 2 cell water column, need to save the pressure gradient to compute the bottom pressure |
---|
585 | IF (mbku(ji,jj) == iku + 1) zpshpi(ji,jj) = zhpi(ji,jj,iku) |
---|
586 | |
---|
587 | ! case iku + 1 (remove the zphi term added in the interior loop and compute the one corrected for zps) |
---|
588 | zhpiint = zcoef0 / e1u(ji,jj) & |
---|
589 | & * ( fse3w(ji+1,jj ,iku+1) * ( (rhd(ji+1,jj,iku+1) + znad) & |
---|
590 | & + (rhd(ji+1,jj,iku ) + znad) ) * tmask(ji+1,jj,iku) & |
---|
591 | & - fse3w(ji ,jj ,iku+1) * ( (rhd(ji ,jj,iku+1) + znad) & |
---|
592 | & + (rhd(ji ,jj,iku ) + znad) ) * tmask(ji ,jj,iku) ) |
---|
593 | zhpi(ji,jj,iku+1) = zcoef0 / e1u(ji,jj) * ge3rui(ji,jj) - zhpiint |
---|
594 | END IF |
---|
595 | |
---|
596 | ! v direction |
---|
597 | ikv = mikv(ji,jj) |
---|
598 | ze3wv = (gdepw_0(ji,jj+1,ikv+1) - gdept_0(ji,jj+1,ikv)) - (gdepw_0(ji,jj,ikv+1) - gdept_0(ji,jj,ikv)) |
---|
599 | IF ( ikv .GT. 1 ) THEN |
---|
600 | ! case ikv |
---|
601 | zhpj(ji,jj,ikv) = zcoef0 / e2v(ji,jj) * ze3wv & |
---|
602 | & * ( rhd(ji,jj+1,ikv) + rhd (ji,jj,ikv) & |
---|
603 | & + SIGN(1._wp,ze3wv) * grvi(ji,jj) + 2._wp * znad ) |
---|
604 | ! corrective term ( = 0 if z coordinate ) |
---|
605 | zvap = -zcoef0 * ( arvi(ji,jj) + 2._wp * znad ) * gzvi(ji,jj) / e2v(ji,jj) |
---|
606 | ! zhpi will be added in interior loop |
---|
607 | va(ji,jj,ikv) = va(ji,jj,ikv) + zvap |
---|
608 | ! in case of 2 cell water column, need to save the pressure gradient to compute the bottom pressure |
---|
609 | IF (mbkv(ji,jj) == ikv + 1) zpshpj(ji,jj) = zhpj(ji,jj,ikv) |
---|
610 | |
---|
611 | ! case ikv + 1 (remove the zphj term added in the interior loop and compute the one corrected for zps) |
---|
612 | zhpjint = zcoef0 / e2v(ji,jj) & |
---|
613 | & * ( fse3w(ji ,jj+1,ikv+1) * ( (rhd(ji,jj+1,ikv+1) + znad) & |
---|
614 | & + (rhd(ji,jj+1,ikv ) + znad) ) * tmask(ji,jj+1,ikv) & |
---|
615 | & - fse3w(ji ,jj ,ikv+1) * ( (rhd(ji,jj ,ikv+1) + znad) & |
---|
616 | & + (rhd(ji,jj ,ikv ) + znad) ) * tmask(ji,jj ,ikv) ) |
---|
617 | zhpj(ji,jj,ikv+1) = zcoef0 / e2v(ji,jj) * ge3rvi(ji,jj) - zhpjint |
---|
618 | END IF |
---|
619 | END DO |
---|
620 | END DO |
---|
621 | |
---|
622 | !================================================================================== |
---|
623 | !===== Compute interior value ===================================================== |
---|
624 | !================================================================================== |
---|
625 | |
---|
626 | DO jj = 2, jpjm1 |
---|
627 | DO ji = fs_2, fs_jpim1 ! vector opt. |
---|
628 | iku=miku(ji,jj); ikv=mikv(ji,jj) |
---|
629 | DO jk = 2, jpkm1 |
---|
630 | ! hydrostatic pressure gradient along s-surfaces |
---|
631 | ! zhpi is masked for the first wet cell (contribution already done in the upper bloc) |
---|
632 | zhpi(ji,jj,jk) = zhpi(ji,jj,jk) + zhpi(ji,jj,jk-1) & |
---|
633 | & + zcoef0 / e1u(ji,jj) & |
---|
634 | & * ( fse3w(ji+1,jj ,jk) * ( (rhd(ji+1,jj,jk ) + znad) & |
---|
635 | & + (rhd(ji+1,jj,jk-1) + znad) ) * tmask(ji+1,jj,jk-1) & |
---|
636 | & - fse3w(ji ,jj ,jk) * ( (rhd(ji ,jj,jk ) + znad) & |
---|
637 | & + (rhd(ji ,jj,jk-1) + znad) ) * tmask(ji ,jj,jk-1) ) |
---|
638 | ! s-coordinate pressure gradient correction |
---|
639 | ! corrective term, we mask this term for the first wet level beneath the ice shelf (contribution done in the upper bloc) |
---|
640 | zuap = - zcoef0 * ( rhd (ji+1,jj ,jk) + rhd (ji,jj,jk) + 2._wp * znad ) & |
---|
641 | & * ( fsde3w(ji+1,jj ,jk) - fsde3w(ji,jj,jk) ) / e1u(ji,jj) * umask(ji,jj,jk-1) |
---|
642 | ua(ji,jj,jk) = ua(ji,jj,jk) + ( zhpi(ji,jj,jk) + zuap) * umask(ji,jj,jk) |
---|
643 | |
---|
644 | ! hydrostatic pressure gradient along s-surfaces |
---|
645 | ! zhpi is masked for the first wet cell (contribution already done in the upper bloc) |
---|
646 | zhpj(ji,jj,jk) = zhpj(ji,jj,jk) + zhpj(ji,jj,jk-1) & |
---|
647 | & + zcoef0 / e2v(ji,jj) & |
---|
648 | & * ( fse3w(ji ,jj+1,jk) * ( (rhd(ji,jj+1,jk ) + znad) & |
---|
649 | & + (rhd(ji,jj+1,jk-1) + znad) ) * tmask(ji,jj+1,jk-1) & |
---|
650 | & - fse3w(ji ,jj ,jk) * ( (rhd(ji,jj ,jk ) + znad) & |
---|
651 | & + (rhd(ji,jj ,jk-1) + znad) ) * tmask(ji,jj ,jk-1) ) |
---|
652 | ! s-coordinate pressure gradient correction |
---|
653 | ! corrective term, we mask this term for the first wet level beneath the ice shelf (contribution done in the upper bloc) |
---|
654 | zvap = - zcoef0 * ( rhd (ji ,jj+1,jk) + rhd (ji,jj,jk) + 2._wp * znad ) & |
---|
655 | & * ( fsde3w(ji ,jj+1,jk) - fsde3w(ji,jj,jk) ) / e2v(ji,jj) * vmask(ji,jj,jk-1) |
---|
656 | ! add to the general momentum trend |
---|
657 | va(ji,jj,jk) = va(ji,jj,jk) + ( zhpj(ji,jj,jk) + zvap ) * vmask(ji,jj,jk) |
---|
658 | END DO |
---|
659 | END DO |
---|
660 | END DO |
---|
661 | |
---|
662 | !================================================================================== |
---|
663 | !===== Compute bottom cell contribution (partial cell) ============================ |
---|
664 | !================================================================================== |
---|
665 | |
---|
666 | DO jj = 2, jpjm1 |
---|
667 | DO ji = 2, jpim1 |
---|
668 | iku = mbku(ji,jj) |
---|
669 | ikv = mbkv(ji,jj) |
---|
670 | |
---|
671 | IF (iku .GT. 1) THEN |
---|
672 | ! remove old value (interior case) |
---|
673 | zuap = -zcoef0 * ( rhd (ji+1,jj ,iku) + rhd (ji,jj,iku) + 2._wp * znad ) & |
---|
674 | & * ( fsde3w(ji+1,jj ,iku) - fsde3w(ji,jj,iku) ) / e1u(ji,jj) |
---|
675 | ua(ji,jj,iku) = ua(ji,jj,iku) - zhpi(ji,jj,iku) - zuap |
---|
676 | ! put new value |
---|
677 | ! -zpshpi to avoid double contribution of the partial step in the top layer |
---|
678 | zuap = -zcoef0 * ( aru(ji,jj) + 2._wp * znad ) * gzu(ji,jj) / e1u(ji,jj) |
---|
679 | zhpi(ji,jj,iku) = zhpi(ji,jj,iku-1) + zcoef0 / e1u(ji,jj) * ge3ru(ji,jj) - zpshpi(ji,jj) |
---|
680 | ua(ji,jj,iku) = ua(ji,jj,iku) + zhpi(ji,jj,iku) + zuap |
---|
681 | END IF |
---|
682 | ! v direction |
---|
683 | IF (ikv .GT. 1) THEN |
---|
684 | ! remove old value (interior case) |
---|
685 | zvap = -zcoef0 * ( rhd (ji ,jj+1,ikv) + rhd (ji,jj,ikv) + 2._wp * znad ) & |
---|
686 | & * ( fsde3w(ji ,jj+1,ikv) - fsde3w(ji,jj,ikv) ) / e2v(ji,jj) |
---|
687 | va(ji,jj,ikv) = va(ji,jj,ikv) - zhpj(ji,jj,ikv) - zvap |
---|
688 | ! put new value |
---|
689 | ! -zpshpj to avoid double contribution of the partial step in the top layer |
---|
690 | zvap = -zcoef0 * ( arv(ji,jj) + 2._wp * znad ) * gzv(ji,jj) / e2v(ji,jj) |
---|
691 | zhpj(ji,jj,ikv) = zhpj(ji,jj,ikv-1) + zcoef0 / e2v(ji,jj) * ge3rv(ji,jj) - zpshpj(ji,jj) |
---|
692 | va(ji,jj,ikv) = va(ji,jj,ikv) + zhpj(ji,jj,ikv) + zvap |
---|
693 | END IF |
---|
694 | END DO |
---|
695 | END DO |
---|
696 | |
---|
697 | ! set back to original density value into the ice shelf cell (maybe useless because it is masked) |
---|
698 | rhd = zrhd |
---|
699 | ! |
---|
700 | CALL wrk_dealloc( jpi,jpj,2, ztstop) |
---|
701 | CALL wrk_dealloc( jpi,jpj,jpk, zhpi, zhpj, zrhd) |
---|
702 | CALL wrk_dealloc( jpi,jpj, ze3w, zp, zrhdtop_isf, zrhdtop_oce, ziceload, zdept, zpshpi, zpshpj) |
---|
703 | ! |
---|
704 | END SUBROUTINE hpg_isf |
---|
705 | |
---|
706 | |
---|
707 | SUBROUTINE hpg_djc( kt ) |
---|
708 | !!--------------------------------------------------------------------- |
---|
709 | !! *** ROUTINE hpg_djc *** |
---|
710 | !! |
---|
711 | !! ** Method : Density Jacobian with Cubic polynomial scheme |
---|
712 | !! |
---|
713 | !! Reference: Shchepetkin and McWilliams, J. Geophys. Res., 108(C3), 3090, 2003 |
---|
714 | !!---------------------------------------------------------------------- |
---|
715 | INTEGER, INTENT(in) :: kt ! ocean time-step index |
---|
716 | !! |
---|
717 | INTEGER :: ji, jj, jk ! dummy loop indices |
---|
718 | REAL(wp) :: zcoef0, zep, cffw ! temporary scalars |
---|
719 | REAL(wp) :: z1_10, cffu, cffx ! " " |
---|
720 | REAL(wp) :: z1_12, cffv, cffy ! " " |
---|
721 | REAL(wp), POINTER, DIMENSION(:,:,:) :: zhpi, zhpj |
---|
722 | REAL(wp), POINTER, DIMENSION(:,:,:) :: dzx, dzy, dzz, dzu, dzv, dzw |
---|
723 | REAL(wp), POINTER, DIMENSION(:,:,:) :: drhox, drhoy, drhoz, drhou, drhov, drhow |
---|
724 | REAL(wp), POINTER, DIMENSION(:,:,:) :: rho_i, rho_j, rho_k |
---|
725 | !!---------------------------------------------------------------------- |
---|
726 | ! |
---|
727 | CALL wrk_alloc( jpi, jpj, jpk, dzx , dzy , dzz , dzu , dzv , dzw ) |
---|
728 | CALL wrk_alloc( jpi, jpj, jpk, drhox, drhoy, drhoz, drhou, drhov, drhow ) |
---|
729 | CALL wrk_alloc( jpi, jpj, jpk, rho_i, rho_j, rho_k, zhpi, zhpj ) |
---|
730 | ! |
---|
731 | |
---|
732 | IF( kt == nit000 ) THEN |
---|
733 | IF(lwp) WRITE(numout,*) |
---|
734 | IF(lwp) WRITE(numout,*) 'dyn:hpg_djc : hydrostatic pressure gradient trend' |
---|
735 | IF(lwp) WRITE(numout,*) '~~~~~~~~~~~ s-coordinate case, density Jacobian with cubic polynomial scheme' |
---|
736 | ENDIF |
---|
737 | |
---|
738 | ! Local constant initialization |
---|
739 | zcoef0 = - grav * 0.5_wp |
---|
740 | z1_10 = 1._wp / 10._wp |
---|
741 | z1_12 = 1._wp / 12._wp |
---|
742 | |
---|
743 | !---------------------------------------------------------------------------------------- |
---|
744 | ! compute and store in provisional arrays elementary vertical and horizontal differences |
---|
745 | !---------------------------------------------------------------------------------------- |
---|
746 | |
---|
747 | !!bug gm Not a true bug, but... dzz=e3w for dzx, dzy verify what it is really |
---|
748 | |
---|
749 | DO jk = 2, jpkm1 |
---|
750 | DO jj = 2, jpjm1 |
---|
751 | DO ji = fs_2, fs_jpim1 ! vector opt. |
---|
752 | drhoz(ji,jj,jk) = rhd (ji ,jj ,jk) - rhd (ji,jj,jk-1) |
---|
753 | dzz (ji,jj,jk) = fsde3w(ji ,jj ,jk) - fsde3w(ji,jj,jk-1) |
---|
754 | drhox(ji,jj,jk) = rhd (ji+1,jj ,jk) - rhd (ji,jj,jk ) |
---|
755 | dzx (ji,jj,jk) = fsde3w(ji+1,jj ,jk) - fsde3w(ji,jj,jk ) |
---|
756 | drhoy(ji,jj,jk) = rhd (ji ,jj+1,jk) - rhd (ji,jj,jk ) |
---|
757 | dzy (ji,jj,jk) = fsde3w(ji ,jj+1,jk) - fsde3w(ji,jj,jk ) |
---|
758 | END DO |
---|
759 | END DO |
---|
760 | END DO |
---|
761 | |
---|
762 | !------------------------------------------------------------------------- |
---|
763 | ! compute harmonic averages using eq. 5.18 |
---|
764 | !------------------------------------------------------------------------- |
---|
765 | zep = 1.e-15 |
---|
766 | |
---|
767 | !!bug gm drhoz not defined at level 1 and used (jk-1 with jk=2) |
---|
768 | !!bug gm idem for drhox, drhoy et ji=jpi and jj=jpj |
---|
769 | |
---|
770 | DO jk = 2, jpkm1 |
---|
771 | DO jj = 2, jpjm1 |
---|
772 | DO ji = fs_2, fs_jpim1 ! vector opt. |
---|
773 | cffw = 2._wp * drhoz(ji ,jj ,jk) * drhoz(ji,jj,jk-1) |
---|
774 | |
---|
775 | cffu = 2._wp * drhox(ji+1,jj ,jk) * drhox(ji,jj,jk ) |
---|
776 | cffx = 2._wp * dzx (ji+1,jj ,jk) * dzx (ji,jj,jk ) |
---|
777 | |
---|
778 | cffv = 2._wp * drhoy(ji ,jj+1,jk) * drhoy(ji,jj,jk ) |
---|
779 | cffy = 2._wp * dzy (ji ,jj+1,jk) * dzy (ji,jj,jk ) |
---|
780 | |
---|
781 | IF( cffw > zep) THEN |
---|
782 | drhow(ji,jj,jk) = 2._wp * drhoz(ji,jj,jk) * drhoz(ji,jj,jk-1) & |
---|
783 | & / ( drhoz(ji,jj,jk) + drhoz(ji,jj,jk-1) ) |
---|
784 | ELSE |
---|
785 | drhow(ji,jj,jk) = 0._wp |
---|
786 | ENDIF |
---|
787 | |
---|
788 | dzw(ji,jj,jk) = 2._wp * dzz(ji,jj,jk) * dzz(ji,jj,jk-1) & |
---|
789 | & / ( dzz(ji,jj,jk) + dzz(ji,jj,jk-1) ) |
---|
790 | |
---|
791 | IF( cffu > zep ) THEN |
---|
792 | drhou(ji,jj,jk) = 2._wp * drhox(ji+1,jj,jk) * drhox(ji,jj,jk) & |
---|
793 | & / ( drhox(ji+1,jj,jk) + drhox(ji,jj,jk) ) |
---|
794 | ELSE |
---|
795 | drhou(ji,jj,jk ) = 0._wp |
---|
796 | ENDIF |
---|
797 | |
---|
798 | IF( cffx > zep ) THEN |
---|
799 | dzu(ji,jj,jk) = 2._wp * dzx(ji+1,jj,jk) * dzx(ji,jj,jk) & |
---|
800 | & / ( dzx(ji+1,jj,jk) + dzx(ji,jj,jk) ) |
---|
801 | ELSE |
---|
802 | dzu(ji,jj,jk) = 0._wp |
---|
803 | ENDIF |
---|
804 | |
---|
805 | IF( cffv > zep ) THEN |
---|
806 | drhov(ji,jj,jk) = 2._wp * drhoy(ji,jj+1,jk) * drhoy(ji,jj,jk) & |
---|
807 | & / ( drhoy(ji,jj+1,jk) + drhoy(ji,jj,jk) ) |
---|
808 | ELSE |
---|
809 | drhov(ji,jj,jk) = 0._wp |
---|
810 | ENDIF |
---|
811 | |
---|
812 | IF( cffy > zep ) THEN |
---|
813 | dzv(ji,jj,jk) = 2._wp * dzy(ji,jj+1,jk) * dzy(ji,jj,jk) & |
---|
814 | & / ( dzy(ji,jj+1,jk) + dzy(ji,jj,jk) ) |
---|
815 | ELSE |
---|
816 | dzv(ji,jj,jk) = 0._wp |
---|
817 | ENDIF |
---|
818 | |
---|
819 | END DO |
---|
820 | END DO |
---|
821 | END DO |
---|
822 | |
---|
823 | !---------------------------------------------------------------------------------- |
---|
824 | ! apply boundary conditions at top and bottom using 5.36-5.37 |
---|
825 | !---------------------------------------------------------------------------------- |
---|
826 | drhow(:,:, 1 ) = 1.5_wp * ( drhoz(:,:, 2 ) - drhoz(:,:, 1 ) ) - 0.5_wp * drhow(:,:, 2 ) |
---|
827 | drhou(:,:, 1 ) = 1.5_wp * ( drhox(:,:, 2 ) - drhox(:,:, 1 ) ) - 0.5_wp * drhou(:,:, 2 ) |
---|
828 | drhov(:,:, 1 ) = 1.5_wp * ( drhoy(:,:, 2 ) - drhoy(:,:, 1 ) ) - 0.5_wp * drhov(:,:, 2 ) |
---|
829 | |
---|
830 | drhow(:,:,jpk) = 1.5_wp * ( drhoz(:,:,jpk) - drhoz(:,:,jpkm1) ) - 0.5_wp * drhow(:,:,jpkm1) |
---|
831 | drhou(:,:,jpk) = 1.5_wp * ( drhox(:,:,jpk) - drhox(:,:,jpkm1) ) - 0.5_wp * drhou(:,:,jpkm1) |
---|
832 | drhov(:,:,jpk) = 1.5_wp * ( drhoy(:,:,jpk) - drhoy(:,:,jpkm1) ) - 0.5_wp * drhov(:,:,jpkm1) |
---|
833 | |
---|
834 | |
---|
835 | !-------------------------------------------------------------- |
---|
836 | ! Upper half of top-most grid box, compute and store |
---|
837 | !------------------------------------------------------------- |
---|
838 | |
---|
839 | !!bug gm : e3w-de3w = 0.5*e3w .... and de3w(2)-de3w(1)=e3w(2) .... to be verified |
---|
840 | ! true if de3w is really defined as the sum of the e3w scale factors as, it seems to me, it should be |
---|
841 | |
---|
842 | DO jj = 2, jpjm1 |
---|
843 | DO ji = fs_2, fs_jpim1 ! vector opt. |
---|
844 | rho_k(ji,jj,1) = -grav * ( fse3w(ji,jj,1) - fsde3w(ji,jj,1) ) & |
---|
845 | & * ( rhd(ji,jj,1) & |
---|
846 | & + 0.5_wp * ( rhd(ji,jj,2) - rhd(ji,jj,1) ) & |
---|
847 | & * ( fse3w (ji,jj,1) - fsde3w(ji,jj,1) ) & |
---|
848 | & / ( fsde3w(ji,jj,2) - fsde3w(ji,jj,1) ) ) |
---|
849 | END DO |
---|
850 | END DO |
---|
851 | |
---|
852 | !!bug gm : here also, simplification is possible |
---|
853 | !!bug gm : optimisation: 1/10 and 1/12 the division should be done before the loop |
---|
854 | |
---|
855 | DO jk = 2, jpkm1 |
---|
856 | DO jj = 2, jpjm1 |
---|
857 | DO ji = fs_2, fs_jpim1 ! vector opt. |
---|
858 | |
---|
859 | rho_k(ji,jj,jk) = zcoef0 * ( rhd (ji,jj,jk) + rhd (ji,jj,jk-1) ) & |
---|
860 | & * ( fsde3w(ji,jj,jk) - fsde3w(ji,jj,jk-1) ) & |
---|
861 | & - grav * z1_10 * ( & |
---|
862 | & ( drhow (ji,jj,jk) - drhow (ji,jj,jk-1) ) & |
---|
863 | & * ( fsde3w(ji,jj,jk) - fsde3w(ji,jj,jk-1) - z1_12 * ( dzw (ji,jj,jk) + dzw (ji,jj,jk-1) ) ) & |
---|
864 | & - ( dzw (ji,jj,jk) - dzw (ji,jj,jk-1) ) & |
---|
865 | & * ( rhd (ji,jj,jk) - rhd (ji,jj,jk-1) - z1_12 * ( drhow(ji,jj,jk) + drhow(ji,jj,jk-1) ) ) & |
---|
866 | & ) |
---|
867 | |
---|
868 | rho_i(ji,jj,jk) = zcoef0 * ( rhd (ji+1,jj,jk) + rhd (ji,jj,jk) ) & |
---|
869 | & * ( fsde3w(ji+1,jj,jk) - fsde3w(ji,jj,jk) ) & |
---|
870 | & - grav* z1_10 * ( & |
---|
871 | & ( drhou (ji+1,jj,jk) - drhou (ji,jj,jk) ) & |
---|
872 | & * ( fsde3w(ji+1,jj,jk) - fsde3w(ji,jj,jk) - z1_12 * ( dzu (ji+1,jj,jk) + dzu (ji,jj,jk) ) ) & |
---|
873 | & - ( dzu (ji+1,jj,jk) - dzu (ji,jj,jk) ) & |
---|
874 | & * ( rhd (ji+1,jj,jk) - rhd (ji,jj,jk) - z1_12 * ( drhou(ji+1,jj,jk) + drhou(ji,jj,jk) ) ) & |
---|
875 | & ) |
---|
876 | |
---|
877 | rho_j(ji,jj,jk) = zcoef0 * ( rhd (ji,jj+1,jk) + rhd (ji,jj,jk) ) & |
---|
878 | & * ( fsde3w(ji,jj+1,jk) - fsde3w(ji,jj,jk) ) & |
---|
879 | & - grav* z1_10 * ( & |
---|
880 | & ( drhov (ji,jj+1,jk) - drhov (ji,jj,jk) ) & |
---|
881 | & * ( fsde3w(ji,jj+1,jk) - fsde3w(ji,jj,jk) - z1_12 * ( dzv (ji,jj+1,jk) + dzv (ji,jj,jk) ) ) & |
---|
882 | & - ( dzv (ji,jj+1,jk) - dzv (ji,jj,jk) ) & |
---|
883 | & * ( rhd (ji,jj+1,jk) - rhd (ji,jj,jk) - z1_12 * ( drhov(ji,jj+1,jk) + drhov(ji,jj,jk) ) ) & |
---|
884 | & ) |
---|
885 | |
---|
886 | END DO |
---|
887 | END DO |
---|
888 | END DO |
---|
889 | CALL lbc_lnk(rho_k,'W',1.) |
---|
890 | CALL lbc_lnk(rho_i,'U',1.) |
---|
891 | CALL lbc_lnk(rho_j,'V',1.) |
---|
892 | |
---|
893 | |
---|
894 | ! --------------- |
---|
895 | ! Surface value |
---|
896 | ! --------------- |
---|
897 | DO jj = 2, jpjm1 |
---|
898 | DO ji = fs_2, fs_jpim1 ! vector opt. |
---|
899 | zhpi(ji,jj,1) = ( rho_k(ji+1,jj ,1) - rho_k(ji,jj,1) - rho_i(ji,jj,1) ) / e1u(ji,jj) |
---|
900 | zhpj(ji,jj,1) = ( rho_k(ji ,jj+1,1) - rho_k(ji,jj,1) - rho_j(ji,jj,1) ) / e2v(ji,jj) |
---|
901 | ! add to the general momentum trend |
---|
902 | ua(ji,jj,1) = ua(ji,jj,1) + zhpi(ji,jj,1) |
---|
903 | va(ji,jj,1) = va(ji,jj,1) + zhpj(ji,jj,1) |
---|
904 | END DO |
---|
905 | END DO |
---|
906 | |
---|
907 | ! ---------------- |
---|
908 | ! interior value (2=<jk=<jpkm1) |
---|
909 | ! ---------------- |
---|
910 | DO jk = 2, jpkm1 |
---|
911 | DO jj = 2, jpjm1 |
---|
912 | DO ji = fs_2, fs_jpim1 ! vector opt. |
---|
913 | ! hydrostatic pressure gradient along s-surfaces |
---|
914 | zhpi(ji,jj,jk) = zhpi(ji,jj,jk-1) & |
---|
915 | & + ( ( rho_k(ji+1,jj,jk) - rho_k(ji,jj,jk ) ) & |
---|
916 | & - ( rho_i(ji ,jj,jk) - rho_i(ji,jj,jk-1) ) ) / e1u(ji,jj) |
---|
917 | zhpj(ji,jj,jk) = zhpj(ji,jj,jk-1) & |
---|
918 | & + ( ( rho_k(ji,jj+1,jk) - rho_k(ji,jj,jk ) ) & |
---|
919 | & -( rho_j(ji,jj ,jk) - rho_j(ji,jj,jk-1) ) ) / e2v(ji,jj) |
---|
920 | ! add to the general momentum trend |
---|
921 | ua(ji,jj,jk) = ua(ji,jj,jk) + zhpi(ji,jj,jk) |
---|
922 | va(ji,jj,jk) = va(ji,jj,jk) + zhpj(ji,jj,jk) |
---|
923 | END DO |
---|
924 | END DO |
---|
925 | END DO |
---|
926 | ! |
---|
927 | CALL wrk_dealloc( jpi, jpj, jpk, dzx , dzy , dzz , dzu , dzv , dzw ) |
---|
928 | CALL wrk_dealloc( jpi, jpj, jpk, drhox, drhoy, drhoz, drhou, drhov, drhow ) |
---|
929 | CALL wrk_dealloc( jpi, jpj, jpk, rho_i, rho_j, rho_k, zhpi, zhpj ) |
---|
930 | ! |
---|
931 | END SUBROUTINE hpg_djc |
---|
932 | |
---|
933 | |
---|
934 | SUBROUTINE hpg_prj( kt ) |
---|
935 | !!--------------------------------------------------------------------- |
---|
936 | !! *** ROUTINE hpg_prj *** |
---|
937 | !! |
---|
938 | !! ** Method : s-coordinate case. |
---|
939 | !! A Pressure-Jacobian horizontal pressure gradient method |
---|
940 | !! based on the constrained cubic-spline interpolation for |
---|
941 | !! all vertical coordinate systems |
---|
942 | !! |
---|
943 | !! ** Action : - Update (ua,va) with the now hydrastatic pressure trend |
---|
944 | !!---------------------------------------------------------------------- |
---|
945 | INTEGER, PARAMETER :: polynomial_type = 1 ! 1: cubic spline, 2: linear |
---|
946 | INTEGER, INTENT(in) :: kt ! ocean time-step index |
---|
947 | !! |
---|
948 | INTEGER :: ji, jj, jk, jkk ! dummy loop indices |
---|
949 | REAL(wp) :: zcoef0, znad ! temporary scalars |
---|
950 | !! |
---|
951 | !! The local variables for the correction term |
---|
952 | INTEGER :: jk1, jis, jid, jjs, jjd |
---|
953 | REAL(wp) :: zuijk, zvijk, zpwes, zpwed, zpnss, zpnsd, zdeps |
---|
954 | REAL(wp) :: zrhdt1 |
---|
955 | REAL(wp) :: zdpdx1, zdpdx2, zdpdy1, zdpdy2 |
---|
956 | REAL(wp), POINTER, DIMENSION(:,:,:) :: zdept, zrhh |
---|
957 | REAL(wp), POINTER, DIMENSION(:,:,:) :: zhpi, zu, zv, fsp, xsp, asp, bsp, csp, dsp |
---|
958 | REAL(wp), POINTER, DIMENSION(:,:) :: zsshu_n, zsshv_n |
---|
959 | !!---------------------------------------------------------------------- |
---|
960 | ! |
---|
961 | CALL wrk_alloc( jpi,jpj,jpk, zhpi, zu, zv, fsp, xsp, asp, bsp, csp, dsp ) |
---|
962 | CALL wrk_alloc( jpi,jpj,jpk, zdept, zrhh ) |
---|
963 | CALL wrk_alloc( jpi,jpj, zsshu_n, zsshv_n ) |
---|
964 | ! |
---|
965 | IF( kt == nit000 ) THEN |
---|
966 | IF(lwp) WRITE(numout,*) |
---|
967 | IF(lwp) WRITE(numout,*) 'dyn:hpg_prj : hydrostatic pressure gradient trend' |
---|
968 | IF(lwp) WRITE(numout,*) '~~~~~~~~~~~ s-coordinate case, cubic spline pressure Jacobian' |
---|
969 | ENDIF |
---|
970 | |
---|
971 | !!---------------------------------------------------------------------- |
---|
972 | ! Local constant initialization |
---|
973 | zcoef0 = - grav |
---|
974 | znad = 0.0_wp |
---|
975 | IF( lk_vvl ) znad = 1._wp |
---|
976 | |
---|
977 | ! Clean 3-D work arrays |
---|
978 | zhpi(:,:,:) = 0._wp |
---|
979 | zrhh(:,:,:) = rhd(:,:,:) |
---|
980 | |
---|
981 | ! Preparing vertical density profile "zrhh(:,:,:)" for hybrid-sco coordinate |
---|
982 | DO jj = 1, jpj |
---|
983 | DO ji = 1, jpi |
---|
984 | jk = mbathy(ji,jj) |
---|
985 | IF( jk <= 0 ) THEN; zrhh(ji,jj,:) = 0._wp |
---|
986 | ELSE IF(jk == 1) THEN; zrhh(ji,jj, jk+1:jpk) = rhd(ji,jj,jk) |
---|
987 | ELSE IF(jk < jpkm1) THEN |
---|
988 | DO jkk = jk+1, jpk |
---|
989 | zrhh(ji,jj,jkk) = interp1(fsde3w(ji,jj,jkk), fsde3w(ji,jj,jkk-1), & |
---|
990 | fsde3w(ji,jj,jkk-2), rhd(ji,jj,jkk-1), rhd(ji,jj,jkk-2)) |
---|
991 | END DO |
---|
992 | ENDIF |
---|
993 | END DO |
---|
994 | END DO |
---|
995 | |
---|
996 | ! Transfer the depth of "T(:,:,:)" to vertical coordinate "zdept(:,:,:)" |
---|
997 | DO jj = 1, jpj |
---|
998 | DO ji = 1, jpi |
---|
999 | zdept(ji,jj,1) = 0.5_wp * fse3w(ji,jj,1) - sshn(ji,jj) * znad |
---|
1000 | END DO |
---|
1001 | END DO |
---|
1002 | |
---|
1003 | DO jk = 2, jpk |
---|
1004 | DO jj = 1, jpj |
---|
1005 | DO ji = 1, jpi |
---|
1006 | zdept(ji,jj,jk) = zdept(ji,jj,jk-1) + fse3w(ji,jj,jk) |
---|
1007 | END DO |
---|
1008 | END DO |
---|
1009 | END DO |
---|
1010 | |
---|
1011 | fsp(:,:,:) = zrhh (:,:,:) |
---|
1012 | xsp(:,:,:) = zdept(:,:,:) |
---|
1013 | |
---|
1014 | ! Construct the vertical density profile with the |
---|
1015 | ! constrained cubic spline interpolation |
---|
1016 | ! rho(z) = asp + bsp*z + csp*z^2 + dsp*z^3 |
---|
1017 | CALL cspline(fsp,xsp,asp,bsp,csp,dsp,polynomial_type) |
---|
1018 | |
---|
1019 | ! Integrate the hydrostatic pressure "zhpi(:,:,:)" at "T(ji,jj,1)" |
---|
1020 | DO jj = 2, jpj |
---|
1021 | DO ji = 2, jpi |
---|
1022 | zrhdt1 = zrhh(ji,jj,1) - interp3(zdept(ji,jj,1),asp(ji,jj,1), & |
---|
1023 | bsp(ji,jj,1), csp(ji,jj,1), & |
---|
1024 | dsp(ji,jj,1) ) * 0.25_wp * fse3w(ji,jj,1) |
---|
1025 | |
---|
1026 | ! assuming linear profile across the top half surface layer |
---|
1027 | zhpi(ji,jj,1) = 0.5_wp * fse3w(ji,jj,1) * zrhdt1 |
---|
1028 | END DO |
---|
1029 | END DO |
---|
1030 | |
---|
1031 | ! Calculate the pressure "zhpi(:,:,:)" at "T(ji,jj,2:jpkm1)" |
---|
1032 | DO jk = 2, jpkm1 |
---|
1033 | DO jj = 2, jpj |
---|
1034 | DO ji = 2, jpi |
---|
1035 | zhpi(ji,jj,jk) = zhpi(ji,jj,jk-1) + & |
---|
1036 | integ_spline(zdept(ji,jj,jk-1), zdept(ji,jj,jk),& |
---|
1037 | asp(ji,jj,jk-1), bsp(ji,jj,jk-1), & |
---|
1038 | csp(ji,jj,jk-1), dsp(ji,jj,jk-1)) |
---|
1039 | END DO |
---|
1040 | END DO |
---|
1041 | END DO |
---|
1042 | |
---|
1043 | ! Z coordinate of U(ji,jj,1:jpkm1) and V(ji,jj,1:jpkm1) |
---|
1044 | |
---|
1045 | ! Prepare zsshu_n and zsshv_n |
---|
1046 | DO jj = 2, jpjm1 |
---|
1047 | DO ji = 2, jpim1 |
---|
1048 | zsshu_n(ji,jj) = (e12u(ji,jj) * sshn(ji,jj) + e12u(ji+1, jj) * sshn(ji+1,jj)) * & |
---|
1049 | & r1_e12u(ji,jj) * umask(ji,jj,1) * 0.5_wp |
---|
1050 | zsshv_n(ji,jj) = (e12v(ji,jj) * sshn(ji,jj) + e12v(ji+1, jj) * sshn(ji,jj+1)) * & |
---|
1051 | & r1_e12v(ji,jj) * vmask(ji,jj,1) * 0.5_wp |
---|
1052 | END DO |
---|
1053 | END DO |
---|
1054 | |
---|
1055 | DO jj = 2, jpjm1 |
---|
1056 | DO ji = 2, jpim1 |
---|
1057 | zu(ji,jj,1) = - ( fse3u(ji,jj,1) - zsshu_n(ji,jj) * znad) |
---|
1058 | zv(ji,jj,1) = - ( fse3v(ji,jj,1) - zsshv_n(ji,jj) * znad) |
---|
1059 | END DO |
---|
1060 | END DO |
---|
1061 | |
---|
1062 | DO jk = 2, jpkm1 |
---|
1063 | DO jj = 2, jpjm1 |
---|
1064 | DO ji = 2, jpim1 |
---|
1065 | zu(ji,jj,jk) = zu(ji,jj,jk-1)- fse3u(ji,jj,jk) |
---|
1066 | zv(ji,jj,jk) = zv(ji,jj,jk-1)- fse3v(ji,jj,jk) |
---|
1067 | END DO |
---|
1068 | END DO |
---|
1069 | END DO |
---|
1070 | |
---|
1071 | DO jk = 1, jpkm1 |
---|
1072 | DO jj = 2, jpjm1 |
---|
1073 | DO ji = 2, jpim1 |
---|
1074 | zu(ji,jj,jk) = zu(ji,jj,jk) + 0.5_wp * fse3u(ji,jj,jk) |
---|
1075 | zv(ji,jj,jk) = zv(ji,jj,jk) + 0.5_wp * fse3v(ji,jj,jk) |
---|
1076 | END DO |
---|
1077 | END DO |
---|
1078 | END DO |
---|
1079 | |
---|
1080 | DO jk = 1, jpkm1 |
---|
1081 | DO jj = 2, jpjm1 |
---|
1082 | DO ji = 2, jpim1 |
---|
1083 | zu(ji,jj,jk) = min(zu(ji,jj,jk), max(-zdept(ji,jj,jk), -zdept(ji+1,jj,jk))) |
---|
1084 | zu(ji,jj,jk) = max(zu(ji,jj,jk), min(-zdept(ji,jj,jk), -zdept(ji+1,jj,jk))) |
---|
1085 | zv(ji,jj,jk) = min(zv(ji,jj,jk), max(-zdept(ji,jj,jk), -zdept(ji,jj+1,jk))) |
---|
1086 | zv(ji,jj,jk) = max(zv(ji,jj,jk), min(-zdept(ji,jj,jk), -zdept(ji,jj+1,jk))) |
---|
1087 | END DO |
---|
1088 | END DO |
---|
1089 | END DO |
---|
1090 | |
---|
1091 | |
---|
1092 | DO jk = 1, jpkm1 |
---|
1093 | DO jj = 2, jpjm1 |
---|
1094 | DO ji = 2, jpim1 |
---|
1095 | zpwes = 0._wp; zpwed = 0._wp |
---|
1096 | zpnss = 0._wp; zpnsd = 0._wp |
---|
1097 | zuijk = zu(ji,jj,jk) |
---|
1098 | zvijk = zv(ji,jj,jk) |
---|
1099 | |
---|
1100 | !!!!! for u equation |
---|
1101 | IF( jk <= mbku(ji,jj) ) THEN |
---|
1102 | IF( -zdept(ji+1,jj,jk) >= -zdept(ji,jj,jk) ) THEN |
---|
1103 | jis = ji + 1; jid = ji |
---|
1104 | ELSE |
---|
1105 | jis = ji; jid = ji +1 |
---|
1106 | ENDIF |
---|
1107 | |
---|
1108 | ! integrate the pressure on the shallow side |
---|
1109 | jk1 = jk |
---|
1110 | DO WHILE ( -zdept(jis,jj,jk1) > zuijk ) |
---|
1111 | IF( jk1 == mbku(ji,jj) ) THEN |
---|
1112 | zuijk = -zdept(jis,jj,jk1) |
---|
1113 | EXIT |
---|
1114 | ENDIF |
---|
1115 | zdeps = MIN(zdept(jis,jj,jk1+1), -zuijk) |
---|
1116 | zpwes = zpwes + & |
---|
1117 | integ_spline(zdept(jis,jj,jk1), zdeps, & |
---|
1118 | asp(jis,jj,jk1), bsp(jis,jj,jk1), & |
---|
1119 | csp(jis,jj,jk1), dsp(jis,jj,jk1)) |
---|
1120 | jk1 = jk1 + 1 |
---|
1121 | END DO |
---|
1122 | |
---|
1123 | ! integrate the pressure on the deep side |
---|
1124 | jk1 = jk |
---|
1125 | DO WHILE ( -zdept(jid,jj,jk1) < zuijk ) |
---|
1126 | IF( jk1 == 1 ) THEN |
---|
1127 | zdeps = zdept(jid,jj,1) + MIN(zuijk, sshn(jid,jj)*znad) |
---|
1128 | zrhdt1 = zrhh(jid,jj,1) - interp3(zdept(jid,jj,1), asp(jid,jj,1), & |
---|
1129 | bsp(jid,jj,1), csp(jid,jj,1), & |
---|
1130 | dsp(jid,jj,1)) * zdeps |
---|
1131 | zpwed = zpwed + 0.5_wp * (zrhh(jid,jj,1) + zrhdt1) * zdeps |
---|
1132 | EXIT |
---|
1133 | ENDIF |
---|
1134 | zdeps = MAX(zdept(jid,jj,jk1-1), -zuijk) |
---|
1135 | zpwed = zpwed + & |
---|
1136 | integ_spline(zdeps, zdept(jid,jj,jk1), & |
---|
1137 | asp(jid,jj,jk1-1), bsp(jid,jj,jk1-1), & |
---|
1138 | csp(jid,jj,jk1-1), dsp(jid,jj,jk1-1) ) |
---|
1139 | jk1 = jk1 - 1 |
---|
1140 | END DO |
---|
1141 | |
---|
1142 | ! update the momentum trends in u direction |
---|
1143 | |
---|
1144 | zdpdx1 = zcoef0 / e1u(ji,jj) * (zhpi(ji+1,jj,jk) - zhpi(ji,jj,jk)) |
---|
1145 | IF( lk_vvl ) THEN |
---|
1146 | zdpdx2 = zcoef0 / e1u(ji,jj) * & |
---|
1147 | ( REAL(jis-jid, wp) * (zpwes + zpwed) + (sshn(ji+1,jj)-sshn(ji,jj)) ) |
---|
1148 | ELSE |
---|
1149 | zdpdx2 = zcoef0 / e1u(ji,jj) * REAL(jis-jid, wp) * (zpwes + zpwed) |
---|
1150 | ENDIF |
---|
1151 | |
---|
1152 | ua(ji,jj,jk) = ua(ji,jj,jk) + (zdpdx1 + zdpdx2) * & |
---|
1153 | & umask(ji,jj,jk) * tmask(ji,jj,jk) * tmask(ji+1,jj,jk) |
---|
1154 | ENDIF |
---|
1155 | |
---|
1156 | !!!!! for v equation |
---|
1157 | IF( jk <= mbkv(ji,jj) ) THEN |
---|
1158 | IF( -zdept(ji,jj+1,jk) >= -zdept(ji,jj,jk) ) THEN |
---|
1159 | jjs = jj + 1; jjd = jj |
---|
1160 | ELSE |
---|
1161 | jjs = jj ; jjd = jj + 1 |
---|
1162 | ENDIF |
---|
1163 | |
---|
1164 | ! integrate the pressure on the shallow side |
---|
1165 | jk1 = jk |
---|
1166 | DO WHILE ( -zdept(ji,jjs,jk1) > zvijk ) |
---|
1167 | IF( jk1 == mbkv(ji,jj) ) THEN |
---|
1168 | zvijk = -zdept(ji,jjs,jk1) |
---|
1169 | EXIT |
---|
1170 | ENDIF |
---|
1171 | zdeps = MIN(zdept(ji,jjs,jk1+1), -zvijk) |
---|
1172 | zpnss = zpnss + & |
---|
1173 | integ_spline(zdept(ji,jjs,jk1), zdeps, & |
---|
1174 | asp(ji,jjs,jk1), bsp(ji,jjs,jk1), & |
---|
1175 | csp(ji,jjs,jk1), dsp(ji,jjs,jk1) ) |
---|
1176 | jk1 = jk1 + 1 |
---|
1177 | END DO |
---|
1178 | |
---|
1179 | ! integrate the pressure on the deep side |
---|
1180 | jk1 = jk |
---|
1181 | DO WHILE ( -zdept(ji,jjd,jk1) < zvijk ) |
---|
1182 | IF( jk1 == 1 ) THEN |
---|
1183 | zdeps = zdept(ji,jjd,1) + MIN(zvijk, sshn(ji,jjd)*znad) |
---|
1184 | zrhdt1 = zrhh(ji,jjd,1) - interp3(zdept(ji,jjd,1), asp(ji,jjd,1), & |
---|
1185 | bsp(ji,jjd,1), csp(ji,jjd,1), & |
---|
1186 | dsp(ji,jjd,1) ) * zdeps |
---|
1187 | zpnsd = zpnsd + 0.5_wp * (zrhh(ji,jjd,1) + zrhdt1) * zdeps |
---|
1188 | EXIT |
---|
1189 | ENDIF |
---|
1190 | zdeps = MAX(zdept(ji,jjd,jk1-1), -zvijk) |
---|
1191 | zpnsd = zpnsd + & |
---|
1192 | integ_spline(zdeps, zdept(ji,jjd,jk1), & |
---|
1193 | asp(ji,jjd,jk1-1), bsp(ji,jjd,jk1-1), & |
---|
1194 | csp(ji,jjd,jk1-1), dsp(ji,jjd,jk1-1) ) |
---|
1195 | jk1 = jk1 - 1 |
---|
1196 | END DO |
---|
1197 | |
---|
1198 | |
---|
1199 | ! update the momentum trends in v direction |
---|
1200 | |
---|
1201 | zdpdy1 = zcoef0 / e2v(ji,jj) * (zhpi(ji,jj+1,jk) - zhpi(ji,jj,jk)) |
---|
1202 | IF( lk_vvl ) THEN |
---|
1203 | zdpdy2 = zcoef0 / e2v(ji,jj) * & |
---|
1204 | ( REAL(jjs-jjd, wp) * (zpnss + zpnsd) + (sshn(ji,jj+1)-sshn(ji,jj)) ) |
---|
1205 | ELSE |
---|
1206 | zdpdy2 = zcoef0 / e2v(ji,jj) * REAL(jjs-jjd, wp) * (zpnss + zpnsd ) |
---|
1207 | ENDIF |
---|
1208 | |
---|
1209 | va(ji,jj,jk) = va(ji,jj,jk) + (zdpdy1 + zdpdy2)*& |
---|
1210 | & vmask(ji,jj,jk)*tmask(ji,jj,jk)*tmask(ji,jj+1,jk) |
---|
1211 | ENDIF |
---|
1212 | |
---|
1213 | |
---|
1214 | END DO |
---|
1215 | END DO |
---|
1216 | END DO |
---|
1217 | ! |
---|
1218 | CALL wrk_dealloc( jpi,jpj,jpk, zhpi, zu, zv, fsp, xsp, asp, bsp, csp, dsp ) |
---|
1219 | CALL wrk_dealloc( jpi,jpj,jpk, zdept, zrhh ) |
---|
1220 | CALL wrk_dealloc( jpi,jpj, zsshu_n, zsshv_n ) |
---|
1221 | ! |
---|
1222 | END SUBROUTINE hpg_prj |
---|
1223 | |
---|
1224 | |
---|
1225 | SUBROUTINE cspline(fsp, xsp, asp, bsp, csp, dsp, polynomial_type) |
---|
1226 | !!---------------------------------------------------------------------- |
---|
1227 | !! *** ROUTINE cspline *** |
---|
1228 | !! |
---|
1229 | !! ** Purpose : constrained cubic spline interpolation |
---|
1230 | !! |
---|
1231 | !! ** Method : f(x) = asp + bsp*x + csp*x^2 + dsp*x^3 |
---|
1232 | !! |
---|
1233 | !! Reference: CJC Kruger, Constrained Cubic Spline Interpoltation |
---|
1234 | !!---------------------------------------------------------------------- |
---|
1235 | IMPLICIT NONE |
---|
1236 | REAL(wp), DIMENSION(:,:,:), INTENT(in) :: fsp, xsp ! value and coordinate |
---|
1237 | REAL(wp), DIMENSION(:,:,:), INTENT(out) :: asp, bsp, csp, dsp ! coefficients of |
---|
1238 | ! the interpoated function |
---|
1239 | INTEGER, INTENT(in) :: polynomial_type ! 1: cubic spline |
---|
1240 | ! 2: Linear |
---|
1241 | ! |
---|
1242 | INTEGER :: ji, jj, jk ! dummy loop indices |
---|
1243 | INTEGER :: jpi, jpj, jpkm1 |
---|
1244 | REAL(wp) :: zdf1, zdf2, zddf1, zddf2, ztmp1, ztmp2, zdxtmp |
---|
1245 | REAL(wp) :: zdxtmp1, zdxtmp2, zalpha |
---|
1246 | REAL(wp) :: zdf(size(fsp,3)) |
---|
1247 | !!---------------------------------------------------------------------- |
---|
1248 | |
---|
1249 | jpi = size(fsp,1) |
---|
1250 | jpj = size(fsp,2) |
---|
1251 | jpkm1 = size(fsp,3) - 1 |
---|
1252 | |
---|
1253 | |
---|
1254 | IF (polynomial_type == 1) THEN ! Constrained Cubic Spline |
---|
1255 | DO ji = 1, jpi |
---|
1256 | DO jj = 1, jpj |
---|
1257 | !!Fritsch&Butland's method, 1984 (preferred, but more computation) |
---|
1258 | ! DO jk = 2, jpkm1-1 |
---|
1259 | ! zdxtmp1 = xsp(ji,jj,jk) - xsp(ji,jj,jk-1) |
---|
1260 | ! zdxtmp2 = xsp(ji,jj,jk+1) - xsp(ji,jj,jk) |
---|
1261 | ! zdf1 = ( fsp(ji,jj,jk) - fsp(ji,jj,jk-1) ) / zdxtmp1 |
---|
1262 | ! zdf2 = ( fsp(ji,jj,jk+1) - fsp(ji,jj,jk) ) / zdxtmp2 |
---|
1263 | ! |
---|
1264 | ! zalpha = ( zdxtmp1 + 2._wp * zdxtmp2 ) / ( zdxtmp1 + zdxtmp2 ) / 3._wp |
---|
1265 | ! |
---|
1266 | ! IF(zdf1 * zdf2 <= 0._wp) THEN |
---|
1267 | ! zdf(jk) = 0._wp |
---|
1268 | ! ELSE |
---|
1269 | ! zdf(jk) = zdf1 * zdf2 / ( ( 1._wp - zalpha ) * zdf1 + zalpha * zdf2 ) |
---|
1270 | ! ENDIF |
---|
1271 | ! END DO |
---|
1272 | |
---|
1273 | !!Simply geometric average |
---|
1274 | DO jk = 2, jpkm1-1 |
---|
1275 | zdf1 = (fsp(ji,jj,jk) - fsp(ji,jj,jk-1)) / (xsp(ji,jj,jk) - xsp(ji,jj,jk-1)) |
---|
1276 | zdf2 = (fsp(ji,jj,jk+1) - fsp(ji,jj,jk)) / (xsp(ji,jj,jk+1) - xsp(ji,jj,jk)) |
---|
1277 | |
---|
1278 | IF(zdf1 * zdf2 <= 0._wp) THEN |
---|
1279 | zdf(jk) = 0._wp |
---|
1280 | ELSE |
---|
1281 | zdf(jk) = 2._wp * zdf1 * zdf2 / (zdf1 + zdf2) |
---|
1282 | ENDIF |
---|
1283 | END DO |
---|
1284 | |
---|
1285 | zdf(1) = 1.5_wp * ( fsp(ji,jj,2) - fsp(ji,jj,1) ) / & |
---|
1286 | & ( xsp(ji,jj,2) - xsp(ji,jj,1) ) - 0.5_wp * zdf(2) |
---|
1287 | zdf(jpkm1) = 1.5_wp * ( fsp(ji,jj,jpkm1) - fsp(ji,jj,jpkm1-1) ) / & |
---|
1288 | & ( xsp(ji,jj,jpkm1) - xsp(ji,jj,jpkm1-1) ) - & |
---|
1289 | & 0.5_wp * zdf(jpkm1 - 1) |
---|
1290 | |
---|
1291 | DO jk = 1, jpkm1 - 1 |
---|
1292 | zdxtmp = xsp(ji,jj,jk+1) - xsp(ji,jj,jk) |
---|
1293 | ztmp1 = (zdf(jk+1) + 2._wp * zdf(jk)) / zdxtmp |
---|
1294 | ztmp2 = 6._wp * (fsp(ji,jj,jk+1) - fsp(ji,jj,jk)) / zdxtmp / zdxtmp |
---|
1295 | zddf1 = -2._wp * ztmp1 + ztmp2 |
---|
1296 | ztmp1 = (2._wp * zdf(jk+1) + zdf(jk)) / zdxtmp |
---|
1297 | zddf2 = 2._wp * ztmp1 - ztmp2 |
---|
1298 | |
---|
1299 | dsp(ji,jj,jk) = (zddf2 - zddf1) / 6._wp / zdxtmp |
---|
1300 | csp(ji,jj,jk) = ( xsp(ji,jj,jk+1) * zddf1 - xsp(ji,jj,jk)*zddf2 ) / 2._wp / zdxtmp |
---|
1301 | bsp(ji,jj,jk) = ( fsp(ji,jj,jk+1) - fsp(ji,jj,jk) ) / zdxtmp - & |
---|
1302 | & csp(ji,jj,jk) * ( xsp(ji,jj,jk+1) + xsp(ji,jj,jk) ) - & |
---|
1303 | & dsp(ji,jj,jk) * ((xsp(ji,jj,jk+1) + xsp(ji,jj,jk))**2 - & |
---|
1304 | & xsp(ji,jj,jk+1) * xsp(ji,jj,jk)) |
---|
1305 | asp(ji,jj,jk) = fsp(ji,jj,jk) - xsp(ji,jj,jk) * (bsp(ji,jj,jk) + & |
---|
1306 | & (xsp(ji,jj,jk) * (csp(ji,jj,jk) + & |
---|
1307 | & dsp(ji,jj,jk) * xsp(ji,jj,jk)))) |
---|
1308 | END DO |
---|
1309 | END DO |
---|
1310 | END DO |
---|
1311 | |
---|
1312 | ELSE IF (polynomial_type == 2) THEN ! Linear |
---|
1313 | DO ji = 1, jpi |
---|
1314 | DO jj = 1, jpj |
---|
1315 | DO jk = 1, jpkm1-1 |
---|
1316 | zdxtmp =xsp(ji,jj,jk+1) - xsp(ji,jj,jk) |
---|
1317 | ztmp1 = fsp(ji,jj,jk+1) - fsp(ji,jj,jk) |
---|
1318 | |
---|
1319 | dsp(ji,jj,jk) = 0._wp |
---|
1320 | csp(ji,jj,jk) = 0._wp |
---|
1321 | bsp(ji,jj,jk) = ztmp1 / zdxtmp |
---|
1322 | asp(ji,jj,jk) = fsp(ji,jj,jk) - bsp(ji,jj,jk) * xsp(ji,jj,jk) |
---|
1323 | END DO |
---|
1324 | END DO |
---|
1325 | END DO |
---|
1326 | |
---|
1327 | ELSE |
---|
1328 | CALL ctl_stop( 'invalid polynomial type in cspline' ) |
---|
1329 | ENDIF |
---|
1330 | |
---|
1331 | END SUBROUTINE cspline |
---|
1332 | |
---|
1333 | |
---|
1334 | FUNCTION interp1(x, xl, xr, fl, fr) RESULT(f) |
---|
1335 | !!---------------------------------------------------------------------- |
---|
1336 | !! *** ROUTINE interp1 *** |
---|
1337 | !! |
---|
1338 | !! ** Purpose : 1-d linear interpolation |
---|
1339 | !! |
---|
1340 | !! ** Method : interpolation is straight forward |
---|
1341 | !! extrapolation is also permitted (no value limit) |
---|
1342 | !!---------------------------------------------------------------------- |
---|
1343 | IMPLICIT NONE |
---|
1344 | REAL(wp), INTENT(in) :: x, xl, xr, fl, fr |
---|
1345 | REAL(wp) :: f ! result of the interpolation (extrapolation) |
---|
1346 | REAL(wp) :: zdeltx |
---|
1347 | !!---------------------------------------------------------------------- |
---|
1348 | |
---|
1349 | zdeltx = xr - xl |
---|
1350 | IF(abs(zdeltx) <= 10._wp * EPSILON(x)) THEN |
---|
1351 | f = 0.5_wp * (fl + fr) |
---|
1352 | ELSE |
---|
1353 | f = ( (x - xl ) * fr - ( x - xr ) * fl ) / zdeltx |
---|
1354 | ENDIF |
---|
1355 | |
---|
1356 | END FUNCTION interp1 |
---|
1357 | |
---|
1358 | |
---|
1359 | FUNCTION interp2(x, a, b, c, d) RESULT(f) |
---|
1360 | !!---------------------------------------------------------------------- |
---|
1361 | !! *** ROUTINE interp1 *** |
---|
1362 | !! |
---|
1363 | !! ** Purpose : 1-d constrained cubic spline interpolation |
---|
1364 | !! |
---|
1365 | !! ** Method : cubic spline interpolation |
---|
1366 | !! |
---|
1367 | !!---------------------------------------------------------------------- |
---|
1368 | IMPLICIT NONE |
---|
1369 | REAL(wp), INTENT(in) :: x, a, b, c, d |
---|
1370 | REAL(wp) :: f ! value from the interpolation |
---|
1371 | !!---------------------------------------------------------------------- |
---|
1372 | |
---|
1373 | f = a + x* ( b + x * ( c + d * x ) ) |
---|
1374 | |
---|
1375 | END FUNCTION interp2 |
---|
1376 | |
---|
1377 | |
---|
1378 | FUNCTION interp3(x, a, b, c, d) RESULT(f) |
---|
1379 | !!---------------------------------------------------------------------- |
---|
1380 | !! *** ROUTINE interp1 *** |
---|
1381 | !! |
---|
1382 | !! ** Purpose : Calculate the first order of deriavtive of |
---|
1383 | !! a cubic spline function y=a+b*x+c*x^2+d*x^3 |
---|
1384 | !! |
---|
1385 | !! ** Method : f=dy/dx=b+2*c*x+3*d*x^2 |
---|
1386 | !! |
---|
1387 | !!---------------------------------------------------------------------- |
---|
1388 | IMPLICIT NONE |
---|
1389 | REAL(wp), INTENT(in) :: x, a, b, c, d |
---|
1390 | REAL(wp) :: f ! value from the interpolation |
---|
1391 | !!---------------------------------------------------------------------- |
---|
1392 | |
---|
1393 | f = b + x * ( 2._wp * c + 3._wp * d * x) |
---|
1394 | |
---|
1395 | END FUNCTION interp3 |
---|
1396 | |
---|
1397 | |
---|
1398 | FUNCTION integ_spline(xl, xr, a, b, c, d) RESULT(f) |
---|
1399 | !!---------------------------------------------------------------------- |
---|
1400 | !! *** ROUTINE interp1 *** |
---|
1401 | !! |
---|
1402 | !! ** Purpose : 1-d constrained cubic spline integration |
---|
1403 | !! |
---|
1404 | !! ** Method : integrate polynomial a+bx+cx^2+dx^3 from xl to xr |
---|
1405 | !! |
---|
1406 | !!---------------------------------------------------------------------- |
---|
1407 | IMPLICIT NONE |
---|
1408 | REAL(wp), INTENT(in) :: xl, xr, a, b, c, d |
---|
1409 | REAL(wp) :: za1, za2, za3 |
---|
1410 | REAL(wp) :: f ! integration result |
---|
1411 | !!---------------------------------------------------------------------- |
---|
1412 | |
---|
1413 | za1 = 0.5_wp * b |
---|
1414 | za2 = c / 3.0_wp |
---|
1415 | za3 = 0.25_wp * d |
---|
1416 | |
---|
1417 | f = xr * ( a + xr * ( za1 + xr * ( za2 + za3 * xr ) ) ) - & |
---|
1418 | & xl * ( a + xl * ( za1 + xl * ( za2 + za3 * xl ) ) ) |
---|
1419 | |
---|
1420 | END FUNCTION integ_spline |
---|
1421 | |
---|
1422 | !!====================================================================== |
---|
1423 | END MODULE dynhpg |
---|
1424 | |
---|