cloudy  trunk
 All Data Structures 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-2008 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 "parse.h"
11 
12 void ParseMetal(char *chCard )
13 {
14  bool lgEOL,
15  lgGrains,
16  lgLogOn;
17  long int i;
18  double dmlog;
19 
20  DEBUG_ENTRY( "ParseMetal()" );
21 
22  /* parse the metals command */
23 
24  /* metal depletion factor, if negative then it is the log */
25  i = 5;
26  abund.ScaleMetals = (realnum)FFmtRead(chCard,&i,INPUT_LINE_LENGTH,&lgEOL);
27  if( lgEOL )
28  {
29  if( nMatch("DEPL",chCard) )
30  {
31  /* this option - no numbers on line but keyword depletion is
32  * deplete by set of scale factors */
33  abund.lgDepln = true;
34  for( i=0; i < LIMELM; i++ )
35  {
36  abund.depset[i] = abund.Depletion[i];
37  }
38  abund.ScaleMetals = 1.;
39  return;
40  }
41  else
42  {
43  /* no number, so keyword, punch out */
44  if( !called.lgTalk )
45  {
46  fprintf( ioQQQ, " %80.80s\n", chCard );
47  }
48  fprintf( ioQQQ, " There must be a number on this line. Sorry.\n" );
49  cdEXIT(EXIT_FAILURE);
50  }
51  }
52 
53  /* sort out whether log */
54  lgLogOn = false;
55  if( nMatch(" LOG",chCard) )
56  {
57  lgLogOn = true;
58  }
59  else if( nMatch("LINE",chCard) )
60  {
61  lgLogOn = false;
62  }
63 
64  if( abund.ScaleMetals <= 0. || lgLogOn )
65  {
66  dmlog = abund.ScaleMetals;
68  }
69  else
70  {
71  dmlog = log10(abund.ScaleMetals);
72  }
73 
74  /* option to vary grain abundance as well */
75  if( nMatch("GRAI",chCard) )
76  {
77  lgGrains = true;
79  }
80  else
81  {
82  lgGrains = false;
83  gv.GrainMetal = 1.;
84  }
85 
86  /* vary option */
87  if( optimize.lgVarOn )
88  {
89  if( lgGrains )
90  {
91  strcpy( optimize.chVarFmt[optimize.nparm], "METALS LOG=%f GRAINS" );
92  }
93  else
94  {
95  strcpy( optimize.chVarFmt[optimize.nparm], "METALS LOG=%f" );
96  }
97 
98  /* pointer to where to write */
100  optimize.vparm[0][optimize.nparm] = (realnum)dmlog;
101  optimize.vincr[optimize.nparm] = 0.5;
103  ++optimize.nparm;
104  }
105  return;
106 }

Generated for cloudy by doxygen 1.8.3.1