00001 /*---------------------------------------------------------------------------*\ 00002 ========= | 00003 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 00004 \\ / O peration | 00005 \\ / A nd | Copyright (C) 1991-2010 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 00013 the Free Software Foundation, either version 3 of the License, or 00014 (at your 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, see <http://www.gnu.org/licenses/>. 00023 00024 Application 00025 foamDebugSwitches 00026 00027 Description 00028 Write out all library debug switches 00029 00030 Usage 00031 - foamDebugSwitches 00032 00033 \*---------------------------------------------------------------------------*/ 00034 00035 #include <OpenFOAM/argList.H> 00036 #include <OpenFOAM/dictionary.H> 00037 #include <OpenFOAM/IFstream.H> 00038 #include <OpenFOAM/IOobject.H> 00039 #include <OpenFOAM/HashSet.H> 00040 00041 using namespace Foam; 00042 00043 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00044 // Main program: 00045 00046 int main(int argc, char *argv[]) 00047 { 00048 argList::noParallel(); 00049 argList::validOptions.insert("new", ""); 00050 argList::validOptions.insert("old", ""); 00051 00052 Foam::argList args(argc, argv); 00053 00054 wordList currDebug(debug::debugSwitches().toc()); 00055 wordList currInfo(debug::infoSwitches().toc()); 00056 wordList currOpt(debug::optimisationSwitches().toc()); 00057 00058 if (args.optionFound("old") || args.optionFound("new")) 00059 { 00060 dictionary controlDict(IFstream(findEtcFile("controlDict", true))()); 00061 00062 // Work-around for compiler bug 00063 wordList dbgTmp = controlDict.subDict("DebugSwitches").toc(); 00064 wordHashSet oldDebug 00065 ( 00066 static_cast<UList<word>&>(dbgTmp) 00067 ); 00068 00069 // Work-around for compiler bug 00070 wordList infoTmp = controlDict.subDict("InfoSwitches").toc(); 00071 wordHashSet oldInfo 00072 ( 00073 static_cast<UList<word>&>(infoTmp) 00074 ); 00075 00076 // Work-around for compiler bug 00077 wordList optTmp = controlDict.subDict("OptimisationSwitches").toc(); 00078 wordHashSet oldOpt 00079 ( 00080 static_cast<UList<word>&>(optTmp) 00081 ); 00082 00083 00084 wordHashSet hashset; 00085 wordList listing; 00086 00087 00088 // list old switches - but this can't work since the (old) inserted 00089 // switches are in both sets 00090 // Workaround: 00091 // 1. run without any options (get complete list) 00092 // 2. comment out DebugSwitches, run again with -new to find new ones 00093 // and do a diff 00094 if (args.optionFound("old")) 00095 { 00096 IOobject::writeDivider(Info); 00097 00098 hashset = oldDebug; 00099 hashset -= currDebug; 00100 listing = hashset.toc(); 00101 sort(listing); 00102 Info<< "old DebugSwitches: " << listing << endl; 00103 00104 hashset = oldInfo; 00105 hashset -= currInfo; 00106 listing = hashset.toc(); 00107 sort(listing); 00108 Info<< "old InfoSwitches: " << listing << endl; 00109 00110 hashset = oldOpt; 00111 hashset -= currOpt; 00112 listing = hashset.toc(); 00113 sort(listing); 00114 Info<< "old OptimisationSwitches: " << listing << endl; 00115 } 00116 00117 // list new switches 00118 if (args.optionFound("new")) 00119 { 00120 IOobject::writeDivider(Info); 00121 00122 hashset = currDebug; 00123 hashset -= oldDebug; 00124 00125 listing = hashset.toc(); 00126 sort(listing); 00127 Info<< "new DebugSwitches: " << listing << endl; 00128 00129 hashset = currInfo; 00130 hashset -= oldInfo; 00131 listing = hashset.toc(); 00132 sort(listing); 00133 Info<< "new InfoSwitches: " << listing << endl; 00134 00135 hashset = currOpt; 00136 hashset -= oldOpt; 00137 listing = hashset.toc(); 00138 sort(listing); 00139 Info<< "new OptimisationSwitches: " << listing << endl; 00140 } 00141 } 00142 else 00143 { 00144 IOobject::writeDivider(Info); 00145 00146 sort(currDebug); 00147 Info<< "DebugSwitches: " << currDebug << endl; 00148 00149 sort(currInfo); 00150 Info<< "InfoSwitches: " << currInfo << endl; 00151 00152 sort(currOpt); 00153 Info<< "OptimisationSwitches: " << currOpt << endl; 00154 } 00155 00156 00157 00158 Info<< "done" << endl; 00159 00160 return 0; 00161 } 00162 00163 00164 // ************************ vim: set sw=4 sts=4 et: ************************ //