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