SICOPOLIS V3.1
 All Classes Files Functions Variables Macros
topography1.F90
Go to the documentation of this file.
1 !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 !
3 ! Subroutine : t o p o g r a p h y 1
4 !
5 !> @file
6 !!
7 !! Definition of the initial surface and bedrock topography
8 !! (including gradients) and of the horizontal grid spacings dxi, deta.
9 !! For present-day initial topography.
10 !!
11 !! @section Copyright
12 !!
13 !! Copyright 2009-2013 Ralf Greve
14 !!
15 !! @section License
16 !!
17 !! This file is part of SICOPOLIS.
18 !!
19 !! SICOPOLIS is free software: you can redistribute it and/or modify
20 !! it under the terms of the GNU General Public License as published by
21 !! the Free Software Foundation, either version 3 of the License, or
22 !! (at your option) any later version.
23 !!
24 !! SICOPOLIS is distributed in the hope that it will be useful,
25 !! but WITHOUT ANY WARRANTY; without even the implied warranty of
26 !! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 !! GNU General Public License for more details.
28 !!
29 !! You should have received a copy of the GNU General Public License
30 !! along with SICOPOLIS. If not, see <http://www.gnu.org/licenses/>.
31 !<
32 !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
33 
34 !-------------------------------------------------------------------------------
35 !> Definition of the initial surface and bedrock topography
36 !! (including gradients) and of the horizontal grid spacings dxi, deta.
37 !! For present-day initial topography.
38 !<------------------------------------------------------------------------------
39 subroutine topography1(dxi, deta)
40 
41 use sico_types
43 
44 implicit none
45 
46 real(dp), intent(out) :: dxi, deta
47 
48 integer(i4b) :: i, j, n
49 integer(i4b) :: ios, n_dummy
50 real(dp) :: d_dummy
51 real(dp) :: xi0, eta0
52 real(dp) :: h_ice, freeboard_ratio
53 character :: ch_dummy
54 
55 character(len= 8) :: ch_imax
56 character(len=128) :: fmt4
57 
58 write(ch_imax, fmt='(i8)') imax
59 write(fmt4, fmt='(a)') '('//trim(adjustl(ch_imax))//'(i1),i1)'
60 
61 !-------- Read topography --------
62 
63 open(21, iostat=ios, &
64  file=inpath//'/grl/'//zs_present_file, &
65  recl=8192, status='old')
66 
67 if (ios.ne.0) stop ' topography1: Error when opening the zs file!'
68 
69 open(22, iostat=ios, &
70  file=inpath//'/grl/'//zl_present_file, &
71  recl=8192, status='old')
72 
73 if (ios.ne.0) stop ' topography1: Error when opening the zl file!'
74 
75 open(23, iostat=ios, &
76  file=inpath//'/grl/'//zl0_file, &
77  recl=8192, status='old')
78 
79 if (ios.ne.0) stop ' topography1: Error when opening the zl0 file!'
80 
81 open(24, iostat=ios, &
82  file=inpath//'/grl/'//mask_present_file, &
83  recl=1024, status='old')
84 
85 if (ios.ne.0) stop ' topography1: Error when opening the mask file!'
86 
87 do n=1, 6; read(21, fmt='(a)') ch_dummy; end do
88 do n=1, 6; read(22, fmt='(a)') ch_dummy; end do
89 do n=1, 6; read(23, fmt='(a)') ch_dummy; end do
90 do n=1, 6; read(24, fmt='(a)') ch_dummy; end do
91 
92 do j=jmax, 0, -1
93  read(21, fmt=*) (zs(j,i), i=0,imax)
94  read(22, fmt=*) (zl(j,i), i=0,imax)
95  read(23, fmt=*) (zl0(j,i), i=0,imax)
96  read(24, fmt=trim(fmt4)) (maske(j,i), i=0,imax)
97 end do
98 
99 close(21, status='keep')
100 close(22, status='keep')
101 close(23, status='keep')
102 close(24, status='keep')
103 
104 !-------- Further stuff --------
105 
106 dxi = dx *1000.0_dp ! km -> m
107 deta = dx *1000.0_dp ! km -> m
108 
109 xi0 = x0 *1000.0_dp ! km -> m
110 eta0 = y0 *1000.0_dp ! km -> m
111 
112 freeboard_ratio = (rho_sw-rho)/rho_sw
113 
114 do i=0, imax
115 do j=0, jmax
116 
117  if (maske(j,i) <= 1 ) then
118 
119  zb(j,i) = zl(j,i) ! ensure consistency
120 
121  else if (maske(j,i) == 2 ) then
122 
123 #if ( MARGIN==1 || MARGIN==2 )
124  zs(j,i) = zl(j,i) ! ensure
125  zb(j,i) = zl(j,i) ! consistency
126 #elif ( MARGIN==3 )
127  zs(j,i) = 0.0_dp ! present-day
128  zb(j,i) = 0.0_dp ! sea level
129 #endif
130 
131  else if (maske(j,i) == 3 ) then
132 
133 #if ( MARGIN==1 || ( MARGIN==2 && MARINE_ICE_FORMATION==1 ) )
134  maske(j,i) = 2 ! floating ice cut off
135  zs(j,i) = zl(j,i)
136  zb(j,i) = zl(j,i)
137 #elif ( MARGIN==2 && MARINE_ICE_FORMATION==2 )
138  maske(j,i) = 0 ! floating ice becomes "underwater ice"
139  h_ice = zs(j,i)-zb(j,i) ! ice thickness
140  zs(j,i) = zl(j,i)+h_ice
141  zb(j,i) = zl(j,i)
142 #elif ( MARGIN==3 )
143  h_ice = zs(j,i)-zb(j,i) ! ice thickness
144  zs(j,i) = freeboard_ratio*h_ice ! ensure properly
145  zb(j,i) = zs(j,i)-h_ice ! floating ice
146 #endif
147 
148  end if
149 
150  xi(i) = xi0 + real(i,dp)*dxi
151  eta(j) = eta0 + real(j,dp)*deta
152 
153  call geo_coord(phi(j,i), lambda(j,i), xi(i), eta(j))
154 
155  zm(j,i) = zb(j,i)
156  n_cts(j,i) = -1
157 
158  h_c(j,i) = zs(j,i)-zm(j,i)
159  h_t(j,i) = 0.0_dp
160 
161  dzs_dtau(j,i) = 0.0_dp
162  dzm_dtau(j,i) = 0.0_dp
163  dzb_dtau(j,i) = 0.0_dp
164  dzl_dtau(j,i) = 0.0_dp
165  dh_c_dtau(j,i) = 0.0_dp
166  dh_t_dtau(j,i) = 0.0_dp
167 
168 end do
169 end do
170 
171 !-------- Metric tensor, gradients of the topography --------
172 
173 call metric()
174 
175 #if TOPOGRAD==0
176 call topograd_1(dxi, deta, 1)
177 #elif TOPOGRAD==1
178 call topograd_2(dxi, deta, 1)
179 #endif
180 
181 !-------- Corresponding area of grid points --------
182 
183 do i=0, imax
184 do j=0, jmax
185  area(j,i) = sq_g11_g(j,i)*sq_g22_g(j,i)*dxi*deta
186 end do
187 end do
188 
189 end subroutine topography1
190 !