cloudy  trunk
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
parse_norm.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 /*ParseNorm parse parameters on the normalize command */
4 #include "cddefines.h"
5 #include "lines.h"
6 #include "input.h"
7 #include "parser.h"
8 #include "service.h"
9 
10 void ParseNorm(Parser &p)
11 {
12  DEBUG_ENTRY( "ParseNorm()" );
13 
14  /* these are flags saying that normalization line has been set */
15  LineSave.lgNormSet = true;
16 
17  /* >>chng 01 aug 23, insist on a line label */
18  /*
19  * get possible label - must do first since it can contain a number.*/
20  /* is there a double quote on the line? if so then this is a line label */
21  if( p.nMatch( "\"" ) )
22  {
23 
24  /* GetQuote does the following -
25  * first copy original version of name into chLabel,
26  * string does include null termination.
27  * set label in OrgCard and second parameter to spaces so
28  * that not picked up below as keyword */
29  string chLabel;
30  if (p.GetQuote( chLabel ))
31  p.StringError();
32  trimTrailingWhiteSpace( chLabel );
33  if( chLabel.length() > NCHLAB-1 )
34  {
35  fprintf( ioQQQ, " The label identifying the line on the normalize command must be no more than %d char long.\n", NCHLAB-1 );
36  fprintf( ioQQQ, " The command line was as follows:\n %s\n", input.chCardSav[input.nRead] );
37  fprintf( ioQQQ, " The label I found was: \"%s\", which has %d characters between the quotes.\n", chLabel.c_str(), (int)chLabel.length() );
38  fprintf( ioQQQ, "Sorry.\n" );
40  }
41 
42  /* copy first four char of label into caps, and null terminate*/
43  strcpy( LineSave.chNormLab, chLabel.c_str());
45  }
46  else
47  {
48  fprintf( ioQQQ, "The normalize command does not have a valid line.\n" );
49  fprintf( ioQQQ, "A 4 char long line label must also be specified, between double quotes, like \"H 1\" 4861.\n" );
50  fprintf( ioQQQ, "Sorry.\n" );
52  }
53 
54  /* normalise lines to this rather than h-b, sec number is scale factor */
56 
57  if( LineSave.WavLNorm < 0 )
58  {
59  fprintf( ioQQQ, "A negative wavelength does not make sense to me.\n" );
60  fprintf( ioQQQ, "Sorry.\n" );
62  }
63 
65 
66  if( p.lgEOL() )
68 
69  /* confirm that scale factor is positive */
70  if( LineSave.ScaleNormLine <= 0. )
71  {
72  fprintf( ioQQQ, " The scale factor for relative intensities must be greater than zero.\n" );
73  fprintf( ioQQQ, "Sorry.\n" );
75  }
76  return;
77 }
bool nMatch(const char *chKey) const
Definition: parser.h:150
double FFmtRead(void)
Definition: parser.cpp:472
t_input input
Definition: input.cpp:12
int GetQuote(string &chLabel)
Definition: parser.cpp:213
long int nRead
Definition: input.h:105
t_LineSave LineSave
Definition: lines.cpp:10
bool lgNormSet
Definition: lines.h:123
FILE * ioQQQ
Definition: cddefines.cpp:7
double getWave()
Definition: parser.cpp:379
Definition: parser.h:43
void trimTrailingWhiteSpace(string &str)
Definition: service.cpp:153
NORETURN void StringError() const
Definition: parser.cpp:203
float realnum
Definition: cddefines.h:124
#define EXIT_FAILURE
Definition: cddefines.h:168
realnum WavLNorm
Definition: lines.h:105
void ParseNorm(Parser &p)
Definition: parse_norm.cpp:10
#define cdEXIT(FAIL)
Definition: cddefines.h:482
char chNormLab[NCHLAB]
Definition: lines.h:120
#define DEBUG_ENTRY(funcname)
Definition: cddefines.h:723
bool lgEOL(void) const
Definition: parser.h:113
const int NCHLAB
Definition: cddefines.h:304
int fprintf(const Output &stream, const char *format,...)
Definition: service.cpp:1121
void caps(char *chCard)
Definition: service.cpp:295
char chCardSav[NKRD][INPUT_LINE_LENGTH]
Definition: input.h:74
double ScaleNormLine
Definition: lines.h:117