- CHECK_ARGS((tag<0 && tag != MPI_ANY_TAG), MPI_ERR_TAG, \
- "%s: param %d %s cannot be negative", __func__, num, #tag);
-#define CHECK_FILE(num, fh) \
- CHECK_ARGS(fh == MPI_FILE_NULL, MPI_ERR_FILE, \
- "%s: param %d %s cannot be MPI_PROC_NULL", __func__, num, #fh);
+ CHECK_ARGS(((tag) < 0 && (tag) != MPI_ANY_TAG), MPI_ERR_TAG, \
+ "%s: param %d %s (=%d) cannot be negative", __func__, (num), _XBT_STRINGIFY(tag), (tag));
+#define CHECK_FILE(num, fh) \
+ CHECK_MPI_NULL((num), MPI_FILE_NULL, MPI_ERR_FILE, (fh))
+#define CHECK_OFFSET(num, offset) \
+ CHECK_NEGATIVE((num), MPI_ERR_DISP, (offset))
+#define CHECK_GROUP(num, group) \
+ CHECK_MPI_NULL((num), MPI_GROUP_NULL, MPI_ERR_GROUP, (group))
+#define CHECK_WIN(num, win) \
+ CHECK_MPI_NULL((num), MPI_WIN_NULL, MPI_ERR_WIN, (win))
+#define CHECK_RANK(num, rank, comm) \
+ CHECK_ARGS(((rank) >= (comm)->group()->size() || (rank) <0), MPI_ERR_RANK, \
+ "%s: param %d %s (=%d) cannot be < 0 or > %d", __func__, (num), _XBT_STRINGIFY(rank), \
+ (rank), (comm)->group()->size() );