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 /*ParseRangeOption parse the range option on the luminosity command */ 00004 #include "cddefines.h" 00005 #include "physconst.h" 00006 #include "rfield.h" 00007 #include "parse.h" 00008 00009 void ParseRangeOption( 00010 /* the number of continuum luminosity sources entered, on the c scale */ 00011 long int nqh, 00012 /* the input line image */ 00013 char *chCard) 00014 { 00015 bool lgEOL; 00016 long int i; 00017 double p1, 00018 p2; 00019 00020 DEBUG_ENTRY( "ParseRangeOption()" ); 00021 00022 if( nMatch("TOTA",chCard) ) 00023 { 00024 rfield.range[nqh][0] = rfield.emm; 00025 rfield.range[nqh][1] = rfield.egamry; 00026 } 00027 else if( nMatch("RANG",chCard) ) 00028 { 00029 i = 1; 00030 /* first call return the luminosity on the card, ignore it */ 00031 p1 = FFmtRead(chCard,&i,INPUT_LINE_LENGTH,&lgEOL); 00032 00033 /* this should be the lower limit */ 00034 p1 = FFmtRead(chCard,&i,INPUT_LINE_LENGTH,&lgEOL); 00035 if( p1 == 0. ) 00036 p1 = rfield.emm; 00037 00038 p2 = FFmtRead(chCard,&i,INPUT_LINE_LENGTH,&lgEOL); 00039 /* no third numer on card then go all the way to gamma ray */ 00040 if( p2 == 0. ) 00041 p2 = rfield.egamry; 00042 00043 /* option to enter log if first energy is neg */ 00044 if( p1 < 0. || nMatch(" LOG",chCard) ) 00045 { 00046 p1 = pow(10.,p1); 00047 /* second number may not have been entered */ 00048 if( !lgEOL ) 00049 p2 = pow(10.,p2); 00050 } 00051 00052 /* make sure that energies are within array bounds */ 00053 rfield.range[nqh][0] = MAX2((realnum)p1,rfield.emm); 00054 rfield.range[nqh][1] = MIN2((realnum)p2,rfield.egamry); 00055 if( rfield.range[nqh][0] > rfield.range[nqh][1] ) 00056 { 00057 fprintf( ioQQQ, " Range MUST be in increasing order - sorry.\n" ); 00058 cdEXIT(EXIT_FAILURE); 00059 } 00060 } 00061 else 00062 { 00063 /* range not specified, use default - total ionizing field 00064 * >>chng 96 dec 18, from 1.001 to 1 Ryd for H mass nuc */ 00065 rfield.range[nqh][0] = HIONPOT; 00066 rfield.range[nqh][1] = rfield.egamry; 00067 } 00068 return; 00069 }