1 | SUBROUTINE init_ocean |
---|
2 | |
---|
3 | !--------------------------------------------------------------------------------! |
---|
4 | ! This file is part of PALM. |
---|
5 | ! |
---|
6 | ! PALM is free software: you can redistribute it and/or modify it under the terms |
---|
7 | ! of the GNU General Public License as published by the Free Software Foundation, |
---|
8 | ! either version 3 of the License, or (at your option) any later 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 1997-2014 Leibniz Universitaet Hannover |
---|
18 | !--------------------------------------------------------------------------------! |
---|
19 | ! |
---|
20 | ! Current revisions: |
---|
21 | ! ----------------- |
---|
22 | ! |
---|
23 | ! |
---|
24 | ! Former revisions: |
---|
25 | ! ------------------ |
---|
26 | ! $Id: init_ocean.f90 1323 2014-03-20 17:09:54Z suehring $ |
---|
27 | ! |
---|
28 | ! 1322 2014-03-20 16:38:49Z raasch |
---|
29 | ! REAL constants defined as wp_kind |
---|
30 | ! |
---|
31 | ! 1320 2014-03-20 08:40:49Z raasch |
---|
32 | ! ONLY-attribute added to USE-statements, |
---|
33 | ! kind-parameters added to all INTEGER and REAL declaration statements, |
---|
34 | ! kinds are defined in new module kinds, |
---|
35 | ! revision history before 2012 removed, |
---|
36 | ! comment fields (!:) to be used for variable explanations added to |
---|
37 | ! all variable declaration statements |
---|
38 | ! |
---|
39 | ! 1179 2013-06-14 05:57:58Z raasch |
---|
40 | ! Initial density profile is stored in array hom |
---|
41 | ! |
---|
42 | ! 1036 2012-10-22 13:43:42Z raasch |
---|
43 | ! code put under GPL (PALM 3.9) |
---|
44 | ! |
---|
45 | ! 97 2007-06-21 08:23:15Z raasch |
---|
46 | ! Initial revision |
---|
47 | ! |
---|
48 | ! Description: |
---|
49 | ! ------------ |
---|
50 | ! Initialization of quantities needed for the ocean version |
---|
51 | !------------------------------------------------------------------------------! |
---|
52 | |
---|
53 | USE arrays_3d, & |
---|
54 | ONLY: dzu, hyp, pt_init, ref_state, sa_init, zu, zw |
---|
55 | |
---|
56 | USE control_parameters, & |
---|
57 | ONLY: g, prho_reference, rho_surface, rho_reference, & |
---|
58 | surface_pressure, use_single_reference_value |
---|
59 | |
---|
60 | USE eqn_state_seawater_mod, & |
---|
61 | ONLY: eqn_state_seawater, eqn_state_seawater_func |
---|
62 | |
---|
63 | USE indices, & |
---|
64 | ONLY: nzb, nzt |
---|
65 | |
---|
66 | USE kinds |
---|
67 | |
---|
68 | USE pegrid |
---|
69 | |
---|
70 | USE statistics, & |
---|
71 | ONLY: hom, statistic_regions |
---|
72 | |
---|
73 | IMPLICIT NONE |
---|
74 | |
---|
75 | INTEGER(iwp) :: k !: |
---|
76 | INTEGER(iwp) :: n !: |
---|
77 | |
---|
78 | REAL(wp) :: pt_l !: |
---|
79 | REAL(wp) :: sa_l !: |
---|
80 | |
---|
81 | REAL(wp), DIMENSION(nzb:nzt+1) :: rho_init !: |
---|
82 | |
---|
83 | ALLOCATE( hyp(nzb:nzt+1) ) |
---|
84 | |
---|
85 | ! |
---|
86 | !-- Set water density near the ocean surface |
---|
87 | rho_surface = 1027.62 |
---|
88 | |
---|
89 | ! |
---|
90 | !-- Calculate initial vertical profile of hydrostatic pressure (in Pa) |
---|
91 | !-- and the reference density (used later in buoyancy term) |
---|
92 | !-- First step: Calculate pressure using reference density |
---|
93 | hyp(nzt+1) = surface_pressure * 100.0_wp |
---|
94 | |
---|
95 | hyp(nzt) = hyp(nzt+1) + rho_surface * g * 0.5 * dzu(nzt+1) |
---|
96 | rho_init(nzt) = rho_surface |
---|
97 | |
---|
98 | DO k = nzt-1, 1, -1 |
---|
99 | hyp(k) = hyp(k+1) + rho_surface * g * dzu(k) |
---|
100 | ENDDO |
---|
101 | hyp(0) = hyp(1) + rho_surface * g * dzu(1) |
---|
102 | |
---|
103 | ! |
---|
104 | !-- Second step: Iteratively calculate in situ density (based on presssure) |
---|
105 | !-- and pressure (based on in situ density) |
---|
106 | DO n = 1, 5 |
---|
107 | |
---|
108 | rho_reference = rho_surface * 0.5 * dzu(nzt+1) |
---|
109 | |
---|
110 | DO k = nzt-1, 0, -1 |
---|
111 | |
---|
112 | sa_l = 0.5 * ( sa_init(k) + sa_init(k+1) ) |
---|
113 | pt_l = 0.5 * ( pt_init(k) + pt_init(k+1) ) |
---|
114 | |
---|
115 | rho_init(k) = eqn_state_seawater_func( hyp(k), pt_l, sa_l ) |
---|
116 | |
---|
117 | rho_reference = rho_reference + rho_init(k) * dzu(k+1) |
---|
118 | |
---|
119 | ENDDO |
---|
120 | |
---|
121 | rho_reference = rho_reference / ( zw(nzt) - zu(nzb) ) |
---|
122 | |
---|
123 | DO k = nzt-1, 0, -1 |
---|
124 | hyp(k) = hyp(k+1) + g * 0.5 * ( rho_init(k) + rho_init(k+1 ) ) * & |
---|
125 | dzu(k+1) |
---|
126 | ENDDO |
---|
127 | |
---|
128 | ENDDO |
---|
129 | |
---|
130 | ! |
---|
131 | !-- Calculate the reference potential density |
---|
132 | prho_reference = 0.0 |
---|
133 | DO k = 0, nzt |
---|
134 | |
---|
135 | sa_l = 0.5 * ( sa_init(k) + sa_init(k+1) ) |
---|
136 | pt_l = 0.5 * ( pt_init(k) + pt_init(k+1) ) |
---|
137 | |
---|
138 | prho_reference = prho_reference + dzu(k+1) * & |
---|
139 | eqn_state_seawater_func( 0.0_wp, pt_l, sa_l ) |
---|
140 | |
---|
141 | ENDDO |
---|
142 | |
---|
143 | prho_reference = prho_reference / ( zu(nzt) - zu(nzb) ) |
---|
144 | |
---|
145 | ! |
---|
146 | !-- Calculate the 3d array of initial in situ and potential density, |
---|
147 | !-- based on the initial temperature and salinity profile |
---|
148 | CALL eqn_state_seawater |
---|
149 | |
---|
150 | ! |
---|
151 | !-- Store initial density profile |
---|
152 | hom(:,1,77,:) = SPREAD( rho_init(:), 2, statistic_regions+1 ) |
---|
153 | |
---|
154 | ! |
---|
155 | !-- Set the reference state to be used in the buoyancy terms |
---|
156 | IF ( use_single_reference_value ) THEN |
---|
157 | ref_state(:) = prho_reference |
---|
158 | ELSE |
---|
159 | ref_state(:) = rho_init(:) |
---|
160 | ENDIF |
---|
161 | |
---|
162 | |
---|
163 | END SUBROUTINE init_ocean |
---|