SICOPOLIS V3.0
 All Classes Files Functions Variables Macros
sico_init.F90
Go to the documentation of this file.
1 !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 !
3 ! Subroutine : s i c o _ i n i t
4 !
5 !> @file
6 !!
7 !! Initialisations for SICOPOLIS.
8 !!
9 !! @section Copyright
10 !!
11 !! Copyright 2009-2013 Ralf Greve
12 !!
13 !! @section License
14 !!
15 !! This file is part of SICOPOLIS.
16 !!
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.
21 !!
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.
26 !!
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/>.
29 !<
30 !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
31 
32 !-------------------------------------------------------------------------------
33 !> Initialisations for SICOPOLIS.
34 !<------------------------------------------------------------------------------
35 subroutine sico_init(delta_ts, glac_index, &
36  sum_accum, mean_accum, mean_accum_inv, &
37  dtime, dtime_temp, dtime_wss, dtime_out, dtime_ser, &
38  time, time_init, time_end, time_output, &
39  dxi, deta, dzeta_c, dzeta_t, dzeta_r, &
40  z_sl, dzsl_dtau, z_mar, &
41  ii, jj, nn, &
42  ndat2d, ndat3d, n_output, &
43  runname)
44 
45 use sico_types
47 
48 implicit none
49 integer(i4b) :: i, j, kc, kt, kr, m, n, ir, jr
50 integer(i4b) :: ios, ios1, ios2, ios3, ios4
51 integer(i4b) :: ndat2d, ndat3d
52 integer(i4b) :: n_output
53 integer(i4b) :: ierr
54 integer(i4b) :: ii((imax+1)*(jmax+1)), jj((imax+1)*(jmax+1)), nn(0:jmax,0:imax)
55 real(dp) :: delta_ts, glac_index
56 real(dp) :: sum_accum, mean_accum, mean_accum_inv
57 real(dp) :: dtime0, dtime_temp0, dtime_wss0, dtime_out0, dtime_ser0
58 real(dp) :: dtime, dtime_temp, dtime_wss, dtime_out, dtime_ser
59 real(dp) :: time_init0, time_end0, time_output0(100)
60 real(dp) :: time, time_init, time_end, time_output(100)
61 real(dp) :: dxi, deta, dzeta_c, dzeta_t, dzeta_r
62 real(dp) :: z_sl, dzsl_dtau, z_mar
63 real(dp) :: d_dummy
64 character (len=100) :: runname, anfdatname
65 character (len=256) :: shell_command
66 character :: ch_dummy
67 logical :: flag_3d_output
68 
69 !-------- Initialisation of the Library of Iterative Solvers Lis,
70 ! if required --------
71 
72 #if (CALCZS==4 || MARGIN==3)
73 
74 #include "lisf.h"
75 call lis_initialize(ierr)
76 
77 #endif
78 
79 !-------- Read physical parameters --------
80 
81 call phys_para
82 
83 temp_min = temp_min
84 s_t = s_t *1.0e-09_dp ! K/km3 -> K/m3
85 x_hat = x_hat *1.0e+03_dp ! km -> m
86 y_hat = y_hat *1.0e+03_dp ! km -> m
87 rad = rad *1.0e+03_dp ! km -> m
88 b_min = b_min /year_sec ! m/a -> m/s
89 b_max = b_max /year_sec ! m/a -> m/s
90 
91 !-------- Compatibility check of the SICOPOLIS version with the header file
92 
93 if ( trim(version) /= trim(sico_version) ) &
94  stop ' sico_init: SICOPOLIS version not compatible with header file!'
95 
96 !-------- Compatibility check of the horizontal resolution with the
97 ! number of grid points --------
98 
99 #if GRID==0
100 
101 if (abs(dx-50.0_dp) < eps) then
102 
103  if ((imax /= 80).or.(jmax /= 80)) then
104  stop ' sico_init: IMAX and/or JMAX wrong!'
105  end if
106 
107 else if (abs(dx-25.0_dp) < eps) then
108 
109  if ((imax /= 160).or.(jmax /= 160)) then
110  stop ' sico_init: IMAX and/or JMAX wrong!'
111  end if
112 
113 else
114  stop ' sico_init: DX wrong!'
115 end if
116 
117 #elif GRID==1
118 
119 stop ' sico_init: GRID==1 not allowed for this application!'
120 
121 #elif GRID==2
122 
123 stop ' sico_init: GRID==2 not allowed for this application!'
124 
125 #endif
126 
127 !-------- Compatibility check of discretization schemes for the horizontal and
128 ! vertical advection terms in the temperature and age equations --------
129 
130 #if ADV_HOR==1
131 stop ' sico_init: Option ADV_HOR==1 (central differences) not defined!'
132 #endif
133 
134 #if ((ADV_HOR == 3) && (ADV_VERT != 3))
135 stop ' sico_init: Options ADV_HOR==3 and ADV_VERT==3 must be used together!'
136 #endif
137 
138 #if ((ADV_HOR != 3) && (ADV_VERT == 3))
139 stop ' sico_init: Options ADV_HOR==3 and ADV_VERT==3 must be used together!'
140 #endif
141 
142 !-------- Setting of forcing flag --------
143 
144 forcing_flag = 1 ! forcing by delta_ts
145 
146 !-------- Initialization of numerical time steps --------
147 
148 dtime0 = dtime0
149 dtime_temp0 = dtime_temp0
150 
151 !-------- Further initializations --------
152 
153 dzeta_c = 1.0_dp/real(kcmax,dp)
154 dzeta_t = 1.0_dp/real(ktmax,dp)
155 dzeta_r = 1.0_dp/real(krmax,dp)
156 
157 ndat2d = 1
158 ndat3d = 1
159 
160 !-------- Construction of a vector (with index n) from a 2-d array
161 ! (with indices i, j) by diagonal numbering --------
162 
163 n=1
164 
165 do m=0, imax+jmax
166  do i=m, 0, -1
167  j = m-i
168  if ((i.le.imax).and.(j.le.jmax)) then
169  ii(n) = i
170  jj(n) = j
171  nn(j,i) = n
172  n=n+1
173  end if
174  end do
175 end do
176 
177 !-------- Specification of current simulation --------
178 
179 runname = runname
180 anfdatname = anfdatname
181 
182 #if defined(YEAR_ZERO)
183 year_zero = year_zero
184 #else
185 year_zero = 2000.0_dp ! default value 2000 CE
186 #endif
187 
188 time_init0 = time_init0
189 time_end0 = time_end0
190 dtime_ser0 = dtime_ser0
191 
192 #if ( OUTPUT==1 || OUTPUT==3 )
193 dtime_out0 = dtime_out0
194 #endif
195 
196 #if ( OUTPUT==2 || OUTPUT==3 )
197 n_output = n_output
198 time_output0( 1) = time_out0_01
199 time_output0( 2) = time_out0_02
200 time_output0( 3) = time_out0_03
201 time_output0( 4) = time_out0_04
202 time_output0( 5) = time_out0_05
203 time_output0( 6) = time_out0_06
204 time_output0( 7) = time_out0_07
205 time_output0( 8) = time_out0_08
206 time_output0( 9) = time_out0_09
207 time_output0(10) = time_out0_10
208 time_output0(11) = time_out0_11
209 time_output0(12) = time_out0_12
210 time_output0(13) = time_out0_13
211 time_output0(14) = time_out0_14
212 time_output0(15) = time_out0_15
213 time_output0(16) = time_out0_16
214 time_output0(17) = time_out0_17
215 time_output0(18) = time_out0_18
216 time_output0(19) = time_out0_19
217 time_output0(20) = time_out0_20
218 #endif
219 
220 !-------- Write log file --------
221 
222 shell_command = 'if [ ! -d'
223 shell_command = trim(shell_command)//' '//outpath
224 shell_command = trim(shell_command)//' '//'] ; then mkdir'
225 shell_command = trim(shell_command)//' '//outpath
226 shell_command = trim(shell_command)//' '//'; fi'
227 call system(trim(shell_command))
228  ! Check whether directory OUTPATH exists. If not, it is created.
229 
230 open(10, iostat=ios, &
231  file=outpath//'/'//trim(runname)//'.log', &
232  status='new')
233 if (ios /= 0) stop ' sico_init: Error when opening the log file!'
234 
235 write(10,1000) 'Computational domain:'
236 #if defined(ANT)
237 write(10,1000) 'Antarctica'
238 #elif defined(GRL)
239 write(10,1000) 'Greenland'
240 #elif defined(SCAND)
241 write(10,1000) 'Scandinavia and Eurasia'
242 #elif defined(NHEM)
243 write(10,1000) 'Northern hemisphere'
244 #elif defined(EMTP2SGE)
245 write(10,1000) 'EISMINT Phase 2 Simplified Geometry Experiment'
246 #elif defined(HEINO)
247 write(10,1000) 'ISMIP HEINO'
248 #elif defined(NMARS)
249 write(10,1000) 'North polar cap of Mars'
250 #elif defined(SMARS)
251 write(10,1000) 'South polar cap of Mars'
252 #else
253 stop ' sico_init: Subroutine sico_init: No valid domain specified!'
254 #endif
255 write(10,1000) ' '
256 
257 write(10,1001) 'imax =', imax
258 write(10,1001) 'jmax =', jmax
259 write(10,1001) 'kcmax =', kcmax
260 write(10,1001) 'ktmax =', ktmax
261 write(10,1001) 'krmax =', krmax
262 write(10,1000) ' '
263 
264 write(10,1002) 'a =', deform
265 write(10,1000) ' '
266 
267 #if (GRID==0 || GRID==1)
268 write(10,1002) 'x0 =', x0
269 write(10,1002) 'y0 =', y0
270 write(10,1002) 'dx =', dx
271 #elif GRID==2
272 write(10,1002) 'dlambda =', dlambda
273 write(10,1002) 'dphi =', dphi
274 #endif
275 write(10,1000) ' '
276 
277 write(10,1002) 'year_zero =', year_zero
278 write(10,1002) 'time_init =', time_init0
279 write(10,1002) 'time_end =', time_end0
280 write(10,1002) 'dtime =', dtime0
281 write(10,1002) 'dtime_temp =', dtime_temp0
282 #if ( OUTPUT==1 || OUTPUT==3 )
283 write(10,1002) 'dtime_out =', dtime_out0
284 #endif
285 write(10,1002) 'dtime_ser =', dtime_ser0
286 write(10,1000) ' '
287 
288 write(10,1000) 'mask_present file = '//mask_present_file
289 write(10,1000) ' '
290 
291 write(10,1000) 'Physical-parameter file = '//phys_para_file
292 write(10,1000) ' '
293 
294 #if (CALCZS==3 || CALCZS==4)
295 write(10,1002) 'ovi_weight =', ovi_weight
296 #if CALCZS==3
297 write(10,1002) 'omega_sor =', omega_sor
298 #endif
299 write(10,1000) ' '
300 #endif
301 
302 write(10,1002) 'temp_min =', temp_min
303 write(10,1002) 's_t =', s_t
304 write(10,1002) 'x_hat =', x_hat
305 write(10,1002) 'y_hat =', y_hat
306 write(10,1002) 'rad =', rad
307 write(10,1002) 'b_min =', b_min
308 write(10,1002) 'b_max =', b_max
309 write(10,1000) ' '
310 
311 #if TSURFACE==1
312 write(10,1002) 'delta_ts0 =', delta_ts0
313 #elif TSURFACE==3
314 write(10,1002) 'sine_amplit =', sine_amplit
315 write(10,1002) 'sine_period =', sine_period
316 #elif TSURFACE==4
317 write(10,1000) 'GRIP file = '//grip_temp_file
318 write(10,1002) 'grip_temp_fact =', grip_temp_fact
319 #endif
320 
321 #if SEA_LEVEL==1
322 write(10,1002) 'z_sl0 =', z_sl0
323 #elif SEA_LEVEL==3
324 write(10,1000) 'sea-level file = '//sea_level_file
325 #endif
326 write(10,1000) ' '
327 
328 #if MARGIN==2
329 #if ( MARINE_ICE_CALVING==2 || MARINE_ICE_CALVING==3 )
330 write(10,1002) 'z_mar =', z_mar
331 write(10,1000) ' '
332 #elif ( MARINE_ICE_CALVING==4 || MARINE_ICE_CALVING==5 \
333  || marine_ice_calving==6 || marine_ice_calving==7 )
334 write(10,1002) 'fact_z_mar =', fact_z_mar
335 write(10,1000) ' '
336 #elif ( ( MARINE_ICE_FORMATION==2 ) && ( MARINE_ICE_CALVING==9 ) )
337 write(10,1002) 'calv_uw_coeff =', calv_uw_coeff
338 write(10,1002) 'r1_calv_uw =', r1_calv_uw
339 write(10,1002) 'r2_calv_uw =', r2_calv_uw
340 write(10,1000) ' '
341 #endif
342 #elif MARGIN==3
343 #if ICE_SHELF_CALVING==2
344 write(10,1002) 'H_calv =', h_calv
345 write(10,1000) ' '
346 #endif
347 #endif
348 
349 write(10,1000) 'Sediment-mask file = '//mask_sedi_file
350 write(10,1000) ' '
351 
352 write(10,1002) 'c_slide =', c_slide
353 write(10,1002) 'gamma_slide =', gamma_slide
354 write(10,1001) 'p_weert =', p_weert
355 write(10,1001) 'q_weert =', q_weert
356 #if SLIDE_LAW==2
357 write(10,1002) 'red_pres_limit_fact =', red_pres_limit_fact
358 #endif
359 write(10,1000) ' '
360 
361 write(10,1002) 'c_slide_sedi =', c_slide_sedi
362 write(10,1002) 'gamma_slide_sedi =', gamma_slide_sedi
363 write(10,1001) 'p_weert_sedi =', p_weert_sedi
364 write(10,1001) 'q_weert_sedi =', q_weert_sedi
365 write(10,1000) ' '
366 
367 #if Q_GEO_MOD==1
368 write(10,1002) 'q_geo =', q_geo
369 write(10,1000) ' '
370 #endif
371 
372 #if REBOUND==1
373 write(10,1002) 'frac_llra =', frac_llra
374 write(10,1000) ' '
375 #endif
376 
377 #if FLOW_LAW==2
378 write(10,1002) 'gr_size =', gr_size
379 write(10,1000) ' '
380 #endif
381 #if FIN_VISC==2
382 write(10,1002) 'sigma_res =', sigma_res
383 write(10,1000) ' '
384 #endif
385 
386 write(10,1001) 'ENHMOD =', enhmod
387 write(10,1002) 'enh_fact =', enh_fact
388 #if ( ENHMOD==2 || ENHMOD==3 )
389 write(10,1002) 'enh_intg =', enh_intg
390 #endif
391 #if ENHMOD==2
392 write(10,1002) 'age_trans =', age_trans_0
393 #endif
394 #if ENHMOD==3
395 write(10,1002) 'date_trans1 =', date_trans1_0
396 write(10,1002) 'date_trans2 =', date_trans2_0
397 write(10,1002) 'date_trans3 =', date_trans3_0
398 #endif
399 #if MARGIN==3
400 write(10,1002) 'enh_shelf =', enh_shelf
401 #endif
402 write(10,1000) ' '
403 
404 write(10,1002) 'numdiff_H_t =', numdiff_h_t
405 write(10,1002) 'tau_cts =', tau_cts
406 write(10,1002) 'H_min =', h_min
407 write(10,1002) 'vh_max =', vh_max
408 write(10,1002) 'hd_min =', hd_min
409 write(10,1002) 'hd_max =', hd_max
410 #if defined(QBM_MIN)
411 write(10,1002) 'qbm_min =', qbm_min
412 #elif defined(QB_MIN) /* obsolete */
413 write(10,1002) 'qb_min =', qb_min
414 #endif
415 #if defined(QBM_MAX)
416 write(10,1002) 'qbm_max =', qbm_max
417 #elif defined(QB_MAX) /* obsolete */
418 write(10,1002) 'qb_max =', qb_max
419 #endif
420 write(10,1002) 'age_min =', age_min
421 write(10,1002) 'age_max =', age_max
422 write(10,1002) 'mean_accum =', mean_accum
423 #if ADV_VERT==1
424 write(10,1002) 'age_diff =', agediff
425 write(10,1002) 'm_age =', m_age
426 #endif
427 write(10,1000) ' '
428 
429 write(10,1001) 'GRID =', grid
430 write(10,1001) 'CALCMOD =', calcmod
431 write(10,1001) 'FLOW_LAW =', flow_law
432 write(10,1001) 'FIN_VISC =', fin_visc
433 write(10,1001) 'MARGIN =', margin
434 #if MARGIN==2
435 write(10,1001) 'MARINE_ICE_FORMATION =', marine_ice_formation
436 write(10,1001) 'MARINE_ICE_CALVING =', marine_ice_calving
437 #elif MARGIN==3
438 write(10,1001) 'ICE_SHELF_CALVING =', ice_shelf_calving
439 #endif
440 write(10,1001) 'ANF_DAT =', anf_dat
441 write(10,1001) 'REBOUND =', rebound
442 write(10,1001) 'Q_LITHO =', q_litho
443 write(10,1001) 'ZS_EVOL =', zs_evol
444 write(10,1001) 'CALCZS =', calczs
445 write(10,1001) 'ADV_HOR =', adv_hor
446 write(10,1001) 'ADV_VERT =', adv_vert
447 write(10,1001) 'TOPOGRAD =', topograd
448 write(10,1001) 'TSURFACE =', tsurface
449 write(10,1001) 'SEA_LEVEL =', sea_level
450 write(10,1001) 'SLIDE_LAW =', slide_law
451 write(10,1001) 'Q_GEO_MOD =', q_geo_mod
452 write(10,1000) ' '
453 
454 #if defined(OUT_TIMES)
455 write(10,1001) 'OUT_TIMES =', out_times
456 #endif
457 write(10,1001) 'OUTPUT =', output
458 write(10,1001) 'OUTSER =', outser
459 #if defined(OUTSER_V_A)
460 write(10,1001) 'OUTSER_V_A =', outser_v_a
461 #endif
462 #if ( OUTPUT==1 || OUTPUT==2 )
463 write(10,1001) 'ERGDAT =', ergdat
464 #endif
465 write(10,1001) 'NETCDF =', netcdf
466 write(10,1000) ' '
467 #if ( OUTPUT==2 || OUTPUT==3 )
468 write(10,1001) 'n_output =', n_output
469 do n=1, n_output
470  write(10,1002) 'time_output =', time_output0(n)
471 end do
472 write(10,1000) ' '
473 #endif
474 
475 write(10,1000) 'Program version and date: '//version//' / '//date
476 
477  1000 format(a)
478  1001 format(a,i4)
479  1002 format(a,es12.4)
480 
481 close(10, status='keep')
482 
483 !-------- Conversion of time quantities --------
484 
485 year_zero = year_zero*year_sec ! a --> s
486 time_init = time_init0*year_sec ! a --> s
487 time_end = time_end0*year_sec ! a --> s
488 dtime = dtime0*year_sec ! a --> s
489 dtime_temp = dtime_temp0*year_sec ! a --> s
490 dtime_ser = dtime_ser0*year_sec ! a --> s
491 #if ( OUTPUT==1 || OUTPUT==3 )
492 dtime_out = dtime_out0*year_sec ! a --> s
493 #endif
494 #if ( OUTPUT==2 || OUTPUT==3 )
495 do n=1, n_output
496  time_output(n) = time_output0(n)*year_sec ! a --> s
497 end do
498 #endif
499 
500 if (abs(dtime_temp/dtime-nint(dtime_temp/dtime)) > eps) &
501  stop ' sico_init: dtime_temp must be a multiple of dtime!'
502 
503 !-------- Mean accumulation --------
504 
505 mean_accum = mean_accum*(1.0e-03_dp/year_sec)*(rho_w/rho)
506 ! ! mm/a water equiv. --> m/s ice equiv.
507 
508 mean_accum_inv = 1.0_dp/mean_accum
509 
510 !-------- Read present topography mask --------
511 
512 open(24, iostat=ios, &
513  file=inpath//'/heino/'//mask_present_file, &
514  recl=8192, status='old')
515 
516 if (ios /= 0) stop ' sico_init: Error when opening the mask file!'
517 
518 do n=1, 6; read(24,'(a)') ch_dummy; end do
519 
520 do j=jmax, 0, -1
521  read(24,2300) (maske_help(j,i), i=0,imax)
522 end do
523 
524 close(24, status='keep')
525 
526 !-------- Read rock/sediment mask --------
527 
528 open(24, iostat=ios, &
529  file=inpath//'/heino/'//mask_sedi_file, &
530  recl=8192, status='old')
531 
532 if (ios /= 0) stop ' sico_init: Error when opening the rock/sediment mask file!'
533 
534 do n=1, 6; read(24,'(a)') ch_dummy; end do
535 
536 do j=jmax, 0, -1
537  read(24,2300) (maske_sedi(j,i), i=0,imax)
538 end do
539 
540 close(24, status='keep')
541 
542 2300 format(imax(i1),i1)
543 
544 !-------- Read data for delta_ts --------
545 
546 #if TSURFACE==4
547 
548 open(21, iostat=ios, &
549  file=inpath//'/general/'//grip_temp_file, &
550  status='old')
551 if (ios /= 0) stop ' sico_init: Error when opening the data file for delta_ts!'
552 
553 read(21,*) ch_dummy, grip_time_min, grip_time_stp, grip_time_max
554 
555 if (ch_dummy /= '#') then
556  write(6,*) ' sico_init: grip_time_min, grip_time_stp, grip_time_max'
557  write(6,*) ' not defined in data file for delta_ts!'
558  stop
559 end if
560 
561 ndata_grip = (grip_time_max-grip_time_min)/grip_time_stp
562 
563 allocate(griptemp(0:ndata_grip))
564 
565 do n=0, ndata_grip
566  read(21,*) d_dummy, griptemp(n)
567 end do
568 
569 close(21, status='keep')
570 
571 #endif
572 
573 !-------- Read data for z_sl --------
574 
575 #if SEA_LEVEL==3
576 
577 open(21, iostat=ios, &
578  file=inpath//'/general/'//sea_level_file, &
579  status='old')
580 if (ios /= 0) stop ' sico_init: Error when opening the data file for z_sl!'
581 
582 read(21,*) ch_dummy, specmap_time_min, specmap_time_stp, specmap_time_max
583 
584 if (ch_dummy /= '#') then
585  write(6,*) ' sico_init: specmap_time_min, specmap_time_stp, specmap_time_max'
586  write(6,*) ' not defined in data file for z_sl!'
587  stop
588 end if
589 
590 ndata_specmap = (specmap_time_max-specmap_time_min)/specmap_time_stp
591 
592 allocate(specmap_zsl(0:ndata_specmap))
593 
594 do n=0, ndata_specmap
595  read(21,*) d_dummy, specmap_zsl(n)
596 end do
597 
598 close(21, status='keep')
599 
600 #endif
601 
602 !-------- Determination of the geothermal heat flux --------
603 
604 #if Q_GEO_MOD==1
605 
606 ! ------ Constant value
607 
608 do i=0, imax
609 do j=0, jmax
610  q_geo(j,i) = q_geo *1.0e-03_dp ! mW/m2 -> W/m2
611 end do
612 end do
613 
614 #elif Q_GEO_MOD==2
615 
616 stop ' sico_init: Option Q_GEO_MOD==2 not available for this application!'
617 
618 #endif
619 
620 !-------- Definition of initial values --------
621 
622 ! ------ Initial topography with a thin ice layer everywhere
623 
624 #if ANF_DAT==1
625 
626 call topography1(dxi, deta)
627 
628 z_sl = -1.11e+11_dp ! dummy value for initial call of subroutine boundary
629 
630 call boundary(time_init, dtime, dxi, deta, &
631  delta_ts, glac_index, z_sl, dzsl_dtau, z_mar)
632 
633 do i=0, imax
634 do j=0, jmax
635 
636  q_bm(j,i) = 0.0_dp
637  q_tld(j,i) = 0.0_dp
638  q_b_tot(j,i) = 0.0_dp
639 
640  p_b_w(j,i) = 0.0_dp
641  h_w(j,i) = 0.0_dp
642 
643  do kc=0, kcmax
644  temp_c(kc,j,i) = temp_s(j,i)
645  age_c(kc,j,i) = 15000.0_dp*year_sec
646  end do
647 
648  do kt=0, ktmax
649  omega_t(kt,j,i) = 0.0_dp
650  age_t(kt,j,i) = 15000.0_dp*year_sec
651  end do
652 
653  do kr=0, krmax
654  temp_r(kr,j,i) = temp_s(j,i)+q_geo(j,i)*h_r/kappa_r &
655  *(1.0_dp-real(kr,dp)/real(krmax,dp))
656 ! (linear temperature distribution according to the
657 ! geothermal heat flux)
658  end do
659 
660 end do
661 end do
662 
663 call calc_enhance(time_init)
664 
665 ! ------ Ice-free, relaxed bedrock
666 
667 #elif ANF_DAT==2
668 
669 call topography2(dxi, deta)
670 
671 z_sl = -1.11e+11_dp ! dummy value for initial call of subroutine boundary
672 
673 call boundary(time_init, dtime, dxi, deta, &
674  delta_ts, glac_index, z_sl, dzsl_dtau, z_mar)
675 
676 do i=0, imax
677 do j=0, jmax
678 
679  q_bm(j,i) = 0.0_dp
680  q_tld(j,i) = 0.0_dp
681  q_b_tot(j,i) = 0.0_dp
682 
683  p_b_w(j,i) = 0.0_dp
684  h_w(j,i) = 0.0_dp
685 
686  do kc=0, kcmax
687  temp_c(kc,j,i) = temp_s(j,i)
688  age_c(kc,j,i) = 15000.0_dp*year_sec
689  end do
690 
691  do kt=0, ktmax
692  omega_t(kt,j,i) = 0.0_dp
693  age_t(kt,j,i) = 15000.0_dp*year_sec
694  end do
695 
696  do kr=0, krmax
697  temp_r(kr,j,i) = temp_s(j,i)+q_geo(j,i)*h_r/kappa_r &
698  *(1.0_dp-real(kr,dp)/real(krmax,dp))
699 ! (linear temperature distribution according to the
700 ! geothermal heat flux)
701  end do
702 
703 end do
704 end do
705 
706 call calc_enhance(time_init)
707 
708 ! ------ Read initial state from output of previous simulation
709 
710 #elif ANF_DAT==3
711 
712 #if NETCDF==1
713 call topography3(dxi, deta, z_sl, anfdatname)
714 #elif NETCDF==2
715 call topography3_nc(dxi, deta, z_sl, anfdatname)
716 #else
717 stop ' sico_init: Parameter NETCDF must be either 1 or 2!'
718 #endif
719 
720 call boundary(time_init, dtime, dxi, deta, &
721  delta_ts, glac_index, z_sl, dzsl_dtau, z_mar)
722 
723 q_b_tot = q_bm + q_tld
724 
725 call calc_enhance(time_init)
726 
727 #endif
728 
729 !-------- Distance between grid points with delta_i=ir, delta_j=jr --------
730 
731 #if (GRID==0 || GRID==1)
732 
733 do ir=-imax, imax
734 do jr=-jmax, jmax
735  dist_dxdy(jr,ir) = sqrt( (real(ir,dp)*dxi)**2 + (real(jr,dp)*deta)**2 )
736  ! distortion due to stereographic projection not accounted for
737 end do
738 end do
739 
740 #endif
741 
742 !-------- General abbreviations --------
743 
744 ea = exp(deform)
745 
746 do kc=0, kcmax
747  zeta_c(kc) = kc*dzeta_c
748  eaz_c(kc) = exp(deform*zeta_c(kc))
749  eaz_c_quotient(kc) = (eaz_c(kc)-1.0_dp)/(ea-1.0_dp)
750 end do
751 
752 do kt=0, ktmax
753  zeta_t(kt) = kt*dzeta_t
754 end do
755 
756 !-------- Initial velocities --------
757 
758 call calc_temp_melt
759 
760 call calc_vxy_b_sia(time, z_sl)
761 call calc_vxy_sia(dzeta_c, dzeta_t)
762 
763 #if MARGIN==3
764 call calc_vxy_ssa(z_sl, dxi, deta, dzeta_c, ii, jj, nn)
765 #endif
766 
767 call calc_vz_sia(dxi, deta, dzeta_c, dzeta_t)
768 
769 #if MARGIN==3
770 call calc_vz_ssa(z_sl, dxi, deta, dzeta_c)
771 #endif
772 
773 !-------- Initialize time-series files --------
774 
775 ! ------ Time-series file for the ice sheet on the whole
776 
777 open(12, iostat=ios, &
778  file=outpath//'/'//trim(runname)//'.ser', &
779  status='new')
780 if (ios /= 0) stop ' sico_init: Error when opening the ser file!'
781 
782 write(12,1102)
783 write(12,1103)
784 
785 #if ( !defined(OUTSER_V_A) || OUTSER_V_A==1 )
786 
787  1102 format(' t(a) D_Ts(deg C) z_sl(m)',/, &
788  ' H_max(m) zs_max(m) V_g(m^3)', &
789  ' V_t(m^3) V_fw(m^3/a) V_sle(m)',/, &
790  ' A_g(m^2) A_t(m^2) V_bm(m^3/a)', &
791  ' V_tld(m^3/a) H_t_max(m) vs_max(m/a)')
792  1103 format('----------------------------------------------------', &
793  '---------------------------------------')
794 
795 #elif OUTSER_V_A==2
796 
797  1102 format(' t(a) D_Ts(deg C) z_sl(m)',/, &
798  ' V(m^3) V_g(m^3) V_f(m^3)', &
799  ' A(m^2) A_g(m^2) A_f(m^2)',/, &
800  ' H_max(m) zs_max(m)', &
801  ' V_t(m^3) V_fw(m^3/a) V_sle(m)',/, &
802  ' A_t(m^2) V_bm(m^3/a)', &
803  ' V_tld(m^3/a) H_t_max(m) vs_max(m/a)')
804  1103 format('----------------------------------------------------', &
805  '---------------------------------------')
806 
807 #else
808  stop ' sico_init: OUTSER_V_A must be either 1 or 2!'
809 #endif
810 
811 ! ------ Time-series file for the sediment area ("Hudson Bay, Hudson Strait")
812 
813 open(15, iostat=ios, &
814  file=outpath//'/'//trim(runname)//'.sed', &
815  status='new')
816 if (ios /= 0) stop ' sico_init: Error when opening the sed file!'
817 
818 write(15,1108)
819 write(15,1109)
820 
821 1108 format(' t(a) D_Ts(deg C) z_sl(m)',/, &
822  ' H_ave(m) Tbh_ave(C) Atb(m^2)')
823 1109 format('----------------------------------------------------')
824 
825 ! ------ Time-series file for the ice-thickness field
826 
827 #if OUTSER==2
828 
829 open(13, iostat=ios, &
830  file=outpath//'/'//trim(runname)//'.thk', &
831  status='new')
832 if (ios /= 0) stop ' sico_init: Error when opening the thk file!'
833 
834 write(13,1104)
835 write(13,1105)
836 
837 1104 format(' t(a) D_Ts(deg C) z_sl(m)',/, &
838  ' H(m): JMAX+1 records [j = JMAX (-1) 0] with',/, &
839  ' IMAX+1 values [i = 0 (1) IMAX] in each record')
840 1105 format('----------------------------------------------------')
841 
842 #endif
843 
844 ! ------ Time-series file for selected positions ("deep boreholes")
845 
846 #if OUTSER==3
847 
848 n_core = 7 ! Points P1 - P7
849 
850 allocate(lambda_core(n_core), phi_core(n_core), &
851  x_core(n_core), y_core(n_core))
852 
853 lambda_core(1) = 0.0_dp ! dummy
854 phi_core(1) = 0.0_dp ! dummy
855 x_core(1) = 3900.0_dp *1.0e+03_dp ! Point P1,
856 y_core(1) = 2000.0_dp *1.0e+03_dp ! conversion km -> m
857 
858 lambda_core(2) = 0.0_dp ! dummy
859 phi_core(2) = 0.0_dp ! dummy
860 x_core(2) = 3800.0_dp *1.0e+03_dp ! Point P2,
861 y_core(2) = 2000.0_dp *1.0e+03_dp ! conversion km -> m
862 
863 lambda_core(3) = 0.0_dp ! dummy
864 phi_core(3) = 0.0_dp ! dummy
865 x_core(3) = 3700.0_dp *1.0e+03_dp ! Point P3,
866 y_core(3) = 2000.0_dp *1.0e+03_dp ! conversion km -> m
867 
868 lambda_core(4) = 0.0_dp ! dummy
869 phi_core(4) = 0.0_dp ! dummy
870 x_core(4) = 3500.0_dp *1.0e+03_dp ! Point P4,
871 y_core(4) = 2000.0_dp *1.0e+03_dp ! conversion km -> m
872 
873 lambda_core(5) = 0.0_dp ! dummy
874 phi_core(5) = 0.0_dp ! dummy
875 x_core(5) = 3200.0_dp *1.0e+03_dp ! Point P5,
876 y_core(5) = 2000.0_dp *1.0e+03_dp ! conversion km -> m
877 
878 lambda_core(6) = 0.0_dp ! dummy
879 phi_core(6) = 0.0_dp ! dummy
880 x_core(6) = 2900.0_dp *1.0e+03_dp ! Point P6,
881 y_core(6) = 2000.0_dp *1.0e+03_dp ! conversion km -> m
882 
883 lambda_core(7) = 0.0_dp ! dummy
884 phi_core(7) = 0.0_dp ! dummy
885 x_core(7) = 2600.0_dp *1.0e+03_dp ! Point P7,
886 y_core(7) = 2000.0_dp *1.0e+03_dp ! conversion km -> m
887 
888 open(14, iostat=ios, &
889  file=outpath//'/'//trim(runname)//'.core', &
890  status='new')
891 if (ios /= 0) stop ' sico_init: Error when opening the core file!'
892 
893 if (forcing_flag == 1) then
894 
895  write(14,1106)
896  write(14,1107)
897 
898  1106 format(' t(a) D_Ts(C) z_sl(m)',/, &
899  ' H_P1(m) H_P2(m) H_P3(m) H_P4(m)', &
900  ' H_P5(m) H_P6(m) H_P7(m)',/, &
901  ' v_P1(m/a) v_P2(m/a) v_P3(m/a) v_P4(m/a)', &
902  ' v_P5(m/a) v_P6(m/a) v_P7(m/a)',/, &
903  ' T_P1(C) T_P2(C) T_P3(C) T_P4(C)', &
904  ' T_P5(C) T_P6(C) T_P7(C)',/, &
905  ' Rb_P1(W/m2) Rb_P2(W/m2) Rb_P3(W/m2) Rb_P4(W/m2)', &
906  ' Rb_P5(W/m2) Rb_P6(W/m2) Rb_P7(W/m2)')
907  1107 format('-----------------------------------------------------------------', &
908  '---------------------------------------')
909 
910 end if
911 
912 #endif
913 
914 !-------- Output of the initial state --------
915 
916 #if OUTPUT==1
917 
918 #if ERGDAT==0
919  flag_3d_output = .false.
920 #elif ERGDAT==1
921  flag_3d_output = .true.
922 #else
923  stop ' sico_init: ERGDAT must be either 0 or 1!'
924 #endif
925 
926 #if NETCDF==1
927  call output1(runname, time_init, delta_ts, glac_index, z_sl, &
928  flag_3d_output, ndat2d, ndat3d)
929 #elif NETCDF==2
930  call output_nc(runname, time_init, delta_ts, glac_index, z_sl, &
931  flag_3d_output, ndat2d, ndat3d)
932 #else
933  stop ' sico_init: Parameter NETCDF must be either 1 or 2!'
934 #endif
935 
936 #elif OUTPUT==2
937 
938 if (time_output(1) <= time_init+eps) then
939 
940 #if ERGDAT==0
941  flag_3d_output = .false.
942 #elif ERGDAT==1
943  flag_3d_output = .true.
944 #else
945  stop ' sico_init: ERGDAT must be either 0 or 1!'
946 #endif
947 
948 #if NETCDF==1
949  call output1(runname, time_init, delta_ts, glac_index, z_sl, &
950  flag_3d_output, ndat2d, ndat3d)
951 #elif NETCDF==2
952  call output_nc(runname, time_init, delta_ts, glac_index, z_sl, &
953  flag_3d_output, ndat2d, ndat3d)
954 #else
955  stop ' sico_init: Parameter NETCDF must be either 1 or 2!'
956 #endif
957 
958 end if
959 
960 #elif OUTPUT==3
961 
962  flag_3d_output = .false.
963 
964 #if NETCDF==1
965  call output1(runname, time_init, delta_ts, glac_index, z_sl, &
966  flag_3d_output, ndat2d, ndat3d)
967 #elif NETCDF==2
968  call output_nc(runname, time_init, delta_ts, glac_index, z_sl, &
969  flag_3d_output, ndat2d, ndat3d)
970 #else
971  stop ' sico_init: Parameter NETCDF must be either 1 or 2!'
972 #endif
973 
974 if (time_output(1) <= time_init+eps) then
975 
976  flag_3d_output = .true.
977 
978 #if NETCDF==1
979  call output1(runname, time_init, delta_ts, glac_index, z_sl, &
980  flag_3d_output, ndat2d, ndat3d)
981 #elif NETCDF==2
982  call output_nc(runname, time_init, delta_ts, glac_index, z_sl, &
983  flag_3d_output, ndat2d, ndat3d)
984 #else
985  stop ' sico_init: Parameter NETCDF must be either 1 or 2!'
986 #endif
987 
988 end if
989 
990 #else
991  stop ' sico_init: OUTPUT must be either 1, 2 or 3!'
992 #endif
993 
994 call output2(time_init, dxi, deta, delta_ts, glac_index, z_sl)
995 #if OUTSER==2
996 call output3(time_init, delta_ts, glac_index, z_sl)
997 #endif
998 #if OUTSER==3
999 call output4(time_init, dxi, deta, delta_ts, glac_index, z_sl)
1000 #endif
1001 
1002 end subroutine sico_init
1003 !