cloudy  trunk
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
parse_plot.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 /*ParsePlot parse the plot command */
4 /*ParsePlotRangeOption parse range from plot command */
5 #include "cddefines.h"
6 #include "plot.h"
7 #include "rfield.h"
8 #include "parse.h"
9 
10 /*ParsePlotRangeOption parse range from plot command, located below */
11 STATIC void ParsePlotRangeOption(char*);
12 
13 /*ParsePlotRangeContin parse range option for continuum on map command, located below */
14 STATIC void ParsePlotRangeContin(char*);
15 
16 void ParsePlot(char *chCard )
17 {
18 
19  DEBUG_ENTRY( "ParsePlot()" );
20 
21  /* total number of plots so far */
22  plotCom.nplot += 1;
23 
24  /* plots are turned on */
25  plotCom.lgPlotON = true;
26 
27  /* make sure we have not hit the limit, the dimension of variables in plot.h */
28  if( plotCom.nplot > NDPLOT )
29  {
30  fprintf( ioQQQ,
31  " Too many plots; the limit is%3ld This one ignored.\n",
32  NDPLOT );
34  }
35 
36  if( nMatch(" MAP",chCard) )
37  {
38  /* option to make plot of heating - cooling map */
39  strcpy( plotCom.chPType[plotCom.nplot-1], " MAP" );
40  }
41 
42  else if( nMatch("CONT",chCard) )
43  {
44  /* option to make "raw" plot, in internal units */
45  if( nMatch(" RAW",chCard) )
46  {
47  strcpy( plotCom.chPType[plotCom.nplot-1], "CRAW" );
48  /* option to make diffuse continuum plot */
49  }
50  else if( nMatch("DIFF",chCard) )
51  {
52  strcpy( plotCom.chPType[plotCom.nplot-1], "DIFF" );
53  /* this is emitted continuum */
54  }
55  else if( nMatch("EMIT",chCard) )
56  {
57  strcpy( plotCom.chPType[plotCom.nplot-1], "EMIT" );
58  /* this is outward and attenuated continuum */
59  }
60  else if( nMatch("OUTW",chCard) )
61  {
62  strcpy( plotCom.chPType[plotCom.nplot-1], "OUTW" );
63  /* this is reflected continuum */
64  }
65  else if( nMatch("REFL",chCard) )
66  {
67  strcpy( plotCom.chPType[plotCom.nplot-1], "REFL" );
68  /* this is continuum in photons */
69  }
70  else if( nMatch("PHOT",chCard) )
71  {
72  strcpy( plotCom.chPType[plotCom.nplot-1], "CPHT" );
73  }
74  else
75  {
76  strcpy( plotCom.chPType[plotCom.nplot-1], "CONT" );
77  }
78  }
79 
80  else if( nMatch("OPAC",chCard) )
81  {
82  if( nMatch("ABSO",chCard) )
83  {
84  /* plot absorption opacity */
85  strcpy( plotCom.chPType[plotCom.nplot-1], "OPAA" );
86  }
87  else if( nMatch("SCAT",chCard) )
88  {
89  /* plot scattering opacity */
90  strcpy( plotCom.chPType[plotCom.nplot-1], "OPAS" );
91  }
92  else if( nMatch("TOTA",chCard) )
93  {
94  /* plot total opacity */
95  strcpy( plotCom.chPType[plotCom.nplot-1], "OPAT" );
96  }
97  else
98  {
99  /* plot total opacity for default */
100  strcpy( plotCom.chPType[plotCom.nplot-1], "OPAT" );
101  }
102  }
103  else
104  {
105  fprintf( ioQQQ, " The second keyword on the PLOT command must be CONTINUUM, _MAP, or OPACITY.\n" );
106  cdEXIT(EXIT_FAILURE);
107  }
108 
109  /* option to turn on trace of plot logic */
110  if( nMatch("TRAC",chCard) )
111  {
112  plotCom.lgPltTrace[plotCom.nplot-1] = true;
113  }
114  else
115  {
116  plotCom.lgPltTrace[plotCom.nplot-1] = false;
117  }
118 
119  /* option to set min and max x-axis */
120  if( strcmp(plotCom.chPType[plotCom.nplot-1]," MAP") == 0 )
121  {
122  /* this will be map of cooling and heating vs temp */
123  ParsePlotRangeOption(chCard);
124  }
125  else
126  {
127  /* continuum map */
128  ParsePlotRangeContin(chCard);
129  }
130 
131  return;
132 }
133 
134 /*ParsePlotRangeOption parse range from plot command */
135 STATIC void ParsePlotRangeOption(char *chCard )
136 {
137  bool lgEOL,
138  lgLogOn;
139  long int i;
140  realnum a;
141 
142  DEBUG_ENTRY( "ParsePlotRangeOption()" );
143 
144  i = 4;
145  /* pltxmn is min for x axis of plot */
146  plotCom.pltxmn[plotCom.nplot-1] = (realnum)FFmtRead(chCard,&i,INPUT_LINE_LENGTH,&lgEOL);
147 
148  if( !nMatch("RANG",chCard) )
149  {
150  /* no lines were enterd, so use default temperature limits */
151  plotCom.pltxmn[plotCom.nplot-1] = 1.;
152  plotCom.pltxmx[plotCom.nplot-1] = 9.;
153  lgLogOn = true;
154  }
155  else if( lgEOL )
156  {
157  /* no lines were enterd, so use default temperature limits */
158  plotCom.pltxmn[plotCom.nplot-1] = 1.;
159  plotCom.pltxmx[plotCom.nplot-1] = 9.;
160  lgLogOn = true;
161  }
162  else
163  {
164  /* number entered, now interprete it */
165  if( plotCom.pltxmn[plotCom.nplot-1] <= 10. )
166  {
167  lgLogOn = true;
168  }
169  else
170  {
171  lgLogOn = false;
172  }
173  /* linear option for temperature */
174  if( nMatch("LINE",chCard) )
175  lgLogOn = false;
176  /* lower temp was entered, now how about upper temp */
177  plotCom.pltxmx[plotCom.nplot-1] = (realnum)FFmtRead(chCard,&i,INPUT_LINE_LENGTH,&lgEOL);
178  if( lgEOL )
179  {
180  if( lgLogOn )
181  {
182  plotCom.pltxmx[plotCom.nplot-1] = 9.;
183  }
184  else
185  {
186  plotCom.pltxmx[plotCom.nplot-1] = 1e9;
187  }
188  }
189  else
190  {
191  /* second number was entered, check for sanity */
193  {
194  fprintf( ioQQQ,
195  " The second (maximum) temperature for the map is%10.2e, but this is less than the first (minimum) temperature,%10.2e\n",
197  fprintf( ioQQQ, " HELP! I am confused!!\n" );
198  cdEXIT(EXIT_FAILURE);
199  }
200  }
201  }
202 
203  /* now force to be log */
204  if( !lgLogOn )
205  {
206  if( plotCom.pltxmx[plotCom.nplot-1] <= 0. || plotCom.pltxmn[plotCom.nplot-1] <=
207  0. )
208  {
209  fprintf( ioQQQ,
210  " Limits for temperature are negative. This is impossible. Sorry.\n" );
211  cdEXIT(EXIT_FAILURE);
212  }
215  }
216 
217  /* check that min is less than max */
219  {
220  fprintf( ioQQQ, " Upper and lower plot boundaries are equal.\n" );
221  cdEXIT(EXIT_FAILURE);
222  }
224  {
225  a = plotCom.pltxmx[plotCom.nplot-1];
227  plotCom.pltxmn[plotCom.nplot-1] = a;
228  }
229 
230  return;
231 }
232 
233 /*ParsePlotRangeContin set range for map to parse range option on map command */
234 STATIC void ParsePlotRangeContin(char *chCard )
235 {
236  bool lgEOL,
237  lgLogOn;
238  long int i;
239  realnum a;
240 
241  DEBUG_ENTRY( "ParsePlotRangeContin()" );
242 
243  i = 4;
244  plotCom.pltxmn[plotCom.nplot-1] = (realnum)FFmtRead(chCard,&i,INPUT_LINE_LENGTH,&lgEOL);
245 
246  if( !nMatch("RANG",chCard) )
247  {
248  /* no numbers on line, just set default limits to energy array */
251  lgLogOn = true;
252  }
253  else if( lgEOL )
254  {
255  /* no numbers on line, just set default limits to energy array */
258  lgLogOn = true;
259  }
260  else
261  {
262  /* lower limit entered, now interprete it */
263  if( plotCom.pltxmn[plotCom.nplot-1] < 0. )
264  {
265  lgLogOn = true;
266  }
267  else if( plotCom.pltxmn[plotCom.nplot-1] == 0.0 )
268  {
269  /* option for first number to be zero, lower edge of array */
270  lgLogOn = false;
272  }
273  else
274  {
275  /* a positive number was entered */
276  lgLogOn = false;
277  }
278 
279  /* now look at upper limit */
280  plotCom.pltxmx[plotCom.nplot-1] = (realnum)FFmtRead(chCard,&i,INPUT_LINE_LENGTH,&lgEOL);
281  if( lgEOL || plotCom.pltxmx[plotCom.nplot-1] == 0.0 )
282  {
283  /* option for second number to be omitted or zero */
284  if( lgLogOn )
285  {
287  }
288  else
289  {
291  }
292  }
293  }
294 
295  /* now force to be log */
296  if( !lgLogOn )
297  {
300  }
301 
302  /* check that min is less than max */
304  {
305  fprintf( ioQQQ, " Upper and lower plot boundaries are equal.\n" );
306  cdEXIT(EXIT_FAILURE);
307  }
309  {
310  a = plotCom.pltxmx[plotCom.nplot-1];
312  plotCom.pltxmn[plotCom.nplot-1] = a;
313  }
314 
315  return;
316 }

Generated for cloudy by doxygen 1.8.3.1