You are here: Home Resources Computers Hebb Octave on Blue Gene mpitb-2.9.12.patch

mpitb-2.9.12.patch

Patches applied to MPITB to make it work with MPICH in general and BlueGene MPI in particular.

— Plain Text, 66 kB (68256 bytes)

File contents

diff -up src/DLD-FUNCTIONS/hAttr.h.orig src/DLD-FUNCTIONS/hAttr.h
--- src/DLD-FUNCTIONS/hAttr.h.orig	2007-07-17 11:15:03.000000000 +0200
+++ src/DLD-FUNCTIONS/hAttr.h	2008-04-02 11:36:33.929187661 +0200
@@ -40,9 +40,12 @@
  #define MAX_ATTR_KVAL	LAM_MPI_SSI_COLL_SHMEM_NUM_SEGMENTS
 #elif    OPEN_MPI
  #define MAX_ATTR_KVAL	IMPI_HOST_COLOR
+#elif    MPICH2
+ #define MAX_ATTR_KVAL  0x40000000  /* Predefined are possibly greater
+                                       than this and not smaller. See mpi.h */
 #else
- #error No max attribute keyval known (this is neither LAM/ nor Open-MPI)
-#endif	/* LAM_MPI / OPEN_MPI */
+#error No max attribute keyval known (this is neither LAM, Open-MPI or MPICH2)
+#endif	/* LAM_MPI / OPEN_MPI / MPICH2 */
 
 
 /* -------------------------------------------------------------------
@@ -52,7 +55,7 @@
 #define PATN_ATR_INT_F_COM_KEY(PNAME)					\
 {									\
 	NARGCHK    (PNAME,2)						\
-	BLCK_ONECOM(PNAME,0)		/* comm   */			\
+	BLCK_ONECOM(PNAME,0,comm)	/* comm   */			\
 	BLCK_ONEINT(PNAME,1,keyval)	/* keyval */			\
 									\
 	int info, flag=0, *pred;	/* for LAM predefined attrs */	\
