SICOPOLIS V5-dev  Revision 1368
metric_m.F90
Go to the documentation of this file.
1 !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 !
3 ! Module : m e t r i c _ m
4 !
5 !> @file
6 !!
7 !! Definition of the components g11 and g22 of the metric tensor of the
8 !! applied numerical coordinates.
9 !!
10 !! @section Copyright
11 !!
12 !! Copyright 2009-2018 Ralf Greve, Roland Warner
13 !!
14 !! @section License
15 !!
16 !! This file is part of SICOPOLIS.
17 !!
18 !! SICOPOLIS is free software: you can redistribute it and/or modify
19 !! it under the terms of the GNU General Public License as published by
20 !! the Free Software Foundation, either version 3 of the License, or
21 !! (at your option) any later version.
22 !!
23 !! SICOPOLIS is distributed in the hope that it will be useful,
24 !! but WITHOUT ANY WARRANTY; without even the implied warranty of
25 !! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 !! GNU General Public License for more details.
27 !!
28 !! You should have received a copy of the GNU General Public License
29 !! along with SICOPOLIS. If not, see <http://www.gnu.org/licenses/>.
30 !<
31 !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
32 
33 !-------------------------------------------------------------------------------
34 !> Definition of the components g11 and g22 of the metric tensor of the
35 !! applied numerical coordinates.
36 !<------------------------------------------------------------------------------
37 module metric_m
38 
39  use sico_types_m
40  use error_m
41 
42  implicit none
43 
44  public :: metric
45 
46 contains
47 
48 !-------------------------------------------------------------------------------
49 !> Main routine of module metric_m:
50 !! Definition of the components g11 and g22 of the metric tensor of the
51 !! applied numerical coordinates.
52 !<------------------------------------------------------------------------------
53  subroutine metric()
54 
55  use sico_variables_m, only : xi, eta, &
59  phi0, pi, eps_dp, &
60  errormsg
61 
62  implicit none
63 
64  integer(i4b) :: i, j
65  real(dp) :: K
66  real(dp) :: g11_g(0:jmax,0:imax), g22_g(0:jmax,0:imax), &
67  g11_sgx(0:jmax,0:imax), g11_sgy(0:jmax,0:imax), &
68  g22_sgx(0:jmax,0:imax), g22_sgy(0:jmax,0:imax)
69 
70 #if (GRID==0) /* Stereographic projection (distortion neglected) */
71 
72 !-------- Components g11, g22 on the grid points (_g) and between
73 ! the grid points (_sg) --------
74 
75  g11_g = 1.0_dp
76  g22_g = 1.0_dp
77  g11_sgx = 1.0_dp
78  g11_sgy = 1.0_dp
79  g22_sgx = 1.0_dp
80  g22_sgy = 1.0_dp
81 
82 #elif (GRID==1) /* Stereographic projection */
83 
84  if (phi0 > eps_dp) then ! for northern hemisphere
85  k = (cos(0.25_dp*pi-0.5_dp*phi0))**2
86  else if (phi0 < (-eps_dp)) then ! for southern hemisphere
87  k = (cos(0.25_dp*pi+0.5_dp*phi0))**2
88  else
89  errormsg = ' >>> metric: PHI0 must be different from zero!'
90  call error(errormsg)
91  end if
92 
93 !-------- Components g11, g22 on the grid points (_g) --------
94 
95  do i=0, imax
96  do j=0, jmax
97  call metric_stereo(xi(i), eta(j), k, g11_g(j,i), g22_g(j,i))
98  end do
99  end do
100 
101 !-------- Components g11, g22 between the grid points (_sg) --------
102 
103  do i=0, imax-1
104  do j=0, jmax
105  call metric_stereo(0.5_dp*(xi(i)+xi(i+1)), eta(j), k, &
106  g11_sgx(j,i), g22_sgx(j,i))
107  end do
108  end do
109 
110  do i=0, imax
111  do j=0, jmax-1
112  call metric_stereo(xi(i), 0.5_dp*(eta(j)+eta(j+1)), k, &
113  g11_sgy(j,i), g22_sgy(j,i))
114  end do
115  end do
116 
117 #elif (GRID==2) /* Geographical coordinates */
118 
119 !-------- Components g11, g22 on the grid points (_g) --------
120 
121  do i=0, imax
122  do j=0, jmax
123  call metric_geogr(eta(j), g11_g(j,i), g22_g(j,i))
124  end do
125  end do
126 
127 !-------- Components g11, g22 between the grid points (_sg) --------
128 
129  do i=0, imax-1
130  do j=0, jmax
131  call metric_geogr(eta(j), g11_sgx(j,i), g22_sgx(j,i))
132  end do
133  end do
134 
135  do i=0, imax
136  do j=0, jmax-1
137  call metric_geogr(0.5_dp*(eta(j)+eta(j+1)), g11_sgy(j,i), g22_sgy(j,i))
138  end do
139  end do
140 
141 #endif
142 
143 !-------- Square roots (sq_) and inverse square roots (insq_) of
144 ! g11 and g22 --------
145 
146  do i=0, imax
147  do j=0, jmax
148  sq_g11_g(j,i) = sqrt(g11_g(j,i))
149  sq_g22_g(j,i) = sqrt(g22_g(j,i))
150  insq_g11_g(j,i) = 1.0_dp/sq_g11_g(j,i)
151  insq_g22_g(j,i) = 1.0_dp/sq_g22_g(j,i)
152  end do
153  end do
154 
155  do i=0, imax-1
156  do j=0, jmax
157  sq_g11_sgx(j,i) = sqrt(g11_sgx(j,i))
158  sq_g22_sgx(j,i) = sqrt(g22_sgx(j,i))
159  insq_g11_sgx(j,i) = 1.0_dp/sq_g11_sgx(j,i)
160  end do
161  end do
162 
163  do i=0, imax
164  do j=0, jmax-1
165  sq_g11_sgy(j,i) = sqrt(g11_sgy(j,i))
166  sq_g22_sgy(j,i) = sqrt(g22_sgy(j,i))
167  insq_g22_sgy(j,i) = 1.0_dp/sq_g22_sgy(j,i)
168  end do
169  end do
170 
171  end subroutine metric
172 
173 !-------------------------------------------------------------------------------
174 !> Components g11 and g22 of the metric tensor for the
175 !! stereographical projection.
176 !<------------------------------------------------------------------------------
177  subroutine metric_stereo(x_val, y_val, K, g11_r, g22_r)
179  use sico_variables_m, only : r
180 
181  implicit none
182 
183  real(dp), intent(in) :: x_val, y_val
184  real(dp), intent(in) :: K
185  real(dp), intent(out) :: g11_r, g22_r
186 
187  g11_r = 1.0_dp / ( k**2*(1.0_dp+(x_val**2+y_val**2)/(2.0_dp*r*k)**2)**2 )
188 
189  g22_r = g11_r
190 
191  end subroutine metric_stereo
192 
193 !-------------------------------------------------------------------------------
194 !> Components g11 and g22 of the metric tensor for geographical coordinates.
195 !<------------------------------------------------------------------------------
196  subroutine metric_geogr(phi_val, g11_r, g22_r)
198  use sico_variables_m, only : r
199 
200  implicit none
201 
202  real(dp), intent(in) :: phi_val
203  real(dp), intent(out) :: g11_r, g22_r
204 
205  g11_r = r**2*(cos(phi_val))**2
206 
207  g22_r = r**2
208 
209  end subroutine metric_geogr
210 
211 !-------------------------------------------------------------------------------
212 
213 end module metric_m
214 !
real(dp), dimension(0:jmax, 0:imax) insq_g22_sgy
insq_g22_sgy(j,i): Inverse square root of g22, at (i,j+1/2)
subroutine error(error_message)
Main routine of error_m: Writing of error messages and stopping execution.
Definition: error_m.F90:47
subroutine metric_stereo(x_val, y_val, K, g11_r, g22_r)
Components g11 and g22 of the metric tensor for the stereographical projection.
Definition: metric_m.F90:178
real(dp), dimension(0:jmax, 0:imax) insq_g11_sgx
insq_g11_sgx(j,i): Inverse square root of g11, at (i+1/2,j)
real(dp), dimension(0:jmax, 0:imax) insq_g22_g
insq_g22_g(j,i): Inverse square root of g22 on grid point (i,j)
real(dp), dimension(0:jmax, 0:imax) sq_g22_sgx
sq_g22_sgx(j,i): Square root of g22, at (i+1/2,j)
subroutine metric_geogr(phi_val, g11_r, g22_r)
Components g11 and g22 of the metric tensor for geographical coordinates.
Definition: metric_m.F90:197
real(dp), dimension(0:jmax, 0:imax) sq_g22_sgy
sq_g22_sgy(j,i): Square root of g22, at (i,j+1/2)
real(dp) r
R: Radius of the planet.
Declarations of kind types for SICOPOLIS.
Writing of error messages and stopping execution.
Definition: error_m.F90:35
real(dp), dimension(0:jmax, 0:imax) sq_g11_sgy
sq_g11_sgy(j,i): Square root of g11, at (i,j+1/2)
real(dp), parameter eps_dp
eps_dp: Small number to double-precision accuracy
Definition of the components g11 and g22 of the metric tensor of the applied numerical coordinates...
Definition: metric_m.F90:37
real(dp) phi0
PHI0: Standard parallel of the stereographic projection.
real(dp), dimension(0:jmax, 0:imax) sq_g11_sgx
sq_g11_sgx(j,i): Square root of g11, at (i+1/2,j)
real(dp), parameter pi
pi: Constant pi
real(dp), dimension(0:jmax, 0:imax) sq_g11_g
sq_g11_g(j,i): Square root of the coefficient g11 of the metric tensor on grid point (i...
subroutine, public metric()
Main routine of module metric_m: Definition of the components g11 and g22 of the metric tensor of the...
Definition: metric_m.F90:54
real(dp), dimension(0:jmax) eta
eta(j): Coordinate eta (= y) of grid point j
real(dp), dimension(0:jmax, 0:imax) insq_g11_g
insq_g11_g(j,i): Inverse square root of g11 on grid point (i,j)
real(dp), dimension(0:imax) xi
xi(i): Coordinate xi (= x) of grid point i
character(len=256) errormsg
errormsg: Error-message string
Declarations of global variables for SICOPOLIS.
real(dp), dimension(0:jmax, 0:imax) sq_g22_g
sq_g22_g(j,i): Square root of the coefficient g22 of the metric tensor on grid point (i...