Use vector instead of VLA, also add missing includes.

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

View File

@@ -23,6 +23,7 @@
#endif // HAVE_CONFIG_H
#include <opm/simulators/WellSwitchingLogger.hpp>
#include <numeric>
namespace Opm
{
@@ -115,18 +116,19 @@ void WellSwitchingLogger::unpackDataAndLog(std::vector<char>& recv_buffer,
well_name_lengths.data(), well_name_lengths.size(),
MPI_INT, MPI_COMM_WORLD);
std::vector<char> well_name;
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,
well_name, well_name_lengths[i], MPI_CHAR,
well_name.data(), well_name_lengths[i], MPI_CHAR,
MPI_COMM_WORLD);
std::array<char,2> fromto{{}};
MPI_Unpack(recv_buffer.data(), recv_buffer.size(), &offset,
fromto.data(), 2, MPI_CHAR, MPI_COMM_WORLD);
logSwitch(well_name, fromto, p);
logSwitch(well_name.data(), fromto, p);
}
}
}

View File

@@ -21,6 +21,7 @@
#ifndef OPM_WELLSWITCHINGLOGGER_HEADER_INCLUDED
#define OPM_WELLSWITCHINGLOGGER_HEADER_INCLUDED
#include <array>
#include <map>
#include <string>
#include <vector>