From 6699512f9148ee87a071340de9791bb2c31dbad7 Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Wed, 12 Feb 2020 21:34:59 +0100 Subject: [PATCH] BUG: file format mangled by collated format (fixes #1587) - incorrectly set BINARY format in the construction of the received data (a side-effect of the parameter ordering). Now use the same default parameters as IFstream and set the correct filename subsequent to construction. --- .../masterUncollatedFileOperation.C | 36 ++++++++----------- 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/src/OpenFOAM/global/fileOperations/masterUncollatedFileOperation/masterUncollatedFileOperation.C b/src/OpenFOAM/global/fileOperations/masterUncollatedFileOperation/masterUncollatedFileOperation.C index 2796a2c3ca3..4100e51f12d 100644 --- a/src/OpenFOAM/global/fileOperations/masterUncollatedFileOperation/masterUncollatedFileOperation.C +++ b/src/OpenFOAM/global/fileOperations/masterUncollatedFileOperation/masterUncollatedFileOperation.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2017-2018 OpenFOAM Foundation - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -774,7 +774,7 @@ masterUncollatedFileOperation if (verbose) { - Info + DetailInfo << "I/O : " << typeName << " (maxMasterFileBufferSize " << maxMasterFileBufferSize << ')' << endl; @@ -820,7 +820,7 @@ masterUncollatedFileOperation if (verbose) { - Info + DetailInfo << "I/O : " << typeName << " (maxMasterFileBufferSize " << maxMasterFileBufferSize << ')' << endl; @@ -2415,6 +2415,8 @@ Foam::fileOperations::masterUncollatedFileOperation::NewIFstream const fileName& filePath ) const { + autoPtr<ISstream> isPtr; + if (Pstream::parRun()) { // Insert logic of filePath. We assume that if a file is absolute @@ -2497,10 +2499,7 @@ Foam::fileOperations::masterUncollatedFileOperation::NewIFstream if (Pstream::master(Pstream::worldComm)) { // Read myself - return autoPtr<ISstream> - ( - new IFstream(filePaths[Pstream::masterNo()]) - ); + isPtr.reset(new IFstream(filePaths[Pstream::masterNo()])); } else { @@ -2522,26 +2521,21 @@ Foam::fileOperations::masterUncollatedFileOperation::NewIFstream << " Done reading " << buf.size() << " bytes" << endl; } - // Note: IPstream is not an IStream so use a IStringStream to - // convert the buffer. Note that we construct with a string - // so it holds a copy of the buffer. - return autoPtr<ISstream> - ( - new IListStream - ( - std::move(buf), - IOstream::BINARY, - IOstream::currentVersion, - filePath - ) - ); + // A local character buffer copy of the Pstream contents. + // Construct with same parameters (ASCII, current version) + // as the IFstream so that it has the same characteristics. + + isPtr.reset(new IListStream(std::move(buf))); + isPtr->name() = filePath; // Assign the proper file name } } else { // Read myself - return autoPtr<ISstream>(new IFstream(filePath)); + isPtr.reset(new IFstream(filePath)); } + + return isPtr; } -- GitLab