tssa_forward.py - pism - [fork] customized build of PISM, the parallel ice sheet model (tillflux branch)
(HTM) git clone git://src.adamsgaard.dk/pism
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) LICENSE
---
tssa_forward.py (2059B)
---
1 #! /usr/bin/env python3
2 #
3 # Copyright (C) 2011, 2014, 2015, 2016, 2018 David Maxwell and Constantine Khroulev
4 #
5 # This file is part of PISM.
6 #
7 # PISM is free software; you can redistribute it and/or modify it under the
8 # terms of the GNU General Public License as published by the Free Software
9 # Foundation; either version 3 of the License, or (at your option) any later
10 # version.
11 #
12 # PISM is distributed in the hope that it will be useful, but WITHOUT ANY
13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
15 # details.
16 #
17 # You should have received a copy of the GNU General Public License
18 # along with PISM; if not, write to the Free Software
19 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20
21 import PISM
22 import time
23
24 # The main code for a run follows:
25 if __name__ == '__main__':
26 context = PISM.Context()
27 config = context.config
28 com = context.com
29
30 PISM.set_abort_on_sigint(True)
31
32 PISM.verbPrintf(2, PISM.Context().com, "SSA forward model.\n")
33 usage = \
34 """ ssa_forward.py -i IN.nc -Mx number -My number [-o file.nc]
35 or (at python prompt)
36 run ssa_forward -i IN.nc -Mx number -My number [-o file.nc]
37 where:
38 -i IN.nc is input file in NetCDF format: contains PISM-written model state
39 -Mx number of grid points in the x direction
40 -My number of grid points in the y direction
41 notes:
42 * -i is required
43 """
44
45 PISM.show_usage_check_req_opts(context.log, "ssa_forward", ["-i"], usage)
46
47 input_file = config.get_string("input.file")
48 if len(input_file) == 0:
49 import sys
50 sys.exit(1)
51
52 config.set_string("output.file_name", "ssa_forward.nc")
53
54 ssa_run = PISM.ssa.SSAFromInputFile(input_file)
55
56 ssa_run.setup()
57
58 solve_t0 = time.time()
59 vel_ssa = ssa_run.solve()
60 solve_t = time.time() - solve_t0
61
62 PISM.verbPrintf(2, context.com, "Solve time %g seconds.\n", solve_t)
63
64 ssa_run.write(config.get_string("output.file_name"))