52bool subdivide
false @endcode
54 The results from the program are stored in a similar structure. At
55 the end of a program, it is possible to write the input and output
56 data into one file. The output file has the same syntax and
57 structure as the input file and can therefore be used as an input
58 file to reproduce the results at a later time. See the <a
59 href=
"#Results">results section</a>
for an example.
61 @dontinclude inputoutput.cc
62 @section commented Commented Program
64 The first few lines in a code
for concepts are filled with the
65 include files. I put the system includes first here.
67 Then, there are the Concepts includes:
69 <li>basics.hh
for the exception handling code and other things.
70 <li>toolbox.hh
for the toolbox, including the intput file parser
71 and the handling of input and output data.
73 Since there are no real computations in the code, no more include files
74 from Concepts are needed.
77 All code in
this example is in one large routine, the main program.
80 Some
default values
for the parameters used. \c l and \c p are just two
81 variables. If \c debug is set to
true, more information is printed to
84 A big
try block to
catch exceptions. More and more runtime errors
85 in Concepts are reported by throwing an exception.
88 First, set up the input parameter
class: some parameters
89 are set up with a
default value.
92 The variable outputParameter is
for easier access to the output
93 area. There, the results of the computations can be stored and
94 eventually written to disk
if necessary.
97 Prepare an array
for values computed later. This array is then
98 added to \c table which is able to nicely format the content of
99 the different arrays (e.g.
for later processing with Gnuplot).
103 @subsection parsing Command Line Parsing
104 Here, we start with the command line parsing. See the man page
105 for \c getopt
for more information.
107 In the second line of the following code fragement, the
string
108 defines what command line arguments are allowed and
if they take a
109 parameter (:) or not. The \c switch statement has an entry
110 for every command line argument listed in the string. There, the
111 parameter is available as \c optarg. The \c default
112 target of the \c switch clause prints some
113 usage information (ie. help for the command line arguments).
115 The parameters are processed in the order they appear on the
116 command line. When first specifying an input file with \c -f, the
117 values in the file can be overridden with additional command line
118 arguments after \c -f.
120 Print the parameters to show the user what is going on.
124 Next, the parameters from the command line or the input file are
125 stored in the respective variables. This is only used for
130 @subsection comp Computations
131 Here are some dummy computations to fill the output area with
133 @skip outputParameters.addInt
136 @section output Output
137 Finally, the input and output data are written to disk with some more
138 information about the user and the system in the header of the
142 This prints the table and its content to the screen and also
143 stores it with high precision in a file suitable for later
144 processing with Gnuplot.
147 Here, all exceptions derived from the base exception class
148 (
concepts::ExceptionBase) in Concepts are catched and printed. You
149 can
test this out by not giving the name of the input file on the
150 command line. Then the parameter \c parameterout does not exist
151 and the library will throw and exception which is caught here.
156 The output of the program called without parameters: @code
161string author
"(empty)"
162string comment
"(empty)"
163string parameterout
"inputoutput.out"
164string title
"(empty)"
170Writing gathered data to disk: inputoutput.out
185 The program creates the following output files:
186 - \c inputoutput.out: @code
191string author
"(empty)"
192string comment
"(empty)"
193string parameterout
"inputoutput.out"
194string title
"(empty)"
213 - \c inputoutput.gnuplot: @code
2249 0.001953125 @endcode
226 Note the \c end keyword at the end of the input
227 part and right before the output part. When reading in this file as
228 input file, the parsing stops right there, ie. the previous output
231 @section complete Complete Source Code
232 @author Philipp Frauenfelder, 2004