OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

foamDebugSwitches.C

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 Description
00026     Write out all library debug switches
00027 
00028 \*---------------------------------------------------------------------------*/
00029 
00030 #include "argList.H"
00031 #include "dictionary.H"
00032 #include "IFstream.H"
00033 #include "IOobject.H"
00034 #include "HashSet.H"
00035 
00036 using namespace Foam;
00037 
00038 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00039 // Main program:
00040 
00041 int main(int argc, char *argv[])
00042 {
00043     argList::noParallel();
00044     argList::validOptions.insert("new", "");
00045     argList::validOptions.insert("old", "");
00046 
00047     Foam::argList args(argc, argv);
00048 
00049     wordList currDebug(debug::debugSwitches().toc());
00050     wordList currInfo(debug::infoSwitches().toc());
00051     wordList currOpt(debug::optimisationSwitches().toc());
00052 
00053     if (args.optionFound("old") || args.optionFound("new"))
00054     {
00055         dictionary controlDict(IFstream(findEtcFile("controlDict", true))());
00056 
00057         wordHashSet oldDebug
00058         (
00059             controlDict.subDict("DebugSwitches").toc()
00060         );
00061 
00062         wordHashSet oldInfo
00063         (
00064             controlDict.subDict("InfoSwitches").toc()
00065         );
00066 
00067         wordHashSet oldOpt
00068         (
00069             controlDict.subDict("OptimisationSwitches").toc()
00070         );
00071 
00072 
00073         wordHashSet hashset;
00074         wordList listing;
00075 
00076 
00077         // list old switches - but this can't work since the (old) inserted
00078         // switches are in both sets
00079         // Workaround:
00080         //  1. run without any options (get complete list)
00081         //  2. comment out DebugSwitches, run again with -new to find new ones
00082         //     and do a diff
00083         if (args.optionFound("old"))
00084         {
00085             IOobject::writeDivider(Info);
00086 
00087             hashset = oldDebug;
00088             hashset -= currDebug;
00089             listing = hashset.toc();
00090             sort(listing);
00091             Info<< "old DebugSwitches: " << listing << endl;
00092 
00093             hashset = oldInfo;
00094             hashset -= currInfo;
00095             listing = hashset.toc();
00096             sort(listing);
00097             Info<< "old InfoSwitches: " << listing << endl;
00098 
00099             hashset = oldOpt;
00100             hashset -= currOpt;
00101             listing = hashset.toc();
00102             sort(listing);
00103             Info<< "old OptimisationSwitches: " << listing << endl;
00104         }
00105 
00106         // list new switches
00107         if (args.optionFound("new"))
00108         {
00109             IOobject::writeDivider(Info);
00110 
00111             hashset = currDebug;
00112             hashset -= oldDebug;
00113 
00114             listing = hashset.toc();
00115             sort(listing);
00116             Info<< "new DebugSwitches: " << listing << endl;
00117 
00118             hashset = currInfo;
00119             hashset -= oldInfo;
00120             listing = hashset.toc();
00121             sort(listing);
00122             Info<< "new InfoSwitches: " << listing << endl;
00123 
00124             hashset = currOpt;
00125             hashset -= oldOpt;
00126             listing = hashset.toc();
00127             sort(listing);
00128             Info<< "new OptimisationSwitches: " << listing << endl;
00129         }
00130     }
00131     else
00132     {
00133         IOobject::writeDivider(Info);
00134 
00135         sort(currDebug);
00136         Info<< "DebugSwitches: " << currDebug << endl;
00137 
00138         sort(currInfo);
00139         Info<< "InfoSwitches: " << currInfo << endl;
00140 
00141         sort(currOpt);
00142         Info<< "OptimisationSwitches: " << currOpt << endl;
00143     }
00144 
00145 
00146 
00147     Info<< "done" << endl;
00148 
00149     return 0;
00150 }
00151 
00152 
00153 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd