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