Skip to content

Commit

Permalink
Merge pull request #6099 from bangerth/archive
Browse files Browse the repository at this point in the history
Ensure oarchives die quickly.
  • Loading branch information
gassmoeller authored Oct 22, 2024
2 parents eac4de4 + ea5c2a4 commit a9e8b3d
Show file tree
Hide file tree
Showing 9 changed files with 76 additions and 21 deletions.
10 changes: 8 additions & 2 deletions source/postprocess/core_statistics.cc
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,15 @@ namespace aspect
template <int dim>
void CoreStatistics<dim>::save (std::map<std::string, std::string> &status_strings) const
{
// Serialize into a stringstream. Put the following into a code
// block of its own to ensure the destruction of the 'oa'
// archive triggers a flush() on the stringstream so we can
// query the completed string below.
std::ostringstream os;
aspect::oarchive oa (os);
oa << (*this);
{
aspect::oarchive oa (os);
oa << (*this);
}

status_strings["CoreStatistics"] = os.str();
}
Expand Down
10 changes: 8 additions & 2 deletions source/postprocess/depth_average.cc
Original file line number Diff line number Diff line change
Expand Up @@ -449,9 +449,15 @@ namespace aspect
void
DepthAverage<dim>::save (std::map<std::string, std::string> &status_strings) const
{
// Serialize into a stringstream. Put the following into a code
// block of its own to ensure the destruction of the 'oa'
// archive triggers a flush() on the stringstream so we can
// query the completed string below.
std::ostringstream os;
aspect::oarchive oa (os);
oa << (*this);
{
aspect::oarchive oa (os);
oa << (*this);
}

status_strings["DepthAverage"] = os.str();
}
Expand Down
10 changes: 8 additions & 2 deletions source/postprocess/gravity_point_values.cc
Original file line number Diff line number Diff line change
Expand Up @@ -793,9 +793,15 @@ namespace aspect
void
GravityPointValues<dim>::save (std::map<std::string, std::string> &status_strings) const
{
// Serialize into a stringstream. Put the following into a code
// block of its own to ensure the destruction of the 'oa'
// archive triggers a flush() on the stringstream so we can
// query the completed string below.
std::ostringstream os;
aspect::oarchive oa (os);
oa << (*this);
{
aspect::oarchive oa (os);
oa << (*this);
}

status_strings["GravityPointValues"] = os.str();
}
Expand Down
13 changes: 10 additions & 3 deletions source/postprocess/particles.cc
Original file line number Diff line number Diff line change
Expand Up @@ -611,11 +611,18 @@ namespace aspect
{
particles_output_base_name += "-" + Utilities::int_to_string(particle_manager+1);
}

// Serialize into a stringstream. Put the following into a code
// block of its own to ensure the destruction of the 'oa'
// archive triggers a flush() on the stringstream so we can
// query the completed string below.
std::ostringstream os;
aspect::oarchive oa (os);
{
aspect::oarchive oa (os);

this->get_particle_manager(particle_manager).save(os);
oa << (*this);
this->get_particle_manager(particle_manager).save(os);
oa << (*this);
}

status_strings[particles_output_base_name] = os.str();
}
Expand Down
10 changes: 8 additions & 2 deletions source/postprocess/point_values.cc
Original file line number Diff line number Diff line change
Expand Up @@ -288,9 +288,15 @@ namespace aspect
void
PointValues<dim>::save (std::map<std::string, std::string> &status_strings) const
{
// Serialize into a stringstream. Put the following into a code
// block of its own to ensure the destruction of the 'oa'
// archive triggers a flush() on the stringstream so we can
// query the completed string below.
std::ostringstream os;
aspect::oarchive oa (os);
oa << (*this);
{
aspect::oarchive oa (os);
oa << (*this);
}

status_strings["PointValues"] = os.str();
}
Expand Down
11 changes: 9 additions & 2 deletions source/postprocess/sea_level.cc
Original file line number Diff line number Diff line change
Expand Up @@ -565,8 +565,15 @@ namespace aspect
SeaLevel<dim>::save (std::map<std::string, std::string> &status_strings) const
{
std::ostringstream os;
aspect::oarchive oa (os);
oa << (*this);

// Serialize into a stringstream. Put the following into a code
// block of its own to ensure the destruction of the 'oa'
// archive triggers a flush() on the stringstream so we can
// query the completed string below.
{
aspect::oarchive oa (os);
oa << (*this);
}

status_strings["SeaLevel"] = os.str();
}
Expand Down
10 changes: 8 additions & 2 deletions source/postprocess/stokes_residual.cc
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,15 @@ namespace aspect
void
StokesResidual<dim>::save (std::map<std::string, std::string> &status_strings) const
{
// Serialize into a stringstream. Put the following into a code
// block of its own to ensure the destruction of the 'oa'
// archive triggers a flush() on the stringstream so we can
// query the completed string below.
std::ostringstream os;
aspect::oarchive oa (os);
oa << (*this);
{
aspect::oarchive oa (os);
oa << (*this);
}

status_strings["StokesResidual"] = os.str();
}
Expand Down
10 changes: 8 additions & 2 deletions source/postprocess/visualization.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1501,9 +1501,15 @@ namespace aspect
void
Visualization<dim>::save (std::map<std::string, std::string> &status_strings) const
{
// Serialize into a stringstream. Put the following into a code
// block of its own to ensure the destruction of the 'oa'
// archive triggers a flush() on the stringstream so we can
// query the completed string below.
std::ostringstream os;
aspect::oarchive oa (os);
oa << (*this);
{
aspect::oarchive oa (os);
oa << (*this);
}

status_strings["Visualization"] = os.str();

Expand Down
13 changes: 9 additions & 4 deletions source/simulator/checkpoint_restart.cc
Original file line number Diff line number Diff line change
Expand Up @@ -326,10 +326,15 @@ namespace aspect
{
std::ostringstream oss;

// serialize into a stringstream
aspect::oarchive oa (oss);
save_critical_parameters (this->parameters, oa);
oa << (*this);
// Serialize into a stringstream. Put the following into a code
// block of its own to ensure the destruction of the 'oa'
// archive triggers a flush() on the stringstream so we can
// query its properties below.
{
aspect::oarchive oa (oss);
save_critical_parameters (this->parameters, oa);
oa << (*this);
}

// compress with zlib and write to file on the root processor
#ifdef DEAL_II_WITH_ZLIB
Expand Down

0 comments on commit a9e8b3d

Please sign in to comment.