00001 /* This file is part of Cloudy and is copyright (C)1978-2010 by Gary J. Ferland and 00002 * others. For conditions of distribution and use see copyright notice in license.txt */ 00003 /*ParseTrace read in options off the trace command line */ 00004 #include "cddefines.h" 00005 #include "iterations.h" 00006 #include "geometry.h" 00007 #include "trace.h" 00008 #include "parser.h" 00009 00010 void ParseTrace(Parser &p ) 00011 { 00012 DEBUG_ENTRY( "ParseTrace()" ); 00013 00014 /* turn on trace at a certain zone; .LE.0 or none for starting trace 00015 * optional second number is iteration to start debugger */ 00016 00017 /* generate string that says debug turned on - this is caught by perl script 00018 * if "no print" occurs on line do not print it - there is one sim in the 00019 * test suite which tests debug print and do not want to trigger comment 00020 * that debug prints are accidentally turned on */ 00021 if( !p.nMatch("NO PR") ) 00022 fprintf(ioQQQ,"DEBUG trace output turned on.\n"); 00023 00024 /* set initially false, in case we do not turn on trace until 00025 * later iteration or zone */ 00026 trace.lgTrace = false; 00027 /* this is which zone to turn on */ 00028 trace.nznbug = (long)p.FFmtRead(); 00029 if( p.lgEOL() ) 00030 trace.lgTrace = true; 00031 00032 /* this is which iteration to turn on */ 00033 trace.npsbug = (long)p.FFmtRead(); 00034 if( p.lgEOL() ) 00035 trace.npsbug = 1; 00036 00037 /* turn trace on now if no numbers on line */ 00038 if( trace.nznbug == 0 && trace.npsbug <= 1 ) 00039 { 00040 trace.lgTrace = true; 00041 geometry.nprint = 1; 00042 iterations.IterPrnt[0] = 1; 00043 } 00044 00045 /* trace convergence is a special command, 00046 * only convergence loops, not full trace */ 00047 if( p.nMatch("CONV") ) 00048 { 00049 /* check for keyword, if not present 00050 * then set to very high level of debugging - initially set to negative number, a sign 00051 * that trace is not on yet, but to turn on trace convergence when we hit the right zone */ 00052 /* 1 ConvPresTempEdenIoniz */ 00053 if( p.nMatch("PRES") ) 00054 trace.nTrConvg = -1; 00055 /* 2 ConvTempEdenIoniz*/ 00056 else if( p.nMatch("TEMP") ) 00057 trace.nTrConvg = -2; 00058 /* 3 ConvEdenIoniz*/ 00059 else if( p.nMatch("EDEN") ) 00060 trace.nTrConvg = -3; 00061 /* 4 ConvIoniz*/ 00062 else if( p.nMatch("IONI") ) 00063 trace.nTrConvg = -4; 00064 /* 5 below ConvBase*/ 00065 /* > 5 all levels*/ 00066 else 00067 trace.nTrConvg = -100; 00068 00069 /* above set trace level to negative number - this will not trigger 00070 * trace output - turn trace on now if no zone or iteration on line */ 00071 if( trace.nznbug == 0 && trace.npsbug <= 1 ) 00072 trace.nTrConvg *= -1; 00073 00074 /* turn off normal trace parameters, this is a special case */ 00075 trace.lgTrace = false; 00076 /*trace.nznbug = 10000;*/ 00077 geometry.nprint = 10000; 00078 iterations.IterPrnt[0] = 10000; 00079 00080 /* this is an option to also turn on ots rate debug prints */ 00081 if( p.nMatch(" OTS") ) 00082 trace.lgOTSBug = true; 00083 00084 /* this is an option to also turn on electron density source debug prints, 00085 * key is ESOURCE */ 00086 if( p.nMatch("ESOU") ) 00087 trace.lgESOURCE = true; 00088 } 00089 00090 /* trace he-like and h-like must come early since they may have name of element */ 00091 /* the trace h-like hydrogenic species command, with lots of options */ 00092 if( p.nMatch("H-LI") ) 00093 { 00094 /* turn on short trace for h-like species */ 00095 trace.lgHBug = true; 00096 00097 /* option to turn on full printout */ 00098 if( p.nMatch("FULL") ) 00099 { 00100 trace.lgIsoTraceFull[ipH_LIKE] = true; 00101 } 00102 else 00103 { 00104 trace.lgIsoTraceFull[ipH_LIKE] = false; 00105 } 00106 00107 /* look for one of the element names on the line*/ 00108 trace.ipIsoTrace[ipH_LIKE] = p.GetElem(); 00109 00110 /* if no element appears on the line GetElem fcn returns -1, 00111 * in this case we want to do hydrogen */ 00112 trace.ipIsoTrace[ipH_LIKE] = MAX2(0, trace.ipIsoTrace[ipH_LIKE] ); 00113 } 00114 00115 /* the trace h-like hydrogenic species command, with lots of options */ 00116 if( p.nMatch("HE-L") ) 00117 { 00118 /* turn on short trace for helium - like species */ 00119 trace.lgHeBug = true; 00120 00121 /* option to turn on full printout */ 00122 if( p.nMatch("FULL") ) 00123 trace.lgIsoTraceFull[ipHE_LIKE] = true; 00124 else 00125 trace.lgIsoTraceFull[ipHE_LIKE] = false; 00126 00127 /* look for one of the element names on the line*/ 00128 trace.ipIsoTrace[ipHE_LIKE] = p.GetElem(); 00129 00130 /* if no element appears on the line fcn returns -1, 00131 * in this case we want to do helium */ 00132 trace.ipIsoTrace[ipHE_LIKE] = MAX2(1, trace.ipIsoTrace[ipHE_LIKE] ); 00133 } 00134 00135 /* were there any keywords on the line? */ 00136 if( p.nMatch("BETA") ) 00137 trace.lgTr8446 = true; 00138 00139 if( p.nMatch("CARB") ) 00140 trace.lgCarBug = true; 00141 00142 if( p.nMatch("CALC") ) 00143 trace.lgCalBug = true; 00144 00145 if( p.nMatch("COMP") ) 00146 trace.lgComBug = true; 00147 00148 if( p.nMatch("CONT") ) 00149 trace.lgConBug = true; 00150 00151 if( p.nMatch("COOL") ) 00152 trace.lgCoolTr = true; 00153 00154 if( p.nMatch("DIFF") ) 00155 trace.lgTrDiff = true; 00156 00157 if( p.nMatch(" DR ") ) 00158 trace.lgDrBug = true; 00159 00160 if( p.nMatch("EDEN") || p.nMatch("ELECTRON") ) 00161 trace.lgNeBug = true; 00162 00163 if( p.nMatch("GAUN") ) 00164 trace.lgTrGant = true; 00165 00166 if( p.nMatch("GRAI") ) 00167 trace.lgDustBug = true; 00168 00169 if( p.nMatch("HEAV") ) 00170 trace.lgHeavyBug = true; 00171 00172 if( p.nMatch("HEAT") ) 00173 trace.lgHeatBug = true; 00174 00175 /* trace helium, but not h-like or he-like */ 00176 if( p.nMatch("HELI") && !p.nMatch("H-LI") && !p.nMatch("HE-L") ) 00177 trace.lgHeBug = true; 00178 00179 /* the simple trace hydrogen command */ 00180 if( p.nMatch("HYDR") && !p.nMatch("H-LI")) 00181 { 00182 trace.lgHBug = true; 00183 trace.lgIsoTraceFull[ipH_LIKE] = false; 00184 /* this says which element, on the C scale (H=0), to trace */ 00185 trace.ipIsoTrace[ipH_LIKE] = 0; 00186 } 00187 00188 if( p.nMatch("IRON") ) 00189 trace.lgFeBug = true; 00190 00191 if( p.nMatch("LEVELN") ) 00192 trace.lgTrLevN = true; 00193 00194 if( p.nMatch("LINE") ) 00195 trace.lgTrLine = true; 00196 00197 if( p.nMatch("NEON") ) 00198 trace.lgNeonBug = true; 00199 00200 00201 /* turn on molecular trace - either CO or H2, or both, 00202 * keyword can be CMOLE or HMOLE depending on what is needed */ 00203 if( p.nMatch("HMOL") ) 00204 { 00205 /* H2 network */ 00206 trace.lgTr_H2_Mole = true; 00207 } 00208 if( p.nMatch("CMOL" ) ) 00209 { 00210 /* CO network */ 00211 trace.lgTr_CO_Mole = true; 00212 } 00213 if( p.nMatch(" MOLE") ) 00214 { 00215 /* turn them both on */ 00216 trace.lgTr_CO_Mole = true; 00217 trace.lgTr_H2_Mole = true; 00218 } 00219 00220 /* trace pointers */ 00221 if( p.nMatch("POIN") ) 00222 trace.lgPointBug = true; 00223 00224 /* following two are optical, optimize */ 00225 if( p.nMatch("OPTIC") ) 00226 trace.lgOptcBug = true; 00227 00228 if( p.nMatch("OPTIM") ) 00229 trace.lgTrOptm = true; 00230 00231 if( p.nMatch(" OTS") ) 00232 trace.lgOTSBug = true; 00233 00234 if( p.nMatch("SECO") && p.nMatch("IONI") ) 00235 /* secondary ionization */ 00236 trace.lgSecIon = true; 00237 00238 if( p.nMatch("THRE") ) 00239 trace.lgTrace3Bod = true; 00240 00241 /* two photon emission, spontaneous and induced */ 00242 if( p.nMatch(" TWO") ) 00243 trace.lgBug2nu = true; 00244 00245 /* wind geometry */ 00246 if( p.nMatch("WIND") ) 00247 trace.lgWind = true; 00248 00249 /* falling through is fine - just turn on minimal trace */ 00250 return; 00251 }