#include "DataSetWriterMPI.h"
#include "ThirdPartyHeadersBegin.h"
#include <boost/unordered_map.hpp>
#include "ThirdPartyHeadersEnd.h"
#include "FieldData.h"
#include "FileWriterInterface.h"
#include "ItemSetIterator.h"
#include "MPICommunicator.h"
#include "MPINonBlockingCommunicationCollection.h"
#include "NodeMap.h"
#include "TecioMPI.h"
#include "zoneUtil.h"
#include "ZoneWriterAbstract.h"
#include "ZoneWriterFactoryMPI.h"
using namespace tecplot::___3933; namespace tecplot { namespace teciompi { DataSetWriterMPI::DataSetWriterMPI( ___37*               ___36, ___3501                    vars, ___3501                    ___4671, ___1844 const&                maxIJKSubzoneSize, ___2090::ItemOffset_t maxFESubzoneSize, MPI_Comm                  communicator, int                       mainProcess, int                       localProcess, bool                      flushToDisk  ) : DataSetWriter(___36, vars, ___4671, maxIJKSubzoneSize, maxFESubzoneSize, flushToDisk) , m_communicator(communicator) , m_mainProcess(mainProcess) , m_localProcess(localProcess) {} DataSetWriterMPI::~DataSetWriterMPI() {} ___372 DataSetWriterMPI::writeDataSet( FileWriterInterface& szpltFile, ___1392&        szpltZoneHeaderFileLocs) { REQUIRE(szpltFile.___2041()); if (!___2337->___896()) return ___4226; ___372 ___2039 = ___4226;
 #if defined _WIN32 && _MSC_FULL_VER < 190022816
unsigned int oldOutputFormat = _set_output_format(_TWO_DIGIT_EXPONENT);
 #endif
try { ZoneWriterFactoryMPI ___4710(___2680, *___2337, m_communicator, m_mainProcess); boost::unordered_map<___4636, boost::shared_ptr<___4709> > zoneWriterMap; boost::unordered_map<___4636, ___1393> zoneFileLocMap; if (m_localProcess == m_mainProcess) { ___1393 fileLoc = szpltFile.fileLoc(); MPICommunicator communicator(m_communicator); m_zoneIter->reset(); ___4636 const ___341 = m_zoneIter->baseItem(); while (___2039 && m_zoneIter->hasNext()) { ___4636 const ___904 = m_zoneIter->next(); ___4636 const fileZone = ___904 - ___341; if (!___2337->___4638(___904 + 1)) continue; uint64_t zoneFileSize; if (___2337->zoneIsPartitioned(___904 + 1) || ___2337->zoneGetOwnerProcess(___904 + 1) == m_localProcess) { zoneFileLocMap[fileZone] = fileLoc; std::vector<___372> ___4564; ___372 ___4499; getZoneSharing(___4564, ___4499, ___904, ___341, szpltFile.___844()); zoneWriterMap[fileZone] = ___4710.___4708(*m_varIter, ___904, ___341, ___4564, ___4499); zoneFileSize = zoneWriterMap[fileZone]->zoneFileSize(szpltFile.___2002() == ___4226); } else { int zoneOwner = ___2337->zoneGetOwnerProcess(___904 + 1); communicator.sendScalar(fileLoc, zoneOwner, TecioMPI::ZONE_FILE_LOC); communicator.receiveScalar(zoneFileSize, zoneOwner, TecioMPI::ZONE_FILE_SIZE); } fileLoc += zoneFileSize; } } else { MPINonBlockingCommunicationCollection communicationCollection(m_communicator); m_zoneIter->reset(); ___4636 const ___341 = m_zoneIter->baseItem(); while (___2039 && m_zoneIter->hasNext()) { ___4636 const ___904 = m_zoneIter->next(); ___4636 const fileZone = ___904 - ___341; if (!___2337->___4638(___904 + 1)) continue; if (___2337->zoneIsPartitioned(___904 + 1) || ___2337->zoneGetOwnerProcess(___904 + 1) == m_localProcess) { std::vector<___372> ___4564; ___372 ___4499; getZoneSharing(___4564, ___4499, ___904, ___341, szpltFile.___844()); zoneWriterMap[fileZone] = ___4710.___4708(*m_varIter, ___904, ___341, ___4564, ___4499); uint64_t zoneSize = zoneWriterMap[fileZone]->zoneFileSize(szpltFile.___2002() == ___4226); if (!___2337->zoneIsPartitioned(___904 + 1)) { communicationCollection.sendScalarCopy(zoneSize, m_mainProcess, TecioMPI::ZONE_FILE_SIZE); communicationCollection.receiveScalar(zoneFileLocMap[fileZone], m_mainProcess, TecioMPI::ZONE_FILE_LOC); } } } communicationCollection.___4446(); } m_zoneIter->reset(); ___4636 const ___341 = m_zoneIter->baseItem(); while (___2039 && m_zoneIter->hasNext()) { ___4636 const ___904 = m_zoneIter->next(); ___4636 const fileZone = ___904 - ___341; if (!___2337->___4638(___904 + 1)) continue; if (___2337->zoneIsPartitioned(___904 + 1) || ___2337->zoneGetOwnerProcess(___904 + 1) == m_localProcess) { ___2039 = zoneWriterMap[fileZone]->writeZone(szpltFile, zoneFileLocMap[fileZone]); if (m_localProcess == m_mainProcess) { szpltZoneHeaderFileLocs[fileZone] = zoneWriterMap[fileZone]->getZoneHeaderFilePosition(); m_varIter->reset(); ___4352 const baseVar = m_varIter->baseItem(); while (m_varIter->hasNext()) { ___4352 const datasetVar = m_varIter->next(); ___4352 const fileVar = datasetVar - baseVar; m_zoneVarMetadata->m_vzMinMaxes[fileVar][fileZone] = zoneWriterMap[fileZone]->varMinMax(datasetVar); } } else if (!___2337->zoneIsPartitioned(___904 + 1)) { MPINonBlockingCommunicationCollection communicationCollection(m_communicator); ___1393 headerFileLoc = zoneWriterMap[fileZone]->getZoneHeaderFilePosition(); communicationCollection.sendScalarCopy(headerFileLoc, m_mainProcess, TecioMPI::HEADER_FILE_LOC); std::vector<___2479> minMaxValues; minMaxValues.reserve(m_varIter->___2812()); m_varIter->reset(); while (m_varIter->hasNext()) { ___4352 const ___4336 = m_varIter->next(); minMaxValues.push_back(zoneWriterMap[fileZone]->varMinMax(___4336)); } communicationCollection.sendVectorCopy(minMaxValues, m_mainProcess, TecioMPI::VAR_MINMAX_VALUES_SIZE, TecioMPI::VAR_MINMAX_VALUES_VEC); communicationCollection.___4446(); } } else if (m_localProcess == m_mainProcess) { int zoneOwner = ___2337->zoneGetOwnerProcess(___904 + 1); MPICommunicator communicator(m_communicator); communicator.receiveScalar(szpltZoneHeaderFileLocs[fileZone], zoneOwner, TecioMPI::HEADER_FILE_LOC); SimpleVector<___2479> minMaxValues; communicator.receiveVector(minMaxValues, zoneOwner, TecioMPI::VAR_MINMAX_VALUES_SIZE, TecioMPI::VAR_MINMAX_VALUES_VEC); ___478(minMaxValues.size() == m_varIter->___2812()); m_varIter->reset(); ___4352 const baseVar = m_varIter->baseItem(); while (m_varIter->hasNext()) { ___4352 const fileVar = m_varIter->next() - baseVar; m_zoneVarMetadata->m_vzMinMaxes[fileVar][fileZone] = minMaxValues[fileVar];
} } if (szpltFile.___844() == ___845) ___2680.remove(___904); } if (!___2039) { ___2680.clear(); } } catch(std::exception const& e) { ___2039 = ___1186(e.what()); }
 #if defined _WIN32 && _MSC_FULL_VER < 190022816
_set_output_format(oldOutputFormat);
 #endif
return ___2039; } }}
