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