diff --git a/src/error.h b/src/error.h
index 57622721b42440b1551ae8fbe63f7fcf389d258a..b41f9a38e237509d9bcecd7c9cdf093487f804cd 100644
--- a/src/error.h
+++ b/src/error.h
@@ -27,7 +27,7 @@
  */
 #ifdef WITH_MPI
     extern int engine_rank;
-    #define error(s, ...) { fprintf( stderr , "[%03i] %s:%s():%i: " s "\n" , engine_rank , __FILE__ , __FUNCTION__ , __LINE__ , ##__VA_ARGS__ ); abort(); }
+    #define error(s, ...) { fprintf( stderr , "[%03i] %s:%s():%i: " s "\n" , engine_rank , __FILE__ , __FUNCTION__ , __LINE__ , ##__VA_ARGS__ ); MPI_Abort(MPI_COMM_WORLD, -1); }
 #else
     #define error(s, ...) { fprintf( stderr , "%s:%s():%i: " s "\n" , __FILE__ , __FUNCTION__ , __LINE__ , ##__VA_ARGS__ ); abort(); }
 #endif
diff --git a/src/units.c b/src/units.c
index 0b12483abf5d0eba27cf642258f1e84cece37dd9..f0f526cca39ecc2e81ed10424875fe60a1f37084 100644
--- a/src/units.c
+++ b/src/units.c
@@ -27,6 +27,9 @@
 #include <string.h>
 #include <stddef.h>
 #include <math.h>
+#ifdef WITH_MPI
+#include <mpi.h>
+#endif
 
 #include "const.h"
 #include "cycle.h"