7 !! Writing of time-slice files in binary format.
11 !! Copyright 2009-2013 Ralf Greve
15 !! This file is part of SICOPOLIS.
17 !! SICOPOLIS is free software: you can redistribute it and/or modify
18 !! it under the terms of the GNU General Public License as published by
19 !! the Free Software Foundation, either version 3 of the License, or
20 !! (at your option) any later version.
22 !! SICOPOLIS is distributed in the hope that it will be useful,
23 !! but WITHOUT ANY WARRANTY; without even the implied warranty of
24 !! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 !! GNU General Public License for more details.
27 !! You should have received a copy of the GNU General Public License
28 !! along with SICOPOLIS. If not, see <http://www.gnu.org/licenses/>.
30 !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
33 !> Writing of time-slice files in binary format.
34 !<------------------------------------------------------------------------------
35 subroutine output1(runname, time, delta_ts, glac_index, z_sl, &
36 flag_3d_output, ndat2d, ndat3d)
43 real(dp),
intent (in) :: time, delta_ts, glac_index, z_sl
44 character (len=100),
intent (in) :: runname
45 logical,
intent (in) :: flag_3d_output
47 integer(i4b),
intent (inout) :: ndat2d, ndat3d
49 integer(i4b) :: i, j, kc, kt, kr
50 integer(i4b) :: ndat, ndat_help, ndat_1000s, ndat_100s, ndat_10s, ndat_1s
51 real(dp) :: v_tot, a_grounded, a_floating
52 real(sp) :: time_conv, delta_ts_conv, glac_index_conv, z_sl_conv, &
53 v_tot_conv, a_grounded_conv, a_floating_conv, &
54 h_r_conv, xi_conv(0:imax), eta_conv(0:jmax), &
55 sigma_level_c_conv(0:kcmax), sigma_level_t_conv(0:ktmax), &
56 sigma_level_r_conv(0:krmax), &
57 lambda_conv(0:jmax,0:imax), phi_conv(0:jmax,0:imax), &
58 temp_s_conv(0:jmax,0:imax), as_perp_conv(0:jmax,0:imax), &
59 zs_conv(0:jmax,0:imax), zm_conv(0:jmax,0:imax), &
60 zb_conv(0:jmax,0:imax), zl_conv(0:jmax,0:imax), &
61 h_c_conv(0:jmax,0:imax), h_t_conv(0:jmax,0:imax), &
62 h_conv(0:jmax,0:imax), &
63 q_bm_conv(0:jmax,0:imax), q_tld_conv(0:jmax,0:imax), &
64 am_perp_conv(0:jmax,0:imax), &
65 qx_conv(0:jmax,0:imax), qy_conv(0:jmax,0:imax), &
66 temp_r_conv(0:krmax,0:jmax,0:imax), &
67 vx_c_conv(0:kcmax,0:jmax,0:imax), &
68 vy_c_conv(0:kcmax,0:jmax,0:imax), &
69 vz_c_conv(0:kcmax,0:jmax,0:imax), &
70 vx_t_conv(0:ktmax,0:jmax,0:imax), &
71 vy_t_conv(0:ktmax,0:jmax,0:imax), &
72 vz_t_conv(0:ktmax,0:jmax,0:imax), &
73 temp_c_conv(0:kcmax,0:jmax,0:imax), &
74 age_c_conv(0:kcmax,0:jmax,0:imax), &
75 omega_t_conv(0:ktmax,0:jmax,0:imax), &
76 age_t_conv(0:ktmax,0:jmax,0:imax), &
77 dzs_dtau_conv(0:jmax,0:imax), dzm_dtau_conv(0:jmax,0:imax), &
78 dzb_dtau_conv(0:jmax,0:imax), dzl_dtau_conv(0:jmax,0:imax), &
79 dh_c_dtau_conv(0:jmax,0:imax), dh_t_dtau_conv(0:jmax,0:imax), &
80 dh_dtau_conv(0:jmax,0:imax), &
81 vx_b_g_conv(0:jmax,0:imax), vy_b_g_conv(0:jmax,0:imax), &
82 vz_b_conv(0:jmax,0:imax), &
83 vx_s_g_conv(0:jmax,0:imax), vy_s_g_conv(0:jmax,0:imax), &
84 vz_s_conv(0:jmax,0:imax), &
85 temp_b_conv(0:jmax,0:imax), temph_b_conv(0:jmax,0:imax), &
86 p_b_w_conv(0:jmax,0:imax), h_w_conv(0:jmax,0:imax), &
87 q_gl_g_conv(0:jmax,0:imax)
88 character (len=256) :: filename
89 character :: ch_1000s, ch_100s, ch_10s, ch_1s
92 character (len= 16) :: ch_date, ch_time, ch_zone
93 character (len=256) :: ch_attr_title, ch_attr_institution, ch_attr_source, &
94 ch_attr_history, ch_attr_references
98 if (flag_3d_output)
then
104 if (ndat > 9999) stop
' output1: Too many time-slice files!'
107 ndat_1000s = ndat_help/1000
108 ndat_help = ndat_help-ndat_1000s*1000
109 ndat_100s = ndat_help/100
110 ndat_help = ndat_help-ndat_100s*100
111 ndat_10s = ndat_help/10
112 ndat_help = ndat_help-ndat_10s*10
115 ch_1000s = char(ndat_1000s+ichar(
'0'))
116 ch_100s = char(ndat_100s +ichar(
'0'))
117 ch_10s = char(ndat_10s +ichar(
'0'))
118 ch_1s = char(ndat_1s +ichar(
'0'))
120 if (flag_3d_output)
then
121 filename = trim(runname)//ch_1000s//ch_100s//ch_10s//ch_1s//
'.erg'
123 filename = trim(runname)//
'_2d_'//ch_1000s//ch_100s//ch_10s//ch_1s//
'.erg'
128 open(11, iostat=ios, &
129 file=outpath//
'/'//trim(filename), &
130 status=
'new', form=
'unformatted')
131 if (ios /= 0) stop
' output1: Error when opening an erg file!'
135 ch_attr_title =
'Time-slice output no. '//ch_1000s//ch_100s//ch_10s//ch_1s// &
136 'of simulation '//trim(runname)
137 write(11) ch_attr_title
139 ch_attr_institution =
'Institute of Low Temperature Science, '// &
140 'Hokkaido University, Sapporo, Japan'
141 write(11) ch_attr_institution
143 ch_attr_source =
'SICOPOLIS Version '//version
144 write(11) ch_attr_source
146 call date_and_time(ch_date, ch_time, ch_zone)
147 ch_attr_history = ch_date(1:4)//
'-'//ch_date(5:6)//
'-'//ch_date(7:8)//
' '// &
148 ch_time(1:2)//
':'//ch_time(3:4)//
':'//ch_time(5:6)//
' '// &
149 ch_zone(1:3)//
':'//ch_zone(4:5)//
' - Data produced'
150 write(11) ch_attr_history
152 ch_attr_references =
'http://sicopolis.greveweb.net/'
153 write(11) ch_attr_references
166 if ( (maske(j,i)==0).or.(maske(j,i)==3) ) &
167 v_tot = v_tot + (h_c(j,i)+h_t(j,i))*area(j,i)
170 a_grounded = a_grounded + area(j,i)
173 a_floating = a_floating + area(j,i)
180 #if ( !defined(OUT_TIMES) || OUT_TIMES==1 )
181 time_conv =
real(time,sp)
183 time_conv =
real((time+year_zero),sp)
185 stop
' output1: OUT_TIMES must be either 1 or 2!'
188 delta_ts_conv =
real(delta_ts,sp)
189 glac_index_conv =
real(glac_index,sp)
190 z_sl_conv =
real(z_sl,sp)
191 v_tot_conv =
real(v_tot,sp)
192 a_grounded_conv =
real(a_grounded,sp)
193 a_floating_conv =
real(a_floating,sp)
194 h_r_conv =
real(h_r,sp)
197 xi_conv(i) =
real(xi(i),sp)
201 eta_conv(j) =
real(eta(j),sp)
205 sigma_level_c_conv(kc) =
real(eaz_c_quotient(kc),sp)
209 sigma_level_t_conv(kt) =
real(zeta_t(kt),sp)
213 sigma_level_r_conv(kr) =
real(kr,sp)/
real(krmax,sp)
219 lambda_conv(j,i) =
real(lambda(j,i),sp)
220 phi_conv(j,i) =
real(phi(j,i),sp)
221 temp_s_conv(j,i) =
real(temp_s(j,i),sp)
222 as_perp_conv(j,i) =
real(as_perp(j,i),sp)
223 zs_conv(j,i) =
real(zs(j,i),sp)
224 zm_conv(j,i) =
real(zm(j,i),sp)
225 zb_conv(j,i) =
real(zb(j,i),sp)
226 zl_conv(j,i) =
real(zl(j,i),sp)
227 h_c_conv(j,i) =
real(H_c(j,i),sp)
228 h_t_conv(j,i) =
real(H_t(j,i),sp)
229 h_conv(j,i) =
real(H_c(j,i)+H_t(j,i),sp)
230 q_bm_conv(j,i) =
real(Q_bm(j,i),sp)
231 q_tld_conv(j,i) =
real(Q_tld(j,i),sp)
232 am_perp_conv(j,i) =
real(am_perp(j,i),sp)
233 qx_conv(j,i) =
real(qx(j,i),sp)
234 qy_conv(j,i) =
real(qy(j,i),sp)
235 dzs_dtau_conv(j,i) =
real(dzs_dtau(j,i),sp)
236 dzm_dtau_conv(j,i) =
real(dzm_dtau(j,i),sp)
237 dzb_dtau_conv(j,i) =
real(dzb_dtau(j,i),sp)
238 dzl_dtau_conv(j,i) =
real(dzl_dtau(j,i),sp)
239 dh_c_dtau_conv(j,i) =
real(dH_c_dtau(j,i),sp)
240 dh_t_dtau_conv(j,i) =
real(dH_t_dtau(j,i),sp)
241 dh_dtau_conv(j,i) =
real(dH_c_dtau(j,i)+dH_t_dtau(j,i),sp)
242 vx_b_g_conv(j,i) =
real(vx_b_g(j,i),sp)
243 vy_b_g_conv(j,i) =
real(vy_b_g(j,i),sp)
244 vz_b_conv(j,i) =
real(vz_b(j,i),sp)
245 vx_s_g_conv(j,i) =
real(vx_s_g(j,i),sp)
246 vy_s_g_conv(j,i) =
real(vy_s_g(j,i),sp)
247 vz_s_conv(j,i) =
real(vz_s(j,i),sp)
248 temp_b_conv(j,i) =
real(temp_b(j,i),sp)
249 temph_b_conv(j,i) =
real(temph_b(j,i),sp)
250 p_b_w_conv(j,i) =
real(p_b_w(j,i),sp)
251 h_w_conv(j,i) =
real(H_w(j,i),sp)
252 q_gl_g_conv(j,i) =
real(q_gl_g(j,i),sp)
255 temp_r_conv(kr,j,i) =
real(temp_r(kr,j,i),sp)
259 vx_t_conv(kt,j,i) =
real(vx_t(kt,j,i),sp)
260 vy_t_conv(kt,j,i) =
real(vy_t(kt,j,i),sp)
261 vz_t_conv(kt,j,i) =
real(vz_t(kt,j,i),sp)
262 omega_t_conv(kt,j,i) =
real(omega_t(kt,j,i),sp)
263 age_t_conv(kt,j,i) =
real(age_t(kt,j,i),sp)
267 vx_c_conv(kc,j,i) =
real(vx_c(kc,j,i),sp)
268 vy_c_conv(kc,j,i) =
real(vy_c(kc,j,i),sp)
269 vz_c_conv(kc,j,i) =
real(vz_c(kc,j,i),sp)
270 temp_c_conv(kc,j,i) =
real(temp_c(kc,j,i),sp)
271 age_c_conv(kc,j,i) =
real(age_c(kc,j,i),sp)
280 if (forcing_flag == 1)
then
281 write(11) delta_ts_conv
282 else if (forcing_flag == 2)
then
283 write(11) glac_index_conv
284 else if (forcing_flag == 3)
then
285 glac_index_conv = 1.11e+11
286 write(11) glac_index_conv
291 write(11) sigma_level_c_conv
292 write(11) sigma_level_t_conv
293 write(11) sigma_level_r_conv
294 write(11) lambda_conv
296 write(11) temp_s_conv
297 write(11) as_perp_conv
308 if (flag_3d_output)
then
315 write(11) temp_c_conv
316 write(11) omega_t_conv
317 write(11) temp_r_conv
321 write(11) am_perp_conv
324 if (flag_3d_output)
then
328 write(11) dzs_dtau_conv
329 write(11) dzm_dtau_conv
330 write(11) dzb_dtau_conv
331 write(11) dzl_dtau_conv
332 write(11) dh_c_dtau_conv
333 write(11) dh_t_dtau_conv
334 write(11) dh_dtau_conv
335 write(11) vx_b_g_conv
336 write(11) vy_b_g_conv
338 write(11) vx_s_g_conv
339 write(11) vy_s_g_conv
341 write(11) temp_b_conv
342 write(11) temph_b_conv
345 write(11) q_gl_g_conv
347 write(11) a_grounded_conv
348 write(11) a_floating_conv
350 close(11, status=
'keep')
356 if (flag_3d_output)
then