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-2022 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 
13 {
14  DEBUG_ENTRY( "ParseMetal()" );
15 
16  /* parse the metals command */
17  abund.lgAbnSolar = false;
18  if( p.nMatch("DEPL") )
19  {
20  realnum scale = (realnum)p.FFmtRead();
21  if( !p.lgEOL() )
22  {
23  fprintf( ioQQQ, "\nPROBLEM -- No number allowed with 'metals deplete'"
24  " but found '%g'\n", scale );
26  }
27 
28  /* keyword depletion is present
29  * deplete by set of scale factors */
30  abund.lgDepln = true;
31  for( long int i=0; i < LIMELM; i++ )
32  {
33  abund.depset[i] = abund.Depletion[i];
34  }
35  }
36  else
37  {
38  /* metal depletion factor, if negative then it is the log */
40  if( p.lgEOL() )
41  p.NoNumb("the depletion factor");
42 
43  /* sort out whether log */
44  bool lgLogOn = false;
45  if( p.nMatch(" LOG") )
46  {
47  lgLogOn = true;
48  }
49  else if( p.nMatch("LINE") )
50  {
51  lgLogOn = false;
52  }
53 
54  double dmlog;
55  if( abund.ScaleMetals <= 0. || lgLogOn )
56  {
57  dmlog = abund.ScaleMetals;
59  }
60  else
61  {
62  dmlog = log10(abund.ScaleMetals);
63  }
64 
65  /* option to vary grain abundance as well */
66  bool lgGrains;
67  if( p.nMatch("GRAI") )
68  {
69  lgGrains = true;
71  }
72  else
73  {
74  lgGrains = false;
75  gv.GrainMetal = 1.;
76  }
77 
78  /* vary option */
79  if( optimize.lgVarOn )
80  {
81  strcpy( optimize.chVarFmt[optimize.nparm], "METALS= %f LOG" );
82  if( lgGrains )
83  strcat( optimize.chVarFmt[optimize.nparm], " GRAINS" );
84  /* pointer to where to write */
86  optimize.vparm[0][optimize.nparm] = (realnum)dmlog;
89  ++optimize.nparm;
90  }
91  }
92  return;
93 }
bool nMatch(const char *chKey) const
Definition: parser.h:150
realnum depset[LIMELM]
Definition: abund.h:245
double FFmtRead(void)
Definition: parser.cpp:472
double exp10(double x)
Definition: cddefines.h:1368
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:105
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
Definition: parser.h:43
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:482
NORETURN void NoNumb(const char *chDesc) const
Definition: parser.cpp:345
t_optimize optimize
Definition: optimize.cpp:6
realnum vincr[LIMPAR]
Definition: optimize.h:195
const int LIMELM
Definition: cddefines.h:308
#define DEBUG_ENTRY(funcname)
Definition: cddefines.h:723
bool lgDepln
Definition: abund.h:251
realnum GrainMetal
Definition: grainvar.h:510
bool lgEOL(void) const
Definition: parser.h:113
int fprintf(const Output &stream, const char *format,...)
Definition: service.cpp:1121
GrainVar gv
Definition: grainvar.cpp:5
void ParseMetal(Parser &p)
Definition: parse_metal.cpp:12
long int nvarxt[LIMPAR]
Definition: optimize.h:198