#include <stdio.h> 


/***************************************************************/  

main() {
	int    i, j, nsp, np[8], ftempint;
	float  **vx, **vy, **vz, ftemp, tmp[5], jwall[8];
	double t, lftemp, **xx;
	FILE   *DMPFile;


	if ((DMPFile = fopen("TT.txt","r")) == NULL) {
		puts("Dump: open failed");
		return;
	}

	fscanf(DMPFile, "%lf\n", &lftemp);
	t=lftemp;
	fscanf(DMPFile, "%g\n", &ftemp);
	tmp[0]=ftemp;
	fscanf(DMPFile, "%g\n", &ftemp);
	tmp[1] =ftemp;
	fscanf(DMPFile, "%g\n", &ftemp);
	tmp[2] =ftemp;
	fscanf(DMPFile, "%g\n", &ftemp);
	tmp[3] =ftemp;
	fscanf(DMPFile, "%g\n", &ftemp);
	tmp[4] =ftemp;
	fscanf(DMPFile, "%d\n", &ftempint);
	nsp=ftempint;

	for (j=0; j<nsp; j++) {
		fscanf(DMPFile, "%g\n", &ftemp);
		jwall[j]=ftemp;
	}

	for (j=0; j<nsp; j++) {
		fscanf(DMPFile, "%d\n", &ftempint);
		np[j]=ftempint;
	}

	xx = (double **)malloc(nsp*sizeof(double *));      /* double precision! */
	vx = (float **)malloc(nsp*sizeof(float *));
	vy = (float **)malloc(nsp*sizeof(float *));
	vz = (float **)malloc(nsp*sizeof(float *));

	for(i=0; i<nsp; i++) {
		j= np[i];
		xx[i]  = (double *)malloc(j*sizeof(double));
		vx[i] = (float *)malloc(j*sizeof(float));
		vy[i] = (float *)malloc(j*sizeof(float));
		vz[i] = (float *)malloc(j*sizeof(float));
	}

	for (j=0; j<nsp; j++) {
		for (i=0; i<np[j]; i++) {
			fscanf(DMPFile, "%lf\n", &lftemp);
			xx[j][i]=lftemp;
			fscanf(DMPFile, "%g\n", &ftemp);
			vx[j][i]=ftemp;
			fscanf(DMPFile, "%g\n", &ftemp);
			vy[j][i]=ftemp;
			fscanf(DMPFile, "%g\n", &ftemp);
			vz[j][i]=ftemp;
		}
	}
	fclose(DMPFile);


	if ((DMPFile = fopen("TTout.txt","w")) == NULL) {
		puts("Dump: open failed");
		return;
	}

	lftemp = t;
	fprintf(DMPFile, "%g\n", lftemp);
	ftemp = tmp[0];
	fprintf(DMPFile, "%g\n", ftemp);
	ftemp = tmp[1];
	fprintf(DMPFile, "%g\n", ftemp);
	ftemp = tmp[2];
	fprintf(DMPFile, "%g\n", ftemp);
	ftemp = tmp[3];
	fprintf(DMPFile, "%g\n", ftemp);
	ftemp = tmp[4];
	fprintf(DMPFile, "%g\n", ftemp);
	ftempint= nsp;
	fprintf(DMPFile, "%d\n", ftempint);

	for (j=0; j<nsp; j++) {
		ftemp =jwall[j];
		fprintf(DMPFile, "%g\n", ftemp);
	}

	for (j=0; j<nsp; j++) {
		ftempint=2*np[j];
		fprintf(DMPFile, "%d\n", ftempint);
	}

	for (j=0; j<nsp; j++) {
		for (i=0; i<np[j]; i++) {
			lftemp = xx[j][i];
			fprintf(DMPFile, "%lf\n", lftemp);
			ftemp = vx[j][i];
			fprintf(DMPFile, "%g\n", ftemp);
			ftemp = vy[j][i];
			fprintf(DMPFile, "%g\n", ftemp);
			ftemp = vz[j][i];
			fprintf(DMPFile, "%g\n", ftemp);

			lftemp = xx[j][i];
			fprintf(DMPFile, "%lf\n", lftemp);
			ftemp = vx[j][i];
			fprintf(DMPFile, "%g\n", ftemp);
			ftemp = vy[j][i];
			fprintf(DMPFile, "%g\n", ftemp);
			ftemp = vz[j][i];
			fprintf(DMPFile, "%g\n", ftemp);
		}
	}

	fclose(DMPFile);
}
/* END */

