diff --git a/include/mxx/file.hpp b/include/mxx/file.hpp index 3a6cfbb..bfc70b6 100644 --- a/include/mxx/file.hpp +++ b/include/mxx/file.hpp @@ -113,6 +113,19 @@ std::string file_block_decompose(const char* filename, MPI_Comm comm = MPI_COMM_ return local_str; } +template +void write_ordered(const std::string& filename, const T* buf, size_t count, const mxx::comm& comm) { + MPI_File handle; + MPI_File_open(comm, &filename[0], MPI_MODE_CREATE | MPI_MODE_WRONLY, MPI_INFO_NULL, &handle); + mxx::datatype dt = mxx::get_datatype(); + MPI_File_write_ordered(handle, const_cast(buf), count, dt.type(), MPI_STATUS_IGNORE); + MPI_File_close(&handle); +} +template +void write_ordered(const std::string& filename, const std::vector& data, const mxx::comm& comm) { + write_ordered(filename, data.data(), data.size(), comm); +} + template void write_files(const std::string& filename, _Iterator begin, _Iterator end, MPI_Comm comm = MPI_COMM_WORLD) { @@ -142,6 +155,7 @@ void write_files(const std::string& filename, _Iterator begin, _Iterator end, MP outfs.close(); } + } // namespace mxx #endif // MXX_FILE_HPP