cloudy  trunk
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
parse_metal.cpp
Go to the documentation of this file.
1 /* This file is part of Cloudy and is copyright (C)1978-2017 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 }
bool nMatch(const char *chKey) const
Definition: parser.h:140
realnum depset[LIMELM]
Definition: abund.h:245
double FFmtRead(void)
Definition: parser.cpp:438
double exp10(double x)
Definition: cddefines.h:1383
t_input input
Definition: input.cpp:12
long int nvfpnt[LIMPAR]
Definition: optimize.h:198
realnum Depletion[LIMELM]
Definition: abund.h:245
long int nRead
Definition: input.h:62
char chVarFmt[LIMPAR][FILENAME_PATH_LENGTH_2]
Definition: optimize.h:267
FILE * ioQQQ
Definition: cddefines.cpp:7
realnum vparm[LIMEXT][LIMPAR]
Definition: optimize.h:192
bool lgTalk
Definition: called.h:12
Definition: parser.h:42
bool lgVarOn
Definition: optimize.h:207
bool lgAbnSolar
Definition: abund.h:202
t_abund abund
Definition: abund.cpp:5
realnum ScaleMetals
Definition: abund.h:254
long int nparm
Definition: optimize.h:204
float realnum
Definition: cddefines.h:124
#define EXIT_FAILURE
Definition: cddefines.h:168
#define cdEXIT(FAIL)
Definition: cddefines.h:484
t_optimize optimize
Definition: optimize.cpp:6
realnum vincr[LIMPAR]
Definition: optimize.h:195
const int LIMELM
Definition: cddefines.h:307
#define DEBUG_ENTRY(funcname)
Definition: cddefines.h:729
bool lgDepln
Definition: abund.h:251
realnum GrainMetal
Definition: grainvar.h:512
bool lgEOL(void) const
Definition: parser.h:103
int fprintf(const Output &stream, const char *format,...)
Definition: service.cpp:1217
int PrintLine(FILE *fp) const
Definition: parser.h:200
GrainVar gv
Definition: grainvar.cpp:5
void ParseMetal(Parser &p)
Definition: parse_metal.cpp:12
long int nvarxt[LIMPAR]
Definition: optimize.h:198
t_called called
Definition: called.cpp:4