Adding helper checks for required number of partitions in AnnotatedTopologyReader if MPI is enabled
diff --git a/plugins/topology/annotated-topology-reader.cc b/plugins/topology/annotated-topology-reader.cc
index 50a5ae4..7b68046 100644
--- a/plugins/topology/annotated-topology-reader.cc
+++ b/plugins/topology/annotated-topology-reader.cc
@@ -47,6 +47,10 @@
 
 #include <set>
 
+#ifdef NS3_MPI
+#include <ns3/mpi-interface.h>
+#endif
+
 using namespace std;
 
 namespace ns3 
@@ -59,6 +63,7 @@
   , m_randX (0, 100.0)
   , m_randY (0, 100.0)
   , m_scale (scale)
+  , m_requiredPartitions (1)
 {
   NS_LOG_FUNCTION (this);
 
@@ -96,6 +101,8 @@
 AnnotatedTopologyReader::CreateNode (const std::string name, double posX, double posY, uint32_t systemId)
 {
   NS_LOG_FUNCTION (this << name << posX << posY);
+  m_requiredPartitions = std::max (m_requiredPartitions, systemId + 1);
+  
   Ptr<Node> node = CreateObject<Node> (systemId);
   Ptr<MobilityModel> loc = DynamicCast<MobilityModel> (m_mobilityFactory.Create ());
   node->AggregateObject (loc);
@@ -277,6 +284,15 @@
 void
 AnnotatedTopologyReader::ApplySettings ()
 {
+#ifdef NS3_MPI
+  if (MpiInterface::GetSize () != m_requiredPartitions)
+    {
+      std::cerr << "MPI interface is enabled, but number of partitions (" << MpiInterface::GetSize ()
+                << ") is not equal to number of partitions in the topology (" << m_requiredPartitions << ")";
+      exit (-1);
+    }
+#endif
+  
   PointToPointHelper p2p;
 
   BOOST_FOREACH (Link &link, m_linksList)
diff --git a/plugins/topology/annotated-topology-reader.h b/plugins/topology/annotated-topology-reader.h
index 48c164b..8ac9286 100644
--- a/plugins/topology/annotated-topology-reader.h
+++ b/plugins/topology/annotated-topology-reader.h
@@ -136,6 +136,8 @@
 
   ObjectFactory m_mobilityFactory;
   double m_scale;
+
+  uint32_t m_requiredPartitions;
 };
 
 }