7 !! Calculation of topography gradients on the staggered grid and on the grid
8 !! points (the latter by second-order discretization).
9 !! Length rescaling with the corresponding components of the metric tensor is
14 !! Copyright 2009-2013 Ralf Greve
18 !! This file is part of SICOPOLIS.
20 !! SICOPOLIS is free software: you can redistribute it and/or modify
21 !! it under the terms of the GNU General Public License as published by
22 !! the Free Software Foundation, either version 3 of the License, or
23 !! (at your option) any later version.
25 !! SICOPOLIS is distributed in the hope that it will be useful,
26 !! but WITHOUT ANY WARRANTY; without even the implied warranty of
27 !! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28 !! GNU General Public License for more details.
30 !! You should have received a copy of the GNU General Public License
31 !! along with SICOPOLIS. If not, see <http://www.gnu.org/licenses/>.
33 !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
36 !> Calculation of topography gradients on the staggered grid and on the grid
37 !! points (the latter by second-order discretization).
38 !! Length rescaling with the corresponding components of the metric tensor is
40 !<------------------------------------------------------------------------------
48 integer(i4b) :: n_switch
49 real(dp) :: dxi, deta, dxi_inv, deta_inv
50 real(dp) :: zs_help(0:jmax,0:imax), zm_help(0:jmax,0:imax), &
51 zb_help(0:jmax,0:imax)
54 deta_inv = 1.0_dp/deta
58 if (n_switch.eq.1)
then
62 zs_help(j,i) = zs(j,i)
63 zm_help(j,i) = zm(j,i)
64 zb_help(j,i) = zb(j,i)
68 else if (n_switch.eq.2)
then
72 zs_help(j,i) = zs_neu(j,i)
73 zm_help(j,i) = zm_neu(j,i)
74 zb_help(j,i) = zb_neu(j,i)
79 stop
' topograd_1: Wrong value for n_switch!'
88 dzs_dxi(j,i) = (zs_help(j,i+1)-zs_help(j,i))*dxi_inv &
90 dzm_dxi(j,i) = (zm_help(j,i+1)-zm_help(j,i))*dxi_inv &
92 dzb_dxi(j,i) = (zb_help(j,i+1)-zb_help(j,i))*dxi_inv &
94 dh_c_dxi(j,i) = dzs_dxi(j,i)-dzm_dxi(j,i)
95 dh_t_dxi(j,i) = dzm_dxi(j,i)-dzb_dxi(j,i)
103 dzs_deta(j,i) = (zs_help(j+1,i)-zs_help(j,i))*deta_inv &
105 dzm_deta(j,i) = (zm_help(j+1,i)-zm_help(j,i))*deta_inv &
107 dzb_deta(j,i) = (zb_help(j+1,i)-zb_help(j,i))*deta_inv &
109 dh_c_deta(j,i) = dzs_deta(j,i)-dzm_deta(j,i)
110 dh_t_deta(j,i) = dzm_deta(j,i)-dzb_deta(j,i)
120 dzs_dxi_g(j,i) = (zs_help(j,i+1)-zs_help(j,i-1))*0.5_dp*dxi_inv &
122 dzm_dxi_g(j,i) = (zm_help(j,i+1)-zm_help(j,i-1))*0.5_dp*dxi_inv &
124 dzb_dxi_g(j,i) = (zb_help(j,i+1)-zb_help(j,i-1))*0.5_dp*dxi_inv &
126 dh_c_dxi_g(j,i) = dzs_dxi_g(j,i)-dzm_dxi_g(j,i)
127 dh_t_dxi_g(j,i) = dzm_dxi_g(j,i)-dzb_dxi_g(j,i)
132 dzs_dxi_g(j,0) = (zs_help(j,1)-zs_help(j,0))*dxi_inv &
134 dzm_dxi_g(j,0) = (zm_help(j,1)-zm_help(j,0))*dxi_inv &
136 dzb_dxi_g(j,0) = (zb_help(j,1)-zb_help(j,0))*dxi_inv &
138 dh_c_dxi_g(j,0) = dzs_dxi_g(j,0)-dzm_dxi_g(j,0)
139 dh_t_dxi_g(j,0) = dzm_dxi_g(j,0)-dzb_dxi_g(j,0)
140 dzs_dxi_g(j,imax) = (zs_help(j,imax)-zs_help(j,imax-1)) &
143 dzm_dxi_g(j,imax) = (zm_help(j,imax)-zm_help(j,imax-1)) &
146 dzb_dxi_g(j,imax) = (zb_help(j,imax)-zb_help(j,imax-1)) &
149 dh_c_dxi_g(j,imax) = dzs_dxi_g(j,imax)-dzm_dxi_g(j,imax)
150 dh_t_dxi_g(j,imax) = dzm_dxi_g(j,imax)-dzb_dxi_g(j,imax)
157 dzs_deta_g(j,i) = (zs_help(j+1,i)-zs_help(j-1,i)) &
160 dzm_deta_g(j,i) = (zm_help(j+1,i)-zm_help(j-1,i)) &
163 dzb_deta_g(j,i) = (zb_help(j+1,i)-zb_help(j-1,i)) &
166 dh_c_deta_g(j,i) = dzs_deta_g(j,i)-dzm_deta_g(j,i)
167 dh_t_deta_g(j,i) = dzm_deta_g(j,i)-dzb_deta_g(j,i)
172 dzs_deta_g(0,i) = (zs_help(1,i)-zs_help(0,i))*deta_inv &
174 dzm_deta_g(0,i) = (zm_help(1,i)-zm_help(0,i))*deta_inv &
176 dzb_deta_g(0,i) = (zb_help(1,i)-zb_help(0,i))*deta_inv &
178 dh_c_deta_g(0,i) = dzs_deta_g(0,i)-dzm_deta_g(0,i)
179 dh_t_deta_g(0,i) = dzm_deta_g(0,i)-dzb_deta_g(0,i)
180 dzs_deta_g(jmax,i) = (zs_help(jmax,i)-zs_help(jmax-1,i)) &
183 dzm_deta_g(jmax,i) = (zm_help(jmax,i)-zm_help(jmax-1,i)) &
186 dzb_deta_g(jmax,i) = (zb_help(jmax,i)-zb_help(jmax-1,i)) &
189 dh_c_deta_g(jmax,i) = dzs_deta_g(jmax,i)-dzm_deta_g(jmax,i)
190 dh_t_deta_g(jmax,i) = dzm_deta_g(jmax,i)-dzb_deta_g(jmax,i)