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