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