BUGFIX: Uninitialised member variables
[foam-extend-3.2.git] / applications / utilities / miscellaneous / foamDebugSwitches / foamDebugSwitches.C
blobb8bccde8aa5e28d0de59c23fbd0cbcac5b784978
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright held by original author
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
11     OpenFOAM is free software; you can redistribute it and/or modify it
12     under the terms of the GNU General Public License as published by the
13     Free Software Foundation; either version 2 of the License, or (at your
14     option) any later version.
16     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
19     for more details.
21     You should have received a copy of the GNU General Public License
22     along with OpenFOAM; if not, write to the Free Software Foundation,
23     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 Description
26     Write out all library debug switches
28 \*---------------------------------------------------------------------------*/
30 #include "argList.H"
31 #include "dictionary.H"
32 #include "IFstream.H"
33 #include "IOobject.H"
34 #include "HashSet.H"
36 using namespace Foam;
38 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
39 // Main program:
41 int main(int argc, char *argv[])
43     argList::noParallel();
44     argList::validOptions.insert("new", "");
45     argList::validOptions.insert("old", "");
47     Foam::argList args(argc, argv);
49     wordList currDebug(debug::debugSwitches().toc());
50     wordList currInfo(debug::infoSwitches().toc());
51     wordList currOpt(debug::optimisationSwitches().toc());
53     if (args.optionFound("old") || args.optionFound("new"))
54     {
55         dictionary controlDict(IFstream(findEtcFile("controlDict", true))());
57         wordHashSet oldDebug
58         (
59             controlDict.subDict("DebugSwitches").toc()
60         );
62         wordHashSet oldInfo
63         (
64             controlDict.subDict("InfoSwitches").toc()
65         );
67         wordHashSet oldOpt
68         (
69             controlDict.subDict("OptimisationSwitches").toc()
70         );
73         wordHashSet hashset;
74         wordList listing;
77         // list old switches - but this can't work since the (old) inserted
78         // switches are in both sets
79         // Workaround:
80         //  1. run without any options (get complete list)
81         //  2. comment out DebugSwitches, run again with -new to find new ones
82         //     and do a diff
83         if (args.optionFound("old"))
84         {
85             IOobject::writeDivider(Info);
87             hashset = wordHashSet(oldDebug);
88             hashset -= wordHashSet(currDebug);
89             listing = hashset.toc();
90             sort(listing);
91             Info<< "old DebugSwitches: " << listing << endl;
93             hashset = wordHashSet(oldInfo);
94             hashset -= wordHashSet(currInfo);
95             listing = hashset.toc();
96             sort(listing);
97             Info<< "old InfoSwitches: " << listing << endl;
99             hashset = wordHashSet(oldOpt);
100             hashset -= wordHashSet(currOpt);
101             listing = hashset.toc();
102             sort(listing);
103             Info<< "old OptimisationSwitches: " << listing << endl;
104         }
106         // list new switches
107         if (args.optionFound("new"))
108         {
109             IOobject::writeDivider(Info);
111             hashset = wordHashSet(currDebug);
112             hashset -= wordHashSet(oldDebug);
114             listing = hashset.toc();
115             sort(listing);
116             Info<< "new DebugSwitches: " << listing << endl;
118             hashset = wordHashSet(currInfo);
119             hashset -= wordHashSet(oldInfo);
120             listing = hashset.toc();
121             sort(listing);
122             Info<< "new InfoSwitches: " << listing << endl;
124             hashset = wordHashSet(currOpt);
125             hashset -= wordHashSet(oldOpt);
126             listing = hashset.toc();
127             sort(listing);
128             Info<< "new OptimisationSwitches: " << listing << endl;
129         }
130     }
131     else
132     {
133         IOobject::writeDivider(Info);
135         sort(currDebug);
136         Info<< "DebugSwitches: " << currDebug << endl;
138         sort(currInfo);
139         Info<< "InfoSwitches: " << currInfo << endl;
141         sort(currOpt);
142         Info<< "OptimisationSwitches: " << currOpt << endl;
143     }
147     Info<< "done" << endl;
149     return 0;
153 // ************************************************************************* //