/*ParseSet scan parameters off SET command */ #include #include "cddefines.h" #include "physconst.h" #include "zonecnt.h" #include "kshllenr.h" #include "colimt.h" #include "path.h" #include "flxfnt.h" #include "mappar.h" #include "sdrmin.h" #include "elecden.h" #include "secondaries.h" #include "bounds.h" #include "punchskip.h" #include "numderiv.h" #include "didz.h" #include "stopcalc.h" #include "opac.h" #include "peimbt.h" #include "trimstg.h" #include "phfiton.h" #include "wkhtcl.h" #include "hctmin.h" #include "plwidth.h" #include "testit.h" #include "physok.h" #include "typmatrx.h" #include "ffmtread.h" #include "lgmatch.h" #include "getquote.h" #include "nonumb.h" #include "parse.h" void ParseSet(char *chCard ) { int lgEOL ; long int i, ip; char *chEnd; # ifdef DEBUG_FUN fputs( "<+>ParseSet()\n", debug_fp ); # endif /* commands to set certain variables, "SET XXX=" */ if( lgMatch("CHAR",chCard) ) { /* set log of minimum charge transfer rate for high ions and H * default of 1.92e-10 set in zero */ i = 5; HCTMin.HCTAlex = (float)FFmtRead(chCard,&i,76,&lgEOL); if( lgEOL ) { NoNumb(chCard); } if( HCTMin.HCTAlex < 0. ) { HCTMin.HCTAlex = (float)pow(10.,HCTMin.HCTAlex); } } else if( lgMatch("CSUP",chCard) ) { /* force secondary ionization rate, log entered */ i = 5; Secondaries.SetCsupra = (float)FFmtRead(chCard,&i,76,&lgEOL); Secondaries.lgCSetOn = TRUE; if( lgEOL ) { NoNumb(chCard); } Secondaries.SetCsupra = (float)pow(10.,Secondaries.SetCsupra); } else if( lgMatch("DIDZ",chCard) ) { /* set parameter to do with choice of dr; * par is the largest optical depth to allow in the zone. * >>chng 96 jan 8 had been two numbers - dtau1 removed */ i = 5; didz.drChange = (float)FFmtRead(chCard,&i,76,&lgEOL); if( didz.drChange <= 0. ) { didz.drChange = (float)pow(10.,didz.drChange); } if( lgEOL ) { NoNumb(chCard); } } else if( lgMatch("EDEN",chCard) ) { i = 5; /* set the electron density */ ElecDen.EdenSet = (float)pow(10.,FFmtRead(chCard,&i,76,&lgEOL)); /* warn that this model is meaningless */ physok.lgPhysOK = FALSE; } else if( lgMatch("COLI",chCard) ) { /* set maximum CO/C ratio */ i = 5; colimt.COLimit = (float)FFmtRead(chCard,&i,76,&lgEOL); if( lgEOL ) { NoNumb(chCard); } if( colimt.COLimit < 0. ) { colimt.COLimit = (float)pow(10.,colimt.COLimit); } } else if( lgMatch(" DR ",chCard) ) { /* set zone thickness by forcing drmax and drmin */ i = 5; sdrminCom.sdrmax = (float)pow(10.,FFmtRead(chCard,&i,76,&lgEOL)); if( lgEOL ) { NoNumb(chCard); } sdrminCom.sdrmin = sdrminCom.sdrmax; } else if( lgMatch("DRMA",chCard) ) { /* set maximum zone thickness */ i = 5; sdrminCom.sdrmax = (float)pow(10.,FFmtRead(chCard,&i,76,&lgEOL)); if( lgEOL ) { NoNumb(chCard); } } else if( lgMatch("DRMI",chCard) ) { /* set minimum zone thickness */ i = 5; sdrminCom.sdrmin = (float)pow(10.,FFmtRead(chCard,&i,76,&lgEOL)); if( lgEOL ) { NoNumb(chCard); } sdrminCom.lgSMinON = TRUE; } else if( lgMatch("FLXF",chCard) ) { /* faintest continuum flux to consider */ i = 5; flxfnt.FluxFaint = (float)FFmtRead(chCard,&i,76,&lgEOL); if( lgEOL ) { NoNumb(chCard); } if( flxfnt.FluxFaint < 0. ) { flxfnt.FluxFaint = (float)pow(10.,flxfnt.FluxFaint); } } else if( lgMatch("LOWE",chCard) ) { /* set lowest te to constant */ i = 5; StopCalc.TeLowest = (float)FFmtRead(chCard,&i,76,&lgEOL); /* linear option */ if( StopCalc.TeLowest <= 10. && !lgMatch("LINE",chCard) ) { StopCalc.TeLowest = (float)pow(10.,StopCalc.TeLowest); } if( lgEOL ) { NoNumb(chCard); } if( StopCalc.TeLowest < 2.8 ) { fprintf( ioQQQ, " TE < 3K, reset to 2.8K.\n" ); StopCalc.TeLowest = 2.8f; } } else if( lgMatch("MATR",chCard) ) { /* which matrix inversion routine to use */ if( lgMatch("MATI",chCard) ) { /* this is matin1 */ strcpy( TypMatrx.chMatrix, "matin1 " ); } else if( lgMatch("LINP",chCard) ) { /* linpack is the default, set in zero.c */ strcpy( TypMatrx.chMatrix, "linpack" ); } else if( lgMatch("BEVI",chCard) ) { /* Bevington matinv */ strcpy( TypMatrx.chMatrix, "Bevingt" ); } else if( lgMatch("VECL",chCard) ) { /* veclib, not currently implimented */ strcpy( TypMatrx.chMatrix, "veclib " ); } else { fprintf( ioQQQ, " The matrix inversion routines I know about are LINPACK, VECLIB, and MATIN1.\n" ); puts( "[Stop in getset]" ); exit(1); } } else if( lgMatch("NERR",chCard) ) { /* keyword is actually EdenError * set telerance in eden match */ i = 5; ElecDen.EdenError = (float)FFmtRead(chCard,&i,76,&lgEOL); if( lgEOL ) { NoNumb(chCard); } if( ElecDen.EdenError < 0. ) { ElecDen.EdenError = (float)pow(10.,ElecDen.EdenError); } } else if( lgMatch("TEST",chCard) ) { /* set flag saying to turn on some test */ Testit.lgTestOn = TRUE; } else if( lgMatch("TRIM",chCard) ) { /* set trim upper or lower, for ionization stage trimming * in routine TrimStage */ i = 5; if( lgMatch("UPPE",chCard) ) { /* set trim upper */ trimstg.trimhi = pow(10.,FFmtRead(chCard,&i,76,&lgEOL)); } else if( lgMatch("LOWE",chCard) ) { /* set trim lower */ trimstg.trimlo = pow(10.,FFmtRead(chCard,&i,76,&lgEOL)); } else if( lgMatch("SMAL",chCard) ) { /* set small limits to both upper and lower limit*/ trimstg.trimlo = SMALLFLOAT; trimstg.trimhi = SMALLFLOAT; lgEOL = FALSE; } else { /* set trim upper */ trimstg.trimhi = pow(10.,FFmtRead(chCard,&i,76,&lgEOL)); /* set trim lower to same number */ trimstg.trimlo = trimstg.trimhi; } if( lgEOL ) { NoNumb(chCard); } if( trimstg.trimlo >= 1. || trimstg.trimhi >= 1. ) { fprintf( ioQQQ, " number must be negative since log\n" ); puts( "[Stop in getset]" ); exit(1); } } else if( lgMatch("SKIP",chCard) ) { /* skip punch command, for punching every n't point */ i = 5; PunchSkip.ncPunchSkip = (long)FFmtRead(chCard,&i,76,&lgEOL); if( lgEOL ) { NoNumb(chCard); } } else if( lgMatch("EAKH",chCard) ) { /* set WeakHeatCool, threshold on punch heating and cooling, default 0.05 */ i = 5; WkHtCl.WeakHeatCool = (float)FFmtRead(chCard,&i,76,&lgEOL); if( lgEOL ) { NoNumb(chCard); } if( WkHtCl.WeakHeatCool < 0. ) { WkHtCl.WeakHeatCool = (float)pow(10.,WkHtCl.WeakHeatCool); } } else if( lgMatch("KSHE",chCard) ) { /* upper limit to opacities for k-shell ionizaiton */ i = 5; KshllEnr.EnergyKshell = (float)FFmtRead(chCard,&i,76,&lgEOL); if( lgEOL ) { NoNumb(chCard); } if( KshllEnr.EnergyKshell == 0. ) { /* arg of 0 causes upper limit to energy array */ KshllEnr.EnergyKshell = bounds.egamry; } else if( KshllEnr.EnergyKshell < 194. ) { fprintf( ioQQQ, " k-shell energy must be greater than 194 Ryd\n" ); puts( "[Stop in getset]" ); exit(1); } } else if( lgMatch("NEGO",chCard) ) { /* punch negative opacities if they occur, set negopac */ opac.lgNegOpacIO = TRUE; } else if( lgMatch("NEND",chCard) ) { /* default limit to number of zones to be computed * only do this if nend is NOT currently left at its default * nend is set to nEndDflt in routine zero * this command only has effect if stop zone not entered */ if( ZoneCnt.lgEndDflt ) { i = 5; ZoneCnt.nEndDflt = (long)FFmtRead(chCard,&i,76,&lgEOL); ZoneCnt.lgEndDflt = FALSE; if( lgEOL ) { NoNumb(chCard); } for( i=0; i < ITRDIM; i++ ) { ZoneCnt.nend[i] = ZoneCnt.nEndDflt; } } } else if( lgMatch("TSQD",chCard) ) { /* upper limit for highest density considered in the * Peimbert-style t^2 section of the printout */ i = 5; peimbt.tsqden = (float)FFmtRead(chCard,&i,76,&lgEOL); if( lgEOL ) { NoNumb(chCard); } peimbt.tsqden = (float)pow(10.,peimbt.tsqden); } else if( lgMatch("NMAP",chCard) ) { /* how many steps in plot or punch of heating-cooling map */ i = 5; MapPar.nMapStep = (long)FFmtRead(chCard,&i,76,&lgEOL); if( lgEOL ) { NoNumb(chCard); } } else if( lgMatch("NUME",chCard) && lgMatch("DERI",chCard) ) { /* this is an option to use numerical derivatives for heating and cooling */ NumDeriv.lgNumDeriv = TRUE; } /* set path for certain files */ else if( lgMatch("PATH",chCard) ) { /* set path for picking up files * format is for path to be within double quotes */ lgDataPathSet = TRUE; /* * get any string within double quotes, and return it as * null terminated string to chDataPath * also sets name in OrgCard and chCard to blanks so that * do not trigger off it later */ GetQuote( chDataPath , chCard ); /* make sure path ends with proper end of line for unix, dos, or vms * * do nothing in any of these cases */ /* find end of string, null char */ chEnd = strchr( chDataPath ,'\0' ); if( chEnd==NULL ) { fprintf( ioQQQ, " strchr returned NULL in getset\n" ); puts( "[Stop in getset]" ); exit(1); } /* set pointer to last valid char */ --chEnd; /* now see what this char is */ if( (*chEnd != '/' && *chEnd != ']') && *chEnd != '\\' ) { /* string is not ended properly, we will have to do it */ /* find which character to end with since none set above * * there must have been something within the string to indicate * what type of system we are on */ if(strchr( chDataPath , '/' ) != NULL ) { /* there was a forward slash somewhere, so cat another to the end */ strcat( chDataPath , "/" ); } else if( strchr( chDataPath , '\\' ) != NULL ) { /* there was a backward slash somewhere, so cat another to the end */ strcat( chDataPath , "\\" ); } else if( strchr( chDataPath , '[' ) != NULL ) { /* there was a [ somewhere, so cat ] to the end */ /* this should work on a vms machine, but I have not tried it */ strcat( chDataPath , "]" ); } /* if none of the above were triggered then we did not find anything, * just leave it alone, either user knew something we didn't, or will * fail when we try to open the file later on */ } /*printf(" final path is %s \n",chDataPath );*/ } else if( lgMatch("PHFI",chCard) ) { /* which version of PHFIT to use, 1995 or 1996 */ i = 5; ip = (long)FFmtRead(chCard,&i,76,&lgEOL); if( lgEOL ) { NoNumb(chCard); } if( ip == 1995 ) { /* option to go back to old results, pre op */ PhFitOn.lgPhFit = TRUE; } else if( ip == 1996 ) { /* default is to use newer results, including opacity project */ PhFitOn.lgPhFit = FALSE; } else { fprintf( ioQQQ, " Two possible values are 1995 and 1996.\n" ); puts( "[Stop in getset]" ); exit(1); } } else if( lgMatch("WIDT",chCard) ) { /* set line width for contrast in continuum plots */ i = 5; /* units are km/sec */ PLWidth.PunchLWidth = (float)FFmtRead(chCard,&i,76,&lgEOL); /* lgEOL if no number hit, could have been c */ if( lgEOL ) { if( lgMatch(" C " , chCard ) ) { /* no number but __c_, so enter speed of light in km/s */ PLWidth.PunchLWidth = (float)(SPEEDLIGHT/1e5); } else { NoNumb(chCard); } } if( PLWidth.PunchLWidth <= 0. ) { fprintf( ioQQQ, " line width must be greater than zero.\n" ); puts( "[Stop in getset]" ); exit(1); } /* this is the factor that is used to add the lines to the continuum, * 15 converts to cm/s */ PLWidth.PunchLWidth = (float)(SPEEDLIGHT/(PLWidth.PunchLWidth*1e5)); } else { fprintf( ioQQQ, " I didnt recognize a key on this SET line.\n" ); puts( "[Stop in getset]" ); exit(1); } # ifdef DEBUG_FUN fputs( " <->ParseSet()\n", debug_fp ); # endif return; }