95 int main(
int argc,
char **argv)
109 Title =
PrgmName +
", test program for JPL ephemeris, version "
111 +
printTime(CurrEpoch,
"Run %04Y/%02m/%02d at %02H:%02M:%02S");
114 bool verbose=
false,
debug=
false;
115 string inputFilename,testFilename,logFilename;
118 for (i=0; i<argc; i++)
120 string word = string(argv[i]);
121 if (argc == 1 ||
word ==
"-h" ||
word ==
"--help")
124 <<
" reads a binary JPL planetary ephemeris file, created by "
125 <<
"convertSSEph,\n and a test file, downloaded from the JPL ftp site, "
126 <<
"containing times and planets\n with JPL-generated ephemeris "
127 <<
"coordinate values. The coordinates are computed using\n the binary "
128 <<
"file and the SolarSystemEphemeris class, and compared with the JPL"
130 <<
"any difference larger than 10^-13 is noted with the word 'Warning' "
131 <<
"at EOL.\n Note that some large coordinate values may differ at the "
132 <<
"level of 10^-13 because the\n size of double precision is barely "
133 <<
"able to hold that much precision; compare the\n computed value "
134 <<
"with the JPL value (copied as a string) in the output file.\n "
135 <<
"Differences larger than 10^-12 are atypical and are noted with "
136 <<
"the word 'Failure'\n at EOL.\n"
137 <<
"\n Usage: " <<
PrgmName <<
" [options]\n Options are:\n"
138 <<
" --log <file> name of optional log file (otherwise stderr)\n"
139 <<
" --file <file> name of binary SS ephemeris file\n"
140 <<
" --test <file> name of JPL test file (e.g. testpo.403)\n"
141 <<
" --verbose print info to the log file.\n"
142 <<
" --debug print debugging info to the log file.\n"
143 <<
" --help print this and quit.\n"
151 else if (
word ==
"-d" ||
word ==
"--debug")
155 else if (
word ==
"-v" ||
word ==
"--verbose")
159 else if (
word ==
"--log")
161 logFilename = string(argv[++i]);
163 else if (
word ==
"--file")
165 inputFilename = string(argv[++i]);
167 else if (
word ==
"--test")
169 testFilename = string(argv[++i]);
174 if (inputFilename.empty())
176 LOG(
ERROR) <<
"Must specify an input binary file name";
179 if (testFilename.empty())
181 LOG(
ERROR) <<
"Must specify an input test file name";
185 if (!logFilename.empty())
188 logstrm.open(logFilename.c_str(),ios_base::out);
189 ConfigureLOG::Stream() = &
logstrm;
192 cout <<
Title << endl;
193 cout <<
"Output is logged to file " << logFilename << endl;
197 ConfigureLOG::ReportLevels() = ConfigureLOG::ReportTimeTags() =
false;
200 ConfigureLOG::ReportingLevel() = ConfigureLOG::FromString(
"DEBUG");
204 ConfigureLOG::ReportingLevel() = ConfigureLOG::FromString(
"VERBOSE");
208 ConfigureLOG::ReportingLevel() = ConfigureLOG::FromString(
"INFO");
219 LOG(
VERBOSE) <<
"Initialize with file " << inputFilename;
226 double JD,PV[6],value,diff;
230 istrm.open(testFilename.c_str(),ios::in);
231 if (!istrm.is_open())
233 LOG(
ERROR) <<
"Could not open test file " << testFilename;
244 else if (line ==
string(
"EOT"))
268 JD-
MJD_TO_JD, Target, Center, PV,
false);
273 if (
isLike(what,
string(
"Requested time is before .*")))
277 else if (
isLike(what,
string(
"Requested time is after .*")))
281 else if (
isLike(what,
string(
"Stream error .*")))
285 else if (
isLike(what,
string(
"Ephemeris not initialized .*")))
304 diff = ::fabs(PV[coord]-value);
307 LOG(
INFO) << fixed << setprecision(1) << setw(9) << JD
308 <<
" " << setw(2) << target
310 <<
" " << setw(2) <<
center
312 <<
" " << setw(1) << coord+1
313 <<
" " << scientific << setprecision(5) << setw(13)
316 <<
" " << fixed << setprecision(20) << setw(25)
319 << (diff > 1.e-12 ? (diff > 1.e-11 ?
" Failure"
329 if (istrm.eof() || !istrm.good())
338 <<
" terminating with error code " << iret <<
": " <<
339 (iret == 1 ?
"time is before first time in ephemeris" :
340 (iret == 2 ?
"time is beyond end time of ephemeris" :
341 (iret == 3 ?
"file reading failed" :
342 (iret == 4 ?
"ephemeris file not initialized" :
343 (iret == 5 ?
"unknown error" :
"accuracy failure")))));
347 totaltime = clock()-totaltime;
349 <<
" timing: " << fixed << setprecision(9)
350 << double(totaltime)/double(CLOCKS_PER_SEC) <<
" seconds.";