From b6170b09b5e5d1b246d177188e4c14c023a871e6 Mon Sep 17 00:00:00 2001 From: Mark Jenkinson <mark@fmrib.ox.ac.uk> Date: Wed, 9 Aug 2006 16:52:37 +0000 Subject: [PATCH] Put in flush calls as a workaround for the stupid ofstream bug on ppc64 --- miscmaths.cc | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/miscmaths.cc b/miscmaths.cc index 72d7f13..3b1c0d3 100644 --- a/miscmaths.cc +++ b/miscmaths.cc @@ -279,13 +279,19 @@ namespace MISCMATHS { int write_ascii_matrix(const Matrix& mat, ofstream& fs, int precision) { + if (precision>0) { + fs.setf(ios::scientific | ios::showpos); + fs.precision(precision); + } +#ifdef PPC64 + int n=0; +#endif for (int i=1; i<=mat.Nrows(); i++) { for (int j=1; j<=mat.Ncols(); j++) { - if (precision>0) { - fs.setf(ios::scientific | ios::showpos); - fs.precision(precision+7); - fs.precision(precision); } fs << mat(i,j) << " "; +#ifdef PPC64 + if ((n++ % 50) == 0) fs.flush(); +#endif } fs << endl; } @@ -352,10 +358,16 @@ namespace MISCMATHS { ny = mat.Ncols(); double val; +#ifdef PPC64 + int n=0; +#endif for (unsigned int y=1; y<=ny; y++) { for (unsigned int x=1; x<=nx; x++) { val = mat(x,y); fs.write((char*)&val,sizeof(val)); +#ifdef PPC64 + if ((n++ % 50) == 0) fs.flush(); +#endif } } -- GitLab