1 | !> @file ocean_mod.f90 |
---|
2 | !------------------------------------------------------------------------------! |
---|
3 | ! This file is part of the PALM model system. |
---|
4 | ! |
---|
5 | ! PALM is free software: you can redistribute it and/or modify it under the |
---|
6 | ! terms of the GNU General Public License as published by the Free Software |
---|
7 | ! Foundation, either version 3 of the License, or (at your option) any later |
---|
8 | ! version. |
---|
9 | ! |
---|
10 | ! PALM is distributed in the hope that it will be useful, but WITHOUT ANY |
---|
11 | ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR |
---|
12 | ! A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
---|
13 | ! |
---|
14 | ! You should have received a copy of the GNU General Public License along with |
---|
15 | ! PALM. If not, see <http://www.gnu.org/licenses/>. |
---|
16 | ! |
---|
17 | ! Copyright 2017-2018 Leibniz Universitaet Hannover |
---|
18 | !--------------------------------------------------------------------------------! |
---|
19 | ! |
---|
20 | ! Current revisions: |
---|
21 | ! ----------------- |
---|
22 | ! |
---|
23 | ! |
---|
24 | ! Former revisions: |
---|
25 | ! ----------------- |
---|
26 | ! $Id: ocean_mod.f90 3614 2018-12-10 07:05:46Z eckhard $ |
---|
27 | ! unused variables removed |
---|
28 | ! |
---|
29 | ! 3568 2018-11-27 16:07:59Z raasch |
---|
30 | ! bugifx: calculate equation of state for seawater even if salinity is switched |
---|
31 | ! off |
---|
32 | ! |
---|
33 | ! 3421 2018-10-24 18:39:32Z gronemeier |
---|
34 | ! Renamed output variables |
---|
35 | ! |
---|
36 | ! 3381 2018-10-19 13:09:06Z raasch |
---|
37 | ! spin-up cooling for ocean surface implemented, see new parameter |
---|
38 | ! surface_cooling_spinup_time |
---|
39 | ! |
---|
40 | ! 3311 2018-10-05 12:34:56Z raasch |
---|
41 | ! check if ocean mode is used for invalid combinations |
---|
42 | ! |
---|
43 | ! 3303 2018-10-03 12:04:15Z raasch |
---|
44 | ! salinity allowed to be switched off |
---|
45 | ! |
---|
46 | ! 3302 2018-10-03 02:39:40Z raasch |
---|
47 | ! Craik Leibovich force (Stokes drift) + wave breaking effect added |
---|
48 | ! |
---|
49 | ! 3294 2018-10-01 02:37:10Z raasch |
---|
50 | ! initial revision |
---|
51 | ! |
---|
52 | ! |
---|
53 | ! Authors: |
---|
54 | ! -------- |
---|
55 | ! @author Siegfried Raasch |
---|
56 | ! |
---|
57 | ! Description: |
---|
58 | ! ------------ |
---|
59 | !> This module contains relevant code for PALM's ocean mode, e.g. the |
---|
60 | !> prognostic equation for salinity, the equation of state for seawater, |
---|
61 | !> the Craik Leibovich force (Stokes force), and wave breaking effects |
---|
62 | !------------------------------------------------------------------------------! |
---|
63 | MODULE ocean_mod |
---|
64 | |
---|
65 | |
---|
66 | #if defined( __nopointer ) |
---|
67 | USE arrays_3d, & |
---|
68 | ONLY: prho, rho_ocean, sa, sa_init, sa_p, tsa_m |
---|
69 | #else |
---|
70 | USE arrays_3d, & |
---|
71 | ONLY: prho, prho_1, rho_ocean, rho_1, sa, sa_init, sa_1, sa_2, sa_3, & |
---|
72 | sa_p, tsa_m |
---|
73 | #endif |
---|
74 | |
---|
75 | USE control_parameters, & |
---|
76 | ONLY: atmos_ocean_sign, bottom_salinityflux, & |
---|
77 | constant_top_salinityflux, ocean_mode, top_salinityflux, & |
---|
78 | wall_salinityflux |
---|
79 | |
---|
80 | USE kinds |
---|
81 | |
---|
82 | |
---|
83 | IMPLICIT NONE |
---|
84 | |
---|
85 | CHARACTER (LEN=20) :: bc_sa_t = 'neumann' !< namelist parameter |
---|
86 | |
---|
87 | INTEGER(iwp) :: ibc_sa_t !< integer flag for bc_sa_t |
---|
88 | INTEGER(iwp) :: iran_ocean = -1234567 !< random number used for wave breaking effects |
---|
89 | |
---|
90 | INTEGER(iwp) :: sa_vertical_gradient_level_ind(10) = -9999 !< grid index values of sa_vertical_gradient_level(s) |
---|
91 | |
---|
92 | LOGICAL :: salinity = .TRUE. !< switch for using salinity |
---|
93 | LOGICAL :: stokes_force = .FALSE. !< switch to switch on the Stokes force |
---|
94 | LOGICAL :: wave_breaking = .FALSE. !< switch to switch on wave breaking effects |
---|
95 | LOGICAL :: surface_cooling_switched_off = .FALSE. !< variable to check if surface heat flux has been switched off |
---|
96 | |
---|
97 | REAL(wp) :: alpha_wave_breaking = 3.0_wp !< coefficient for wave breaking generated turbulence from Noh et al. (2004), JPO |
---|
98 | REAL(wp) :: prho_reference !< reference state of potential density at ocean surface |
---|
99 | REAL(wp) :: sa_surface = 35.0_wp !< surface salinity, namelist parameter |
---|
100 | REAL(wp) :: sa_vertical_gradient(10) = 0.0_wp !< namelist parameter |
---|
101 | REAL(wp) :: sa_vertical_gradient_level(10) = -999999.9_wp !< namelist parameter |
---|
102 | REAL(wp) :: stokes_waveheight = 0.0_wp !< wave height assumed for Stokes drift velocity |
---|
103 | REAL(wp) :: stokes_wavelength = 0.0_wp !< wavelength assumed for Stokes drift velocity |
---|
104 | REAL(wp) :: surface_cooling_spinup_time = 999999.9_wp !< time after which surface heat flux is switched off |
---|
105 | REAL(wp) :: timescale_wave_breaking !< time scale of random forcing |
---|
106 | REAL(wp) :: u_star_wave_breaking !< to store the absolute value of friction velocity at the ocean surface |
---|
107 | |
---|
108 | REAL(wp), DIMENSION(12), PARAMETER :: nom = & |
---|
109 | (/ 9.9984085444849347D2, 7.3471625860981584D0, & |
---|
110 | -5.3211231792841769D-2, 3.6492439109814549D-4, & |
---|
111 | 2.5880571023991390D0, -6.7168282786692354D-3, & |
---|
112 | 1.9203202055760151D-3, 1.1798263740430364D-2, & |
---|
113 | 9.8920219266399117D-8, 4.6996642771754730D-6, & |
---|
114 | -2.5862187075154352D-8, -3.2921414007960662D-12 /) |
---|
115 | !< constants used in equation of state for seawater |
---|
116 | |
---|
117 | REAL(wp), DIMENSION(13), PARAMETER :: den = & |
---|
118 | (/ 1.0D0, 7.2815210113327091D-3, & |
---|
119 | -4.4787265461983921D-5, 3.3851002965802430D-7, & |
---|
120 | 1.3651202389758572D-10, 1.7632126669040377D-3, & |
---|
121 | -8.8066583251206474D-6, -1.8832689434804897D-10, & |
---|
122 | 5.7463776745432097D-6, 1.4716275472242334D-9, & |
---|
123 | 6.7103246285651894D-6, -2.4461698007024582D-17, & |
---|
124 | -9.1534417604289062D-18 /) |
---|
125 | !< constants used in equation of state for seawater |
---|
126 | |
---|
127 | SAVE |
---|
128 | |
---|
129 | PUBLIC :: bc_sa_t, ibc_sa_t, prho_reference, sa_surface, & |
---|
130 | sa_vertical_gradient, sa_vertical_gradient_level, & |
---|
131 | sa_vertical_gradient_level_ind, stokes_force, wave_breaking |
---|
132 | |
---|
133 | |
---|
134 | INTERFACE eqn_state_seawater |
---|
135 | MODULE PROCEDURE eqn_state_seawater |
---|
136 | MODULE PROCEDURE eqn_state_seawater_ij |
---|
137 | END INTERFACE eqn_state_seawater |
---|
138 | |
---|
139 | INTERFACE eqn_state_seawater_func |
---|
140 | MODULE PROCEDURE eqn_state_seawater_func |
---|
141 | END INTERFACE eqn_state_seawater_func |
---|
142 | |
---|
143 | INTERFACE ocean_check_parameters |
---|
144 | MODULE PROCEDURE ocean_check_parameters |
---|
145 | END INTERFACE ocean_check_parameters |
---|
146 | |
---|
147 | INTERFACE ocean_check_data_output |
---|
148 | MODULE PROCEDURE ocean_check_data_output |
---|
149 | END INTERFACE ocean_check_data_output |
---|
150 | |
---|
151 | INTERFACE ocean_check_data_output_pr |
---|
152 | MODULE PROCEDURE ocean_check_data_output_pr |
---|
153 | END INTERFACE ocean_check_data_output_pr |
---|
154 | |
---|
155 | INTERFACE ocean_define_netcdf_grid |
---|
156 | MODULE PROCEDURE ocean_define_netcdf_grid |
---|
157 | END INTERFACE ocean_define_netcdf_grid |
---|
158 | |
---|
159 | INTERFACE ocean_data_output_2d |
---|
160 | MODULE PROCEDURE ocean_data_output_2d |
---|
161 | END INTERFACE ocean_data_output_2d |
---|
162 | |
---|
163 | INTERFACE ocean_data_output_3d |
---|
164 | MODULE PROCEDURE ocean_data_output_3d |
---|
165 | END INTERFACE ocean_data_output_3d |
---|
166 | |
---|
167 | INTERFACE ocean_header |
---|
168 | MODULE PROCEDURE ocean_header |
---|
169 | END INTERFACE ocean_header |
---|
170 | |
---|
171 | INTERFACE ocean_init |
---|
172 | MODULE PROCEDURE ocean_init |
---|
173 | END INTERFACE ocean_init |
---|
174 | |
---|
175 | INTERFACE ocean_init_arrays |
---|
176 | MODULE PROCEDURE ocean_init_arrays |
---|
177 | END INTERFACE ocean_init_arrays |
---|
178 | |
---|
179 | INTERFACE ocean_parin |
---|
180 | MODULE PROCEDURE ocean_parin |
---|
181 | END INTERFACE ocean_parin |
---|
182 | |
---|
183 | INTERFACE ocean_prognostic_equations |
---|
184 | MODULE PROCEDURE ocean_prognostic_equations |
---|
185 | MODULE PROCEDURE ocean_prognostic_equations_ij |
---|
186 | END INTERFACE ocean_prognostic_equations |
---|
187 | |
---|
188 | INTERFACE ocean_swap_timelevel |
---|
189 | MODULE PROCEDURE ocean_swap_timelevel |
---|
190 | END INTERFACE ocean_swap_timelevel |
---|
191 | |
---|
192 | INTERFACE ocean_rrd_global |
---|
193 | MODULE PROCEDURE ocean_rrd_global |
---|
194 | END INTERFACE ocean_rrd_global |
---|
195 | |
---|
196 | INTERFACE ocean_rrd_local |
---|
197 | MODULE PROCEDURE ocean_rrd_local |
---|
198 | END INTERFACE ocean_rrd_local |
---|
199 | |
---|
200 | INTERFACE ocean_wrd_global |
---|
201 | MODULE PROCEDURE ocean_wrd_global |
---|
202 | END INTERFACE ocean_wrd_global |
---|
203 | |
---|
204 | INTERFACE ocean_wrd_local |
---|
205 | MODULE PROCEDURE ocean_wrd_local |
---|
206 | END INTERFACE ocean_wrd_local |
---|
207 | |
---|
208 | INTERFACE ocean_3d_data_averaging |
---|
209 | MODULE PROCEDURE ocean_3d_data_averaging |
---|
210 | END INTERFACE ocean_3d_data_averaging |
---|
211 | |
---|
212 | INTERFACE stokes_drift_terms |
---|
213 | MODULE PROCEDURE stokes_drift_terms |
---|
214 | MODULE PROCEDURE stokes_drift_terms_ij |
---|
215 | END INTERFACE stokes_drift_terms |
---|
216 | |
---|
217 | INTERFACE wave_breaking_term |
---|
218 | MODULE PROCEDURE wave_breaking_term |
---|
219 | MODULE PROCEDURE wave_breaking_term_ij |
---|
220 | END INTERFACE wave_breaking_term |
---|
221 | |
---|
222 | PRIVATE |
---|
223 | ! |
---|
224 | !-- Add INTERFACES that must be available to other modules (alphabetical order) |
---|
225 | PUBLIC eqn_state_seawater, ocean_check_data_output, & |
---|
226 | ocean_check_data_output_pr, ocean_check_parameters, & |
---|
227 | ocean_data_output_2d, ocean_data_output_3d, & |
---|
228 | ocean_define_netcdf_grid, ocean_header, ocean_init, & |
---|
229 | ocean_init_arrays, ocean_parin, ocean_prognostic_equations, & |
---|
230 | ocean_swap_timelevel, ocean_rrd_global, ocean_rrd_local, & |
---|
231 | ocean_wrd_global, ocean_wrd_local, ocean_3d_data_averaging, & |
---|
232 | stokes_drift_terms, wave_breaking_term |
---|
233 | |
---|
234 | |
---|
235 | CONTAINS |
---|
236 | |
---|
237 | !------------------------------------------------------------------------------! |
---|
238 | ! Description: |
---|
239 | ! ------------ |
---|
240 | !> Equation of state for seawater as a function of potential temperature, |
---|
241 | !> salinity, and pressure. |
---|
242 | !> For coefficients see Jackett et al., 2006: J. Atm. Ocean Tech. |
---|
243 | !> eqn_state_seawater calculates the potential density referred at hyp(0). |
---|
244 | !> eqn_state_seawater_func calculates density. |
---|
245 | !> TODO: so far, routine is not adjusted to use topography |
---|
246 | !------------------------------------------------------------------------------! |
---|
247 | SUBROUTINE eqn_state_seawater |
---|
248 | |
---|
249 | USE arrays_3d, & |
---|
250 | ONLY: hyp, prho, pt_p, rho_ocean, sa_p |
---|
251 | USE indices, & |
---|
252 | ONLY: nxl, nxr, nyn, nys, nzb, nzt |
---|
253 | |
---|
254 | USE surface_mod, & |
---|
255 | ONLY : bc_h |
---|
256 | |
---|
257 | IMPLICIT NONE |
---|
258 | |
---|
259 | INTEGER(iwp) :: i !< running index x direction |
---|
260 | INTEGER(iwp) :: j !< running index y direction |
---|
261 | INTEGER(iwp) :: k !< running index z direction |
---|
262 | INTEGER(iwp) :: m !< running index surface elements |
---|
263 | |
---|
264 | REAL(wp) :: pden !< temporary scalar user for calculating density |
---|
265 | REAL(wp) :: pnom !< temporary scalar user for calculating density |
---|
266 | REAL(wp) :: p1 !< temporary scalar user for calculating density |
---|
267 | REAL(wp) :: p2 !< temporary scalar user for calculating density |
---|
268 | REAL(wp) :: p3 !< temporary scalar user for calculating density |
---|
269 | REAL(wp) :: pt1 !< temporary scalar user for calculating density |
---|
270 | REAL(wp) :: pt2 !< temporary scalar user for calculating density |
---|
271 | REAL(wp) :: pt3 !< temporary scalar user for calculating density |
---|
272 | REAL(wp) :: pt4 !< temporary scalar user for calculating density |
---|
273 | REAL(wp) :: sa1 !< temporary scalar user for calculating density |
---|
274 | REAL(wp) :: sa15 !< temporary scalar user for calculating density |
---|
275 | REAL(wp) :: sa2 !< temporary scalar user for calculating density |
---|
276 | |
---|
277 | |
---|
278 | DO i = nxl, nxr |
---|
279 | DO j = nys, nyn |
---|
280 | DO k = nzb+1, nzt |
---|
281 | ! |
---|
282 | !-- Pressure is needed in dbar |
---|
283 | p1 = hyp(k) * 1E-4_wp |
---|
284 | p2 = p1 * p1 |
---|
285 | p3 = p2 * p1 |
---|
286 | |
---|
287 | ! |
---|
288 | !-- Temperature needed in degree Celsius |
---|
289 | pt1 = pt_p(k,j,i) - 273.15_wp |
---|
290 | pt2 = pt1 * pt1 |
---|
291 | pt3 = pt1 * pt2 |
---|
292 | pt4 = pt2 * pt2 |
---|
293 | |
---|
294 | sa1 = sa_p(k,j,i) |
---|
295 | sa15 = sa1 * SQRT( sa1 ) |
---|
296 | sa2 = sa1 * sa1 |
---|
297 | |
---|
298 | pnom = nom(1) + nom(2)*pt1 + nom(3)*pt2 + & |
---|
299 | nom(4)*pt3 + nom(5)*sa1 + nom(6)*sa1*pt1 + & |
---|
300 | nom(7)*sa2 |
---|
301 | |
---|
302 | pden = den(1) + den(2)*pt1 + den(3)*pt2 + & |
---|
303 | den(4)*pt3 + den(5)*pt4 + den(6)*sa1 + & |
---|
304 | den(7)*sa1*pt1 + den(8)*sa1*pt3 + den(9)*sa15 + & |
---|
305 | den(10)*sa15*pt2 |
---|
306 | ! |
---|
307 | !-- Potential density (without pressure terms) |
---|
308 | prho(k,j,i) = pnom / pden |
---|
309 | |
---|
310 | pnom = pnom + nom(8)*p1 + nom(9)*p1*pt2 + & |
---|
311 | nom(10)*p1*sa1 + nom(11)*p2 + nom(12)*p2*pt2 |
---|
312 | |
---|
313 | pden = pden + den(11)*p1 + den(12)*p2*pt3 + & |
---|
314 | den(13)*p3*pt1 |
---|
315 | |
---|
316 | ! |
---|
317 | !-- In-situ density |
---|
318 | rho_ocean(k,j,i) = pnom / pden |
---|
319 | |
---|
320 | ENDDO |
---|
321 | |
---|
322 | ! |
---|
323 | !-- Neumann conditions are assumed at top boundary and currently also at |
---|
324 | !-- bottom boundary (see comment lines below) |
---|
325 | prho(nzt+1,j,i) = prho(nzt,j,i) |
---|
326 | rho_ocean(nzt+1,j,i) = rho_ocean(nzt,j,i) |
---|
327 | |
---|
328 | ENDDO |
---|
329 | ENDDO |
---|
330 | ! |
---|
331 | !-- Neumann conditions at up/downward-facing surfaces |
---|
332 | !$OMP PARALLEL DO PRIVATE( i, j, k ) |
---|
333 | DO m = 1, bc_h(0)%ns |
---|
334 | i = bc_h(0)%i(m) |
---|
335 | j = bc_h(0)%j(m) |
---|
336 | k = bc_h(0)%k(m) |
---|
337 | prho(k-1,j,i) = prho(k,j,i) |
---|
338 | rho_ocean(k-1,j,i) = rho_ocean(k,j,i) |
---|
339 | ENDDO |
---|
340 | ! |
---|
341 | !-- Downward facing surfaces |
---|
342 | !$OMP PARALLEL DO PRIVATE( i, j, k ) |
---|
343 | DO m = 1, bc_h(1)%ns |
---|
344 | i = bc_h(1)%i(m) |
---|
345 | j = bc_h(1)%j(m) |
---|
346 | k = bc_h(1)%k(m) |
---|
347 | prho(k+1,j,i) = prho(k,j,i) |
---|
348 | rho_ocean(k+1,j,i) = rho_ocean(k,j,i) |
---|
349 | ENDDO |
---|
350 | |
---|
351 | END SUBROUTINE eqn_state_seawater |
---|
352 | |
---|
353 | |
---|
354 | !------------------------------------------------------------------------------! |
---|
355 | ! Description: |
---|
356 | ! ------------ |
---|
357 | !> Same as above, but for grid point i,j |
---|
358 | !------------------------------------------------------------------------------! |
---|
359 | SUBROUTINE eqn_state_seawater_ij( i, j ) |
---|
360 | |
---|
361 | USE arrays_3d, & |
---|
362 | ONLY: hyp, prho, pt_p, rho_ocean, sa_p |
---|
363 | |
---|
364 | USE indices, & |
---|
365 | ONLY: nzb, nzt |
---|
366 | |
---|
367 | USE surface_mod, & |
---|
368 | ONLY : bc_h |
---|
369 | |
---|
370 | IMPLICIT NONE |
---|
371 | |
---|
372 | INTEGER(iwp) :: i !< running index x direction |
---|
373 | INTEGER(iwp) :: j !< running index y direction |
---|
374 | INTEGER(iwp) :: k !< running index z direction |
---|
375 | INTEGER(iwp) :: m !< running index surface elements |
---|
376 | INTEGER(iwp) :: surf_e !< end index of surface elements at (j,i)-gridpoint |
---|
377 | INTEGER(iwp) :: surf_s !< start index of surface elements at (j,i)-gridpoint |
---|
378 | |
---|
379 | REAL(wp) :: pden !< temporary scalar user for calculating density |
---|
380 | REAL(wp) :: pnom !< temporary scalar user for calculating density |
---|
381 | REAL(wp) :: p1 !< temporary scalar user for calculating density |
---|
382 | REAL(wp) :: p2 !< temporary scalar user for calculating density |
---|
383 | REAL(wp) :: p3 !< temporary scalar user for calculating density |
---|
384 | REAL(wp) :: pt1 !< temporary scalar user for calculating density |
---|
385 | REAL(wp) :: pt2 !< temporary scalar user for calculating density |
---|
386 | REAL(wp) :: pt3 !< temporary scalar user for calculating density |
---|
387 | REAL(wp) :: pt4 !< temporary scalar user for calculating density |
---|
388 | REAL(wp) :: sa1 !< temporary scalar user for calculating density |
---|
389 | REAL(wp) :: sa15 !< temporary scalar user for calculating density |
---|
390 | REAL(wp) :: sa2 !< temporary scalar user for calculating density |
---|
391 | |
---|
392 | DO k = nzb+1, nzt |
---|
393 | ! |
---|
394 | !-- Pressure is needed in dbar |
---|
395 | p1 = hyp(k) * 1E-4_wp |
---|
396 | p2 = p1 * p1 |
---|
397 | p3 = p2 * p1 |
---|
398 | ! |
---|
399 | !-- Temperature needed in degree Celsius |
---|
400 | pt1 = pt_p(k,j,i) - 273.15_wp |
---|
401 | pt2 = pt1 * pt1 |
---|
402 | pt3 = pt1 * pt2 |
---|
403 | pt4 = pt2 * pt2 |
---|
404 | |
---|
405 | sa1 = sa_p(k,j,i) |
---|
406 | sa15 = sa1 * SQRT( sa1 ) |
---|
407 | sa2 = sa1 * sa1 |
---|
408 | |
---|
409 | pnom = nom(1) + nom(2)*pt1 + nom(3)*pt2 + & |
---|
410 | nom(4)*pt3 + nom(5)*sa1 + nom(6)*sa1*pt1 + nom(7)*sa2 |
---|
411 | |
---|
412 | pden = den(1) + den(2)*pt1 + den(3)*pt2 + & |
---|
413 | den(4)*pt3 + den(5)*pt4 + den(6)*sa1 + & |
---|
414 | den(7)*sa1*pt1 + den(8)*sa1*pt3 + den(9)*sa15 + & |
---|
415 | den(10)*sa15*pt2 |
---|
416 | ! |
---|
417 | !-- Potential density (without pressure terms) |
---|
418 | prho(k,j,i) = pnom / pden |
---|
419 | |
---|
420 | pnom = pnom + nom(8)*p1 + nom(9)*p1*pt2 + & |
---|
421 | nom(10)*p1*sa1 + nom(11)*p2 + nom(12)*p2*pt2 |
---|
422 | pden = pden + den(11)*p1 + den(12)*p2*pt3 + & |
---|
423 | den(13)*p3*pt1 |
---|
424 | |
---|
425 | ! |
---|
426 | !-- In-situ density |
---|
427 | rho_ocean(k,j,i) = pnom / pden |
---|
428 | |
---|
429 | ENDDO |
---|
430 | ! |
---|
431 | !-- Neumann conditions at up/downward-facing walls |
---|
432 | surf_s = bc_h(0)%start_index(j,i) |
---|
433 | surf_e = bc_h(0)%end_index(j,i) |
---|
434 | DO m = surf_s, surf_e |
---|
435 | k = bc_h(0)%k(m) |
---|
436 | prho(k-1,j,i) = prho(k,j,i) |
---|
437 | rho_ocean(k-1,j,i) = rho_ocean(k,j,i) |
---|
438 | ENDDO |
---|
439 | ! |
---|
440 | !-- Downward facing surfaces |
---|
441 | surf_s = bc_h(1)%start_index(j,i) |
---|
442 | surf_e = bc_h(1)%end_index(j,i) |
---|
443 | DO m = surf_s, surf_e |
---|
444 | k = bc_h(1)%k(m) |
---|
445 | prho(k+1,j,i) = prho(k,j,i) |
---|
446 | rho_ocean(k+1,j,i) = rho_ocean(k,j,i) |
---|
447 | ENDDO |
---|
448 | ! |
---|
449 | !-- Neumann condition are assumed at top boundary |
---|
450 | prho(nzt+1,j,i) = prho(nzt,j,i) |
---|
451 | rho_ocean(nzt+1,j,i) = rho_ocean(nzt,j,i) |
---|
452 | |
---|
453 | END SUBROUTINE eqn_state_seawater_ij |
---|
454 | |
---|
455 | |
---|
456 | !------------------------------------------------------------------------------! |
---|
457 | ! Description: |
---|
458 | ! ------------ |
---|
459 | !> Equation of state for seawater as a function |
---|
460 | !------------------------------------------------------------------------------! |
---|
461 | REAL(wp) FUNCTION eqn_state_seawater_func( p, pt, sa ) |
---|
462 | |
---|
463 | IMPLICIT NONE |
---|
464 | |
---|
465 | REAL(wp) :: p !< temporary scalar user for calculating density |
---|
466 | REAL(wp) :: p1 !< temporary scalar user for calculating density |
---|
467 | REAL(wp) :: p2 !< temporary scalar user for calculating density |
---|
468 | REAL(wp) :: p3 !< temporary scalar user for calculating density |
---|
469 | REAL(wp) :: pt !< temporary scalar user for calculating density |
---|
470 | REAL(wp) :: pt1 !< temporary scalar user for calculating density |
---|
471 | REAL(wp) :: pt2 !< temporary scalar user for calculating density |
---|
472 | REAL(wp) :: pt3 !< temporary scalar user for calculating density |
---|
473 | REAL(wp) :: pt4 !< temporary scalar user for calculating density |
---|
474 | REAL(wp) :: sa !< temporary scalar user for calculating density |
---|
475 | REAL(wp) :: sa15 !< temporary scalar user for calculating density |
---|
476 | REAL(wp) :: sa2 !< temporary scalar user for calculating density |
---|
477 | |
---|
478 | ! |
---|
479 | !-- Pressure is needed in dbar |
---|
480 | p1 = p * 1.0E-4_wp |
---|
481 | p2 = p1 * p1 |
---|
482 | p3 = p2 * p1 |
---|
483 | |
---|
484 | ! |
---|
485 | !-- Temperature needed in degree Celsius |
---|
486 | pt1 = pt - 273.15_wp |
---|
487 | pt2 = pt1 * pt1 |
---|
488 | pt3 = pt1 * pt2 |
---|
489 | pt4 = pt2 * pt2 |
---|
490 | |
---|
491 | sa15 = sa * SQRT( sa ) |
---|
492 | sa2 = sa * sa |
---|
493 | |
---|
494 | |
---|
495 | eqn_state_seawater_func = & |
---|
496 | ( nom(1) + nom(2)*pt1 + nom(3)*pt2 + nom(4)*pt3 + & |
---|
497 | nom(5)*sa + nom(6)*sa*pt1 + nom(7)*sa2 + nom(8)*p1 + & |
---|
498 | nom(9)*p1*pt2 + nom(10)*p1*sa + nom(11)*p2 + nom(12)*p2*pt2 & |
---|
499 | ) / & |
---|
500 | ( den(1) + den(2)*pt1 + den(3)*pt2 + den(4)*pt3 + & |
---|
501 | den(5)*pt4 + den(6)*sa + den(7)*sa*pt1 + den(8)*sa*pt3 + & |
---|
502 | den(9)*sa15 + den(10)*sa15*pt2 + den(11)*p1 + den(12)*p2*pt3 + & |
---|
503 | den(13)*p3*pt1 & |
---|
504 | ) |
---|
505 | |
---|
506 | |
---|
507 | END FUNCTION eqn_state_seawater_func |
---|
508 | |
---|
509 | |
---|
510 | !------------------------------------------------------------------------------! |
---|
511 | ! Description: |
---|
512 | ! ------------ |
---|
513 | !> Reads the ocean parameters namelist |
---|
514 | !------------------------------------------------------------------------------! |
---|
515 | SUBROUTINE ocean_parin |
---|
516 | |
---|
517 | IMPLICIT NONE |
---|
518 | |
---|
519 | CHARACTER (LEN=80) :: line !< dummy string that contains the current line of the parameter file |
---|
520 | |
---|
521 | |
---|
522 | NAMELIST /ocean_parameters/ bc_sa_t, bottom_salinityflux, salinity, & |
---|
523 | sa_surface, sa_vertical_gradient, sa_vertical_gradient_level, & |
---|
524 | stokes_waveheight, stokes_wavelength, surface_cooling_spinup_time,& |
---|
525 | top_salinityflux, wall_salinityflux, wave_breaking |
---|
526 | |
---|
527 | ! |
---|
528 | !-- Try to find the namelist |
---|
529 | REWIND ( 11 ) |
---|
530 | line = ' ' |
---|
531 | DO WHILE ( INDEX( line, '&ocean_parameters' ) == 0 ) |
---|
532 | READ ( 11, '(A)', END=12 ) line |
---|
533 | ENDDO |
---|
534 | BACKSPACE ( 11 ) |
---|
535 | |
---|
536 | ! |
---|
537 | !-- Read namelist |
---|
538 | READ ( 11, ocean_parameters, ERR = 10 ) |
---|
539 | ! |
---|
540 | !-- Set switch that enables PALM's ocean mode |
---|
541 | ocean_mode = .TRUE. |
---|
542 | |
---|
543 | GOTO 12 |
---|
544 | |
---|
545 | 10 BACKSPACE( 11 ) |
---|
546 | READ( 11 , '(A)') line |
---|
547 | CALL parin_fail_message( 'ocean_parameters', line ) |
---|
548 | |
---|
549 | 12 CONTINUE |
---|
550 | |
---|
551 | END SUBROUTINE ocean_parin |
---|
552 | |
---|
553 | !------------------------------------------------------------------------------! |
---|
554 | ! Description: |
---|
555 | ! ------------ |
---|
556 | !> Check parameters routine for the ocean mode |
---|
557 | !------------------------------------------------------------------------------! |
---|
558 | SUBROUTINE ocean_check_parameters |
---|
559 | |
---|
560 | USE control_parameters, & |
---|
561 | ONLY: coupling_char, coupling_mode, initializing_actions, & |
---|
562 | message_string, use_top_fluxes |
---|
563 | |
---|
564 | USE pmc_interface, & |
---|
565 | ONLY: nested_run |
---|
566 | |
---|
567 | IMPLICIT NONE |
---|
568 | |
---|
569 | |
---|
570 | ! |
---|
571 | !-- Check for invalid combinations |
---|
572 | IF ( nested_run ) THEN |
---|
573 | message_string = 'ocean mode not allowed for nesting' |
---|
574 | CALL message( 'ocean_check_parameters', 'PA0510', 1, 2, 0, 6, 0 ) |
---|
575 | ENDIF |
---|
576 | |
---|
577 | IF ( TRIM( initializing_actions ) == 'cyclic_fill' ) THEN |
---|
578 | message_string = 'ocean mode does not allow cyclic-fill initialization' |
---|
579 | CALL message( 'ocean_check_parameters', 'PA0511', 1, 2, 0, 6, 0 ) |
---|
580 | ENDIF |
---|
581 | |
---|
582 | ! |
---|
583 | !-- Check ocean setting |
---|
584 | IF ( TRIM( coupling_mode ) == 'uncoupled' .AND. & |
---|
585 | TRIM( coupling_char ) == '_O' .AND. & |
---|
586 | .NOT. ocean_mode ) THEN |
---|
587 | |
---|
588 | ! |
---|
589 | !-- Check whether an (uncoupled) atmospheric run has been declared as an |
---|
590 | !-- ocean run (this setting is done via palmrun-option -y) |
---|
591 | message_string = 'ocean mode does not allow coupling_char = "' // & |
---|
592 | TRIM( coupling_char ) // '" set by palmrun-option "-y"' |
---|
593 | CALL message( 'ocean_check_parameters', 'PA0317', 1, 2, 0, 6, 0 ) |
---|
594 | |
---|
595 | ENDIF |
---|
596 | |
---|
597 | ! |
---|
598 | !-- Ocean version must use flux boundary conditions at the top |
---|
599 | IF ( .NOT. use_top_fluxes ) THEN |
---|
600 | message_string = 'use_top_fluxes must be .TRUE. in ocean mode' |
---|
601 | CALL message( 'ocean_check_parameters', 'PA0042', 1, 2, 0, 6, 0 ) |
---|
602 | ENDIF |
---|
603 | |
---|
604 | ! |
---|
605 | !-- Boundary conditions for salinity |
---|
606 | IF ( bc_sa_t == 'dirichlet' ) THEN |
---|
607 | ibc_sa_t = 0 |
---|
608 | ELSEIF ( bc_sa_t == 'neumann' ) THEN |
---|
609 | ibc_sa_t = 1 |
---|
610 | ELSE |
---|
611 | message_string = 'unknown boundary condition: bc_sa_t = "' // & |
---|
612 | TRIM( bc_sa_t ) // '"' |
---|
613 | CALL message( 'ocean_check_parameters', 'PA0068', 1, 2, 0, 6, 0 ) |
---|
614 | ENDIF |
---|
615 | |
---|
616 | IF ( top_salinityflux == 9999999.9_wp ) constant_top_salinityflux = .FALSE. |
---|
617 | |
---|
618 | IF ( .NOT. salinity ) THEN |
---|
619 | IF ( ( bottom_salinityflux /= 0.0_wp .AND. & |
---|
620 | bottom_salinityflux /= 9999999.9_wp ) .OR. & |
---|
621 | ( top_salinityflux /= 0.0_wp .AND. & |
---|
622 | top_salinityflux /= 9999999.9_wp ) ) & |
---|
623 | THEN |
---|
624 | message_string = 'salinityflux must not be set for ocean run ' // & |
---|
625 | 'without salinity' |
---|
626 | CALL message( 'ocean_check_parameters', 'PA0509', 1, 2, 0, 6, 0 ) |
---|
627 | ENDIF |
---|
628 | ENDIF |
---|
629 | |
---|
630 | IF ( ibc_sa_t == 1 .AND. top_salinityflux == 9999999.9_wp ) THEN |
---|
631 | message_string = 'boundary condition: bc_sa_t = "' // & |
---|
632 | TRIM( bc_sa_t ) // '" requires to set top_salinityflux' |
---|
633 | CALL message( 'ocean_check_parameters', 'PA0069', 1, 2, 0, 6, 0 ) |
---|
634 | ENDIF |
---|
635 | |
---|
636 | ! |
---|
637 | !-- A fixed salinity at the top implies Dirichlet boundary condition for |
---|
638 | !-- salinity. In this case specification of a constant salinity flux is |
---|
639 | !-- forbidden. |
---|
640 | IF ( ibc_sa_t == 0 .AND. constant_top_salinityflux .AND. & |
---|
641 | top_salinityflux /= 0.0_wp ) THEN |
---|
642 | message_string = 'boundary condition: bc_sa_t = "' // & |
---|
643 | TRIM( bc_sa_t ) // '" is not allowed with ' // & |
---|
644 | 'top_salinityflux /= 0.0' |
---|
645 | CALL message( 'ocean_check_parameters', 'PA0070', 1, 2, 0, 6, 0 ) |
---|
646 | ENDIF |
---|
647 | |
---|
648 | ! |
---|
649 | !-- Check if Stokes force is to be used |
---|
650 | IF ( stokes_waveheight /= 0.0_wp .AND. stokes_wavelength /= 0.0_wp ) THEN |
---|
651 | stokes_force = .TRUE. |
---|
652 | ELSE |
---|
653 | IF ( ( stokes_waveheight <= 0.0_wp .AND. stokes_wavelength > 0.0_wp ) & |
---|
654 | .OR. & |
---|
655 | ( stokes_waveheight > 0.0_wp .AND. stokes_wavelength <= 0.0_wp ) & |
---|
656 | .OR. & |
---|
657 | ( stokes_waveheight < 0.0_wp .AND. stokes_wavelength < 0.0_wp ) ) & |
---|
658 | THEN |
---|
659 | message_string = 'wrong settings for stokes_wavelength and/or ' // & |
---|
660 | 'stokes_waveheight' |
---|
661 | CALL message( 'ocean_check_parameters', 'PA0460', 1, 2, 0, 6, 0 ) |
---|
662 | ENDIF |
---|
663 | ENDIF |
---|
664 | |
---|
665 | END SUBROUTINE ocean_check_parameters |
---|
666 | |
---|
667 | |
---|
668 | !------------------------------------------------------------------------------! |
---|
669 | ! Description: |
---|
670 | ! ------------ |
---|
671 | !> Check data output. |
---|
672 | !------------------------------------------------------------------------------! |
---|
673 | SUBROUTINE ocean_check_data_output( var, unit ) |
---|
674 | |
---|
675 | IMPLICIT NONE |
---|
676 | |
---|
677 | CHARACTER (LEN=*) :: unit !< unit of output variable |
---|
678 | CHARACTER (LEN=*) :: var !< name of output variable |
---|
679 | |
---|
680 | |
---|
681 | SELECT CASE ( TRIM( var ) ) |
---|
682 | |
---|
683 | CASE ( 'rho_sea_water' ) |
---|
684 | unit = 'kg/m3' |
---|
685 | |
---|
686 | CASE ( 'sa' ) |
---|
687 | unit = 'psu' |
---|
688 | |
---|
689 | CASE DEFAULT |
---|
690 | unit = 'illegal' |
---|
691 | |
---|
692 | END SELECT |
---|
693 | |
---|
694 | END SUBROUTINE ocean_check_data_output |
---|
695 | |
---|
696 | |
---|
697 | !------------------------------------------------------------------------------! |
---|
698 | ! Description: |
---|
699 | ! ------------ |
---|
700 | !> Check data output of profiles |
---|
701 | !------------------------------------------------------------------------------! |
---|
702 | SUBROUTINE ocean_check_data_output_pr( variable, var_count, unit, dopr_unit ) |
---|
703 | |
---|
704 | USE arrays_3d, & |
---|
705 | ONLY: zu, zw |
---|
706 | |
---|
707 | USE control_parameters, & |
---|
708 | ONLY: data_output_pr |
---|
709 | |
---|
710 | USE indices |
---|
711 | |
---|
712 | USE profil_parameter |
---|
713 | |
---|
714 | USE statistics |
---|
715 | |
---|
716 | IMPLICIT NONE |
---|
717 | |
---|
718 | CHARACTER (LEN=*) :: unit !< |
---|
719 | CHARACTER (LEN=*) :: variable !< |
---|
720 | CHARACTER (LEN=*) :: dopr_unit !< local value of dopr_unit |
---|
721 | |
---|
722 | INTEGER(iwp) :: var_count !< |
---|
723 | |
---|
724 | SELECT CASE ( TRIM( variable ) ) |
---|
725 | |
---|
726 | CASE ( 'prho' ) |
---|
727 | dopr_index(var_count) = 71 |
---|
728 | dopr_unit = 'kg/m3' |
---|
729 | hom(:,2,71,:) = SPREAD( zu, 2, statistic_regions+1 ) |
---|
730 | unit = dopr_unit |
---|
731 | |
---|
732 | CASE ( 'rho_sea_water' ) |
---|
733 | dopr_index(var_count) = 64 |
---|
734 | dopr_unit = 'kg/m3' |
---|
735 | hom(:,2,64,:) = SPREAD( zu, 2, statistic_regions+1 ) |
---|
736 | IF ( data_output_pr(var_count)(1:1) == '#' ) THEN |
---|
737 | dopr_initial_index(var_count) = 77 |
---|
738 | hom(:,2,77,:) = SPREAD( zu, 2, statistic_regions+1 ) |
---|
739 | hom(nzb,2,77,:) = 0.0_wp ! because zu(nzb) is negative |
---|
740 | data_output_pr(var_count) = data_output_pr(var_count)(2:) |
---|
741 | ENDIF |
---|
742 | unit = dopr_unit |
---|
743 | |
---|
744 | CASE ( 'sa', '#sa' ) |
---|
745 | dopr_index(var_count) = 23 |
---|
746 | dopr_unit = 'psu' |
---|
747 | hom(:,2,23,:) = SPREAD( zu, 2, statistic_regions+1 ) |
---|
748 | IF ( data_output_pr(var_count)(1:1) == '#' ) THEN |
---|
749 | dopr_initial_index(var_count) = 26 |
---|
750 | hom(:,2,26,:) = SPREAD( zu, 2, statistic_regions+1 ) |
---|
751 | hom(nzb,2,26,:) = 0.0_wp ! because zu(nzb) is negative |
---|
752 | data_output_pr(var_count) = data_output_pr(var_count)(2:) |
---|
753 | ENDIF |
---|
754 | unit = dopr_unit |
---|
755 | |
---|
756 | CASE ( 'w"sa"' ) |
---|
757 | dopr_index(var_count) = 65 |
---|
758 | dopr_unit = 'psu m/s' |
---|
759 | hom(:,2,65,:) = SPREAD( zw, 2, statistic_regions+1 ) |
---|
760 | unit = dopr_unit |
---|
761 | |
---|
762 | CASE ( 'w*sa*' ) |
---|
763 | dopr_index(var_count) = 66 |
---|
764 | dopr_unit = 'psu m/s' |
---|
765 | hom(:,2,66,:) = SPREAD( zw, 2, statistic_regions+1 ) |
---|
766 | unit = dopr_unit |
---|
767 | |
---|
768 | CASE ( 'wsa' ) |
---|
769 | dopr_index(var_count) = 67 |
---|
770 | dopr_unit = 'psu m/s' |
---|
771 | hom(:,2,67,:) = SPREAD( zw, 2, statistic_regions+1 ) |
---|
772 | unit = dopr_unit |
---|
773 | |
---|
774 | CASE DEFAULT |
---|
775 | unit = 'illegal' |
---|
776 | |
---|
777 | END SELECT |
---|
778 | |
---|
779 | |
---|
780 | END SUBROUTINE ocean_check_data_output_pr |
---|
781 | |
---|
782 | |
---|
783 | !------------------------------------------------------------------------------! |
---|
784 | ! Description: |
---|
785 | ! ------------ |
---|
786 | !> Define appropriate grid for netcdf variables. |
---|
787 | !> It is called out from subroutine netcdf. |
---|
788 | !------------------------------------------------------------------------------! |
---|
789 | SUBROUTINE ocean_define_netcdf_grid( var, found, grid_x, grid_y, grid_z ) |
---|
790 | |
---|
791 | IMPLICIT NONE |
---|
792 | |
---|
793 | CHARACTER (LEN=*), INTENT(OUT) :: grid_x !< x grid of output variable |
---|
794 | CHARACTER (LEN=*), INTENT(OUT) :: grid_y !< y grid of output variable |
---|
795 | CHARACTER (LEN=*), INTENT(OUT) :: grid_z !< z grid of output variable |
---|
796 | CHARACTER (LEN=*), INTENT(IN) :: var !< name of output variable |
---|
797 | |
---|
798 | LOGICAL, INTENT(OUT) :: found !< flag if output variable is found |
---|
799 | |
---|
800 | found = .TRUE. |
---|
801 | |
---|
802 | ! |
---|
803 | !-- Check for the grid |
---|
804 | SELECT CASE ( TRIM( var ) ) |
---|
805 | |
---|
806 | CASE ( 'rho_sea_water', 'rho_sea_water_xy', 'rho_sea_water_xz', & |
---|
807 | 'rho_sea_water_yz', 'sa', 'sa_xy', 'sa_xz', 'sa_yz' ) |
---|
808 | grid_x = 'x' |
---|
809 | grid_y = 'y' |
---|
810 | grid_z = 'zu' |
---|
811 | |
---|
812 | CASE DEFAULT |
---|
813 | found = .FALSE. |
---|
814 | grid_x = 'none' |
---|
815 | grid_y = 'none' |
---|
816 | grid_z = 'none' |
---|
817 | |
---|
818 | END SELECT |
---|
819 | |
---|
820 | END SUBROUTINE ocean_define_netcdf_grid |
---|
821 | |
---|
822 | |
---|
823 | !------------------------------------------------------------------------------! |
---|
824 | ! Description: |
---|
825 | ! ------------ |
---|
826 | !> Average 3D data. |
---|
827 | !------------------------------------------------------------------------------! |
---|
828 | SUBROUTINE ocean_3d_data_averaging( mode, variable ) |
---|
829 | |
---|
830 | |
---|
831 | USE arrays_3d, & |
---|
832 | ONLY: rho_ocean, sa |
---|
833 | |
---|
834 | USE averaging, & |
---|
835 | ONLY: rho_ocean_av, sa_av |
---|
836 | |
---|
837 | USE control_parameters, & |
---|
838 | ONLY: average_count_3d |
---|
839 | |
---|
840 | USE indices, & |
---|
841 | ONLY: nxlg, nxrg, nyng, nysg, nzb, nzt |
---|
842 | |
---|
843 | IMPLICIT NONE |
---|
844 | |
---|
845 | CHARACTER (LEN=*) :: mode !< flag defining mode 'allocate', 'sum' or 'average' |
---|
846 | CHARACTER (LEN=*) :: variable !< name of variable |
---|
847 | |
---|
848 | INTEGER(iwp) :: i !< loop index |
---|
849 | INTEGER(iwp) :: j !< loop index |
---|
850 | INTEGER(iwp) :: k !< loop index |
---|
851 | |
---|
852 | IF ( mode == 'allocate' ) THEN |
---|
853 | |
---|
854 | SELECT CASE ( TRIM( variable ) ) |
---|
855 | |
---|
856 | CASE ( 'rho_sea_water' ) |
---|
857 | IF ( .NOT. ALLOCATED( rho_ocean_av ) ) THEN |
---|
858 | ALLOCATE( rho_ocean_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
859 | ENDIF |
---|
860 | rho_ocean_av = 0.0_wp |
---|
861 | |
---|
862 | CASE ( 'sa' ) |
---|
863 | IF ( .NOT. ALLOCATED( sa_av ) ) THEN |
---|
864 | ALLOCATE( sa_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
865 | ENDIF |
---|
866 | sa_av = 0.0_wp |
---|
867 | |
---|
868 | CASE DEFAULT |
---|
869 | CONTINUE |
---|
870 | |
---|
871 | END SELECT |
---|
872 | |
---|
873 | ELSEIF ( mode == 'sum' ) THEN |
---|
874 | |
---|
875 | SELECT CASE ( TRIM( variable ) ) |
---|
876 | |
---|
877 | CASE ( 'rho_sea_water' ) |
---|
878 | IF ( ALLOCATED( rho_ocean_av ) ) THEN |
---|
879 | DO i = nxlg, nxrg |
---|
880 | DO j = nysg, nyng |
---|
881 | DO k = nzb, nzt+1 |
---|
882 | rho_ocean_av(k,j,i) = rho_ocean_av(k,j,i) + & |
---|
883 | rho_ocean(k,j,i) |
---|
884 | ENDDO |
---|
885 | ENDDO |
---|
886 | ENDDO |
---|
887 | ENDIF |
---|
888 | |
---|
889 | CASE ( 'sa' ) |
---|
890 | IF ( ALLOCATED( sa_av ) ) THEN |
---|
891 | DO i = nxlg, nxrg |
---|
892 | DO j = nysg, nyng |
---|
893 | DO k = nzb, nzt+1 |
---|
894 | sa_av(k,j,i) = sa_av(k,j,i) + sa(k,j,i) |
---|
895 | ENDDO |
---|
896 | ENDDO |
---|
897 | ENDDO |
---|
898 | ENDIF |
---|
899 | |
---|
900 | CASE DEFAULT |
---|
901 | CONTINUE |
---|
902 | |
---|
903 | END SELECT |
---|
904 | |
---|
905 | ELSEIF ( mode == 'average' ) THEN |
---|
906 | |
---|
907 | SELECT CASE ( TRIM( variable ) ) |
---|
908 | |
---|
909 | CASE ( 'rho_sea_water' ) |
---|
910 | IF ( ALLOCATED( rho_ocean_av ) ) THEN |
---|
911 | DO i = nxlg, nxrg |
---|
912 | DO j = nysg, nyng |
---|
913 | DO k = nzb, nzt+1 |
---|
914 | rho_ocean_av(k,j,i) = rho_ocean_av(k,j,i) / & |
---|
915 | REAL( average_count_3d, KIND=wp ) |
---|
916 | ENDDO |
---|
917 | ENDDO |
---|
918 | ENDDO |
---|
919 | ENDIF |
---|
920 | |
---|
921 | CASE ( 'sa' ) |
---|
922 | IF ( ALLOCATED( sa_av ) ) THEN |
---|
923 | DO i = nxlg, nxrg |
---|
924 | DO j = nysg, nyng |
---|
925 | DO k = nzb, nzt+1 |
---|
926 | sa_av(k,j,i) = sa_av(k,j,i) / & |
---|
927 | REAL( average_count_3d, KIND=wp ) |
---|
928 | ENDDO |
---|
929 | ENDDO |
---|
930 | ENDDO |
---|
931 | ENDIF |
---|
932 | |
---|
933 | END SELECT |
---|
934 | |
---|
935 | ENDIF |
---|
936 | |
---|
937 | END SUBROUTINE ocean_3d_data_averaging |
---|
938 | |
---|
939 | |
---|
940 | !------------------------------------------------------------------------------! |
---|
941 | ! Description: |
---|
942 | ! ------------ |
---|
943 | !> Define 2D output variables. |
---|
944 | !------------------------------------------------------------------------------! |
---|
945 | SUBROUTINE ocean_data_output_2d( av, variable, found, grid, mode, local_pf, & |
---|
946 | nzb_do, nzt_do ) |
---|
947 | |
---|
948 | USE arrays_3d, & |
---|
949 | ONLY: rho_ocean, sa |
---|
950 | |
---|
951 | USE averaging, & |
---|
952 | ONLY: rho_ocean_av, sa_av |
---|
953 | |
---|
954 | USE indices, & |
---|
955 | ONLY: nxl, nxlg, nxr, nxrg, nyn, nyng, nys, nysg, nzb, nzt, & |
---|
956 | wall_flags_0 |
---|
957 | |
---|
958 | IMPLICIT NONE |
---|
959 | |
---|
960 | CHARACTER (LEN=*) :: grid !< name of vertical grid |
---|
961 | CHARACTER (LEN=*) :: mode !< either 'xy', 'xz' or 'yz' |
---|
962 | CHARACTER (LEN=*) :: variable !< name of variable |
---|
963 | |
---|
964 | INTEGER(iwp) :: av !< flag for (non-)average output |
---|
965 | INTEGER(iwp) :: flag_nr !< number of masking flag |
---|
966 | INTEGER(iwp) :: i !< loop index |
---|
967 | INTEGER(iwp) :: j !< loop index |
---|
968 | INTEGER(iwp) :: k !< loop index |
---|
969 | INTEGER(iwp) :: nzb_do !< vertical output index (bottom) |
---|
970 | INTEGER(iwp) :: nzt_do !< vertical output index (top) |
---|
971 | |
---|
972 | LOGICAL :: found !< flag if output variable is found |
---|
973 | LOGICAL :: resorted !< flag if output is already resorted |
---|
974 | |
---|
975 | REAL(wp) :: fill_value = -999.0_wp !< value for the _FillValue attribute |
---|
976 | |
---|
977 | REAL(wp), DIMENSION(nxl:nxr,nys:nyn,nzb_do:nzt_do) :: local_pf !< local |
---|
978 | !< array to which output data is resorted to |
---|
979 | |
---|
980 | REAL(wp), DIMENSION(:,:,:), POINTER :: to_be_resorted !< points to selected output variable |
---|
981 | |
---|
982 | found = .TRUE. |
---|
983 | resorted = .FALSE. |
---|
984 | ! |
---|
985 | !-- Set masking flag for topography for not resorted arrays |
---|
986 | flag_nr = 0 |
---|
987 | |
---|
988 | SELECT CASE ( TRIM( variable ) ) |
---|
989 | |
---|
990 | CASE ( 'rho_sea_water_xy', 'rho_sea_water_xz', 'rho_sea_water_yz' ) |
---|
991 | IF ( av == 0 ) THEN |
---|
992 | to_be_resorted => rho_ocean |
---|
993 | ELSE |
---|
994 | IF ( .NOT. ALLOCATED( rho_ocean_av ) ) THEN |
---|
995 | ALLOCATE( rho_ocean_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
996 | rho_ocean_av = REAL( fill_value, KIND = wp ) |
---|
997 | ENDIF |
---|
998 | to_be_resorted => rho_ocean_av |
---|
999 | ENDIF |
---|
1000 | |
---|
1001 | CASE ( 'sa_xy', 'sa_xz', 'sa_yz' ) |
---|
1002 | IF ( av == 0 ) THEN |
---|
1003 | to_be_resorted => sa |
---|
1004 | ELSE |
---|
1005 | IF ( .NOT. ALLOCATED( sa_av ) ) THEN |
---|
1006 | ALLOCATE( sa_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
1007 | sa_av = REAL( fill_value, KIND = wp ) |
---|
1008 | ENDIF |
---|
1009 | to_be_resorted => sa_av |
---|
1010 | ENDIF |
---|
1011 | IF ( mode == 'xy' ) grid = 'zu' |
---|
1012 | |
---|
1013 | CASE DEFAULT |
---|
1014 | found = .FALSE. |
---|
1015 | grid = 'none' |
---|
1016 | |
---|
1017 | END SELECT |
---|
1018 | |
---|
1019 | IF ( found .AND. .NOT. resorted ) THEN |
---|
1020 | DO i = nxl, nxr |
---|
1021 | DO j = nys, nyn |
---|
1022 | DO k = nzb_do, nzt_do |
---|
1023 | local_pf(i,j,k) = MERGE( to_be_resorted(k,j,i), & |
---|
1024 | REAL( fill_value, KIND = wp ), & |
---|
1025 | BTEST( wall_flags_0(k,j,i), flag_nr ) ) |
---|
1026 | ENDDO |
---|
1027 | ENDDO |
---|
1028 | ENDDO |
---|
1029 | resorted = .TRUE. |
---|
1030 | ENDIF |
---|
1031 | |
---|
1032 | END SUBROUTINE ocean_data_output_2d |
---|
1033 | |
---|
1034 | |
---|
1035 | !------------------------------------------------------------------------------! |
---|
1036 | ! Description: |
---|
1037 | ! ------------ |
---|
1038 | !> Define 3D output variables. |
---|
1039 | !------------------------------------------------------------------------------! |
---|
1040 | SUBROUTINE ocean_data_output_3d( av, variable, found, local_pf, nzb_do, nzt_do ) |
---|
1041 | |
---|
1042 | |
---|
1043 | USE arrays_3d, & |
---|
1044 | ONLY: rho_ocean, sa |
---|
1045 | |
---|
1046 | USE averaging, & |
---|
1047 | ONLY: rho_ocean_av, sa_av |
---|
1048 | |
---|
1049 | USE indices, & |
---|
1050 | ONLY: nxl, nxlg, nxr, nxrg, nyn, nyng, nys, nysg, nzb, nzt, & |
---|
1051 | wall_flags_0 |
---|
1052 | |
---|
1053 | IMPLICIT NONE |
---|
1054 | |
---|
1055 | CHARACTER (LEN=*) :: variable !< name of variable |
---|
1056 | |
---|
1057 | INTEGER(iwp) :: av !< flag for (non-)average output |
---|
1058 | INTEGER(iwp) :: flag_nr !< number of masking flag |
---|
1059 | INTEGER(iwp) :: i !< loop index |
---|
1060 | INTEGER(iwp) :: j !< loop index |
---|
1061 | INTEGER(iwp) :: k !< loop index |
---|
1062 | INTEGER(iwp) :: nzb_do !< lower limit of the data output (usually 0) |
---|
1063 | INTEGER(iwp) :: nzt_do !< vertical upper limit of the data output (usually nz_do3d) |
---|
1064 | |
---|
1065 | LOGICAL :: found !< flag if output variable is found |
---|
1066 | LOGICAL :: resorted !< flag if output is already resorted |
---|
1067 | |
---|
1068 | REAL(wp) :: fill_value = -999.0_wp !< value for the _FillValue attribute |
---|
1069 | |
---|
1070 | REAL(sp), DIMENSION(nxl:nxr,nys:nyn,nzb_do:nzt_do) :: local_pf !< local |
---|
1071 | !< array to which output data is resorted to |
---|
1072 | |
---|
1073 | REAL(wp), DIMENSION(:,:,:), POINTER :: to_be_resorted !< points to selected output variable |
---|
1074 | |
---|
1075 | found = .TRUE. |
---|
1076 | resorted = .FALSE. |
---|
1077 | ! |
---|
1078 | !-- Set masking flag for topography for not resorted arrays |
---|
1079 | flag_nr = 0 |
---|
1080 | |
---|
1081 | SELECT CASE ( TRIM( variable ) ) |
---|
1082 | |
---|
1083 | CASE ( 'rho_sea_water' ) |
---|
1084 | IF ( av == 0 ) THEN |
---|
1085 | to_be_resorted => rho_ocean |
---|
1086 | ELSE |
---|
1087 | IF ( .NOT. ALLOCATED( rho_ocean_av ) ) THEN |
---|
1088 | ALLOCATE( rho_ocean_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
1089 | rho_ocean_av = REAL( fill_value, KIND = wp ) |
---|
1090 | ENDIF |
---|
1091 | to_be_resorted => rho_ocean_av |
---|
1092 | ENDIF |
---|
1093 | |
---|
1094 | CASE ( 'sa' ) |
---|
1095 | IF ( av == 0 ) THEN |
---|
1096 | to_be_resorted => sa |
---|
1097 | ELSE |
---|
1098 | IF ( .NOT. ALLOCATED( sa_av ) ) THEN |
---|
1099 | ALLOCATE( sa_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
1100 | sa_av = REAL( fill_value, KIND = wp ) |
---|
1101 | ENDIF |
---|
1102 | to_be_resorted => sa_av |
---|
1103 | ENDIF |
---|
1104 | |
---|
1105 | CASE DEFAULT |
---|
1106 | found = .FALSE. |
---|
1107 | |
---|
1108 | END SELECT |
---|
1109 | |
---|
1110 | |
---|
1111 | IF ( found .AND. .NOT. resorted ) THEN |
---|
1112 | DO i = nxl, nxr |
---|
1113 | DO j = nys, nyn |
---|
1114 | DO k = nzb_do, nzt_do |
---|
1115 | local_pf(i,j,k) = MERGE( to_be_resorted(k,j,i), & |
---|
1116 | REAL( fill_value, KIND = wp ), & |
---|
1117 | BTEST( wall_flags_0(k,j,i), flag_nr ) ) |
---|
1118 | ENDDO |
---|
1119 | ENDDO |
---|
1120 | ENDDO |
---|
1121 | resorted = .TRUE. |
---|
1122 | ENDIF |
---|
1123 | |
---|
1124 | END SUBROUTINE ocean_data_output_3d |
---|
1125 | |
---|
1126 | |
---|
1127 | !------------------------------------------------------------------------------! |
---|
1128 | ! Description: |
---|
1129 | ! ------------ |
---|
1130 | !> Header output for ocean parameters |
---|
1131 | !------------------------------------------------------------------------------! |
---|
1132 | SUBROUTINE ocean_header( io ) |
---|
1133 | |
---|
1134 | |
---|
1135 | IMPLICIT NONE |
---|
1136 | |
---|
1137 | INTEGER(iwp), INTENT(IN) :: io !< Unit of the output file |
---|
1138 | |
---|
1139 | ! |
---|
1140 | !-- Write ocean header |
---|
1141 | WRITE( io, 1 ) |
---|
1142 | IF ( stokes_force ) WRITE( io, 2 ) stokes_waveheight, stokes_wavelength |
---|
1143 | IF ( wave_breaking ) THEN |
---|
1144 | WRITE( io, 3 ) alpha_wave_breaking, timescale_wave_breaking |
---|
1145 | ENDIF |
---|
1146 | IF ( .NOT. salinity ) WRITE( io, 4 ) |
---|
1147 | IF ( surface_cooling_spinup_time /= 999999.9_wp ) THEN |
---|
1148 | WRITE( io, 5 ) surface_cooling_spinup_time |
---|
1149 | ENDIF |
---|
1150 | |
---|
1151 | 1 FORMAT (//' Ocean settings:'/ & |
---|
1152 | ' ------------------------------------------'/) |
---|
1153 | 2 FORMAT (' --> Craik-Leibovich vortex force and Stokes drift switched', & |
---|
1154 | ' on'/ & |
---|
1155 | ' waveheight: ',F4.1,' m wavelength: ',F6.1,' m') |
---|
1156 | 3 FORMAT (' --> wave breaking generated turbulence switched on'/ & |
---|
1157 | ' alpha: ',F4.1/ & |
---|
1158 | ' timescale:',F5.1,' s') |
---|
1159 | 4 FORMAT (' --> prognostic salinity equation is switched off' ) |
---|
1160 | 5 FORMAT (' --> surface heat flux is switched off after ',F8.1,' s') |
---|
1161 | |
---|
1162 | END SUBROUTINE ocean_header |
---|
1163 | |
---|
1164 | |
---|
1165 | !------------------------------------------------------------------------------! |
---|
1166 | ! Description: |
---|
1167 | ! ------------ |
---|
1168 | !> Allocate arrays and assign pointers. |
---|
1169 | !------------------------------------------------------------------------------! |
---|
1170 | SUBROUTINE ocean_init_arrays |
---|
1171 | |
---|
1172 | USE indices, & |
---|
1173 | ONLY: nxlg, nxrg, nyng, nysg, nzb, nzt |
---|
1174 | |
---|
1175 | IMPLICIT NONE |
---|
1176 | |
---|
1177 | #if defined( __nopointer ) |
---|
1178 | ALLOCATE( prho(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
1179 | rho_ocean(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
1180 | sa(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
1181 | sa_p(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
1182 | tsa_m(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
1183 | #else |
---|
1184 | ALLOCATE( prho_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
1185 | rho_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
1186 | sa_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & |
---|
1187 | sa_3(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
1188 | |
---|
1189 | IF ( salinity ) THEN |
---|
1190 | ALLOCATE( sa_2(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
1191 | ENDIF |
---|
1192 | |
---|
1193 | prho => prho_1 |
---|
1194 | rho_ocean => rho_1 ! routines calc_mean_profile and diffusion_e require |
---|
1195 | ! density to be a pointer |
---|
1196 | #endif |
---|
1197 | |
---|
1198 | #if ! defined( __nopointer ) |
---|
1199 | ! |
---|
1200 | !-- Initial assignment of pointers |
---|
1201 | IF ( salinity ) THEN |
---|
1202 | sa => sa_1; sa_p => sa_2; tsa_m => sa_3 |
---|
1203 | ELSE |
---|
1204 | sa => sa_1; sa_p => sa_1; tsa_m => sa_3 |
---|
1205 | ENDIF |
---|
1206 | #endif |
---|
1207 | |
---|
1208 | END SUBROUTINE ocean_init_arrays |
---|
1209 | |
---|
1210 | |
---|
1211 | !------------------------------------------------------------------------------! |
---|
1212 | ! Description: |
---|
1213 | ! ------------ |
---|
1214 | !> Initialization of quantities needed for the ocean mode |
---|
1215 | !------------------------------------------------------------------------------! |
---|
1216 | SUBROUTINE ocean_init |
---|
1217 | |
---|
1218 | |
---|
1219 | USE arrays_3d, & |
---|
1220 | ONLY: dzu, dzw, hyp, pt_init, ref_state, u_stokes_zu, u_stokes_zw, & |
---|
1221 | v_stokes_zu, v_stokes_zw, zu, zw |
---|
1222 | |
---|
1223 | USE basic_constants_and_equations_mod, & |
---|
1224 | ONLY: g |
---|
1225 | |
---|
1226 | USE basic_constants_and_equations_mod, & |
---|
1227 | ONLY: pi |
---|
1228 | |
---|
1229 | USE control_parameters, & |
---|
1230 | ONLY: initializing_actions, molecular_viscosity, rho_surface, & |
---|
1231 | rho_reference, surface_pressure, top_momentumflux_u, & |
---|
1232 | top_momentumflux_v, use_single_reference_value |
---|
1233 | |
---|
1234 | USE indices, & |
---|
1235 | ONLY: nxl, nxlg, nxrg, nyng, nys, nysg, nzb, nzt |
---|
1236 | |
---|
1237 | USE kinds |
---|
1238 | |
---|
1239 | USE pegrid, & |
---|
1240 | ONLY: myid |
---|
1241 | |
---|
1242 | USE statistics, & |
---|
1243 | ONLY: hom, statistic_regions |
---|
1244 | |
---|
1245 | IMPLICIT NONE |
---|
1246 | |
---|
1247 | INTEGER(iwp) :: i !< loop index |
---|
1248 | INTEGER(iwp) :: j !< loop index |
---|
1249 | INTEGER(iwp) :: k !< loop index |
---|
1250 | INTEGER(iwp) :: n !< loop index |
---|
1251 | |
---|
1252 | REAL(wp) :: alpha !< angle of surface stress |
---|
1253 | REAL(wp) :: dum !< dummy argument |
---|
1254 | REAL(wp) :: pt_l !< local scalar for pt used in equation of state function |
---|
1255 | REAL(wp) :: sa_l !< local scalar for sa used in equation of state function |
---|
1256 | REAL(wp) :: velocity_amplitude !< local scalar for amplitude of Stokes drift velocity |
---|
1257 | REAL(wp) :: x !< temporary variable to store surface stress along x |
---|
1258 | REAL(wp) :: y !< temporary variable to store surface stress along y |
---|
1259 | |
---|
1260 | REAL(wp), DIMENSION(nzb:nzt+1) :: rho_ocean_init !< local array for initial density |
---|
1261 | |
---|
1262 | ALLOCATE( hyp(nzb:nzt+1) ) |
---|
1263 | |
---|
1264 | |
---|
1265 | ! |
---|
1266 | !-- In case of no restart run, calculate the inital salinity profilevcusing the |
---|
1267 | !-- given salinity gradients |
---|
1268 | IF ( TRIM( initializing_actions ) /= 'read_restart_data' ) THEN |
---|
1269 | |
---|
1270 | sa_init = sa_surface |
---|
1271 | ! |
---|
1272 | !-- Last arguments gives back the gradient at top level to be used as |
---|
1273 | !-- possible Neumann boundary condition. This is not realized for the ocean |
---|
1274 | !-- mode, therefore a dummy argument is used. |
---|
1275 | IF ( salinity ) THEN |
---|
1276 | CALL init_vertical_profiles( sa_vertical_gradient_level_ind, & |
---|
1277 | sa_vertical_gradient_level, & |
---|
1278 | sa_vertical_gradient, sa_init, & |
---|
1279 | sa_surface, dum ) |
---|
1280 | ENDIF |
---|
1281 | ENDIF |
---|
1282 | |
---|
1283 | ! |
---|
1284 | !-- Initialize required 3d-arrays |
---|
1285 | IF ( TRIM( initializing_actions ) /= 'read_restart_data' .AND. & |
---|
1286 | TRIM( initializing_actions ) /= 'cyclic_fill' ) THEN |
---|
1287 | ! |
---|
1288 | !-- Initialization via computed 1D-model profiles |
---|
1289 | IF ( INDEX( initializing_actions, 'set_constant_profiles' ) /= 0 ) THEN |
---|
1290 | |
---|
1291 | DO i = nxlg, nxrg |
---|
1292 | DO j = nysg, nyng |
---|
1293 | sa(:,j,i) = sa_init |
---|
1294 | ENDDO |
---|
1295 | ENDDO |
---|
1296 | |
---|
1297 | ENDIF |
---|
1298 | ! |
---|
1299 | !-- Store initial profiles for output purposes etc. |
---|
1300 | !-- Store initial salinity profile |
---|
1301 | hom(:,1,26,:) = SPREAD( sa(:,nys,nxl), 2, statistic_regions+1 ) |
---|
1302 | ! |
---|
1303 | !-- Initialize old and new time levels. |
---|
1304 | tsa_m = 0.0_wp |
---|
1305 | sa_p = sa |
---|
1306 | |
---|
1307 | ELSEIF ( TRIM( initializing_actions ) == 'read_restart_data' ) THEN |
---|
1308 | |
---|
1309 | ! |
---|
1310 | !-- Initialize new time levels (only done in order to set boundary values |
---|
1311 | !-- including ghost points) |
---|
1312 | sa_p = sa |
---|
1313 | ! |
---|
1314 | !-- Allthough tendency arrays are set in prognostic_equations, they have |
---|
1315 | !-- have to be predefined here because they are used (but multiplied with 0) |
---|
1316 | !-- there before they are set. |
---|
1317 | tsa_m = 0.0_wp |
---|
1318 | |
---|
1319 | ENDIF |
---|
1320 | |
---|
1321 | ! |
---|
1322 | !-- Set water density near the ocean surface |
---|
1323 | rho_surface = 1027.62_wp |
---|
1324 | |
---|
1325 | ! |
---|
1326 | !-- Set kinematic viscosity to sea water at 20C. |
---|
1327 | !-- This changes the default value that is given for air! |
---|
1328 | molecular_viscosity = 1.05E-6_wp |
---|
1329 | |
---|
1330 | ! |
---|
1331 | !-- Change sign of buoyancy/stability terms because density gradient is used |
---|
1332 | !-- instead of the potential temperature gradient to calculate the buoyancy |
---|
1333 | atmos_ocean_sign = -1.0_wp |
---|
1334 | |
---|
1335 | ! |
---|
1336 | !-- Calculate initial vertical profile of hydrostatic pressure (in Pa) |
---|
1337 | !-- and the reference density (used later in buoyancy term) |
---|
1338 | !-- First step: Calculate pressure using reference density |
---|
1339 | hyp(nzt+1) = surface_pressure * 100.0_wp |
---|
1340 | hyp(nzt) = hyp(nzt+1) + rho_surface * g * 0.5_wp * dzu(nzt+1) |
---|
1341 | rho_ocean_init(nzt) = rho_surface |
---|
1342 | rho_ocean_init(nzt+1) = rho_surface ! only required for output |
---|
1343 | |
---|
1344 | DO k = nzt-1, 1, -1 |
---|
1345 | hyp(k) = hyp(k+1) + rho_surface * g * dzu(k) |
---|
1346 | ENDDO |
---|
1347 | hyp(0) = hyp(1) + rho_surface * g * dzu(1) |
---|
1348 | |
---|
1349 | ! |
---|
1350 | !-- Second step: Iteratively calculate in situ density (based on presssure) |
---|
1351 | !-- and pressure (based on in situ density) |
---|
1352 | DO n = 1, 5 |
---|
1353 | |
---|
1354 | rho_reference = rho_surface * 0.5_wp * dzu(nzt+1) |
---|
1355 | |
---|
1356 | DO k = nzt, 0, -1 |
---|
1357 | |
---|
1358 | sa_l = 0.5_wp * ( sa_init(k) + sa_init(k+1) ) |
---|
1359 | pt_l = 0.5_wp * ( pt_init(k) + pt_init(k+1) ) |
---|
1360 | |
---|
1361 | rho_ocean_init(k) = eqn_state_seawater_func( hyp(k), pt_l, sa_l ) |
---|
1362 | |
---|
1363 | rho_reference = rho_reference + rho_ocean_init(k) * dzu(k+1) |
---|
1364 | |
---|
1365 | ENDDO |
---|
1366 | |
---|
1367 | rho_reference = rho_reference / ( zw(nzt) - zu(nzb) ) |
---|
1368 | |
---|
1369 | hyp(nzt) = hyp(nzt+1) + rho_surface * g * 0.5_wp * dzu(nzt+1) |
---|
1370 | DO k = nzt-1, 0, -1 |
---|
1371 | hyp(k) = hyp(k+1) + g * 0.5_wp * ( rho_ocean_init(k) & |
---|
1372 | + rho_ocean_init(k+1) ) * dzu(k+1) |
---|
1373 | ENDDO |
---|
1374 | |
---|
1375 | ENDDO |
---|
1376 | |
---|
1377 | ! |
---|
1378 | !-- Calculate the reference potential density |
---|
1379 | prho_reference = 0.0_wp |
---|
1380 | DO k = 0, nzt |
---|
1381 | |
---|
1382 | sa_l = 0.5_wp * ( sa_init(k) + sa_init(k+1) ) |
---|
1383 | pt_l = 0.5_wp * ( pt_init(k) + pt_init(k+1) ) |
---|
1384 | |
---|
1385 | prho_reference = prho_reference + dzu(k+1) * & |
---|
1386 | eqn_state_seawater_func( 0.0_wp, pt_l, sa_l ) |
---|
1387 | |
---|
1388 | ENDDO |
---|
1389 | |
---|
1390 | prho_reference = prho_reference / ( zu(nzt) - zu(nzb) ) |
---|
1391 | |
---|
1392 | ! |
---|
1393 | !-- Calculate the 3d array of initial in situ and potential density, |
---|
1394 | !-- based on the initial temperature and salinity profile |
---|
1395 | CALL eqn_state_seawater |
---|
1396 | |
---|
1397 | ! |
---|
1398 | !-- Store initial density profile |
---|
1399 | hom(:,1,77,:) = SPREAD( rho_ocean_init(:), 2, statistic_regions+1 ) |
---|
1400 | |
---|
1401 | ! |
---|
1402 | !-- Set the reference state to be used in the buoyancy terms |
---|
1403 | IF ( use_single_reference_value ) THEN |
---|
1404 | ref_state(:) = rho_reference |
---|
1405 | ELSE |
---|
1406 | ref_state(:) = rho_ocean_init(:) |
---|
1407 | ENDIF |
---|
1408 | |
---|
1409 | ! |
---|
1410 | !-- Calculate the Stokes drift velocity profile |
---|
1411 | IF ( stokes_force ) THEN |
---|
1412 | |
---|
1413 | ! |
---|
1414 | !-- First, calculate angle of surface stress |
---|
1415 | x = -top_momentumflux_u |
---|
1416 | y = -top_momentumflux_v |
---|
1417 | IF ( x == 0.0_wp ) THEN |
---|
1418 | IF ( y > 0.0_wp ) THEN |
---|
1419 | alpha = pi / 2.0_wp |
---|
1420 | ELSEIF ( y < 0.0_wp ) THEN |
---|
1421 | alpha = 3.0_wp * pi / 2.0_wp |
---|
1422 | ENDIF |
---|
1423 | ELSE |
---|
1424 | IF ( x < 0.0_wp ) THEN |
---|
1425 | alpha = ATAN( y / x ) + pi |
---|
1426 | ELSE |
---|
1427 | IF ( y < 0.0_wp ) THEN |
---|
1428 | alpha = ATAN( y / x ) + 2.0_wp * pi |
---|
1429 | ELSE |
---|
1430 | alpha = ATAN( y / x ) |
---|
1431 | ENDIF |
---|
1432 | ENDIF |
---|
1433 | ENDIF |
---|
1434 | |
---|
1435 | velocity_amplitude = ( pi * stokes_waveheight / stokes_wavelength )**2 *& |
---|
1436 | SQRT( g * stokes_wavelength / ( 2.0_wp * pi ) ) |
---|
1437 | |
---|
1438 | DO k = nzb, nzt |
---|
1439 | u_stokes_zu(k) = velocity_amplitude * COS( alpha ) * & |
---|
1440 | EXP( 4.0_wp * pi * zu(k) / stokes_wavelength ) |
---|
1441 | u_stokes_zw(k) = velocity_amplitude * COS( alpha ) * & |
---|
1442 | EXP( 4.0_wp * pi * zw(k) / stokes_wavelength ) |
---|
1443 | v_stokes_zu(k) = velocity_amplitude * SIN( alpha ) * & |
---|
1444 | EXP( 4.0_wp * pi * zu(k) / stokes_wavelength ) |
---|
1445 | v_stokes_zw(k) = velocity_amplitude * SIN( alpha ) * & |
---|
1446 | EXP( 4.0_wp * pi * zw(k) / stokes_wavelength ) |
---|
1447 | ENDDO |
---|
1448 | u_stokes_zu(nzt+1) = u_stokes_zw(nzt) ! because zu(nzt+1) changes the sign |
---|
1449 | u_stokes_zw(nzt+1) = u_stokes_zw(nzt) ! because zw(nzt+1) changes the sign |
---|
1450 | v_stokes_zu(nzt+1) = v_stokes_zw(nzt) ! because zu(nzt+1) changes the sign |
---|
1451 | v_stokes_zw(nzt+1) = v_stokes_zw(nzt) ! because zw(nzt+1) changes the sign |
---|
1452 | |
---|
1453 | ENDIF |
---|
1454 | |
---|
1455 | ! |
---|
1456 | !-- Wave breaking effects |
---|
1457 | IF ( wave_breaking ) THEN |
---|
1458 | ! |
---|
1459 | !-- Calculate friction velocity at ocean surface |
---|
1460 | u_star_wave_breaking = SQRT( SQRT( top_momentumflux_u**2 + & |
---|
1461 | top_momentumflux_v**2 ) ) |
---|
1462 | ! |
---|
1463 | !-- Set the time scale of random forcing. The vertical grid spacing at the |
---|
1464 | !-- ocean surface is assumed as the length scale of turbulence. |
---|
1465 | !-- Formula follows Noh et al. (2004), JPO |
---|
1466 | timescale_wave_breaking = 0.1_wp * dzw(nzt) / alpha_wave_breaking / & |
---|
1467 | u_star_wave_breaking |
---|
1468 | ! |
---|
1469 | !-- Set random number seeds differently on the processor cores in order to |
---|
1470 | !-- create different random number sequences |
---|
1471 | iran_ocean = iran_ocean + myid |
---|
1472 | ENDIF |
---|
1473 | |
---|
1474 | END SUBROUTINE ocean_init |
---|
1475 | |
---|
1476 | |
---|
1477 | !------------------------------------------------------------------------------! |
---|
1478 | ! Description: |
---|
1479 | ! ------------ |
---|
1480 | !> Prognostic equation for salinity. |
---|
1481 | !> Vector-optimized version |
---|
1482 | !------------------------------------------------------------------------------! |
---|
1483 | SUBROUTINE ocean_prognostic_equations |
---|
1484 | |
---|
1485 | USE advec_s_bc_mod, & |
---|
1486 | ONLY: advec_s_bc |
---|
1487 | |
---|
1488 | USE advec_s_pw_mod, & |
---|
1489 | ONLY: advec_s_pw |
---|
1490 | |
---|
1491 | USE advec_s_up_mod, & |
---|
1492 | ONLY: advec_s_up |
---|
1493 | |
---|
1494 | USE advec_ws, & |
---|
1495 | ONLY: advec_s_ws |
---|
1496 | |
---|
1497 | USE arrays_3d, & |
---|
1498 | ONLY: rdf_sc, tend, tsa_m |
---|
1499 | |
---|
1500 | USE control_parameters, & |
---|
1501 | ONLY: dt_3d, intermediate_timestep_count, & |
---|
1502 | intermediate_timestep_count_max, scalar_advec, simulated_time, & |
---|
1503 | timestep_scheme, tsc, ws_scheme_sca |
---|
1504 | |
---|
1505 | USE cpulog, & |
---|
1506 | ONLY: cpu_log, log_point |
---|
1507 | |
---|
1508 | USE diffusion_s_mod, & |
---|
1509 | ONLY: diffusion_s |
---|
1510 | |
---|
1511 | USE indices, & |
---|
1512 | ONLY: nxl, nxr, nyn, nys, nzb, nzt, wall_flags_0 |
---|
1513 | |
---|
1514 | USE surface_mod, & |
---|
1515 | ONLY: surf_def_v, surf_def_h, surf_lsm_h, surf_lsm_v, surf_usm_h, & |
---|
1516 | surf_usm_v |
---|
1517 | |
---|
1518 | USE user_actions_mod, & |
---|
1519 | ONLY: user_actions |
---|
1520 | |
---|
1521 | IMPLICIT NONE |
---|
1522 | |
---|
1523 | INTEGER(iwp) :: i !< loop index |
---|
1524 | INTEGER(iwp) :: j !< loop index |
---|
1525 | INTEGER(iwp) :: k !< loop index |
---|
1526 | |
---|
1527 | REAL(wp) :: sbt !< weighting factor for sub-time step |
---|
1528 | |
---|
1529 | ! |
---|
1530 | !-- Switch of the surface heat flux, if requested |
---|
1531 | IF ( surface_cooling_spinup_time /= 999999.9_wp ) THEN |
---|
1532 | IF ( .NOT. surface_cooling_switched_off .AND. & |
---|
1533 | simulated_time >= surface_cooling_spinup_time ) THEN |
---|
1534 | |
---|
1535 | surf_def_h(2)%shf = 0.0_wp |
---|
1536 | surface_cooling_switched_off = .TRUE. |
---|
1537 | |
---|
1538 | ENDIF |
---|
1539 | ENDIF |
---|
1540 | |
---|
1541 | ! |
---|
1542 | !-- Compute prognostic equations for the ocean mode |
---|
1543 | !-- First, start with salinity |
---|
1544 | IF ( salinity ) THEN |
---|
1545 | |
---|
1546 | CALL cpu_log( log_point(37), 'sa-equation', 'start' ) |
---|
1547 | |
---|
1548 | ! |
---|
1549 | !-- sa-tendency terms with communication |
---|
1550 | sbt = tsc(2) |
---|
1551 | IF ( scalar_advec == 'bc-scheme' ) THEN |
---|
1552 | |
---|
1553 | IF ( timestep_scheme(1:5) /= 'runge' ) THEN |
---|
1554 | ! |
---|
1555 | !-- Bott-Chlond scheme always uses Euler time step. Thus: |
---|
1556 | sbt = 1.0_wp |
---|
1557 | ENDIF |
---|
1558 | tend = 0.0_wp |
---|
1559 | CALL advec_s_bc( sa, 'sa' ) |
---|
1560 | |
---|
1561 | ENDIF |
---|
1562 | |
---|
1563 | ! |
---|
1564 | !-- sa-tendency terms with no communication |
---|
1565 | IF ( scalar_advec /= 'bc-scheme' ) THEN |
---|
1566 | tend = 0.0_wp |
---|
1567 | IF ( timestep_scheme(1:5) == 'runge' ) THEN |
---|
1568 | IF ( ws_scheme_sca ) THEN |
---|
1569 | CALL advec_s_ws( sa, 'sa' ) |
---|
1570 | ELSE |
---|
1571 | CALL advec_s_pw( sa ) |
---|
1572 | ENDIF |
---|
1573 | ELSE |
---|
1574 | CALL advec_s_up( sa ) |
---|
1575 | ENDIF |
---|
1576 | ENDIF |
---|
1577 | |
---|
1578 | CALL diffusion_s( sa, & |
---|
1579 | surf_def_h(0)%sasws, surf_def_h(1)%sasws, & |
---|
1580 | surf_def_h(2)%sasws, & |
---|
1581 | surf_lsm_h%sasws, surf_usm_h%sasws, & |
---|
1582 | surf_def_v(0)%sasws, surf_def_v(1)%sasws, & |
---|
1583 | surf_def_v(2)%sasws, surf_def_v(3)%sasws, & |
---|
1584 | surf_lsm_v(0)%sasws, surf_lsm_v(1)%sasws, & |
---|
1585 | surf_lsm_v(2)%sasws, surf_lsm_v(3)%sasws, & |
---|
1586 | surf_usm_v(0)%sasws, surf_usm_v(1)%sasws, & |
---|
1587 | surf_usm_v(2)%sasws, surf_usm_v(3)%sasws ) |
---|
1588 | |
---|
1589 | CALL user_actions( 'sa-tendency' ) |
---|
1590 | |
---|
1591 | ! |
---|
1592 | !-- Prognostic equation for salinity |
---|
1593 | DO i = nxl, nxr |
---|
1594 | DO j = nys, nyn |
---|
1595 | DO k = nzb+1, nzt |
---|
1596 | sa_p(k,j,i) = sa(k,j,i) + ( dt_3d * ( sbt * tend(k,j,i) + & |
---|
1597 | tsc(3) * tsa_m(k,j,i) ) & |
---|
1598 | - tsc(5) * rdf_sc(k) * & |
---|
1599 | ( sa(k,j,i) - sa_init(k) ) & |
---|
1600 | ) & |
---|
1601 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
1602 | BTEST( wall_flags_0(k,j,i), 0 ) & |
---|
1603 | ) |
---|
1604 | IF ( sa_p(k,j,i) < 0.0_wp ) sa_p(k,j,i) = 0.1_wp * sa(k,j,i) |
---|
1605 | ENDDO |
---|
1606 | ENDDO |
---|
1607 | ENDDO |
---|
1608 | |
---|
1609 | ! |
---|
1610 | !-- Calculate tendencies for the next Runge-Kutta step |
---|
1611 | IF ( timestep_scheme(1:5) == 'runge' ) THEN |
---|
1612 | IF ( intermediate_timestep_count == 1 ) THEN |
---|
1613 | DO i = nxl, nxr |
---|
1614 | DO j = nys, nyn |
---|
1615 | DO k = nzb+1, nzt |
---|
1616 | tsa_m(k,j,i) = tend(k,j,i) |
---|
1617 | ENDDO |
---|
1618 | ENDDO |
---|
1619 | ENDDO |
---|
1620 | ELSEIF ( intermediate_timestep_count < intermediate_timestep_count_max ) & |
---|
1621 | THEN |
---|
1622 | DO i = nxl, nxr |
---|
1623 | DO j = nys, nyn |
---|
1624 | DO k = nzb+1, nzt |
---|
1625 | tsa_m(k,j,i) = -9.5625_wp * tend(k,j,i) + & |
---|
1626 | 5.3125_wp * tsa_m(k,j,i) |
---|
1627 | ENDDO |
---|
1628 | ENDDO |
---|
1629 | ENDDO |
---|
1630 | ENDIF |
---|
1631 | ENDIF |
---|
1632 | |
---|
1633 | CALL cpu_log( log_point(37), 'sa-equation', 'stop' ) |
---|
1634 | |
---|
1635 | ENDIF |
---|
1636 | |
---|
1637 | ! |
---|
1638 | !-- Calculate density by the equation of state for seawater |
---|
1639 | CALL cpu_log( log_point(38), 'eqns-seawater', 'start' ) |
---|
1640 | CALL eqn_state_seawater |
---|
1641 | CALL cpu_log( log_point(38), 'eqns-seawater', 'stop' ) |
---|
1642 | |
---|
1643 | END SUBROUTINE ocean_prognostic_equations |
---|
1644 | |
---|
1645 | |
---|
1646 | !------------------------------------------------------------------------------! |
---|
1647 | ! Description: |
---|
1648 | ! ------------ |
---|
1649 | !> Prognostic equations for ocean mode (so far, salinity only) |
---|
1650 | !> Cache-optimized version |
---|
1651 | !------------------------------------------------------------------------------! |
---|
1652 | SUBROUTINE ocean_prognostic_equations_ij( i, j, i_omp_start, tn ) |
---|
1653 | |
---|
1654 | USE advec_s_pw_mod, & |
---|
1655 | ONLY: advec_s_pw |
---|
1656 | |
---|
1657 | USE advec_s_up_mod, & |
---|
1658 | ONLY: advec_s_up |
---|
1659 | |
---|
1660 | USE advec_ws, & |
---|
1661 | ONLY: advec_s_ws |
---|
1662 | |
---|
1663 | USE arrays_3d, & |
---|
1664 | ONLY: diss_l_sa, diss_s_sa, flux_l_sa, flux_s_sa, rdf_sc, tend, tsa_m |
---|
1665 | |
---|
1666 | USE control_parameters, & |
---|
1667 | ONLY: dt_3d, intermediate_timestep_count, & |
---|
1668 | intermediate_timestep_count_max, simulated_time, & |
---|
1669 | timestep_scheme, tsc, ws_scheme_sca |
---|
1670 | |
---|
1671 | USE diffusion_s_mod, & |
---|
1672 | ONLY: diffusion_s |
---|
1673 | |
---|
1674 | USE indices, & |
---|
1675 | ONLY: nzb, nzt, wall_flags_0 |
---|
1676 | |
---|
1677 | USE surface_mod, & |
---|
1678 | ONLY: surf_def_v, surf_def_h, surf_lsm_h, surf_lsm_v, surf_usm_h, & |
---|
1679 | surf_usm_v |
---|
1680 | |
---|
1681 | USE user_actions_mod, & |
---|
1682 | ONLY: user_actions |
---|
1683 | |
---|
1684 | IMPLICIT NONE |
---|
1685 | |
---|
1686 | INTEGER(iwp) :: i !< loop index x direction |
---|
1687 | INTEGER(iwp) :: i_omp_start !< first loop index of i-loop in calling & |
---|
1688 | !< routine prognostic_equations |
---|
1689 | INTEGER(iwp) :: j !< loop index y direction |
---|
1690 | INTEGER(iwp) :: k !< loop index z direction |
---|
1691 | INTEGER(iwp) :: tn !< task number of openmp task |
---|
1692 | |
---|
1693 | |
---|
1694 | ! |
---|
1695 | !-- Switch of the surface heat flux, if requested |
---|
1696 | IF ( surface_cooling_spinup_time /= 999999.9_wp ) THEN |
---|
1697 | IF ( .NOT. surface_cooling_switched_off .AND. & |
---|
1698 | simulated_time >= surface_cooling_spinup_time ) THEN |
---|
1699 | |
---|
1700 | surf_def_h(2)%shf = 0.0_wp |
---|
1701 | surface_cooling_switched_off = .TRUE. |
---|
1702 | |
---|
1703 | ENDIF |
---|
1704 | ENDIF |
---|
1705 | |
---|
1706 | ! |
---|
1707 | !-- Compute prognostic equations for the ocean mode |
---|
1708 | !-- First, start with tendency-terms for salinity |
---|
1709 | IF ( salinity ) THEN |
---|
1710 | |
---|
1711 | tend(:,j,i) = 0.0_wp |
---|
1712 | IF ( timestep_scheme(1:5) == 'runge' ) & |
---|
1713 | THEN |
---|
1714 | IF ( ws_scheme_sca ) THEN |
---|
1715 | CALL advec_s_ws( i, j, sa, 'sa', flux_s_sa, diss_s_sa, flux_l_sa,& |
---|
1716 | diss_l_sa, i_omp_start, tn ) |
---|
1717 | ELSE |
---|
1718 | CALL advec_s_pw( i, j, sa ) |
---|
1719 | ENDIF |
---|
1720 | ELSE |
---|
1721 | CALL advec_s_up( i, j, sa ) |
---|
1722 | ENDIF |
---|
1723 | CALL diffusion_s( i, j, sa, & |
---|
1724 | surf_def_h(0)%sasws, surf_def_h(1)%sasws, & |
---|
1725 | surf_def_h(2)%sasws, & |
---|
1726 | surf_lsm_h%sasws, surf_usm_h%sasws, & |
---|
1727 | surf_def_v(0)%sasws, surf_def_v(1)%sasws, & |
---|
1728 | surf_def_v(2)%sasws, surf_def_v(3)%sasws, & |
---|
1729 | surf_lsm_v(0)%sasws, surf_lsm_v(1)%sasws, & |
---|
1730 | surf_lsm_v(2)%sasws, surf_lsm_v(3)%sasws, & |
---|
1731 | surf_usm_v(0)%sasws, surf_usm_v(1)%sasws, & |
---|
1732 | surf_usm_v(2)%sasws, surf_usm_v(3)%sasws ) |
---|
1733 | |
---|
1734 | CALL user_actions( i, j, 'sa-tendency' ) |
---|
1735 | |
---|
1736 | ! |
---|
1737 | !-- Prognostic equation for salinity |
---|
1738 | DO k = nzb+1, nzt |
---|
1739 | |
---|
1740 | sa_p(k,j,i) = sa(k,j,i) + ( dt_3d * & |
---|
1741 | ( tsc(2) * tend(k,j,i) + & |
---|
1742 | tsc(3) * tsa_m(k,j,i) ) & |
---|
1743 | - tsc(5) * rdf_sc(k) & |
---|
1744 | * ( sa(k,j,i) - sa_init(k) ) & |
---|
1745 | ) * MERGE( 1.0_wp, 0.0_wp, & |
---|
1746 | BTEST( wall_flags_0(k,j,i), 0 ) ) |
---|
1747 | |
---|
1748 | IF ( sa_p(k,j,i) < 0.0_wp ) sa_p(k,j,i) = 0.1_wp * sa(k,j,i) |
---|
1749 | |
---|
1750 | ENDDO |
---|
1751 | |
---|
1752 | ! |
---|
1753 | !-- Calculate tendencies for the next Runge-Kutta step |
---|
1754 | IF ( timestep_scheme(1:5) == 'runge' ) THEN |
---|
1755 | IF ( intermediate_timestep_count == 1 ) THEN |
---|
1756 | DO k = nzb+1, nzt |
---|
1757 | tsa_m(k,j,i) = tend(k,j,i) |
---|
1758 | ENDDO |
---|
1759 | ELSEIF ( intermediate_timestep_count < intermediate_timestep_count_max ) & |
---|
1760 | THEN |
---|
1761 | DO k = nzb+1, nzt |
---|
1762 | tsa_m(k,j,i) = -9.5625_wp * tend(k,j,i) + & |
---|
1763 | 5.3125_wp * tsa_m(k,j,i) |
---|
1764 | ENDDO |
---|
1765 | ENDIF |
---|
1766 | ENDIF |
---|
1767 | |
---|
1768 | ENDIF |
---|
1769 | |
---|
1770 | ! |
---|
1771 | !-- Calculate density by the equation of state for seawater |
---|
1772 | CALL eqn_state_seawater( i, j ) |
---|
1773 | |
---|
1774 | END SUBROUTINE ocean_prognostic_equations_ij |
---|
1775 | |
---|
1776 | |
---|
1777 | !------------------------------------------------------------------------------! |
---|
1778 | ! Description: |
---|
1779 | ! ------------ |
---|
1780 | !> Swapping of timelevels. |
---|
1781 | !------------------------------------------------------------------------------! |
---|
1782 | SUBROUTINE ocean_swap_timelevel( mod_count ) |
---|
1783 | |
---|
1784 | IMPLICIT NONE |
---|
1785 | |
---|
1786 | INTEGER, INTENT(IN) :: mod_count !< flag defining where pointers point to |
---|
1787 | |
---|
1788 | #if defined( __nopointer ) |
---|
1789 | |
---|
1790 | sa = sa_p |
---|
1791 | |
---|
1792 | #else |
---|
1793 | |
---|
1794 | SELECT CASE ( mod_count ) |
---|
1795 | |
---|
1796 | CASE ( 0 ) |
---|
1797 | IF ( salinity ) THEN |
---|
1798 | sa => sa_1; sa_p => sa_2 |
---|
1799 | ENDIF |
---|
1800 | |
---|
1801 | CASE ( 1 ) |
---|
1802 | IF ( salinity ) THEN |
---|
1803 | sa => sa_2; sa_p => sa_1 |
---|
1804 | ENDIF |
---|
1805 | |
---|
1806 | END SELECT |
---|
1807 | |
---|
1808 | #endif |
---|
1809 | |
---|
1810 | END SUBROUTINE ocean_swap_timelevel |
---|
1811 | |
---|
1812 | |
---|
1813 | !------------------------------------------------------------------------------! |
---|
1814 | ! Description: |
---|
1815 | ! ------------ |
---|
1816 | !> This routine reads the respective restart data for the ocean module. |
---|
1817 | !------------------------------------------------------------------------------! |
---|
1818 | SUBROUTINE ocean_rrd_global( found ) |
---|
1819 | |
---|
1820 | |
---|
1821 | USE control_parameters, & |
---|
1822 | ONLY: length, restart_string |
---|
1823 | |
---|
1824 | |
---|
1825 | IMPLICIT NONE |
---|
1826 | |
---|
1827 | LOGICAL, INTENT(OUT) :: found |
---|
1828 | |
---|
1829 | |
---|
1830 | found = .TRUE. |
---|
1831 | |
---|
1832 | SELECT CASE ( restart_string(1:length) ) |
---|
1833 | |
---|
1834 | CASE ( 'bc_sa_t' ) |
---|
1835 | READ ( 13 ) bc_sa_t |
---|
1836 | |
---|
1837 | CASE ( 'bottom_salinityflux' ) |
---|
1838 | READ ( 13 ) bottom_salinityflux |
---|
1839 | |
---|
1840 | CASE ( 'salinity' ) |
---|
1841 | READ ( 13 ) salinity |
---|
1842 | |
---|
1843 | CASE ( 'sa_init' ) |
---|
1844 | READ ( 13 ) sa_init |
---|
1845 | |
---|
1846 | CASE ( 'sa_surface' ) |
---|
1847 | READ ( 13 ) sa_surface |
---|
1848 | |
---|
1849 | CASE ( 'sa_vertical_gradient' ) |
---|
1850 | READ ( 13 ) sa_vertical_gradient |
---|
1851 | |
---|
1852 | CASE ( 'sa_vertical_gradient_level' ) |
---|
1853 | READ ( 13 ) sa_vertical_gradient_level |
---|
1854 | |
---|
1855 | CASE ( 'stokes_waveheight' ) |
---|
1856 | READ ( 13 ) stokes_waveheight |
---|
1857 | |
---|
1858 | CASE ( 'stokes_wavelength' ) |
---|
1859 | READ ( 13 ) stokes_wavelength |
---|
1860 | |
---|
1861 | CASE ( 'surface_cooling_spinup_time' ) |
---|
1862 | READ ( 13 ) surface_cooling_spinup_time |
---|
1863 | |
---|
1864 | CASE ( 'top_salinityflux' ) |
---|
1865 | READ ( 13 ) top_salinityflux |
---|
1866 | |
---|
1867 | CASE ( 'wall_salinityflux' ) |
---|
1868 | READ ( 13 ) wall_salinityflux |
---|
1869 | |
---|
1870 | CASE ( 'wave_breaking' ) |
---|
1871 | READ ( 13 ) wave_breaking |
---|
1872 | |
---|
1873 | CASE DEFAULT |
---|
1874 | |
---|
1875 | found = .FALSE. |
---|
1876 | |
---|
1877 | END SELECT |
---|
1878 | |
---|
1879 | END SUBROUTINE ocean_rrd_global |
---|
1880 | |
---|
1881 | |
---|
1882 | !------------------------------------------------------------------------------! |
---|
1883 | ! Description: |
---|
1884 | ! ------------ |
---|
1885 | !> This routine reads the respective restart data for the ocean module. |
---|
1886 | !------------------------------------------------------------------------------! |
---|
1887 | SUBROUTINE ocean_rrd_local( i, k, nxlf, nxlc, nxl_on_file, nxrf, nxrc, & |
---|
1888 | nxr_on_file, nynf, nync, nyn_on_file, nysf, & |
---|
1889 | nysc, nys_on_file, tmp_2d, tmp_3d, found ) |
---|
1890 | |
---|
1891 | USE averaging, & |
---|
1892 | ONLY: rho_ocean_av, sa_av |
---|
1893 | |
---|
1894 | USE control_parameters, & |
---|
1895 | ONLY: length, restart_string |
---|
1896 | |
---|
1897 | USE indices, & |
---|
1898 | ONLY: nbgp, nxlg, nxrg, nyng, nysg, nzb, nzt |
---|
1899 | |
---|
1900 | USE pegrid |
---|
1901 | |
---|
1902 | |
---|
1903 | IMPLICIT NONE |
---|
1904 | |
---|
1905 | INTEGER(iwp) :: i !< |
---|
1906 | INTEGER(iwp) :: k !< |
---|
1907 | INTEGER(iwp) :: nxlc !< |
---|
1908 | INTEGER(iwp) :: nxlf !< |
---|
1909 | INTEGER(iwp) :: nxl_on_file !< |
---|
1910 | INTEGER(iwp) :: nxrc !< |
---|
1911 | INTEGER(iwp) :: nxrf !< |
---|
1912 | INTEGER(iwp) :: nxr_on_file !< |
---|
1913 | INTEGER(iwp) :: nync !< |
---|
1914 | INTEGER(iwp) :: nynf !< |
---|
1915 | INTEGER(iwp) :: nyn_on_file !< |
---|
1916 | INTEGER(iwp) :: nysc !< |
---|
1917 | INTEGER(iwp) :: nysf !< |
---|
1918 | INTEGER(iwp) :: nys_on_file !< |
---|
1919 | |
---|
1920 | LOGICAL, INTENT(OUT) :: found |
---|
1921 | |
---|
1922 | REAL(wp), DIMENSION(nys_on_file-nbgp:nyn_on_file+nbgp,nxl_on_file-nbgp:nxr_on_file+nbgp) :: tmp_2d !< |
---|
1923 | REAL(wp), DIMENSION(nzb:nzt+1,nys_on_file-nbgp:nyn_on_file+nbgp,nxl_on_file-nbgp:nxr_on_file+nbgp) :: tmp_3d !< |
---|
1924 | |
---|
1925 | |
---|
1926 | found = .TRUE. |
---|
1927 | |
---|
1928 | SELECT CASE ( restart_string(1:length) ) |
---|
1929 | |
---|
1930 | CASE ( 'rho_ocean_av' ) |
---|
1931 | IF ( .NOT. ALLOCATED( rho_ocean_av ) ) THEN |
---|
1932 | ALLOCATE( rho_ocean_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
1933 | ENDIF |
---|
1934 | IF ( k == 1 ) READ ( 13 ) tmp_3d |
---|
1935 | rho_ocean_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) = & |
---|
1936 | tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp) |
---|
1937 | |
---|
1938 | CASE ( 'sa' ) |
---|
1939 | IF ( k == 1 ) READ ( 13 ) tmp_3d |
---|
1940 | sa(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) = & |
---|
1941 | tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp) |
---|
1942 | |
---|
1943 | CASE ( 'sa_av' ) |
---|
1944 | IF ( .NOT. ALLOCATED( sa_av ) ) THEN |
---|
1945 | ALLOCATE( sa_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
1946 | ENDIF |
---|
1947 | IF ( k == 1 ) READ ( 13 ) tmp_3d |
---|
1948 | sa_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) = & |
---|
1949 | tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp) |
---|
1950 | |
---|
1951 | CASE DEFAULT |
---|
1952 | found = .FALSE. |
---|
1953 | |
---|
1954 | END SELECT |
---|
1955 | |
---|
1956 | END SUBROUTINE ocean_rrd_local |
---|
1957 | |
---|
1958 | |
---|
1959 | !------------------------------------------------------------------------------! |
---|
1960 | ! Description: |
---|
1961 | ! ------------ |
---|
1962 | !> This routine writes the respective restart data for the ocean module. |
---|
1963 | !------------------------------------------------------------------------------! |
---|
1964 | SUBROUTINE ocean_wrd_global |
---|
1965 | |
---|
1966 | |
---|
1967 | IMPLICIT NONE |
---|
1968 | |
---|
1969 | CALL wrd_write_string( 'bc_sa_t' ) |
---|
1970 | WRITE ( 14 ) bc_sa_t |
---|
1971 | |
---|
1972 | CALL wrd_write_string( 'bottom_salinityflux' ) |
---|
1973 | WRITE ( 14 ) bottom_salinityflux |
---|
1974 | |
---|
1975 | CALL wrd_write_string( 'salinity' ) |
---|
1976 | WRITE ( 14 ) salinity |
---|
1977 | |
---|
1978 | CALL wrd_write_string( 'sa_init' ) |
---|
1979 | WRITE ( 14 ) sa_init |
---|
1980 | |
---|
1981 | CALL wrd_write_string( 'sa_surface' ) |
---|
1982 | WRITE ( 14 ) sa_surface |
---|
1983 | |
---|
1984 | CALL wrd_write_string( 'sa_vertical_gradient' ) |
---|
1985 | WRITE ( 14 ) sa_vertical_gradient |
---|
1986 | |
---|
1987 | CALL wrd_write_string( 'sa_vertical_gradient_level' ) |
---|
1988 | WRITE ( 14 ) sa_vertical_gradient_level |
---|
1989 | |
---|
1990 | CALL wrd_write_string( 'stokes_waveheight' ) |
---|
1991 | WRITE ( 14 ) stokes_waveheight |
---|
1992 | |
---|
1993 | CALL wrd_write_string( 'stokes_wavelength' ) |
---|
1994 | WRITE ( 14 ) stokes_wavelength |
---|
1995 | |
---|
1996 | CALL wrd_write_string( 'surface_cooling_spinup_time' ) |
---|
1997 | WRITE ( 14 ) surface_cooling_spinup_time |
---|
1998 | |
---|
1999 | CALL wrd_write_string( 'top_salinityflux' ) |
---|
2000 | WRITE ( 14 ) top_salinityflux |
---|
2001 | |
---|
2002 | CALL wrd_write_string( 'wall_salinityflux' ) |
---|
2003 | WRITE ( 14 ) wall_salinityflux |
---|
2004 | |
---|
2005 | CALL wrd_write_string( 'wave_breaking' ) |
---|
2006 | WRITE ( 14 ) wave_breaking |
---|
2007 | |
---|
2008 | END SUBROUTINE ocean_wrd_global |
---|
2009 | |
---|
2010 | |
---|
2011 | !------------------------------------------------------------------------------! |
---|
2012 | ! Description: |
---|
2013 | ! ------------ |
---|
2014 | !> This routine writes the respective restart data for the ocean module. |
---|
2015 | !------------------------------------------------------------------------------! |
---|
2016 | SUBROUTINE ocean_wrd_local |
---|
2017 | |
---|
2018 | USE averaging, & |
---|
2019 | ONLY: rho_ocean_av, sa_av |
---|
2020 | |
---|
2021 | IMPLICIT NONE |
---|
2022 | |
---|
2023 | IF ( ALLOCATED( rho_ocean_av ) ) THEN |
---|
2024 | CALL wrd_write_string( 'rho_ocean_av' ) |
---|
2025 | WRITE ( 14 ) rho_ocean_av |
---|
2026 | ENDIF |
---|
2027 | |
---|
2028 | CALL wrd_write_string( 'sa' ) |
---|
2029 | WRITE ( 14 ) sa |
---|
2030 | |
---|
2031 | IF ( ALLOCATED( sa_av ) ) THEN |
---|
2032 | CALL wrd_write_string( 'sa_av' ) |
---|
2033 | WRITE ( 14 ) sa_av |
---|
2034 | ENDIF |
---|
2035 | |
---|
2036 | END SUBROUTINE ocean_wrd_local |
---|
2037 | |
---|
2038 | |
---|
2039 | !------------------------------------------------------------------------------! |
---|
2040 | ! Description: |
---|
2041 | ! ------------ |
---|
2042 | !> This routine calculates the Craik Leibovich vortex force and the additional |
---|
2043 | !> effect of the Stokes drift on the Coriolis force |
---|
2044 | !> Call for all gridpoints. |
---|
2045 | !------------------------------------------------------------------------------! |
---|
2046 | SUBROUTINE stokes_drift_terms( component ) |
---|
2047 | |
---|
2048 | USE arrays_3d, & |
---|
2049 | ONLY: ddzu, u, u_stokes_zu, u_stokes_zw, v, v_stokes_zu, & |
---|
2050 | v_stokes_zw, w, tend |
---|
2051 | |
---|
2052 | USE control_parameters, & |
---|
2053 | ONLY: f, fs, message_string |
---|
2054 | |
---|
2055 | USE grid_variables, & |
---|
2056 | ONLY: ddx, ddy |
---|
2057 | |
---|
2058 | USE indices, & |
---|
2059 | ONLY: nxl, nxr, nys, nysv, nyn, nzb, nzt |
---|
2060 | |
---|
2061 | IMPLICIT NONE |
---|
2062 | |
---|
2063 | INTEGER(iwp) :: component !< component of momentum equation |
---|
2064 | INTEGER(iwp) :: i !< loop index along x |
---|
2065 | INTEGER(iwp) :: j !< loop index along y |
---|
2066 | INTEGER(iwp) :: k !< loop index along z |
---|
2067 | |
---|
2068 | |
---|
2069 | ! |
---|
2070 | !-- Compute Stokes terms for the respective velocity components |
---|
2071 | SELECT CASE ( component ) |
---|
2072 | |
---|
2073 | ! |
---|
2074 | !-- u-component |
---|
2075 | CASE ( 1 ) |
---|
2076 | DO i = nxl, nxr |
---|
2077 | DO j = nysv, nyn |
---|
2078 | DO k = nzb+1, nzt |
---|
2079 | tend(k,j,i) = tend(k,j,i) + v_stokes_zu(k) * ( & |
---|
2080 | 0.5 * ( v(k,j+1,i) - v(k,j+1,i-1) & |
---|
2081 | + v(k,j,i) - v(k,j,i-1) ) * ddx & |
---|
2082 | - 0.5 * ( u(k,j+1,i) - u(k,j-1,i) ) * ddy & |
---|
2083 | ) & |
---|
2084 | + f * v_stokes_zu(k) |
---|
2085 | ENDDO |
---|
2086 | ENDDO |
---|
2087 | ENDDO |
---|
2088 | |
---|
2089 | ! |
---|
2090 | !-- v-component |
---|
2091 | CASE ( 2 ) |
---|
2092 | DO i = nxl, nxr |
---|
2093 | DO j = nysv, nyn |
---|
2094 | DO k = nzb+1, nzt |
---|
2095 | tend(k,j,i) = tend(k,j,i) - u_stokes_zu(k) * ( & |
---|
2096 | 0.5 * ( v(k,j,i+1) - v(k,j,i-1) ) * ddx & |
---|
2097 | - 0.5 * ( u(k,j,i) - u(k,j-1,i) & |
---|
2098 | + u(k,j,i+1) - u(k,j-1,i+1) ) * ddy & |
---|
2099 | ) & |
---|
2100 | - f * u_stokes_zu(k) |
---|
2101 | ENDDO |
---|
2102 | ENDDO |
---|
2103 | ENDDO |
---|
2104 | |
---|
2105 | ! |
---|
2106 | !-- w-component |
---|
2107 | CASE ( 3 ) |
---|
2108 | DO i = nxl, nxr |
---|
2109 | DO j = nys, nyn |
---|
2110 | DO k = nzb+1, nzt |
---|
2111 | tend(k,j,i) = tend(k,j,i) + u_stokes_zw(k) * ( & |
---|
2112 | 0.5 * ( u(k+1,j,i) - u(k,j,i) & |
---|
2113 | + u(k+1,j,i+1) - u(k,j,i+1) & |
---|
2114 | ) * ddzu(k+1) & |
---|
2115 | - 0.5 * ( w(k,j,i+1) - w(k,j,i-1) & |
---|
2116 | ) * ddx ) & |
---|
2117 | - v_stokes_zw(k) * ( & |
---|
2118 | 0.5 * ( w(k,j+1,i) - w(k,j-1,i) & |
---|
2119 | ) * ddy & |
---|
2120 | - 0.5 * ( v(k+1,j,i) - v(k,j,i) & |
---|
2121 | + v(k+1,j+1,i) - v(k,j+1,i) & |
---|
2122 | ) * ddzu(k) ) & |
---|
2123 | + fs * u_stokes_zw(k) |
---|
2124 | ENDDO |
---|
2125 | ENDDO |
---|
2126 | ENDDO |
---|
2127 | |
---|
2128 | CASE DEFAULT |
---|
2129 | WRITE( message_string, * ) 'wrong component of Stokes force: ', & |
---|
2130 | component |
---|
2131 | CALL message( 'stokes_drift_terms', 'PA0091', 1, 2, 0, 6, 0 ) |
---|
2132 | |
---|
2133 | END SELECT |
---|
2134 | |
---|
2135 | END SUBROUTINE stokes_drift_terms |
---|
2136 | |
---|
2137 | |
---|
2138 | !------------------------------------------------------------------------------! |
---|
2139 | ! Description: |
---|
2140 | ! ------------ |
---|
2141 | !> This routine calculates the Craik Leibovich vortex force and the additional |
---|
2142 | !> effect of the Stokes drift on the Coriolis force |
---|
2143 | !> Call for gridpoints i,j. |
---|
2144 | !------------------------------------------------------------------------------! |
---|
2145 | |
---|
2146 | SUBROUTINE stokes_drift_terms_ij( i, j, component ) |
---|
2147 | |
---|
2148 | USE arrays_3d, & |
---|
2149 | ONLY: ddzu, u, u_stokes_zu, u_stokes_zw, v, v_stokes_zu, & |
---|
2150 | v_stokes_zw, w, tend |
---|
2151 | |
---|
2152 | USE control_parameters, & |
---|
2153 | ONLY: f, fs, message_string |
---|
2154 | |
---|
2155 | USE grid_variables, & |
---|
2156 | ONLY: ddx, ddy |
---|
2157 | |
---|
2158 | USE indices, & |
---|
2159 | ONLY: nzb, nzt |
---|
2160 | |
---|
2161 | IMPLICIT NONE |
---|
2162 | |
---|
2163 | INTEGER(iwp) :: component !< component of momentum equation |
---|
2164 | INTEGER(iwp) :: i !< loop index along x |
---|
2165 | INTEGER(iwp) :: j !< loop index along y |
---|
2166 | INTEGER(iwp) :: k !< loop incex along z |
---|
2167 | |
---|
2168 | |
---|
2169 | ! |
---|
2170 | !-- Compute Stokes terms for the respective velocity components |
---|
2171 | SELECT CASE ( component ) |
---|
2172 | |
---|
2173 | ! |
---|
2174 | !-- u-component |
---|
2175 | CASE ( 1 ) |
---|
2176 | DO k = nzb+1, nzt |
---|
2177 | tend(k,j,i) = tend(k,j,i) + v_stokes_zu(k) * ( & |
---|
2178 | 0.5 * ( v(k,j+1,i) - v(k,j+1,i-1) & |
---|
2179 | + v(k,j,i) - v(k,j,i-1) ) * ddx & |
---|
2180 | - 0.5 * ( u(k,j+1,i) - u(k,j-1,i) ) * ddy & |
---|
2181 | ) & |
---|
2182 | + f * v_stokes_zu(k) |
---|
2183 | ENDDO |
---|
2184 | ! |
---|
2185 | !-- v-component |
---|
2186 | CASE ( 2 ) |
---|
2187 | DO k = nzb+1, nzt |
---|
2188 | tend(k,j,i) = tend(k,j,i) - u_stokes_zu(k) * ( & |
---|
2189 | 0.5 * ( v(k,j,i+1) - v(k,j,i-1) ) * ddx & |
---|
2190 | - 0.5 * ( u(k,j,i) - u(k,j-1,i) & |
---|
2191 | + u(k,j,i+1) - u(k,j-1,i+1) ) * ddy & |
---|
2192 | ) & |
---|
2193 | - f * u_stokes_zu(k) |
---|
2194 | ENDDO |
---|
2195 | |
---|
2196 | ! |
---|
2197 | !-- w-component |
---|
2198 | CASE ( 3 ) |
---|
2199 | DO k = nzb+1, nzt |
---|
2200 | tend(k,j,i) = tend(k,j,i) + u_stokes_zw(k) * ( & |
---|
2201 | 0.5 * ( u(k+1,j,i) - u(k,j,i) & |
---|
2202 | + u(k+1,j,i+1) - u(k,j,i+1) & |
---|
2203 | ) * ddzu(k+1) & |
---|
2204 | - 0.5 * ( w(k,j,i+1) - w(k,j,i-1) & |
---|
2205 | ) * ddx ) & |
---|
2206 | - v_stokes_zw(k) * ( & |
---|
2207 | 0.5 * ( w(k,j+1,i) - w(k,j-1,i) & |
---|
2208 | ) * ddy & |
---|
2209 | - 0.5 * ( v(k+1,j,i) - v(k,j,i) & |
---|
2210 | + v(k+1,j+1,i) - v(k,j+1,i) & |
---|
2211 | ) * ddzu(k) ) & |
---|
2212 | + fs * u_stokes_zw(k) |
---|
2213 | ENDDO |
---|
2214 | |
---|
2215 | CASE DEFAULT |
---|
2216 | WRITE( message_string, * ) ' wrong component: ', component |
---|
2217 | CALL message( 'stokes_drift_terms', 'PA0091', 1, 2, 0, 6, 0 ) |
---|
2218 | |
---|
2219 | END SELECT |
---|
2220 | |
---|
2221 | END SUBROUTINE stokes_drift_terms_ij |
---|
2222 | |
---|
2223 | |
---|
2224 | !------------------------------------------------------------------------------! |
---|
2225 | ! Description: |
---|
2226 | ! ------------ |
---|
2227 | !> This routine calculates turbulence generated by wave breaking near the ocean |
---|
2228 | !> surface, following a parameterization given in Noh et al. (2004), JPO |
---|
2229 | !> Call for all gridpoints. |
---|
2230 | !> TODO: so far, this routine only works if the model time step has about the |
---|
2231 | !> same value as the time scale of wave breaking! |
---|
2232 | !------------------------------------------------------------------------------! |
---|
2233 | SUBROUTINE wave_breaking_term( component ) |
---|
2234 | |
---|
2235 | USE arrays_3d, & |
---|
2236 | ONLY: u_p, v_p |
---|
2237 | |
---|
2238 | USE control_parameters, & |
---|
2239 | ONLY: dt_3d, message_string |
---|
2240 | |
---|
2241 | USE indices, & |
---|
2242 | ONLY: nxl, nxlu, nxr, nys, nysv, nyn, nzt |
---|
2243 | |
---|
2244 | IMPLICIT NONE |
---|
2245 | |
---|
2246 | INTEGER(iwp) :: component !< component of momentum equation |
---|
2247 | INTEGER(iwp) :: i !< loop index along x |
---|
2248 | INTEGER(iwp) :: j !< loop index along y |
---|
2249 | |
---|
2250 | REAL(wp) :: random_gauss !< function that creates a random number with a |
---|
2251 | !< Gaussian distribution |
---|
2252 | |
---|
2253 | |
---|
2254 | ! |
---|
2255 | !-- Compute wave breaking terms for the respective velocity components. |
---|
2256 | !-- Velocities are directly manipulated, since this is not a real force |
---|
2257 | SELECT CASE ( component ) |
---|
2258 | |
---|
2259 | ! |
---|
2260 | !-- u-component |
---|
2261 | CASE ( 1 ) |
---|
2262 | DO i = nxlu, nxr |
---|
2263 | DO j = nys, nyn |
---|
2264 | u_p(nzt,j,i) = u_p(nzt,j,i) + & |
---|
2265 | ( random_gauss( iran_ocean, 1.0_wp ) - 1.0_wp ) & |
---|
2266 | * alpha_wave_breaking * u_star_wave_breaking & |
---|
2267 | / timescale_wave_breaking * dt_3d |
---|
2268 | ENDDO |
---|
2269 | ENDDO |
---|
2270 | ! |
---|
2271 | !-- v-component |
---|
2272 | CASE ( 2 ) |
---|
2273 | DO i = nxl, nxr |
---|
2274 | DO j = nysv, nyn |
---|
2275 | v_p(nzt,j,i) = v_p(nzt,j,i) + & |
---|
2276 | ( random_gauss( iran_ocean, 1.0_wp ) - 1.0_wp ) & |
---|
2277 | * alpha_wave_breaking * u_star_wave_breaking & |
---|
2278 | / timescale_wave_breaking * dt_3d |
---|
2279 | ENDDO |
---|
2280 | ENDDO |
---|
2281 | |
---|
2282 | CASE DEFAULT |
---|
2283 | WRITE( message_string, * ) 'wrong component of wave breaking: ', & |
---|
2284 | component |
---|
2285 | CALL message( 'stokes_drift_terms', 'PA0466', 1, 2, 0, 6, 0 ) |
---|
2286 | |
---|
2287 | END SELECT |
---|
2288 | |
---|
2289 | END SUBROUTINE wave_breaking_term |
---|
2290 | |
---|
2291 | |
---|
2292 | !------------------------------------------------------------------------------! |
---|
2293 | ! Description: |
---|
2294 | ! ------------ |
---|
2295 | !> This routine calculates turbulence generated by wave breaking near the ocean |
---|
2296 | !> surface, following a parameterization given in Noh et al. (2004), JPO |
---|
2297 | !> Call for gridpoint i,j. |
---|
2298 | !> TODO: so far, this routine only works if the model time step has about the |
---|
2299 | !> same value as the time scale of wave breaking! |
---|
2300 | !------------------------------------------------------------------------------! |
---|
2301 | SUBROUTINE wave_breaking_term_ij( i, j, component ) |
---|
2302 | |
---|
2303 | USE arrays_3d, & |
---|
2304 | ONLY: u_p, v_p |
---|
2305 | |
---|
2306 | USE control_parameters, & |
---|
2307 | ONLY: dt_3d, message_string |
---|
2308 | |
---|
2309 | USE indices, & |
---|
2310 | ONLY: nzt |
---|
2311 | |
---|
2312 | IMPLICIT NONE |
---|
2313 | |
---|
2314 | INTEGER(iwp) :: component !< component of momentum equation |
---|
2315 | INTEGER(iwp) :: i !< loop index along x |
---|
2316 | INTEGER(iwp) :: j !< loop index along y |
---|
2317 | |
---|
2318 | REAL(wp) :: random_gauss !< function that creates a random number with a |
---|
2319 | !< Gaussian distribution |
---|
2320 | |
---|
2321 | ! |
---|
2322 | !-- Compute wave breaking terms for the respective velocity components |
---|
2323 | SELECT CASE ( component ) |
---|
2324 | |
---|
2325 | ! |
---|
2326 | !-- u-/v-component |
---|
2327 | CASE ( 1 ) |
---|
2328 | u_p(nzt,j,i) = u_p(nzt,j,i) + & |
---|
2329 | ( random_gauss( iran_ocean, 1.0_wp ) - 1.0_wp ) & |
---|
2330 | * alpha_wave_breaking * u_star_wave_breaking & |
---|
2331 | / timescale_wave_breaking * dt_3d |
---|
2332 | |
---|
2333 | CASE ( 2 ) |
---|
2334 | v_p(nzt,j,i) = v_p(nzt,j,i) + & |
---|
2335 | ( random_gauss( iran_ocean, 1.0_wp ) - 1.0_wp ) & |
---|
2336 | * alpha_wave_breaking * u_star_wave_breaking & |
---|
2337 | / timescale_wave_breaking * dt_3d |
---|
2338 | |
---|
2339 | CASE DEFAULT |
---|
2340 | WRITE( message_string, * ) 'wrong component of wave breaking: ', & |
---|
2341 | component |
---|
2342 | CALL message( 'stokes_drift_terms', 'PA0466', 1, 2, 0, 6, 0 ) |
---|
2343 | |
---|
2344 | END SELECT |
---|
2345 | |
---|
2346 | END SUBROUTINE wave_breaking_term_ij |
---|
2347 | |
---|
2348 | |
---|
2349 | END MODULE ocean_mod |
---|