The Conley-Morse Graphs Software
cmgraphs.cpp
Go to the documentation of this file.
1/////////////////////////////////////////////////////////////////////////////
2///
3/// @file cmgraphs.cpp
4///
5/// Conley-Morse graphs - the main program.
6/// This program computes a set of Conley-Morse graphs
7/// for a given discrete dynamical system
8/// for a prescribed rectangular range of parameters,
9/// and establishes the continuation relation
10/// between adjacent computed graphs.
11///
12/// @author Pawel Pilarczyk
13///
14///
15/// @mainpage The Conley-Morse Graphs Software
16///
17/// \section intro Introduction
18///
19/// This website contains the documentation of software designed and
20/// programmed by <a href="https://www.pawelpilarczyk.com/">Pawel Pilarczyk</a>
21/// and accompanies the paper
22/// <em>Databases for the Global Dynamics of Multiparameter Systems</em>
23/// by Z. Arai, W. Kalies, H. Kokubu, K. Mischaikow, H. Oka,
24/// and P. Pilarczyk. Please, see the
25/// <a href="https://www.pawelpilarczyk.com/database/">website of the project</a>
26/// and refer to the <a href="https://www.pawelpilarczyk.com/cmgraphs/">page
27/// devoted to the software</a> for more information.
28///
29/// \section license License
30///
31/// In order to make this software freely available for wide audience,
32/// it is provided here under the terms of the
33/// <a href="http://www.gnu.org/copyleft/gpl.html">GNU General
34/// Public License</a>, and this documentation is provided under the terms
35/// of the <a href="http://www.gnu.org/copyleft/fdl.html">GNU Free
36/// Documentation License</a>.
37///
38/// \section browsing Browsing
39///
40/// Although a lot of effort has been put into making this software
41/// as transparent and clear as possible,
42/// and to make this documentation complete,
43/// I am sure that there is a lot of important information
44/// which should have been included here but was omitted.
45/// Therefore, this documentation was generated in such
46/// a way that it contains the entire source code
47/// which can be browsed and verified in case of any doubt.
48///
49/// Have a nice browsing!
50///
51/// Pawel Pilarczyk
52///
53/////////////////////////////////////////////////////////////////////////////
54
55// Copyright (C) 1997-2014 by Pawel Pilarczyk.
56//
57// This file is part of my research software package. This is free software:
58// you can redistribute it and/or modify it under the terms of the GNU
59// General Public License as published by the Free Software Foundation,
60// either version 3 of the License, or (at your option) any later version.
61//
62// This software is distributed in the hope that it will be useful,
63// but WITHOUT ANY WARRANTY; without even the implied warranty of
64// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
65// GNU General Public License for more details.
66//
67// You should have received a copy of the GNU General Public License
68// along with this software; see the file "license.txt". If not,
69// please, see <https://www.gnu.org/licenses/>.
70
71// Started in November 2005. Last revision: July 7, 2014.
72
73
74// include some standard C++ header files
75#include <exception>
76
77// include selected header files from the CHomP library
78#include "chomp/system/config.h"
79#include "chomp/system/textfile.h"
80#include "chomp/system/timeused.h"
81#include "chomp/system/arg.h"
82#include "chomp/multiwork/mw.h"
83
84// include local header files
85#include "config.h"
86#include "typedefs.h"
87#include "typedyns.h"
88#include "worker.h"
89#include "coord.h"
90
91
92// --------------------------------------------------
93// -------------------- OVERTURE --------------------
94// --------------------------------------------------
95
96/// The title of the program which is displayed every time
97/// the program is launcued.
98const char *title = "\
99This is a Conley-Morse graphs computation program.\n\
100Ver. 0.09, July 15, 2014. Copyright (C) 2005-2014 by Pawel Pilarczyk.\n\
101This is free software. No warranty. Consult 'license.txt' for details.";
102
103/// The help information about the program which is displayed
104/// if the program is launched without command-line arguments
105/// or with incorrect arguments.
106const char *helpinfo = "\
107This is the front-end program for the computation of Conley-Morse graphs\n\
108for a selected range of parameters for a given discrete dynamical system,\n\
109as configured in the file 'config.h' of the source code. Please, see the\n\
110documentation of the program and the source code for more information.\n\
111Command line arguments (either '-w', or '-c' and '-f' must be specified):\n\
112-w computer:port - run as a worker and connect to the given coordinator,\n\
113-c [port] - run as a coordinator and listen to workers at the given port;\n\
114\tif port=0 (default) then runs the computations locally only,\n\
115-f prefix - file name prefix for saving the final continuation data,\n\
116-i filename - intermediate results file (new results will be appended),\n\
117-g filename - file name to save the text code for Conley-Morse graphs,\n\
118-m prefix - file name prefix for text code of Conley-Morse graphs,\n\
119-s prefix - file name prefix for shared info on Morse decompositions,\n\
120-p prefix - file name prefix for PNG pictures of Morse decompositions,\n\
121-q prefix - file name prefix for Morse sets as lists of cubes,\n\
122-o prefix - file name prefix for post-processing Morse sets information,\n\
123-t filename - file name with optimization information (read & append),\n\
124-u prefix - file name prefix for ODE integration optimization information,\n\
125-z prefix - prefix for temporary files with Morse decompositions cache,\n\
126-n num - the number of parameter space patches for matching;\n\
127\tvalue <0 sets the distance between patch corners in each direciton,\n\
128--full - use the full range of the phase space to plot Morse sets,\n\
129--log filename - file name to save all the text output of the program to,\n\
130--quiet - suppress any output written to the terminal,\n\
131--debug - display a lot of additional information (for debugging etc.),\n\
132--help - make the program show this brief help information and exit.\n\
133For more information ask the author at http://www.pawelpilarczyk.com/.";
134
135
136// --------------------------------------------------
137// ---------------------- MAIN ----------------------
138// --------------------------------------------------
139
140/// The main procedure of the program.
141/// Returns: 0 = Ok, -1 = Error, 1 = Help displayed, 2 = Wrong arguments.
142int main (int argc, char *argv [])
143{
144 using namespace chomp::homology;
145
146 // prepare user-configurable data
147 char *workAddress = 0;
148 char *interFileName = 0;
149 char *mapOptFileName = 0;
150 char *mapOptPrefix = 0;
151 char *graphsFileName = 0;
152 char *graphsPrefix = 0;
153 char *finalPrefix = 0;
154 char *sharePrefix = 0;
155 char *phaseSpacePrefix = 0;
156 char *morseDecPrefix = 0;
157 char *cubesPrefix = 0;
158 char *procPrefix = 0;
159 int coordPort = -1;
160 int skipIndices = 0;
161 bool fullPhaseSpace = false;
162 int nPatches = 0;
163 const int maxComments = 16;
164 int nComments = 0;
165 char *comments [maxComments];
166
167 // interprete the command-line arguments
168 arguments a;
169 arg (a, "c", coordPort, 0);
170 arg (a, "w", workAddress);
171 arg (a, "i", interFileName);
172 arg (a, "t", mapOptFileName);
173 arg (a, "u", mapOptPrefix);
174 arg (a, "g", graphsFileName);
175 arg (a, "m", graphsPrefix);
176 arg (a, "f", finalPrefix);
177 arg (a, "s", sharePrefix);
178 arg (a, "q", cubesPrefix);
179 arg (a, "o", procPrefix);
180 arg (a, "p", phaseSpacePrefix);
181 arg (a, "z", morseDecPrefix);
182 arg (a, "n", nPatches);
183 arg (a, "-comment", comments, nComments, maxComments);
184 arg (a, "-skip-indices", skipIndices, 1);
185 argswitch (a, "-full", fullPhaseSpace, true);
186 arghelp (a);
187
188 argstreamprepare (a);
189 int argresult = a. analyze (argc, argv);
190 argstreamset ();
191
192 // if the final results prefix is specified but no port for the
193 // coordinator was specified then set it to 0 (local work)
194 if (finalPrefix && (coordPort < 0))
195 coordPort = 0;
196
197 // if no worker/coordinator selected then show help information
198 if (!finalPrefix && !workAddress)
199 argresult = 1;
200
201 // show the program's main title
202 if (argresult >= 0)
203 sout << title << '\n';
204
205 // if something was incorrect, show an additional message and exit
206 if (argresult < 0)
207 {
208 sout << "Call with '--help' for help.\n";
209 return 2;
210 }
211
212 // if help requested, show help information
213 if (argresult > 0)
214 {
215 sout << helpinfo << '\n';
216 return 1;
217 }
218
219 // try running the main function and catch an error message if thrown
220 try
221 {
222 // set an appropriate program time message
223 program_time = "Aborted after:";
224 program_time = 1;
225
226 // run as a worker if requested to
227 if (workAddress)
228 {
229 Worker w (false);
230 w. Port (0);
231 w. Add (workAddress);
232 w. TimeOut (600);
233 sout << "Running as a worker...\n";
234 int result = w. Work ();
235 if (result == chomp::multiwork::mwOk)
236 sout << "Work completed successfully.\n";
237 else
238 sout << "Could not work - probably "
239 "an error occurred.\n";
240 }
241
242 // run as a coordinator otherwise
243 else
244 {
245 Worker w (true);
246 Coordinator c (interFileName,
247 mapOptFileName, mapOptPrefix,
248 graphsFileName, graphsPrefix,
249 finalPrefix, sharePrefix,
250 phaseSpacePrefix, cubesPrefix,
251 morseDecPrefix, procPrefix,
252 fullPhaseSpace, skipIndices, nPatches);
253 c. Port (coordPort);
254 sout << "Running as a coordinator...\n";
255 int result = c. Coordinate (coordPort ? 0 : &w);
256 if (result == chomp::multiwork::mwOk)
257 sout << "The task completed successfully.\n";
258 else
259 sout << "Could not coordinate - probably "
260 "an error occurred.\n";
261 }
262
263 // set an appropriate program time message
264 program_time = "Total time used:";
265
266 // finalize
267 return 0;
268 }
269 catch (const char *msg)
270 {
271 sout << "ERROR: " << msg << '\n';
272 return -1;
273 }
274 catch (const std::exception &e)
275 {
276 sout << "ERROR: " << e. what () << '\n';
277 return -1;
278 }
279 catch (...)
280 {
281 sout << "ABORT: An unknown error occurred.\n";
282 return -1;
283 }
284} /* main */
285
The coordinator class which prepares chunks of parameter space to be processed by workers,...
Definition: coord.h:74
The worker class that processes single chunks of data which contain the definition of a selected rect...
Definition: worker.h:73
int main(int argc, char *argv[])
The main procedure of the program.
Definition: cmgraphs.cpp:142
const char * helpinfo
The help information about the program which is displayed if the program is launched without command-...
Definition: cmgraphs.cpp:106
const char * title
The title of the program which is displayed every time the program is launcued.
Definition: cmgraphs.cpp:98
Choice of configuration settings.
The coordinator class for the Conley-Morse graphs computation program.
Customizable data types for the Conley-Morse graphs computation program.
Data types for the dynamical systems data structures.
The worker class for the Conley-Morse graphs computation program.