484 |
/* probably only need to get shape of first element */ |
/* probably only need to get shape of first element */ |
485 |
/* write the data different ways for scalar, vector and tensor */ |
/* write the data different ways for scalar, vector and tensor */ |
486 |
if (nCompReqd == 1) { |
if (nCompReqd == 1) { |
487 |
fprintf(fileHandle_p, " %e", sampleAvg[0]); |
fprintf(fileHandle_p, " %e", (float) sampleAvg[0]); |
488 |
} else if (nCompReqd == 3) { |
} else if (nCompReqd == 3) { |
489 |
/* write out the data */ |
/* write out the data */ |
490 |
for (int m=0; m<shape; m++) fprintf(fileHandle_p, " %e", sampleAvg[m]); |
for (int m=0; m<shape; m++) fprintf(fileHandle_p, " %e", (float) sampleAvg[m]); |
491 |
for (int m=0; m<nCompReqd-shape; m++) fprintf(fileHandle_p, " %e", 0.); |
for (int m=0; m<nCompReqd-shape; m++) fprintf(fileHandle_p, " %e", (float) 0.); |
492 |
} else if (nCompReqd == 9) { |
} else if (nCompReqd == 9) { |
493 |
/* tensor data, so have a 3x3 matrix to output as a row |
/* tensor data, so have a 3x3 matrix to output as a row |
494 |
* of 9 data points */ |
* of 9 data points */ |
495 |
int count = 0; |
int count = 0; |
496 |
for (int m=0; m<shape; m++) { |
for (int m=0; m<shape; m++) { |
497 |
for (int n=0; n<shape; n++) { |
for (int n=0; n<shape; n++) { |
498 |
fprintf(fileHandle_p, " %e", sampleAvg[count]); |
fprintf(fileHandle_p, " %e", (float) sampleAvg[count]); |
499 |
count++; |
count++; |
500 |
} |
} |
501 |
for (int n=0; n<3-shape; n++) fprintf(fileHandle_p, " %e", 0.); |
for (int n=0; n<3-shape; n++) fprintf(fileHandle_p, " %e", (float) 0.); |
502 |
} |
} |
503 |
for (int m=0; m<3-shape; m++) |
for (int m=0; m<3-shape; m++) |
504 |
for (int n=0; n<3; n++) fprintf(fileHandle_p, " %e", 0.); |
for (int n=0; n<3; n++) fprintf(fileHandle_p, " %e", (float) 0.); |
505 |
} |
} |
506 |
fprintf(fileHandle_p, "\n"); |
fprintf(fileHandle_p, "\n"); |
507 |
} |
} |
614 |
/* write the data different ways for scalar, vector and tensor */ |
/* write the data different ways for scalar, vector and tensor */ |
615 |
if (do_write) { |
if (do_write) { |
616 |
if (nCompReqd == 1) { |
if (nCompReqd == 1) { |
617 |
fprintf(fileHandle_p, " %e", values[0]); |
fprintf(fileHandle_p, " %e", (float) values[0]); |
618 |
} else if (nCompReqd == 3) { |
} else if (nCompReqd == 3) { |
619 |
for (int m=0; m<shape; m++) fprintf(fileHandle_p, " %e", values[m]); |
for (int m=0; m<shape; m++) fprintf(fileHandle_p, " %e", (float) values[m]); |
620 |
for (int m=0; m<nCompReqd-shape; m++) fprintf(fileHandle_p, " %e", 0.); |
for (int m=0; m<nCompReqd-shape; m++) fprintf(fileHandle_p, " %e", (float) 0.); |
621 |
} else if (nCompReqd == 9) { |
} else if (nCompReqd == 9) { |
622 |
/* tensor data, so have a 3x3 matrix to output as a row |
/* tensor data, so have a 3x3 matrix to output as a row |
623 |
* of 9 data points */ |
* of 9 data points */ |
624 |
int count = 0; |
int count = 0; |
625 |
for (int m=0; m<shape; m++) { |
for (int m=0; m<shape; m++) { |
626 |
for (int n=0; n<shape; n++) { |
for (int n=0; n<shape; n++) { |
627 |
fprintf(fileHandle_p, " %e", values[count]); |
fprintf(fileHandle_p, " %e", (float) values[count]); |
628 |
count++; |
count++; |
629 |
} |
} |
630 |
for (int n=0; n<3-shape; n++) fprintf(fileHandle_p, " %e", 0.); |
for (int n=0; n<3-shape; n++) fprintf(fileHandle_p, " %e", (float) 0.); |
631 |
} |
} |
632 |
for (int m=0; m<3-shape; m++) |
for (int m=0; m<3-shape; m++) |
633 |
for (int n=0; n<3; n++) fprintf(fileHandle_p, " %e", 0.); |
for (int n=0; n<3; n++) fprintf(fileHandle_p, " %e", (float) 0.); |
634 |
} |
} |
635 |
fprintf(fileHandle_p, "\n"); |
fprintf(fileHandle_p, "\n"); |
636 |
} |
} |