cloudy
trunk
source
parse_norm.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
/*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 "
lines_service.h
"
9
10
void
ParseNorm
(
Parser
&p)
11
{
12
char
chLabel[
INPUT_LINE_LENGTH
];
13
14
DEBUG_ENTRY
(
"ParseNorm()"
);
15
16
/* these are flags saying that normalization line has been set */
17
LineSave
.
lgNormSet
=
true
;
18
19
/* >>chng 01 aug 23, insist on a line label */
20
/*
21
* get possible label - must do first since it can contain a number.*/
22
/* is there a double quote on the line? if so then this is a line label */
23
if
( p.
nMatch
(
"\""
) )
24
{
25
26
/* GetQuote does the following -
27
* first copy original version of name into chLabel,
28
* string does include null termination.
29
* set label in OrgCard and second parameter to spaces so
30
* that not picked up below as keyword */
31
p.
GetQuote
( chLabel ,
true
);
32
if
( chLabel[4] !=
'\0'
|| strlen(chLabel) != 4 )
33
{
34
fprintf(
ioQQQ
,
" The label identifying the line on the normalize command must be exactly 4 char long.\n"
);
35
fprintf(
ioQQQ
,
" The command line was as follows:\n %s\n"
,
input
.
chCardSav
[
input
.
nRead
] );
36
fprintf(
ioQQQ
,
" The label I found was: \"%s\", where were not 4 characters between the quotes.\n"
, chLabel );
37
fprintf(
ioQQQ
,
"Sorry.\n"
);
38
cdEXIT
(
EXIT_FAILURE
);
39
}
40
41
/* copy first four char of label into caps, and null terminate*/
42
cap4
(
LineSave
.
chNormLab
, chLabel);
43
}
44
else
45
{
46
fprintf(
ioQQQ
,
"The normalize command does not have a valid line.\n"
);
47
fprintf(
ioQQQ
,
"A 4 char long line label must also be specified, between double quotes, like \"H 1\" 4861.\n"
);
48
fprintf(
ioQQQ
,
"Sorry.\n"
);
49
cdEXIT
(
EXIT_FAILURE
);
50
}
51
52
/* normalise lines to this rather than h-b, sec number is scale factor */
53
LineSave
.
WavLNorm
= (
realnum
)p.
getWave
();
54
55
if
(
LineSave
.
WavLNorm
< 0 )
56
{
57
fprintf(
ioQQQ
,
"A negative wavelength does not make sense to me.\n"
);
58
fprintf(
ioQQQ
,
"Sorry.\n"
);
59
cdEXIT
(
EXIT_FAILURE
);
60
}
61
62
/* get the error assocated with the 4 significant figures that are visible,
63
* wavelength of 0 (a continuum) has error of zero */
64
LineSave
.
errorwave
=
WavlenErrorGet
(
LineSave
.
WavLNorm
);
65
66
LineSave
.
ScaleNormLine
= p.
FFmtRead
();
67
68
if
( p.
lgEOL
() )
69
LineSave
.
ScaleNormLine
= 1.;
70
71
/* confirm that scale factor is positive */
72
if
(
LineSave
.
ScaleNormLine
<= 0. )
73
{
74
fprintf(
ioQQQ
,
" The scale factor for relative intensities must be greater than zero.\n"
);
75
fprintf(
ioQQQ
,
"Sorry.\n"
);
76
cdEXIT
(
EXIT_FAILURE
);
77
}
78
return
;
79
}
ParseNorm
void ParseNorm(Parser &p)
Definition:
parse_norm.cpp:10
Parser::nMatch
bool nMatch(const char *chKey) const
Definition:
parser.h:135
lines.h
Parser::FFmtRead
double FFmtRead(void)
Definition:
parser.cpp:353
t_LineSave::lgNormSet
bool lgNormSet
Definition:
lines.h:100
t_input::nRead
long int nRead
Definition:
input.h:49
ioQQQ
FILE * ioQQQ
Definition:
cddefines.cpp:7
realnum
float realnum
Definition:
cddefines.h:103
t_input::chCardSav
char chCardSav[NKRD][INPUT_LINE_LENGTH]
Definition:
input.h:32
t_LineSave::WavLNorm
realnum WavLNorm
Definition:
lines.h:84
lines_service.h
Parser::GetQuote
int GetQuote(char *chLabel, bool lgABORT)
Definition:
parser.h:209
input
t_input input
Definition:
input.cpp:12
Parser::getWave
double getWave()
Definition:
parser.cpp:260
LineSave
t_LineSave LineSave
Definition:
lines.cpp:5
EXIT_FAILURE
#define EXIT_FAILURE
Definition:
cddefines.h:140
Parser
Definition:
parser.h:31
cap4
void cap4(char *chCAP, const char *chLab)
Definition:
service.cpp:240
cddefines.h
t_LineSave::ScaleNormLine
double ScaleNormLine
Definition:
lines.h:94
cdEXIT
#define cdEXIT(FAIL)
Definition:
cddefines.h:434
Parser::lgEOL
bool lgEOL(void) const
Definition:
parser.h:98
WavlenErrorGet
realnum WavlenErrorGet(realnum wavelength)
Definition:
lines_service.cpp:182
INPUT_LINE_LENGTH
const int INPUT_LINE_LENGTH
Definition:
cddefines.h:254
parser.h
t_LineSave::errorwave
realnum errorwave
Definition:
lines.h:87
t_LineSave::chNormLab
char chNormLab[5]
Definition:
lines.h:97
input.h
DEBUG_ENTRY
#define DEBUG_ENTRY(funcname)
Definition:
cddefines.h:684
Generated by
1.8.17