cloudy trunk
Loading...
Searching...
No Matches
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
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;
25 abund.ScaleMetals = (realnum)p.FFmtRead();
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;
66 abund.ScaleMetals = (realnum)pow((realnum)10.f,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;
77 gv.GrainMetal = abund.ScaleMetals;
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 */
92 optimize.nvfpnt[optimize.nparm] = input.nRead;
93 optimize.vparm[0][optimize.nparm] = (realnum)dmlog;
94 optimize.vincr[optimize.nparm] = 0.5;
95 optimize.nvarxt[optimize.nparm] = 1;
96 ++optimize.nparm;
97 }
98 return;
99}
t_abund abund
Definition abund.cpp:5
t_called called
Definition called.cpp:5
FILE * ioQQQ
Definition cddefines.cpp:7
const int LIMELM
Definition cddefines.h:258
#define EXIT_FAILURE
Definition cddefines.h:140
#define cdEXIT(FAIL)
Definition cddefines.h:434
float realnum
Definition cddefines.h:103
#define DEBUG_ENTRY(funcname)
Definition cddefines.h:684
double FFmtRead(void)
Definition parser.cpp:353
bool nMatch(const char *chKey) const
Definition parser.h:135
bool lgEOL(void) const
Definition parser.h:98
int PrintLine(FILE *fp) const
Definition parser.h:204
GrainVar gv
Definition grainvar.cpp:5
t_input input
Definition input.cpp:12
t_optimize optimize
Definition optimize.cpp:5
void ParseMetal(Parser &p)