Commit c4ddc963 authored by Jan Oliver Oelerich's avatar Jan Oliver Oelerich

Merge branch 'master' into dft

# Conflicts:
#	src/classes/IO.cpp
#	src/classes/Simulation.cpp
parents 0156e9e0 2d2dfc7e
......@@ -21,7 +21,7 @@ Requirements
The following libraries and tools are needed to successfully compile the code:
* A C++11 compiler (such as `gcc/g++ <https://gcc.gnu.org/>`_). The Intel compiler suite is currently _not_ supported!
* A C++11 compiler (such as `gcc/g++ <https://gcc.gnu.org/>`_ or `intel mkl <https://software.intel.com/en-us/mkl>`_).
* `CMake <https://cmake.org/>`_ > 3.3
* `NetCDF <https://www.unidata.ucar.edu/software/netcdf/>`_
* `libConfig <http://www.hyperrealm.com/libconfig/>`_ >= 1.5
......
......@@ -142,7 +142,7 @@ Parameters of the STEM probe.
*STEMsalabim* can calculate a defocus series to model chromatic aberrations. In that case, this parameter is the
full-width-half-maximum of the normal distribution of defocus spread in ``nm``.
**probe.fwhm_defoci**
**probe.num_defoci**
*number [default: `1`]*
*STEMsalabim* can calculate a defocus series to model chromatic aberrations. In that case, this parameter is the
......
......@@ -699,6 +699,24 @@ string getTempFileName() {
return output::fmt("%s/%s_%d.bin", p.tmpDir(), p.uuid(), mpi_rank);
}
void IO::generateTemporaryResultFile() {
auto &mpi_env = mpi::Environment::getInstance();
int mpi_rank = mpi_env.rank();
auto tmpfile = std::ofstream(getTempFileName(), std::ios::binary | std::ios::app);
if(tmpfile.fail()) {
output::error("Couldn't open temporary binary %s file for writing.\n", getTempFileName());
}
tmpfile.write(reinterpret_cast<const char *>(&mpi_rank), sizeof(mpi_rank));
tmpfile.close();
}
void IO::removeTemporaryResultFile() {
remove(getTempFileName().c_str());
}
void IO::writeTemporaryResult(unsigned int idefocus, unsigned int iconf, ScanPoint &point,
shared_ptr<memory::buffer::number_buffer<float>> &combuf,
shared_ptr<memory::buffer::number_buffer<float>> &ibuf,
......@@ -709,7 +727,7 @@ void IO::writeTemporaryResult(unsigned int idefocus, unsigned int iconf, ScanPoi
auto tmpfile = std::ofstream(getTempFileName(), std::ios::binary | std::ios::app);
// the format is as follows:
// int rank
// int rank ( written in generateTemporaryResultFile)
// for each pixel:
// unsigned int idefocus
// unsigned int iconf
......@@ -722,8 +740,7 @@ void IO::writeTemporaryResult(unsigned int idefocus, unsigned int iconf, ScanPoi
}
if(tmpfile.tellp() == 0) {
// empty file, write rank
tmpfile.write(reinterpret_cast<const char *>(&mpi_rank), sizeof(mpi_rank));
output::error("File %s shouldn't be empty! Has writeTemporaryResult() been called?\n", getTempFileName());
}
tmpfile.write(reinterpret_cast<const char *>(&idefocus), sizeof(idefocus));
......@@ -823,9 +840,6 @@ void IO::copyFromTemporaryFile(const shared_ptr<GridManager> &gridman,
tmpfile.close();
// remove the file, as all the data is now transferred.
remove(getTempFileName().c_str());
}
......
......@@ -132,6 +132,16 @@ namespace stemsalabim {
const std::shared_ptr<GridManager> &gridman, const ScanPoint &point,
std::shared_ptr<memory::buffer::number_buffer<float>> &cbuf, NCVar & v);
/*!
* Generates the temporary result file and writes the header.
*/
static void generateTemporaryResultFile();
/*!
* Removes the temporary result file.
*/
static void removeTemporaryResultFile();
/*!
* Write temporary results to a binary file (custom format). This is done in MPI mode.
* @param idefocus current defocus index
......
......@@ -197,6 +197,8 @@ void Simulation::run() {
output::fmt("Finished calculation of transmission functions in %s.\n",
output::humantime(algorithms::getTimeSince(t1))));
_io->generateTemporaryResultFile();
if(mpi_env.isMaster()) {
multisliceMaster(st);
} else {
......@@ -214,7 +216,7 @@ void Simulation::run() {
if(rank == mpi_env.rank()) {
auto start = high_resolution_clock::now();
_io->copyFromTemporaryFile(_gridman, _com_buffer, _adf_intensity_buffer, _cbed_intensity_buffer);
_io->removeTemporaryResultFile();
printLine(st,
output::fmt("Finished copying pixels for %s.\n",
output::humantime(algorithms::getTimeSince(start))));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment