SICOPOLIS V5-dev  Revision 1264
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 
41  implicit none
42 
43 #ifndef ALLOW_OPENAD
44  private
45 #endif
46  public :: metric
47 
48 contains
49 
50 !-------------------------------------------------------------------------------
51 !> Main routine of module metric_m:
52 !! Definition of the components g11 and g22 of the metric tensor of the
53 !! applied numerical coordinates.
54 !<------------------------------------------------------------------------------
55  subroutine metric()
56 
57  use sico_variables_m, only : xi, eta, &
61  phi0, pi, eps
62 
63  implicit none
64 
65  integer(i4b) :: i, j
66  real(dp) :: K
67  real(dp) :: g11_g(0:jmax,0:imax), g22_g(0:jmax,0:imax), &
68  g11_sgx(0:jmax,0:imax), g11_sgy(0:jmax,0:imax), &
69  g22_sgx(0:jmax,0:imax), g22_sgy(0:jmax,0:imax)
70 
71 #if (GRID==0) /* Stereographic projection (distortion neglected) */
72 
73 !-------- Components g11, g22 on the grid points (_g) and between
74 ! the grid points (_sg) --------
75 
76  g11_g = 1.0_dp
77  g22_g = 1.0_dp
78  g11_sgx = 1.0_dp
79  g11_sgy = 1.0_dp
80  g22_sgx = 1.0_dp
81  g22_sgy = 1.0_dp
82 
83 #elif (GRID==1) /* Stereographic projection */
84 
85  if (phi0 > eps) then ! for northern hemisphere
86  k = (cos(0.25_dp*pi-0.5_dp*phi0))**2
87  else if (phi0 < (-eps)) then ! for southern hemisphere
88  k = (cos(0.25_dp*pi+0.5_dp*phi0))**2
89  else
90 #ifndef ALLOW_OPENAD
91  stop ' metric: PHI0 must be different from zero!'
92 #else
93  write(*,*) ' metric: PHI0 must be different from zero!'
94 #endif
95 end if
96 
97 !-------- Components g11, g22 on the grid points (_g) --------
98 
99  do i=0, imax
100  do j=0, jmax
101  call metric_stereo(xi(i), eta(j), k, g11_g(j,i), g22_g(j,i))
102  end do
103  end do
104 
105 !-------- Components g11, g22 between the grid points (_sg) --------
106 
107  do i=0, imax-1
108  do j=0, jmax
109  call metric_stereo(0.5_dp*(xi(i)+xi(i+1)), eta(j), k, &
110  g11_sgx(j,i), g22_sgx(j,i))
111  end do
112  end do
113 
114  do i=0, imax
115  do j=0, jmax-1
116  call metric_stereo(xi(i), 0.5_dp*(eta(j)+eta(j+1)), k, &
117  g11_sgy(j,i), g22_sgy(j,i))
118  end do
119  end do
120 
121 #elif (GRID==2) /* Geographical coordinates */
122 
123 !-------- Components g11, g22 on the grid points (_g) --------
124 
125  do i=0, imax
126  do j=0, jmax
127  call metric_geogr(eta(j), g11_g(j,i), g22_g(j,i))
128  end do
129  end do
130 
131 !-------- Components g11, g22 between the grid points (_sg) --------
132 
133  do i=0, imax-1
134  do j=0, jmax
135  call metric_geogr(eta(j), g11_sgx(j,i), g22_sgx(j,i))
136  end do
137  end do
138 
139  do i=0, imax
140  do j=0, jmax-1
141  call metric_geogr(0.5_dp*(eta(j)+eta(j+1)), g11_sgy(j,i), g22_sgy(j,i))
142  end do
143  end do
144 
145 #endif
146 
147 !-------- Square roots (sq_) and inverse square roots (insq_) of
148 ! g11 and g22 --------
149 
150  do i=0, imax
151  do j=0, jmax
152  sq_g11_g(j,i) = sqrt(g11_g(j,i))
153  sq_g22_g(j,i) = sqrt(g22_g(j,i))
154  insq_g11_g(j,i) = 1.0_dp/sq_g11_g(j,i)
155  insq_g22_g(j,i) = 1.0_dp/sq_g22_g(j,i)
156  end do
157  end do
158 
159  do i=0, imax-1
160  do j=0, jmax
161  sq_g11_sgx(j,i) = sqrt(g11_sgx(j,i))
162  sq_g22_sgx(j,i) = sqrt(g22_sgx(j,i))
163  insq_g11_sgx(j,i) = 1.0_dp/sq_g11_sgx(j,i)
164  end do
165  end do
166 
167  do i=0, imax
168  do j=0, jmax-1
169  sq_g11_sgy(j,i) = sqrt(g11_sgy(j,i))
170  sq_g22_sgy(j,i) = sqrt(g22_sgy(j,i))
171  insq_g22_sgy(j,i) = 1.0_dp/sq_g22_sgy(j,i)
172  end do
173  end do
174 
175  end subroutine metric
176 
177 !-------------------------------------------------------------------------------
178 !> Components g11 and g22 of the metric tensor for the
179 !! stereographical projection.
180 !<------------------------------------------------------------------------------
181  subroutine metric_stereo(x_val, y_val, K, g11_r, g22_r)
183  use sico_variables_m, only : r
184 
185  implicit none
186 
187  real(dp), intent(in) :: x_val, y_val
188  real(dp), intent(in) :: K
189  real(dp), intent(out) :: g11_r, g22_r
190 
191  g11_r = 1.0_dp / ( k**2*(1.0_dp+(x_val**2+y_val**2)/(2.0_dp*r*k)**2)**2 )
192 
193  g22_r = g11_r
194 
195  end subroutine metric_stereo
196 
197 !-------------------------------------------------------------------------------
198 !> Components g11 and g22 of the metric tensor for geographical coordinates.
199 !<------------------------------------------------------------------------------
200  subroutine metric_geogr(phi_val, g11_r, g22_r)
202  use sico_variables_m, only : r
203 
204  implicit none
205 
206  real(dp), intent(in) :: phi_val
207  real(dp), intent(out) :: g11_r, g22_r
208 
209  g11_r = r**2*(cos(phi_val))**2
210 
211  g22_r = r**2
212 
213  end subroutine metric_geogr
214 
215 !-------------------------------------------------------------------------------
216 
217 end module metric_m
218 !
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)
real(dp), parameter eps
eps: Small number
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:182
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:201
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.
real(dp), dimension(0:jmax, 0:imax) sq_g11_sgy
sq_g11_sgy(j,i): Square root of g11, at (i,j+1/2)
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:56
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
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...