From 22ea1c6a6c3dd912cf292cfb2180bbdb1abb2a84 Mon Sep 17 00:00:00 2001 From: Alain Miniussi <alain.miniussi@oca.eu> Date: Tue, 6 Feb 2018 16:26:28 +0100 Subject: [PATCH] C->C++ Former-commit-id: 6e63ef4d4f69cadfa8b0b2936ccfa96b87cdff69 --- src/D3/planetarySystem.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/D3/planetarySystem.cpp b/src/D3/planetarySystem.cpp index d93114e31..85b549497 100644 --- a/src/D3/planetarySystem.cpp +++ b/src/D3/planetarySystem.cpp @@ -83,12 +83,19 @@ namespace D3 { Planet p = sys.planet(i); Triplet pos = p.position; Triplet vel = p.velocity; - FILE *output = OFileOpenIndexed("planet%d.dat", i, "a"); - fprintf (output, "%d\t%f\t%f\t%f\t%f\t%f\t%f\t%f\t%.10g\t%.10g\t%.10g\t%f\t%f\n", - progress.outputIndex(), pos.x, pos.y, pos.z, vel.x, vel.y, vel.z, p.mass, - sys.lostMass()*RHO0*VOL0/XMSOL,sys.lostMassZ()*RHO0*VOL0/XMSOL,sys.lostAccretion(), - progress.physicalTime(), *disk.referential().omega); - fclose (output); + std::ofstream out(OFilePathIndexed("planet%d.dat", i), std::ofstream::trunc); + out << std::scientific; + out.precision(10); + out << progress.outputIndex() + << pos.x << pos.y << pos.z + << vel.x << vel.y << vel.z + << p.mass + << sys.lostMass()*RHO0*VOL0/XMSOL + << sys.lostMassZ()*RHO0*VOL0/XMSOL + << sys.lostAccretion() + << progress.physicalTime() + << *disk.referential().omega + << std::endl; } } } -- GitLab