Writes the initial model in a IFRIT uniform scala binary data file The slow order of the nested loops is mandatory here
{
FILE *fd;
char filename[600];
int i, j, k;
int ntemp;
double tmp, tmp_vx, tmp_vy, tmp_vz;
float data1;
fd = fopen(filename, "wb");
if (fd == NULL) {
printf("-----------------------------------\n");
printf("The output directory does not exist\n");
printf("-----------------------------------\n");
exit(13);
}
ntemp = 12;
fwrite(&ntemp, 1, sizeof (int), fd);
fwrite(&
x, 1,
sizeof (
int), fd);
fwrite(&
y, 1,
sizeof (
int), fd);
fwrite(&
z, 1,
sizeof (
int), fd);
fwrite(&ntemp, 1, sizeof (int), fd);
fwrite(&ntemp, 1, sizeof (int), fd);
for (k = 0; k <
z; k++) {
for (j = 0; j <
y; j++) {
for (i = 0; i <
x; i++) {
data1 = (float) tmp;
fwrite(&data1, 1, sizeof (data1), fd);
}
}
}
fwrite(&ntemp, 4, 1, fd);
fclose(fd);
fd = fopen(filename, "wb");
if (fd == NULL) {
printf("-----------------------------------\n");
printf("The output directory does not exist\n");
printf("-----------------------------------\n");
exit(13);
}
ntemp = 12;
fwrite(&ntemp, 1, sizeof (int), fd);
fwrite(&
x, 1,
sizeof (
int), fd);
fwrite(&y, 1, sizeof (int), fd);
fwrite(&z, 1, sizeof (int), fd);
fwrite(&ntemp, 1, sizeof (int), fd);
fwrite(&ntemp, 1, sizeof (int), fd);
for (k = 0; k <
z; k++) {
for (j = 0; j <
y; j++) {
for (i = 0; i <
x; i++) {
data1 = (float) tmp;
fwrite(&data1, 1, sizeof (data1), fd);
}
}
}
fwrite(&ntemp, 1, sizeof (int), fd);
fclose(fd);
fd = fopen(filename, "wb");
if (fd == NULL) {
printf("-----------------------------------\n");
printf("The output directory does not exist\n");
printf("-----------------------------------\n");
exit(13);
}
ntemp = 12;
fwrite(&ntemp, 1, sizeof (int), fd);
fwrite(&
x, 1,
sizeof (
int), fd);
fwrite(&y, 1, sizeof (int), fd);
fwrite(&z, 1, sizeof (int), fd);
fwrite(&ntemp, 1, sizeof (int), fd);
fwrite(&ntemp, 1, sizeof (int), fd);
for (k = 0; k <
z; k++) {
for (j = 0; j <
y; j++) {
for (i = 0; i <
x; i++) {
if (
dom[i][j][k] == 0) tmp =
pre[i][j][k];
if (
dom[i][j][k] == 1) tmp = 0.0;
data1 = (float) tmp;
fwrite(&data1, 1, sizeof (data1), fd);
}
}
}
fwrite(&ntemp, 1, sizeof (int), fd);
fclose(fd);
fd = fopen(filename, "wb");
if (fd == NULL) {
printf("-----------------------------------\n");
printf("The output directory does not exist\n");
printf("-----------------------------------\n");
exit(13);
}
ntemp = 12;
fwrite(&ntemp, 1, sizeof (int), fd);
fwrite(&x, 1, sizeof (int), fd);
fwrite(&y, 1, sizeof (int), fd);
fwrite(&z, 1, sizeof (int), fd);
fwrite(&ntemp, 1, sizeof (int), fd);
fwrite(&ntemp, 1, sizeof (int), fd);
for (i = 0; i <
x; i++) {
for (j = 0; j <
y; j++) {
for (k = 0; k <
z; k++) {
data1 = (float) tmp_vx;
fwrite(&data1, 1, sizeof (data1), fd);
}
}
}
fwrite(&ntemp, 1, sizeof (int), fd);
fwrite(&ntemp, 1, sizeof (int), fd);
for (k = 0; k <
z; k++) {
for (j = 0; j <
y; j++) {
for (i = 0; i <
x; i++) {
data1 = (float) tmp_vy;
fwrite(&data1, 1, sizeof (data1), fd);
}
}
}
fwrite(&ntemp, 1, sizeof (int), fd);
fwrite(&ntemp, 1, sizeof (int), fd);
for (k = 0; k <
z; k++) {
for (j = 0; j <
y; j++) {
for (i = 0; i <
x; i++) {
data1 = (float) tmp_vz;
fwrite(&data1, 1, sizeof (data1), fd);
}
}
}
fwrite(&ntemp, 1, sizeof (int), fd);
fclose(fd);
fd = fopen(filename, "wb");
if (fd == NULL) {
printf("-----------------------------------\n");
printf("The output directory does not exist\n");
printf("-----------------------------------\n");
exit(13);
}
ntemp = 12;
fwrite(&ntemp, 1, sizeof (int), fd);
fwrite(&x, 1, sizeof (int), fd);
fwrite(&y, 1, sizeof (int), fd);
fwrite(&z, 1, sizeof (int), fd);
fwrite(&ntemp, 1, sizeof (int), fd);
fwrite(&ntemp, 1, sizeof (int), fd);
for (k = 0; k <
z; k++) {
for (j = 0; j <
y; j++) {
for (i = 0; i <
x; i++) {
data1 = (float) tmp;
fwrite(&data1, 1, sizeof (data1), fd);
}
}
}
fwrite(&ntemp, 1, sizeof (int), fd);
fclose(fd);
fd = fopen(filename, "wb");
if (fd == NULL) {
printf("-----------------------------------\n");
printf("The output directory does not exist\n");
printf("-----------------------------------\n");
exit(13);
}
ntemp = 12;
fwrite(&ntemp, 1, sizeof (int), fd);
fwrite(&x, 1, sizeof (int), fd);
fwrite(&y, 1, sizeof (int), fd);
fwrite(&z, 1, sizeof (int), fd);
fwrite(&ntemp, 1, sizeof (int), fd);
fwrite(&ntemp, 1, sizeof (int), fd);
for (k = 0; k <
z; k++) {
for (j = 0; j <
y; j++) {
for (i = 0; i <
x; i++) {
data1 = (float) tmp;
fwrite(&data1, 1, sizeof (data1), fd);
}
}
}
fwrite(&ntemp, 1, sizeof (int), fd);
fclose(fd);
}
}
fd = fopen(filename, "wb");
if (fd == NULL) {
printf("-----------------------------------\n");
printf("The output directory does not exist\n");
printf("-----------------------------------\n");
exit(13);
}
ntemp = 12;
fwrite(&ntemp, 1, sizeof (int), fd);
fwrite(&x, 1, sizeof (int), fd);
fwrite(&y, 1, sizeof (int), fd);
fwrite(&z, 1, sizeof (int), fd);
fwrite(&ntemp, 1, sizeof (int), fd);
fwrite(&ntemp, 1, sizeof (int), fd);
for (k = 0; k <
z; k++) {
for (j = 0; j <
y; j++) {
for (i = 0; i <
x; i++) {
data1 = (float) tmp;
fwrite(&data1, 1, sizeof (data1), fd);
}
}
}
fwrite(&ntemp, 1, sizeof (int), fd);
fclose(fd);
}
return 0;
}