TYCHO Density File 1.7e-05 200 200 1 323
The C-routine writing the native TYCHO density file is shown here:
/*!
In this routine a TYCHO density file is written.
*/
int write_tyc(int x, int y, int z, int counter) {
FILE *fd;
char filename[600];
int i, j, k, tmp1;
double tmp;
sprintf(filename, "%srho_%i.tyc", output_dir, counter);
fd = fopen(filename, "w");
if (fd == NULL) {
printf("-----------------------------------\n");
printf("The output directory does not exist\n");
printf("-----------------------------------\n");
exit(13);
}
fprintf(fd, "TYCHO Density File\n%g\n%i\n%i\n%i\n%i\n",
time_sim, x, y, z, counter);
fseek(fd, 200, SEEK_SET);
for (i = 0; i < x; i++) {
for (j = 0; j < y; j++) {
for (k = 0; k < z; k++) {
tmp = rho[i][j][k];
if (isnan(tmp)) {
printf("NaN in density array %i %i %i\n", i, j, k);
exit(0);
}
fwrite(&tmp, 1, sizeof (double), fd);
}
}
}
fclose(fd);
return 0;
}