Use vector instead of VLA, also add missing includes.

This commit is contained in:
Atgeirr Flø Rasmussen committed 2016-10-13 17:08:52 +02:00
1 parent cdf7f3cc0d
commit 654a24b625
2 files changed
+6 -3

No files matched your search

+5 -3
View File
@@ -23,6 +23,7 @@
#endif // HAVE_CONFIG_H #endif // HAVE_CONFIG_H
#include <opm/simulators/WellSwitchingLogger.hpp> #include <opm/simulators/WellSwitchingLogger.hpp>
#include <numeric>
namespace Opm namespace Opm
{ {
@@ -115,18 +116,19 @@ void WellSwitchingLogger::unpackDataAndLog(std::vector<char>& recv_buffer,
well_name_lengths.data(), well_name_lengths.size(), well_name_lengths.data(), well_name_lengths.size(),
MPI_INT, MPI_COMM_WORLD); MPI_INT, MPI_COMM_WORLD);
std::vector<char> well_name;
for ( int i = 0; i < no_switches; ++i ) for ( int i = 0; i < no_switches; ++i )
{ {
char well_name[well_name_lengths[i]] = {}; well_name.resize(well_name_lengths[i]);
MPI_Unpack(recv_buffer.data(), recv_buffer.size(), &offset, MPI_Unpack(recv_buffer.data(), recv_buffer.size(), &offset,
well_name, well_name_lengths[i], MPI_CHAR, well_name.data(), well_name_lengths[i], MPI_CHAR,
MPI_COMM_WORLD); MPI_COMM_WORLD);
std::array<char,2> fromto{{}}; std::array<char,2> fromto{{}};
MPI_Unpack(recv_buffer.data(), recv_buffer.size(), &offset, MPI_Unpack(recv_buffer.data(), recv_buffer.size(), &offset,
fromto.data(), 2, MPI_CHAR, MPI_COMM_WORLD); fromto.data(), 2, MPI_CHAR, MPI_COMM_WORLD);
logSwitch(well_name, fromto, p); logSwitch(well_name.data(), fromto, p);
} }
} }
} }
+1
View File
@@ -21,6 +21,7 @@
#ifndef OPM_WELLSWITCHINGLOGGER_HEADER_INCLUDED #ifndef OPM_WELLSWITCHINGLOGGER_HEADER_INCLUDED
#define OPM_WELLSWITCHINGLOGGER_HEADER_INCLUDED #define OPM_WELLSWITCHINGLOGGER_HEADER_INCLUDED
#include <array>
#include <map> #include <map>
#include <string> #include <string>
#include <vector> #include <vector>