cloudy  trunk
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
parse_rangeoption.cpp
Go to the documentation of this file.
1 /* This file is part of Cloudy and is copyright (C)1978-2022 by Gary J. Ferland and
2  * others. For conditions of distribution and use see copyright notice in license.txt */
3 /*ParseRangeOption parse the range option on the luminosity command */
4 #include "cddefines.h"
5 #include "rfield.h"
6 #include "parser.h"
7 
9  /* the input line image */
10  Parser &p)
11 {
12  bool lgP1Absent, lgP2Absent;
13  double p1,
14  p2;
15 
16  DEBUG_ENTRY( "ParseRangeOption()" );
17 
18  if( p.nMatch("TOTA") )
19  {
20  rfield.range[p.m_nqh][0] = rfield.emm();
21  rfield.range[p.m_nqh][1] = rfield.egamry();
22  }
23  else if( p.nMatch("RANG") )
24  {
25  p.set_point(0);
26  /* first call return the luminosity on the card, ignore it */
27  (void) p.FFmtRead();
28  (void) p.lgEOL();
29 
30  /* read lower limit and upper limit*/
31  p1 = p.FFmtRead();
32  lgP1Absent = p.lgEOL();
33  p2 = p.FFmtRead();
34  lgP2Absent = p.lgEOL();
35 
36  /* option to enter log if first energy is neg */
37  if( p1 < 0. || p.nMatch(" LOG") )
38  {
39  p1 = exp10(p1);
40  p2 = exp10(p2);
41  }
42 
43  if( lgP1Absent )
44  p1 = rfield.emm();
45  if( lgP2Absent )
46  p2 = rfield.egamry();
47 
48  /* make sure that energies are within array bounds */
49  rfield.range[p.m_nqh][0] = MAX2(p1,rfield.emm());
50  rfield.range[p.m_nqh][1] = MIN2(p2,rfield.egamry());
51  if( rfield.range[p.m_nqh][0] >= rfield.range[p.m_nqh][1] )
52  {
53  fprintf( ioQQQ, " Range MUST be in increasing order - sorry.\n" );
55  }
56  }
57  else
58  {
59  /* range not specified, use default - total ionizing field
60  * >>chng 96 dec 18, from 1.001 to 1 Ryd for H mass nuc */
61  rfield.range[p.m_nqh][0] = HIONPOT;
62  rfield.range[p.m_nqh][1] = rfield.egamry();
63  }
64  return;
65 }
double emm() const
Definition: mesh.h:93
bool nMatch(const char *chKey) const
Definition: parser.h:150
double FFmtRead(void)
Definition: parser.cpp:472
double exp10(double x)
Definition: cddefines.h:1368
long int m_nqh
Definition: parser.h:54
FILE * ioQQQ
Definition: cddefines.cpp:7
#define MIN2(a, b)
Definition: cddefines.h:803
Definition: parser.h:43
void ParseRangeOption(Parser &p)
double range[LIMSPC][2]
Definition: rfield.h:331
void set_point(long int ipnt)
Definition: parser.h:95
t_rfield rfield
Definition: rfield.cpp:9
#define EXIT_FAILURE
Definition: cddefines.h:168
#define cdEXIT(FAIL)
Definition: cddefines.h:482
#define DEBUG_ENTRY(funcname)
Definition: cddefines.h:723
double egamry() const
Definition: mesh.h:97
bool lgEOL(void) const
Definition: parser.h:113
#define MAX2(a, b)
Definition: cddefines.h:824
int fprintf(const Output &stream, const char *format,...)
Definition: service.cpp:1121