cloudy
trunk
|
00001 /* This file is part of Cloudy and is copyright (C)1978-2008 by Gary J. Ferland and 00002 * others. For conditions of distribution and use see copyright notice in license.txt */ 00003 /*ParseIonPar parse the ionization parameter command */ 00004 #include "cddefines.h" 00005 #include "radius.h" 00006 #include "optimize.h" 00007 #include "rfield.h" 00008 #include "input.h" 00009 #include "parse.h" 00010 00011 void ParseIonPar(long int *nqh, 00012 char *chCard, 00013 realnum *ar1) 00014 { 00015 bool lgEOL; 00016 long int i; 00017 00018 DEBUG_ENTRY( "ParseIonPar()" ); 00019 00020 /* check not too many continua */ 00021 if( *nqh >= LIMSPC ) 00022 { 00023 /* too many continua were entered */ 00024 fprintf( ioQQQ, " Too many continua entered; increase LIMSPC\n" ); 00025 cdEXIT(EXIT_FAILURE); 00026 } 00027 00028 /* this is counter for where to start scanning number on line - different 00029 * for XI than for IONIZ */ 00030 i = -1; 00031 /* say that continuum is per unit area, ionization parameter*/ 00032 strcpy( rfield.chRSpec[*nqh], "SQCM" ); 00033 if( chCard[0] == 'I' ) 00034 { 00035 /* this is the usual ionization parameter, U */ 00036 strcpy( rfield.chSpNorm[*nqh], "IONI" ); 00037 i = 5; 00038 } 00039 else if( chCard[0] == 'X' ) 00040 { 00041 /* the X-Ray ionization parameter, xi */ 00042 strcpy( rfield.chSpNorm[*nqh], "IONX" ); 00043 /* >>chng 06 jan 20, had used 5 as in ionization parameter so 00044 * possible to miss beginning of number */ 00045 i = 3; 00046 } 00047 else 00048 { 00049 fprintf(ioQQQ," ParseIonPar hit chCard insanity.\n"); 00050 cdEXIT(EXIT_FAILURE); 00051 } 00052 00053 /* get the ionization parameter*/ 00054 rfield.totpow[*nqh] = FFmtRead(chCard,&i,INPUT_LINE_LENGTH,&lgEOL); 00055 if( lgEOL ) 00056 NoNumb(chCard); 00057 00058 /* check for linear option, if present take log since rfield.totpow[*nqh] 00059 * being log ionization parameter is the default */ 00060 if( nMatch( "LINE" , chCard ) ) 00061 rfield.totpow[*nqh] = log10(rfield.totpow[*nqh]); 00062 00063 /* >>chng 06 mar 22, add time option to vary only some continua with time */ 00064 if( nMatch( "TIME" , chCard ) ) 00065 rfield.lgTimeVary[*nqh] = true; 00066 00067 /* vary option */ 00068 if( optimize.lgVarOn ) 00069 { 00070 if( chCard[0] == 'I' ) 00071 { 00072 /* this is the usual ionization parameter, U */ 00073 strcpy( optimize.chVarFmt[optimize.nparm], "IONIZATION PARAMETER=%f" ); 00074 } 00075 else if( chCard[0] == 'X' ) 00076 { 00077 /* the X-Ray ionization parameter, xi */ 00078 strcpy( optimize.chVarFmt[optimize.nparm], "XI=%f" ); 00079 } 00080 else 00081 { 00082 fprintf( ioQQQ, " Insanity in detecting which ionization parameter.\n" ); 00083 cdEXIT(EXIT_FAILURE); 00084 } 00085 /* pointer to where to write */ 00086 optimize.nvfpnt[optimize.nparm] = input.nRead; 00087 optimize.vparm[0][optimize.nparm] = (realnum)rfield.totpow[*nqh]; 00088 optimize.vincr[optimize.nparm] = 0.5; 00089 optimize.nvarxt[optimize.nparm] = 1; 00090 ++optimize.nparm; 00091 } 00092 00093 /* set R to large value if U specified. */ 00094 /* set radius to very large value if not already set */ 00095 /* >>chng 01 jul 24, from Radius == 0 to this, as per PvH comments */ 00096 if( !radius.lgRadiusKnown ) 00097 { 00098 *ar1 = (realnum)radius.rdfalt; 00099 radius.Radius = pow(10.,radius.rdfalt); 00100 } 00101 /* increment nmber of specifications of continuum intensities, */ 00102 ++*nqh; 00103 return; 00104 }