#include <math.h>
#include <stdio.h>

#include "../src/param.h"
#include "../src/tdef.h"
#include "../src/common.c"

#include "../src/libutility/utility.h"


int main()
{
   int     no_outputs, i;
   double  z_init, z_final, a_init, a_final, t_init, t_final;
   double  omega0, lambda0, hubble0;
   double  dt, t_out, a_out, z_out;
   FILE   *fpout;
   
   printf("=================================================\n");
   printf(" calculate output redshifts for AMIGA (fixed dt)\n");
   printf("=================================================\n");
   printf("please give number of outputs:        ");
   scanf("%d",&no_outputs);
   printf("please give initial redshift:         ");
   scanf("%lf",&z_init);
   printf("please give final redshift:           ");
   scanf("%lf",&z_final);
   printf("please give omega0:                   ");
   scanf("%lf",&omega0);
   printf("please give lambda0:                  ");
   scanf("%lf",&lambda0);
   printf("please give hubble0:                  ");
   scanf("%lf",&hubble0);
   printf("\n");
   
   simu.omega0  = omega0;
   simu.lambda0 = lambda0;
   a_init  = 1.0/(1.0+z_init);
   a_final = 1.0/(1.0+z_final);
   
   create_timeline(a_init/10., a_final, &simu.timeline);
   
   t_init  = calc_t(a_init);
   t_final = calc_t(a_final);

   dt = (t_final-t_init)/(double)no_outputs;
   
   printf("time step dt   = %lf Myr's (t = %g -> %g)\n\n",
          dt*1000.*Mpc/H0/Gyr/hubble0, t_init*Mpc/H0/Gyr, t_final*Mpc/H0/Gyr);
   
   fpout = fopen("z.out","w");
   for(i=0; i<=no_outputs; i++)
	{
	  t_out = t_init + (double)i*dt;
	  a_out = calc_a(t_out);
	  z_out = 1.0/a_out - 1.0;
	  fprintf(fpout,"%lf\n",z_out);
	}
   fclose(fpout);

   fpout = fopen("a.out","w");
   for(i=0; i<=no_outputs; i++)
     {
      t_out = t_init + (double)i*dt;
      a_out = calc_a(t_out);
      fprintf(fpout,"%lf\n",a_out);
     }
   fclose(fpout);
}
