22 #include "rheolef/diststream.h"
23 #include "rheolef/rheostream.h"
31 idiststream
din (cin);
47 size_type io_proc = idiststream::io_proc();
50 if (my_proc == io_proc) {
53 #ifdef _RHEOLEF_HAVE_MPI
54 mpi::broadcast (comm,
status, io_proc);
63 idiststream::io_proc() {
64 #ifndef _RHEOLEF_HAVE_MPI
67 boost::optional<int> opt_io_proc = environment::io_rank();
68 check_macro (opt_io_proc,
"no process can perform i/o");
69 int io_proc = opt_io_proc.get();
70 if (io_proc == mpi::any_source) {
78 odiststream::io_proc()
80 return idiststream::io_proc();
90 if (_use_alloc && _ptr_is != 0) {
91 delete_macro (_ptr_is);
96 _ptr_is = new_macro (irheostream(filename, suffix));
98 _ptr_is = new_macro (irheostream);
104 idiststream::close ()
106 if (_use_alloc && _ptr_is != 0) {
107 if (
size_type(_comm.rank()) == idiststream::io_proc()) {
108 irheostream* ptr_irs = (irheostream*)(_ptr_is);
113 idiststream::~idiststream ()
116 if (_use_alloc && _ptr_is != 0) {
117 delete_macro (_ptr_is);
123 idiststream::good()
const
126 if (
size_type(comm().rank()) != idiststream::io_proc()) {
128 }
else if (_ptr_is == 0) {
131 status = (*_ptr_is).good();
133 #ifdef _RHEOLEF_HAVE_MPI
134 mpi::broadcast(comm(),
status, 0);
144 std::string filename,
150 if (_use_alloc && _ptr_os != 0) {
151 delete_macro (_ptr_os);
156 _ptr_os = new_macro (
orheostream(filename, suffix, mode));
164 odiststream::close ()
166 if (_use_alloc && _ptr_os != 0) {
167 if (
size_type(_comm.rank()) == odiststream::io_proc()) {
176 if (
size_type(_comm.rank()) != odiststream::io_proc())
return;
177 if (_use_alloc && _ptr_os != 0) {
180 }
else if (_ptr_os != 0) {
184 odiststream::~odiststream ()
187 if (_use_alloc && _ptr_os != 0) {
188 delete_macro (_ptr_os);
194 odiststream::good()
const
197 if (
size_type(comm().rank()) != idiststream::io_proc()) {
199 }
else if (_ptr_os == 0) {
202 status = (*_ptr_os).good();
204 #ifdef _RHEOLEF_HAVE_MPI
205 mpi::broadcast(comm(),
status, 0);
216 size_type io_proc = odiststream::io_proc();
219 #ifdef _RHEOLEF_HAVE_MPI
220 mpi::communicator().barrier();
222 if (my_proc == io_proc) {
225 #ifdef _RHEOLEF_HAVE_MPI
226 mpi::communicator().barrier();
227 mpi::broadcast (mpi::communicator(),
status, io_proc);
235 size_type io_proc = odiststream::io_proc();
238 if (my_proc == io_proc) {
241 #ifdef _RHEOLEF_HAVE_MPI
242 mpi::broadcast (mpi::communicator(),
status, io_proc);
field::size_type size_type
odiststream: see the diststream page for the full documentation
check_macro(expr1.have_homogeneous_space(Xh1), "dual(expr1,expr2); expr1 should have homogeneous space. HINT: use dual(interpolate(Xh, expr1),expr2)")
This file is part of Rheolef.
idiststream din(cin)
see the diststream page for the full documentation
bool scatch(std::istream &in, const std::string &ch, bool full_match=true)
scatch: see the rheostream page for the full documentation
int dis_system(const std::string &command, const communicator &comm)
bool dis_scatch(idiststream &ips, const communicator &comm, std::string ch)
distributed version of scatch(istream&,string)
bool dis_file_exists(const std::string &filename, const communicator &comm)
bool file_exists(const std::string &filename)
file_exists: see the rheostream page for the full documentation