cloudy
trunk
Loading...
Searching...
No Matches
source
parse_age.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
/*ParseAge parse parameters off the age command */
4
#include "
cddefines.h
"
5
#include "
timesc.h
"
6
#include "
parse.h
"
7
#include "
parser.h
"
8
9
#define NUMBEROF(a) (sizeof(a)/sizeof((a)[0]))
10
11
namespace
Time
{
12
const
double
YEAR
=3.15569e7,
13
MILLENIUM
=
YEAR
*1000.,
14
CENTURY
=
YEAR
*100.,
15
MONTH
=
YEAR
/12.,
16
FORTNIGHT
=(24.*3600.*14.),
17
WEEK
=(24.*3600.*7.),
18
DAY
=(24.*3600.),
19
HOUR
=3600.,
20
MINUTE
=60.,
21
SECOND
=1.;
22
23
KeyAction<UnitConverter>
TimeUnits
[] =
24
{
25
MakeKeyAction
(
"MILL"
,
UnitConverter
(
MILLENIUM
)),
26
MakeKeyAction
(
"CENT"
,
UnitConverter
(
CENTURY
)),
27
MakeKeyAction
(
"YEAR"
,
UnitConverter
(
YEAR
)),
28
MakeKeyAction
(
"MONT"
,
UnitConverter
(
MONTH
)),
29
MakeKeyAction
(
"FORT"
,
UnitConverter
(
FORTNIGHT
)),
30
MakeKeyAction
(
"WEEK"
,
UnitConverter
(
WEEK
)),
31
MakeKeyAction
(
"DAY "
,
UnitConverter
(
DAY
)),
32
MakeKeyAction
(
"HOUR"
,
UnitConverter
(
HOUR
)),
33
MakeKeyAction
(
"MINU"
,
UnitConverter
(
MINUTE
)),
34
MakeKeyAction
(
"SECO"
,
UnitConverter
(
SECOND
)),
35
};
36
37
}
38
39
void
ParseAge
(
Parser
&p )
40
{
41
DEBUG_ENTRY
(
"ParseAge()"
);
42
43
/* set age for the cloud
44
* various timescales will be checked in AgeCheck, called in comment */
45
46
realnum
value = (
realnum
)p.
FFmtRead
();
47
48
/* key " off" turns age off */
49
if
( p.
lgEOL
() && (!p.
nWord
(
" OFF"
)) )
50
{
51
fprintf(
ioQQQ
,
" The age must be on this line.\n"
);
52
cdEXIT
(
EXIT_FAILURE
);
53
}
54
55
/* check if log of age */
56
if
( p.
nWord
(
" LOG"
) )
57
{
58
value = (
realnum
)pow((
realnum
)10.f, value);
59
}
60
61
parserProcess
(p,
Time::TimeUnits
,
NUMBEROF
(
Time::TimeUnits
), &value);
62
63
timesc
.CloudAgeSet = value;
64
65
return
;
66
}
ioQQQ
FILE * ioQQQ
Definition
cddefines.cpp:7
cddefines.h
EXIT_FAILURE
#define EXIT_FAILURE
Definition
cddefines.h:140
cdEXIT
#define cdEXIT(FAIL)
Definition
cddefines.h:434
realnum
float realnum
Definition
cddefines.h:103
DEBUG_ENTRY
#define DEBUG_ENTRY(funcname)
Definition
cddefines.h:684
KeyAction
Definition
parser.h:232
Parser
Definition
parser.h:32
Parser::FFmtRead
double FFmtRead(void)
Definition
parser.cpp:353
Parser::nWord
const char * nWord(const char *chKey) const
Definition
parser.cpp:30
Parser::lgEOL
bool lgEOL(void) const
Definition
parser.h:98
UnitConverter
Definition
parser.h:258
Time
Definition
parse_age.cpp:11
Time::HOUR
const double HOUR
Definition
parse_age.cpp:19
Time::TimeUnits
KeyAction< UnitConverter > TimeUnits[]
Definition
parse_age.cpp:23
Time::DAY
const double DAY
Definition
parse_age.cpp:18
Time::YEAR
const double YEAR
Definition
parse_age.cpp:12
Time::SECOND
const double SECOND
Definition
parse_age.cpp:21
Time::MINUTE
const double MINUTE
Definition
parse_age.cpp:20
Time::FORTNIGHT
const double FORTNIGHT
Definition
parse_age.cpp:16
Time::MILLENIUM
const double MILLENIUM
Definition
parse_age.cpp:13
Time::CENTURY
const double CENTURY
Definition
parse_age.cpp:14
Time::MONTH
const double MONTH
Definition
parse_age.cpp:15
Time::WEEK
const double WEEK
Definition
parse_age.cpp:17
parse.h
NUMBEROF
#define NUMBEROF(a)
Definition
parse_age.cpp:9
ParseAge
void ParseAge(Parser &p)
Definition
parse_age.cpp:39
parser.h
parserProcess
bool parserProcess(Parser &p, T *list, unsigned long nlist, V *value)
Definition
parser.h:272
MakeKeyAction
KeyAction< V > MakeKeyAction(const char *keyword, const V &action)
Definition
parser.h:251
timesc
t_timesc timesc
Definition
timesc.cpp:5
timesc.h
Generated by
1.14.0