SICOPOLIS V3.2
 All Classes Files Functions Variables Macros
make_zl0.F90
Go to the documentation of this file.
1 !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 !
3 ! Subroutine : m a k e _ z l 0
4 !
5 !> @file
6 !!
7 !! Generation of an isostatically relaxed lithosphere surface topography
8 !! for either the rigid lithosphere, the local lithosphere or the elastic
9 !! lithosphere model (depending on the setting of the parameter REBOUND).
10 !! This routine is not to be used regularly, and it is only executed if the
11 !! parameter EXEC_MAKE_ZL0 is defined in the header file.
12 !!
13 !! @section Copyright
14 !!
15 !! Copyright 2014-2016 Ralf Greve
16 !!
17 !! @section License
18 !!
19 !! This file is part of SICOPOLIS.
20 !!
21 !! SICOPOLIS is free software: you can redistribute it and/or modify
22 !! it under the terms of the GNU General Public License as published by
23 !! the Free Software Foundation, either version 3 of the License, or
24 !! (at your option) any later version.
25 !!
26 !! SICOPOLIS is distributed in the hope that it will be useful,
27 !! but WITHOUT ANY WARRANTY; without even the implied warranty of
28 !! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29 !! GNU General Public License for more details.
30 !!
31 !! You should have received a copy of the GNU General Public License
32 !! along with SICOPOLIS. If not, see <http://www.gnu.org/licenses/>.
33 !<
34 !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
35 
36 !-------------------------------------------------------------------------------
37 !> Generation of an isostatically relaxed lithosphere surface topography
38 !! for either the rigid lithosphere, the local lithosphere or the elastic
39 !! lithosphere model (depending on the setting of the parameter REBOUND).
40 !! This routine is not to be used regularly, and it is only executed if the
41 !! parameter EXEC_MAKE_ZL0 is defined in the header file.
42 !<------------------------------------------------------------------------------
43 subroutine make_zl0()
44 
45 use sico_types
47 use sico_vars
48 
49 implicit none
50 
51 integer(i4b) :: i, j, m, n, i_f, j_f, n_filter
52 integer(i4b) :: ios
53 real(dp), dimension(0:JMAX,0:IMAX) :: zl0_raw, zl0_smoothed
54 real(dp) :: rho_ratio
55 real(dp) :: filter_width, sigma_filter
56 real(dp) :: dist, weigh, sum_weigh
57 character(len= 8) :: ch_resolution
58 character(len= 64) :: ch_model
59 character(len=256) :: ch_filename
60 
61 !-------- Checking of the grid --------
62 
63 #if (GRID==0 || GRID==1)
64 
65 continue
66 
67 #else
68 
69 stop ' make_zl0: Routine works only for GRID 0 or 1!'
70 
71 #endif
72 
73 !-------- Computation of the raw (unsmoothed) topography --------
74 
75 rho_ratio = rho/rho_a
76 
77 #if (REBOUND==0)
78 
79 zl0_raw = zl ! rigid lithosphere
80 
81 #elif (REBOUND==1)
82 
83 do i=0, imax
84 do j=0, jmax
85 
86  if (maske(j,i) == 0) then
87  zl0_raw(j,i) = zl(j,i) + rho_ratio*(h_c(j,i)+h_t(j,i))
88  else
89  zl0_raw(j,i) = zl(j,i)
90  end if ! local lithosphere
91 
92 end do
93 end do
94 
95 #elif (REBOUND==2)
96 
97 zl0_raw = zl + wss ! elastic lithosphere
98 
99 #else
100 
101 stop ' make_zl0: REBOUND must be either 0, 1 or 2!'
102 
103 #endif
104 
105 !-------- Smoothing of the topography (Gaussian filter) --------
106 
107 do i=0, imax
108 do j=0, jmax
109 
110  filter_width = real(DX, dp) ! half span of filtered area, in km
111  ! (chosen as one grid spacing)
112 
113  sigma_filter = filter_width/real(DX, dp) ! half span of filtered area,
114  ! in grid points
115 
116  n_filter = ceiling(2.0_dp*sigma_filter)
117  n_filter = max(n_filter, 5)
118 
119  sum_weigh = 0.0_dp
120 
121  do m=-n_filter, n_filter
122  do n=-n_filter, n_filter
123 
124  i_f = i+m
125  j_f = j+n
126 
127  if (i_f < 0) i_f = 0
128  if (i_f > imax) i_f = imax
129 
130  if (j_f < 0) j_f = 0
131  if (j_f > jmax) j_f = jmax
132 
133  dist = sqrt(real(m,dp)**2+real(n,dp)**2)
134  weigh = exp(-(dist/sigma_filter)**2)
135  sum_weigh = sum_weigh + weigh
136 
137  zl0_smoothed(j,i) = zl0_smoothed(j,i) + weigh*zl0_raw(j_f,i_f)
138 
139  end do
140  end do
141 
142  zl0_smoothed(j,i) = zl0_smoothed(j,i)/sum_weigh
143 
144 end do
145 end do
146 
147 !-------- Writing on file --------
148 
149 if ( abs(real(dx,dp)-nint(real(dx,dp))) < eps ) then
150  write(ch_resolution, fmt='(i8)') nint(real(dx,dp))
151 else
152  write(ch_resolution, fmt='(f8.2)') real(dx,dp)
153 end if
154 
155 ch_resolution = adjustl(ch_resolution)
156 
157 #if (REBOUND==0)
158 ch_model = 'rigid_lithosphere'
159 #elif (REBOUND==1)
160 ch_model = 'local_lithosphere'
161 #elif (REBOUND==2)
162 ch_model = 'elastic_lithosphere'
163 #endif
164 
165 ch_filename = trim(ch_domain_short)//'_'//trim(ch_resolution)
166 ch_filename = trim(ch_filename)//'_zl0_'//trim(ch_model)//'.dat'
167 
168 open(23, iostat=ios, &
169  file=outpath//'/'//trim(ch_filename), &
170  recl=8192, status='replace')
171 if (ios /= 0) stop ' make_zl0: Error when opening the new zl0 file!'
172 
173 write(23,'(a)') &
174 '%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++'
175 write(23,'(a)') '% '//trim(ch_domain_long)//':'
176 write(23,'(a)') &
177 '% Relaxed lithosphere surface topography without ice load, in m AMSL.'
178 write(23,'(a)') &
179 '% Horizontal resolution '//trim(ch_resolution)//' km.'
180 write(23,'(a,i3,a,i3,a,i3,a,i3,a)') &
181 '% ', jmax+1, ' records [j = ', &
182 jmax, ' (-1) 0] with ', imax+1, &
183 ' values [i = 0 (1) ', imax, '] in each record.'
184 write(23,'(a)') &
185 '%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++'
186 
187 do j=jmax, 0, -1
188  do i=0, imax-1
189  if ( zl0_smoothed(j,i) < -9999.0_dp ) zl0_smoothed(j,i) = -9999.0_dp
190  write(23,'(f8.1)', advance='no') zl0_smoothed(j,i)
191  end do
192  i=imax
193  if ( zl0_smoothed(j,i) < -9999.0_dp ) zl0_smoothed(j,i) = -9999.0_dp
194  write(23,'(f8.1)') zl0_smoothed(j,i)
195 end do
196 
197 close(23, status='keep')
198 
199 end subroutine make_zl0
200 !
Declarations of kind types for SICOPOLIS.
Definition: sico_types.F90:35
Declarations of global variables for SICOPOLIS (for the ANT domain).
Definition: sico_vars.F90:35
subroutine make_zl0()
Generation of an isostatically relaxed lithosphere surface topography for either the rigid lithospher...
Definition: make_zl0.F90:43
Declarations of global variables for SICOPOLIS.