39 #define MemError1( a ) do { fprintf( stderr, "MEMORY ERROR %d\n" a "\n", __LINE__ ); exit( __LINE__ ); } while ( 0 )
43 " This file is part of PLplot.\n" \
45 " PLplot is free software; you can redistribute it and/or modify\n" \
46 " it under the terms of the GNU Library General Public License as published\n" \
47 " by the Free Software Foundation; either version 2 of the License, or\n" \
48 " (at your option) any later version.\n" \
50 " PLplot is distributed in the hope that it will be useful,\n" \
51 " but WITHOUT ANY WARRANTY; without even the implied warranty of\n" \
52 " MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" \
53 " GNU Library General Public License for more details.\n" \
55 " You should have received a copy of the GNU Library General Public License\n" \
56 " along with PLplot; if not, write to the Free Software\n" \
57 " Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA\n" \
60 " This header file contains spline data (xspline, yspline, and y2spline)\n" \
61 " for converting between UT1 and ephemeris time.\n" \
62 " It is an automatically generated file, so please do\n" \
63 " not edit it directly. Make any changes to deltaT.dat then use\n" \
64 " deltaT-gen to recreate this header file.\n" \
76 int number_of_lines = 0;
78 if ( ( argc < 2 ) || ( fr = fopen( argv[1],
"r" ) ) == NULL )
80 fprintf( stderr,
"Cannot open first file as readable\n" );
84 if ( ( argc < 3 ) || ( fw = fopen( argv[2],
"w" ) ) == NULL )
86 fprintf( stderr,
"Cannot open second file as writable\n" );
94 while ( ( fgets( readbuffer, 255, fr ) != NULL ) )
103 if ( ( xspline = (
double *) calloc( (
size_t) number_of_lines, (
size_t)
sizeof (
double ) ) ) == NULL )
104 MemError1(
"Allocating memory to the xspline table" );
106 if ( ( yspline = (
double *) calloc( (
size_t) number_of_lines, (
size_t)
sizeof (
double ) ) ) == NULL )
107 MemError1(
"Allocating memory to the yspline table" );
109 if ( ( y2spline = (
double *) calloc( (
size_t) number_of_lines, (
size_t)
sizeof (
double ) ) ) == NULL )
110 MemError1(
"Allocating memory to the y2spline table" );
118 while ( ( fgets( readbuffer, 255, fr ) != NULL ) )
120 sscanf( readbuffer,
"%lf %lf", (
double *) &xspline[i], (
double *) &yspline[i] );
129 dspline( xspline, yspline, number_of_lines, 2, 6.4e-3, 2, 6.4e-3, y2spline );
136 fprintf( fw,
"%s\n",
header );
138 fprintf( fw,
"const int number_of_entries_in_spline_tables=%d;\n\n", number_of_lines );
140 fprintf( fw,
"const double xspline[%d] = {\n", number_of_lines );
141 for ( i = 0; i < number_of_lines; i++ )
143 fprintf( fw,
"%10.0f,\n", xspline[i] );
145 fprintf( fw,
"};\n" );
147 fprintf( fw,
"const double yspline[%d] = {\n", number_of_lines );
148 for ( i = 0; i < number_of_lines; i++ )
150 fprintf( fw,
"%10.0f,\n", yspline[i] );
152 fprintf( fw,
"};\n" );
154 fprintf( fw,
"const double y2spline[%d] = {\n", number_of_lines );
155 for ( i = 0; i < number_of_lines; i++ )
157 fprintf( fw,
"%25.15e,\n", y2spline[i] );
159 fprintf( fw,
"};\n" );
int dspline(double *x, double *y, int n, int if1, double cond1, int ifn, double condn, double *y2)
int main(int argc, char *argv[])
const double y2spline[58]