ENH: autoLayerDriver: better layering information message
[OpenFOAM-2.0.x.git] / applications / utilities / miscellaneous / foamDebugSwitches / foamDebugSwitches.C
blob4c74174e2e2db63a0801477f95f09b0d25f2ff87
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
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
13     the Free Software Foundation, either version 3 of the License, or
14     (at your 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, see <http://www.gnu.org/licenses/>.
24 Description
25     Write out all library debug switches
27 \*---------------------------------------------------------------------------*/
29 #include "argList.H"
30 #include "dictionary.H"
31 #include "IFstream.H"
32 #include "IOobject.H"
33 #include "HashSet.H"
35 using namespace Foam;
37 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
38 // Main program:
40 int main(int argc, char *argv[])
42     argList::noParallel();
43     argList::addBoolOption
44     (
45         "new",
46         "output switches that are known from the libraries "
47         "but that do not seem to be known in the current etc/controlDict"
48     );
49     argList::addBoolOption
50     (
51         "old",
52         "output switches that appear to be unknown in "
53         "the current etc/controlDict"
54     );
56     argList args(argc, argv);
58     wordList currDebug(debug::debugSwitches().toc());
59     wordList currInfo(debug::infoSwitches().toc());
60     wordList currOpt(debug::optimisationSwitches().toc());
62     if (args.optionFound("old") || args.optionFound("new"))
63     {
64         fileNameList controlDictFiles = findEtcFiles("controlDict", true);
65         dictionary controlDict;
66         forAllReverse(controlDictFiles, cdfi)
67         {
68             controlDict.merge(dictionary(IFstream(controlDictFiles[cdfi])()));
69         }
71         wordHashSet oldDebug
72         (
73             controlDict.subDict("DebugSwitches").toc()
74         );
76         wordHashSet oldInfo
77         (
78             controlDict.subDict("InfoSwitches").toc()
79         );
81         wordHashSet oldOpt
82         (
83             controlDict.subDict("OptimisationSwitches").toc()
84         );
87         wordHashSet hashset;
88         wordList listing;
91         // list old switches - but this can't work since the (old) inserted
92         // switches are in both sets
93         // Workaround:
94         //  1. run without any options (get complete list)
95         //  2. comment out DebugSwitches, run again with -new to find new ones
96         //     and do a diff
97         if (args.optionFound("old"))
98         {
99             IOobject::writeDivider(Info);
101             hashset = oldDebug;
102             hashset -= currDebug;
103             listing = hashset.toc();
104             sort(listing);
105             Info<< "old DebugSwitches: " << listing << endl;
107             hashset = oldInfo;
108             hashset -= currInfo;
109             listing = hashset.toc();
110             sort(listing);
111             Info<< "old InfoSwitches: " << listing << endl;
113             hashset = oldOpt;
114             hashset -= currOpt;
115             listing = hashset.toc();
116             sort(listing);
117             Info<< "old OptimisationSwitches: " << listing << endl;
118         }
120         // list new switches
121         if (args.optionFound("new"))
122         {
123             IOobject::writeDivider(Info);
125             hashset = currDebug;
126             hashset -= oldDebug;
128             listing = hashset.toc();
129             sort(listing);
130             Info<< "new DebugSwitches: " << listing << endl;
132             hashset = currInfo;
133             hashset -= oldInfo;
134             listing = hashset.toc();
135             sort(listing);
136             Info<< "new InfoSwitches: " << listing << endl;
138             hashset = currOpt;
139             hashset -= oldOpt;
140             listing = hashset.toc();
141             sort(listing);
142             Info<< "new OptimisationSwitches: " << listing << endl;
143         }
144     }
145     else
146     {
147         IOobject::writeDivider(Info);
149         sort(currDebug);
150         Info<< "DebugSwitches: " << currDebug << endl;
152         sort(currInfo);
153         Info<< "InfoSwitches: " << currInfo << endl;
155         sort(currOpt);
156         Info<< "OptimisationSwitches: " << currOpt << endl;
157     }
161     Info<< "done" << endl;
163     return 0;
167 // ************************************************************************* //