From e276a8a15c485f8dcb7165fc244353dbdb375808 Mon Sep 17 00:00:00 2001 From: Oliver Hahn Date: Tue, 25 Feb 2014 18:32:28 +0100 Subject: [PATCH] fix to TIPSY output plugin when running with baryons also added more verbose error messages to TIPSY plugin --- plugins/output_tipsy.cc | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/plugins/output_tipsy.cc b/plugins/output_tipsy.cc index 85e0392..3f1a73d 100644 --- a/plugins/output_tipsy.cc +++ b/plugins/output_tipsy.cc @@ -764,15 +764,18 @@ public: for( unsigned j=0; jsize(1); ++j ) for( unsigned k=0; ksize(2); ++k ) { - if( temp_dat.size() < block_buf_size_ ) - temp_dat.push_back( pmass ); - else - { - ofs_temp.write( (char*)&temp_dat[0], sizeof(T_store)*block_buf_size_ ); - nwritten += block_buf_size_; - temp_dat.clear(); - temp_dat.push_back( pmass ); - } + if( gh.is_in_mask(ilevel,i,j,k) && !gh.is_refined(ilevel,i,j,k) ) + { + if( temp_dat.size() < block_buf_size_ ) + temp_dat.push_back( pmass ); + else + { + ofs_temp.write( (char*)&temp_dat[0], sizeof(T_store)*block_buf_size_ ); + nwritten += block_buf_size_; + temp_dat.clear(); + temp_dat.push_back( pmass ); + } + } } if( temp_dat.size() > 0 ) @@ -781,13 +784,17 @@ public: nwritten+=temp_dat.size(); } - if( nwritten != nptot ) - throw std::runtime_error("Internal consistency error while writing temporary file for baryon masses"); - + if( nwritten != nptot ){ + LOGERR("TIPSY output plugin wrote %ld gas particles, should have %ld", nwritten, nptot); + throw std::runtime_error("Internal consistency error while writing temporary file for baryon masses"); + } + ofs_temp.write( (char *)&blksize, sizeof(size_t) ); - if( ofs_temp.bad() ) - throw std::runtime_error("I/O error while writing temporary file for baryon masses"); + if( ofs_temp.bad() ){ + LOGERR("I/O error while writing temporary file for baryon masse"); + throw std::runtime_error("I/O error while writing temporary file for baryon masses"); + } } }