cloudy  trunk
parse_metal.cpp
Go to the documentation of this file.
1 /* This file is part of Cloudy and is copyright (C)1978-2013 by Gary J. Ferland and
2  * others. For conditions of distribution and use see copyright notice in license.txt */
3 /*ParseMetal parse parameters on metal command */
4 #include "cddefines.h"
5 #include "input.h"
6 #include "optimize.h"
7 #include "grainvar.h"
8 #include "called.h"
9 #include "abund.h"
10 #include "parser.h"
11 
12 void ParseMetal(Parser &p )
13 {
14  bool
15  lgGrains,
16  lgLogOn;
17  double dmlog;
18 
19  DEBUG_ENTRY( "ParseMetal()" );
20 
21  /* parse the metals command */
22 
23  /* metal depletion factor, if negative then it is the log */
24  abund.lgAbnSolar = false;
26  if( p.lgEOL() )
27  {
28  if( p.nMatch("DEPL") )
29  {
30  /* this option - no numbers on line but keyword depletion is
31  * deplete by set of scale factors */
32  abund.lgDepln = true;
33  for( long int i=0; i < LIMELM; i++ )
34  {
35  abund.depset[i] = abund.Depletion[i];
36  }
37  abund.ScaleMetals = 1.;
38  return;
39  }
40  else
41  {
42  /* no number, so keyword, punch out */
43  if( !called.lgTalk )
44  {
45  p.PrintLine( ioQQQ );
46  }
47  fprintf( ioQQQ, " There must be a number on this line. Sorry.\n" );
49  }
50  }
51 
52  /* sort out whether log */
53  lgLogOn = false;
54  if( p.nMatch(" LOG") )
55  {
56  lgLogOn = true;
57  }
58  else if( p.nMatch("LINE") )
59  {
60  lgLogOn = false;
61  }
62 
63  if( abund.ScaleMetals <= 0. || lgLogOn )
64  {
65  dmlog = abund.ScaleMetals;
67  }
68  else
69  {
70  dmlog = log10(abund.ScaleMetals);
71  }
72 
73  /* option to vary grain abundance as well */
74  if( p.nMatch("GRAI") )
75  {
76  lgGrains = true;
78  }
79  else
80  {
81  lgGrains = false;
82  gv.GrainMetal = 1.;
83  }
84 
85  /* vary option */
86  if( optimize.lgVarOn )
87  {
88  strcpy( optimize.chVarFmt[optimize.nparm], "METALS= %f LOG" );
89  if( lgGrains )
90  strcat( optimize.chVarFmt[optimize.nparm], " GRAINS" );
91  /* pointer to where to write */
93  optimize.vparm[0][optimize.nparm] = (realnum)dmlog;
96  ++optimize.nparm;
97  }
98  return;
99 }
Parser::nMatch
bool nMatch(const char *chKey) const
Definition: parser.h:135
t_optimize::vincr
realnum vincr[LIMPAR]
Definition: optimize.h:191
Parser::FFmtRead
double FFmtRead(void)
Definition: parser.cpp:353
t_abund::lgDepln
bool lgDepln
Definition: abund.h:103
t_optimize::nparm
long int nparm
Definition: optimize.h:201
t_input::nRead
long int nRead
Definition: input.h:49
ioQQQ
FILE * ioQQQ
Definition: cddefines.cpp:7
realnum
float realnum
Definition: cddefines.h:103
abund.h
t_optimize::lgVarOn
bool lgVarOn
Definition: optimize.h:203
input
t_input input
Definition: input.cpp:12
optimize
t_optimize optimize
Definition: optimize.cpp:5
t_optimize::vparm
realnum vparm[LIMEXT][LIMPAR]
Definition: optimize.h:188
t_optimize::chVarFmt
char chVarFmt[LIMPAR][FILENAME_PATH_LENGTH_2]
Definition: optimize.h:263
EXIT_FAILURE
#define EXIT_FAILURE
Definition: cddefines.h:140
t_abund::Depletion
realnum Depletion[LIMELM]
Definition: abund.h:97
Parser
Definition: parser.h:31
cddefines.h
optimize.h
t_abund::lgAbnSolar
bool lgAbnSolar
Definition: abund.h:57
t_called::lgTalk
bool lgTalk
Definition: called.h:12
t_abund::depset
realnum depset[LIMELM]
Definition: abund.h:100
t_optimize::nvarxt
long int nvarxt[LIMPAR]
Definition: optimize.h:194
LIMELM
const int LIMELM
Definition: cddefines.h:258
cdEXIT
#define cdEXIT(FAIL)
Definition: cddefines.h:434
Parser::lgEOL
bool lgEOL(void) const
Definition: parser.h:98
abund
t_abund abund
Definition: abund.cpp:5
grainvar.h
parser.h
called
t_called called
Definition: called.cpp:5
t_optimize::nvfpnt
long int nvfpnt[LIMPAR]
Definition: optimize.h:195
gv
GrainVar gv
Definition: grainvar.cpp:5
called.h
GrainVar::GrainMetal
realnum GrainMetal
Definition: grainvar.h:506
Parser::PrintLine
int PrintLine(FILE *fp) const
Definition: parser.h:204
input.h
ParseMetal
void ParseMetal(Parser &p)
Definition: parse_metal.cpp:12
DEBUG_ENTRY
#define DEBUG_ENTRY(funcname)
Definition: cddefines.h:684
t_abund::ScaleMetals
realnum ScaleMetals
Definition: abund.h:106