さて、これまで断片的にいろいろな関数を説明してきたが、プログラム全体と してはどんな構造にすればいいだろうか?やらないといけないことは以下のよ うなものである。
pt minus 1 pt
int main()
{
particle * pp;
int n;
cerr << "Enter n:";
cin >> n ;
pp = new particle[n];
double rsize = 1.0;
create_uniform_sphere(pp, n, 0 , rsize);
bhnode * bn = NULL;
int nnodes = n*2+100;
bn = new bhnode[nnodes];
double eps2;
double theta;
double dt;
double tend;
int iout;
cerr << "Enter eps2, theta, dt, tend, iout:";
cin >> eps2 >>theta >>dt >>tend >> iout;
cerr << "eps2=" << eps2 << " theta=" <<theta <<" dt=" << dt
<< " tend=" << tend << " iout=" << iout <<endl;
calculate_gravity(bn,nnodes,pp,n,eps2, theta);
cerr << "Initial data"<<endl;
print_energies(pp,n,0);
int istep = 0;
for(double t=0;t<tend; t+=dt){
integrate(bn, nnodes, pp, n, eps2, theta, dt);
istep++;
if (istep % iout == 0){
cerr << "Time=" << t+dt <<endl;
print_cm(pp, n);
print_energies(pp,n,1);
}
}
return 0;
}