@@ -83,7 +86,7 @@
 #define PATN_F_COM_KEY(PNAME)						\
 {									\
 	NARGCHK    (PNAME,2)						\
-	BLCK_ONECOM(PNAME,0)		/* comm   */			\
+	BLCK_ONECOM(PNAME,0,comm) /* comm */				\
 	BLCK_ONEINT(PNAME,1,keyval)	/* keyval */			\
 									\
 	int info =  PNAME(comm, keyval);/* side effect - */		\
diff -up src/DLD-FUNCTIONS/hColl.h.orig src/DLD-FUNCTIONS/hColl.h
--- src/DLD-FUNCTIONS/hColl.h.orig	2007-07-17 11:15:11.000000000 +0200
+++ src/DLD-FUNCTIONS/hColl.h	2008-04-02 01:01:03.835314886 +0200
@@ -56,15 +56,14 @@
  */					/* program NAME, root is ARG Nth*/
 #define	ROOTCOM_GET(PNAME,ARGN)	/* every root followed by comm (6patt) */\
 	if (( ! args(ARGN  ).is_real_scalar() )				\
-/*	 || ( ! args(ARGN+1).is_real_scalar())){	*/		\
-	 || ( ! MPITB_isOPtrTyp(args(ARGN+1)))){			\
+	 || ( ! MPITB_VAL_COULD_BE_COMM(args(ARGN+1)))){		\
 	  error(							\
-	    STRFY(PNAME) ": required args#%d-%d: root(int), comm(ptr)",	\
+	    STRFY(PNAME) ": required args#%d-%d: root(int), comm",	\
 				ARGN+1,ARGN+2);				\
 	  return octave_value(MPI_ERR_ARG); /* error returns nothing */	\
 	}								\
 int	 root =	args(ARGN  ).int_value();				\
-MPI_Comm comm = MPITB_ptrcast(MPI_Comm, args(ARGN+1));
+MPI_Comm comm = MPITB_VAL_TO_COMM(args(ARGN+1));
 
 
 /* -------------------------------------------------------------------------
@@ -77,12 +76,11 @@ MPI_Comm comm = MPITB_ptrcast(MPI_Comm, 
  * -------------------------------------------------------------------------
  */					/* program NAME, root is ARG Nth*/
 #define	BLCK_OP_GET(PNAME,ARGN)		/* common to 4 call patterns */	\
-/*	if  ( ! args(ARGN  ).is_real_scalar()){	*/			\
-	if  ( ! MPITB_isOPtrTyp(args(ARGN  ))){				\
-	  error(STRFY(PNAME) ": required arg#%d: op(ptr)", ARGN+1);	\
+	if  ( ! MPITB_VAL_COULD_BE_OP(args(ARGN  ))){			\
+	  error(STRFY(PNAME) ": required arg#%d: op", ARGN+1);		\
 	  return octave_value(MPI_ERR_ARG); /* error returns nothing */	\
 	}								\
-MPI_Op  Op = MPITB_ptrcast(MPI_Op, args(ARGN  ));
+MPI_Op  Op = MPITB_VAL_TO_OP(args(ARGN));
 
 
 /* -------------------------------------------------------------------------
@@ -236,7 +234,7 @@ MPI_Datatype	P##TYPE = get_MPI_Type (arg
 	BCNTYPE_GET(PNAME,0,S,0)	/* Snam,Ssym, SCNT/TYPE/BUF */	\
 	BCNTYPE_GET(PNAME,1,R,1)	/* Rnam,Rsym, RCNT/TYPE/BUF */	\
 	RCNT = SCNT;		/* avoid SIGSEGV, never let RCNT>SCNT */\
-	BLCK_ONECOM(PNAME,2  )		/* comm */			\
+	BLCK_ONECOM(PNAME,2,comm) /* comm */				\
 									\
 	int info =  PNAME (SBUF,SCNT,STYPE,				\
 			   RBUF,RCNT,RTYPE,				\
@@ -300,7 +298,7 @@ MPI_Datatype	P##TYPE = get_MPI_Type (arg
 	BCNTYPE_GET(PNAME,0,S,0)	/* Snam,Ssym, SCNT/TYPE/BUF */	\
 	BCNTYPE_GET(PNAME,1,R,1)	/* Rnam,Rsym, RCNT/TYPE/BUF */	\
 	BLCK_ONEINT(PNAME,2,srcnt)	/* srcnt */			\
-	BLCK_ONECOM(PNAME,3)		/* comm */			\
+	BLCK_ONECOM(PNAME,3,comm) /* comm */				\
 									\
 	SCNT = RCNT = srcnt;	/* See MPI man page. Braindamage!! */	\
 									\
@@ -330,7 +328,7 @@ MPI_Datatype	P##TYPE = get_MPI_Type (arg
 	BCNTYPE_GET(PNAME,0,S,0)	/* Snam,Ssym, SCNT/TYPE/BUF */	\
 	BCNTYPE_GET(PNAME,1,R,1)	/* Rnam,Rsym, RCNT/TYPE/BUF */	\
 	BLCK_OP_GET(PNAME,2  )		/* Op   */			\
-	BLCK_ONECOM(PNAME,3  )		/* comm */			\
+	BLCK_ONECOM(PNAME,3,comm) /* comm */				\
 									\
 	BLCK_CHGTYPE		/*CHAR->UCHAR, BOOL->BYTE, f/REPLACE*/	\
 									\
@@ -386,7 +384,7 @@ MPI_Datatype	P##TYPE = get_MPI_Type (arg
 	BCNTYPE_GET(PNAME,1,R,1)	/* Rnam,Rsym, RCNT/TYPE/BUF */	\
 	BLCK_intVEC(PNAME,2,R,cnts)	/* Rdata,Rsize,Rcnts */		\
 	BLCK_OP_GET(PNAME,3  )		/* Op   */			\
-	BLCK_ONECOM(PNAME,4  )		/* comm */			\
+	BLCK_ONECOM(PNAME,4,comm) /* comm */				\
 									\
 	BLCK_CHGTYPE		/*CHAR->UCHAR, BOOL->BYTE, f/REPLACE*/	\
 									\
@@ -414,7 +412,7 @@ MPI_Datatype	P##TYPE = get_MPI_Type (arg
 	NARGCHK    (PNAME,  5)	/* SRCDC -> src/rcvar,cnts,disps,comm */\
 	BCNTYPE_GET(PNAME,0,S,0)	/* Snam,Ssym, SCNT/TYPE/BUF */	\
 	BCDTYPE_GET(PNAME,1,R,1)	/* Rnam/.../BUF, Rcnts/disps */	\
-	BLCK_ONECOM(PNAME,4  )		/* comm */			\
+	BLCK_ONECOM(PNAME,4,comm) /* comm */				\
 									\
 	int info =  PNAME (SBUF,SCNT,STYPE,				\
 			   RBUF,Rcnts,Rdisps,RTYPE,			\
@@ -495,7 +493,7 @@ MPI_Datatype	P##TYPE = get_MPI_Type (arg
 	NARGCHK    (PNAME,  7)	/*SSSRRRC->svar/cnt/dsp,rvar/cnt/dsp,comm*/\
 	BCDTYPE_GET(PNAME,0,S,0)	/* Snam/.../BUF, Scnts/disps */	\
 	BCDTYPE_GET(PNAME,3,R,1)	/* Rnam/.../BUF, Rcnts/disps */	\
-	BLCK_ONECOM(PNAME,6  )		/* comm */			\
+	BLCK_ONECOM(PNAME,6,comm) /* comm */				\
 									\
 	int info =  PNAME (SBUF,Scnts,Sdisps,STYPE,			\
 			   RBUF,Rcnts,Rdisps,RTYPE,			\
diff -up src/DLD-FUNCTIONS/hConst.h.orig src/DLD-FUNCTIONS/hConst.h
--- src/DLD-FUNCTIONS/hConst.h.orig	2007-07-17 11:15:15.000000000 +0200
+++ src/DLD-FUNCTIONS/hConst.h	2008-04-01 18:42:04.559284870 +0200
@@ -13,6 +13,44 @@
  * ----------------------------------------------------
  */
 
+#if defined(LAM) || defined(OPEN_MPI)
+  #define GEN_1_MPI_COMM        GEN_1_PTR
+  #define RET_1_MPI_COMM        RET_1_PTR
+  #define GEN_1_MPI_ERRHANDLER  GEN_1_PTR
+  #define RET_1_MPI_ERRHANDLER  RET_1_PTR
+  #define GEN_1_MPI_FILE        GEN_1_PTR
+  #define RET_1_MPI_FILE        RET_1_PTR
+  #define GEN_1_MPI_GROUP       GEN_1_PTR
+  #define RET_1_MPI_GROUP       RET_1_PTR
+  #define GEN_1_MPI_INFO        GEN_1_PTR
+  #define RET_1_MPI_INFO        RET_1_PTR
+  #define GEN_1_MPI_OP          GEN_1_PTR
+  #define RET_1_MPI_OP          RET_1_PTR
+  #define GEN_1_MPI_REQUEST     GEN_1_PTR
+  #define RET_1_MPI_REQUEST     RET_1_PTR
+  #define GEN_1_MPI_WIN         GEN_1_PTR
+  #define RET_1_MPI_WIN         RET_1_PTR
+#elif defined(MPICH2)
+  #define GEN_1_MPI_COMM        GEN_1_INT
+  #define RET_1_MPI_COMM        RET_1_INT
+  #define GEN_1_MPI_ERRHANDLER  GEN_1_INT
+  #define RET_1_MPI_ERRHANDLER  RET_1_INT
+  #define GEN_1_MPI_FILE        GEN_1_PTR
+  #define RET_1_MPI_FILE        RET_1_PTR
+  #define GEN_1_MPI_GROUP       GEN_1_INT
+  #define RET_1_MPI_GROUP       RET_1_INT
+  #define GEN_1_MPI_INFO        GEN_1_INT
+  #define RET_1_MPI_INFO        RET_1_INT
+  #define GEN_1_MPI_OP          GEN_1_INT
+  #define RET_1_MPI_OP          RET_1_INT
+  #define GEN_1_MPI_REQUEST     GEN_1_INT
+  #define RET_1_MPI_REQUEST     RET_1_INT
+  #define GEN_1_MPI_WIN         GEN_1_INT
+  #define RET_1_MPI_WIN         RET_1_INT
+#else
+#error Unimplemented MPI implementation. Fix me here!
+#endif
+
 /* -------------------------------------------------------------------------
  * -------- Building Blocks ------------------------------------------------
  * ------------------------------------------------------------------------- */
@@ -42,12 +80,12 @@
  */
 
 #define GEN_1_PTR(PNAME)						\
-MPITB_OctPtrTyp retcode(void){						\
+MPITB_OctPtrTyp retcode (void){						\
 	return MPITB_intcast(PNAME);					\
 }
 
-#define RET_1_PTR							\
-	RET_1_ARG (retcode());
+#define RET_1_PTR	\
+	RET_1_ARG (retcode())
 
 
 /* -------------------------------------------------------------------------
diff -up src/DLD-FUNCTIONS/hErr.h.orig src/DLD-FUNCTIONS/hErr.h
--- src/DLD-FUNCTIONS/hErr.h.orig	2007-07-17 11:15:18.000000000 +0200
+++ src/DLD-FUNCTIONS/hErr.h	2008-04-02 00:24:24.681129034 +0200
@@ -33,13 +33,11 @@
  * -------------------------------------------------------------------------
  */
 #define BLCK_ONEHND(PNAME,ARGN)		/* ARG Nth in arglist  */	\
-/*	if ( ! args(ARGN).is_real_scalar()){	*/			\
-	if ( ! MPITB_isOPtrTyp(args(ARGN))){				\
-	  error(STRFY(PNAME) ": required arg#%d: ehnd(ptr)", ARGN+1);	\
+	if ( ! MPITB_VAL_COULD_BE_ERRHANDLER(args(ARGN))){		\
+	  error(STRFY(PNAME) ": required arg#%d: ehnd", ARGN+1);	\
 	  return octave_value(MPI_ERR_ARG); /* error returns nothing */	\
 	}								\
-	MPI_Errhandler ehnd = MPITB_ptrcast ( MPI_Errhandler, args(ARGN) );
-
+	MPI_Errhandler ehnd = MPITB_VAL_TO_ERRHANDLER(args(ARGN));
 
 /* -------------------------------------------------------------------------
  * -------- Call Patterns --------------------------------------------------
@@ -60,12 +58,12 @@
 #define PATN_ERRH_F_COM(PNAME)						\
 {									\
 	NARGCHK    (PNAME,1)						\
-	BLCK_ONECOM(PNAME,0)	/* comm */				\
+	BLCK_ONECOM(PNAME,0,comm) /* comm */				\
 									\
 	MPI_Errhandler		 ehnd=0;				\
 	int info =  PNAME(comm, &ehnd);					\
 									\
-	RET_2_ARG  (info, MPITB_intcast(				\
+	RET_2_ARG  (info, MPITB_ERRHANDLER_TO_VAL(			\
 				 ehnd	))				\
 }
 
@@ -77,7 +75,7 @@
 #define PATN_F_COM_ERRH(PNAME)						\
 {									\
 	NARGCHK    (PNAME,2)						\
-	BLCK_ONECOM(PNAME,0)	/* comm */				\
+	BLCK_ONECOM(PNAME,0,comm) /* comm */				\
 	BLCK_ONEHND(PNAME,1)	/* ehnd */				\
 									\
 	int info =  PNAME (comm, ehnd);					\
diff -up src/DLD-FUNCTIONS/hGrp.h.orig src/DLD-FUNCTIONS/hGrp.h
--- src/DLD-FUNCTIONS/hGrp.h.orig	2007-07-17 11:15:22.000000000 +0200
+++ src/DLD-FUNCTIONS/hGrp.h	2008-04-02 01:06:11.443456368 +0200
@@ -66,13 +66,11 @@
  * -------------------------------------------------------------------------
  */
 #define BLCK_ONEGRP(PNAME,ARGN)		/* progNAME, Nth ARG in list  */\
-/*	if ( ! args(ARGN).is_real_scalar() ){	*/			\
-	if ( ! MPITB_isOPtrTyp(args(ARGN)) ){				\
-	  error(STRFY(PNAME) ": required arg#%d: grp(ptr)", ARGN+1);	\
+	if ( ! MPITB_VAL_COULD_BE_GROUP(args(ARGN)) ){			\
+	  error(STRFY(PNAME) ": required arg#%d: grp", ARGN+1);		\
 	  return octave_value(MPI_ERR_ARG); /* error returns nothing */	\
 	}								\
-	MPI_Group grp = MPITB_ptrcast ( MPI_Group, args(ARGN) );
-
+	MPI_Group grp = MPITB_VAL_TO_GROUP(args(ARGN));
 
 /* -------------------------------------------------------------------------
  * BLCK_TWOGRP:
@@ -84,17 +82,15 @@
  * -------------------------------------------------------------------------
  */
 #define BLCK_TWOGRP(PNAME,ARGM,ARGN)		/*N & M-th ARG in list*/\
-/*	if ((! args(ARGM).is_real_scalar() )	*/			\
-	if ((! MPITB_isOPtrTyp(args(ARGM)) )				\
-	  ||(! MPITB_isOPtrTyp(args(ARGN)))){				\
+	if ((! MPITB_VAL_COULD_BE_GROUP(args(ARGM)) )			\
+	  ||(! MPITB_VAL_COULD_BE_GROUP(args(ARGN)))){			\
 	  error(							\
-	    STRFY(PNAME) ": required args#%d-%d: grp1(ptr), grp2(ptr)",	\
+	    STRFY(PNAME) ": required args#%d-%d: grp1, grp2",		\
 							ARGM,ARGN);	\
 	  return octave_value(MPI_ERR_ARG); /* error returns nothing */	\
 	}								\
-	MPI_Group grp1 = MPITB_ptrcast(MPI_Group, args(ARGM) ),		\
-		  grp2 = MPITB_ptrcast(MPI_Group, args(ARGN) );
-
+	MPI_Group grp1 = MPITB_VAL_TO_GROUP(args(ARGM)),		\
+		  grp2 = MPITB_VAL_TO_GROUP(args(ARGN));
 
 /* -------------------------------------------------------------------------
  * BLCK_TWOCOM:
@@ -105,17 +101,15 @@
  * -------------------------------------------------------------------------
  */
 #define BLCK_TWOCOM(PNAME,ARGM,ARGN)		/*N & M-th ARG in list*/\
-/*	if ((! args(ARGM).is_real_scalar() )	*/			\
-	if ((! MPITB_isOPtrTyp(args(ARGM)) )				\
-	  ||(! MPITB_isOPtrTyp(args(ARGN)))){				\
+	if ((! MPITB_VAL_COULD_BE_COMM(args(ARGM)) )			\
+	  ||(! MPITB_VAL_COULD_BE_COMM(args(ARGN)))){			\
 	  error(							\
-	   STRFY(PNAME) ": required args#%d-%d: comm1(ptr), comm2(ptr)",\
+	    STRFY(PNAME) ": required args#%d-%d: comm1, comm2",		\
 							ARGM,ARGN);	\
 	  return octave_value(MPI_ERR_ARG); /* error returns nothing */	\
 	}								\
-	MPI_Comm comm1 = MPITB_ptrcast(MPI_Comm, args(ARGM) ),		\
-		 comm2 = MPITB_ptrcast(MPI_Comm, args(ARGN) );
-
+	MPI_Comm comm1 = MPITB_VAL_TO_COMM(args(ARGM)),			\
+	         comm2 = MPITB_VAL_TO_COMM(args(ARGN));
 
 /* -------------------------------------------------------------------------
  * BLCK_COMLDR:
@@ -127,21 +121,20 @@
  * -------------------------------------------------------------------------
  */
 #define BLCK_COMLDR(PNAME,ARGN,P)		/* P for PREFIX */	\
-	if ((! MPITB_isOPtrTyp(args(ARGN  )) )				\
+	if ((! MPITB_VAL_COULD_BE_COMM(args(ARGN  )) )			\
 	  ||(! args(ARGN+1).is_real_scalar())){				\
 	  error(STRFY(PNAME)	": required args#%d-%d: "		\
-		STRFY(P)	"_comm(ptr), "				\
+		STRFY(P)	"_comm, "				\
 		STRFY(P)	"_leader(int)",		ARGN+1,ARGN+2);	\
 	  return octave_value(MPI_ERR_ARG); /* error returns nothing */	\
 	}								\
-	MPI_Comm P##_comm = MPITB_ptrcast(MPI_Comm, args(ARGN) );	\
-	   int   P##_lead =			    args(ARGN+1).int_value();
+	MPI_Comm P##_comm = MPITB_VAL_TO_COMM( args(ARGN) );		\
+	   int   P##_lead = args(ARGN+1).int_value();
 //	   int   P##_lead = reinterpret_cast<int> ( args(ARGN+1).int_value() );
 // BUG: BRAINDAMAGE!! casting int to int, compile error w/gcc4.0.2 Ubuntu
 // MPI_Intercomm_create.cc:49: error: invalid cast from type 'int' to type 'int'
 // CREDIT: detected by Michael Creel, Econometrics UAB Spain
 
-
 /* -------------------------------------------------------------------------
  * BLCK_GETRNKS:
  * Take int-row-vector ARG Nth into source code (chosen vector name VN)
@@ -226,10 +219,10 @@
 {									\
 	NARGCHK    (PNAME,1)						\
 	BLCK_ONESYM(PNAME,0,  comm)	/* commnam, commsym */		\
-	BLCK_ONECOM(PNAME,0)		/* copy/in  comm */		\
+	BLCK_ONECOM(PNAME,0,comm) /* comm */				\
 									\
 	int info =  PNAME   (&comm);					\
-	commsym ->define(MPITB_intcast(					\
+	commsym ->define(MPITB_COMM_TO_VAL(					\
 			      comm )  );/* copy/out */			\
 	RET_1_ARG  (info)						\
 }
@@ -248,10 +241,10 @@
 #define PATN_GRP_F_COM(PNAME)						\
 {									\
 	NARGCHK       (PNAME,1)						\
-	BLCK_ONECOM   (PNAME,0)		/* comm */			\
+	BLCK_ONECOM   (PNAME,0,comm) /* comm */				\
 	MPI_Group		grp0=0;					\
 	int info= PNAME(comm,  &grp0 );					\
-	RET_2_ARG(info,MPITB_intcast(					\
+	RET_2_ARG(info,MPITB_GROUP_TO_VAL(  				\
 				grp0 ))					\
 }
 
@@ -263,10 +256,10 @@
 #define PATN_COM_F_COM(PNAME)						\
 {									\
 	NARGCHK       (PNAME,1)						\
-	BLCK_ONECOM   (PNAME,0)		/* comm */			\
+	BLCK_ONECOM   (PNAME,0,comm) /* comm */				\
 	MPI_Comm		comm0=0;				\
 	int info= PNAME(comm,  &comm0 );				\
-	RET_2_ARG(info,MPITB_intcast(					\
+	RET_2_ARG(info,MPITB_COMM_TO_VAL(  				\
 				comm0 ))				\
 }
 
@@ -278,11 +271,11 @@
 #define PATN_COM_F_COM_GRP(PNAME)					\
 {									\
 	NARGCHK       (PNAME,2)						\
-	BLCK_ONECOM   (PNAME,0)		/* comm */			\
+	BLCK_ONECOM   (PNAME,0,comm) /* comm */				\
 	BLCK_ONEGRP   (PNAME,1)		/* grp  */			\
 	MPI_Comm		   comm0=0;				\
 	int info= PNAME(comm, grp,&comm0 );				\
-	RET_2_ARG(info,MPITB_intcast(					\
+	RET_2_ARG(info,MPITB_COMM_TO_VAL(  				\
 				   comm0 ))				\
 }
 
@@ -313,7 +306,8 @@
 	MPI_Comm				 comm0=0;		\
 	int       info=PNAME(l_comm,l_lead,				\
 			     r_comm,r_lead, tag,&comm0 );		\
-	RET_2_ARG(info, MPITB_intcast          ( comm0 ))		\
+	RET_2_ARG(info,MPITB_COMM_TO_VAL(  				\
+				   comm0 ))				\
 }
 
 
@@ -324,12 +318,13 @@
 #define PATN_COM_F_COM_2INT(PNAME)					\
 {									\
 	NARGCHK       (PNAME,3)						\
-	BLCK_ONECOM   (PNAME,0)		/* comm  */			\
+	BLCK_ONECOM   (PNAME,0,comm) /* comm */				\
 	BLCK_ONEINT   (PNAME,1,color)	/* color */			\
 	BLCK_ONEINT   (PNAME,2,key  )	/* key   */			\
 	MPI_Comm			      comm0=0;			\
 	int       info=PNAME(comm,color,key, &comm0 );			\
-	RET_2_ARG(info,MPITB_intcast        ( comm0 ))			\
+	RET_2_ARG(info,MPITB_COMM_TO_VAL(  				\
+				   comm0 ))				\
 }
 
 
@@ -349,7 +344,7 @@
 	BLCK_ONEGRP(PNAME,0)		/* copy/in grp    */		\
 									\
 	int info =  PNAME  (&grp);					\
-	grpsym  ->define(MPITB_intcast(					\
+	grpsym  ->define(MPITB_GROUP_TO_VAL(					\
 			     grp     ));/* copy/out grp */		\
 	RET_1_ARG  (info)						\
 }
@@ -399,7 +394,8 @@
 	BLCK_TWOGRP   (PNAME,0,1)	/* grp1, grp2 */		\
 	MPI_Group			      grp0=0;			\
 	int       info=PNAME(grp1, grp2,     &grp0 );			\
-	RET_2_ARG(info,MPITB_intcast	    ( grp0 ))			\
+	RET_2_ARG(info,MPITB_GROUP_TO_VAL(  				\
+				grp0 ))					\
 }
 
 
@@ -415,7 +411,8 @@
 	BLCK_GETRNKS     (PNAME,1,rnks)	/* rnks,n,om */			\
 	MPI_Group			       grp0=0;			\
 	int info = PNAME  (grp, n,rnks,	      &grp0 );			\
-	RET_2_ARG (info,MPITB_intcast	     ( grp0 ))			\
+	RET_2_ARG(info,MPITB_GROUP_TO_VAL(  				\
+				grp0 ))					\
 }
 
 
@@ -431,7 +428,8 @@
 	BLCK_GETRNGS     (PNAME,1,rngs)	/* rngs,m,om */			\
 	MPI_Group			       grp0=0;			\
 	int info = PNAME  (grp, m,rngs,	      &grp0 );			\
-	RET_2_ARG (info,MPITB_intcast	     ( grp0 ))			\
+	RET_2_ARG(info,MPITB_GROUP_TO_VAL(  				\
+				grp0 ))					\
 }
 
 
diff -up src/DLD-FUNCTIONS/hInfo.h.orig src/DLD-FUNCTIONS/hInfo.h
--- src/DLD-FUNCTIONS/hInfo.h.orig	2007-07-17 11:15:26.000000000 +0200
+++ src/DLD-FUNCTIONS/hInfo.h	2008-04-02 10:47:35.609281181 +0200
@@ -44,19 +44,19 @@
 
 /* -------------------------------------------------------------------------
  * BLCK_ONEINF:
- * Take one info argument ARG Nth into source code (name inf always)
+ * Take one info argument ARG Nth into source code (variable name in 3rd arg)
  * -------------------------------------------------------------------------
  * crossref: used just from here
  * hInfo.h (12 uses):	all PATN_ except for MPI_Info_create/MPI_Close_port
  * -------------------------------------------------------------------------
  */
-#define BLCK_ONEINF(PNAME,ARGN)						\
-	if (  !	MPITB_isOPtrTyp(args(ARGN)) ){				\
-	  error(STRFY(PNAME) ": required arg#%d: inf(ptr)", ARGN+1);	\
+
+#define BLCK_ONEINF(PNAME,ARGN,INF)					\
+	if (  !	MPITB_VAL_COULD_BE_INFO(args(ARGN)) ){			\
+	  error(STRFY(PNAME) ": required arg#%d: inf", ARGN+1);		\
 	  return octave_value(MPI_ERR_ARG); /* error returns nothing */	\
 	}								\
-	MPI_Info inf = MPITB_ptrcast ( MPI_Info, args(ARGN) );
-
+	MPI_Info INF = MPITB_VAL_TO_INFO(args(ARGN));
 
 
 /* -------------------------------------------------------------------------
@@ -81,7 +81,7 @@
 	NARGCHK   (PNAME,0)						\
 	MPI_Info          inf=0;					\
 	int info = PNAME(&inf );					\
-	RET_2_ARG (info, MPITB_intcast(					\
+	RET_2_ARG (info, MPITB_INFO_TO_VAL(					\
 			 inf )	      )					\
 }
 
@@ -93,7 +93,7 @@
 #define PATN_F_INF_STR(PNAME)						\
 {									\
 	NARGCHK    (PNAME,2)						\
-	BLCK_ONEINF(PNAME,0)	/* inf */				\
+	BLCK_ONEINF(PNAME,0,inf) /* inf */				\
 	BLCK_ONESTR(PNAME,1,key)/* key */				\
 	int  info = PNAME ( inf, const_cast<char*>(			\
 			    key.c_str() ));				\
@@ -108,10 +108,10 @@
 #define PATN_INF_F_INF(PNAME)						\
 {									\
 	NARGCHK       (PNAME,1)						\
-	BLCK_ONEINF   (PNAME,0)						\
+	BLCK_ONEINF   (PNAME,0,inf)					\
 	MPI_Info		 inf0=0;				\
 	int info = PNAME (inf,  &inf0 );				\
-	RET_2_ARG (info, MPITB_intcast(					\
+	RET_2_ARG (info, MPITB_INFO_TO_VAL(					\
 				 inf0 ) )				\
 }
 
@@ -124,10 +124,10 @@
 {									\
 	NARGCHK    (PNAME,1)						\
 	BLCK_ONESYM(PNAME,0, inf)	/* infnam, infsym */		\
-	BLCK_ONEINF(PNAME,0)		/* copy/in inf */		\
+	BLCK_ONEINF(PNAME,0,inf)	/* copy/in inf */		\
 									\
 	int info  = PNAME  (&inf);					\
-	    infsym->define( MPITB_intcast(				\
+	    infsym->define( MPITB_INFO_TO_VAL(				\
 			    inf) );	/* copy/out inf */		\
 	RET_1_ARG  (info)						\
 }
@@ -145,7 +145,7 @@
 #define PATN_F_INF_STR_STR(PNAME)					\
 {									\
 	NARGCHK    (PNAME,3)						\
-	BLCK_ONEINF(PNAME,0)		/* inf */			\
+	BLCK_ONEINF(PNAME,0,inf)	/* inf */			\
 	BLCK_ONESTR(PNAME,1,key)	/* key */			\
 	BLCK_ONESTR(PNAME,2,val)	/* val */			\
   									\
@@ -166,7 +166,7 @@
 #define PATN_INT_STR_F_INF_STR(PNAME)					\
 {									\
 	NARGCHK    (PNAME,2)						\
-	BLCK_ONEINF(PNAME,0)						\
+	BLCK_ONEINF(PNAME,0,inf)					\
 	BLCK_ONESTR(PNAME,1,key)					\
 									\
 	char val   [MPI_MAX_INFO_VAL];					\
@@ -188,7 +188,7 @@
 #define PATN_INT_F_INF(PNAME)						\
 {									\
 	NARGCHK       (PNAME,1)						\
-	BLCK_ONEINF   (PNAME,0)						\
+	BLCK_ONEINF   (PNAME,0,inf)					\
 	int nkeys=0,							\
 		  info=PNAME(inf,&nkeys);				\
 	RET_2_ARG(info,           nkeys)				\
@@ -204,8 +204,8 @@
 #define PATN_STR_F_INF_INT(PNAME)					\
 {									\
 	NARGCHK    (PNAME,2)						\
-	BLCK_ONEINF(PNAME,0)	/* inf */				\
-	BLCK_ONEINT(PNAME,1,n)	/*  n  */				\
+	BLCK_ONEINF(PNAME,0,inf) /* inf */				\
+	BLCK_ONEINT(PNAME,1,n)	 /*  n  */				\
 									\
 	char key   [MPI_MAX_INFO_KEY];					\
    for (int  i=0; i<MPI_MAX_INFO_KEY; i++)				\
@@ -224,7 +224,7 @@
 #define PATN_2INT_F_INF_STR(PNAME)					\
 {					/* BUG: MAX_INFO_VAL? */	\
 	NARGCHK    (PNAME,2)						\
-	BLCK_ONEINF(PNAME,0)		/* inf */			\
+	BLCK_ONEINF(PNAME,0,inf)	/* inf */			\
 	BLCK_ONESTR(PNAME,1,  key)	/* key */			\
 	int  len=0, flag=0,						\
 	     info = PNAME  ( inf,					\
@@ -250,15 +250,15 @@
 {									\
 	NARGCHK    (PNAME,4)						\
 	BLCK_ONESTR(PNAME,0,port)/* port */				\
-	BLCK_ONEINF(PNAME,1)	 /* inf  */				\
+	BLCK_ONEINF(PNAME,1,inf) /* inf  */				\
 	BLCK_ONEINT(PNAME,2,root)/* root */	/*ROOTCOM_GET hColl */	\
-	BLCK_ONECOM(PNAME,3)	 /* comm */				\
+	BLCK_ONECOM(PNAME,3,comm) /* comm */				\
 									\
 	MPI_Comm				clcomm=0;		\
 	int  info = PNAME  (						\
 	 const_cast<char *>( port.c_str() ),				\
 			     inf, root, comm,  &clcomm );		\
-	RET_2_ARG  (info,	MPITB_intcast ( clcomm ))		\
+	RET_2_ARG  (info,	MPITB_COMM_TO_VAL ( clcomm ))		\
 }
 
 
@@ -271,7 +271,7 @@
 {									\
 	NARGCHK    (PNAME,3)						\
 	BLCK_ONESTR(PNAME,0, svc)	/* svc  */			\
-	BLCK_ONEINF(PNAME,1)		/* inf  */			\
+	BLCK_ONEINF(PNAME,1,inf)	/* inf  */			\
 	BLCK_ONESTR(PNAME,2, port)	/* port */			\
 									\
 	int  info = PNAME  (						\
@@ -289,14 +289,22 @@
  * #define MPI_MAX_PORT_NAME 36               / * max port name length * /
  * ------------------------------------------------------------------- */
 
+#ifndef MPI_MAX_PORT_NAME
+#ifdef MPI_MAX_NAME_LEN
+#define MPI_MAX_PORT_NAME MPI_MAX_NAME_LEN
+#else
+#error Unknown value for MPI_MAX_PORT_NAME. Check your MPI implementation.
+#endif /* MPI_MAX_NAME_LEN */
+#endif /* MPI_MAX_PORT_NAME */
+
 #define PATN_STR_F_STR_INF(PNAME)					\
 {									\
 	NARGCHK    (PNAME,2)						\
 	BLCK_ONESTR(PNAME,0,svc)/* svc  */				\
-	BLCK_ONEINF(PNAME,1)	/* inf  */				\
+	BLCK_ONEINF(PNAME,1,inf) /* inf  */				\
 									\
-	char port  [MPI_MAX_NAME_LEN];					\
-   for (int  i=0; i<MPI_MAX_NAME_LEN; i++)				\
+	char port  [MPI_MAX_PORT_NAME];					\
+   for (int  i=0; i<MPI_MAX_PORT_NAME; i++)				\
 	     port[i]=0;							\
 									\
 	int  info = PNAME  (						\
@@ -313,10 +321,10 @@
 #define PATN_STR_F_INF(PNAME)						\
 {									\
 	NARGCHK    (PNAME,1)						\
-	BLCK_ONEINF(PNAME,0)	/* inf  */				\
+	BLCK_ONEINF(PNAME,0,inf) /* inf  */				\
 									\
-	char port  [MPI_MAX_NAME_LEN];					\
-   for (int  i=0; i<MPI_MAX_NAME_LEN; i++)				\
+	char port  [MPI_MAX_PORT_NAME];					\
+   for (int  i=0; i<MPI_MAX_PORT_NAME; i++)				\
 	     port[i]=0;							\
 									\
 	int  info = PNAME(inf, port);					\
diff -up src/DLD-FUNCTIONS/hRecv.h.orig src/DLD-FUNCTIONS/hRecv.h
--- src/DLD-FUNCTIONS/hRecv.h.orig	2007-07-17 11:15:29.000000000 +0200
+++ src/DLD-FUNCTIONS/hRecv.h	2008-04-01 21:53:09.795815175 +0200
@@ -99,7 +99,7 @@
 									\
 	BLCK_ONEINT(PNAME,4-RP, src)	/* src            */		\
 	BLCK_ONEINT(PNAME,5-RP,rtag)	/* rtag           */		\
-	BLCK_ONECOM(PNAME,6-RP)		/* comm           */
+	BLCK_ONECOM(PNAME,6-RP,comm) /* comm */				\
 
 
 
diff -up src/DLD-FUNCTIONS/hSend.h.orig src/DLD-FUNCTIONS/hSend.h
--- src/DLD-FUNCTIONS/hSend.h.orig	2007-07-17 11:15:32.000000000 +0200
+++ src/DLD-FUNCTIONS/hSend.h	2008-04-01 13:46:13.740312899 +0200
@@ -94,7 +94,7 @@
 	int info = PNAME (BUF,SIZ,TYPE, srcdst,tag,comm,		\
 			&req);						\
 									\
-	RET_2_ARG (info, MPITB_intcast(					\
+	RET_2_ARG (info, MPITB_REQUEST_TO_VAL(				\
 			 req )	       );				\
 }
 
diff -up src/DLD-FUNCTIONS/hSndRecv.h.orig src/DLD-FUNCTIONS/hSndRecv.h
--- src/DLD-FUNCTIONS/hSndRecv.h.orig	2007-07-17 11:15:37.000000000 +0200
+++ src/DLD-FUNCTIONS/hSndRecv.h	2008-04-01 21:45:42.409288608 +0200
@@ -72,7 +72,7 @@
 	BLCK_ONESYM (PNAME,0,var)	/* varnam, varsym */		\
 	BLCK_ONEINT (PNAME,1,srcdst)	/* srcdst         */		\
 	BLCK_ONEINT (PNAME,2,tag)	/* tag            */		\
-	BLCK_ONECOM (PNAME,3)		/* comm           */		\
+	BLCK_ONECOM (PNAME,3,comm) /* comm */				\
 									\
 	DECLARE_BUFF_VARS		/* BUF, SIZ, TYPE */		\
 	BUF = get_MPI_Buff(varsym,SIZ,false,TYPE,MK_UNIQ);/*SIZ!=bytes*/\
diff -up src/DLD-FUNCTIONS/hTopo.h.orig src/DLD-FUNCTIONS/hTopo.h
--- src/DLD-FUNCTIONS/hTopo.h.orig	2007-07-17 11:15:43.000000000 +0200
+++ src/DLD-FUNCTIONS/hTopo.h	2008-04-01 21:46:53.580468023 +0200
@@ -133,7 +133,7 @@
 #define PATN_COM_F_COM_2INTVEC_INT(PNAME)				\
 {									\
 	NARGCHK    (PNAME,4)		/* get args */			\
-	BLCK_ONECOM(PNAME,0)		/* comm     */			\
+	BLCK_ONECOM(PNAME,0,comm) 	/* comm */			\
 	BLCK_INTVEC(PNAME,1,dims)	/* dims,   ndims    */		\
 	BLCK_INTVEC(PNAME,2,periods)	/* periods,nperiods */		\
 	BLCK_ONEINT(PNAME,3,reorder)					\
@@ -148,7 +148,7 @@
 	int info =  PNAME (comm,	ndims,dims,periods,reorder,	\
 			  &comm_cart );					\
 									\
-	RET_2_ARG  (info,  MPITB_intcast(				\
+	RET_2_ARG  (info,  MPITB_COMM_TO_VAL(				\
 			   comm_cart )	)				\
 }
 
@@ -160,7 +160,7 @@
 #define PATN_COM_F_COM_INTVEC_INTVEC_INT(PNAME)				\
 {									\
 	NARGCHK    (PNAME,4)		/* get args */			\
-	BLCK_ONECOM(PNAME,0)		/* comm     */			\
+	BLCK_ONECOM(PNAME,0,comm) 	/* comm */			\
 	BLCK_INTVEC(PNAME,1,index)	/* index, nindex */		\
 	BLCK_INTVEC(PNAME,2,edges)	/* edges, nedges */		\
 	BLCK_ONEINT(PNAME,3,reorder)					\
@@ -169,7 +169,7 @@
 	int info =  PNAME (comm,nindex,index,edges,reorder,		\
 			  &comm_graph );				\
 									\
-	RET_2_ARG  (info,  MPITB_intcast(				\
+	RET_2_ARG  (info,  MPITB_COMM_TO_VAL(				\
 			   comm_graph )	)				\
 }
 
@@ -186,7 +186,7 @@
 #define PATN_2INT_F_COM(PNAME)						\
 {									\
 	NARGCHK    (PNAME,1)						\
-	BLCK_ONECOM(PNAME,0)						\
+	BLCK_ONECOM(PNAME,0,comm) 	/* comm */			\
 	int int1=0, int2=0,						\
 	    info =  PNAME (comm, &int1, &int2);				\
 	RET_3_ARG  (info,         int1,  int2)				\
@@ -200,7 +200,7 @@
 #define PATN_2INTVEC_F_COM(PNAME)					\
 {									\
 	NARGCHK    (PNAME,1)						\
-	BLCK_ONECOM(PNAME,0)						\
+	BLCK_ONECOM(PNAME,0,comm) 	/* comm */			\
 									\
 	int nindex=0, nedges=0,						\
 	    info  =MPI_Graphdims_get (comm, &nindex, &nedges);		\
@@ -225,7 +225,7 @@
 #define PATN_INT_F_COM_INT(PNAME)					\
 {									\
 	NARGCHK    (PNAME,2)						\
-	BLCK_ONECOM(PNAME,0)		/* comm */			\
+	BLCK_ONECOM(PNAME,0,comm) 	/* comm */			\
 	BLCK_ONEINT(PNAME,1,rank)					\
 									\
 	int nneighs=0,							\
@@ -243,7 +243,7 @@
 #define PATN_INTVEC_NEIGH_F_COM_INT(PNAME)				\
 {									\
 	NARGCHK    (PNAME,2)						\
-	BLCK_ONECOM(PNAME,0)		/* comm */			\
+	BLCK_ONECOM(PNAME,0,comm) 	/* comm */			\
 	BLCK_ONEINT(PNAME,1,rank)					\
 									\
 	int nneighs=0,							\
@@ -273,7 +273,7 @@
 #define PATN_3INTVEC_F_COM(PNAME)					\
 {									\
 	NARGCHK    (PNAME,1)						\
-	BLCK_ONECOM(PNAME,0)						\
+	BLCK_ONECOM(PNAME,0,comm) 	/* comm */			\
 									\
 	int ndims  =0,							\
 	    info   =MPI_Cartdim_get (comm, &ndims);			\
@@ -300,7 +300,7 @@
 #define PATN_INT_F_COM_INTVEC(PNAME)					\
 {									\
 	NARGCHK    (PNAME,2)		/* get args */			\
-	BLCK_ONECOM(PNAME,0)		/* comm     */			\
+	BLCK_ONECOM(PNAME,0,comm) 	/* comm */			\
 	BLCK_INTVEC(PNAME,1,coords)	/* coords, ncoords */		\
 									\
 	int rank=0,							\
@@ -318,7 +318,7 @@
 #define PATN_INTVEC_COORD_F_COM_INT(PNAME)				\
 {									\
 	NARGCHK    (PNAME,2)						\
-	BLCK_ONECOM(PNAME,0)		/* comm */			\
+	BLCK_ONECOM(PNAME,0,comm) 	/* comm */			\
 	BLCK_ONEINT(PNAME,1,rank)					\
 									\
 	int ndims  =0,							\
@@ -342,7 +342,7 @@
 #define PATN_2INT_F_COM_2INT(PNAME)					\
 {									\
 	NARGCHK    (PNAME,3)						\
-	BLCK_ONECOM(PNAME,0)		/* comm */			\
+	BLCK_ONECOM(PNAME,0,comm) 	/* comm */			\
 	BLCK_ONEINT(PNAME,1,dir )					\
 	BLCK_ONEINT(PNAME,2,disp)					\
 									\
@@ -360,14 +360,14 @@
 #define PATN_COM_F_COM_INTVEC(PNAME)					\
 {									\
 	NARGCHK    (PNAME,2)		/* get args */			\
-	BLCK_ONECOM(PNAME,0)		/* comm     */			\
+	BLCK_ONECOM(PNAME,0,comm) 	/* comm */			\
 	BLCK_INTVEC(PNAME,1,dims)	/* dims, ndims */		\
 									\
 	MPI_Comm	   comm_sub=0;					\
 	int info =  PNAME (comm, dims,					\
 			  &comm_sub );					\
 									\
-	RET_2_ARG  (info,  MPITB_intcast(				\
+	RET_2_ARG  (info,  MPITB_COMM_TO_VAL(				\
 			   comm_sub )	)				\
 }
 
@@ -379,7 +379,7 @@
 #define PATN_INT_F_COM_2INTVEC(PNAME)				\
 {									\
 	NARGCHK    (PNAME,3)		/* get args */			\
-	BLCK_ONECOM(PNAME,0)		/* comm     */			\
+	BLCK_ONECOM(PNAME,0,comm) 	/* comm */			\
 	BLCK_INTVEC(PNAME,1,dims)	/* dims,   ndims    */		\
 	BLCK_INTVEC(PNAME,2,periods)	/* periods,nperiods */		\
 									\
@@ -404,7 +404,7 @@
 #define PATN_INT_F_COM_INTVEC_INTVEC(PNAME)				\
 {									\
 	NARGCHK    (PNAME,3)		/* get args */			\
-	BLCK_ONECOM(PNAME,0)		/* comm     */			\
+	BLCK_ONECOM(PNAME,0,comm) 	/* comm */			\
 	BLCK_INTVEC(PNAME,1,index)	/* index, nindex */		\
 	BLCK_INTVEC(PNAME,2,edges)	/* edges, nedges */		\
 									\
diff -up src/DLD-FUNCTIONS/hTstWait.h.orig src/DLD-FUNCTIONS/hTstWait.h
--- src/DLD-FUNCTIONS/hTstWait.h.orig	2007-07-17 11:15:46.000000000 +0200
+++ src/DLD-FUNCTIONS/hTstWait.h	2008-04-02 00:43:21.163635706 +0200
@@ -95,19 +95,19 @@
 	NARGCHK    (PNAME,1)		/* nargin */			\
 	BLCK_ONESYM(PNAME,0,req)	/* reqnam, reqsym */		\
 									\
-	if(! MPITB_isOPtrTyp(args(0))){	/* this could be BLCK_ONEREQ? */\
-	   error(STRFY(PNAME) ": required arg req(ptr)");		\
+					/* this could be BLCK_ONEREQ? */\
+	if(! MPITB_VAL_COULD_BE_REQUEST(args(0))){			\
+	   error(STRFY(PNAME) ": required arg req");			\
 	   return octave_value(MPI_ERR_ARG); /* error returns nothing */\
 	}								\
-	MPI_Request req = MPITB_ptrcast ( MPI_Request, args(0) );
+	MPI_Request req = MPITB_VAL_TO_REQUEST(args(0));
 						/* req copied in */
 				
 
 #define REQ_ONE_END				/* req copied out */	\
-	reqsym->define( MPITB_intcast( req ) );
+	reqsym->define( MPITB_REQUEST_TO_VAL(req) );
 					/* MPI updates req, so do we */
 
-
 /* -------------------------------------------------------------------------
  * REQ_MANY: Take nargin req arguments into source code (name reqs always)
  * REQ_MANY_END: companion macro, copies reqs out (must use both in pairs)
@@ -128,26 +128,25 @@
 	}								\
 									\
 	for (int i=0; i<nargin; i++)	/*this could be BLCK_MANYREQS?*/\
-	 if (! MPITB_isOPtrTyp(args(i))){				\
+	 if (! MPITB_VAL_COULD_BE_REQUEST(args(i))){			\
 	   error(STRFY(PNAME) ": req arguments should be pointers");	\
 	   return octave_value(MPI_ERR_ARG); /* error returns nothing */\
 	}								\
 									\
 	MPI_Request reqs[nargin];					\
 	for (int i=0;  i<nargin; i++){					\
-	   reqs[i] = MPITB_ptrcast ( MPI_Request, args(i) );		\
+	   reqs[i] = MPITB_VAL_TO_REQUEST(args(i));			\
 	}					/* copy reqs in */
 
 
 #define REQ_MANY_END				/* copy reqs out */	\
 	string_vector reqstrvec = args.name_tags();			\
 	for (int i=0; i<nargin; i++){					\
-	  symbol_record*reqsym= curr_sym_tab -> lookup ( reqstrvec (i) );\
-			reqsym->define( MPITB_intcast( reqs[i] ) );	\
+	  symbol_record *reqsym = curr_sym_tab -> lookup ( reqstrvec (i) );\
+	  reqsym->define( MPITB_REQUEST_TO_VAL( reqs[i] ) );		\
 	}
 					/* MPI updates req, so do we */
 
-
 /* -------------------------------------------------------------------------
  * intVEC_PUT: translate C-int vector to Octave-row vector
  * -------------------------------------------------------------------------
@@ -172,7 +171,7 @@
 	NARGCHK    (PNAME,3)		/* handy argchk here */		\
 	BLCK_ONEINT(PNAME,0,src)	/* src  */			\
 	BLCK_ONEINT(PNAME,1,tag)	/* tag  */			\
-	BLCK_ONECOM(PNAME,2)		/* comm */
+	BLCK_ONECOM(PNAME,2,comm) 	/* comm */			\
 
 
 
@@ -196,7 +195,8 @@
 {									\
 	REQ_ONE   (PNAME)						\
 	int        flag =        0 ;					\
-	MPI_Status stat = {0,0,0,0};					\
+	MPI_Status stat;            					\
+	memset(&stat,0,sizeof(stat));					\
 									\
 	int info = PNAME(&req,						\
 			 &flag,            &stat);			\
@@ -213,7 +213,8 @@
 #define PATN_STA_F_REQ(PNAME)						\
 {									\
 	REQ_ONE   (PNAME)						\
-	MPI_Status stat = {0,0,0,0};					\
+	MPI_Status stat;            					\
+	memset(&stat,0,sizeof(stat));					\
 									\
 	int info = PNAME(&req,             &stat);			\
 									\
@@ -264,7 +265,8 @@
 {									\
 	REQ_MANY  (PNAME)						\
 	int idx=0, flag =  0;						\
-	MPI_Status stat = {0,0,0,0};					\
+	MPI_Status stat ;               				\
+	memset(&stat,0,sizeof(stat));					\
 									\
 	int info = PNAME(nargin, reqs,					\
 			&idx, &flag,		 &stat);		\
@@ -282,7 +284,8 @@
 {									\
 	REQ_MANY  (PNAME)						\
 	int        idx  =  0;						\
-	MPI_Status stat = {0,0,0,0};					\
+	MPI_Status stat ;           					\
+	memset(&stat,0,sizeof(stat));					\
 									\
 	int info = PNAME(nargin, reqs,					\
 			&idx,			 &stat);		\
@@ -374,7 +377,8 @@
 	BLCK_2IC  (PNAME)		/* src, tag, comm */		\
 									\
 	int	   flag =  0;						\
-	MPI_Status stat = {0,0,0,0};					\
+	MPI_Status stat ;           					\
+	memset(&stat,0,sizeof(stat));					\
 	int info = PNAME( src,tag,comm, &flag,&stat );			\
 									\
 	Octave_map           os = put_MPI_Stat(stat);			\
@@ -390,7 +394,8 @@
 {									\
 	BLCK_2IC  (PNAME)		/* src, tag, comm */		\
 									\
-	MPI_Status stat = {0,0,0,0};					\
+	MPI_Status stat;            					\
+	memset(&stat,0,sizeof(stat));					\
 	int info = PNAME( src,tag,comm,       &stat );			\
 									\
 	Octave_map           os = put_MPI_Stat(stat);			\
diff -up src/DLD-FUNCTIONS/hType.h.orig src/DLD-FUNCTIONS/hType.h
--- src/DLD-FUNCTIONS/hType.h.orig	2007-07-17 11:15:50.000000000 +0200
+++ src/DLD-FUNCTIONS/hType.h	2008-04-02 01:10:23.123631442 +0200
@@ -61,11 +61,13 @@
   #define MPI_CXX_BOOL    ((MPI_Datatype) &lam_mpi_cxx_bool)
  #elif    OPEN_MPI
   #define MPI_CXX_BOOL    ((MPI_Datatype) &ompi_mpi_cxx_bool)
-//#define MPI_CXX_BOOL	MPI_BOOL
+ #elif    MPICH2
+//#define MPI_CXX_BOOL	MPI_LOGICAL
+  #define MPI_CXX_BOOL	MPIR_CXX_BOOL
  #else
-  #error No bool type known (this is neither LAM/ nor Open-MPI)
+  #error No C++ bool type known (this is neither LAM/ nor Open-MPI)
  #endif	/* LAM_MPI / OPEN_MPI */
-#endif	/* ndef MPI_CXX_BOOL */
+#endif	/* ifndef MPI_CXX_BOOL */
 
 
 /* ----------------------------------------------------------------
diff -up src/DLD-FUNCTIONS/MPI_Attr_put.cc.orig src/DLD-FUNCTIONS/MPI_Attr_put.cc
--- src/DLD-FUNCTIONS/MPI_Attr_put.cc.orig	2007-07-17 11:17:14.000000000 +0200
+++ src/DLD-FUNCTIONS/MPI_Attr_put.cc	2008-04-01 21:53:37.062828469 +0200
@@ -121,7 +121,7 @@ int copywrapper##N(MPI_Comm OLDcomm, int
 	  error("Octave copy wrapper" STRFY(N) ": key not active ?!?");	\
 									\
 octave_value_list args;							\
-args(0) =   MPITB_intcast	      ( OLDcomm );			\
+args(0) =   MPITB_COMM_TO_VAL   ( OLDcomm );			\
 args(1) =				keyval ;			\
 args(2) = * static_cast<octave_value*> (extra_st);/*constr.1 copy more*/\
 args(3) = * static_cast<octave_value*> ( attr_in);/*f/passed void ptrs*/\
@@ -162,7 +162,7 @@ int delwrapper##N(MPI_Comm comm, int key
 	  error("Octave delete wrapper" STRFY(N) ": key not active ?!?");\
 									\
 octave_value_list args;							\
-args(0) =   MPITB_intcast	      ( comm );				\
+args(0) =   MPITB_COMM_TO_VAL   ( comm );				\
 args(1) =				keyval;				\
 args(2) = * static_cast<octave_value*> (attr    );/*constr.1 copy more*/\
 args(3) = * static_cast<octave_value*> (extra_st);/*f/passed void ptrs*/\
@@ -485,7 +485,7 @@ DEFUN_DLD(NAME, args, nargout,
 	/* info = MPI_Attr_put (comm, kv, attr) */
 
 	NARGCHK    (NAME,3)
-	BLCK_ONECOM(NAME,0)		/* comm   */
+	BLCK_ONECOM(NAME,0,comm) 	/* comm */
 	BLCK_ONEINT(NAME,1,keyval)	/* keyval */
 //	BLCK_ONESYM(NAME,2,attr  )	/* attrnam, attrsym */
 	const octave_value&attr  =	/* attr   */
diff -up src/DLD-FUNCTIONS/MPI_BAND.cc.orig src/DLD-FUNCTIONS/MPI_BAND.cc
--- src/DLD-FUNCTIONS/MPI_BAND.cc.orig	2007-07-17 11:17:15.000000000 +0200
+++ src/DLD-FUNCTIONS/MPI_BAND.cc	2008-03-31 22:57:06.356773854 +0200
@@ -18,7 +18,7 @@
 #include "hConst.h"		// GEN_PTR/RET_PTR system
 
 #define   NAME	MPI_BAND
-GEN_1_PTR(NAME)
+GEN_1_MPI_OP(NAME)
 #undef		MPI_BAND
 DEFUN_DLD(NAME, args, nargout,
 "MPI_BAND               MPITB constant for corresponding MPI_Op object\n\
@@ -28,5 +28,5 @@ DEFUN_DLD(NAME, args, nargout,
 ")
 {
 	NARGCHK (NAME,0)
-	RET_1_PTR
+	RET_1_MPI_OP
 }
diff -up src/DLD-FUNCTIONS/MPI_BOR.cc.orig src/DLD-FUNCTIONS/MPI_BOR.cc
--- src/DLD-FUNCTIONS/MPI_BOR.cc.orig	2007-07-17 11:17:17.000000000 +0200
+++ src/DLD-FUNCTIONS/MPI_BOR.cc	2008-03-31 22:57:23.605828740 +0200
@@ -18,7 +18,7 @@
 #include "hConst.h"		// GEN_PTR/RET_PTR system
 
 #define   NAME	MPI_BOR
-GEN_1_PTR(NAME)
+GEN_1_MPI_OP(NAME)
 #undef		MPI_BOR
 DEFUN_DLD(NAME, args, nargout,
 "MPI_BOR                MPITB constant for corresponding MPI_Op object\n\
@@ -28,5 +28,5 @@ DEFUN_DLD(NAME, args, nargout,
 ")
 {
 	NARGCHK (NAME,0)
-	RET_1_PTR
+	RET_1_MPI_OP
 }
diff -up src/DLD-FUNCTIONS/MPI_BXOR.cc.orig src/DLD-FUNCTIONS/MPI_BXOR.cc
--- src/DLD-FUNCTIONS/MPI_BXOR.cc.orig	2007-07-17 11:17:23.000000000 +0200
+++ src/DLD-FUNCTIONS/MPI_BXOR.cc	2008-03-31 22:57:36.306772264 +0200
@@ -18,7 +18,7 @@
 #include "hConst.h"		// GEN_PTR/RET_PTR system
 
 #define   NAME	MPI_BXOR
-GEN_1_PTR(NAME)
+GEN_1_MPI_OP(NAME)
 #undef		MPI_BXOR
 DEFUN_DLD(NAME, args, nargout,
 "MPI_BXOR               MPITB constant for corresponding MPI_Op object\n\
@@ -28,5 +28,5 @@ DEFUN_DLD(NAME, args, nargout,
 ")
 {
 	NARGCHK (NAME,0)
-	RET_1_PTR
+	RET_1_MPI_OP
 }
diff -up src/DLD-FUNCTIONS/MPI_COMM_NULL.cc.orig src/DLD-FUNCTIONS/MPI_COMM_NULL.cc
--- src/DLD-FUNCTIONS/MPI_COMM_NULL.cc.orig	2007-07-17 11:17:41.000000000 +0200
+++ src/DLD-FUNCTIONS/MPI_COMM_NULL.cc	2008-04-01 17:13:31.843286681 +0200
@@ -18,7 +18,7 @@
 #include "hConst.h"		// GEN_PTR/RET_PTR system
 
 #define   NAME	MPI_COMM_NULL
-GEN_1_PTR(NAME)
+GEN_1_MPI_COMM(NAME)
 #undef		MPI_COMM_NULL
 DEFUN_DLD(NAME, args, nargout,
 "MPI_COMM_NULL          MPITB constant for corresponding handle\n\
@@ -28,5 +28,5 @@ DEFUN_DLD(NAME, args, nargout,
 ")
 {
 	NARGCHK (NAME,0)
-	RET_1_PTR
+	RET_1_MPI_COMM
 }
diff -up src/DLD-FUNCTIONS/MPI_COMM_SELF.cc.orig src/DLD-FUNCTIONS/MPI_COMM_SELF.cc
--- src/DLD-FUNCTIONS/MPI_COMM_SELF.cc.orig	2007-07-17 11:17:45.000000000 +0200
+++ src/DLD-FUNCTIONS/MPI_COMM_SELF.cc	2008-03-31 23:15:11.719802329 +0200
@@ -18,7 +18,7 @@
 #include "hConst.h"		// GEN_PTR/RET_PTR system
 
 #define   NAME	MPI_COMM_SELF
-GEN_1_PTR(NAME)
+GEN_1_MPI_COMM(NAME)
 #undef		MPI_COMM_SELF
 DEFUN_DLD(NAME, args, nargout,
 "MPI_COMM_SELF          MPITB constant for corresponding MPI_Comm object\n\
@@ -28,5 +28,5 @@ DEFUN_DLD(NAME, args, nargout,
 ")
 {
 	NARGCHK (NAME,0)
-	RET_1_PTR
+	RET_1_MPI_COMM
 }
diff -up src/DLD-FUNCTIONS/MPI_Comm_spawn.cc.orig src/DLD-FUNCTIONS/MPI_Comm_spawn.cc
--- src/DLD-FUNCTIONS/MPI_Comm_spawn.cc.orig	2007-07-17 11:17:46.000000000 +0200
+++ src/DLD-FUNCTIONS/MPI_Comm_spawn.cc	2008-04-01 22:22:13.478292639 +0200
@@ -15,6 +15,7 @@
  * ----------------------------------------------------
  */
 #include "mpitb.h"	// buildblocks NARGCHK, etc
+#include "hInfo.h"	// buildblocks BLCK_ONEINF, etc
 #include <ov-cell.h>	// avoid errmsg "cell -- incomplete datatype"
 #include <quit.h>	// OCTAVE_QUIT
 
@@ -80,12 +81,9 @@ DEFUN_DLD(NAME, args, nargout,
 	|| (! args(1).is_cell       () )
 	|| (! args(2).is_real_scalar() )
 	|| (! args(4).is_real_scalar() )
-//	|| (! args(3).is_real_scalar() )
-//	|| (! args(5).is_real_scalar())){
-	|| (! MPITB_isOPtrTyp (args(3)))
-	|| (! MPITB_isOPtrTyp (args(5)))){
+        ) {
 	error(STRNGFY(NAME) ": required prog(str), args(cellstr), "
-		"nproc(int), inf(ptr), root(int), parents(ptr)");
+		"nproc(int), inf, root(int), parents");
 	return octave_value(MPI_ERR_ARG);	// error returns nothing
     }
 
@@ -101,9 +99,9 @@ DEFUN_DLD(NAME, args, nargout,
 
     Cell   argcell = args(1).  cell_value();
     int    nproc   = args(2).   int_value();
+    BLCK_ONEINF(NAME,3,inf)
     int    root    = args(4).   int_value();
-  MPI_Info inf     = MPITB_ptrcast(MPI_Info, args(3));
-  MPI_Comm parents = MPITB_ptrcast(MPI_Comm, args(5));
+    BLCK_ONECOM(NAME,5,parents)
 
     if (argcell.rows() > 1){
 	error(STRNGFY(NAME) ": required arg#2: args(cellstr 1xN)");
@@ -145,7 +143,7 @@ DEFUN_DLD(NAME, args, nargout,
 //  RET_3_ARG(info, (int)children, m)
     octave_value_list retval;
 	   retval(2) =     m;
-	   retval(1) =  MPITB_intcast(children);
+	   retval(1) =  MPITB_COMM_TO_VAL(children);
 	   retval(0) =  info;
     return retval;
 }
diff -up src/DLD-FUNCTIONS/MPI_Comm_spawn_multiple.cc.orig src/DLD-FUNCTIONS/MPI_Comm_spawn_multiple.cc
--- src/DLD-FUNCTIONS/MPI_Comm_spawn_multiple.cc.orig	2007-07-17 11:17:47.000000000 +0200
+++ src/DLD-FUNCTIONS/MPI_Comm_spawn_multiple.cc	2008-04-01 22:22:31.698366308 +0200
@@ -16,6 +16,7 @@
  * ----------------------------------------------------
  */
 #include "mpitb.h"	// buildblocks NARGCHK, etc
+#include "hInfo.h"	// buildblocks BLCK_ONEINF, etc
 #include <ov-cell.h>	// avoid errmsg "cell -- incomplete datatype"
 #include <quit.h>	// OCTAVE_QUIT
 
@@ -84,10 +85,9 @@ DEFUN_DLD(NAME, args, nargout,
 	|| (! args(2).is_cell       () )	/***************/
 	|| (! args(3).is_cell       () )
 	|| (! args(4).is_real_scalar() )
-	|| (! MPITB_isOPtrTyp(args(5)))){
-//	|| (! args(5).is_real_scalar())){
+      ){
 	error(STRNGFY(NAME) ": required cprg(cellstr), carg(cell-cellstr), "
-		"cnprc(cellint), cinf(cellptr), root(int), parents(ptr)");
+		"cnprc(cellint), cinf(cellptr), root(int), parents");
 	return octave_value(MPI_ERR_ARG);	// error returns nothing
     }
 
@@ -96,7 +96,7 @@ DEFUN_DLD(NAME, args, nargout,
     		&cnpr    = args(2).cell_value(),/***************/
     		&cinf    = args(3).cell_value();
     int   root           = args(4). int_value();
- MPI_Comm parents        = MPITB_ptrcast(MPI_Comm, args(5));
+    BLCK_ONECOM(NAME,5,parents)
 
 						/***************/
 						/* DIMS-CHECK  */
@@ -195,7 +195,7 @@ DEFUN_DLD(NAME, args, nargout,
 
 MPI_Info inf  [nprg];
 	for (int i=0; i<nprg; i++)
-	  inf  [i] = MPITB_ptrcast( MPI_Info, cinf(i,0) );
+	  inf  [i] = MPITB_VAL_TO_INFO( cinf(i,0) );
 
 						/***************/
 						/* MPI BINDING */
@@ -221,7 +221,7 @@ MPI_Comm children;
 						/***************/
     octave_value_list retval;
 	   retval (0) = info;
-	   retval (1) = MPITB_intcast(children);
+	   retval (1) = MPITB_COMM_TO_VAL(children);
 	   retval (2) = merr;
     return retval;
 }
diff -up src/DLD-FUNCTIONS/MPI_COMM_WORLD.cc.orig src/DLD-FUNCTIONS/MPI_COMM_WORLD.cc
--- src/DLD-FUNCTIONS/MPI_COMM_WORLD.cc.orig	2007-07-17 11:17:49.000000000 +0200
+++ src/DLD-FUNCTIONS/MPI_COMM_WORLD.cc	2008-03-31 23:01:09.542026209 +0200
@@ -18,7 +18,7 @@
 #include "hConst.h"		// GEN_PTR/RET_PTR system
 
 #define   NAME	MPI_COMM_WORLD
-GEN_1_PTR(NAME)
+GEN_1_MPI_COMM(NAME)
 #undef		MPI_COMM_WORLD
 DEFUN_DLD(NAME,	args, nargout,
 "MPI_COMM_WORLD         MPITB constant for corresponding MPI_Comm object\n\
@@ -28,5 +28,5 @@ DEFUN_DLD(NAME,	args, nargout,
 ")
 {
 	NARGCHK (NAME,0)
-	RET_1_PTR
+	RET_1_MPI_COMM
 }
diff -up src/DLD-FUNCTIONS/MPI_Errhandler_create.cc.orig src/DLD-FUNCTIONS/MPI_Errhandler_create.cc
--- src/DLD-FUNCTIONS/MPI_Errhandler_create.cc.orig	2007-07-17 11:18:13.000000000 +0200
+++ src/DLD-FUNCTIONS/MPI_Errhandler_create.cc	2008-04-01 14:46:21.325036470 +0200
@@ -62,7 +62,7 @@ char*ermsg=va_arg  (arglist, char *);			
 	   va_end  (arglist);						\
 									\
 octave_value_list args;							\
-	args(0) = MPITB_intcast (					\
+	args(0) = MPITB_COMM_TO_VAL (					\
 		  *cptr );						\
 	args(1) = *eptr;						\
 	args(2) = ercod;						\
@@ -191,7 +191,7 @@ DEFUN_DLD(NAME, args, nargout,
     if (info ==  MPI_SUCCESS)
 			ehfun[i].OctaveCMD =
 				 OctaveCMD ;
-    RET_2_ARG (info, MPITB_intcast (
+    RET_2_ARG (info, MPITB_ERRHANDLER_TO_VAL (
 			ehfun[i].eh)      )
 }
 
@@ -242,7 +242,7 @@ DEFUN_DLD(NAME, args, nargout,
     if (info ==  MPI_SUCCESS)
 			ehfun[i].OctaveCMD = "";
 
-    ehsym->define(MPITB_intcast(
+    ehsym->define(MPITB_ERRHANDLER_TO_VAL(
 			ehfun[i].eh ));
     RET_1_ARG   (info)
 }
diff -up src/DLD-FUNCTIONS/MPI_Errhandler_free.cc.orig src/DLD-FUNCTIONS/MPI_Errhandler_free.cc
--- src/DLD-FUNCTIONS/MPI_Errhandler_free.cc.orig	2007-07-17 11:18:13.000000000 +0200
+++ src/DLD-FUNCTIONS/MPI_Errhandler_free.cc	2008-04-01 15:19:20.586074839 +0200
@@ -62,7 +62,7 @@ char*ermsg=va_arg  (arglist, char *);			
 	   va_end  (arglist);						\
 									\
 octave_value_list args;							\
-	args(0) = MPITB_intcast (					\
+	args(0) = MPITB_COMM_TO_VAL (					\
 		  *cptr );						\
 	args(1) = *eptr;						\
 	args(2) = ercod;						\
@@ -191,8 +191,8 @@ DEFUN_DLD(NAME, args, nargout,
     if (info ==  MPI_SUCCESS)
 			ehfun[i].OctaveCMD =
 				 OctaveCMD ;
-    RET_2_ARG (info, MPITB_intcast (
-			ehfun[i].eh)      )
+    RET_2_ARG (info, MPITB_ERRHANDLER_TO_VAL (
+			ehfun[i].eh )      )
 }
 
 
@@ -242,7 +242,7 @@ DEFUN_DLD(NAME, args, nargout,
     if (info ==  MPI_SUCCESS)
 			ehfun[i].OctaveCMD = "";
 
-    ehsym->define(MPITB_intcast(
+    ehsym->define(MPITB_ERRHANDLER_TO_VAL(
 			ehfun[i].eh ));
     RET_1_ARG   (info)
 }
diff -up src/DLD-FUNCTIONS/MPI_ERRHANDLER_NULL.cc.orig src/DLD-FUNCTIONS/MPI_ERRHANDLER_NULL.cc
--- src/DLD-FUNCTIONS/MPI_ERRHANDLER_NULL.cc.orig	2007-07-17 11:18:24.000000000 +0200
+++ src/DLD-FUNCTIONS/MPI_ERRHANDLER_NULL.cc	2008-03-31 23:50:47.391450452 +0200
@@ -18,7 +18,7 @@
 #include "hConst.h"		// GEN_PTR/RET_PTR system
 
 #define   NAME	MPI_ERRHANDLER_NULL
-GEN_1_PTR(NAME)
+GEN_1_MPI_ERRHANDLER(NAME)
 #undef		MPI_ERRHANDLER_NULL
 DEFUN_DLD(NAME, args, nargout,
 "MPI_ERRHANDLER_NULL   MPITB constant for corresponding handle\n\
@@ -28,5 +28,5 @@ DEFUN_DLD(NAME, args, nargout,
 ")
 {
 	NARGCHK (NAME,0)
-	RET_1_PTR
+	RET_1_MPI_ERRHANDLER
 }
diff -up src/DLD-FUNCTIONS/MPI_ERRORS_ARE_FATAL.cc.orig src/DLD-FUNCTIONS/MPI_ERRORS_ARE_FATAL.cc
--- src/DLD-FUNCTIONS/MPI_ERRORS_ARE_FATAL.cc.orig	2007-07-17 11:18:43.000000000 +0200
+++ src/DLD-FUNCTIONS/MPI_ERRORS_ARE_FATAL.cc	2008-03-31 23:50:54.142490856 +0200
@@ -18,7 +18,7 @@
 #include "hConst.h"		// GEN_PTR/RET_PTR system
 
 #define   NAME	MPI_ERRORS_ARE_FATAL
-GEN_1_PTR(NAME)
+GEN_1_MPI_ERRHANDLER(NAME)
 #undef		MPI_ERRORS_ARE_FATAL
 DEFUN_DLD(NAME, args, nargout,
 "MPI_ERRORS_ARE_FATAL  MPITB constant for corresponding MPI_Errhandler object\n\
@@ -29,5 +29,5 @@ DEFUN_DLD(NAME, args, nargout,
 ")
 {
 	NARGCHK (NAME,0)
-	RET_1_PTR
+	RET_1_MPI_ERRHANDLER
 }
diff -up src/DLD-FUNCTIONS/MPI_ERRORS_RETURN.cc.orig src/DLD-FUNCTIONS/MPI_ERRORS_RETURN.cc
--- src/DLD-FUNCTIONS/MPI_ERRORS_RETURN.cc.orig	2007-07-17 11:18:43.000000000 +0200
+++ src/DLD-FUNCTIONS/MPI_ERRORS_RETURN.cc	2008-03-31 23:51:00.298491925 +0200
@@ -18,7 +18,7 @@
 #include "hConst.h"		// GEN_PTR/RET_PTR system
 
 #define   NAME	MPI_ERRORS_RETURN
-GEN_1_PTR(NAME)
+GEN_1_MPI_ERRHANDLER(NAME)
 #undef		MPI_ERRORS_RETURN
 DEFUN_DLD(NAME, args, nargout,
 "MPI_ERRORS_RETURN     MPITB constant for corresponding MPI_Errhandler object\n\
@@ -29,5 +29,5 @@ DEFUN_DLD(NAME, args, nargout,
 ")
 {
 	NARGCHK (NAME,0)
-	RET_1_PTR
+	RET_1_MPI_ERRHANDLER
 }
diff -up src/DLD-FUNCTIONS/MPI_FILE_NULL.cc.orig src/DLD-FUNCTIONS/MPI_FILE_NULL.cc
--- src/DLD-FUNCTIONS/MPI_FILE_NULL.cc.orig	2007-07-17 11:19:06.000000000 +0200
+++ src/DLD-FUNCTIONS/MPI_FILE_NULL.cc	2008-04-01 18:40:48.331164094 +0200
@@ -18,7 +18,7 @@
 #include "hConst.h"		// GEN_PTR/RET_PTR system
 
 #define   NAME	MPI_FILE_NULL
-GEN_1_PTR(NAME)
+GEN_1_MPI_FILE(NAME)
 #undef		MPI_FILE_NULL
 DEFUN_DLD(NAME, args, nargout,
 "MPI_FILE_NULL          MPITB constant for corresponding handle\n\
@@ -28,5 +28,5 @@ DEFUN_DLD(NAME, args, nargout,
 ")
 {
 	NARGCHK (NAME,0)
-	RET_1_PTR
+	RET_1_MPI_FILE
 }
diff -up src/DLD-FUNCTIONS/MPI_GROUP_EMPTY.cc.orig src/DLD-FUNCTIONS/MPI_GROUP_EMPTY.cc
--- src/DLD-FUNCTIONS/MPI_GROUP_EMPTY.cc.orig	2007-07-17 11:19:21.000000000 +0200
+++ src/DLD-FUNCTIONS/MPI_GROUP_EMPTY.cc	2008-03-31 23:47:05.769304510 +0200
@@ -18,7 +18,7 @@
 #include "hConst.h"		// GEN_PTR/RET_PTR system
 
 #define   NAME	MPI_GROUP_EMPTY
-GEN_1_PTR(NAME)
+GEN_1_MPI_GROUP(NAME)
 #undef		MPI_GROUP_EMPTY
 DEFUN_DLD(NAME, args, nargout,
 "MPI_GROUP_EMPTY        MPITB constant for corresponding MPI_Group object\n\
@@ -28,5 +28,5 @@ DEFUN_DLD(NAME, args, nargout,
 ")
 {
 	NARGCHK (NAME,0)
-	RET_1_PTR
+	RET_1_MPI_GROUP
 }
diff -up src/DLD-FUNCTIONS/MPI_GROUP_NULL.cc.orig src/DLD-FUNCTIONS/MPI_GROUP_NULL.cc
--- src/DLD-FUNCTIONS/MPI_GROUP_NULL.cc.orig	2007-07-17 11:19:25.000000000 +0200
+++ src/DLD-FUNCTIONS/MPI_GROUP_NULL.cc	2008-03-31 23:47:19.106283815 +0200
@@ -18,7 +18,7 @@
 #include "hConst.h"		// GEN_PTR/RET_PTR system
 
 #define   NAME	MPI_GROUP_NULL
-GEN_1_PTR(NAME)
+GEN_1_MPI_GROUP(NAME)
 #undef		MPI_GROUP_NULL
 DEFUN_DLD(NAME, args, nargout,
 "MPI_GROUP_NULL         MPITB constant for corresponding handle\n\
@@ -28,5 +28,5 @@ DEFUN_DLD(NAME, args, nargout,
 ")
 {
 	NARGCHK (NAME,0)
-	RET_1_PTR
+	RET_1_MPI_GROUP
 }
diff -up src/DLD-FUNCTIONS/MPI_INFO_NULL.cc.orig src/DLD-FUNCTIONS/MPI_INFO_NULL.cc
--- src/DLD-FUNCTIONS/MPI_INFO_NULL.cc.orig	2007-07-17 11:19:37.000000000 +0200
+++ src/DLD-FUNCTIONS/MPI_INFO_NULL.cc	2008-03-31 23:52:58.069508098 +0200
@@ -18,7 +18,7 @@
 #include "hConst.h"		// GEN_PTR/RET_PTR system
 
 #define   NAME	MPI_INFO_NULL
-GEN_1_PTR(NAME)
+GEN_1_MPI_INFO(NAME)
 #undef		MPI_INFO_NULL
 DEFUN_DLD(NAME, args, nargout,
 "MPI_INFO_NULL          MPITB constant for corresponding handle\n\
@@ -28,5 +28,5 @@ DEFUN_DLD(NAME, args, nargout,
 ")
 {
 	NARGCHK (NAME,0)
-	RET_1_PTR
+	RET_1_MPI_INFO
 }
diff -up src/DLD-FUNCTIONS/MPI_Keyval_create.cc.orig src/DLD-FUNCTIONS/MPI_Keyval_create.cc
--- src/DLD-FUNCTIONS/MPI_Keyval_create.cc.orig	2007-07-17 11:17:14.000000000 +0200
+++ src/DLD-FUNCTIONS/MPI_Keyval_create.cc	2008-04-01 21:53:54.313888689 +0200
@@ -121,7 +121,7 @@ int copywrapper##N(MPI_Comm OLDcomm, int
 	  error("Octave copy wrapper" STRFY(N) ": key not active ?!?");	\
 									\
 octave_value_list args;							\
-args(0) =   MPITB_intcast	      ( OLDcomm );			\
+args(0) =   MPITB_COMM_TO_VAL   ( OLDcomm );			\
 args(1) =				keyval ;			\
 args(2) = * static_cast<octave_value*> (extra_st);/*constr.1 copy more*/\
 args(3) = * static_cast<octave_value*> ( attr_in);/*f/passed void ptrs*/\
@@ -162,7 +162,7 @@ int delwrapper##N(MPI_Comm comm, int key
 	  error("Octave delete wrapper" STRFY(N) ": key not active ?!?");\
 									\
 octave_value_list args;							\
-args(0) =   MPITB_intcast	      ( comm );				\
+args(0) =   MPITB_COMM_TO_VAL   ( comm );				\
 args(1) =				keyval;				\
 args(2) = * static_cast<octave_value*> (attr    );/*constr.1 copy more*/\
 args(3) = * static_cast<octave_value*> (extra_st);/*f/passed void ptrs*/\
@@ -485,7 +485,7 @@ DEFUN_DLD(NAME, args, nargout,
 	/* info = MPI_Attr_put (comm, kv, attr) */
 
 	NARGCHK    (NAME,3)
-	BLCK_ONECOM(NAME,0)		/* comm   */
+	BLCK_ONECOM(NAME,0,comm) 	/* comm */
 	BLCK_ONEINT(NAME,1,keyval)	/* keyval */
 //	BLCK_ONESYM(NAME,2,attr  )	/* attrnam, attrsym */
 	const octave_value&attr  =	/* attr   */
diff -up src/DLD-FUNCTIONS/MPI_Keyval_free.cc.orig src/DLD-FUNCTIONS/MPI_Keyval_free.cc
--- src/DLD-FUNCTIONS/MPI_Keyval_free.cc.orig	2007-07-17 11:17:14.000000000 +0200
+++ src/DLD-FUNCTIONS/MPI_Keyval_free.cc	2008-04-01 21:54:04.432959217 +0200
@@ -121,7 +121,7 @@ int copywrapper##N(MPI_Comm OLDcomm, int
 	  error("Octave copy wrapper" STRFY(N) ": key not active ?!?");	\
 									\
 octave_value_list args;							\
-args(0) =   MPITB_intcast	      ( OLDcomm );			\
+args(0) =   MPITB_COMM_TO_VAL   ( OLDcomm );			\
 args(1) =				keyval ;			\
 args(2) = * static_cast<octave_value*> (extra_st);/*constr.1 copy more*/\
 args(3) = * static_cast<octave_value*> ( attr_in);/*f/passed void ptrs*/\
@@ -162,7 +162,7 @@ int delwrapper##N(MPI_Comm comm, int key
 	  error("Octave delete wrapper" STRFY(N) ": key not active ?!?");\
 									\
 octave_value_list args;							\
-args(0) =   MPITB_intcast	      ( comm );				\
+args(0) =   MPITB_COMM_TO_VAL   ( comm );				\
 args(1) =				keyval;				\
 args(2) = * static_cast<octave_value*> (attr    );/*constr.1 copy more*/\
 args(3) = * static_cast<octave_value*> (extra_st);/*f/passed void ptrs*/\
@@ -485,7 +485,7 @@ DEFUN_DLD(NAME, args, nargout,
 	/* info = MPI_Attr_put (comm, kv, attr) */
 
 	NARGCHK    (NAME,3)
-	BLCK_ONECOM(NAME,0)		/* comm   */
+	BLCK_ONECOM(NAME,0,comm) 	/* comm */
 	BLCK_ONEINT(NAME,1,keyval)	/* keyval */
 //	BLCK_ONESYM(NAME,2,attr  )	/* attrnam, attrsym */
 	const octave_value&attr  =	/* attr   */
diff -up src/DLD-FUNCTIONS/MPI_LAND.cc.orig src/DLD-FUNCTIONS/MPI_LAND.cc
--- src/DLD-FUNCTIONS/MPI_LAND.cc.orig	2007-07-17 11:19:57.000000000 +0200
+++ src/DLD-FUNCTIONS/MPI_LAND.cc	2008-03-31 22:57:55.811887201 +0200
@@ -18,7 +18,7 @@
 #include "hConst.h"		// GEN_PTR/RET_PTR system
 
 #define   NAME	MPI_LAND
-GEN_1_PTR(NAME)
+GEN_1_MPI_OP(NAME)
 #undef		MPI_LAND
 DEFUN_DLD(NAME, args, nargout,
 "MPI_LAND               MPITB constant for corresponding MPI_Op object\n\
@@ -28,5 +28,5 @@ DEFUN_DLD(NAME, args, nargout,
 ")
 {
 	NARGCHK (NAME,0)
-	RET_1_PTR
+	RET_1_MPI_OP
 }
diff -up src/DLD-FUNCTIONS/MPI_LOR.cc.orig src/DLD-FUNCTIONS/MPI_LOR.cc
--- src/DLD-FUNCTIONS/MPI_LOR.cc.orig	2007-07-17 11:19:59.000000000 +0200
+++ src/DLD-FUNCTIONS/MPI_LOR.cc	2008-03-31 22:58:04.182821171 +0200
@@ -18,7 +18,7 @@
 #include "hConst.h"		// GEN_PTR/RET_PTR system
 
 #define   NAME	MPI_LOR
-GEN_1_PTR(NAME)
+GEN_1_MPI_OP(NAME)
 #undef		MPI_LOR
 DEFUN_DLD(NAME, args, nargout,
 "MPI_LOR                MPITB constant for corresponding MPI_Op object\n\
@@ -28,5 +28,5 @@ DEFUN_DLD(NAME, args, nargout,
 ")
 {
 	NARGCHK (NAME,0)
-	RET_1_PTR
+	RET_1_MPI_OP
 }
diff -up src/DLD-FUNCTIONS/MPI_LXOR.cc.orig src/DLD-FUNCTIONS/MPI_LXOR.cc
--- src/DLD-FUNCTIONS/MPI_LXOR.cc.orig	2007-07-17 11:19:59.000000000 +0200
+++ src/DLD-FUNCTIONS/MPI_LXOR.cc	2008-03-31 22:58:10.431808192 +0200
@@ -18,7 +18,7 @@
 #include "hConst.h"		// GEN_PTR/RET_PTR system
 
 #define   NAME	MPI_LXOR
-GEN_1_PTR(NAME)
+GEN_1_MPI_OP(NAME)
 #undef		MPI_LXOR
 DEFUN_DLD(NAME, args, nargout,
 "MPI_LXOR               MPITB constant for corresponding MPI_Op object\n\
@@ -28,5 +28,5 @@ DEFUN_DLD(NAME, args, nargout,
 ")
 {
 	NARGCHK (NAME,0)
-	RET_1_PTR
+	RET_1_MPI_OP
 }
diff -up src/DLD-FUNCTIONS/MPI_MAX.cc.orig src/DLD-FUNCTIONS/MPI_MAX.cc
--- src/DLD-FUNCTIONS/MPI_MAX.cc.orig	2007-07-17 11:20:00.000000000 +0200
+++ src/DLD-FUNCTIONS/MPI_MAX.cc	2008-03-31 22:58:17.473807603 +0200
@@ -18,7 +18,7 @@
 #include "hConst.h"		// GEN_PTR/RET_PTR system
 
 #define   NAME	MPI_MAX
-GEN_1_PTR(NAME)
+GEN_1_MPI_OP(NAME)
 #undef		MPI_MAX
 DEFUN_DLD(NAME, args, nargout,
 "MPI_MAX                MPITB constant for corresponding MPI_Op object\n\
@@ -28,5 +28,5 @@ DEFUN_DLD(NAME, args, nargout,
 ")
 {
 	NARGCHK (NAME,0)
-	RET_1_PTR
+	RET_1_MPI_OP
 }
diff -up src/DLD-FUNCTIONS/MPI_MAX_NAME_LEN.cc.orig src/DLD-FUNCTIONS/MPI_MAX_NAME_LEN.cc
--- src/DLD-FUNCTIONS/MPI_MAX_NAME_LEN.cc.orig	2007-07-17 11:20:02.000000000 +0200
+++ src/DLD-FUNCTIONS/MPI_MAX_NAME_LEN.cc	2008-03-26 13:25:28.860853167 +0100
@@ -16,6 +16,9 @@
 #include "mpitb.h"		// buildblocks NARGCHK, etc
 #include "hConst.h"		// GEN_INT/RET_INT system
 
+#ifndef MPI_MAX_NAME_LEN
+#define   MPI_MAX_NAME_LEN MPI_MAX_PORT_NAME 
+#endif
 #define   NAME	MPI_MAX_NAME_LEN
 GEN_1_INT(NAME)
 #undef		MPI_MAX_NAME_LEN
diff -up src/DLD-FUNCTIONS/MPI_MIN.cc.orig src/DLD-FUNCTIONS/MPI_MIN.cc
--- src/DLD-FUNCTIONS/MPI_MIN.cc.orig	2007-07-17 11:20:05.000000000 +0200
+++ src/DLD-FUNCTIONS/MPI_MIN.cc	2008-03-31 22:58:24.012884855 +0200
@@ -18,7 +18,7 @@
 #include "hConst.h"		// GEN_PTR/RET_PTR system
 
 #define   NAME	MPI_MIN
-GEN_1_PTR(NAME)
+GEN_1_MPI_OP(NAME)
 #undef		MPI_MIN
 DEFUN_DLD(NAME, args, nargout,
 "MPI_MIN                MPITB constant for corresponding MPI_Op object\n\
@@ -28,5 +28,5 @@ DEFUN_DLD(NAME, args, nargout,
 ")
 {
 	NARGCHK (NAME,0)
-	RET_1_PTR
+	RET_1_MPI_OP
 }
diff -up src/DLD-FUNCTIONS/MPI_OP_NULL.cc.orig src/DLD-FUNCTIONS/MPI_OP_NULL.cc
--- src/DLD-FUNCTIONS/MPI_OP_NULL.cc.orig	2007-07-17 11:20:08.000000000 +0200
+++ src/DLD-FUNCTIONS/MPI_OP_NULL.cc	2008-03-31 22:58:28.647849028 +0200
@@ -18,7 +18,7 @@
 #include "hConst.h"		// GEN_PTR/RET_PTR system
 
 #define   NAME	MPI_OP_NULL
-GEN_1_PTR(NAME)
+GEN_1_MPI_OP(NAME)
 #undef		MPI_OP_NULL
 DEFUN_DLD(NAME, args, nargout,
 "MPI_OP_NULL            MPITB constant for corresponding handle\n\
@@ -28,5 +28,5 @@ DEFUN_DLD(NAME, args, nargout,
 ")
 {
 	NARGCHK (NAME,0)
-	RET_1_PTR
+	RET_1_MPI_OP
 }
diff -up src/DLD-FUNCTIONS/MPI_Pack.cc.orig src/DLD-FUNCTIONS/MPI_Pack.cc
--- src/DLD-FUNCTIONS/MPI_Pack.cc.orig	2007-07-17 11:20:09.000000000 +0200
+++ src/DLD-FUNCTIONS/MPI_Pack.cc	2008-04-01 21:48:22.117552733 +0200
@@ -548,7 +548,7 @@ t_id, Octave type_name, and correspondin
 	BLCK_ONESYM(NAME,1,buf)		// bufnam, bufsym
 	BLCK_NULSYM(NAME,2,pos)		// no NULL-check for possym
 	BLCK_ONEINT(NAME,2,pos)		// pos -> IDX (global scope)
-	BLCK_ONECOM(NAME,3)		// comm-> COM (global scope)
+	BLCK_ONECOM(NAME,3,comm)	// comm-> COM (global scope)
 
 	BUF = get_MPI_Buff (bufsym,SIZ,true,	// SIZ in bytes
 				 TYPE, true);	// buffer MK_UNIQ
diff -up src/DLD-FUNCTIONS/MPI_Pack_size.cc.orig src/DLD-FUNCTIONS/MPI_Pack_size.cc
--- src/DLD-FUNCTIONS/MPI_Pack_size.cc.orig	2007-07-17 11:20:10.000000000 +0200
+++ src/DLD-FUNCTIONS/MPI_Pack_size.cc	2008-04-01 21:48:34.413563152 +0200
@@ -427,7 +427,7 @@ DEFUN_DLD(NAME, args, nargout,
  * first arg must be variable
  * ---------------------------------------------------------------- */
 	BLCK_ONESYM(NAME,0,var)		// varnam, varsym
-	BLCK_ONECOM(NAME,1)		// comm-> COM (global scope)
+	BLCK_ONECOM(NAME,1,comm)	// comm-> COM (global scope)
 
 	COM = comm;
     int size = size_class (args(0), varnam);
diff -up src/DLD-FUNCTIONS/MPI_PROD.cc.orig src/DLD-FUNCTIONS/MPI_PROD.cc
--- src/DLD-FUNCTIONS/MPI_PROD.cc.orig	2007-07-17 11:20:12.000000000 +0200
+++ src/DLD-FUNCTIONS/MPI_PROD.cc	2008-03-31 22:58:35.606862524 +0200
@@ -18,7 +18,7 @@
 #include "hConst.h"		// GEN_PTR/RET_PTR system
 
 #define   NAME	MPI_PROD
-GEN_1_PTR(NAME)
+GEN_1_MPI_OP(NAME)
 #undef		MPI_PROD
 DEFUN_DLD(NAME, args, nargout,
 "MPI_PROD               MPITB constant for corresponding MPI_Op object\n\
@@ -28,5 +28,5 @@ DEFUN_DLD(NAME, args, nargout,
 ")
 {
 	NARGCHK (NAME,0)
-	RET_1_PTR
+	RET_1_MPI_OP
 }
diff -up src/DLD-FUNCTIONS/MPI_REPLACE.cc.orig src/DLD-FUNCTIONS/MPI_REPLACE.cc
--- src/DLD-FUNCTIONS/MPI_REPLACE.cc.orig	2007-07-17 11:20:16.000000000 +0200
+++ src/DLD-FUNCTIONS/MPI_REPLACE.cc	2008-03-31 23:52:12.778439659 +0200
@@ -18,7 +18,7 @@
 #include "hConst.h"		// GEN_PTR/RET_PTR system
 
 #define   NAME	MPI_REPLACE
-GEN_1_PTR(NAME)
+GEN_1_MPI_OP(NAME)
 #undef		MPI_REPLACE
 DEFUN_DLD(NAME, args, nargout,
 "MPI_REPLACE            MPITB constant for corresponding MPI_Op object\n\
@@ -28,5 +28,5 @@ DEFUN_DLD(NAME, args, nargout,
 ")
 {
 	NARGCHK (NAME,0)
-	RET_1_PTR
+	RET_1_MPI_OP
 }
diff -up src/DLD-FUNCTIONS/MPI_REQUEST_NULL.cc.orig src/DLD-FUNCTIONS/MPI_REQUEST_NULL.cc
--- src/DLD-FUNCTIONS/MPI_REQUEST_NULL.cc.orig	2007-07-17 11:20:17.000000000 +0200
+++ src/DLD-FUNCTIONS/MPI_REQUEST_NULL.cc	2008-03-31 23:53:11.549599382 +0200
@@ -18,7 +18,7 @@
 #include "hConst.h"		// GEN_PTR/RET_PTR system
 
 #define   NAME	MPI_REQUEST_NULL
-GEN_1_PTR(NAME)
+GEN_1_MPI_REQUEST(NAME)
 #undef		MPI_REQUEST_NULL
 DEFUN_DLD(NAME, args, nargout,
 "MPI_REQUEST_NULL       MPITB constant for corresponding handle\n\
@@ -28,5 +28,5 @@ DEFUN_DLD(NAME, args, nargout,
 ")
 {
 	NARGCHK (NAME,0)
-	RET_1_PTR
+	RET_1_MPI_REQUEST
 }
diff -up src/DLD-FUNCTIONS/MPI_SUM.cc.orig src/DLD-FUNCTIONS/MPI_SUM.cc
--- src/DLD-FUNCTIONS/MPI_SUM.cc.orig	2007-07-17 11:20:29.000000000 +0200
+++ src/DLD-FUNCTIONS/MPI_SUM.cc	2008-03-31 22:59:49.368896949 +0200
@@ -18,7 +18,7 @@
 #include "hConst.h"		// GEN_PTR/RET_PTR system
 
 #define   NAME	MPI_SUM
-GEN_1_PTR(NAME)
+GEN_1_MPI_OP(NAME)
 #undef		MPI_SUM
 DEFUN_DLD(NAME, args, nargout,
 "MPI_SUM                MPITB constant for corresponding MPI_Op object\n\
@@ -28,5 +28,5 @@ DEFUN_DLD(NAME, args, nargout,
 ")
 {
 	NARGCHK (NAME,0)
-	RET_1_PTR
+	RET_1_MPI_OP
 }
diff -up src/DLD-FUNCTIONSmpitb.h.orig src/DLD-FUNCTIONS/mpitb.h
--- src/DLD-FUNCTIONS/mpitb.h.orig	2008-03-20 09:26:32.314347727 +0100
+++ src/DLD-FUNCTIONS/mpitb.h	2008-04-02 01:11:14.267595587 +0200
@@ -109,7 +109,7 @@ typedef int octave_idx_type;
 #define MPITB_64BIT		0
 #define MPITB_ST_offset		1
 #endif
-				// Minimal check that ov could be a pointer
+
 #define MPITB_isOPtrTyp(ov)	((ov.is_scalar_type())&&(ov.is_numeric_type()))
 				// construct octave_value from MPI C-Pointer
 #define MPITB_intcast(cptr)			MPITB_OctPtrTyp		 (\
@@ -118,6 +118,57 @@ typedef int octave_idx_type;
 #define MPITB_ptrcast(typ,ov)	reinterpret_cast <typ> ( ov.		  \
 						MPITB_OctIntFcn().value() )
 
+#if defined(LAM) || defined(OPEN_MPI)
+  #define MPITB_COMM_TO_VAL(comm )     (MPITB_intcast(comm ))
+  #define MPITB_VAL_TO_COMM(ov)        (MPITB_ptrcast(MPI_Comm,ov))
+  #define MPITB_VAL_COULD_BE_COMM(ov)  (MPITB_isOPtrTyp(ov))
+
+  #define MPITB_ERRHANDLER_TO_VAL(eh)  (MPITB_intcast(eh   ))
+  #define MPITB_VAL_TO_ERRHANDLER(ov)  (MPITB_ptrcast(MPI_Errhandler,ov))
+  #define MPITB_VAL_COULD_BE_ERRHANDLER(ov)  (MPITB_isOPtrTyp(ov))
+
+  #define MPITB_GROUP_TO_VAL(group)    (MPITB_intcast(group))
+  #define MPITB_VAL_TO_GROUP(ov)       (MPITB_ptrcast(MPI_Group,ov))
+  #define MPITB_VAL_COULD_BE_GROUP(ov) (MPITB_isOPtrTyp(ov))
+
+  #define MPITB_INFO_TO_VAL(info )     (MPITB_intcast(info ))
+  #define MPITB_VAL_TO_INFO(ov)        (MPITB_ptrcast(MPI_Info,ov))
+  #define MPITB_VAL_COULD_BE_INFO(ov)  (MPITB_isOPtrTyp(ov))
+
+  #define MPITB_REQUEST_TO_VAL(req  )  (MPITB_intcast(req  ))
+  #define MPITB_VAL_TO_REQUEST(ov)     (MPITB_ptrcast(MPI_Request,ov))
+  #define MPITB_VAL_COULD_BE_REQUEST(ov) (MPITB_isOPtrTyp(ov))
+
+  #define MPITB_OP_TO_VAL(op   )       (MPITB_intcast(op   ))
+  #define MPITB_VAL_TO_OP(ov)          (MPITB_ptrcast(MPI_Op,ov))
+  #define MPITB_VAL_COULD_BE_OP(ov)    (MPITB_isOPtrTyp(ov))
+#elif defined(MPICH2)
+  #define MPITB_COMM_TO_VAL(comm )     (static_cast<unsigned long> (comm ))
+  #define MPITB_VAL_TO_COMM(ov)        (static_cast<MPI_Comm> (ov.int_value()))
+  #define MPITB_VAL_COULD_BE_COMM(ov)  (ov.is_real_scalar())
+
+  #define MPITB_ERRHANDLER_TO_VAL(eh)  (static_cast<unsigned long> (eh   ))
+  #define MPITB_VAL_TO_ERRHANDLER(ov)  (static_cast<MPI_Errhandler> (ov.int_value()))
+  #define MPITB_VAL_COULD_BE_ERRHANDLER(ov)  (ov.is_real_scalar())
+
+  #define MPITB_GROUP_TO_VAL(group)    (static_cast<unsigned long> (group))
+  #define MPITB_VAL_TO_GROUP(ov)       (static_cast<MPI_Group> (ov.int_value()))
+  #define MPITB_VAL_COULD_BE_GROUP(ov) (ov.is_real_scalar())
+
+  #define MPITB_INFO_TO_VAL(info )     (static_cast<unsigned long> (info ))
+  #define MPITB_VAL_TO_INFO(ov)        (static_cast<MPI_Info> (ov.int_value()))
+  #define MPITB_VAL_COULD_BE_INFO(ov)  (ov.is_real_scalar())
+
+  #define MPITB_REQUEST_TO_VAL(req  )  (static_cast<unsigned long> (req  ))
+  #define MPITB_VAL_TO_REQUEST(ov)     (static_cast<MPI_Request> (ov.int_value()))
+  #define MPITB_VAL_COULD_BE_REQUEST(ov) (ov.is_real_scalar())
+
+  #define MPITB_OP_TO_VAL(op   )       (static_cast<unsigned long> (op   ))
+  #define MPITB_VAL_TO_OP(ov)          (static_cast<MPI_Op> (ov.int_value()))
+  #define MPITB_VAL_COULD_BE_OP(ov)    (ov.is_real_scalar())
+#else
+  #error MPI implementation not recognized. Fix me!
+#endif
 
 /* -------------------------------------------------------------------------
  * -------- Building Blocks ------------------------------------------------
@@ -332,12 +383,12 @@ typedef int octave_idx_type;
  * -------------------------------------------------------------------------
  */
 
-#define BLCK_ONECOM(PNAME,ARGN)		/* ARG Nth in arglist  */	\
-	if ( ! MPITB_isOPtrTyp(args(ARGN)) ){				\
-	error(STRFY(PNAME)	": required arg#%d: comm(ptr)", ARGN+1);\
+#define BLCK_ONECOM(PNAME,ARGN,COMM)	/* ARG Nth in arglist  */	\
+	if ( ! MPITB_VAL_COULD_BE_COMM(args(ARGN)) ){			\
+	  error(STRFY(PNAME)	": required arg#%d: comm", ARGN+1);	\
 	  RET_1_ARG(MPI_ERR_ARG);	/* error returns nothing */	\
 	}								\
-	MPI_Comm comm = MPITB_ptrcast ( MPI_Comm, args(ARGN) );
+	MPI_Comm COMM = MPITB_VAL_TO_COMM(args(ARGN));
 
 
 /* -------------------------------------------------------------------------
@@ -474,7 +525,7 @@ typedef int octave_idx_type;
 	MPI_Comm               comm=0;					\
 	int        info=PNAME( &comm );					\
 	RET_2_ARG (info,						\
-		MPITB_intcast( comm ))					\
+		MPITB_COMM_TO_VAL( comm ))				\
 }
 
 
@@ -522,7 +573,7 @@ typedef int octave_idx_type;
 #define PATN_F_COM( PNAME)		/* programNAME */		\
 {									\
 	NARGCHK    (PNAME,1)						\
-	BLCK_ONECOM(PNAME,0)		 /* comm  */			\
+	BLCK_ONECOM(PNAME,0,comm)	 /* comm  */			\
 	int info =  PNAME		   (comm);			\
 	RET_1_ARG  (info)						\
 }
@@ -546,7 +597,7 @@ typedef int octave_idx_type;
 #define PATN_INT_F_COM(PNAME)						\
 {									\
 	NARGCHK       (PNAME,1)						\
-	BLCK_ONECOM   (PNAME,0)		/* comm */			\
+	BLCK_ONECOM   (PNAME,0,comm)	/* comm */			\
     int int0=0,   info=PNAME (comm, &int0);				\
 	RET_2_ARG(info,		     int0)				\
 }
@@ -559,7 +610,7 @@ typedef int octave_idx_type;
 #define PATN_F_COM_INT(PNAME,  INTNAME)	/* programNAME, int-arg-NAME */	\
 {									\
 	NARGCHK       (PNAME,2)						\
-	BLCK_ONECOM   (PNAME,0)		/* comm    */			\
+	BLCK_ONECOM   (PNAME,0,comm)	/* comm    */			\
 	BLCK_ONEINT   (PNAME,1,INTNAME)	/* errcode */			\
 									\
 	int info=PNAME(comm,   INTNAME);				\
@@ -574,13 +625,13 @@ typedef int octave_idx_type;
 #define PATN_COM_F_COM_INT(PNAME,INAM)	/* programNAME, int-arg-NAME */	\
 {					/* -> hGrp.h ? */		\
 	NARGCHK       (PNAME,2)						\
-	BLCK_ONECOM   (PNAME,0)		/* comm */			\
+	BLCK_ONECOM   (PNAME,0,comm)	/* comm */			\
 	BLCK_ONEINT   (PNAME,1,INAM)	/* high */			\
 									\
 	MPI_Comm                    intracomm=0;			\
 	int info=PNAME(comm, INAM, &intracomm );			\
 	RET_2_ARG     (info,						\
-		      MPITB_intcast(intracomm ))			\
+		      MPITB_COMM_TO_VAL(intracomm ))			\
 }
 
 
diff -up src/DLD-FUNCTIONS/MPI_Unpack.cc.orig src/DLD-FUNCTIONS/MPI_Unpack.cc
--- src/DLD-FUNCTIONS/MPI_Unpack.cc.orig	2007-07-17 11:20:37.000000000 +0200
+++ src/DLD-FUNCTIONS/MPI_Unpack.cc	2008-04-01 21:49:44.111562511 +0200
@@ -495,7 +495,7 @@ DEFUN_DLD(NAME, args, nargout,
 	BLCK_ONESYM(NAME,0,buf)		// bufnam, bufsym
 	BLCK_NULSYM(NAME,1,pos)		// no NULL-check for possym
 	BLCK_ONEINT(NAME,1,pos)		// pos -> IDX (global scope)
-	BLCK_ONECOM(NAME,2)		// comm-> COM (global scope)
+	BLCK_ONECOM(NAME,2,comm)	// comm-> COM (global scope)
 
 	BUF = get_MPI_Buff(bufsym, SIZ,true,	// SIZ in bytes
 				  TYPE,false);	// buffer MK_UNIQ not required
diff -up src/DLD-FUNCTIONS/MPI_WIN_NULL.cc.orig src/DLD-FUNCTIONS/MPI_WIN_NULL.cc
--- src/DLD-FUNCTIONS/MPI_WIN_NULL.cc.orig	2007-07-17 11:20:42.000000000 +0200
+++ src/DLD-FUNCTIONS/MPI_WIN_NULL.cc	2008-03-31 23:53:24.961565501 +0200
@@ -18,7 +18,7 @@
 #include "hConst.h"		// GEN_PTR/RET_PTR system
 
 #define   NAME	MPI_WIN_NULL
-GEN_1_PTR(NAME)
+GEN_1_MPI_WIN(NAME)
 #undef		MPI_WIN_NULL
 DEFUN_DLD(NAME, args, nargout,
 "MPI_WIN_NULL           MPITB constant for corresponding handle\n\
@@ -28,5 +28,5 @@ DEFUN_DLD(NAME, args, nargout,
 ")
 {
 	NARGCHK (NAME,0)
-	RET_1_PTR
+	RET_1_MPI_WIN
 }