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 | !!---------------------------------------------------------------------- |
---|
959 | ! |
---|
960 | CALL wrk_alloc( jpi,jpj,jpk, zhpi, zu, zv, fsp, xsp, asp, bsp, csp, dsp ) |
---|
961 | CALL wrk_alloc( jpi,jpj,jpk, zdept, zrhh ) |
---|
962 | ! |
---|
963 | IF( kt == nit000 ) THEN |
---|
964 | IF(lwp) WRITE(numout,*) |
---|
965 | IF(lwp) WRITE(numout,*) 'dyn:hpg_prj : hydrostatic pressure gradient trend' |
---|
966 | IF(lwp) WRITE(numout,*) '~~~~~~~~~~~ s-coordinate case, cubic spline pressure Jacobian' |
---|
967 | ENDIF |
---|
968 | |
---|
969 | !!---------------------------------------------------------------------- |
---|
970 | ! Local constant initialization |
---|
971 | zcoef0 = - grav |
---|
972 | znad = 0.0_wp |
---|
973 | IF( lk_vvl ) znad = 1._wp |
---|
974 | |
---|
975 | ! Clean 3-D work arrays |
---|
976 | zhpi(:,:,:) = 0._wp |
---|
977 | zrhh(:,:,:) = rhd(:,:,:) |
---|
978 | |
---|
979 | ! Preparing vertical density profile "zrhh(:,:,:)" for hybrid-sco coordinate |
---|
980 | DO jj = 1, jpj |
---|
981 | DO ji = 1, jpi |
---|
982 | jk = mbathy(ji,jj) |
---|
983 | IF( jk <= 0 ) THEN; zrhh(ji,jj,:) = 0._wp |
---|
984 | ELSE IF(jk == 1) THEN; zrhh(ji,jj, jk+1:jpk) = rhd(ji,jj,jk) |
---|
985 | ELSE IF(jk < jpkm1) THEN |
---|
986 | DO jkk = jk+1, jpk |
---|
987 | zrhh(ji,jj,jkk) = interp1(fsde3w(ji,jj,jkk), fsde3w(ji,jj,jkk-1), & |
---|
988 | fsde3w(ji,jj,jkk-2), rhd(ji,jj,jkk-1), rhd(ji,jj,jkk-2)) |
---|
989 | END DO |
---|
990 | ENDIF |
---|
991 | END DO |
---|
992 | END DO |
---|
993 | |
---|
994 | ! Transfer the depth of "T(:,:,:)" to vertical coordinate "zdept(:,:,:)" |
---|
995 | DO jj = 1, jpj |
---|
996 | DO ji = 1, jpi |
---|
997 | zdept(ji,jj,1) = 0.5_wp * fse3w(ji,jj,1) - sshn(ji,jj) * znad |
---|
998 | END DO |
---|
999 | END DO |
---|
1000 | |
---|
1001 | DO jk = 2, jpk |
---|
1002 | DO jj = 1, jpj |
---|
1003 | DO ji = 1, jpi |
---|
1004 | zdept(ji,jj,jk) = zdept(ji,jj,jk-1) + fse3w(ji,jj,jk) |
---|
1005 | END DO |
---|
1006 | END DO |
---|
1007 | END DO |
---|
1008 | |
---|
1009 | fsp(:,:,:) = zrhh (:,:,:) |
---|
1010 | xsp(:,:,:) = zdept(:,:,:) |
---|
1011 | |
---|
1012 | ! Construct the vertical density profile with the |
---|
1013 | ! constrained cubic spline interpolation |
---|
1014 | ! rho(z) = asp + bsp*z + csp*z^2 + dsp*z^3 |
---|
1015 | CALL cspline(fsp,xsp,asp,bsp,csp,dsp,polynomial_type) |
---|
1016 | |
---|
1017 | ! Integrate the hydrostatic pressure "zhpi(:,:,:)" at "T(ji,jj,1)" |
---|
1018 | DO jj = 2, jpj |
---|
1019 | DO ji = 2, jpi |
---|
1020 | zrhdt1 = zrhh(ji,jj,1) - interp3(zdept(ji,jj,1),asp(ji,jj,1), & |
---|
1021 | bsp(ji,jj,1), csp(ji,jj,1), & |
---|
1022 | dsp(ji,jj,1) ) * 0.25_wp * fse3w(ji,jj,1) |
---|
1023 | |
---|
1024 | ! assuming linear profile across the top half surface layer |
---|
1025 | zhpi(ji,jj,1) = 0.5_wp * fse3w(ji,jj,1) * zrhdt1 |
---|
1026 | END DO |
---|
1027 | END DO |
---|
1028 | |
---|
1029 | ! Calculate the pressure "zhpi(:,:,:)" at "T(ji,jj,2:jpkm1)" |
---|
1030 | DO jk = 2, jpkm1 |
---|
1031 | DO jj = 2, jpj |
---|
1032 | DO ji = 2, jpi |
---|
1033 | zhpi(ji,jj,jk) = zhpi(ji,jj,jk-1) + & |
---|
1034 | integ_spline(zdept(ji,jj,jk-1), zdept(ji,jj,jk),& |
---|
1035 | asp(ji,jj,jk-1), bsp(ji,jj,jk-1), & |
---|
1036 | csp(ji,jj,jk-1), dsp(ji,jj,jk-1)) |
---|
1037 | END DO |
---|
1038 | END DO |
---|
1039 | END DO |
---|
1040 | |
---|
1041 | ! Z coordinate of U(ji,jj,1:jpkm1) and V(ji,jj,1:jpkm1) |
---|
1042 | DO jj = 2, jpjm1 |
---|
1043 | DO ji = 2, jpim1 |
---|
1044 | zu(ji,jj,1) = - ( fse3u(ji,jj,1) - sshn(ji,jj) * znad) ! probable bug: changed from sshu_n for ztilde compilation |
---|
1045 | zv(ji,jj,1) = - ( fse3v(ji,jj,1) - sshn(ji,jj) * znad) ! probable bug: changed from sshv_n for ztilde compilation |
---|
1046 | END DO |
---|
1047 | END DO |
---|
1048 | |
---|
1049 | DO jk = 2, jpkm1 |
---|
1050 | DO jj = 2, jpjm1 |
---|
1051 | DO ji = 2, jpim1 |
---|
1052 | zu(ji,jj,jk) = zu(ji,jj,jk-1)- fse3u(ji,jj,jk) |
---|
1053 | zv(ji,jj,jk) = zv(ji,jj,jk-1)- fse3v(ji,jj,jk) |
---|
1054 | END DO |
---|
1055 | END DO |
---|
1056 | END DO |
---|
1057 | |
---|
1058 | DO jk = 1, jpkm1 |
---|
1059 | DO jj = 2, jpjm1 |
---|
1060 | DO ji = 2, jpim1 |
---|
1061 | zu(ji,jj,jk) = zu(ji,jj,jk) + 0.5_wp * fse3u(ji,jj,jk) |
---|
1062 | zv(ji,jj,jk) = zv(ji,jj,jk) + 0.5_wp * fse3v(ji,jj,jk) |
---|
1063 | END DO |
---|
1064 | END DO |
---|
1065 | END DO |
---|
1066 | |
---|
1067 | DO jk = 1, jpkm1 |
---|
1068 | DO jj = 2, jpjm1 |
---|
1069 | DO ji = 2, jpim1 |
---|
1070 | zu(ji,jj,jk) = min(zu(ji,jj,jk), max(-zdept(ji,jj,jk), -zdept(ji+1,jj,jk))) |
---|
1071 | zu(ji,jj,jk) = max(zu(ji,jj,jk), min(-zdept(ji,jj,jk), -zdept(ji+1,jj,jk))) |
---|
1072 | zv(ji,jj,jk) = min(zv(ji,jj,jk), max(-zdept(ji,jj,jk), -zdept(ji,jj+1,jk))) |
---|
1073 | zv(ji,jj,jk) = max(zv(ji,jj,jk), min(-zdept(ji,jj,jk), -zdept(ji,jj+1,jk))) |
---|
1074 | END DO |
---|
1075 | END DO |
---|
1076 | END DO |
---|
1077 | |
---|
1078 | |
---|
1079 | DO jk = 1, jpkm1 |
---|
1080 | DO jj = 2, jpjm1 |
---|
1081 | DO ji = 2, jpim1 |
---|
1082 | zpwes = 0._wp; zpwed = 0._wp |
---|
1083 | zpnss = 0._wp; zpnsd = 0._wp |
---|
1084 | zuijk = zu(ji,jj,jk) |
---|
1085 | zvijk = zv(ji,jj,jk) |
---|
1086 | |
---|
1087 | !!!!! for u equation |
---|
1088 | IF( jk <= mbku(ji,jj) ) THEN |
---|
1089 | IF( -zdept(ji+1,jj,jk) >= -zdept(ji,jj,jk) ) THEN |
---|
1090 | jis = ji + 1; jid = ji |
---|
1091 | ELSE |
---|
1092 | jis = ji; jid = ji +1 |
---|
1093 | ENDIF |
---|
1094 | |
---|
1095 | ! integrate the pressure on the shallow side |
---|
1096 | jk1 = jk |
---|
1097 | DO WHILE ( -zdept(jis,jj,jk1) > zuijk ) |
---|
1098 | IF( jk1 == mbku(ji,jj) ) THEN |
---|
1099 | zuijk = -zdept(jis,jj,jk1) |
---|
1100 | EXIT |
---|
1101 | ENDIF |
---|
1102 | zdeps = MIN(zdept(jis,jj,jk1+1), -zuijk) |
---|
1103 | zpwes = zpwes + & |
---|
1104 | integ_spline(zdept(jis,jj,jk1), zdeps, & |
---|
1105 | asp(jis,jj,jk1), bsp(jis,jj,jk1), & |
---|
1106 | csp(jis,jj,jk1), dsp(jis,jj,jk1)) |
---|
1107 | jk1 = jk1 + 1 |
---|
1108 | END DO |
---|
1109 | |
---|
1110 | ! integrate the pressure on the deep side |
---|
1111 | jk1 = jk |
---|
1112 | DO WHILE ( -zdept(jid,jj,jk1) < zuijk ) |
---|
1113 | IF( jk1 == 1 ) THEN |
---|
1114 | zdeps = zdept(jid,jj,1) + MIN(zuijk, sshn(jid,jj)*znad) |
---|
1115 | zrhdt1 = zrhh(jid,jj,1) - interp3(zdept(jid,jj,1), asp(jid,jj,1), & |
---|
1116 | bsp(jid,jj,1), csp(jid,jj,1), & |
---|
1117 | dsp(jid,jj,1)) * zdeps |
---|
1118 | zpwed = zpwed + 0.5_wp * (zrhh(jid,jj,1) + zrhdt1) * zdeps |
---|
1119 | EXIT |
---|
1120 | ENDIF |
---|
1121 | zdeps = MAX(zdept(jid,jj,jk1-1), -zuijk) |
---|
1122 | zpwed = zpwed + & |
---|
1123 | integ_spline(zdeps, zdept(jid,jj,jk1), & |
---|
1124 | asp(jid,jj,jk1-1), bsp(jid,jj,jk1-1), & |
---|
1125 | csp(jid,jj,jk1-1), dsp(jid,jj,jk1-1) ) |
---|
1126 | jk1 = jk1 - 1 |
---|
1127 | END DO |
---|
1128 | |
---|
1129 | ! update the momentum trends in u direction |
---|
1130 | |
---|
1131 | zdpdx1 = zcoef0 / e1u(ji,jj) * (zhpi(ji+1,jj,jk) - zhpi(ji,jj,jk)) |
---|
1132 | IF( lk_vvl ) THEN |
---|
1133 | zdpdx2 = zcoef0 / e1u(ji,jj) * & |
---|
1134 | ( REAL(jis-jid, wp) * (zpwes + zpwed) + (sshn(ji+1,jj)-sshn(ji,jj)) ) |
---|
1135 | ELSE |
---|
1136 | zdpdx2 = zcoef0 / e1u(ji,jj) * REAL(jis-jid, wp) * (zpwes + zpwed) |
---|
1137 | ENDIF |
---|
1138 | |
---|
1139 | ua(ji,jj,jk) = ua(ji,jj,jk) + (zdpdx1 + zdpdx2) * & |
---|
1140 | & umask(ji,jj,jk) * tmask(ji,jj,jk) * tmask(ji+1,jj,jk) |
---|
1141 | ENDIF |
---|
1142 | |
---|
1143 | !!!!! for v equation |
---|
1144 | IF( jk <= mbkv(ji,jj) ) THEN |
---|
1145 | IF( -zdept(ji,jj+1,jk) >= -zdept(ji,jj,jk) ) THEN |
---|
1146 | jjs = jj + 1; jjd = jj |
---|
1147 | ELSE |
---|
1148 | jjs = jj ; jjd = jj + 1 |
---|
1149 | ENDIF |
---|
1150 | |
---|
1151 | ! integrate the pressure on the shallow side |
---|
1152 | jk1 = jk |
---|
1153 | DO WHILE ( -zdept(ji,jjs,jk1) > zvijk ) |
---|
1154 | IF( jk1 == mbkv(ji,jj) ) THEN |
---|
1155 | zvijk = -zdept(ji,jjs,jk1) |
---|
1156 | EXIT |
---|
1157 | ENDIF |
---|
1158 | zdeps = MIN(zdept(ji,jjs,jk1+1), -zvijk) |
---|
1159 | zpnss = zpnss + & |
---|
1160 | integ_spline(zdept(ji,jjs,jk1), zdeps, & |
---|
1161 | asp(ji,jjs,jk1), bsp(ji,jjs,jk1), & |
---|
1162 | csp(ji,jjs,jk1), dsp(ji,jjs,jk1) ) |
---|
1163 | jk1 = jk1 + 1 |
---|
1164 | END DO |
---|
1165 | |
---|
1166 | ! integrate the pressure on the deep side |
---|
1167 | jk1 = jk |
---|
1168 | DO WHILE ( -zdept(ji,jjd,jk1) < zvijk ) |
---|
1169 | IF( jk1 == 1 ) THEN |
---|
1170 | zdeps = zdept(ji,jjd,1) + MIN(zvijk, sshn(ji,jjd)*znad) |
---|
1171 | zrhdt1 = zrhh(ji,jjd,1) - interp3(zdept(ji,jjd,1), asp(ji,jjd,1), & |
---|
1172 | bsp(ji,jjd,1), csp(ji,jjd,1), & |
---|
1173 | dsp(ji,jjd,1) ) * zdeps |
---|
1174 | zpnsd = zpnsd + 0.5_wp * (zrhh(ji,jjd,1) + zrhdt1) * zdeps |
---|
1175 | EXIT |
---|
1176 | ENDIF |
---|
1177 | zdeps = MAX(zdept(ji,jjd,jk1-1), -zvijk) |
---|
1178 | zpnsd = zpnsd + & |
---|
1179 | integ_spline(zdeps, zdept(ji,jjd,jk1), & |
---|
1180 | asp(ji,jjd,jk1-1), bsp(ji,jjd,jk1-1), & |
---|
1181 | csp(ji,jjd,jk1-1), dsp(ji,jjd,jk1-1) ) |
---|
1182 | jk1 = jk1 - 1 |
---|
1183 | END DO |
---|
1184 | |
---|
1185 | |
---|
1186 | ! update the momentum trends in v direction |
---|
1187 | |
---|
1188 | zdpdy1 = zcoef0 / e2v(ji,jj) * (zhpi(ji,jj+1,jk) - zhpi(ji,jj,jk)) |
---|
1189 | IF( lk_vvl ) THEN |
---|
1190 | zdpdy2 = zcoef0 / e2v(ji,jj) * & |
---|
1191 | ( REAL(jjs-jjd, wp) * (zpnss + zpnsd) + (sshn(ji,jj+1)-sshn(ji,jj)) ) |
---|
1192 | ELSE |
---|
1193 | zdpdy2 = zcoef0 / e2v(ji,jj) * REAL(jjs-jjd, wp) * (zpnss + zpnsd ) |
---|
1194 | ENDIF |
---|
1195 | |
---|
1196 | va(ji,jj,jk) = va(ji,jj,jk) + (zdpdy1 + zdpdy2)*& |
---|
1197 | & vmask(ji,jj,jk)*tmask(ji,jj,jk)*tmask(ji,jj+1,jk) |
---|
1198 | ENDIF |
---|
1199 | |
---|
1200 | |
---|
1201 | END DO |
---|
1202 | END DO |
---|
1203 | END DO |
---|
1204 | ! |
---|
1205 | CALL wrk_dealloc( jpi,jpj,jpk, zhpi, zu, zv, fsp, xsp, asp, bsp, csp, dsp ) |
---|
1206 | CALL wrk_dealloc( jpi,jpj,jpk, zdept, zrhh ) |
---|
1207 | ! |
---|
1208 | END SUBROUTINE hpg_prj |
---|
1209 | |
---|
1210 | |
---|
1211 | SUBROUTINE cspline(fsp, xsp, asp, bsp, csp, dsp, polynomial_type) |
---|
1212 | !!---------------------------------------------------------------------- |
---|
1213 | !! *** ROUTINE cspline *** |
---|
1214 | !! |
---|
1215 | !! ** Purpose : constrained cubic spline interpolation |
---|
1216 | !! |
---|
1217 | !! ** Method : f(x) = asp + bsp*x + csp*x^2 + dsp*x^3 |
---|
1218 | !! |
---|
1219 | !! Reference: CJC Kruger, Constrained Cubic Spline Interpoltation |
---|
1220 | !!---------------------------------------------------------------------- |
---|
1221 | IMPLICIT NONE |
---|
1222 | REAL(wp), DIMENSION(:,:,:), INTENT(in) :: fsp, xsp ! value and coordinate |
---|
1223 | REAL(wp), DIMENSION(:,:,:), INTENT(out) :: asp, bsp, csp, dsp ! coefficients of |
---|
1224 | ! the interpoated function |
---|
1225 | INTEGER, INTENT(in) :: polynomial_type ! 1: cubic spline |
---|
1226 | ! 2: Linear |
---|
1227 | ! |
---|
1228 | INTEGER :: ji, jj, jk ! dummy loop indices |
---|
1229 | INTEGER :: jpi, jpj, jpkm1 |
---|
1230 | REAL(wp) :: zdf1, zdf2, zddf1, zddf2, ztmp1, ztmp2, zdxtmp |
---|
1231 | REAL(wp) :: zdxtmp1, zdxtmp2, zalpha |
---|
1232 | REAL(wp) :: zdf(size(fsp,3)) |
---|
1233 | !!---------------------------------------------------------------------- |
---|
1234 | |
---|
1235 | jpi = size(fsp,1) |
---|
1236 | jpj = size(fsp,2) |
---|
1237 | jpkm1 = size(fsp,3) - 1 |
---|
1238 | |
---|
1239 | |
---|
1240 | IF (polynomial_type == 1) THEN ! Constrained Cubic Spline |
---|
1241 | DO ji = 1, jpi |
---|
1242 | DO jj = 1, jpj |
---|
1243 | !!Fritsch&Butland's method, 1984 (preferred, but more computation) |
---|
1244 | ! DO jk = 2, jpkm1-1 |
---|
1245 | ! zdxtmp1 = xsp(ji,jj,jk) - xsp(ji,jj,jk-1) |
---|
1246 | ! zdxtmp2 = xsp(ji,jj,jk+1) - xsp(ji,jj,jk) |
---|
1247 | ! zdf1 = ( fsp(ji,jj,jk) - fsp(ji,jj,jk-1) ) / zdxtmp1 |
---|
1248 | ! zdf2 = ( fsp(ji,jj,jk+1) - fsp(ji,jj,jk) ) / zdxtmp2 |
---|
1249 | ! |
---|
1250 | ! zalpha = ( zdxtmp1 + 2._wp * zdxtmp2 ) / ( zdxtmp1 + zdxtmp2 ) / 3._wp |
---|
1251 | ! |
---|
1252 | ! IF(zdf1 * zdf2 <= 0._wp) THEN |
---|
1253 | ! zdf(jk) = 0._wp |
---|
1254 | ! ELSE |
---|
1255 | ! zdf(jk) = zdf1 * zdf2 / ( ( 1._wp - zalpha ) * zdf1 + zalpha * zdf2 ) |
---|
1256 | ! ENDIF |
---|
1257 | ! END DO |
---|
1258 | |
---|
1259 | !!Simply geometric average |
---|
1260 | DO jk = 2, jpkm1-1 |
---|
1261 | zdf1 = (fsp(ji,jj,jk) - fsp(ji,jj,jk-1)) / (xsp(ji,jj,jk) - xsp(ji,jj,jk-1)) |
---|
1262 | zdf2 = (fsp(ji,jj,jk+1) - fsp(ji,jj,jk)) / (xsp(ji,jj,jk+1) - xsp(ji,jj,jk)) |
---|
1263 | |
---|
1264 | IF(zdf1 * zdf2 <= 0._wp) THEN |
---|
1265 | zdf(jk) = 0._wp |
---|
1266 | ELSE |
---|
1267 | zdf(jk) = 2._wp * zdf1 * zdf2 / (zdf1 + zdf2) |
---|
1268 | ENDIF |
---|
1269 | END DO |
---|
1270 | |
---|
1271 | zdf(1) = 1.5_wp * ( fsp(ji,jj,2) - fsp(ji,jj,1) ) / & |
---|
1272 | & ( xsp(ji,jj,2) - xsp(ji,jj,1) ) - 0.5_wp * zdf(2) |
---|
1273 | zdf(jpkm1) = 1.5_wp * ( fsp(ji,jj,jpkm1) - fsp(ji,jj,jpkm1-1) ) / & |
---|
1274 | & ( xsp(ji,jj,jpkm1) - xsp(ji,jj,jpkm1-1) ) - & |
---|
1275 | & 0.5_wp * zdf(jpkm1 - 1) |
---|
1276 | |
---|
1277 | DO jk = 1, jpkm1 - 1 |
---|
1278 | zdxtmp = xsp(ji,jj,jk+1) - xsp(ji,jj,jk) |
---|
1279 | ztmp1 = (zdf(jk+1) + 2._wp * zdf(jk)) / zdxtmp |
---|
1280 | ztmp2 = 6._wp * (fsp(ji,jj,jk+1) - fsp(ji,jj,jk)) / zdxtmp / zdxtmp |
---|
1281 | zddf1 = -2._wp * ztmp1 + ztmp2 |
---|
1282 | ztmp1 = (2._wp * zdf(jk+1) + zdf(jk)) / zdxtmp |
---|
1283 | zddf2 = 2._wp * ztmp1 - ztmp2 |
---|
1284 | |
---|
1285 | dsp(ji,jj,jk) = (zddf2 - zddf1) / 6._wp / zdxtmp |
---|
1286 | csp(ji,jj,jk) = ( xsp(ji,jj,jk+1) * zddf1 - xsp(ji,jj,jk)*zddf2 ) / 2._wp / zdxtmp |
---|
1287 | bsp(ji,jj,jk) = ( fsp(ji,jj,jk+1) - fsp(ji,jj,jk) ) / zdxtmp - & |
---|
1288 | & csp(ji,jj,jk) * ( xsp(ji,jj,jk+1) + xsp(ji,jj,jk) ) - & |
---|
1289 | & dsp(ji,jj,jk) * ((xsp(ji,jj,jk+1) + xsp(ji,jj,jk))**2 - & |
---|
1290 | & xsp(ji,jj,jk+1) * xsp(ji,jj,jk)) |
---|
1291 | asp(ji,jj,jk) = fsp(ji,jj,jk) - xsp(ji,jj,jk) * (bsp(ji,jj,jk) + & |
---|
1292 | & (xsp(ji,jj,jk) * (csp(ji,jj,jk) + & |
---|
1293 | & dsp(ji,jj,jk) * xsp(ji,jj,jk)))) |
---|
1294 | END DO |
---|
1295 | END DO |
---|
1296 | END DO |
---|
1297 | |
---|
1298 | ELSE IF (polynomial_type == 2) THEN ! Linear |
---|
1299 | DO ji = 1, jpi |
---|
1300 | DO jj = 1, jpj |
---|
1301 | DO jk = 1, jpkm1-1 |
---|
1302 | zdxtmp =xsp(ji,jj,jk+1) - xsp(ji,jj,jk) |
---|
1303 | ztmp1 = fsp(ji,jj,jk+1) - fsp(ji,jj,jk) |
---|
1304 | |
---|
1305 | dsp(ji,jj,jk) = 0._wp |
---|
1306 | csp(ji,jj,jk) = 0._wp |
---|
1307 | bsp(ji,jj,jk) = ztmp1 / zdxtmp |
---|
1308 | asp(ji,jj,jk) = fsp(ji,jj,jk) - bsp(ji,jj,jk) * xsp(ji,jj,jk) |
---|
1309 | END DO |
---|
1310 | END DO |
---|
1311 | END DO |
---|
1312 | |
---|
1313 | ELSE |
---|
1314 | CALL ctl_stop( 'invalid polynomial type in cspline' ) |
---|
1315 | ENDIF |
---|
1316 | |
---|
1317 | END SUBROUTINE cspline |
---|
1318 | |
---|
1319 | |
---|
1320 | FUNCTION interp1(x, xl, xr, fl, fr) RESULT(f) |
---|
1321 | !!---------------------------------------------------------------------- |
---|
1322 | !! *** ROUTINE interp1 *** |
---|
1323 | !! |
---|
1324 | !! ** Purpose : 1-d linear interpolation |
---|
1325 | !! |
---|
1326 | !! ** Method : interpolation is straight forward |
---|
1327 | !! extrapolation is also permitted (no value limit) |
---|
1328 | !!---------------------------------------------------------------------- |
---|
1329 | IMPLICIT NONE |
---|
1330 | REAL(wp), INTENT(in) :: x, xl, xr, fl, fr |
---|
1331 | REAL(wp) :: f ! result of the interpolation (extrapolation) |
---|
1332 | REAL(wp) :: zdeltx |
---|
1333 | !!---------------------------------------------------------------------- |
---|
1334 | |
---|
1335 | zdeltx = xr - xl |
---|
1336 | IF(abs(zdeltx) <= 10._wp * EPSILON(x)) THEN |
---|
1337 | f = 0.5_wp * (fl + fr) |
---|
1338 | ELSE |
---|
1339 | f = ( (x - xl ) * fr - ( x - xr ) * fl ) / zdeltx |
---|
1340 | ENDIF |
---|
1341 | |
---|
1342 | END FUNCTION interp1 |
---|
1343 | |
---|
1344 | |
---|
1345 | FUNCTION interp2(x, a, b, c, d) RESULT(f) |
---|
1346 | !!---------------------------------------------------------------------- |
---|
1347 | !! *** ROUTINE interp1 *** |
---|
1348 | !! |
---|
1349 | !! ** Purpose : 1-d constrained cubic spline interpolation |
---|
1350 | !! |
---|
1351 | !! ** Method : cubic spline interpolation |
---|
1352 | !! |
---|
1353 | !!---------------------------------------------------------------------- |
---|
1354 | IMPLICIT NONE |
---|
1355 | REAL(wp), INTENT(in) :: x, a, b, c, d |
---|
1356 | REAL(wp) :: f ! value from the interpolation |
---|
1357 | !!---------------------------------------------------------------------- |
---|
1358 | |
---|
1359 | f = a + x* ( b + x * ( c + d * x ) ) |
---|
1360 | |
---|
1361 | END FUNCTION interp2 |
---|
1362 | |
---|
1363 | |
---|
1364 | FUNCTION interp3(x, a, b, c, d) RESULT(f) |
---|
1365 | !!---------------------------------------------------------------------- |
---|
1366 | !! *** ROUTINE interp1 *** |
---|
1367 | !! |
---|
1368 | !! ** Purpose : Calculate the first order of deriavtive of |
---|
1369 | !! a cubic spline function y=a+b*x+c*x^2+d*x^3 |
---|
1370 | !! |
---|
1371 | !! ** Method : f=dy/dx=b+2*c*x+3*d*x^2 |
---|
1372 | !! |
---|
1373 | !!---------------------------------------------------------------------- |
---|
1374 | IMPLICIT NONE |
---|
1375 | REAL(wp), INTENT(in) :: x, a, b, c, d |
---|
1376 | REAL(wp) :: f ! value from the interpolation |
---|
1377 | !!---------------------------------------------------------------------- |
---|
1378 | |
---|
1379 | f = b + x * ( 2._wp * c + 3._wp * d * x) |
---|
1380 | |
---|
1381 | END FUNCTION interp3 |
---|
1382 | |
---|
1383 | |
---|
1384 | FUNCTION integ_spline(xl, xr, a, b, c, d) RESULT(f) |
---|
1385 | !!---------------------------------------------------------------------- |
---|
1386 | !! *** ROUTINE interp1 *** |
---|
1387 | !! |
---|
1388 | !! ** Purpose : 1-d constrained cubic spline integration |
---|
1389 | !! |
---|
1390 | !! ** Method : integrate polynomial a+bx+cx^2+dx^3 from xl to xr |
---|
1391 | !! |
---|
1392 | !!---------------------------------------------------------------------- |
---|
1393 | IMPLICIT NONE |
---|
1394 | REAL(wp), INTENT(in) :: xl, xr, a, b, c, d |
---|
1395 | REAL(wp) :: za1, za2, za3 |
---|
1396 | REAL(wp) :: f ! integration result |
---|
1397 | !!---------------------------------------------------------------------- |
---|
1398 | |
---|
1399 | za1 = 0.5_wp * b |
---|
1400 | za2 = c / 3.0_wp |
---|
1401 | za3 = 0.25_wp * d |
---|
1402 | |
---|
1403 | f = xr * ( a + xr * ( za1 + xr * ( za2 + za3 * xr ) ) ) - & |
---|
1404 | & xl * ( a + xl * ( za1 + xl * ( za2 + za3 * xl ) ) ) |
---|
1405 | |
---|
1406 | END FUNCTION integ_spline |
---|
1407 | |
---|
1408 | !!====================================================================== |
---|
1409 | END MODULE dynhpg |
---|
1410 | |
---|