/* Main program for numerical integration of the solar system. * See the readme file for discussion. * * Before compiling, set type of computer in mconf.h, * arithmetic precision in prec.h, and model parameters * in ssystem.h. * * If DE200 compatible outputs are desired, include the * rotation r118_200() in the output routine. */ #include "mconf.h" #include "prec.h" #include "int.h" #include "ssystem.h" /* Include data for the initial states and model parameters. */ #if DE102 #include "ini102.h" #endif #if DE118 #include "ini118.h" #endif #if DE200 #include "ini200.h" #endif static DOUBLE vnewt[6*NTOTAL]; DOUBLE *awork; /* Adams integrator work array */ DOUBLE *rwork; /* Runge-Kutta work array */ DOUBLE Rij[NTOTAL][NTOTAL]; DOUBLE SQRT(); static int fd; static char fname[80]; #if IBMPC #include #include #include #include #endif main() { DOUBLE t, e0, e, err, h, ccor; static DOUBLE xa, ya, za, xb, yb, zb; /* for display */ DOUBLE *pdv; int i, ii, j, ord, outsteps, iout; long isamps, nsamps, nsteps; DOUBLE adstep(); orlup: printf( "Adams order ? " ); scanf( "%d", &ord ); if( (ord > MAXORD) || (ord < 1) ) { printf( "order must be between 1 and %d\n", MAXORD ); goto orlup; } printf( "step size, days ? " ); #if LDOUBLE scanf( "%Lf", &h ); #else scanf( "%lf", &h ); #endif /* Each output file record contains the Julian date * followed by the current velocity and position states. * See ini118.h for the data structure of the state array. * The state variables for a test object such as a comet * or asteroid should be placed in the array immediately after * the Sun state. */ printf( "Output file name ? " ); scanf( "%s", fname ); #if IBMPC fd = open( fname, O_BINARY | O_CREAT | O_RDWR, S_IREAD | S_IWRITE ); #else fd = creat( fname ); #endif if( fd <= 0 ) { printf( "cant create \"%s\"\n", fname ); exit(1); } printf( "Interval between output samples, in steps ? " ); scanf( "%d", &outsteps ); printf( "Number of output samples ? " ); scanf( "%ld", &nsamps ); /* Note, it is not necessary to clear out the work arrays. */ i = ((NEQ+1)*(MAXORD+2)+(6*NEQ))*sizeof(DOUBLE); awork = (DOUBLE *)malloc(i); if( awork == 0 ) { printf( "malloc(awork) failed\n" ); exit(0); } printf( "Allocated %d bytes to awork\n", i ); i = (MAXRUNG+2)*NEQ*sizeof(DOUBLE); rwork = (DOUBLE *)malloc(i); if( rwork == 0 ) { printf( "malloc(rwork) failed\n" ); exit(0); } printf( "Allocated %d bytes to rwork\n", i ); printf( "NEQ %d, NEQC %d, 6*NTOTAL %d, IAROIDS %d, NBODY %d, NTOTAL %d\n", NEQ, NEQC, 6*NTOTAL, IAROIDS, NBODY, NTOTAL ); printf( "initializing...\n" ); /* Ensure that the relativistic center of the N bodies is at 0.0. * This condition will already be satisfied by states taken from the * JPL ephemeris tapes. */ /* findcenter( JD0, yn ); findcenter( JD1, yn1 ); */ t = JD0; err = 0.0; rkstart( NEQ, rwork ); adstart( h, &yn[0], awork, NEQ, ord, t ); printf( "initialized.\n" ); wfile( t, yn ); /* see below */ nsteps = 0; for( isamps=0; isamps 1e-6 ) exit(0); */ printf( "Final x, y, z, positions and errors:\n" ); /* ii = 6*FMASS; for(i=FMASS; i