39 const commsTypes commsType,
41 DynamicList<char>& externalBuf,
42 label& externalBufPosition,
45 const bool clearAtEnd,
47 const versionNumber version,
52 Istream(
format, version, UNCOMPRESSED, global),
53 fromProcNo_(fromProcNo),
54 externalBuf_(externalBuf),
55 externalBufPosition_(externalBufPosition),
58 clearAtEnd_(clearAtEnd),
64 if (commsType == commsTypes::nonBlocking)
72 label wantedSize = externalBuf_.capacity();
76 Pout<<
"UIPstream::UIPstream : read from:" << fromProcNo
77 <<
" tag:" << tag <<
" comm:" << comm_
78 <<
" wanted size:" << wantedSize
94 MPI_Get_count(&status, MPI_BYTE, &messageSize_);
96 externalBuf_.setCapacity(messageSize_);
97 wantedSize = messageSize_;
101 Pout<<
"UIPstream::UIPstream : probed size:" << wantedSize
110 externalBuf_.begin(),
117 externalBuf_.setSize(messageSize_);
129 UPstream(buffers.commsType_),
130 Istream(buffers.format_, buffers.version_),
131 fromProcNo_(fromProcNo),
132 externalBuf_(buffers.recvBuf_[fromProcNo]),
133 externalBufPosition_(buffers.recvBufPos_[fromProcNo]),
135 comm_(buffers.comm_),
141 commsType() != UPstream::commsTypes::scheduled
142 && !buffers.finishedSendsCalled_
146 <<
"PstreamBuffers::finishedSends() never called." <<
endl
147 <<
"Please call PstreamBuffers::finishedSends() after doing"
148 <<
" all your sends (using UOPstream) and before doing any"
155 if (commsType() == commsTypes::nonBlocking)
158 messageSize_ = buffers.recvBuf_[fromProcNo].size();
162 Pout<<
"UIPstream::UIPstream PstreamBuffers :"
163 <<
" fromProcNo:" << fromProcNo
164 <<
" tag:" << tag_ <<
" comm:" << comm_
165 <<
" receive buffer size:" << messageSize_
173 label wantedSize = externalBuf_.capacity();
177 Pout<<
"UIPstream::UIPstream PstreamBuffers :"
178 <<
" read from:" << fromProcNo
179 <<
" tag:" << tag_ <<
" comm:" << comm_
180 <<
" wanted size:" << wantedSize
195 MPI_Get_count(&status, MPI_BYTE, &messageSize_);
197 externalBuf_.setCapacity(messageSize_);
198 wantedSize = messageSize_;
202 Pout<<
"UIPstream::UIPstream PstreamBuffers : probed size:"
211 externalBuf_.begin(),
218 externalBuf_.setSize(messageSize_);
232 const commsTypes commsType,
233 const int fromProcNo,
235 const std::streamsize bufSize,
237 const label communicator
242 Pout<<
"UIPstream::read : starting read from:" << fromProcNo
243 <<
" tag:" << tag <<
" comm:" << communicator
244 <<
" wanted size:" <<
label(bufSize)
250 Pout<<
"UIPstream::read : starting read from:" << fromProcNo
251 <<
" tag:" << tag <<
" comm:" << communicator
252 <<
" wanted size:" <<
label(bufSize)
278 <<
"MPI_Recv cannot receive incoming message"
288 MPI_Get_count(&status, MPI_BYTE, &messageSize);
292 Pout<<
"UIPstream::read : finished read from:" << fromProcNo
293 <<
" tag:" << tag <<
" read size:" <<
label(bufSize)
298 if (messageSize > bufSize)
301 <<
"buffer (" <<
label(bufSize)
302 <<
") not large enough for incoming message ("
303 << messageSize <<
')'
328 <<
"MPI_Recv cannot start non-blocking receive"
336 Pout<<
"UIPstream::read : started read from:" << fromProcNo
337 <<
" tag:" << tag <<
" read size:" <<
label(bufSize)
351 <<
"Unsupported communications type "
Useful combination of include files which define Sin, Sout and Serr and the use of IO streams general...
static label read(const commsTypes commsType, const int fromProcNo, char *buf, const std::streamsize bufSize, const int tag=UPstream::msgType(), const label communicator=0)
Read into given buffer from given processor and return the.
UIPstream(const commsTypes commsType, const int fromProcNo, DynamicList< char > &externalBuf, label &externalBufPosition, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm, const bool clearAtEnd=false, const streamFormat format=BINARY, const versionNumber version=currentVersion, const bool global=false)
Construct given process index to read from and optional buffer size,.
static label warnComm
Debugging: warn for use of any communicator differing from warnComm.
static const NamedEnum< commsTypes, 3 > commsTypeNames
commsTypes commsType() const
Get the communications type of the stream.
static void printStack(Ostream &)
Helper function to print a stack.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
DynamicList< MPI_Comm > MPICommunicators_
DynamicList< MPI_Request > outstandingRequests_
errorManipArg< error, int > exit(error &err, const int errNo=1)
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Ostream & endl(Ostream &os)
Add newline and flush stream.
errorManip< error > abort(error &err)
prefixOSstream Pout(cout, "Pout")
word format(conversionProperties.lookup("format"))