tpismr.cc - pism - [fork] customized build of PISM, the parallel ice sheet model (tillflux branch)
HTML git clone git://src.adamsgaard.dk/pism
DIR Log
DIR Files
DIR Refs
DIR LICENSE
---
tpismr.cc (3868B)
---
1 // Copyright (C) 2004-2011, 2013, 2014, 2015, 2016, 2017 Jed Brown, Ed Bueler and Constantine Khroulev
2 //
3 // This file is part of PISM.
4 //
5 // PISM is free software; you can redistribute it and/or modify it under the
6 // terms of the GNU General Public License as published by the Free Software
7 // Foundation; either version 3 of the License, or (at your option) any later
8 // version.
9 //
10 // PISM is distributed in the hope that it will be useful, but WITHOUT ANY
11 // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13 // details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with PISM; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18
19 static char help[] =
20 "Ice sheet driver for PISM ice sheet simulations, initialized from data.\n"
21 "The basic PISM executable for evolution runs.\n";
22
23 #include <memory>
24 #include <petscsys.h> // PETSC_COMM_WORLD
25
26 #include "pism/util/IceGrid.hh"
27 #include "pism/icemodel/IceModel.hh"
28 #include "pism/util/Config.hh"
29
30 #include "pism/util/pism_options.hh"
31 #include "pism/util/petscwrappers/PetscInitializer.hh"
32 #include "pism/util/error_handling.hh"
33 #include "pism/util/Context.hh"
34 #include "pism/util/Profiling.hh"
35
36 #include "pism/regional/IceGrid_Regional.hh"
37 #include "pism/regional/IceRegionalModel.hh"
38
39 using namespace pism;
40
41 int main(int argc, char *argv[]) {
42
43 MPI_Comm com = MPI_COMM_WORLD;
44 petsc::Initializer petsc(argc, argv, help);
45
46 com = PETSC_COMM_WORLD;
47
48 try {
49 Context::Ptr ctx = context_from_options(com, "pismr");
50 Logger::Ptr log = ctx->log();
51
52 std::string usage =
53 " pismr -i IN.nc [-bootstrap] [-regional] [OTHER PISM & PETSc OPTIONS]\n"
54 "where:\n"
55 " -i IN.nc is input file in NetCDF format: contains PISM-written model state\n"
56 " -bootstrap enable heuristics to produce an initial state from an incomplete input\n"
57 " -regional enable \"regional mode\"\n"
58 "notes:\n"
59 " * option -i is required\n"
60 " * if -bootstrap is used then also '-Mx A -My B -Mz C -Lz D' are required\n";
61 {
62 std::vector<std::string> required(1, "-i");
63
64 bool done = show_usage_check_req_opts(*log, "PISMR (basic evolution run mode)" ,
65 required, usage);
66 if (done) {
67 return 0;
68 }
69 }
70
71 options::String profiling_log = options::String("-profile",
72 "Save detailed profiling data to a file.");
73
74 Config::Ptr config = ctx->config();
75
76 if (profiling_log.is_set()) {
77 ctx->profiling().start();
78 }
79
80 IceGrid::Ptr grid;
81 std::unique_ptr<IceModel> model;
82
83 if (options::Bool("-regional", "enable regional (outlet glacier) mode")) {
84 grid = regional_grid_from_options(ctx);
85 model.reset(new IceRegionalModel(grid, ctx));
86 } else {
87 grid = IceGrid::FromOptions(ctx);
88 model.reset(new IceModel(grid, ctx));
89 }
90
91 model->init();
92
93 const bool
94 list_ascii = options::Bool("-list_diagnostics",
95 "List available diagnostic quantities and stop"),
96 list_json = options::Bool("-list_diagnostics_json",
97 "List available diagnostic quantities (JSON format) and stop");
98
99 if (list_ascii) {
100 model->list_diagnostics();
101 } else if (list_json) {
102 model->list_diagnostics_json();
103 } else {
104 model->run();
105
106 log->message(2, "... done with run\n");
107
108 model->save_results();
109 }
110 print_unused_parameters(*log, 3, *config);
111
112 if (profiling_log.is_set()) {
113 ctx->profiling().report(profiling_log);
114 }
115 }
116 catch (...) {
117 handle_fatal_errors(com);
118 return 1;
119 }
120
121 return 0;
122 }