|
Rheolef
7.2
an efficient C++ finite element environment
|
i/o streams in distributed environment
The idiststream and odiststream classes provide a stream input and output interface for parallel and distributed codes. The main difference Recall that, with the usual std::istream and std::ostream, any i/o operation are executed on all processes: e.g. the output is printed many times. In contrast, idiststream and odiststream manage nicely the distributed environment.
For small data, e.g. int, double or string, a specific processor is selected for i/o operations. For large data, the i/o operations are delegated to a specific class member functions when available.
For convenience, the standard streams cin, cout, clog and cerr are extended as din, dout, dlog and derr, respectively.
Finally, optional suffix extension to the file name is automatically handled:
odiststream foo("NAME", "suffix");
is similar
ofstream foo("NAME.suffix").
Conversely,
irheostream foo("NAME","suffix");
is similar to
ifstream foo("NAME.suffix").
Recursive search in a directory list is provided for finding the input file. However, we look at a search path environment variable RHEOPATH in order to find NAME while the suffix is assumed. Moreover, gzip compressed files, ending with the .gz suffix are handled, and decompression is done automatically on the fly in that case.
File compression/decompresion is handled on the fly, thanks to the gzip library. The data compression is assumed by default for output: it can be deactivated while opening a file by an optional argument:
odiststream foo("NAME", "suffix", io::nogz);
An existing file, possibly compressed, can be reopen in append mode. New results will be appended at the end of an existing file:
odiststream foo("NAME", "suffix", io::app);
The flush member function is nicely handled in compression mode: this feature allows intermediate results to be available during long computations. Buffers are flushed and data are available in the output file.
This documentation has been generated from file linalg/lib/diststream.h