13#if defined(MAIA_MS_COMPILER)
97 ostringstream tmpEncodeBuffer;
100 for(MString::const_iterator iter = inputStr.begin(); iter < inputStr.end(); iter++) {
107 tmpEncodeBuffer <<
""";
110 tmpEncodeBuffer <<
"&";
113 tmpEncodeBuffer <<
"'";
116 tmpEncodeBuffer <<
"<";
119 tmpEncodeBuffer <<
">";
122 tmpEncodeBuffer << c;
127 return tmpEncodeBuffer.str();
140 ostringstream tmpStream;
143 tmpStream <<
"<m d=\"" <<
m_domainId <<
"\" ";
176 return previousValue;
190 return previousValue;
200 const MInt maxNoChars = 1024;
203 MChar host[maxNoChars];
204 gethostname(host, maxNoChars - 1);
205 host[maxNoChars - 1] =
'\0';
209#if defined(MAIA_MS_COMPILER)
210 constexpr MInt INFO_BUFFER_SIZE = 32767;
211 TCHAR infoBuf[INFO_BUFFER_SIZE];
212 DWORD bufCharCount = INFO_BUFFER_SIZE;
213 if(!GetUserName(infoBuf, &bufCharCount)) {
220 p = getpwuid(getuid());
229 MChar dir[maxNoChars];
230#if defined(MAIA_MS_COMPILER)
231 _getcwd(dir, maxNoChars - 1);
233 if(!getcwd(dir, maxNoChars - 1)) {
237 dir[maxNoChars - 1] =
'\0';
240 stringstream executionCommand;
241 executionCommand.str(
"");
249 executionCommand <<
"paraview plugin was started --> no execution command";
254 MChar tmpDateTime[128];
262 timeInfo = localtime(&rawTime);
265 strftime(tmpDateTime, 128,
"%Y-%m-%d %H:%M:%S", timeInfo);
268 ostringstream tmpBuffer;
271 tmpBuffer <<
"<?xml version=\"1.0\" standalone=\"yes\" ?>\n";
272 tmpBuffer <<
"<root>\n";
273 tmpBuffer <<
"<meta name=\"noDomains\" content=\"" <<
m_noDomains <<
"\" />\n";
274 tmpBuffer <<
"<meta name=\"dateCreation\" content=\"" << tmpDateTime <<
"\" />\n";
275 tmpBuffer <<
"<meta name=\"fileFormatVersion\" content=\"" <<
m_fileFormatVersion <<
"\" />\n";
276 tmpBuffer <<
"<meta name=\"projectName\" content=\"" <<
m_projectName <<
"\" />\n";
277 tmpBuffer <<
"<meta name=\"user\" content=\"" << user <<
"\" />\n";
278 tmpBuffer <<
"<meta name=\"host\" content=\"" << host <<
" (" << XSTRINGIFY(MAIA_HOST_STRING) <<
")"
280 tmpBuffer <<
"<meta name=\"dir\" content=\"" << dir <<
"\" />\n";
281 tmpBuffer <<
"<meta name=\"executionCommand\" content=\"" << executionCommand.str() <<
"\" />\n";
282 tmpBuffer <<
"<meta name=\"revision\" content=\"" << XSTRINGIFY(MAIA_VERSION_STRING) <<
"\" />\n";
283 tmpBuffer <<
"<meta name=\"build\" content=\"" << XSTRINGIFY(MAIA_COMPILER_STRING) <<
" "
284 << XSTRINGIFY(MAIA_BUILD_TYPE_STRING) <<
" (" <<
MString(XSTRINGIFY(MAIA_COMPILER_VERSION_STRING)) <<
")"
289 return tmpBuffer.str();
301 MChar tmpDateTime[128];
309 timeInfo = localtime(&rawTime);
312 strftime(tmpDateTime, 128,
"%Y-%m-%d %H:%M:%S", timeInfo);
315 ostringstream tmpBuffer;
318 tmpBuffer <<
"<meta name=\"dateClosing\" content=\"" << tmpDateTime <<
"\" />\n";
319 tmpBuffer <<
"</root>\n";
322 return tmpBuffer.str();
332 : m_isOpen(false), m_rootOnlyHardwired(false), m_filename(), m_file(), m_mpiComm() {
349 MPI_Comm mpiComm,
MBool rootOnlyHardwired)
350 : m_isOpen(false), m_rootOnlyHardwired(false), m_filename(), m_file(), m_mpiComm() {
351 open(filename, projectName, mpiComm, rootOnlyHardwired);
377 MBool rootOnlyHardwired) {
426 static_cast<void>(forceClose);
505 : m_maxMessageLength(0),
506 m_mpiWriteBufferSize(0),
512 m_mpiRequest(MPI_REQUEST_NULL) {
527 : m_maxMessageLength(0),
528 m_mpiWriteBufferSize(0),
534 m_mpiRequest(MPI_REQUEST_NULL) {
535 open(filename, projectName, mpiComm);
586 MInt amode = MPI_MODE_CREATE | MPI_MODE_WRONLY;
752 return previousValue;
780 return oldBufferSize;
790 : m_isInitialized(false), m_printDomainId(false), m_output(0), m_mpiComm(), m_isDisabled(false) {
804 : m_isInitialized(false), m_printDomainId(false), m_output(0), m_mpiComm(), m_isDisabled(false) {
841 ostringstream tmpStream;
844 tmpStream <<
"[" << setfill(
'0') << setw(7) <<
m_domainId <<
"] ";
869 ostringstream tmpEncodeStreambuffer;
871 for(MString::const_iterator iter = inputStr.begin(); iter < inputStr.end(); iter++) {
873 tmpEncodeStreambuffer << c;
875 if(c ==
'\n' && iter != inputStr.end() - 1) {
880 return tmpEncodeStreambuffer.str();
946 MBool rootOnlyHardwired)
947 : m_fileType(0), m_isOpen(false) {
948 open(filename, projectName, fileType, mpiComm, rootOnlyHardwired);
976 MBool rootOnlyHardwired) {
1023 mTerm(1, AT_,
"Unknown file type");
static MInt m_argc
Reads the name of the property-file and creates a new Application.
MInt m_minFlushSize
Minimum length of the internal buffer before flushing.
MInt m_domainId
Contains the MPI rank (= domain id) of this process.
virtual MInt setMinFlushSize(MInt minFlushSize)
Sets the minimum buffer length that has to be reached before the buffer is flushed.
InfoOut_buffer()
Generic constructor is used when no information is provided during declaration.
MString m_prefixMessage
Stores the prefix that is prepended to each output.
MString m_suffixMessage
Stores the suffix that is apended to each output.
std::ostringstream m_tmpBuffer
Temporary buffer to hold string until flushing.
virtual void createSuffixMessage()
Creates an XML suffix that is appended to each message.
std::vector< std::pair< MString, MString > > m_prefixAttributes
virtual MBool setRootOnly(MBool rootOnly=true)
Sets interal state of whether only the root domain (rank 0) should write to file.
virtual MString getXmlHeader()
Return an XML header that should written at the beginning of each log file.
virtual void createPrefixMessage()
Creates an XML prefix using the domain id that is prepended to each message.
MInt m_noDomains
Contains the MPI rank count (= number of domains)
MString m_projectName
Name of the current Project.
MBool m_rootOnly
Stores whether only the root domain writes a log file.
virtual MString encodeXml(const std::string &str)
Parses the string input and returns the string with XML entities escaped.
static const MInt m_fileFormatVersion
virtual MString getXmlFooter()
Return an XML footer that should written at the end of each log file.
Customized buffer to facilitate MPI I/O usage for a single file for all domains within an MPI communi...
void close(MBool forceClose=false)
Closes the MPI file.
MChar * m_mpiWriteBuffer
MPI write buffer.
virtual void flushBuffer()
Flushes the buffer by writing the contents to the MPI file.
MBool m_isOpen
Stores whether the MPI file was already opened.
MInt setMpiWriteBuffer(MInt newBufferSize)
Delete the current MPI write buffer and allocate a new one.
MInt m_mpiWriteBufferSize
Size of the MPI write buffer.
void open(const MString &filename, const MString &projectName, MPI_Comm mpiComm=MPI_COMM_WORLD)
Initialization of the MPI I/O environment.
MPI_Request m_mpiRequest
MPI request object (nonblocking I/O)
MInt m_maxMessageLength
Maximum message length (excluding formatting)
MString m_filename
Filename on disk.
MPI_File m_mpiFileHandle
MPI file handle.
virtual MInt sync()
Flushes the buffer if flushing conditions are met.
static const MInt m_maxStringLength
Maximum string length (including formatting, default: 4096)
MInt setMinFlushSize(MInt minFlushSize)
Sets the minimum buffer length that has to be reached before the buffer is flushed.
InfoOut_mpiFileBuffer()
Generic constructor is used when no information is provided during declaration.
~InfoOut_mpiFileBuffer()
Destructor calls close() to close the MPI file (if opened) and deletes the MPI write buffer.
MPI_Comm m_mpiComm
MPI communicator group.
Customized buffer to facilitate of a regular physical file for each processor within an MPI communica...
~InfoOut_simpleFileBuffer()
Destructor calls close() to close the file.
MString m_filename
Filename on disk.
void close(MBool forceClose=false)
Closes the file.
virtual void flushBuffer()
Flushes the buffer by writing the contents to the file.
MBool m_isOpen
Stores whether the file(s) were already opened.
virtual MInt sync()
Flushes the buffer by writing the contents to the file.
MBool m_rootOnlyHardwired
If true, only domain 0 opens and uses a file.
void open(const MString &filename, const MString &projectName, MPI_Comm mpiComm=MPI_COMM_WORLD, MBool rootOnlyHardwired=false)
Initialization of the file I/O environment.
InfoOut_simpleFileBuffer()
Generic constructor is used when no information is provided during declaration.
MPI_Comm m_mpiComm
MPI communicator group.
std::ofstream m_file
File stream tied to physical file on disk.
Customized string buffer to prepend cout/cerr with the domain id.
virtual MString addPrefix(const MString &str)
virtual void flushBuffer()
This function does nothing for this class, since as of now there is no intermediate buffering.
virtual MInt sync()
Flushes the buffer by writing the contents to the asssociated output stream.
std::ostream * m_output
Stores the output stream (usually cout or cerr) that will be modified.
InfoOut_streamBuffer()
Default constructor does basically nothing.
void initialize(std::ostream *os, MPI_Comm mpiComm=MPI_COMM_WORLD, MBool printDomainId=true)
Initializes the buffer to make it ready for use.
MPI_Comm m_mpiComm
MPI communicator group.
MBool m_isInitialized
Stores whether a stream was already associated with this buffer.
MBool m_isDisabled
Stores wether output in streamBuffer should be written.
MBool m_printDomainId
Stores whether the domain id should be prepended to each output.
MBool m_isOpen
Stores whether a file was already opened or not.
InfoOutFile()
Default constructor creates (virtual) file that cannot yet be used.
~InfoOutFile()
Destructor closes the stream.
MInt m_fileType
File type that is opened.
void open(const MString &filename, const MString &projectName, MInt fileType=0, MPI_Comm mpiComm=MPI_COMM_WORLD, MBool rootOnlyHardwired=false)
Opens a file by passing the parameters to InfoOut_<xyz>FileBuffer::open(...).
void close(MBool forceClose=false)
Pass the close call to the respective internal buffer.
MBool setRootOnly(MBool rootOnly=true)
Sets interal state of whether only the root domain (rank 0) should write to file.
MInt setMinFlushSize(MInt minFlushSize)
Sets the minimum buffer length that has to be reached before the buffer is flushed.
void modifyAttribute(MInt, std::pair< MString, MString >)
Modifies an attribute of the prefix of the XML string.
void eraseAttribute(MInt)
Erases an attribute from the prefix of the XML string.
InfoOut_buffer * m_buffer
MInt addAttribute(std::pair< MString, MString >)
Adds an attribute to the prefix of the XML string.
InfoOutStream()
Default construtor creates InfoOutStream that is not (yet) usable.
MBool setRootOnly(MBool rootOnly=true)
Sets interal state of whether only the root domain (rank 0) should write to file. Author Michael Schl...
MBool m_isInitialized
Stores whether a stream was already opened or not.
void initialize(std::ostream *os, MPI_Comm mpiComm=MPI_COMM_WORLD, MBool printDomainId=true)
Passes the parameters to a call of InfoOut_streamBuffer::initialize().
~InfoOutStream()
Destructor deletes the internal buffer object.
void mTerm(const MInt errorCode, const MString &location, const MString &message)
std::basic_string< char > MString
int MPI_File_iwrite_shared(MPI_File mpi_fh, const void *buf, int count, MPI_Datatype datatype, MPI_Request *request, const MString &name)
same as MPI_File_iwrite_shared
int MPI_Barrier(MPI_Comm comm, const MString &name)
same as MPI_Barrier
int MPI_File_open(MPI_Comm comm, const char *filename, int amode, MPI_Info info, MPI_File *mpi_fh, const MString &name)
same as MPI_File_open
int MPI_Wait(MPI_Request *request, MPI_Status *status, const MString &name)
same as MPI_Wait
int MPI_File_close(MPI_File *mpi_fh, const MString &name)
same as MPI_File_close
int MPI_File_write_shared(MPI_File mpi_fh, const void *buf, int count, MPI_Datatype datatype, MPI_Status *status, const MString &name)
same as MPI_File_write_shared
Namespace to hold all supported filetypes within the InfoOutFile.
const MInt MAIA_INFOOUT_SIMPLE_FILE
Use a physical file for each domain.
const MInt MAIA_INFOOUT_MPI_FILE
Use a single file for all domains (MPI I/O)