[mpich2-commits] r5487 - in mpich2/trunk/src: include mpid/ch3/channels/nemesis/nemesis/netmod/tcp mpid/ch3/channels/nemesis/nemesis/src mpid/ch3/channels/nemesis/src mpid/ch3/include mpid/ch3/src pmi/pmi2

buntinas at mcs.anl.gov buntinas at mcs.anl.gov
Mon Oct 19 17:33:48 CDT 2009


Author: buntinas
Date: 2009-10-19 17:33:48 -0500 (Mon, 19 Oct 2009)
New Revision: 5487

Added:
   mpich2/trunk/src/pmi/pmi2/pmi2compat.h
Modified:
   mpich2/trunk/src/include/pmi2.h
   mpich2/trunk/src/mpid/ch3/channels/nemesis/nemesis/netmod/tcp/socksm.c
   mpich2/trunk/src/mpid/ch3/channels/nemesis/nemesis/src/mpid_nem_alloc.c
   mpich2/trunk/src/mpid/ch3/channels/nemesis/src/ch3_abort.c
   mpich2/trunk/src/mpid/ch3/include/mpidimpl.h
   mpich2/trunk/src/mpid/ch3/src/ch3u_comm_spawn_multiple.c
   mpich2/trunk/src/mpid/ch3/src/mpid_abort.c
   mpich2/trunk/src/mpid/ch3/src/mpid_get_universe_size.c
   mpich2/trunk/src/mpid/ch3/src/mpid_init.c
   mpich2/trunk/src/mpid/ch3/src/mpid_vc.c
   mpich2/trunk/src/mpid/ch3/src/mpidi_pg.c
   mpich2/trunk/src/pmi/pmi2/configure.in
   mpich2/trunk/src/pmi/pmi2/simple2pmi.c
   mpich2/trunk/src/pmi/pmi2/simple2pmi.h
   mpich2/trunk/src/pmi/pmi2/simple_pmiutil.c
   mpich2/trunk/src/pmi/pmi2/simple_pmiutil.h
Log:
renamed pmi v2 functions to PMI2_; removed mpi error codes from pmi2

Modified: mpich2/trunk/src/include/pmi2.h
===================================================================
--- mpich2/trunk/src/include/pmi2.h	2009-10-19 19:24:19 UTC (rev 5486)
+++ mpich2/trunk/src/include/pmi2.h	2009-10-19 22:33:48 UTC (rev 5487)
@@ -11,18 +11,53 @@
 #error This header file defines the PMI2 API, but PMI2 was not selected
 #endif
 
-#define PMI_MAX_KEYLEN 64
-#define PMI_MAX_VALLEN 1024
-#define PMI_MAX_ATTRVALUE 1024
+#define PMI2_MAX_KEYLEN 64
+#define PMI2_MAX_VALLEN 1024
+#define PMI2_MAX_ATTRVALUE 1024
 
 #if defined(__cplusplus)
 extern "C" {
 #endif
-#if 0
-} /* this is here to keep emacs from indenting everything in the
-   * extern "C" block */
-#endif
 
+/*D
+PMI2_CONSTANTS - PMI2 definitions
+
+Error Codes:
++ PMI2_SUCCESS - operation completed successfully
+. PMI2_FAIL - operation failed
+. PMI2_ERR_NOMEM - input buffer not large enough
+. PMI2_ERR_INIT - PMI not initialized
+. PMI2_ERR_INVALID_ARG - invalid argument
+. PMI2_ERR_INVALID_KEY - invalid key argument
+. PMI2_ERR_INVALID_KEY_LENGTH - invalid key length argument
+. PMI2_ERR_INVALID_VAL - invalid val argument
+. PMI2_ERR_INVALID_VAL_LENGTH - invalid val length argument
+. PMI2_ERR_INVALID_LENGTH - invalid length argument
+. PMI2_ERR_INVALID_NUM_ARGS - invalid number of arguments
+. PMI2_ERR_INVALID_ARGS - invalid args argument
+. PMI2_ERR_INVALID_NUM_PARSED - invalid num_parsed length argument
+. PMI2_ERR_INVALID_KEYVALP - invalid keyvalp argument
+. PMI2_ERR_INVALID_SIZE - invalid size argument
+- PMI2_ERR_OTHER - other unspecified error
+
+D*/
+#define PMI2_SUCCESS                0
+#define PMI2_FAIL                   -1
+#define PMI2_ERR_INIT               1
+#define PMI2_ERR_NOMEM              2
+#define PMI2_ERR_INVALID_ARG        3
+#define PMI2_ERR_INVALID_KEY        4
+#define PMI2_ERR_INVALID_KEY_LENGTH 5
+#define PMI2_ERR_INVALID_VAL        6
+#define PMI2_ERR_INVALID_VAL_LENGTH 7
+#define PMI2_ERR_INVALID_LENGTH     8
+#define PMI2_ERR_INVALID_NUM_ARGS   9
+#define PMI2_ERR_INVALID_ARGS       10
+#define PMI2_ERR_INVALID_NUM_PARSED 11
+#define PMI2_ERR_INVALID_KEYVALP    12
+#define PMI2_ERR_INVALID_SIZE       13
+#define PMI2_ERR_OTHER              14
+
 /* This is here to allow spawn multiple functions to compile.  This
    needs to be removed once those functions are fixed for pmi2 */
 typedef struct PMI_keyval_t
@@ -33,7 +68,7 @@
 
 
 /*@
-  PMI_Connect_comm_t - connection structure used when connecting to other jobs
+  PMI2_Connect_comm_t - connection structure used when connecting to other jobs
 
   Fields:
   + read - Read from a connection to the leader of the job to which
@@ -59,17 +94,17 @@
   that it manages).
   
 @*/
-typedef struct PMI_Connect_comm {
+typedef struct PMI2_Connect_comm {
     int (*read)( void *buf, int maxlen, void *ctx );
     int (*write)( const void *buf, int len, void *ctx );
     void *ctx;
     int  isMaster;
-} PMI_Connect_comm_t;
+} PMI2_Connect_comm_t;
 
 struct MPID_Info;
 
 /*@
-  PMI_Init - initialize the Process Manager Interface
+  PMI2_Init - initialize the Process Manager Interface
 
   Output Parameter:
   + spawned - spawned flag
@@ -82,14 +117,14 @@
   
   Notes:
   Initialize PMI for this process group. The value of spawned indicates whether
-  this process was created by 'PMI_Spawn_multiple'.  'spawned' will be non-zero
+  this process was created by 'PMI2_Spawn_multiple'.  'spawned' will be non-zero
   iff this process group has a parent.
 
 @*/
-int PMI_Init(int *spawned, int *size, int *rank, int *appnum);
+int PMI2_Init(int *spawned, int *size, int *rank, int *appnum);
 
 /*@
-  PMI_Finalize - finalize the Process Manager Interface
+  PMI2_Finalize - finalize the Process Manager Interface
   
   Return values:
   Returns 'MPI_SUCCESS' on success and an MPI error code on failure.
@@ -98,19 +133,19 @@
   Finalize PMI for this job.
   
 @*/
-int PMI_Finalize(void);
+int PMI2_Finalize(void);
 
 /*@
-  PMI_Initialized - check if PMI has been initialized
+  PMI2_Initialized - check if PMI has been initialized
 
   Return values:
-  Non-zero if PMI_Initialize has been called successfully, zero otherwise.
+  Non-zero if PMI2_Initialize has been called successfully, zero otherwise.
   
 @*/
-int PMI_Initialized(void);
+int PMI2_Initialized(void);
 
 /*@
-  PMI_Abort - abort the process group associated with this process
+  PMI2_Abort - abort the process group associated with this process
   
   Input Parameters:
   + flag - non-zero if all processes in this job should abort, zero otherwise
@@ -121,10 +156,10 @@
   error code otherwise.
 
 @*/
-int PMI_Abort(int flag, const char msg[]);
+int PMI2_Abort(int flag, const char msg[]);
 
 /*@
-  PMI_Spawn - spawn a new set of processes
+  PMI2_Spawn - spawn a new set of processes
 
   Input Parameters:
   + count - count of commands
@@ -159,7 +194,7 @@
   mpiexec in the MPI-2 standard.  Environment variables may be passed to the
   spawned processes through PMI implementation specific 'info_keyval' parameters.
 @*/
-int PMI_Job_Spawn(int count, const char * cmds[], const char ** argvs[],
+int PMI2_Job_Spawn(int count, const char * cmds[], const char ** argvs[],
                   const int maxprocs[], 
                   const int info_keyval_sizes[],
                   const struct MPID_Info *info_keyval_vectors[],
@@ -170,7 +205,7 @@
 
 
 /*@
-  PMI_Job_GetId - get job id of this job 
+  PMI2_Job_GetId - get job id of this job 
 
   Input parameters:
   . jobid_size - size of buffer provided in jobid
@@ -182,10 +217,10 @@
   Returns 'MPI_SUCCESS' on success and an MPI error code on failure.
 
 @*/
-int PMI_Job_GetId(char jobid[], int jobid_size);
+int PMI2_Job_GetId(char jobid[], int jobid_size);
 
 /*@
-  PMI_Job_Connect - connect to the parallel job with ID jobid
+  PMI2_Job_Connect - connect to the parallel job with ID jobid
 
   Input parameters:
   . jobid - job id of the job to connect to
@@ -199,17 +234,17 @@
 
   Notes:
   This just "registers" the other parallel job as part of a parallel
-  program, and is used in the PMI_KVS_xxx routines (see below). This
+  program, and is used in the PMI2_KVS_xxx routines (see below). This
   is not a collective call and establishes a connection between all
   processes that are connected to the calling processes (on the one
   side) and that are connected to the named jobId on the other
   side. Processes that are already connected may call this routine.
 
 @*/
-int PMI_Job_Connect(const char jobid[], PMI_Connect_comm_t *conn);
+int PMI2_Job_Connect(const char jobid[], PMI2_Connect_comm_t *conn);
 
 /*@
-  PMI_Job_Disconnect - disconnects from the job with ID jobid
+  PMI2_Job_Disconnect - disconnects from the job with ID jobid
 
   Input parameters:
   . jobid - job id of the job to connect to
@@ -218,10 +253,10 @@
   Returns 'MPI_SUCCESS' on success and an MPI error code on failure.
 
 @*/
-int PMI_Job_Disconnect(const char jobid[]);
+int PMI2_Job_Disconnect(const char jobid[]);
 
 /*@
-  PMI_KVS_Put - put a key/value pair in the keyval space for this job
+  PMI2_KVS_Put - put a key/value pair in the keyval space for this job
 
   Input Parameters:
   + key - key
@@ -231,15 +266,15 @@
   Returns 'MPI_SUCCESS' on success and an MPI error code on failure.
 
   Notes:
-  If multiple PMI_KVS_Put calls are made with the same key between
-  calls to PMI_KVS_Fence, the behavior is undefined. That is, the
-  value returned by PMI_KVS_Get for that key after the PMI_KVS_Fence
+  If multiple PMI2_KVS_Put calls are made with the same key between
+  calls to PMI2_KVS_Fence, the behavior is undefined. That is, the
+  value returned by PMI2_KVS_Get for that key after the PMI2_KVS_Fence
   is not defined.
 
 @*/
-int PMI_KVS_Put(const char key[], const char value[]);
+int PMI2_KVS_Put(const char key[], const char value[]);
 /*@
-  PMI_KVS_Fence - commit all PMI_KVS_Put calls made before this fence
+  PMI2_KVS_Fence - commit all PMI2_KVS_Put calls made before this fence
 
   Return values:
   Returns 'MPI_SUCCESS' on success and an MPI error code on failure.
@@ -248,19 +283,19 @@
   This is a collective call across the job.  It has semantics that are
   similar to those for MPI_Win_fence and hence is most easily
   implemented as a barrier across all of the processes in the job.
-  Specifically, all PMI_KVS_Put operations performed by any process in
-  the same job must be visible to all processes (by using PMI_KVS_Get)
-  after PMI_KVS_Fence completes.  However, a PMI implementation could
+  Specifically, all PMI2_KVS_Put operations performed by any process in
+  the same job must be visible to all processes (by using PMI2_KVS_Get)
+  after PMI2_KVS_Fence completes.  However, a PMI implementation could
   make this a lazy operation by not waiting for all processes to enter
-  their corresponding PMI_KVS_Fence until some process issues a
-  PMI_KVS_Get. This might be appropriate for some wide-area
+  their corresponding PMI2_KVS_Fence until some process issues a
+  PMI2_KVS_Get. This might be appropriate for some wide-area
   implementations.
   
 @*/
-int PMI_KVS_Fence(void);
+int PMI2_KVS_Fence(void);
 
 /*@
-  PMI_KVS_Get - returns the value associated with key in the key-value
+  PMI2_KVS_Get - returns the value associated with key in the key-value
       space associated with the job ID jobid
 
   Input Parameters:
@@ -278,10 +313,10 @@
   Returns 'MPI_SUCCESS' on success and an MPI error code on failure.
 
 @*/
-int PMI_KVS_Get(const char *jobid, const char key[], char value [], int maxvalue, int *vallen);
+int PMI2_KVS_Get(const char *jobid, const char key[], char value [], int maxvalue, int *vallen);
 
 /*@
-  PMI_Info_GetNodeAttr - returns the value of the attribute associated
+  PMI2_Info_GetNodeAttr - returns the value of the attribute associated
       with this node
 
   Input Parameters:
@@ -298,7 +333,7 @@
   Returns 'MPI_SUCCESS' on success and an MPI error code on failure.
 
   Notes:
-  This provides a way, when combined with PMI_Info_PutNodeAttr, for
+  This provides a way, when combined with PMI2_Info_PutNodeAttr, for
   processes on the same node to share information without requiring a
   more general barrier across the entire job.
 
@@ -318,10 +353,10 @@
     file.  Returned as a string.
 
 @*/
-int PMI_Info_GetNodeAttr(const char name[], char value[], int valuelen, int *found, int waitfor);
+int PMI2_Info_GetNodeAttr(const char name[], char value[], int valuelen, int *found, int waitfor);
 
 /*@
-  PMI_Info_GetNodeAttrIntArray - returns the value of the attribute associated
+  PMI2_Info_GetNodeAttrIntArray - returns the value of the attribute associated
       with this node.  The value must be an array of integers.
 
   Input Parameters:
@@ -337,7 +372,7 @@
   Returns 'MPI_SUCCESS' on success and an MPI error code on failure.
 
   Notes:
-  Notice that, unlike PMI_Info_GetNodeAttr, this function does not
+  Notice that, unlike PMI2_Info_GetNodeAttr, this function does not
   have a waitfor parameter, and will return immediately with found=0
   if the attribute was not found.
 
@@ -352,10 +387,10 @@
     cartesian.
 
 @*/
-int PMI_Info_GetNodeAttrIntArray(const char name[], int array[], int arraylen, int *outlen, int *found);
+int PMI2_Info_GetNodeAttrIntArray(const char name[], int array[], int arraylen, int *outlen, int *found);
 
 /*@
-  PMI_Info_PutNodeAttr - stores the value of the named attribute
+  PMI2_Info_PutNodeAttr - stores the value of the named attribute
   associated with this node
 
   Input Parameters:
@@ -370,10 +405,10 @@
   processes on the same SMP node.
   
 @*/
-int PMI_Info_PutNodeAttr(const char name[], const char value[]);
+int PMI2_Info_PutNodeAttr(const char name[], const char value[]);
 
 /*@
-  PMI_Info_GetJobAttr - returns the value of the attribute associated
+  PMI2_Info_GetJobAttr - returns the value of the attribute associated
   with this job
 
   Input Parameters:
@@ -388,10 +423,10 @@
   Returns 'MPI_SUCCESS' on success and an MPI error code on failure.
 
 @*/
-int PMI_Info_GetJobAttr(const char name[], char value[], int valuelen, int *found);
+int PMI2_Info_GetJobAttr(const char name[], char value[], int valuelen, int *found);
 
 /*@
-  PMI_Info_GetJobAttrIntArray - returns the value of the attribute associated
+  PMI2_Info_GetJobAttrIntArray - returns the value of the attribute associated
       with this job.  The value must be an array of integers.
 
   Input Parameters:
@@ -411,7 +446,7 @@
   + universeSize - The size of the "universe" (defined for the MPI
     attribute MPI_UNIVERSE_SIZE
 
-  . hasNameServ - The value hasNameServ is true if the PMI environment
+  . hasNameServ - The value hasNameServ is true if the PMI2 environment
     supports the name service operations (publish, lookup, and
     unpublish).
     
@@ -440,7 +475,7 @@
   . cartDims - Return a string of comma-separated values describing
     the dimensions of the Cartesian topology. This must be consistent
     with the value of cartCoords that may be returned by
-    PMI_Info_GetNodeAttrIntArray.
+    PMI2_Info_GetNodeAttrIntArray.
 
     These job attributes are just a start, but they provide both an
     example of the sort of external data that is available through the
@@ -453,10 +488,10 @@
     underlying data models.
 
 @*/
-int PMI_Info_GetJobAttrIntArray(const char name[], int array[], int arraylen, int *outlen, int *found);
+int PMI2_Info_GetJobAttrIntArray(const char name[], int array[], int arraylen, int *outlen, int *found);
 
 /*@
-  PMI_Nameserv_publish - publish a name 
+  PMI2_Nameserv_publish - publish a name 
 
   Input parameters:
   + service_name - string representing the service being published
@@ -467,10 +502,10 @@
   Returns 'MPI_SUCCESS' on success and an MPI error code on failure.
 
 @*/
-int PMI_Nameserv_publish(const char service_name[], const struct MPID_Info *info_ptr, const char port[]);
+int PMI2_Nameserv_publish(const char service_name[], const struct MPID_Info *info_ptr, const char port[]);
 
 /*@
-  PMI_Nameserv_lookup - lookup a service by name
+  PMI2_Nameserv_lookup - lookup a service by name
 
   Input parameters:
   + service_name - string representing the service being published
@@ -484,10 +519,10 @@
   Returns 'MPI_SUCCESS' on success and an MPI error code on failure.
 
 @*/
-int PMI_Nameserv_lookup(const char service_name[], const struct MPID_Info *info_ptr,
+int PMI2_Nameserv_lookup(const char service_name[], const struct MPID_Info *info_ptr,
                         char port[], int portLen);
 /*@
-  PMI_Nameserv_unpublish - unpublish a name
+  PMI2_Nameserv_unpublish - unpublish a name
 
   Input parameters:
   + service_name - string representing the service being unpublished
@@ -497,7 +532,7 @@
   Returns 'MPI_SUCCESS' on success and an MPI error code on failure.
 
 @*/
-int PMI_Nameserv_unpublish(const char service_name[], 
+int PMI2_Nameserv_unpublish(const char service_name[], 
                            const struct MPID_Info *info_ptr);
 
 

Modified: mpich2/trunk/src/mpid/ch3/channels/nemesis/nemesis/netmod/tcp/socksm.c
===================================================================
--- mpich2/trunk/src/mpid/ch3/channels/nemesis/nemesis/netmod/tcp/socksm.c	2009-10-19 19:24:19 UTC (rev 5486)
+++ mpich2/trunk/src/mpid/ch3/channels/nemesis/nemesis/netmod/tcp/socksm.c	2009-10-19 22:33:48 UTC (rev 5487)
@@ -785,7 +785,7 @@
             int val_max_sz;
 
 #ifdef USE_PMI2_API
-            val_max_sz = PMI_MAX_VALLEN;
+            val_max_sz = PMI2_MAX_VALLEN;
 #else
             pmi_errno = PMI_KVS_Get_value_length_max(&val_max_sz);
             MPIU_ERR_CHKANDJUMP1(pmi_errno, mpi_errno, MPI_ERR_OTHER, "**fail", "**fail %d", pmi_errno);

Modified: mpich2/trunk/src/mpid/ch3/channels/nemesis/nemesis/src/mpid_nem_alloc.c
===================================================================
--- mpich2/trunk/src/mpid/ch3/channels/nemesis/nemesis/src/mpid_nem_alloc.c	2009-10-19 19:24:19 UTC (rev 5486)
+++ mpich2/trunk/src/mpid/ch3/channels/nemesis/nemesis/src/mpid_nem_alloc.c	2009-10-19 22:33:48 UTC (rev 5487)
@@ -237,16 +237,16 @@
              * serializing operation with our peers on the local node this
              * ensures that these initializations have occurred before any peer
              * attempts to use the resources. */
-            mpi_errno = PMI_Info_PutNodeAttr("sharedFilename", serialized_hnd);
+            mpi_errno = PMI2_Info_PutNodeAttr("sharedFilename", serialized_hnd);
             if (mpi_errno) MPIU_ERR_POP(mpi_errno);
         } else {
             int found = FALSE;
 
             /* Allocate space for pmi key and val */
-            MPIU_CHKLMEM_MALLOC(val, char *, PMI_MAX_VALLEN, mpi_errno, "val");
+            MPIU_CHKLMEM_MALLOC(val, char *, PMI2_MAX_VALLEN, mpi_errno, "val");
 
             /* get name of shared file */
-            mpi_errno = PMI_Info_GetNodeAttr("sharedFilename", val, PMI_MAX_VALLEN, &found, TRUE);
+            mpi_errno = PMI2_Info_GetNodeAttr("sharedFilename", val, PMI2_MAX_VALLEN, &found, TRUE);
             if (mpi_errno) MPIU_ERR_POP(mpi_errno);
             MPIU_ERR_CHKANDJUMP1(!found, mpi_errno, MPI_ERR_OTHER, "**intern", "**intern %s", "nodeattr not found");
 

Modified: mpich2/trunk/src/mpid/ch3/channels/nemesis/src/ch3_abort.c
===================================================================
--- mpich2/trunk/src/mpid/ch3/channels/nemesis/src/ch3_abort.c	2009-10-19 19:24:19 UTC (rev 5486)
+++ mpich2/trunk/src/mpid/ch3/channels/nemesis/src/ch3_abort.c	2009-10-19 22:33:48 UTC (rev 5487)
@@ -23,7 +23,7 @@
     MPIDI_FUNC_ENTER(MPID_STATE_MPIDI_CH3_ABORT);
 
 #ifdef USE_PMI2_API
-    PMI_Abort(TRUE, error_msg);
+    PMI2_Abort(TRUE, error_msg);
 #else
     PMI_Abort(exit_code, error_msg);
 #endif

Modified: mpich2/trunk/src/mpid/ch3/include/mpidimpl.h
===================================================================
--- mpich2/trunk/src/mpid/ch3/include/mpidimpl.h	2009-10-19 19:24:19 UTC (rev 5486)
+++ mpich2/trunk/src/mpid/ch3/include/mpidimpl.h	2009-10-19 22:33:48 UTC (rev 5487)
@@ -47,6 +47,8 @@
 int gethostname(char *name, size_t len);
 # endif
 
+extern int MPIDI_Use_pmi2_api;
+
 #define MPIDI_CHANGE_VC_STATE(vc, new_state) do {               \
         MPIU_DBG_VCSTATECHANGE(vc, VC_STATE_##new_state);       \
         (vc)->state = MPIDI_VC_STATE_##new_state;               \

Modified: mpich2/trunk/src/mpid/ch3/src/ch3u_comm_spawn_multiple.c
===================================================================
--- mpich2/trunk/src/mpid/ch3/src/ch3u_comm_spawn_multiple.c	2009-10-19 19:24:19 UTC (rev 5486)
+++ mpich2/trunk/src/mpid/ch3/src/ch3u_comm_spawn_multiple.c	2009-10-19 22:33:48 UTC (rev 5487)
@@ -297,7 +297,7 @@
         {
             int vallen = 0;
             MPIU_THREAD_CS_ENTER(PMI,);
-            mpi_errno = PMI_KVS_Get(kvsname, PARENT_PORT_KVSKEY, val, sizeof(val), &vallen);
+            mpi_errno = PMI2_KVS_Get(kvsname, PARENT_PORT_KVSKEY, val, sizeof(val), &vallen);
             MPIU_THREAD_CS_EXIT(PMI,);
             if (mpi_errno) MPIU_ERR_POP(mpi_errno);
         }

Modified: mpich2/trunk/src/mpid/ch3/src/mpid_abort.c
===================================================================
--- mpich2/trunk/src/mpid/ch3/src/mpid_abort.c	2009-10-19 19:24:19 UTC (rev 5486)
+++ mpich2/trunk/src/mpid/ch3/src/mpid_abort.c	2009-10-19 22:33:48 UTC (rev 5487)
@@ -130,8 +130,8 @@
        Should PMI_Abort have a parameter for which of these two cases to
        perform? */
 #ifdef USE_PMI2_API
-    PMI_Abort(TRUE, error_msg);
-#else    
+    PMI2_Abort(TRUE, error_msg);
+#else
     PMI_Abort(exit_code, error_msg);
 #endif
 

Modified: mpich2/trunk/src/mpid/ch3/src/mpid_get_universe_size.c
===================================================================
--- mpich2/trunk/src/mpid/ch3/src/mpid_get_universe_size.c	2009-10-19 19:24:19 UTC (rev 5486)
+++ mpich2/trunk/src/mpid/ch3/src/mpid_get_universe_size.c	2009-10-19 22:33:48 UTC (rev 5487)
@@ -27,11 +27,11 @@
 {
     int mpi_errno = MPI_SUCCESS;
 #ifdef USE_PMI2_API
-    char val[PMI_MAX_VALLEN];
+    char val[PMI2_MAX_VALLEN];
     int found = 0;
     char *endptr;
     
-    mpi_errno = PMI_Info_GetJobAttr("universeSize", val, sizeof(val), &found);
+    mpi_errno = PMI2_Info_GetJobAttr("universeSize", val, sizeof(val), &found);
     if (mpi_errno) MPIU_ERR_POP(mpi_errno);
 
     if (!found)

Modified: mpich2/trunk/src/mpid/ch3/src/mpid_init.c
===================================================================
--- mpich2/trunk/src/mpid/ch3/src/mpid_init.c	2009-10-19 19:24:19 UTC (rev 5486)
+++ mpich2/trunk/src/mpid/ch3/src/mpid_init.c	2009-10-19 22:33:48 UTC (rev 5487)
@@ -28,6 +28,8 @@
 #include "pmi.h"
 #endif
 
+int MPIDI_Use_pmi2_api = 0;
+
 static int InitPG( int *argc_p, char ***argv_p,
 		   int *has_args, int *has_env, int *has_parent, 
 		   int *pg_rank_p, MPIDI_PG_t **pg_p );
@@ -57,7 +59,18 @@
 
     /* FIXME: This is a good place to check for environment variables
        and command line options that may control the device */
-
+    MPIDI_Use_pmi2_api = FALSE;
+#ifdef USE_PMI2_API
+    MPIDI_Use_pmi2_api = TRUE;
+#else
+    {
+        int ret, val;
+        ret = MPIU_GetEnvBool("MPICH_USE_PMI2_API", &val);
+        if (ret == 1 && val)
+            MPIDI_Use_pmi2_api = TRUE;
+    }
+#endif
+    
 #if 1
     /* This is a sanity check because we define a generic packet size
      */
@@ -348,9 +361,9 @@
 	 */
 
 #ifdef USE_PMI2_API
-        mpi_errno = PMI_Init(has_parent, &pg_size, &pg_rank, &appnum);
+        mpi_errno = PMI2_Init(has_parent, &pg_size, &pg_rank, &appnum);
         if (mpi_errno) MPIU_ERR_POP(mpi_errno);
-#else        
+#else
 	pmi_errno = PMI_Init(has_parent);
 	if (pmi_errno != PMI_SUCCESS) {
 	    MPIU_ERR_SETANDJUMP1(mpi_errno,MPI_ERR_OTHER, "**pmi_init",
@@ -389,7 +402,7 @@
 	    MPIU_ERR_SETANDJUMP(mpi_errno,MPI_ERR_OTHER, "**nomem");
 	}
 
-        mpi_errno = PMI_Job_GetId(pg_id, MAX_JOBID_LEN);
+        mpi_errno = PMI2_Job_GetId(pg_id, MAX_JOBID_LEN);
         if (mpi_errno) MPIU_ERR_POP(mpi_errno);
         
 
@@ -493,7 +506,7 @@
     int pmi_errno;
     int mpi_errno = MPI_SUCCESS;
 #ifdef USE_PMI2_API
-    *val_max_sz_p = PMI_MAX_VALLEN;
+    *val_max_sz_p = PMI2_MAX_VALLEN;
 #else
     pmi_errno = PMI_KVS_Get_value_length_max(val_max_sz_p);
     if (pmi_errno != PMI_SUCCESS)

Modified: mpich2/trunk/src/mpid/ch3/src/mpid_vc.c
===================================================================
--- mpich2/trunk/src/mpid/ch3/src/mpid_vc.c	2009-10-19 19:24:19 UTC (rev 5486)
+++ mpich2/trunk/src/mpid/ch3/src/mpid_vc.c	2009-10-19 22:33:48 UTC (rev 5487)
@@ -1116,7 +1116,7 @@
         int found = FALSE;
         MPIU_CHKLMEM_MALLOC(node_ids, int *, pg->size * sizeof(int), mpi_errno, "node_ids");
 
-        mpi_errno = PMI_Info_GetJobAttrIntArray("nodeIDs", node_ids, pg->size, &outlen, &found);
+        mpi_errno = PMI2_Info_GetJobAttrIntArray("nodeIDs", node_ids, pg->size, &outlen, &found);
         if (mpi_errno) MPIU_ERR_POP(mpi_errno);
         MPIU_ERR_CHKANDJUMP1(!found, mpi_errno, MPI_ERR_OTHER, "**intern", "**intern %s", "nodeIDs attribute not found");
         MPIU_ERR_CHKANDJUMP1(outlen != pg->size, mpi_errno, MPI_ERR_OTHER, "**intern", "**intern %s", "did not receive enough nodeids");
@@ -1133,7 +1133,7 @@
     }
 #else
     {
-        char process_mapping[PMI_MAX_VALLEN];
+        char process_mapping[PMI2_MAX_VALLEN];
         int outlen;
         int found = FALSE;
         int i;
@@ -1144,7 +1144,7 @@
         int did_map = 0;
         int num_nodes = 0;
 
-        mpi_errno = PMI_Info_GetJobAttr("process-mapping", process_mapping, sizeof(process_mapping), &found);
+        mpi_errno = PMI2_Info_GetJobAttr("process-mapping", process_mapping, sizeof(process_mapping), &found);
         if (mpi_errno) MPIU_ERR_POP(mpi_errno);
         MPIU_ERR_CHKANDJUMP1(!found, mpi_errno, MPI_ERR_OTHER, "**intern", "**intern %s", "process-mapping attribute not found");
         /* this code currently assumes pg is comm_world */

Modified: mpich2/trunk/src/mpid/ch3/src/mpidi_pg.c
===================================================================
--- mpich2/trunk/src/mpid/ch3/src/mpidi_pg.c	2009-10-19 19:24:19 UTC (rev 5486)
+++ mpich2/trunk/src/mpid/ch3/src/mpidi_pg.c	2009-10-19 22:33:48 UTC (rev 5487)
@@ -95,7 +95,7 @@
        PG_Finalize */
     if (pg_world->connData) {
 #ifdef USE_PMI2_API
-        mpi_errno = PMI_Finalize();
+        mpi_errno = PMI2_Finalize();
         if (mpi_errno) MPIU_ERR_SET(mpi_errno, MPI_ERR_OTHER, "**ch3|pmi_finalize");
 #else
 	int rc;
@@ -590,7 +590,7 @@
 #ifdef USE_PMI2_API
     int mpi_errno = MPI_SUCCESS;
     int len;
-    char key[PMI_MAX_KEYLEN];
+    char key[PMI2_MAX_KEYLEN];
     MPIDI_STATE_DECL(MPID_STATE_MPIDI_PG_SetConnInfo);
 
     MPIDI_FUNC_ENTER(MPID_STATE_MPIDI_PG_SetConnInfo);
@@ -598,10 +598,10 @@
     len = MPIU_Snprintf(key, sizeof(key), "P%d-businesscard", rank);
     MPIU_ERR_CHKANDJUMP1(len < 0 || len > sizeof(key), mpi_errno, MPI_ERR_OTHER, "**snprintf", "**snprintf %d", len);
 
-    mpi_errno = PMI_KVS_Put(key, connString);
+    mpi_errno = PMI2_KVS_Put(key, connString);
     if (mpi_errno) MPIU_ERR_POP(mpi_errno);
 
-    mpi_errno = PMI_KVS_Fence();
+    mpi_errno = PMI2_KVS_Fence();
     if (mpi_errno) MPIU_ERR_POP(mpi_errno);
     
  fn_exit:
@@ -687,10 +687,10 @@
 	MPIU_ERR_SETANDJUMP(mpi_errno,MPI_ERR_OTHER,"**nomem");
     }
 
-    mpi_errno = PMI_KVS_Get(pg->connData, key, buf, bufsize, &vallen);
+    mpi_errno = PMI2_KVS_Get(pg->connData, key, buf, bufsize, &vallen);
     if (mpi_errno) {
 	MPIDI_PG_CheckForSingleton();
-	mpi_errno = PMI_KVS_Get(pg->connData, key, buf, bufsize, &vallen);
+	mpi_errno = PMI2_KVS_Get(pg->connData, key, buf, bufsize, &vallen);
         if (mpi_errno) MPIU_ERR_POP(mpi_errno);
     }
  fn_exit:
@@ -831,7 +831,7 @@
 	MPIU_ERR_SETANDJUMP(mpi_errno,MPI_ERR_OTHER, "**nomem");
     }
     
-    mpi_errno = PMI_Job_GetId(pg->connData, MAX_JOBID_LEN);
+    mpi_errno = PMI2_Job_GetId(pg->connData, MAX_JOBID_LEN);
     if (mpi_errno) MPIU_ERR_POP(mpi_errno);
 #else
     int pmi_errno, kvs_name_sz;

Modified: mpich2/trunk/src/pmi/pmi2/configure.in
===================================================================
--- mpich2/trunk/src/pmi/pmi2/configure.in	2009-10-19 19:24:19 UTC (rev 5486)
+++ mpich2/trunk/src/pmi/pmi2/configure.in	2009-10-19 22:33:48 UTC (rev 5487)
@@ -52,6 +52,15 @@
 
 PAC_PROG_MAKE
 
+# Check for alloca function.  May set HAVE_ALLOCA_H and HAVE_ALLOCA
+AC_FUNC_ALLOCA
+# We don't use alloca unless USE_ALLOCA is also set.
+AC_ARG_ENABLE(alloca,
+[--enable-alloca - Use alloca to allocate temporary memory if available],,enable_alloca=no)
+if test "$enable_alloca" = yes ; then
+    AC_DEFINE(USE_ALLOCA,1,[Define if alloca should be used if available])
+fi
+
 AC_CHECK_HEADERS(unistd.h string.h stdlib.h sys/socket.h strings.h)
 dnl Use snprintf if possible when creating messages
 AC_CHECK_FUNCS(snprintf)

Added: mpich2/trunk/src/pmi/pmi2/pmi2compat.h
===================================================================
--- mpich2/trunk/src/pmi/pmi2/pmi2compat.h	                        (rev 0)
+++ mpich2/trunk/src/pmi/pmi2/pmi2compat.h	2009-10-19 22:33:48 UTC (rev 5487)
@@ -0,0 +1,17 @@
+/* -*- Mode: C; c-basic-offset:4 ; -*- */
+/*
+ *  (C) 2007 by Argonne National Laboratory.
+ *      See COPYRIGHT in top-level directory.
+ */
+
+#include "mpiimpl.h"
+
+#define PMI2U_Malloc MPIU_Malloc
+#define PMI2U_Free MPIU_Free
+#define PMI2U_Snprintf MPIU_Snprintf
+#define PMI2U_Strncpy MPIU_Strncpy
+#define PMI2U_Assert MPIU_Assert
+#define PMI2U_Exit MPIU_Exit
+#define PMI2U_Info MPID_Info
+#define PMI2U_Memcpy MPIU_Memcpy
+

Modified: mpich2/trunk/src/pmi/pmi2/simple2pmi.c
===================================================================
--- mpich2/trunk/src/pmi/pmi2/simple2pmi.c	2009-10-19 19:24:19 UTC (rev 5486)
+++ mpich2/trunk/src/pmi/pmi2/simple2pmi.c	2009-10-19 22:33:48 UTC (rev 5487)
@@ -4,7 +4,7 @@
  *      See COPYRIGHT in top-level directory.
  */
 
-#include "mpiimpl.h"
+#include "pmi2compat.h"
 #include "simple2pmi.h"
 #include "simple_pmiutil.h"
 #include "pmi2.h"
@@ -42,18 +42,18 @@
 
 #define MAX_INT_STR_LEN 11 /* number of digits in MAX_UINT + 1 */
 
-typedef enum { PMI_UNINITIALIZED = 0, 
+typedef enum { PMI2_UNINITIALIZED = 0,
                SINGLETON_INIT_BUT_NO_PM = 1,
 	       NORMAL_INIT_WITH_PM,
-	       SINGLETON_INIT_WITH_PM } PMIState;
-static PMIState PMI_initialized = PMI_UNINITIALIZED;
+	       SINGLETON_INIT_WITH_PM } PMI2State;
+static PMI2State PMI2_initialized = PMI2_UNINITIALIZED;
 
-static int PMI_debug = 0;
-static int PMI_fd = -1;
-static int PMI_size = 1;
-static int PMI_rank = 0;
+static int PMI2_debug = 0;
+static int PMI2_fd = -1;
+static int PMI2_size = 1;
+static int PMI2_rank = 0;
 
-static int PMI_debug_init = 0;    /* Set this to true to debug the init */
+static int PMI2_debug_init = 0;    /* Set this to true to debug the init */
 
 #ifdef MPICH_IS_THREADED
 static MPID_Thread_mutex_t mutex;
@@ -65,7 +65,7 @@
    null-terminated string.  isCopy is set to FALSE, so caller must
    free key and val memory, if necessary.
 */
-static void init_kv_str(PMI_Keyvalpair *kv, const char key[], const char val[])
+static void init_kv_str(PMI2_Keyvalpair *kv, const char key[], const char val[])
 {
     kv->key = key;
     kv->value = val;
@@ -75,52 +75,39 @@
 
 
 static int getPMIFD(void);
-static int PMIi_ReadCommandExp( int fd, PMI_Command *cmd, const char *exp, int* rc, const char **errmsg );
-static int PMIi_ReadCommand( int fd, PMI_Command *cmd );
+static int PMIi_ReadCommandExp( int fd, PMI2_Command *cmd, const char *exp, int* rc, const char **errmsg );
+static int PMIi_ReadCommand( int fd, PMI2_Command *cmd );
 
-static int PMIi_WriteSimpleCommand( int fd, PMI_Command *resp, const char cmd[], PMI_Keyvalpair *pairs[], int npairs);
-static int PMIi_WriteSimpleCommandStr( int fd, PMI_Command *resp, const char cmd[], ...);
+static int PMIi_WriteSimpleCommand( int fd, PMI2_Command *resp, const char cmd[], PMI2_Keyvalpair *pairs[], int npairs);
+static int PMIi_WriteSimpleCommandStr( int fd, PMI2_Command *resp, const char cmd[], ...);
 static int PMIi_InitIfSingleton(void);
 
-static void freepairs(PMI_Keyvalpair** pairs, int npairs);
-static int getval(PMI_Keyvalpair *const pairs[], int npairs, const char *key,  const char **value, int *vallen);
-static int getvalint(PMI_Keyvalpair *const pairs[], int npairs, const char *key, int *val);
-static int getvalptr(PMI_Keyvalpair *const pairs[], int npairs, const char *key, void *val);
-static int getvalbool(PMI_Keyvalpair *const pairs[], int npairs, const char *key, int *val);
+static void freepairs(PMI2_Keyvalpair** pairs, int npairs);
+static int getval(PMI2_Keyvalpair *const pairs[], int npairs, const char *key,  const char **value, int *vallen);
+static int getvalint(PMI2_Keyvalpair *const pairs[], int npairs, const char *key, int *val);
+static int getvalptr(PMI2_Keyvalpair *const pairs[], int npairs, const char *key, void *val);
+static int getvalbool(PMI2_Keyvalpair *const pairs[], int npairs, const char *key, int *val);
 
 static int accept_one_connection(int list_sock);
 static int GetResponse(const char request[], const char expectedCmd[], int checkRc);
 
-static void dump_PMI_Command(FILE *file, PMI_Command *cmd);
-static void dump_PMI_Keyvalpair(FILE *file, PMI_Keyvalpair *kv);
+static void dump_PMI2_Command(FILE *file, PMI2_Command *cmd);
+static void dump_PMI2_Keyvalpair(FILE *file, PMI2_Keyvalpair *kv);
 
 
-typedef struct MPIDI_Process
+typedef struct pending_item
 {
-    void * my_pg;
-    int my_pg_rank;
-}
-MPIDI_Process_t;
-extern MPIDI_Process_t MPIDI_Process;
-
-int PRINT = 0;
-
-typedef struct pending_item 
-{
     struct pending_item *next;
-    PMI_Command *cmd;
+    PMI2_Command *cmd;
 } pending_item_t;
 
 pending_item_t *pendingq_head = NULL;
 pending_item_t *pendingq_tail = NULL;
 
-static inline void ENQUEUE(PMI_Command *cmd)
+static inline void ENQUEUE(PMI2_Command *cmd)
 {
-    pending_item_t *pi = MPIU_Malloc(sizeof(pending_item_t));
+    pending_item_t *pi = PMI2U_Malloc(sizeof(pending_item_t));
 
-    if (PRINT)
-        printf("%d ENQUEUE(%p)\n", MPIDI_Process.my_pg_rank, cmd);
-
     pi->next = NULL;
     pi->cmd = cmd;
 
@@ -132,19 +119,16 @@
     }
 }
         
-static inline int SEARCH_REMOVE(PMI_Command *cmd)
+static inline int SEARCH_REMOVE(PMI2_Command *cmd)
 {
     pending_item_t *pi, *prev;
 
-    if (PRINT)
-        printf("%d SEARCH_REMOVE(%p)\n", MPIDI_Process.my_pg_rank, cmd);
-
     pi = pendingq_head;
     if (pi->cmd == cmd) {
         pendingq_head = pi->next;
         if (pendingq_head == NULL)
             pendingq_tail = NULL;
-        MPIU_Free(pi);
+        PMI2U_Free(pi);
         return 1;
     }
     prev = pi;
@@ -155,13 +139,11 @@
             prev->next = pi->next;
             if (prev->next == NULL)
                 pendingq_tail = prev;
-            MPIU_Free(pi);
+            PMI2U_Free(pi);
             return 1;
         }
     }
     
-    printf("%d cmd %p not found in queue\n", MPIDI_Process.my_pg_rank, cmd);
-
     return 0;
 }
 
@@ -170,15 +152,11 @@
 /* ------------------------------------------------------------------------- */
 /* PMI API Routines */
 /* ------------------------------------------------------------------------- */
-#undef FUNCNAME
-#define FUNCNAME PMI_Init
-#undef FCNAME
-#define FCNAME MPIDI_QUOTE(FUNCNAME)
-int PMI_Init(int *spawned, int *size, int *rank, int *appnum)
+int PMI2_Init(int *spawned, int *size, int *rank, int *appnum)
 {
-    int mpi_errno = MPI_SUCCESS;
+    int pmi2_errno = PMI2_SUCCESS;
     char *p;
-    char buf[PMIU_MAXLINE], cmdline[PMIU_MAXLINE];
+    char buf[PMI2U_MAXLINE], cmdline[PMI2U_MAXLINE];
     char *jobid;
     char *pmiid;
     int ret;
@@ -188,57 +166,57 @@
        unbuffered (user explicitly set?) */
     /* setvbuf(stdout,0,_IONBF,0); */
     setbuf(stdout, NULL);
-    /* PMIU_printf( 1, "PMI_INIT\n" ); */
+    /* PMI2U_printf( 1, "PMI2_INIT\n" ); */
 
-    /* Get the value of PMI_DEBUG from the environment if possible, since
+    /* Get the value of PMI2_DEBUG from the environment if possible, since
        we may have set it to help debug the setup process */
-    p = getenv( "PMI_DEBUG" );
+    p = getenv( "PMI2_DEBUG" );
     if (p)
-        PMI_debug = atoi( p );
+        PMI2_debug = atoi( p );
 
     /* Get the fd for PMI commands; if none, we're a singleton */
-    mpi_errno = getPMIFD();
-    if (mpi_errno) MPIU_ERR_POP(mpi_errno);
+    pmi2_errno = getPMIFD();
+    if (pmi2_errno) PMI2U_ERR_POP(pmi2_errno);
 
-    if ( PMI_fd == -1 ) {
-	/* Singleton init: Process not started with mpiexec, 
+    if ( PMI2_fd == -1 ) {
+	/* Singleton init: Process not started with mpiexec,
 	   so set size to 1, rank to 0 */
-	PMI_size = 1;
-	PMI_rank = 0;
+	PMI2_size = 1;
+	PMI2_rank = 0;
 	*spawned = 0;
 	
-	PMI_initialized = SINGLETON_INIT_BUT_NO_PM;
+	PMI2_initialized = SINGLETON_INIT_BUT_NO_PM;
 	
         goto fn_exit;
     }
 
     /* do initial PMI1 init */
-    ret = MPIU_Snprintf( buf, PMIU_MAXLINE, "cmd=init pmi_version=%d pmi_subversion=%d\n", PMI_VERSION, PMI_SUBVERSION );
-    MPIU_ERR_CHKANDJUMP1(ret < 0, mpi_errno, MPI_ERR_OTHER, "**intern", "**intern %s", "failed to generate init line");
+    ret = PMI2U_Snprintf( buf, PMI2U_MAXLINE, "cmd=init pmi_version=%d pmi_subversion=%d\n", PMI_VERSION, PMI_SUBVERSION );
+    PMI2U_ERR_CHKANDJUMP1(ret < 0, pmi2_errno, PMI2_ERR_OTHER, "**intern", "**intern %s", "failed to generate init line");
 
-    ret = PMIU_writeline(PMI_fd, buf);
-    MPIU_ERR_CHKANDJUMP(ret < 0, mpi_errno, MPI_ERR_OTHER, "**pmi_init_send");
+    ret = PMI2U_writeline(PMI2_fd, buf);
+    PMI2U_ERR_CHKANDJUMP(ret < 0, pmi2_errno, PMI2_ERR_OTHER, "**pmi2_init_send");
 
-    ret = PMIU_readline(PMI_fd, buf, PMIU_MAXLINE);
-    MPIU_ERR_CHKANDJUMP1(ret < 0, mpi_errno, MPI_ERR_OTHER, "**pmi_initack", "**pmi_initack %s", strerror(errno));
+    ret = PMI2U_readline(PMI2_fd, buf, PMI2U_MAXLINE);
+    PMI2U_ERR_CHKANDJUMP1(ret < 0, pmi2_errno, PMI2_ERR_OTHER, "**pmi2_initack", "**pmi2_initack %s", strerror(errno));
 
-    PMIU_parse_keyvals( buf );
+    PMI2U_parse_keyvals( buf );
     cmdline[0] = 0;
-    PMIU_getval( "cmd", cmdline, PMIU_MAXLINE );
-    MPIU_ERR_CHKANDJUMP(strncmp( cmdline, "response_to_init", PMIU_MAXLINE ) != 0,  mpi_errno, MPI_ERR_OTHER, "**bad_cmd");
+    PMI2U_getval( "cmd", cmdline, PMI2U_MAXLINE );
+    PMI2U_ERR_CHKANDJUMP(strncmp( cmdline, "response_to_init", PMI2U_MAXLINE ) != 0,  pmi2_errno, PMI2_ERR_OTHER, "**bad_cmd");
 
-    PMIU_getval( "rc", buf, PMIU_MAXLINE );
-    if ( strncmp( buf, "0", PMIU_MAXLINE ) != 0 ) {
-	char buf1[PMIU_MAXLINE];
-        PMIU_getval( "pmi_version", buf, PMIU_MAXLINE );
-        PMIU_getval( "pmi_subversion", buf1, PMIU_MAXLINE );
-        MPIU_ERR_SETANDJUMP4(mpi_errno, MPI_ERR_OTHER, "**pmi_version", "**pmi_version %s %s %s %s", buf, buf1, PMI_VERSION, PMI_SUBVERSION);
+    PMI2U_getval( "rc", buf, PMI2U_MAXLINE );
+    if ( strncmp( buf, "0", PMI2U_MAXLINE ) != 0 ) {
+	char buf1[PMI2U_MAXLINE];
+        PMI2U_getval( "pmi_version", buf, PMI2U_MAXLINE );
+        PMI2U_getval( "pmi_subversion", buf1, PMI2U_MAXLINE );
+        PMI2U_ERR_SETANDJUMP4(pmi2_errno, PMI2_ERR_OTHER, "**pmi2_version", "**pmi2_version %s %s %d %d", buf, buf1, PMI_VERSION, PMI_SUBVERSION);
     }
 
     /* do full PMI2 init */
     {
-        PMI_Keyvalpair pairs[3];
-        PMI_Keyvalpair *pairs_p[] = { pairs, pairs+1, pairs+2 };
+        PMI2_Keyvalpair pairs[3];
+        PMI2_Keyvalpair *pairs_p[] = { pairs, pairs+1, pairs+2 };
         int npairs = 0;
         int isThreaded = 0;
         const char *errmsg;
@@ -246,7 +224,7 @@
         int found;
         int version, subver;
         int spawner_jobid;
-        PMI_Command cmd = {0};
+        PMI2_Command cmd = {0};
         int debugged, pmiverbose;
         
 
@@ -273,34 +251,34 @@
         ++npairs;
         
  
-        mpi_errno = PMIi_WriteSimpleCommand(PMI_fd, 0, FULLINIT_CMD, pairs_p, npairs); /* don't pass in thread id for init */
-        if (mpi_errno) MPIU_ERR_POP(mpi_errno);
+        pmi2_errno = PMIi_WriteSimpleCommand(PMI2_fd, 0, FULLINIT_CMD, pairs_p, npairs); /* don't pass in thread id for init */
+        if (pmi2_errno) PMI2U_ERR_POP(pmi2_errno);
 
         /* Read auth-response */
         /* Send auth-response-complete */
     
         /* Read fullinit-response */
-        mpi_errno = PMIi_ReadCommandExp(PMI_fd, &cmd, FULLINITRESP_CMD, &rc, &errmsg);
-        if (mpi_errno) MPIU_ERR_POP(mpi_errno);
-        MPIU_ERR_CHKANDJUMP1(rc, mpi_errno, MPI_ERR_OTHER, "**pmi_fullinit", "**pmi_fullinit %s", errmsg ? errmsg : "unknown");
+        pmi2_errno = PMIi_ReadCommandExp(PMI2_fd, &cmd, FULLINITRESP_CMD, &rc, &errmsg);
+        if (pmi2_errno) PMI2U_ERR_POP(pmi2_errno);
+        PMI2U_ERR_CHKANDJUMP1(rc, pmi2_errno, PMI2_ERR_OTHER, "**pmi2_fullinit", "**pmi2_fullinit %s", errmsg ? errmsg : "unknown");
 
         found = getvalint(cmd.pairs, cmd.nPairs, PMIVERSION_KEY, &version);
-        MPIU_ERR_CHKANDJUMP(found != 1, mpi_errno, MPI_ERR_OTHER, "**intern");
+        PMI2U_ERR_CHKANDJUMP(found != 1, pmi2_errno, PMI2_ERR_OTHER, "**intern");
 
         found = getvalint(cmd.pairs, cmd.nPairs, PMISUBVER_KEY, &subver);
-        MPIU_ERR_CHKANDJUMP(found != 1, mpi_errno, MPI_ERR_OTHER, "**intern");
+        PMI2U_ERR_CHKANDJUMP(found != 1, pmi2_errno, PMI2_ERR_OTHER, "**intern");
 
         found = getvalint(cmd.pairs, cmd.nPairs, RANK_KEY, rank);
-        MPIU_ERR_CHKANDJUMP(found != 1, mpi_errno, MPI_ERR_OTHER, "**intern");
+        PMI2U_ERR_CHKANDJUMP(found != 1, pmi2_errno, PMI2_ERR_OTHER, "**intern");
 
         found = getvalint(cmd.pairs, cmd.nPairs, SIZE_KEY, size);
-        MPIU_ERR_CHKANDJUMP(found != 1, mpi_errno, MPI_ERR_OTHER, "**intern");
+        PMI2U_ERR_CHKANDJUMP(found != 1, pmi2_errno, PMI2_ERR_OTHER, "**intern");
 
         found = getvalint(cmd.pairs, cmd.nPairs, APPNUM_KEY, appnum);
-        MPIU_ERR_CHKANDJUMP(found != 1, mpi_errno, MPI_ERR_OTHER, "**intern");
+        PMI2U_ERR_CHKANDJUMP(found != 1, pmi2_errno, PMI2_ERR_OTHER, "**intern");
 
         found = getvalint(cmd.pairs, cmd.nPairs, SPAWNERJOBID_KEY, &spawner_jobid);
-        MPIU_ERR_CHKANDJUMP(found == -1, mpi_errno, MPI_ERR_OTHER, "**intern");
+        PMI2U_ERR_CHKANDJUMP(found == -1, pmi2_errno, PMI2_ERR_OTHER, "**intern");
         if (found)
             *spawned = TRUE;
         else
@@ -308,88 +286,84 @@
 
         debugged = 0;
         found = getvalbool(cmd.pairs, cmd.nPairs, DEBUGGED_KEY, &debugged);
-        MPIU_ERR_CHKANDJUMP(found == -1, mpi_errno, MPI_ERR_OTHER, "**intern");
-        PMI_debug |= debugged;
+        PMI2U_ERR_CHKANDJUMP(found == -1, pmi2_errno, PMI2_ERR_OTHER, "**intern");
+        PMI2_debug |= debugged;
         
         pmiverbose = 0;
         found = getvalint(cmd.pairs, cmd.nPairs, PMIVERBOSE_KEY, &pmiverbose);
-        MPIU_ERR_CHKANDJUMP(found == -1, mpi_errno, MPI_ERR_OTHER, "**intern");
+        PMI2U_ERR_CHKANDJUMP(found == -1, pmi2_errno, PMI2_ERR_OTHER, "**intern");
         
         freepairs(cmd.pairs, cmd.nPairs);
     }
     
-    if ( ! PMI_initialized )
-	PMI_initialized = NORMAL_INIT_WITH_PM;    
+    if ( ! PMI2_initialized )
+	PMI2_initialized = NORMAL_INIT_WITH_PM;
         
 fn_exit:
-    return mpi_errno;
+    return pmi2_errno;
 fn_fail:
 
     goto fn_exit;
 }
 
-#undef FUNCNAME
-#define FUNCNAME PMI_Finalize
-#undef FCNAME
-#define FCNAME MPIDI_QUOTE(FUNCNAME)
-int PMI_Finalize(void)
+int PMI2_Finalize(void)
 {
-    int mpi_errno = MPI_SUCCESS;
+    int pmi2_errno = PMI2_SUCCESS;
     int rc;
     const char *errmsg;
-    PMI_Command cmd = {0};
+    PMI2_Command cmd = {0};
    
-    if ( PMI_initialized > SINGLETON_INIT_BUT_NO_PM) {
-        mpi_errno = PMIi_WriteSimpleCommandStr(PMI_fd, &cmd, FINALIZE_CMD, NULL);
-        if (mpi_errno) MPIU_ERR_POP(mpi_errno);
-        mpi_errno = PMIi_ReadCommandExp(PMI_fd, &cmd, FINALIZERESP_CMD, &rc, &errmsg);
-        if (mpi_errno) MPIU_ERR_POP(mpi_errno);
-        MPIU_ERR_CHKANDJUMP1(rc, mpi_errno, MPI_ERR_OTHER, "**pmi_finalize", "**pmi_finalize %s", errmsg ? errmsg : "unknown");
+    if ( PMI2_initialized > SINGLETON_INIT_BUT_NO_PM) {
+        pmi2_errno = PMIi_WriteSimpleCommandStr(PMI2_fd, &cmd, FINALIZE_CMD, NULL);
+        if (pmi2_errno) PMI2U_ERR_POP(pmi2_errno);
+        pmi2_errno = PMIi_ReadCommandExp(PMI2_fd, &cmd, FINALIZERESP_CMD, &rc, &errmsg);
+        if (pmi2_errno) PMI2U_ERR_POP(pmi2_errno);
+        PMI2U_ERR_CHKANDJUMP1(rc, pmi2_errno, PMI2_ERR_OTHER, "**pmi2_finalize", "**pmi2_finalize %s", errmsg ? errmsg : "unknown");
         freepairs(cmd.pairs, cmd.nPairs);
         
-	shutdown( PMI_fd, SHUT_RDWR );
-	close( PMI_fd );
+	shutdown( PMI2_fd, SHUT_RDWR );
+	close( PMI2_fd );
     }
 
 fn_exit:
-    return mpi_errno;
+    return pmi2_errno;
 fn_fail:
 
     goto fn_exit;
 }
 
-int PMI_Initialized(void)
+int PMI2_Initialized(void)
 {
     /* Turn this into a logical value (1 or 0) .  This allows us
-       to use PMI_initialized to distinguish between initialized with
-       an PMI service (e.g., via mpiexec) and the singleton init, 
+       to use PMI2_initialized to distinguish between initialized with
+       an PMI service (e.g., via mpiexec) and the singleton init,
        which has no PMI service */
-    return PMI_initialized != 0;
+    return PMI2_initialized != 0;
 }
 
-int PMI_Abort( int flag, const char msg[] )
+int PMI2_Abort( int flag, const char msg[] )
 {
-    PMIU_printf(1, "aborting job:\n%s\n", msg);
+    PMI2U_printf(1, "aborting job:\n%s\n", msg);
 
     /* ignoring return code, because we're exiting anyway */
-    PMIi_WriteSimpleCommandStr(PMI_fd, NULL, ABORT_CMD, ISWORLD_KEY, flag ? TRUE_VAL : FALSE_VAL, MSG_KEY, msg, NULL);
+    PMIi_WriteSimpleCommandStr(PMI2_fd, NULL, ABORT_CMD, ISWORLD_KEY, flag ? TRUE_VAL : FALSE_VAL, MSG_KEY, msg, NULL);
     
-    MPIU_Exit(PMII_EXIT_CODE);
-    return MPI_SUCCESS;
+    PMI2U_Exit(PMII_EXIT_CODE);
+    return PMI2_SUCCESS;
 }
 
-int PMI_Job_Spawn( int count, const char * cmds[], const char ** argvs[],
-                   const int maxprocs[], 
+int PMI2_Job_Spawn( int count, const char * cmds[], const char ** argvs[],
+                   const int maxprocs[],
                    const int info_keyval_sizes[],
-                   const MPID_Info *info_keyval_vectors[],
+                   const PMI2U_Info *info_keyval_vectors[],
                    int preput_keyval_size,
-                   const MPID_Info *preput_keyval_vector[],
-                   char jobId[], int jobIdSize,      
+                   const PMI2U_Info *preput_keyval_vector[],
+                   char jobId[], int jobIdSize,
                    int errors[])
 {
 #if 0
     int  i,rc,argcnt,spawncnt,total_num_processes,num_errcodes_found;
-    char buf[PMIU_MAXLINE], tempbuf[PMIU_MAXLINE], cmd[PMIU_MAXLINE];
+    char buf[PMI2U_MAXLINE], tempbuf[PMI2U_MAXLINE], cmd[PMI2U_MAXLINE];
     char *lead, *lag;
 
     /* Connect to the PM if we haven't already */
@@ -401,21 +375,21 @@
     {
         total_num_processes += maxprocs[spawncnt];
 
-        rc = MPIU_Snprintf(buf, PMIU_MAXLINE, 
+        rc = PMI2U_Snprintf(buf, PMI2U_MAXLINE,
 			   "mcmd=spawn\nnprocs=%d\nexecname=%s\n",
 			   maxprocs[spawncnt], cmds[spawncnt] );
 	if (rc < 0) {
 	    return PMI_FAIL;
 	}
 
-	rc = MPIU_Snprintf(tempbuf, PMIU_MAXLINE,
+	rc = PMI2U_Snprintf(tempbuf, PMI2U_MAXLINE,
 			   "totspawns=%d\nspawnssofar=%d\n",
 			   count, spawncnt+1);
 
-	if (rc < 0) { 
+	if (rc < 0) {
 	    return PMI_FAIL;
 	}
-	rc = MPIU_Strnapp(buf,tempbuf,PMIU_MAXLINE);
+	rc = PMI2U_Strnapp(buf,tempbuf,PMI2U_MAXLINE);
 	if (rc != 0) {
 	    return PMI_FAIL;
 	}
@@ -429,124 +403,124 @@
 		*/
 		/* Note that part of this fixme was really a design error -
 		   because this uses the mcmd form, the data can be
-		   sent in multiple writelines.  This code now takes 
-		   advantage of that.  Note also that a correct parser 
-		   of the commands will permit any character other than a 
-		   new line in the argument, since the form is 
+		   sent in multiple writelines.  This code now takes
+		   advantage of that.  Note also that a correct parser
+		   of the commands will permit any character other than a
+		   new line in the argument, since the form is
 		   argn=<any nonnewline><newline> */
-                rc = MPIU_Snprintf(tempbuf,PMIU_MAXLINE,"arg%d=%s\n",
+                rc = PMI2U_Snprintf(tempbuf,PMI2U_MAXLINE,"arg%d=%s\n",
 				   i+1,argvs[spawncnt][i]);
 		if (rc < 0) {
 		    return PMI_FAIL;
 		}
-                rc = MPIU_Strnapp(buf,tempbuf,PMIU_MAXLINE);
+                rc = PMI2U_Strnapp(buf,tempbuf,PMI2U_MAXLINE);
 		if (rc != 0) {
 		    return PMI_FAIL;
 		}
                 argcnt++;
-		rc = PMIU_writeline( PMI_fd, buf );
+		rc = PMI2U_writeline( PMI_fd, buf );
 		buf[0] = 0;
 
             }
         }
-        rc = MPIU_Snprintf(tempbuf,PMIU_MAXLINE,"argcnt=%d\n",argcnt);
+        rc = PMI2U_Snprintf(tempbuf,PMI2U_MAXLINE,"argcnt=%d\n",argcnt);
 	if (rc < 0) {
 	    return PMI_FAIL;
 	}
-        rc = MPIU_Strnapp(buf,tempbuf,PMIU_MAXLINE);
+        rc = PMI2U_Strnapp(buf,tempbuf,PMI2U_MAXLINE);
 	if (rc != 0) {
 	    return PMI_FAIL;
 	}
     
-        rc = MPIU_Snprintf(tempbuf,PMIU_MAXLINE,"preput_num=%d\n", 
+        rc = PMI2U_Snprintf(tempbuf,PMI2U_MAXLINE,"preput_num=%d\n",
 			   preput_keyval_size);
 	if (rc < 0) {
 	    return PMI_FAIL;
 	}
 
-        rc = MPIU_Strnapp(buf,tempbuf,PMIU_MAXLINE);
+        rc = PMI2U_Strnapp(buf,tempbuf,PMI2U_MAXLINE);
 	if (rc != 0) {
 	    return PMI_FAIL;
 	}
         for (i=0; i < preput_keyval_size; i++) {
-	    rc = MPIU_Snprintf(tempbuf,PMIU_MAXLINE,"preput_key_%d=%s\n",
+	    rc = PMI2U_Snprintf(tempbuf,PMI2U_MAXLINE,"preput_key_%d=%s\n",
 			       i,preput_keyval_vector[i].key);
 	    if (rc < 0) {
 		return PMI_FAIL;
 	    }
-	    rc = MPIU_Strnapp(buf,tempbuf,PMIU_MAXLINE); 
+	    rc = PMI2U_Strnapp(buf,tempbuf,PMI2U_MAXLINE);
 	    if (rc != 0) {
 		return PMI_FAIL;
 	    }
-	    rc = MPIU_Snprintf(tempbuf,PMIU_MAXLINE,"preput_val_%d=%s\n",
+	    rc = PMI2U_Snprintf(tempbuf,PMI2U_MAXLINE,"preput_val_%d=%s\n",
 			       i,preput_keyval_vector[i].val);
 	    if (rc < 0) {
 		return PMI_FAIL;
 	    }
-	    rc = MPIU_Strnapp(buf,tempbuf,PMIU_MAXLINE); 
+	    rc = PMI2U_Strnapp(buf,tempbuf,PMI2U_MAXLINE);
 	    if (rc != 0) {
 		return PMI_FAIL;
 	    }
-        } 
-        rc = MPIU_Snprintf(tempbuf,PMIU_MAXLINE,"info_num=%d\n", 
+        }
+        rc = PMI2U_Snprintf(tempbuf,PMI2U_MAXLINE,"info_num=%d\n",
 			   info_keyval_sizes[spawncnt]);
 	if (rc < 0) {
 	    return PMI_FAIL;
 	}
-        rc = MPIU_Strnapp(buf,tempbuf,PMIU_MAXLINE);
+        rc = PMI2U_Strnapp(buf,tempbuf,PMI2U_MAXLINE);
 	if (rc != 0) {
 	    return PMI_FAIL;
 	}
 	for (i=0; i < info_keyval_sizes[spawncnt]; i++)
 	{
-	    rc = MPIU_Snprintf(tempbuf,PMIU_MAXLINE,"info_key_%d=%s\n",
+	    rc = PMI2U_Snprintf(tempbuf,PMI2U_MAXLINE,"info_key_%d=%s\n",
 			       i,info_keyval_vectors[spawncnt][i].key);
 	    if (rc < 0) {
 		return PMI_FAIL;
 	    }
-	    rc = MPIU_Strnapp(buf,tempbuf,PMIU_MAXLINE); 
+	    rc = PMI2U_Strnapp(buf,tempbuf,PMI2U_MAXLINE);
 	    if (rc != 0) {
 		return PMI_FAIL;
 	    }
-	    rc = MPIU_Snprintf(tempbuf,PMIU_MAXLINE,"info_val_%d=%s\n",
+	    rc = PMI2U_Snprintf(tempbuf,PMI2U_MAXLINE,"info_val_%d=%s\n",
 			       i,info_keyval_vectors[spawncnt][i].val);
 	    if (rc < 0) {
 		return PMI_FAIL;
 	    }
-	    rc = MPIU_Strnapp(buf,tempbuf,PMIU_MAXLINE); 
+	    rc = PMI2U_Strnapp(buf,tempbuf,PMI2U_MAXLINE);
 	    if (rc != 0) {
 		return PMI_FAIL;
 	    }
 	}
 
-        rc = MPIU_Strnapp(buf, "endcmd\n", PMIU_MAXLINE);
+        rc = PMI2U_Strnapp(buf, "endcmd\n", PMI2U_MAXLINE);
 	if (rc != 0) {
 	    return PMI_FAIL;
 	}
-        PMIU_writeline( PMI_fd, buf );
+        PMI2U_writeline( PMI_fd, buf );
     }
 
-    PMIU_readline( PMI_fd, buf, PMIU_MAXLINE );
-    PMIU_parse_keyvals( buf ); 
-    PMIU_getval( "cmd", cmd, PMIU_MAXLINE );
-    if ( strncmp( cmd, "spawn_result", PMIU_MAXLINE ) != 0 ) {
-	PMIU_printf( 1, "got unexpected response to spawn :%s:\n", buf );
+    PMI2U_readline( PMI2_fd, buf, PMI2U_MAXLINE );
+    PMI2U_parse_keyvals( buf );
+    PMI2U_getval( "cmd", cmd, PMI2U_MAXLINE );
+    if ( strncmp( cmd, "spawn_result", PMI2U_MAXLINE ) != 0 ) {
+	PMI2U_printf( 1, "got unexpected response to spawn :%s:\n", buf );
 	return( -1 );
     }
     else {
-	PMIU_getval( "rc", buf, PMIU_MAXLINE );
+	PMI2U_getval( "rc", buf, PMI2U_MAXLINE );
 	rc = atoi( buf );
 	if ( rc != 0 ) {
 	    /****
-	    PMIU_getval( "status", tempbuf, PMIU_MAXLINE );
-	    PMIU_printf( 1, "pmi_spawn_mult failed; status: %s\n",tempbuf);
+	    PMI2U_getval( "status", tempbuf, PMI2U_MAXLINE );
+	    PMI2U_printf( 1, "pmi2_spawn_mult failed; status: %s\n",tempbuf);
 	    ****/
 	    return( -1 );
 	}
     }
     
-    PMIU_Assert(errors != NULL);
-    if (PMIU_getval( "errcodes", tempbuf, PMIU_MAXLINE )) {
+    PMI2U_Assert(errors != NULL);
+    if (PMI2U_getval( "errcodes", tempbuf, PMI2U_MAXLINE )) {
         num_errcodes_found = 0;
         lag = &tempbuf[0];
         do {
@@ -554,9 +528,9 @@
             if (lead) *lead = '\0';
             errors[num_errcodes_found++] = atoi(lag);
             lag = lead + 1; /* move past the null char */
-            PMIU_Assert(num_errcodes_found <= total_num_processes);
+            PMI2U_Assert(num_errcodes_found <= total_num_processes);
         } while (lead != NULL);
-        PMIU_Assert(num_errcodes_found == total_num_processes);
+        PMI2U_Assert(num_errcodes_found == total_num_processes);
     }
     else {
         /* gforker doesn't return errcodes, so we'll just pretend that means
@@ -570,265 +544,237 @@
     return 0;
 }
 
-#undef FUNCNAME
-#define FUNCNAME PMI_Job_GetId
-#undef FCNAME
-#define FCNAME MPIDI_QUOTE(FUNCNAME)
-int PMI_Job_GetId(char jobid[], int jobid_size)
+int PMI2_Job_GetId(char jobid[], int jobid_size)
 {
-    int mpi_errno = MPI_SUCCESS;
+    int pmi2_errno = PMI2_SUCCESS;
     int found;
     const char *jid;
     int jidlen;
     int rc;
     const char *errmsg;
-    PMI_Command cmd = {0};
+    PMI2_Command cmd = {0};
     
-    mpi_errno = PMIi_WriteSimpleCommandStr(PMI_fd, &cmd, JOBGETID_CMD, NULL);
-    if (mpi_errno) MPIU_ERR_POP(mpi_errno);
-    mpi_errno = PMIi_ReadCommandExp(PMI_fd, &cmd, JOBGETIDRESP_CMD, &rc, &errmsg);
-    if (mpi_errno) MPIU_ERR_POP(mpi_errno);
-    MPIU_ERR_CHKANDJUMP1(rc, mpi_errno, MPI_ERR_OTHER, "**pmi_jobgetid", "**pmi_jobgetid %s", errmsg ? errmsg : "unknown");
+    pmi2_errno = PMIi_WriteSimpleCommandStr(PMI2_fd, &cmd, JOBGETID_CMD, NULL);
+    if (pmi2_errno) PMI2U_ERR_POP(pmi2_errno);
+    pmi2_errno = PMIi_ReadCommandExp(PMI2_fd, &cmd, JOBGETIDRESP_CMD, &rc, &errmsg);
+    if (pmi2_errno) PMI2U_ERR_POP(pmi2_errno);
+    PMI2U_ERR_CHKANDJUMP1(rc, pmi2_errno, PMI2_ERR_OTHER, "**pmi2_jobgetid", "**pmi2_jobgetid %s", errmsg ? errmsg : "unknown");
 
     found = getval(cmd.pairs, cmd.nPairs, JOBID_KEY, &jid, &jidlen);
-    MPIU_ERR_CHKANDJUMP(found != 1, mpi_errno, MPI_ERR_OTHER, "**intern");
+    PMI2U_ERR_CHKANDJUMP(found != 1, pmi2_errno, PMI2_ERR_OTHER, "**intern");
 
-    MPIU_Strncpy(jobid, jid, jobid_size);
+    PMI2U_Strncpy(jobid, jid, jobid_size);
 
 fn_exit:
     freepairs(cmd.pairs, cmd.nPairs);
-    return mpi_errno;
+    return pmi2_errno;
 fn_fail:
 
     goto fn_exit;
 }
 
 #undef FUNCNAME
-#define FUNCNAME PMI_Job_Connect
+#define FUNCNAME PMI2_Job_Connect
 #undef FCNAME
-#define FCNAME MPIDI_QUOTE(FUNCNAME)
-int PMI_Job_Connect(const char jobid[], PMI_Connect_comm_t *conn)
+#define FCNAME PMI2DI_QUOTE(FUNCNAME)
+int PMI2_Job_Connect(const char jobid[], PMI2_Connect_comm_t *conn)
 {
-    int mpi_errno = MPI_SUCCESS;
-    PMI_Command cmd = {0};
+    int pmi2_errno = PMI2_SUCCESS;
+    PMI2_Command cmd = {0};
     int found;
     int kvscopy;
     int rc;
     const char *errmsg;
 
-    mpi_errno = PMIi_WriteSimpleCommandStr(PMI_fd, &cmd, JOBCONNECT_CMD, JOBID_KEY, jobid, NULL);
-    if (mpi_errno) MPIU_ERR_POP(mpi_errno);
-    mpi_errno = PMIi_ReadCommandExp(PMI_fd, &cmd, JOBCONNECTRESP_CMD, &rc, &errmsg);
-    if (mpi_errno) MPIU_ERR_POP(mpi_errno);
-    MPIU_ERR_CHKANDJUMP1(rc, mpi_errno, MPI_ERR_OTHER, "**pmi_jobconnect", "**pmi_jobconnect %s", errmsg ? errmsg : "unknown");
+    pmi2_errno = PMIi_WriteSimpleCommandStr(PMI2_fd, &cmd, JOBCONNECT_CMD, JOBID_KEY, jobid, NULL);
+    if (pmi2_errno) PMI2U_ERR_POP(pmi2_errno);
+    pmi2_errno = PMIi_ReadCommandExp(PMI2_fd, &cmd, JOBCONNECTRESP_CMD, &rc, &errmsg);
+    if (pmi2_errno) PMI2U_ERR_POP(pmi2_errno);
+    PMI2U_ERR_CHKANDJUMP1(rc, pmi2_errno, PMI2_ERR_OTHER, "**pmi2_jobconnect", "**pmi2_jobconnect %s", errmsg ? errmsg : "unknown");
 
     found = getvalbool(cmd.pairs, cmd.nPairs, KVSCOPY_KEY, &kvscopy);
-    MPIU_ERR_CHKANDJUMP(found != 1, mpi_errno, MPI_ERR_OTHER, "**intern");
+    PMI2U_ERR_CHKANDJUMP(found != 1, pmi2_errno, PMI2_ERR_OTHER, "**intern");
 
-    MPIU_ERR_CHKANDJUMP(kvscopy, mpi_errno, MPI_ERR_OTHER, "**notimpl");
+    PMI2U_ERR_CHKANDJUMP(kvscopy, pmi2_errno, PMI2_ERR_OTHER, "**notimpl");
 
     
  fn_exit:
     freepairs(cmd.pairs, cmd.nPairs);
-    return mpi_errno;
+    return pmi2_errno;
  fn_fail:
 
     goto fn_exit;
 }
 
-#undef FUNCNAME
-#define FUNCNAME PMI_Job_Disconnect
-#undef FCNAME
-#define FCNAME MPIDI_QUOTE(FUNCNAME)
-int PMI_Job_Disconnect(const char jobid[])
+int PMI2_Job_Disconnect(const char jobid[])
 {
-    int mpi_errno = MPI_SUCCESS;
-    PMI_Command cmd = {0};
+    int pmi2_errno = PMI2_SUCCESS;
+    PMI2_Command cmd = {0};
     int rc;
     const char *errmsg;
 
-    mpi_errno = PMIi_WriteSimpleCommandStr(PMI_fd, &cmd, JOBDISCONNECT_CMD, JOBID_KEY, jobid, NULL);
-    if (mpi_errno) MPIU_ERR_POP(mpi_errno);
-    mpi_errno = PMIi_ReadCommandExp(PMI_fd, &cmd, JOBDISCONNECTRESP_CMD, &rc, &errmsg);
-    if (mpi_errno) MPIU_ERR_POP(mpi_errno);
-    MPIU_ERR_CHKANDJUMP1(rc, mpi_errno, MPI_ERR_OTHER, "**pmi_jobdisconnect", "**pmi_jobdisconnect %s", errmsg ? errmsg : "unknown");
+    pmi2_errno = PMIi_WriteSimpleCommandStr(PMI2_fd, &cmd, JOBDISCONNECT_CMD, JOBID_KEY, jobid, NULL);
+    if (pmi2_errno) PMI2U_ERR_POP(pmi2_errno);
+    pmi2_errno = PMIi_ReadCommandExp(PMI2_fd, &cmd, JOBDISCONNECTRESP_CMD, &rc, &errmsg);
+    if (pmi2_errno) PMI2U_ERR_POP(pmi2_errno);
+    PMI2U_ERR_CHKANDJUMP1(rc, pmi2_errno, PMI2_ERR_OTHER, "**pmi2_jobdisconnect", "**pmi2_jobdisconnect %s", errmsg ? errmsg : "unknown");
         
 fn_exit:
     freepairs(cmd.pairs, cmd.nPairs);
-    return mpi_errno;
+    return pmi2_errno;
 fn_fail:
     goto fn_exit;
 }
 
-#undef FUNCNAME
-#define FUNCNAME PMI_KVS_Put
-#undef FCNAME
-#define FCNAME MPIDI_QUOTE(FUNCNAME)
-int PMI_KVS_Put(const char key[], const char value[])
+int PMI2_KVS_Put(const char key[], const char value[])
 {
-    int mpi_errno = MPI_SUCCESS;
-    PMI_Command cmd = {0};
+    int pmi2_errno = PMI2_SUCCESS;
+    PMI2_Command cmd = {0};
     int rc;
     const char *errmsg;
 
-    mpi_errno = PMIi_WriteSimpleCommandStr(PMI_fd, &cmd, KVSPUT_CMD, KEY_KEY, key, VALUE_KEY, value, NULL);
-    if (mpi_errno) MPIU_ERR_POP(mpi_errno);
-    mpi_errno = PMIi_ReadCommandExp(PMI_fd, &cmd, KVSPUTRESP_CMD, &rc, &errmsg);
-    if (mpi_errno) MPIU_ERR_POP(mpi_errno);
-    MPIU_ERR_CHKANDJUMP1(rc, mpi_errno, MPI_ERR_OTHER, "**pmi_kvsput", "**pmi_kvsput %s", errmsg ? errmsg : "unknown");        
+    pmi2_errno = PMIi_WriteSimpleCommandStr(PMI2_fd, &cmd, KVSPUT_CMD, KEY_KEY, key, VALUE_KEY, value, NULL);
+    if (pmi2_errno) PMI2U_ERR_POP(pmi2_errno);
+    pmi2_errno = PMIi_ReadCommandExp(PMI2_fd, &cmd, KVSPUTRESP_CMD, &rc, &errmsg);
+    if (pmi2_errno) PMI2U_ERR_POP(pmi2_errno);
+    PMI2U_ERR_CHKANDJUMP1(rc, pmi2_errno, PMI2_ERR_OTHER, "**pmi2_kvsput", "**pmi2_kvsput %s", errmsg ? errmsg : "unknown");
         
 fn_exit:
     freepairs(cmd.pairs, cmd.nPairs);
-    return mpi_errno;
+    return pmi2_errno;
 fn_fail:
     goto fn_exit;
 }
-#undef FUNCNAME
-#define FUNCNAME PMI_KVS_Fence
-#undef FCNAME
-#define FCNAME MPIDI_QUOTE(FUNCNAME)
-int PMI_KVS_Fence(void)
+int PMI2_KVS_Fence(void)
 {
-    int mpi_errno = MPI_SUCCESS;
-    PMI_Command cmd = {0};
+    int pmi2_errno = PMI2_SUCCESS;
+    PMI2_Command cmd = {0};
     int rc;
     const char *errmsg;
 
-    mpi_errno = PMIi_WriteSimpleCommandStr(PMI_fd, &cmd, KVSFENCE_CMD, NULL);
-    if (mpi_errno) MPIU_ERR_POP(mpi_errno);
-    mpi_errno = PMIi_ReadCommandExp(PMI_fd, &cmd, KVSFENCERESP_CMD, &rc, &errmsg);
-    if (mpi_errno) MPIU_ERR_POP(mpi_errno);
-    MPIU_ERR_CHKANDJUMP1(rc, mpi_errno, MPI_ERR_OTHER, "**pmi_kvsfence", "**pmi_kvsfence %s", errmsg ? errmsg : "unknown");
+    pmi2_errno = PMIi_WriteSimpleCommandStr(PMI2_fd, &cmd, KVSFENCE_CMD, NULL);
+    if (pmi2_errno) PMI2U_ERR_POP(pmi2_errno);
+    pmi2_errno = PMIi_ReadCommandExp(PMI2_fd, &cmd, KVSFENCERESP_CMD, &rc, &errmsg);
+    if (pmi2_errno) PMI2U_ERR_POP(pmi2_errno);
+    PMI2U_ERR_CHKANDJUMP1(rc, pmi2_errno, PMI2_ERR_OTHER, "**pmi2_kvsfence", "**pmi2_kvsfence %s", errmsg ? errmsg : "unknown");
 
 fn_exit:
     freepairs(cmd.pairs, cmd.nPairs);
-    return mpi_errno;
+    return pmi2_errno;
 fn_fail:
     goto fn_exit;
 }
 
-#undef FUNCNAME
-#define FUNCNAME PMI_KVS_Get
-#undef FCNAME
-#define FCNAME MPIDI_QUOTE(FUNCNAME)
-int PMI_KVS_Get(const char *jobid, const char key[], char value [], int maxValue, int *valLen)
+int PMI2_KVS_Get(const char *jobid, const char key[], char value [], int maxValue, int *valLen)
 {
-    int mpi_errno = MPI_SUCCESS;
+    int pmi2_errno = PMI2_SUCCESS;
     int found, keyfound;
     const char *kvsvalue;
     int kvsvallen;
     int ret;
-    PMI_Command cmd = {0};
+    PMI2_Command cmd = {0};
     int rc;
     const char *errmsg;
 
-    mpi_errno = PMIi_InitIfSingleton();
-    if (mpi_errno) MPIU_ERR_POP(mpi_errno);
+    pmi2_errno = PMIi_InitIfSingleton();
+    if (pmi2_errno) PMI2U_ERR_POP(pmi2_errno);
     
-    mpi_errno = PMIi_WriteSimpleCommandStr(PMI_fd, &cmd, KVSGET_CMD, JOBID_KEY, jobid, KEY_KEY, key, NULL);
-    if (mpi_errno) MPIU_ERR_POP(mpi_errno);
-    mpi_errno = PMIi_ReadCommandExp(PMI_fd, &cmd, KVSGETRESP_CMD, &rc, &errmsg);
-    if (mpi_errno) MPIU_ERR_POP(mpi_errno);
-    MPIU_ERR_CHKANDJUMP1(rc, mpi_errno, MPI_ERR_OTHER, "**pmi_kvsget", "**pmi_kvsget %s", errmsg ? errmsg : "unknown");
+    pmi2_errno = PMIi_WriteSimpleCommandStr(PMI2_fd, &cmd, KVSGET_CMD, JOBID_KEY, jobid, KEY_KEY, key, NULL);
+    if (pmi2_errno) PMI2U_ERR_POP(pmi2_errno);
+    pmi2_errno = PMIi_ReadCommandExp(PMI2_fd, &cmd, KVSGETRESP_CMD, &rc, &errmsg);
+    if (pmi2_errno) PMI2U_ERR_POP(pmi2_errno);
+    PMI2U_ERR_CHKANDJUMP1(rc, pmi2_errno, PMI2_ERR_OTHER, "**pmi2_kvsget", "**pmi2_kvsget %s", errmsg ? errmsg : "unknown");
 
     found = getvalbool(cmd.pairs, cmd.nPairs, FOUND_KEY, &keyfound);
-    MPIU_ERR_CHKANDJUMP(found != 1, mpi_errno, MPI_ERR_OTHER, "**intern");
-    MPIU_ERR_CHKANDJUMP(!keyfound, mpi_errno, MPI_ERR_OTHER, "**pmi_kvsget_notfound");
+    PMI2U_ERR_CHKANDJUMP(found != 1, pmi2_errno, PMI2_ERR_OTHER, "**intern");
+    PMI2U_ERR_CHKANDJUMP(!keyfound, pmi2_errno, PMI2_ERR_OTHER, "**pmi2_kvsget_notfound");
 
     found = getval(cmd.pairs, cmd.nPairs, VALUE_KEY, &kvsvalue, &kvsvallen);
-    MPIU_ERR_CHKANDJUMP(found != 1, mpi_errno, MPI_ERR_OTHER, "**intern");
+    PMI2U_ERR_CHKANDJUMP(found != 1, pmi2_errno, PMI2_ERR_OTHER, "**intern");
 
-    ret = MPIU_Strncpy(value, kvsvalue, maxValue);
+    ret = PMI2U_Strncpy(value, kvsvalue, maxValue);
     *valLen = ret ? -kvsvallen : kvsvallen;
     
 
  fn_exit:
     freepairs(cmd.pairs, cmd.nPairs);
-    return mpi_errno;
+    return pmi2_errno;
  fn_fail:
 
     goto fn_exit;
 }
 
-#undef FUNCNAME
-#define FUNCNAME PMI_Info_GetNodeAttr
-#undef FCNAME
-#define FCNAME MPIDI_QUOTE(FUNCNAME)
-int PMI_Info_GetNodeAttr(const char name[], char value[], int valuelen, int *flag, int waitfor)
+int PMI2_Info_GetNodeAttr(const char name[], char value[], int valuelen, int *flag, int waitfor)
 {
-    int mpi_errno = MPI_SUCCESS;
+    int pmi2_errno = PMI2_SUCCESS;
     int found;
     const char *kvsvalue;
     int kvsvallen;
-    PMI_Command cmd = {0};
+    PMI2_Command cmd = {0};
     int rc;
     const char *errmsg;
 
-    mpi_errno = PMIi_InitIfSingleton();
-    if (mpi_errno) MPIU_ERR_POP(mpi_errno);
+    pmi2_errno = PMIi_InitIfSingleton();
+    if (pmi2_errno) PMI2U_ERR_POP(pmi2_errno);
     
-    mpi_errno = PMIi_WriteSimpleCommandStr(PMI_fd, &cmd, GETNODEATTR_CMD, KEY_KEY, name, WAIT_KEY, waitfor ? "TRUE" : "FALSE", NULL);
-    if (mpi_errno) MPIU_ERR_POP(mpi_errno);
-    mpi_errno = PMIi_ReadCommandExp(PMI_fd, &cmd, GETNODEATTRRESP_CMD, &rc, &errmsg);
-    if (mpi_errno) MPIU_ERR_POP(mpi_errno);
-    MPIU_ERR_CHKANDJUMP1(rc, mpi_errno, MPI_ERR_OTHER, "**pmi_getnodeattr", "**pmi_getnodeattr %s", errmsg ? errmsg : "unknown");
+    pmi2_errno = PMIi_WriteSimpleCommandStr(PMI2_fd, &cmd, GETNODEATTR_CMD, KEY_KEY, name, WAIT_KEY, waitfor ? "TRUE" : "FALSE", NULL);
+    if (pmi2_errno) PMI2U_ERR_POP(pmi2_errno);
+    pmi2_errno = PMIi_ReadCommandExp(PMI2_fd, &cmd, GETNODEATTRRESP_CMD, &rc, &errmsg);
+    if (pmi2_errno) PMI2U_ERR_POP(pmi2_errno);
+    PMI2U_ERR_CHKANDJUMP1(rc, pmi2_errno, PMI2_ERR_OTHER, "**pmi2_getnodeattr", "**pmi2_getnodeattr %s", errmsg ? errmsg : "unknown");
 
     found = getvalbool(cmd.pairs, cmd.nPairs, FOUND_KEY, flag);
-    MPIU_ERR_CHKANDJUMP(found != 1, mpi_errno, MPI_ERR_OTHER, "**intern");
+    PMI2U_ERR_CHKANDJUMP(found != 1, pmi2_errno, PMI2_ERR_OTHER, "**intern");
     if (*flag) {
         found = getval(cmd.pairs, cmd.nPairs, VALUE_KEY, &kvsvalue, &kvsvallen);
-        MPIU_ERR_CHKANDJUMP(found != 1, mpi_errno, MPI_ERR_OTHER, "**intern");
+        PMI2U_ERR_CHKANDJUMP(found != 1, pmi2_errno, PMI2_ERR_OTHER, "**intern");
 
-        MPIU_Strncpy(value, kvsvalue, valuelen);
+        PMI2U_Strncpy(value, kvsvalue, valuelen);
     }
     
 fn_exit:
     freepairs(cmd.pairs, cmd.nPairs);
-    return mpi_errno;
+    return pmi2_errno;
 fn_fail:
     goto fn_exit;
 }
 
-#undef FUNCNAME
-#define FUNCNAME PMI_Info_GetNodeAttr
-#undef FCNAME
-#define FCNAME MPIDI_QUOTE(FUNCNAME)
-int PMI_Info_GetNodeAttrIntArray(const char name[], int array[], int arraylen, int *outlen, int *flag)
+int PMI2_Info_GetNodeAttrIntArray(const char name[], int array[], int arraylen, int *outlen, int *flag)
 {
-    int mpi_errno = MPI_SUCCESS;
+    int pmi2_errno = PMI2_SUCCESS;
     int found;
     const char *kvsvalue;
     int kvsvallen;
-    PMI_Command cmd = {0};
+    PMI2_Command cmd = {0};
     int rc;
     const char *errmsg;
     int i;
     const char *valptr;
     
-    mpi_errno = PMIi_InitIfSingleton();
-    if (mpi_errno) MPIU_ERR_POP(mpi_errno);
+    pmi2_errno = PMIi_InitIfSingleton();
+    if (pmi2_errno) PMI2U_ERR_POP(pmi2_errno);
     
-    mpi_errno = PMIi_WriteSimpleCommandStr(PMI_fd, &cmd, GETNODEATTR_CMD, KEY_KEY, name, WAIT_KEY, "FALSE", NULL);
-    if (mpi_errno) MPIU_ERR_POP(mpi_errno);
-    mpi_errno = PMIi_ReadCommandExp(PMI_fd, &cmd, GETNODEATTRRESP_CMD, &rc, &errmsg);
-    if (mpi_errno) MPIU_ERR_POP(mpi_errno);
-    MPIU_ERR_CHKANDJUMP1(rc, mpi_errno, MPI_ERR_OTHER, "**pmi_getnodeattr", "**pmi_getnodeattr %s", errmsg ? errmsg : "unknown");
+    pmi2_errno = PMIi_WriteSimpleCommandStr(PMI2_fd, &cmd, GETNODEATTR_CMD, KEY_KEY, name, WAIT_KEY, "FALSE", NULL);
+    if (pmi2_errno) PMI2U_ERR_POP(pmi2_errno);
+    pmi2_errno = PMIi_ReadCommandExp(PMI2_fd, &cmd, GETNODEATTRRESP_CMD, &rc, &errmsg);
+    if (pmi2_errno) PMI2U_ERR_POP(pmi2_errno);
+    PMI2U_ERR_CHKANDJUMP1(rc, pmi2_errno, PMI2_ERR_OTHER, "**pmi2_getnodeattr", "**pmi2_getnodeattr %s", errmsg ? errmsg : "unknown");
 
     found = getvalbool(cmd.pairs, cmd.nPairs, FOUND_KEY, flag);
-    MPIU_ERR_CHKANDJUMP(found != 1, mpi_errno, MPI_ERR_OTHER, "**intern");
+    PMI2U_ERR_CHKANDJUMP(found != 1, pmi2_errno, PMI2_ERR_OTHER, "**intern");
     if (*flag) {
         found = getval(cmd.pairs, cmd.nPairs, VALUE_KEY, &kvsvalue, &kvsvallen);
-        MPIU_ERR_CHKANDJUMP(found != 1, mpi_errno, MPI_ERR_OTHER, "**intern");
+        PMI2U_ERR_CHKANDJUMP(found != 1, pmi2_errno, PMI2_ERR_OTHER, "**intern");
 
         valptr = kvsvalue;
         i = 0;
         rc = sscanf(valptr, "%d", &array[i]);
-        MPIU_ERR_CHKANDJUMP1(rc != 1, mpi_errno, MPI_ERR_OTHER, "**intern", "**intern %s", "unable to parse intarray");
+        PMI2U_ERR_CHKANDJUMP1(rc != 1, pmi2_errno, PMI2_ERR_OTHER, "**intern", "**intern %s", "unable to parse intarray");
         ++i;
         while ((valptr = strchr(valptr, ',')) && i < arraylen) {
             ++valptr; /* skip over the ',' */
             rc = sscanf(valptr, "%d", &array[i]);
-            MPIU_ERR_CHKANDJUMP1(rc != 1, mpi_errno, MPI_ERR_OTHER, "**intern", "**intern %s", "unable to parse intarray");
+            PMI2U_ERR_CHKANDJUMP1(rc != 1, pmi2_errno, PMI2_ERR_OTHER, "**intern", "**intern %s", "unable to parse intarray");
             ++i;
         }
         
@@ -837,114 +783,102 @@
     
 fn_exit:
     freepairs(cmd.pairs, cmd.nPairs);
-    return mpi_errno;
+    return pmi2_errno;
 fn_fail:
     goto fn_exit;
 }
 
-#undef FUNCNAME
-#define FUNCNAME PMI_Info_PutNodeAttr
-#undef FCNAME
-#define FCNAME MPIDI_QUOTE(FUNCNAME)
-int PMI_Info_PutNodeAttr(const char name[], const char value[])
+int PMI2_Info_PutNodeAttr(const char name[], const char value[])
 {
-    int mpi_errno = MPI_SUCCESS;
-    PMI_Command cmd = {0};
+    int pmi2_errno = PMI2_SUCCESS;
+    PMI2_Command cmd = {0};
     int rc;
     const char *errmsg;
 
-    mpi_errno = PMIi_WriteSimpleCommandStr(PMI_fd, &cmd, PUTNODEATTR_CMD, KEY_KEY, name, VALUE_KEY, value, NULL);
-    if (mpi_errno) MPIU_ERR_POP(mpi_errno);
-    mpi_errno = PMIi_ReadCommandExp(PMI_fd, &cmd, PUTNODEATTRRESP_CMD, &rc, &errmsg);
-    if (mpi_errno) MPIU_ERR_POP(mpi_errno);
-    MPIU_ERR_CHKANDJUMP1(rc, mpi_errno, MPI_ERR_OTHER, "**pmi_putnodeattr", "**pmi_putnodeattr %s", errmsg ? errmsg : "unknown");
+    pmi2_errno = PMIi_WriteSimpleCommandStr(PMI2_fd, &cmd, PUTNODEATTR_CMD, KEY_KEY, name, VALUE_KEY, value, NULL);
+    if (pmi2_errno) PMI2U_ERR_POP(pmi2_errno);
+    pmi2_errno = PMIi_ReadCommandExp(PMI2_fd, &cmd, PUTNODEATTRRESP_CMD, &rc, &errmsg);
+    if (pmi2_errno) PMI2U_ERR_POP(pmi2_errno);
+    PMI2U_ERR_CHKANDJUMP1(rc, pmi2_errno, PMI2_ERR_OTHER, "**pmi2_putnodeattr", "**pmi2_putnodeattr %s", errmsg ? errmsg : "unknown");
         
 fn_exit:
     freepairs(cmd.pairs, cmd.nPairs);
-    return mpi_errno;
+    return pmi2_errno;
 fn_fail:
     goto fn_exit;
 }
 
-#undef FUNCNAME
-#define FUNCNAME PMI_Info_GetJobAttr
-#undef FCNAME
-#define FCNAME MPIDI_QUOTE(FUNCNAME)
-int PMI_Info_GetJobAttr(const char name[], char value[], int valuelen, int *flag)
+int PMI2_Info_GetJobAttr(const char name[], char value[], int valuelen, int *flag)
 {
-    int mpi_errno = MPI_SUCCESS;
+    int pmi2_errno = PMI2_SUCCESS;
     int found;
     const char *kvsvalue;
     int kvsvallen;
-    PMI_Command cmd = {0};
+    PMI2_Command cmd = {0};
     int rc;
     const char *errmsg;
 
-    mpi_errno = PMIi_InitIfSingleton();
-    if (mpi_errno) MPIU_ERR_POP(mpi_errno);
+    pmi2_errno = PMIi_InitIfSingleton();
+    if (pmi2_errno) PMI2U_ERR_POP(pmi2_errno);
     
-    mpi_errno = PMIi_WriteSimpleCommandStr(PMI_fd, &cmd, GETJOBATTR_CMD, KEY_KEY, name, NULL);
-    if (mpi_errno) MPIU_ERR_POP(mpi_errno);
-    mpi_errno = PMIi_ReadCommandExp(PMI_fd, &cmd, GETJOBATTRRESP_CMD, &rc, &errmsg);
-    if (mpi_errno) MPIU_ERR_POP(mpi_errno);
-    MPIU_ERR_CHKANDJUMP1(rc, mpi_errno, MPI_ERR_OTHER, "**pmi_getjobattr", "**pmi_getjobattr %s", errmsg ? errmsg : "unknown");
+    pmi2_errno = PMIi_WriteSimpleCommandStr(PMI2_fd, &cmd, GETJOBATTR_CMD, KEY_KEY, name, NULL);
+    if (pmi2_errno) PMI2U_ERR_POP(pmi2_errno);
+    pmi2_errno = PMIi_ReadCommandExp(PMI2_fd, &cmd, GETJOBATTRRESP_CMD, &rc, &errmsg);
+    if (pmi2_errno) PMI2U_ERR_POP(pmi2_errno);
+    PMI2U_ERR_CHKANDJUMP1(rc, pmi2_errno, PMI2_ERR_OTHER, "**pmi2_getjobattr", "**pmi2_getjobattr %s", errmsg ? errmsg : "unknown");
 
     found = getvalbool(cmd.pairs, cmd.nPairs, FOUND_KEY, flag);
-    MPIU_ERR_CHKANDJUMP(found != 1, mpi_errno, MPI_ERR_OTHER, "**intern");
+    PMI2U_ERR_CHKANDJUMP(found != 1, pmi2_errno, PMI2_ERR_OTHER, "**intern");
 
     if (*flag) {
         found = getval(cmd.pairs, cmd.nPairs, VALUE_KEY, &kvsvalue, &kvsvallen);
-        MPIU_ERR_CHKANDJUMP(found != 1, mpi_errno, MPI_ERR_OTHER, "**intern");
+        PMI2U_ERR_CHKANDJUMP(found != 1, pmi2_errno, PMI2_ERR_OTHER, "**intern");
         
-        MPIU_Strncpy(value, kvsvalue, valuelen);
+        PMI2U_Strncpy(value, kvsvalue, valuelen);
     }
     
 fn_exit:
     freepairs(cmd.pairs, cmd.nPairs);
-    return mpi_errno;
+    return pmi2_errno;
 fn_fail:
     goto fn_exit;
 }
-#undef FUNCNAME
-#define FUNCNAME PMI_Info_GetJobAttrIntArray
-#undef FCNAME
-#define FCNAME MPIDI_QUOTE(FUNCNAME)
-int PMI_Info_GetJobAttrIntArray(const char name[], int array[], int arraylen, int *outlen, int *flag)
+int PMI2_Info_GetJobAttrIntArray(const char name[], int array[], int arraylen, int *outlen, int *flag)
 {
-    int mpi_errno = MPI_SUCCESS;
+    int pmi2_errno = PMI2_SUCCESS;
     int found;
     const char *kvsvalue;
     int kvsvallen;
-    PMI_Command cmd = {0};
+    PMI2_Command cmd = {0};
     int rc;
     const char *errmsg;
     int i;
     const char *valptr;
     
-    mpi_errno = PMIi_InitIfSingleton();
-    if (mpi_errno) MPIU_ERR_POP(mpi_errno);
+    pmi2_errno = PMIi_InitIfSingleton();
+    if (pmi2_errno) PMI2U_ERR_POP(pmi2_errno);
     
-    mpi_errno = PMIi_WriteSimpleCommandStr(PMI_fd, &cmd, GETJOBATTR_CMD, KEY_KEY, name, NULL);
-    if (mpi_errno) MPIU_ERR_POP(mpi_errno);
-    mpi_errno = PMIi_ReadCommandExp(PMI_fd, &cmd, GETJOBATTRRESP_CMD, &rc, &errmsg);
-    if (mpi_errno) MPIU_ERR_POP(mpi_errno);
-    MPIU_ERR_CHKANDJUMP1(rc, mpi_errno, MPI_ERR_OTHER, "**pmi_getjobattr", "**pmi_getjobattr %s", errmsg ? errmsg : "unknown");
+    pmi2_errno = PMIi_WriteSimpleCommandStr(PMI2_fd, &cmd, GETJOBATTR_CMD, KEY_KEY, name, NULL);
+    if (pmi2_errno) PMI2U_ERR_POP(pmi2_errno);
+    pmi2_errno = PMIi_ReadCommandExp(PMI2_fd, &cmd, GETJOBATTRRESP_CMD, &rc, &errmsg);
+    if (pmi2_errno) PMI2U_ERR_POP(pmi2_errno);
+    PMI2U_ERR_CHKANDJUMP1(rc, pmi2_errno, PMI2_ERR_OTHER, "**pmi2_getjobattr", "**pmi2_getjobattr %s", errmsg ? errmsg : "unknown");
 
     found = getvalbool(cmd.pairs, cmd.nPairs, FOUND_KEY, flag);
-    MPIU_ERR_CHKANDJUMP(found != 1, mpi_errno, MPI_ERR_OTHER, "**intern");
+    PMI2U_ERR_CHKANDJUMP(found != 1, pmi2_errno, PMI2_ERR_OTHER, "**intern");
     if (*flag) {
         found = getval(cmd.pairs, cmd.nPairs, VALUE_KEY, &kvsvalue, &kvsvallen);
-        MPIU_ERR_CHKANDJUMP(found != 1, mpi_errno, MPI_ERR_OTHER, "**intern");
+        PMI2U_ERR_CHKANDJUMP(found != 1, pmi2_errno, PMI2_ERR_OTHER, "**intern");
 
         valptr = kvsvalue;
         i = 0;
         rc = sscanf(valptr, "%d", &array[i]);
-        MPIU_ERR_CHKANDJUMP1(rc != 1, mpi_errno, MPI_ERR_OTHER, "**intern", "**intern %s", "unable to parse intarray");
+        PMI2U_ERR_CHKANDJUMP1(rc != 1, pmi2_errno, PMI2_ERR_OTHER, "**intern", "**intern %s", "unable to parse intarray");
         ++i;
         while ((valptr = strchr(valptr, ',')) && i < arraylen) {
             ++valptr; /* skip over the ',' */
             rc = sscanf(valptr, "%d", &array[i]);
-            MPIU_ERR_CHKANDJUMP1(rc != 1, mpi_errno, MPI_ERR_OTHER, "**intern", "**intern %s", "unable to parse intarray");
+            PMI2U_ERR_CHKANDJUMP1(rc != 1, pmi2_errno, PMI2_ERR_OTHER, "**intern", "**intern %s", "unable to parse intarray");
             ++i;
         }
         
@@ -953,31 +887,27 @@
     
 fn_exit:
     freepairs(cmd.pairs, cmd.nPairs);
-    return mpi_errno;
+    return pmi2_errno;
 fn_fail:
     goto fn_exit;
 }
 
-#undef FUNCNAME
-#define FUNCNAME PMI_Nameserv_publish
-#undef FCNAME
-#define FCNAME MPIDI_QUOTE(FUNCNAME)
-int PMI_Nameserv_publish(const char service_name[], const MPID_Info *info_ptr, const char port[])
+int PMI2_Nameserv_publish(const char service_name[], const PMI2U_Info *info_ptr, const char port[])
 {
 #if 0
-    int mpi_errno = MPI_SUCCESS;
-    PMI_Keyvalpair *pairs;
-    PMI_Keyvalpair **pair_p;
-    int ninfokeys = 0; 
-    const MPID_Info *ip = info_ptr;
+    int pmi2_errno = PMI2_SUCCESS;
+    PMI2_Keyvalpair *pairs;
+    PMI2_Keyvalpair **pair_p;
+    int ninfokeys = 0;
+    const PMI2U_Info *ip = info_ptr;
     int i;
-    PMI_Command cmd = {0};
+    PMI2_Command cmd = {0};
     int rc;
     const char *errmsg;
     char intbuf[MAX_INT_STR_LEN];
-    MPIU_CHKLMEM_DECL(2);
+    PMI2U_CHKLMEM_DECL(2);
 
-    MPIU_ERR_SETANDJUMP(mpi_errno, MPI_ERR_OTHER, "**notimpl");
+    PMI2U_ERR_SETANDJUMP(pmi2_errno, PMI2_ERR_OTHER, "**notimpl");
         
     
     while (ip) {
@@ -985,24 +915,24 @@
         ip = ip->next;
     }
     
-    /* MPIU_CHKLMEM_MALLOC(pairs, PMI_Keyvalpair *, (sizeof(PMI_Keyvalpair) * 2 * ninfokeys + 1), mpi_errno, "pairs"); */
-    /* MPIU_CHKLMEM_MALLOC(pair_p, PMI_Keyvalpair **, (sizeof(PMI_Keyvalpair*) * 2 * ninfokeys + 1), mpi_errno, "pair_p"); */
+    /* PMI2U_CHKLMEM_MALLOC(pairs, PMI2_Keyvalpair *, (sizeof(PMI2_Keyvalpair) * 2 * ninfokeys + 1), pmi2_errno, "pairs"); */
+    /* PMI2U_CHKLMEM_MALLOC(pair_p, PMI2_Keyvalpair **, (sizeof(PMI2_Keyvalpair*) * 2 * ninfokeys + 1), pmi2_errno, "pair_p"); */
 
-    MPIU_Snprintf(intbuf, sizeof(intbuf), "%u", ninfokeys);
-    init_kv_str(&pairs[0], INFOKEYCOUNT_KEY, intbuf);        
+    PMI2U_Snprintf(intbuf, sizeof(intbuf), "%u", ninfokeys);
+    init_kv_str(&pairs[0], INFOKEYCOUNT_KEY, intbuf);
 
-    mpi_errno = PMIi_WriteSimpleCommandStr(PMI_fd, &cmd, NAMEPUBLISH_CMD, NAME_KEY, service_name, PORT_KEY, port, NULL);
-    if (mpi_errno) MPIU_ERR_POP(mpi_errno);
-    mpi_errno = PMIi_ReadCommandExp(PMI_fd, &cmd, NAMEPUBLISHRESP_CMD, &rc, &errmsg);
-    if (mpi_errno) MPIU_ERR_POP(mpi_errno);
-    MPIU_ERR_CHKANDJUMP1(rc, mpi_errno, MPI_ERR_OTHER, "**pmi_nameservpublish", "**pmi_nameservpublish %s", errmsg ? errmsg : "unknown");
+    pmi2_errno = PMIi_WriteSimpleCommandStr(PMI2_fd, &cmd, NAMEPUBLISH_CMD, NAME_KEY, service_name, PORT_KEY, port, NULL);
+    if (pmi2_errno) PMI2U_ERR_POP(pmi2_errno);
+    pmi2_errno = PMIi_ReadCommandExp(PMI2_fd, &cmd, NAMEPUBLISHRESP_CMD, &rc, &errmsg);
+    if (pmi2_errno) PMI2U_ERR_POP(pmi2_errno);
+    PMI2U_ERR_CHKANDJUMP1(rc, pmi2_errno, PMI2_ERR_OTHER, "**pmi2_nameservpublish", "**pmi2_nameservpublish %s", errmsg ? errmsg : "unknown");
 
         
         
 fn_exit:
     freepairs(cmd.pairs, cmd.nPairs);
-    MPIU_CHKLMEM_FREEALL();
-    return mpi_errno;
+    PMI2U_CHKLMEM_FREEALL();
+    return pmi2_errno;
 fn_fail:
 
     goto fn_exit;
@@ -1011,34 +941,26 @@
 }
 
 
-#undef FUNCNAME
-#define FUNCNAME PMI_Nameserv_lookup
-#undef FCNAME
-#define FCNAME MPIDI_QUOTE(FUNCNAME)
-int PMI_Nameserv_lookup(const char service_name[], const MPID_Info *info_ptr,
+int PMI2_Nameserv_lookup(const char service_name[], const PMI2U_Info *info_ptr,
                         char port[], int portLen)
 {
-    int mpi_errno = MPI_SUCCESS;
+    int pmi2_errno = PMI2_SUCCESS;
         
         
 fn_exit:
-    return mpi_errno;
+    return pmi2_errno;
 fn_fail:
     goto fn_exit;
 }
 
-#undef FUNCNAME
-#define FUNCNAME PMI_Nameserv_unpublish
-#undef FCNAME
-#define FCNAME MPIDI_QUOTE(FUNCNAME)
-int PMI_Nameserv_unpublish(const char service_name[], 
-                           const MPID_Info *info_ptr)
+int PMI2_Nameserv_unpublish(const char service_name[],
+                           const PMI2U_Info *info_ptr)
 {
-    int mpi_errno = MPI_SUCCESS;
+    int pmi2_errno = PMI2_SUCCESS;
         
         
 fn_exit:
-    return mpi_errno;
+    return pmi2_errno;
 fn_fail:
     goto fn_exit;
 }
@@ -1050,19 +972,19 @@
  * PMIi_ReadCommand - Reads an entire command from the PMI socket.  This
  * routine blocks the thread until the command is read.
  *
- * PMIi_WriteSimpleCommand - Write a simple command to the PMI socket; this 
+ * PMIi_WriteSimpleCommand - Write a simple command to the PMI socket; this
  * allows printf - style arguments.  This blocks the thread until the buffer
- * has been written (for fault-tolerance, we may want to keep it around 
+ * has been written (for fault-tolerance, we may want to keep it around
  * in case of PMI failure).
  *
- * PMIi_WaitFor - Wait for a particular PMI command request to complete.  
- * In a multithreaded environment, this may 
+ * PMIi_WaitFor - Wait for a particular PMI command request to complete.
+ * In a multithreaded environment, this may
  */
 /* ------------------------------------------------------------------------- */
 
 
 /* frees all of the keyvals pointed to by a keyvalpair* array and the array iteself*/
-static void freepairs(PMI_Keyvalpair** pairs, int npairs)
+static void freepairs(PMI2_Keyvalpair** pairs, int npairs)
 {
     int i;
 
@@ -1071,8 +993,8 @@
 
     for (i = 0; i < npairs; ++i)
         if (pairs[i]->isCopy)
-            MPIU_Free(pairs[i]);
-    MPIU_Free(pairs);
+            PMI2U_Free(pairs[i]);
+    PMI2U_Free(pairs);
 }
 
 
@@ -1080,16 +1002,12 @@
  * matching key, set val appropriately and return 1.  If no matching
  * key is found, 0 is returned.  If the value is invalid, -1 is returned */
 
-#undef FUNCNAME
-#define FUNCNAME getval
-#undef FCNAME
-#define FCNAME MPIDI_QUOTE(FUNCNAME)
-static int getval(PMI_Keyvalpair *const pairs[], int npairs, const char *key,  const char **value, int *vallen)
+static int getval(PMI2_Keyvalpair *const pairs[], int npairs, const char *key,  const char **value, int *vallen)
 {
     int i;
     
-    for (i = 0; i < npairs; ++i) 
-        if (strncmp(key, pairs[i]->key, PMI_MAX_KEYLEN) == 0) {
+    for (i = 0; i < npairs; ++i)
+        if (strncmp(key, pairs[i]->key, PMI2_MAX_KEYLEN) == 0) {
             *value = pairs[i]->value;
             *vallen = pairs[i]->valueLen;
             return 1;
@@ -1097,16 +1015,13 @@
     return 0;
 }
 
-#undef FUNCNAME
-#define FUNCNAME getvalint
-#undef FCNAME
-#define FCNAME MPIDI_QUOTE(FUNCNAME)
-static int getvalint(PMI_Keyvalpair *const pairs[], int npairs, const char *key, int *val)
+static int getvalint(PMI2_Keyvalpair *const pairs[], int npairs, const char *key, int *val)
 {
     int found;
     const char *value;
     int vallen;
-    char *endptr;
+    int ret;
+    /* char *endptr; */
     
     found = getval(pairs, npairs, key, &value, &vallen);
     if (found != 1)
@@ -1115,24 +1030,25 @@
     if (vallen == 0)
         return -1;
 
-    *val = strtoll(value, &endptr, 0);
-    if (endptr - value != vallen)
+    ret = sscanf(value, "%d", val);
+    if (ret != 1)
         return -1;
     
+    /* *val = strtoll(value, &endptr, 0); */
+    /* if (endptr - value != vallen) */
+    /*     return -1; */
+    
     return 1;
 }
 
-#undef FUNCNAME
-#define FUNCNAME getvalptr
-#undef FCNAME
-#define FCNAME MPIDI_QUOTE(FUNCNAME)
-static int getvalptr(PMI_Keyvalpair *const pairs[], int npairs, const char *key, void *val)
+static int getvalptr(PMI2_Keyvalpair *const pairs[], int npairs, const char *key, void *val)
 {
     int found;
     const char *value;
     int vallen;
-    char *endptr;
+    int ret;
     void **val_ = val;
+    /* char *endptr; */
     
     found = getval(pairs, npairs, key, &value, &vallen);
     if (found != 1)
@@ -1141,19 +1057,19 @@
     if (vallen == 0)
         return -1;
 
-    *val_ = (void *)(MPIR_Upint)strtoll(value, &endptr, 0);
-    if (endptr - value != vallen)
+    ret = sscanf(value, "%p", val_);
+    if (ret != 1)
         return -1;
+
+    /* *val_ = (void *)(PMI2R_Upint)strtoll(value, &endptr, 0); */
+    /* if (endptr - value != vallen) */
+    /*     return -1; */
     
     return 1;
 }
 
 
-#undef FUNCNAME
-#define FUNCNAME getvalbool
-#undef FCNAME
-#define FCNAME MPIDI_QUOTE(FUNCNAME)
-static int getvalbool(PMI_Keyvalpair *const pairs[], int npairs, const char *key, int *val)
+static int getvalbool(PMI2_Keyvalpair *const pairs[], int npairs, const char *key, int *val)
 {
     int found;
     const char *value;
@@ -1186,15 +1102,11 @@
 
    This function will modify the buffer passed through cmdptr to
    insert '\0' following the key, and to replace escaped ';;' with
-   ';'.  
+   ';'.
  */
-#undef FUNCNAME
-#define FUNCNAME parse_keyval
-#undef FCNAME
-#define FCNAME MPIDI_QUOTE(FUNCNAME)
 static int parse_keyval(char **cmdptr, int *len, char **key, char **val, int *vallen)
 {
-    int mpi_errno = MPI_SUCCESS;
+    int pmi2_errno = PMI2_SUCCESS;
     char *c = *cmdptr;
     char *d;
 
@@ -1205,8 +1117,8 @@
         --*len;
         ++c;
     }
-    MPIU_ERR_CHKANDJUMP(*len == 0, mpi_errno, MPI_ERR_OTHER, "**bad_keyval");
-    MPIU_ERR_CHKANDJUMP(c - *key > PMI_MAX_KEYLEN, mpi_errno, MPI_ERR_OTHER, "**bad_keyval");
+    PMI2U_ERR_CHKANDJUMP(*len == 0, pmi2_errno, PMI2_ERR_OTHER, "**bad_keyval");
+    PMI2U_ERR_CHKANDJUMP(c - *key > PMI2_MAX_KEYLEN, pmi2_errno, PMI2_ERR_OTHER, "**bad_keyval");
     *c = '\0'; /* terminate the key string */
 
     /* skip over the '=' */
@@ -1217,7 +1129,7 @@
     *val = d = c; /* val is next */
     while (*len) {
         if (*c == ';') { /* handle escaped ';' */
-            if (*(c+1) != ';') 
+            if (*(c+1) != ';')
                 break;
             else
             {
@@ -1228,37 +1140,33 @@
         --*len;
         *(d++) = *(c++);
     }
-    MPIU_ERR_CHKANDJUMP(*len == 0, mpi_errno, MPI_ERR_OTHER, "**bad_keyval");
-    MPIU_ERR_CHKANDJUMP(d - *val > PMI_MAX_VALLEN, mpi_errno, MPI_ERR_OTHER, "**bad_keyval");
+    PMI2U_ERR_CHKANDJUMP(*len == 0, pmi2_errno, PMI2_ERR_OTHER, "**bad_keyval");
+    PMI2U_ERR_CHKANDJUMP(d - *val > PMI2_MAX_VALLEN, pmi2_errno, PMI2_ERR_OTHER, "**bad_keyval");
     *vallen = d - *val;
 
     *cmdptr = c+1; /* skip over the ';' */
     --*len;
 
  fn_exit:
-    return mpi_errno;
+    return pmi2_errno;
  fn_fail:
     goto fn_exit;
 }
 
-#undef FUNCNAME
-#define FUNCNAME create_keyval
-#undef FCNAME
-#define FCNAME MPIDI_QUOTE(FUNCNAME)
-static int create_keyval(PMI_Keyvalpair **kv, const char *key, const char *val, int vallen)
+static int create_keyval(PMI2_Keyvalpair **kv, const char *key, const char *val, int vallen)
 {
-    int mpi_errno = MPI_SUCCESS;
+    int pmi2_errno = PMI2_SUCCESS;
     char *key_p;
     char *value_p;
-    MPIU_CHKPMEM_DECL(3);
+    PMI2U_CHKPMEM_DECL(3);
 
-    MPIU_CHKPMEM_MALLOC(*kv, PMI_Keyvalpair *, sizeof(PMI_Keyvalpair), mpi_errno, "pair");
+    PMI2U_CHKPMEM_MALLOC(*kv, PMI2_Keyvalpair *, sizeof(PMI2_Keyvalpair), pmi2_errno, "pair");
         
-    MPIU_CHKPMEM_MALLOC(key_p, char *, strlen(key)+1, mpi_errno, "key");
-    MPIU_Strncpy(key_p, key, PMI_MAX_KEYLEN+1);
+    PMI2U_CHKPMEM_MALLOC(key_p, char *, strlen(key)+1, pmi2_errno, "key");
+    PMI2U_Strncpy(key_p, key, PMI2_MAX_KEYLEN+1);
     
-    MPIU_CHKPMEM_MALLOC(value_p, char *, vallen+1, mpi_errno, "value");
-    MPIU_Memcpy(value_p, val, vallen);
+    PMI2U_CHKPMEM_MALLOC(value_p, char *, vallen+1, pmi2_errno, "value");
+    PMI2U_Memcpy(value_p, val, vallen);
     value_p[vallen] = '\0';
     
     (*kv)->key = key_p;
@@ -1267,23 +1175,19 @@
     (*kv)->isCopy = TRUE;
 
 fn_exit:
-    MPIU_CHKPMEM_COMMIT();
-    return mpi_errno;
+    PMI2U_CHKPMEM_COMMIT();
+    return pmi2_errno;
 fn_fail:
-    MPIU_CHKPMEM_REAP();
+    PMI2U_CHKPMEM_REAP();
     goto fn_exit;
 }
 
 
 /* Note that we fill in the fields in a command that is provided.
    We may want to share these routines with the PMI version 2 server */
-#undef FUNCNAME
-#define FUNCNAME PMIi_ReadCommand
-#undef FCNAME
-#define FCNAME MPIDI_QUOTE(FUNCNAME)
-int PMIi_ReadCommand( int fd, PMI_Command *cmd )
+int PMIi_ReadCommand( int fd, PMI2_Command *cmd )
 {
-    int mpi_errno = MPI_SUCCESS;
+    int pmi2_errno = PMI2_SUCCESS;
     char cmd_len_str[PMII_COMMANDLEN_SIZE+1];
     int cmd_len, remaining_len, vallen = 0;
     char *c, *cmd_buf = NULL;
@@ -1295,9 +1199,8 @@
     char *command = NULL;
     int nPairs;
     int found;
-    PMI_Keyvalpair **pairs = NULL;
-    PMI_Command *target_cmd;
-    MPIU_CHKPMEM_DECL(2);
+    PMI2_Keyvalpair **pairs = NULL;
+    PMI2_Command *target_cmd;
 
     memset(cmd_len_str, 0, sizeof(cmd_len_str));
 
@@ -1324,13 +1227,13 @@
 
         /* get length of cmd */
         offset = 0;
-        do 
+        do
         {
             do {
                 nbytes = read(fd, &cmd_len_str[offset], PMII_COMMANDLEN_SIZE - offset);
             } while (nbytes == -1 && errno == EINTR);
 
-            MPIU_ERR_CHKANDJUMP1(nbytes <= 0, mpi_errno, MPI_ERR_OTHER, "**read", "**read %s", strerror(errno));
+            PMI2U_ERR_CHKANDJUMP1(nbytes <= 0, pmi2_errno, PMI2_ERR_OTHER, "**read", "**read %s", strerror(errno));
 
             offset += nbytes;
         }
@@ -1338,20 +1241,20 @@
     
         cmd_len = atoi(cmd_len_str);
 
-        cmd_buf = MPIU_Malloc(cmd_len+1);
-        if (!cmd_buf) { MPIU_CHKMEM_SETERR(mpi_errno, cmd_len+1, "cmd_buf"); goto fn_exit; }        
+        cmd_buf = PMI2U_Malloc(cmd_len+1);
+        if (!cmd_buf) { PMI2U_CHKMEM_SETERR(pmi2_errno, cmd_len+1, "cmd_buf"); goto fn_exit; }
 
         memset(cmd_buf, 0, cmd_len+1);
 
         /* get command */
         offset = 0;
-        do 
+        do
         {
             do {
                 nbytes = read(fd, &cmd_buf[offset], cmd_len - offset);
             } while (nbytes == -1 && errno == EINTR);
 
-            MPIU_ERR_CHKANDJUMP1(nbytes <= 0, mpi_errno, MPI_ERR_OTHER, "**read", "**read %s", strerror(errno));
+            PMI2U_ERR_CHKANDJUMP1(nbytes <= 0, pmi2_errno, PMI2_ERR_OTHER, "**read", "**read %s", strerror(errno));
 
             offset += nbytes;
         }
@@ -1362,7 +1265,7 @@
         /* count number of "key=val;" */
         c = cmd_buf;
         remaining_len = cmd_len;
-        num_pairs = 0;    
+        num_pairs = 0;
     
         while (remaining_len) {
             while (remaining_len && *c != ';') {
@@ -1381,31 +1284,31 @@
     
         c = cmd_buf;
         remaining_len = cmd_len;
-        mpi_errno = parse_keyval(&c, &remaining_len, &key, &val, &vallen);
-        if (mpi_errno) MPIU_ERR_POP(mpi_errno);
+        pmi2_errno = parse_keyval(&c, &remaining_len, &key, &val, &vallen);
+        if (pmi2_errno) PMI2U_ERR_POP(pmi2_errno);
 
-        MPIU_ERR_CHKANDJUMP(strncmp(key, "cmd", PMI_MAX_KEYLEN) != 0, mpi_errno, MPI_ERR_OTHER, "**bad_cmd");
+        PMI2U_ERR_CHKANDJUMP(strncmp(key, "cmd", PMI2_MAX_KEYLEN) != 0, pmi2_errno, PMI2_ERR_OTHER, "**bad_cmd");
     
-        command = MPIU_Malloc(vallen+1);
-        if (!command) { MPIU_CHKMEM_SETERR(mpi_errno, vallen+1, "command"); goto fn_exit; }
-        MPIU_Memcpy(command, val, vallen);
+        command = PMI2U_Malloc(vallen+1);
+        if (!command) { PMI2U_CHKMEM_SETERR(pmi2_errno, vallen+1, "command"); goto fn_exit; }
+        PMI2U_Memcpy(command, val, vallen);
         val[vallen] = '\0';
 
         nPairs = num_pairs-1;  /* num_pairs-1 because the first pair is the command */
 
-        pairs = MPIU_Malloc(sizeof(PMI_Keyvalpair *) * nPairs);
-        if (!pairs) { MPIU_CHKMEM_SETERR(mpi_errno, sizeof(PMI_Keyvalpair *) * nPairs, "pairs"); goto fn_exit; }
+        pairs = PMI2U_Malloc(sizeof(PMI2_Keyvalpair *) * nPairs);
+        if (!pairs) { PMI2U_CHKMEM_SETERR(pmi2_errno, sizeof(PMI2_Keyvalpair *) * nPairs, "pairs"); goto fn_exit; }
     
         pair_index = 0;
         while (remaining_len)
         {
-            PMI_Keyvalpair *pair;
+            PMI2_Keyvalpair *pair;
         
-            mpi_errno = parse_keyval(&c, &remaining_len, &key, &val, &vallen);
-            if (mpi_errno) MPIU_ERR_POP(mpi_errno);
+            pmi2_errno = parse_keyval(&c, &remaining_len, &key, &val, &vallen);
+            if (pmi2_errno) PMI2U_ERR_POP(pmi2_errno);
 
-            mpi_errno = create_keyval(&pair, key, val, vallen);
-            if (mpi_errno) MPIU_ERR_POP(mpi_errno);
+            pmi2_errno = create_keyval(&pair, key, val, vallen);
+            if (pmi2_errno) PMI2U_ERR_POP(pmi2_errno);
         
             pairs[pair_index] = pair;
             ++pair_index;
@@ -1415,12 +1318,12 @@
         if (!found) /* if there's no thrid specified, assume it's for you */
             target_cmd = cmd;
         else
-            if (PMI_debug && SEARCH_REMOVE(target_cmd) == 0) {
+            if (PMI2_debug && SEARCH_REMOVE(target_cmd) == 0) {
                 int i;
                 
                 printf("command=%s\n", command);
                 for (i = 0; i < nPairs; ++i)
-                    dump_PMI_Keyvalpair(stdout, pairs[i]);
+                    dump_PMI2_Keyvalpair(stdout, pairs[i]);
             }
         
         target_cmd->command = command;
@@ -1430,7 +1333,7 @@
         target_cmd->complete = TRUE;
 #endif
 
-        MPIU_Free(cmd_buf);
+        PMI2U_Free(cmd_buf);
     } while (!cmd->complete);
     
 #ifdef MPICH_IS_THREADED
@@ -1448,57 +1351,47 @@
     
 
 fn_exit:
-    MPIU_CHKPMEM_COMMIT();
-    return mpi_errno;
+    return pmi2_errno;
 fn_fail:
-    MPIU_CHKPMEM_REAP();
     if (cmd_buf)
-        MPIU_Free(cmd_buf);
+        PMI2U_Free(cmd_buf);
     goto fn_exit;
 }
 
 /* PMIi_ReadCommandExp -- reads a command checks that it matches the
  * expected command string exp, and parses the return code */
-#undef FUNCNAME
-#define FUNCNAME PMIi_ReadCommandExp
-#undef FCNAME
-#define FCNAME MPIDI_QUOTE(FUNCNAME)
-int PMIi_ReadCommandExp( int fd, PMI_Command *cmd, const char *exp, int* rc, const char **errmsg )
+int PMIi_ReadCommandExp( int fd, PMI2_Command *cmd, const char *exp, int* rc, const char **errmsg )
 {
-    int mpi_errno = MPI_SUCCESS;
+    int pmi2_errno = PMI2_SUCCESS;
     int found;
     int msglen;
     
-    mpi_errno = PMIi_ReadCommand(fd, cmd);
-    if (mpi_errno) MPIU_ERR_POP(mpi_errno);
+    pmi2_errno = PMIi_ReadCommand(fd, cmd);
+    if (pmi2_errno) PMI2U_ERR_POP(pmi2_errno);
 
-    MPIU_ERR_CHKANDJUMP(strncmp(cmd->command, exp, strlen(exp)) != 0,  mpi_errno, MPI_ERR_OTHER, "**bad_cmd");
+    PMI2U_ERR_CHKANDJUMP(strncmp(cmd->command, exp, strlen(exp)) != 0,  pmi2_errno, PMI2_ERR_OTHER, "**bad_cmd");
 
     found = getvalint(cmd->pairs, cmd->nPairs, RC_KEY, rc);
-    MPIU_ERR_CHKANDJUMP(found != 1, mpi_errno, MPI_ERR_OTHER, "**intern");
+    PMI2U_ERR_CHKANDJUMP(found != 1, pmi2_errno, PMI2_ERR_OTHER, "**intern");
 
     found = getval(cmd->pairs, cmd->nPairs, ERRMSG_KEY, errmsg, &msglen);
-    MPIU_ERR_CHKANDJUMP(found == -1, mpi_errno, MPI_ERR_OTHER, "**intern");
+    PMI2U_ERR_CHKANDJUMP(found == -1, pmi2_errno, PMI2_ERR_OTHER, "**intern");
 
     if (!found)
         *errmsg = NULL;
 
     
 fn_exit:
-    return mpi_errno;
+    return pmi2_errno;
 fn_fail:
 
     goto fn_exit;
 }
 
 
-#undef FUNCNAME
-#define FUNCNAME PMIi_WriteSimpleCommand
-#undef FCNAME
-#define FCNAME MPIDI_QUOTE(FUNCNAME)
-int PMIi_WriteSimpleCommand( int fd, PMI_Command *resp, const char cmd[], PMI_Keyvalpair *pairs[], int npairs)
+int PMIi_WriteSimpleCommand( int fd, PMI2_Command *resp, const char cmd[], PMI2_Keyvalpair *pairs[], int npairs)
 {
-    int mpi_errno = MPI_SUCCESS;
+    int pmi2_errno = PMI2_SUCCESS;
     char cmdbuf[PMII_MAX_COMMAND_LEN];
     char cmdlenbuf[PMII_COMMANDLEN_SIZE+1];
     char *c = cmdbuf;
@@ -1514,18 +1407,18 @@
     memset(c, ' ', PMII_COMMANDLEN_SIZE);
     c += PMII_COMMANDLEN_SIZE;
 
-    MPIU_ERR_CHKANDJUMP(strlen(cmd) > PMI_MAX_VALLEN, mpi_errno, MPI_ERR_OTHER, "**cmd_too_long");
+    PMI2U_ERR_CHKANDJUMP(strlen(cmd) > PMI2_MAX_VALLEN, pmi2_errno, PMI2_ERR_OTHER, "**cmd_too_long");
 
-    ret = MPIU_Snprintf(c, remaining_len, "cmd=%s;", cmd);
-    MPIU_ERR_CHKANDJUMP1(ret >= remaining_len, mpi_errno, MPI_ERR_OTHER, "**intern", "**intern %s", "Ran out of room for command");
+    ret = PMI2U_Snprintf(c, remaining_len, "cmd=%s;", cmd);
+    PMI2U_ERR_CHKANDJUMP1(ret >= remaining_len, pmi2_errno, PMI2_ERR_OTHER, "**intern", "**intern %s", "Ran out of room for command");
     c += ret;
     remaining_len -= ret;
 
 #ifdef MPICH_IS_THREADED
     MPIU_THREAD_CHECK_BEGIN;
     if (resp) {
-        ret = MPIU_Snprintf(c, remaining_len, "thrid=%p;", resp);
-        MPIU_ERR_CHKANDJUMP1(ret >= remaining_len, mpi_errno, MPI_ERR_OTHER, "**intern", "**intern %s", "Ran out of room for command");
+        ret = PMI2U_Snprintf(c, remaining_len, "thrid=%p;", resp);
+        PMI2U_ERR_CHKANDJUMP1(ret >= remaining_len, pmi2_errno, PMI2_ERR_OTHER, "**intern", "**intern %s", "Ran out of room for command");
         c += ret;
         remaining_len -= ret;
     }
@@ -1534,14 +1427,14 @@
     
     for (pair_index = 0; pair_index < npairs; ++pair_index) {
         /* write key= */
-        MPIU_ERR_CHKANDJUMP(strlen(pairs[pair_index]->key) > PMI_MAX_KEYLEN, mpi_errno, MPI_ERR_OTHER, "**key_too_long");
-        ret = MPIU_Snprintf(c, remaining_len, "%s=", pairs[pair_index]->key);
-        MPIU_ERR_CHKANDJUMP1(ret >= remaining_len, mpi_errno, MPI_ERR_OTHER, "**intern", "**intern %s", "Ran out of room for command");
+        PMI2U_ERR_CHKANDJUMP(strlen(pairs[pair_index]->key) > PMI2_MAX_KEYLEN, pmi2_errno, PMI2_ERR_OTHER, "**key_too_long");
+        ret = PMI2U_Snprintf(c, remaining_len, "%s=", pairs[pair_index]->key);
+        PMI2U_ERR_CHKANDJUMP1(ret >= remaining_len, pmi2_errno, PMI2_ERR_OTHER, "**intern", "**intern %s", "Ran out of room for command");
         c += ret;
         remaining_len -= ret;
 
         /* write value and escape ;'s as ;; */
-        MPIU_ERR_CHKANDJUMP(pairs[pair_index]->valueLen > PMI_MAX_VALLEN, mpi_errno, MPI_ERR_OTHER, "**val_too_long");
+        PMI2U_ERR_CHKANDJUMP(pairs[pair_index]->valueLen > PMI2_MAX_VALLEN, pmi2_errno, PMI2_ERR_OTHER, "**val_too_long");
         for (i = 0; i < pairs[pair_index]->valueLen; ++i) {
             if (pairs[pair_index]->value[i] == ';') {
                 *c = ';';
@@ -1551,7 +1444,7 @@
             *c = pairs[pair_index]->value[i];
             ++c;
             --remaining_len;
-        }        
+        }
 
         /* append ; */
         *c = ';';
@@ -1561,10 +1454,10 @@
 
     /* prepend the buffer length stripping off the trailing '\0' */
     cmdlen = PMII_MAX_COMMAND_LEN - remaining_len;
-    ret = MPIU_Snprintf(cmdlenbuf, sizeof(cmdlenbuf), "%d", cmdlen);
-    MPIU_ERR_CHKANDJUMP1(ret >= PMII_COMMANDLEN_SIZE, mpi_errno, MPI_ERR_OTHER, "**intern", "**intern %s", "Command length won't fit in length buffer");
+    ret = PMI2U_Snprintf(cmdlenbuf, sizeof(cmdlenbuf), "%d", cmdlen);
+    PMI2U_ERR_CHKANDJUMP1(ret >= PMII_COMMANDLEN_SIZE, pmi2_errno, PMI2_ERR_OTHER, "**intern", "**intern %s", "Command length won't fit in length buffer");
 
-    MPIU_Memcpy(cmdbuf, cmdlenbuf, ret);
+    PMI2U_Memcpy(cmdbuf, cmdlenbuf, ret);
 
     printf_d("PMI sending: %s\n", cmdbuf);
     
@@ -1583,7 +1476,7 @@
     MPIU_THREAD_CHECK_END;
 #endif
 
-    if (PMI_debug)
+    if (PMI2_debug)
         ENQUEUE(resp);
 
     offset = 0;
@@ -1592,7 +1485,7 @@
             nbytes = write(fd, &cmdbuf[offset], cmdlen + PMII_COMMANDLEN_SIZE - offset);
         } while (nbytes == -1 && errno == EINTR);
 
-        MPIU_ERR_CHKANDJUMP1(nbytes <= 0, mpi_errno, MPI_ERR_OTHER, "**write", "**write %s", strerror(errno));
+        PMI2U_ERR_CHKANDJUMP1(nbytes <= 0, pmi2_errno, PMI2_ERR_OTHER, "**write", "**write %s", strerror(errno));
 
         offset += nbytes;
     } while (offset < cmdlen + PMII_COMMANDLEN_SIZE);
@@ -1608,27 +1501,22 @@
 #endif
     
 fn_exit:
-    return mpi_errno;
+    return pmi2_errno;
 fn_fail:
     goto fn_exit;
 }
 
-#undef FUNCNAME
-#define FUNCNAME PMIi_WriteSimpleCommandStr
-#undef FCNAME
-#define FCNAME MPIDI_QUOTE(FUNCNAME)
-int PMIi_WriteSimpleCommandStr(int fd, PMI_Command *resp, const char cmd[], ...)
+int PMIi_WriteSimpleCommandStr(int fd, PMI2_Command *resp, const char cmd[], ...)
 {
-    int mpi_errno = MPI_SUCCESS;
+    int pmi2_errno = PMI2_SUCCESS;
     va_list ap;
-    PMI_Keyvalpair *pairs;
-    PMI_Keyvalpair **pairs_p;
+    PMI2_Keyvalpair *pairs;
+    PMI2_Keyvalpair **pairs_p;
     int npairs;
     int i;
     const char *key;
     const char *val;
-    int vallen;
-    MPIU_CHKLMEM_DECL(2);
+    PMI2U_CHKLMEM_DECL(2);
 
     npairs = 0;
     va_start(ap, cmd);
@@ -1639,8 +1527,8 @@
     }
     va_end(ap);
 
-    MPIU_CHKLMEM_MALLOC(pairs, PMI_Keyvalpair *, sizeof(PMI_Keyvalpair) * npairs, mpi_errno, "pairs");
-    MPIU_CHKLMEM_MALLOC(pairs_p, PMI_Keyvalpair **, sizeof(PMI_Keyvalpair *) * npairs, mpi_errno, "pairs_p");
+    PMI2U_CHKLMEM_MALLOC(pairs, PMI2_Keyvalpair *, sizeof(PMI2_Keyvalpair) * npairs, pmi2_errno, "pairs");
+    PMI2U_CHKLMEM_MALLOC(pairs_p, PMI2_Keyvalpair **, sizeof(PMI2_Keyvalpair *) * npairs, pmi2_errno, "pairs_p");
 
     i = 0;
     va_start(ap, cmd);
@@ -1655,12 +1543,12 @@
     }
     va_end(ap);
 
-    mpi_errno = PMIi_WriteSimpleCommand(fd, resp, cmd, pairs_p, npairs);
-    if (mpi_errno) MPIU_ERR_POP(mpi_errno);
+    pmi2_errno = PMIi_WriteSimpleCommand(fd, resp, cmd, pairs_p, npairs);
+    if (pmi2_errno) PMI2U_ERR_POP(pmi2_errno);
     
 fn_exit:
-    MPIU_CHKLMEM_FREEALL();
-    return mpi_errno;
+    PMI2U_CHKLMEM_FREEALL();
+    return pmi2_errno;
 fn_fail:
     goto fn_exit;
 }
@@ -1695,12 +1583,8 @@
 #define TCP 0
 #endif
 
-/* stub for connecting to a specified host/port instead of using a 
+/* stub for connecting to a specified host/port instead of using a
    specified fd inherited from a parent process */
-#undef FUNCNAME
-#define FUNCNAME PMII_Connect_to_pm
-#undef FCNAME
-#define FCNAME MPIDI_QUOTE(FUNCNAME)
 static int PMII_Connect_to_pm( char *hostname, int portnum )
 {
     struct hostent     *hp;
@@ -1711,27 +1595,27 @@
     
     hp = gethostbyname( hostname );
     if (!hp) {
-	PMIU_printf( 1, "Unable to get host entry for %s\n", hostname );
+	PMI2U_printf( 1, "Unable to get host entry for %s\n", hostname );
 	return -1;
     }
     
     memset( (void *)&sa, 0, sizeof(sa) );
     /* POSIX might define h_addr_list only and node define h_addr */
 #ifdef HAVE_H_ADDR_LIST
-    MPIU_Memcpy( (void *)&sa.sin_addr, (void *)hp->h_addr_list[0], hp->h_length);
+    PMI2U_Memcpy( (void *)&sa.sin_addr, (void *)hp->h_addr_list[0], hp->h_length);
 #else
-    MPIU_Memcpy( (void *)&sa.sin_addr, (void *)hp->h_addr, hp->h_length);
+    PMI2U_Memcpy( (void *)&sa.sin_addr, (void *)hp->h_addr, hp->h_length);
 #endif
     sa.sin_family = hp->h_addrtype;
     sa.sin_port   = htons( (unsigned short) portnum );
     
     fd = socket( AF_INET, SOCK_STREAM, TCP );
     if (fd < 0) {
-	PMIU_printf( 1, "Unable to get AF_INET socket\n" );
+	PMI2U_printf( 1, "Unable to get AF_INET socket\n" );
 	return -1;
     }
     
-    if (setsockopt( fd, IPPROTO_TCP, TCP_NODELAY, 
+    if (setsockopt( fd, IPPROTO_TCP, TCP_NODELAY,
 		    (char *)&optval, sizeof(optval) )) {
 	perror( "Error calling setsockopt:" );
     }
@@ -1740,7 +1624,7 @@
     if (connect( fd, (struct sockaddr *)&sa, sizeof(sa) ) < 0) {
 	switch (errno) {
 	case ECONNREFUSED:
-	    PMIU_printf( 1, "connect failed with connection refused\n" );
+	    PMI2U_printf( 1, "connect failed with connection refused\n" );
 	    /* (close socket, get new socket, try again) */
 	    if (q_wait)
 		close(fd);
@@ -1753,11 +1637,11 @@
 	    break;
 	    
 	case ETIMEDOUT: /* timed out */
-	    PMIU_printf( 1, "connect failed with timeout\n" );
+	    PMI2U_printf( 1, "connect failed with timeout\n" );
 	    return -1;
 
 	default:
-	    PMIU_printf( 1, "connect failed with errno %d\n", errno );
+	    PMI2U_printf( 1, "connect failed with errno %d\n", errno );
 	    return -1;
 	}
     }
@@ -1766,108 +1650,104 @@
 }
 
 #if 0
-#undef FUNCNAME
-#define FUNCNAME PMII_Set_from_port
-#undef FCNAME
-#define FCNAME MPIDI_QUOTE(FUNCNAME)
 static int PMII_Set_from_port( int fd, int id )
 {
-    char buf[PMIU_MAXLINE], cmd[PMIU_MAXLINE];
+    char buf[PMI2U_MAXLINE], cmd[PMI2U_MAXLINE];
     int err, rc;
 
     /* We start by sending a startup message to the server */
 
-    if (PMI_debug) {
-	PMIU_printf( 1, "Writing initack to destination fd %d\n", fd );
+    if (PMI2_debug) {
+	PMI2U_printf( 1, "Writing initack to destination fd %d\n", fd );
     }
     /* Handshake and initialize from a port */
 
-    rc = MPIU_Snprintf( buf, PMIU_MAXLINE, "cmd=initack pmiid=%d\n", id );
+    rc = PMI2U_Snprintf( buf, PMI2U_MAXLINE, "cmd=initack pmiid=%d\n", id );
     if (rc < 0) {
-	return PMI_FAIL;
+	return PMI2_FAIL;
     }
-    PMIU_printf( PMI_debug, "writing on fd %d line :%s:\n", fd, buf );
-    err = PMIU_writeline( fd, buf );
+    PMI2U_printf( PMI2_debug, "writing on fd %d line :%s:\n", fd, buf );
+    err = PMI2U_writeline( fd, buf );
     if (err) {
-	PMIU_printf( 1, "Error in writeline initack\n" );
+	PMI2U_printf( 1, "Error in writeline initack\n" );
 	return -1;
     }
 
     /* cmd=initack */
     buf[0] = 0;
-    PMIU_printf( PMI_debug, "reading initack\n" );
-    err = PMIU_readline( fd, buf, PMIU_MAXLINE );
+    PMI2U_printf( PMI2_debug, "reading initack\n" );
+    err = PMI2U_readline( fd, buf, PMI2U_MAXLINE );
     if (err < 0) {
-	PMIU_printf( 1, "Error reading initack on %d\n", fd );
+	PMI2U_printf( 1, "Error reading initack on %d\n", fd );
 	perror( "Error on readline:" );
 	return -1;
     }
-    PMIU_parse_keyvals( buf );
-    PMIU_getval( "cmd", cmd, PMIU_MAXLINE );
+    PMI2U_parse_keyvals( buf );
+    PMI2U_getval( "cmd", cmd, PMI2U_MAXLINE );
     if ( strcmp( cmd, "initack" ) ) {
-	PMIU_printf( 1, "got unexpected input %s\n", buf );
+	PMI2U_printf( 1, "got unexpected input %s\n", buf );
 	return -1;
     }
     
-    /* Read, in order, size, rank, and debug.  Eventually, we'll want 
+    /* Read, in order, size, rank, and debug.  Eventually, we'll want
        the handshake to include a version number */
 
     /* size */
-    PMIU_printf( PMI_debug, "reading size\n" );
-    err = PMIU_readline( fd, buf, PMIU_MAXLINE );
+    PMI2U_printf( PMI2_debug, "reading size\n" );
+    err = PMI2U_readline( fd, buf, PMI2U_MAXLINE );
     if (err < 0) {
-	PMIU_printf( 1, "Error reading size on %d\n", fd );
+	PMI2U_printf( 1, "Error reading size on %d\n", fd );
 	perror( "Error on readline:" );
 	return -1;
     }
-    PMIU_parse_keyvals( buf );
-    PMIU_getval( "cmd", cmd, PMIU_MAXLINE );
+    PMI2U_parse_keyvals( buf );
+    PMI2U_getval( "cmd", cmd, PMI2U_MAXLINE );
     if ( strcmp(cmd,"set")) {
-	PMIU_printf( 1, "got unexpected command %s in %s\n", cmd, buf );
+	PMI2U_printf( 1, "got unexpected command %s in %s\n", cmd, buf );
 	return -1;
     }
     /* cmd=set size=n */
-    PMIU_getval( "size", cmd, PMIU_MAXLINE );
-    PMI_size = atoi(cmd);
+    PMI2U_getval( "size", cmd, PMI2U_MAXLINE );
+    PMI2_size = atoi(cmd);
 
     /* rank */
-    PMIU_printf( PMI_debug, "reading rank\n" );
-    err = PMIU_readline( fd, buf, PMIU_MAXLINE );
+    PMI2U_printf( PMI2_debug, "reading rank\n" );
+    err = PMI2U_readline( fd, buf, PMI2U_MAXLINE );
     if (err < 0) {
-	PMIU_printf( 1, "Error reading rank on %d\n", fd );
+	PMI2U_printf( 1, "Error reading rank on %d\n", fd );
 	perror( "Error on readline:" );
 	return -1;
     }
-    PMIU_parse_keyvals( buf );
-    PMIU_getval( "cmd", cmd, PMIU_MAXLINE );
+    PMI2U_parse_keyvals( buf );
+    PMI2U_getval( "cmd", cmd, PMI2U_MAXLINE );
     if ( strcmp(cmd,"set")) {
-	PMIU_printf( 1, "got unexpected command %s in %s\n", cmd, buf );
+	PMI2U_printf( 1, "got unexpected command %s in %s\n", cmd, buf );
 	return -1;
     }
     /* cmd=set rank=n */
-    PMIU_getval( "rank", cmd, PMIU_MAXLINE );
-    PMI_rank = atoi(cmd);
-    PMIU_Set_rank( PMI_rank );
+    PMI2U_getval( "rank", cmd, PMI2U_MAXLINE );
+    PMI2_rank = atoi(cmd);
+    PMI2U_Set_rank( PMI2_rank );
 
     /* debug flag */
-    err = PMIU_readline( fd, buf, PMIU_MAXLINE );
+    err = PMI2U_readline( fd, buf, PMI2U_MAXLINE );
     if (err < 0) {
-	PMIU_printf( 1, "Error reading debug on %d\n", fd );
+	PMI2U_printf( 1, "Error reading debug on %d\n", fd );
 	return -1;
     }
-    PMIU_parse_keyvals( buf );
-    PMIU_getval( "cmd", cmd, PMIU_MAXLINE );
+    PMI2U_parse_keyvals( buf );
+    PMI2U_getval( "cmd", cmd, PMI2U_MAXLINE );
     if ( strcmp(cmd,"set")) {
-	PMIU_printf( 1, "got unexpected command %s in %s\n", cmd, buf );
+	PMI2U_printf( 1, "got unexpected command %s in %s\n", cmd, buf );
 	return -1;
     }
     /* cmd=set debug=n */
-    PMIU_getval( "debug", cmd, PMIU_MAXLINE );
-    PMI_debug = atoi(cmd);
+    PMI2U_getval( "debug", cmd, PMI2U_MAXLINE );
+    PMI2_debug = atoi(cmd);
 
-    if (PMI_debug) {
-	DBG_PRINTF( ("end of handshake, rank = %d, size = %d\n", 
-		    PMI_rank, PMI_size )); 
+    if (PMI2_debug) {
+	DBG_PRINTF( ("end of handshake, rank = %d, size = %d\n",
+		    PMI2_rank, PMI2_size ));
 	DBG_PRINTF( ("Completed init\n" ) );
     }
 
@@ -1876,18 +1756,18 @@
 #endif
 
 /* ------------------------------------------------------------------------- */
-/* 
+/*
  * Singleton Init.
- * 
+ *
  * MPI-2 allows processes to become MPI processes and then make MPI calls,
- * such as MPI_Comm_spawn, that require a process manager (this is different 
- * than the much simpler case of allowing MPI programs to run with an 
+ * such as MPI_Comm_spawn, that require a process manager (this is different
+ * than the much simpler case of allowing MPI programs to run with an
  * MPI_COMM_WORLD of size 1 without an mpiexec or process manager).
  *
  * The process starts when either the client or the process manager contacts
  * the other.  If the client starts, it sends a singinit command and
  * waits for the server to respond with its own singinit command.
- * If the server start, it send a singinit command and waits for the 
+ * If the server start, it send a singinit command and waits for the
  * client to respond with its own singinit command
  *
  * client sends singinit with these required values
@@ -1914,27 +1794,23 @@
  *
  * cmd=init pmi_version=<val> pmi_subversion=<val>
  *
- * and expects to receive a 
+ * and expects to receive a
  *
- * cmd=response_to_init rc=0 pmi_version=<val> pmi_subversion=<val> 
+ * cmd=response_to_init rc=0 pmi_version=<val> pmi_subversion=<val>
  *
  * (This is the usual init sequence).
  *
  */
 /* ------------------------------------------------------------------------- */
-/* This is a special routine used to re-initialize PMI when it is in 
-   the singleton init case.  That is, the executable was started without 
-   mpiexec, and PMI_Init returned as if there was only one process.
+/* This is a special routine used to re-initialize PMI when it is in
+   the singleton init case.  That is, the executable was started without
+   mpiexec, and PMI2_Init returned as if there was only one process.
 
    Note that PMI routines should not call PMII_singinit; they should
    call PMIi_InitIfSingleton(), which both connects to the process mangager
    and sets up the initial KVS connection entry.
 */
 
-#undef FUNCNAME
-#define FUNCNAME PMII_singinit
-#undef FCNAME
-#define FCNAME MPIDI_QUOTE(FUNCNAME)
 static int PMII_singinit(void)
 {
 #if 0
@@ -1952,11 +1828,11 @@
     singinit_listen_sock = socket(AF_INET, SOCK_STREAM, 0);
     rc = bind(singinit_listen_sock, (struct sockaddr *)&sin ,sizeof(sin));
     len = sizeof(struct sockaddr_in);
-    rc = getsockname( singinit_listen_sock, (struct sockaddr *) &sin, &len ); 
-    MPIU_Snprintf(port_c, sizeof(port_c), "%d",ntohs(sin.sin_port));
+    rc = getsockname( singinit_listen_sock, (struct sockaddr *) &sin, &len );
+    PMI2U_Snprintf(port_c, sizeof(port_c), "%d",ntohs(sin.sin_port));
     rc = listen(singinit_listen_sock, 5);
 
-    PMIU_printf( PMI_debug_init, "Starting mpiexec with %s\n", port_c );
+    PMI2U_printf( PMI2_debug_init, "Starting mpiexec with %s\n", port_c );
 
     /* Launch the mpiexec process with the name of this port */
     pid = fork();
@@ -1971,75 +1847,75 @@
 	/* FIXME: Use a valid hostname */
 	newargv[3] = "default_interface";  /* default interface name, for now */
 	newargv[4] = "default_key";   /* default authentication key, for now */
-	MPIU_Snprintf(charpid, sizeof(charpid), "%d",getpid());
+	PMI2U_Snprintf(charpid, sizeof(charpid), "%d",getpid());
 	newargv[5] = charpid;
 	newargv[6] = NULL;
 	rc = execvp(newargv[0],newargv);
 	perror("PMII_singinit: execv failed");
-	PMIU_printf(1, "  This singleton init program attempted to access some feature\n");
-	PMIU_printf(1, "  for which process manager support was required, e.g. spawn or universe_size.\n");
-	PMIU_printf(1, "  But the necessary mpiexec is not in your path.\n");
+	PMI2U_printf(1, "  This singleton init program attempted to access some feature\n");
+	PMI2U_printf(1, "  for which process manager support was required, e.g. spawn or universe_size.\n");
+	PMI2U_printf(1, "  But the necessary mpiexec is not in your path.\n");
 	return(-1);
     }
     else
     {
-	char buf[PMIU_MAXLINE], cmd[PMIU_MAXLINE];
+	char buf[PMI2U_MAXLINE], cmd[PMI2U_MAXLINE];
 	char *p;
 	int connectStdio = 0;
 
 	/* Allow one connection back from the created mpiexec program */
-	PMI_fd =  accept_one_connection(singinit_listen_sock);
-	if (PMI_fd < 0) {
-	    PMIU_printf( 1, "Failed to establish singleton init connection\n" );
+	PMI2_fd =  accept_one_connection(singinit_listen_sock);
+	if (PMI2_fd < 0) {
+	    PMI2U_printf( 1, "Failed to establish singleton init connection\n" );
 	    return PMI_FAIL;
 	}
 	/* Execute the singleton init protocol */
-	rc = PMIU_readline( PMI_fd, buf, PMIU_MAXLINE );
-	PMIU_printf( PMI_debug_init, "Singinit: read %s\n", buf );
+	rc = PMI2U_readline( PMI2_fd, buf, PMI2U_MAXLINE );
+	PMI2U_printf( PMI2_debug_init, "Singinit: read %s\n", buf );
 
-	PMIU_parse_keyvals( buf );
-	PMIU_getval( "cmd", cmd, PMIU_MAXLINE );
+	PMI2U_parse_keyvals( buf );
+	PMI2U_getval( "cmd", cmd, PMI2U_MAXLINE );
 	if (strcmp( cmd, "singinit" ) != 0) {
-	    PMIU_printf( 1, "unexpected command from PM: %s\n", cmd );
+	    PMI2U_printf( 1, "unexpected command from PM: %s\n", cmd );
 	    return PMI_FAIL;
 	}
-	p = PMIU_getval( "authtype", cmd, PMIU_MAXLINE );
+	p = PMI2U_getval( "authtype", cmd, PMI2U_MAXLINE );
 	if (p && strcmp( cmd, "none" ) != 0) {
-	    PMIU_printf( 1, "unsupported authentication method %s\n", cmd );
+	    PMI2U_printf( 1, "unsupported authentication method %s\n", cmd );
 	    return PMI_FAIL;
 	}
-	/* p = PMIU_getval( "authstring", cmd, PMIU_MAXLINE ); */
+	/* p = PMI2U_getval( "authstring", cmd, PMI2U_MAXLINE ); */
 	
 	/* If we're successful, send back our own singinit */
-	rc = MPIU_Snprintf( buf, PMIU_MAXLINE, 
+	rc = PMI2U_Snprintf( buf, PMI2U_MAXLINE,
      "cmd=singinit pmi_version=%d pmi_subversion=%d stdio=yes authtype=none\n",
 			PMI_VERSION, PMI_SUBVERSION );
 	if (rc < 0) {
 	    return PMI_FAIL;
 	}
-	PMIU_printf( PMI_debug_init, "GetResponse with %s\n", buf );
+	PMI2U_printf( PMI2_debug_init, "GetResponse with %s\n", buf );
 
 	rc = GetResponse( buf, "singinit_info", 0 );
 	if (rc != 0) {
-	    PMIU_printf( 1, "GetResponse failed\n" );
+	    PMI2U_printf( 1, "GetResponse failed\n" );
 	    return PMI_FAIL;
 	}
-	p = PMIU_getval( "versionok", cmd, PMIU_MAXLINE );
+	p = PMI2U_getval( "versionok", cmd, PMI2U_MAXLINE );
 	if (p && strcmp( cmd, "yes" ) != 0) {
-	    PMIU_printf( 1, "Process manager needs a different PMI version\n" );
+	    PMI2U_printf( 1, "Process manager needs a different PMI version\n" );
 	    return PMI_FAIL;
 	}
-	p = PMIU_getval( "stdio", cmd, PMIU_MAXLINE );
+	p = PMI2U_getval( "stdio", cmd, PMI2U_MAXLINE );
 	if (p && strcmp( cmd, "yes" ) == 0) {
-	    PMIU_printf( PMI_debug_init, "PM agreed to connect stdio\n" );
+	    PMI2U_printf( PMI2_debug_init, "PM agreed to connect stdio\n" );
 	    connectStdio = 1;
 	}
-	p = PMIU_getval( "kvsname", singinit_kvsname, sizeof(singinit_kvsname) );
-	PMIU_printf( PMI_debug_init, "kvsname to use is %s\n", 
+	p = PMI2U_getval( "kvsname", singinit_kvsname, sizeof(singinit_kvsname) );
+	PMI2U_printf( PMI2_debug_init, "kvsname to use is %s\n",
 		     singinit_kvsname );
 	
 	if (connectStdio) {
-	    PMIU_printf( PMI_debug_init, 
+	    PMI2U_printf( PMI2_debug_init,
 			 "Accepting three connections for stdin, out, err\n" );
 	    stdin_sock  = accept_one_connection(singinit_listen_sock);
 	    dup2(stdin_sock, 0);
@@ -2048,55 +1924,47 @@
 	    stderr_sock = accept_one_connection(singinit_listen_sock);
 	    dup2(stderr_sock,2);
 	}
-	PMIU_printf( PMI_debug_init, "Done with singinit handshake\n" );
+	PMI2U_printf( PMI2_debug_init, "Done with singinit handshake\n" );
     }
-    return 0;
 #endif
+    return 0;
 }
 
 /* Promote PMI to a fully initialized version if it was started as
    a singleton init */
-#undef FUNCNAME
-#define FUNCNAME PMII_InitIfSingleton
-#undef FCNAME
-#define FCNAME MPIDI_QUOTE(FUNCNAME)
 static int PMIi_InitIfSingleton(void)
 {
 #if 0
     int rc;
     static int firstcall = 1;
 
-    if (PMI_initialized != SINGLETON_INIT_BUT_NO_PM || !firstcall) return 0;
+    if (PMI2_initialized != SINGLETON_INIT_BUT_NO_PM || !firstcall) return 0;
 
     /* We only try to init as a singleton the first time */
     firstcall = 0;
 
-    /* First, start (if necessary) an mpiexec, connect to it, 
+    /* First, start (if necessary) an mpiexec, connect to it,
        and start the singleton init handshake */
     rc = PMII_singinit();
 
     if (rc < 0)
 	return(-1);
-    PMI_initialized = SINGLETON_INIT_WITH_PM;    /* do this right away */
-    PMI_size	    = 1;
-    PMI_rank	    = 0;
-    PMI_debug	    = 0;
-    PMI_spawned	    = 0;
+    PMI2_initialized = SINGLETON_INIT_WITH_PM;    /* do this right away */
+    PMI2_size	    = 1;
+    PMI2_rank	    = 0;
+    PMI2_debug	    = 0;
+    PMI2_spawned	    = 0;
 
-    PMII_getmaxes( &PMI_kvsname_max, &PMI_keylen_max, &PMI_vallen_max );
+    PMII_getmaxes( &PMI2_kvsname_max, &PMI2_keylen_max, &PMI2_vallen_max );
 
-    /* FIXME: We need to support a distinct kvsname for each 
+    /* FIXME: We need to support a distinct kvsname for each
        process group */
-    PMI_KVS_Put( singinit_kvsname, cached_singinit_key, cached_singinit_val );
+    PMI2_KVS_Put( singinit_kvsname, cached_singinit_key, cached_singinit_val );
 
 #endif
     return 0;
 }
 
-#undef FUNCNAME
-#define FUNCNAME accept_one_connection
-#undef FCNAME
-#define FCNAME MPIDI_QUOTE(FUNCNAME)
 static int accept_one_connection(int list_sock)
 {
     int gotit, new_sock;
@@ -2114,7 +1982,7 @@
 		continue;
 	    else
 	    {
-		PMIU_printf(1, "accept failed in accept_one_connection\n");
+		PMI2U_printf(1, "accept failed in accept_one_connection\n");
 		exit(-1);
 	    }
 	}
@@ -2125,21 +1993,17 @@
 }
 
 
-/* Get the FD to use for PMI operations.  If a port is used, rather than 
-   a pre-established FD (i.e., via pipe), this routine will handle the 
-   initial handshake.  
+/* Get the FD to use for PMI operations.  If a port is used, rather than
+   a pre-established FD (i.e., via pipe), this routine will handle the
+   initial handshake.
 */
-#undef FUNCNAME
-#define FUNCNAME getPMIFD
-#undef FCNAME
-#define FCNAME MPIDI_QUOTE(FUNCNAME)
 static int getPMIFD(void)
 {
-    int mpi_errno = MPI_SUCCESS;
+    int pmi2_errno = PMI2_SUCCESS;
     char *p;
 
     /* Set the default */
-    PMI_fd = -1;    
+    PMI2_fd = -1;
 
     p = getenv( "PMI_PORT" );
     if (p) {
@@ -2147,7 +2011,7 @@
 	char hostname[MAXHOSTNAME+1];
 	char *pn, *ph;
 
-	/* Connect to the indicated port (in format hostname:portnumber) 
+	/* Connect to the indicated port (in format hostname:portnumber)
 	   and get the fd for the socket */
 	
 	/* Split p into host and port */
@@ -2158,81 +2022,78 @@
 	}
 	*ph = 0;
 
-        MPIU_ERR_CHKANDJUMP1(*pn != ':', mpi_errno, MPI_ERR_OTHER, "**pmi_port", "**pmi_port %s", p);
+        PMI2U_ERR_CHKANDJUMP1(*pn != ':', pmi2_errno, PMI2_ERR_OTHER, "**pmi2_port", "**pmi2_port %s", p);
         
         portnum = atoi( pn+1 );
         /* FIXME: Check for valid integer after : */
-        /* This routine only gets the fd to use to talk to 
+        /* This routine only gets the fd to use to talk to
            the process manager. The handshake below is used
            to setup the initial values */
-        PMI_fd = PMII_Connect_to_pm( hostname, portnum );
-        MPIU_ERR_CHKANDJUMP2(PMI_fd < 0, mpi_errno, MPI_ERR_OTHER, "**connect_to_pm", "**connect_to_pm %s %d", hostname, portnum);
+        PMI2_fd = PMII_Connect_to_pm( hostname, portnum );
+        PMI2U_ERR_CHKANDJUMP2(PMI2_fd < 0, pmi2_errno, PMI2_ERR_OTHER, "**connect_to_pm", "**connect_to_pm %s %d", hostname, portnum);
     }
 
     /* OK to return success for singleton init */
 
  fn_exit:
-    return mpi_errno;
+    return pmi2_errno;
  fn_fail:
     goto fn_exit;
 }
 
 /* ----------------------------------------------------------------------- */
-/* 
+/*
  * This function is used to request information from the server and check
  * that the response uses the expected command name.  On a successful
- * return from this routine, additional PMIU_getval calls may be used
+ * return from this routine, additional PMI2U_getval calls may be used
  * to access information about the returned value.
  *
  * If checkRc is true, this routine also checks that the rc value returned
  * was 0.  If not, it uses the "msg" value to report on the reason for
  * the failure.
  */
-#undef FUNCNAME
-#define FUNCNAME GetResponse
-#undef FCNAME
-#define FCNAME MPIDI_QUOTE(FUNCNAME)
 static int GetResponse( const char request[], const char expectedCmd[],
 			int checkRc )
 {
-    int err, n;
-    char *p;
-    char recvbuf[PMIU_MAXLINE];
-    char cmdName[PMIU_MAXLINE];
+    int err = 0;
 #if 0
+    int n;
+    char *p;
+    char recvbuf[PMI2U_MAXLINE];
+    char cmdName[PMI2U_MAXLINE];
 
     /* FIXME: This is an example of an incorrect fix - writeline can change
        the second argument in some cases, and that will break the const'ness
        of request.  Instead, writeline should take a const item and return
        an error in the case in which it currently truncates the data. */
-    err = PMIU_writeline( PMI_fd, (char *)request );
+    err = PMI2U_writeline( PMI2_fd, (char *)request );
     if (err) {
 	return err;
     }
-    n = PMIU_readline( PMI_fd, recvbuf, sizeof(recvbuf) );
+    n = PMI2U_readline( PMI2_fd, recvbuf, sizeof(recvbuf) );
     if (n <= 0) {
-	PMIU_printf( 1, "readline failed\n" );
+	PMI2U_printf( 1, "readline failed\n" );
 	return PMI_FAIL;
     }
-    err = PMIU_parse_keyvals( recvbuf );
+    err = PMI2U_parse_keyvals( recvbuf );
     if (err) {
-	PMIU_printf( 1, "parse_kevals failed %d\n", err );
+	PMI2U_printf( 1, "parse_kevals failed %d\n", err );
 	return err;
     }
-    p = PMIU_getval( "cmd", cmdName, sizeof(cmdName) );
+    p = PMI2U_getval( "cmd", cmdName, sizeof(cmdName) );
     if (!p) {
-	PMIU_printf( 1, "getval cmd failed\n" );
+	PMI2U_printf( 1, "getval cmd failed\n" );
 	return PMI_FAIL;
     }
     if (strcmp( expectedCmd, cmdName ) != 0) {
-	PMIU_printf( 1, "expecting cmd=%s, got %s\n", expectedCmd, cmdName );
+	PMI2U_printf( 1, "expecting cmd=%s, got %s\n", expectedCmd, cmdName );
 	return PMI_FAIL;
     }
     if (checkRc) {
-	p = PMIU_getval( "rc", cmdName, PMIU_MAXLINE );
+	p = PMI2U_getval( "rc", cmdName, PMI2U_MAXLINE );
 	if ( p && strcmp(cmdName,"0") != 0 ) {
-	    PMIU_getval( "msg", cmdName, PMIU_MAXLINE );
-	    PMIU_printf( 1, "Command %s failed, reason='%s'\n", 
+	    PMI2U_getval( "msg", cmdName, PMI2U_MAXLINE );
+	    PMI2U_printf( 1, "Command %s failed, reason='%s'\n",
 			 request, cmdName );
 	    return PMI_FAIL;
 	}
@@ -2243,7 +2104,7 @@
 }
 
 
-static void dump_PMI_Keyvalpair(FILE *file, PMI_Keyvalpair *kv)
+static void dump_PMI2_Keyvalpair(FILE *file, PMI2_Keyvalpair *kv)
 {
     fprintf(file, "  key      = %s\n", kv->key);
     fprintf(file, "  value    = %s\n", kv->value);
@@ -2251,7 +2112,7 @@
     fprintf(file, "  isCopy   = %s\n", kv->isCopy ? "TRUE" : "FALSE");
 }
 
-static void dump_PMI_Command(FILE *file, PMI_Command *cmd)
+static void dump_PMI2_Command(FILE *file, PMI2_Command *cmd)
 {
     int i;
     
@@ -2259,5 +2120,5 @@
     fprintf(file, "nPairs = %d\n", cmd->nPairs);
 
     for (i = 0; i < cmd->nPairs; ++i)
-        dump_PMI_Keyvalpair(file, cmd->pairs[i]);
+        dump_PMI2_Keyvalpair(file, cmd->pairs[i]);
 }

Modified: mpich2/trunk/src/pmi/pmi2/simple2pmi.h
===================================================================
--- mpich2/trunk/src/pmi/pmi2/simple2pmi.h	2009-10-19 19:24:19 UTC (rev 5486)
+++ mpich2/trunk/src/pmi/pmi2/simple2pmi.h	2009-10-19 22:33:48 UTC (rev 5487)
@@ -80,23 +80,23 @@
 
 /* Parse commands are in this structure.  Fields in this structure are 
    dynamically allocated as necessary */
-typedef struct PMI_Keyvalpair {
+typedef struct PMI2_Keyvalpair {
     const char *key;
     const char *value;
-    int   valueLen;  /* Length of a value (values may contain nulls, so
-			we need this) */
-    int   isCopy;    /* The value is a copy (and will need to be freed) 
-			if this is true, otherwise, 
-			it is a null-terminated string in the original
-			buffer */
-} PMI_Keyvalpair;
+    int         valueLen;  /* Length of a value (values may contain nulls, so
+                              we need this) */
+    int         isCopy;    /* The value is a copy (and will need to be freed) 
+                              if this is true, otherwise, 
+                              it is a null-terminated string in the original
+                              buffer */
+} PMI2_Keyvalpair;
 
-typedef struct PMI_Command {
-    int                  nPairs; /* Number of key=value pairs */
-    char                *command; /* Overall command buffer */
-    PMI_Keyvalpair     **pairs; /* Array of pointers to pairs */
-    int                  complete;
-} PMI_Command;
+typedef struct PMI2_Command {
+    int               nPairs;   /* Number of key=value pairs */
+    char             *command;  /* Overall command buffer */
+    PMI2_Keyvalpair **pairs;    /* Array of pointers to pairs */
+    int               complete;
+} PMI2_Command;
 
 /* Debug value */
 extern int MPIE_Debug;

Modified: mpich2/trunk/src/pmi/pmi2/simple_pmiutil.c
===================================================================
--- mpich2/trunk/src/pmi/pmi2/simple_pmiutil.c	2009-10-19 19:24:19 UTC (rev 5486)
+++ mpich2/trunk/src/pmi/pmi2/simple_pmiutil.c	2009-10-19 22:33:48 UTC (rev 5487)
@@ -14,6 +14,8 @@
 #include "pmi2conf.h"
 #define printf_d(x...) /* printf(x) */
 
+#include "pmi2compat.h"
+
 #include <stdio.h>
 #ifdef HAVE_STDLIB_H
 #include <stdlib.h>
@@ -28,11 +30,6 @@
 #include <errno.h>
 #include "simple_pmiutil.h"
 
-/* Use the memory definitions from mpich2/src/include */
-#include "mpimem.h"
-/* Use the MPI error message routines from mpich2/src/include */
-#include "mpibase.h"
-
 #define MAXVALLEN 1024
 #define MAXKEYLEN   32
 
@@ -40,24 +37,24 @@
    PMI specification.
    They are just part of this implementation's internal utilities.
 */
-struct PMIU_keyval_pairs {
+struct PMI2U_keyval_pairs {
     char key[MAXKEYLEN];
-    char value[MAXVALLEN];	
+    char value[MAXVALLEN];
 };
-static struct PMIU_keyval_pairs PMIU_keyval_tab[64] = { { {0}, {0} } };
-static int  PMIU_keyval_tab_idx = 0;
+static struct PMI2U_keyval_pairs PMI2U_keyval_tab[64] = { { {0}, {0} } };
+static int  PMI2U_keyval_tab_idx = 0;
 
 /* This is used to prepend printed output.  Set the initial value to 
    "unset" */
-static char PMIU_print_id[PMIU_IDSIZE] = "unset";
+static char PMI2U_print_id[PMI2U_IDSIZE] = "unset";
 
-void PMIU_Set_rank( int PMI_rank )
+void PMI2U_Set_rank( int PMI_rank )
 {
-    MPIU_Snprintf( PMIU_print_id, PMIU_IDSIZE, "cli_%d", PMI_rank );
+    PMI2U_Snprintf( PMI2U_print_id, PMI2U_IDSIZE, "cli_%d", PMI_rank );
 }
-void PMIU_SetServer( void )
+void PMI2U_SetServer( void )
 {
-    MPIU_Strncpy( PMIU_print_id, "server", PMIU_IDSIZE );
+    PMI2U_Strncpy( PMI2U_print_id, "server", PMI2U_IDSIZE );
 }
 
 /* Note that vfprintf is part of C89 */
@@ -65,7 +62,7 @@
 /* style: allow:fprintf:1 sig:0 */
 /* style: allow:vfprintf:1 sig:0 */
 /* This should be combined with the message routines */
-void PMIU_printf( int print_flag, const char *fmt, ... )
+void PMI2U_printf( int print_flag, const char *fmt, ... )
 {
     va_list ap;
     static FILE *logfile= 0;
@@ -80,7 +77,7 @@
 	    char filename[1024];
 	    p = getenv("PMI_ID");
 	    if (p) {
-		MPIU_Snprintf( filename, sizeof(filename), 
+		PMI2U_Snprintf( filename, sizeof(filename), 
 			       "testclient-%s.out", p );
 		logfile = fopen( filename, "w" );
 	    }
@@ -93,10 +90,10 @@
     }
 
     if ( print_flag ) {
-	/* MPIU_Error_printf( "[%s]: ", PMIU_print_id ); */
-	/* FIXME: Decide what role PMIU_printf should have (if any) and
-	   select the appropriate MPIU routine */
-	fprintf( logfile, "[%s]: ", PMIU_print_id );
+	/* PMI2U_Error_printf( "[%s]: ", PMI2U_print_id ); */
+	/* FIXME: Decide what role PMI2U_printf should have (if any) and
+	   select the appropriate PMI2U routine */
+	fprintf( logfile, "[%s]: ", PMI2U_print_id );
 	va_start( ap, fmt );
 	vfprintf( logfile, fmt, ap );
 	va_end( ap );
@@ -109,7 +106,7 @@
  * Return the next newline-terminated string of maximum length maxlen.
  * This is a buffered version, and reads from fd as necessary.  A
  */
-int PMIU_readline( int fd, char *buf, int maxlen )
+int PMI2U_readline( int fd, char *buf, int maxlen )
 {
     static char readbuf[MAX_READLINE];
     static char *nextChar = 0, *lastChar = 0;  /* lastChar is really one past 
@@ -123,11 +120,8 @@
        be calling this, and there should only be a single fd.  
        Server side code should not use this routine (see the 
        replacement version in src/pm/util/pmiserv.c) */
-    if (nextChar != lastChar && fd != lastfd) {
-	MPIU_Internal_error_printf( "Panic - buffer inconsistent\n" );
-	return -1;
-    }
-
+    PMI2U_Assert(nextChar == lastChar || fd == lastfd);
+    
     p      = buf;
     curlen = 1;    /* Make room for the null */
     while (curlen < maxlen) {
@@ -174,17 +168,17 @@
     return curlen-1;
 }
 
-int PMIU_writeline( int fd, char *buf )	
+int PMI2U_writeline( int fd, char *buf )	
 {
     int size, n;
 
     size = strlen( buf );
-    if ( size > PMIU_MAXLINE ) {
-	buf[PMIU_MAXLINE-1] = '\0';
-	PMIU_printf( 1, "write_line: message string too big: :%s:\n", buf );
+    if ( size > PMI2U_MAXLINE ) {
+	buf[PMI2U_MAXLINE-1] = '\0';
+	PMI2U_printf( 1, "write_line: message string too big: :%s:\n", buf );
     }
     else if ( buf[strlen( buf ) - 1] != '\n' )  /* error:  no newline at end */
-	    PMIU_printf( 1, "write_line: message string doesn't end in newline: :%s:\n",
+	    PMI2U_printf( 1, "write_line: message string doesn't end in newline: :%s:\n",
 		       buf );
     else {
         printf_d("PMI sending: %s\n", buf);
@@ -194,21 +188,21 @@
 	} while (n == -1 && errno == EINTR);
 
 	if ( n < 0 ) {
-	    PMIU_printf( 1, "write_line error; fd=%d buf=:%s:\n", fd, buf );
+	    PMI2U_printf( 1, "write_line error; fd=%d buf=:%s:\n", fd, buf );
 	    perror("system msg for write_line failure ");
 	    return(-1);
 	}
 	if ( n < size)
-	    PMIU_printf( 1, "write_line failed to write entire message\n" );
+	    PMI2U_printf( 1, "write_line failed to write entire message\n" );
     }
     return 0;
 }
 
 /*
  * Given an input string st, parse it into internal storage that can be
- * queried by routines such as PMIU_getval.
+ * queried by routines such as PMI2U_getval.
  */
-int PMIU_parse_keyvals( char *st )
+int PMI2U_parse_keyvals( char *st )
 {
     char *p, *keystart, *valstart;
     int  offset;
@@ -216,14 +210,14 @@
     if ( !st )
 	return( -1 );
 
-    PMIU_keyval_tab_idx = 0;
+    PMI2U_keyval_tab_idx = 0;
     p = st;
     while ( 1 ) {
 	while ( *p == ' ' )
 	    p++;
 	/* got non-blank */
 	if ( *p == '=' ) {
-	    PMIU_printf( 1, "PMIU_parse_keyvals:  unexpected = at character %d in %s\n",
+	    PMI2U_printf( 1, "PMI2U_parse_keyvals:  unexpected = at character %d in %s\n",
 		       p - st, st );
 	    return( -1 );
 	}
@@ -234,29 +228,29 @@
 	while ( *p != ' ' && *p != '=' && *p != '\n' && *p != '\0' )
 	    p++;
 	if ( *p == ' ' || *p == '\n' || *p == '\0' ) {
-	    PMIU_printf( 1,
-       "PMIU_parse_keyvals: unexpected key delimiter at character %d in %s\n",
+	    PMI2U_printf( 1,
+       "PMI2U_parse_keyvals: unexpected key delimiter at character %d in %s\n",
 		       p - st, st );
 	    return( -1 );
 	}
 	/* Null terminate the key */
 	*p = 0;
 	/* store key */
-        MPIU_Strncpy( PMIU_keyval_tab[PMIU_keyval_tab_idx].key, keystart, 
+        PMI2U_Strncpy( PMI2U_keyval_tab[PMI2U_keyval_tab_idx].key, keystart, 
 		      MAXKEYLEN );
 
 	valstart = ++p;			/* start of value */
 	while ( *p != ' ' && *p != '\n' && *p != '\0' )
 	    p++;
 	/* store value */
-        MPIU_Strncpy( PMIU_keyval_tab[PMIU_keyval_tab_idx].value, valstart, 
+        PMI2U_Strncpy( PMI2U_keyval_tab[PMI2U_keyval_tab_idx].value, valstart, 
 		      MAXVALLEN );
 	offset = p - valstart;
 	/* When compiled with -fPIC, the pgcc compiler generates incorrect
 	   code if "p - valstart" is used instead of using the 
 	   intermediate offset */
-	PMIU_keyval_tab[PMIU_keyval_tab_idx].value[offset] = '\0';  
-	PMIU_keyval_tab_idx++;
+	PMI2U_keyval_tab[PMI2U_keyval_tab_idx].value[offset] = '\0';  
+	PMI2U_keyval_tab_idx++;
 	if ( *p == ' ' )
 	    continue;
 	if ( *p == '\n' || *p == '\0' )
@@ -264,22 +258,22 @@
     }
 }
 
-void PMIU_dump_keyvals( void )
+void PMI2U_dump_keyvals( void )
 {
     int i;
-    for (i=0; i < PMIU_keyval_tab_idx; i++) 
-	PMIU_printf(1, "  %s=%s\n",PMIU_keyval_tab[i].key, PMIU_keyval_tab[i].value);
+    for (i=0; i < PMI2U_keyval_tab_idx; i++) 
+	PMI2U_printf(1, "  %s=%s\n",PMI2U_keyval_tab[i].key, PMI2U_keyval_tab[i].value);
 }
 
-char *PMIU_getval( const char *keystr, char *valstr, int vallen )
+char *PMI2U_getval( const char *keystr, char *valstr, int vallen )
 {
     int i, rc;
     
-    for (i = 0; i < PMIU_keyval_tab_idx; i++) {
-	if ( strcmp( keystr, PMIU_keyval_tab[i].key ) == 0 ) { 
-	    rc = MPIU_Strncpy( valstr, PMIU_keyval_tab[i].value, vallen );
+    for (i = 0; i < PMI2U_keyval_tab_idx; i++) {
+	if ( strcmp( keystr, PMI2U_keyval_tab[i].key ) == 0 ) { 
+	    rc = PMI2U_Strncpy( valstr, PMI2U_keyval_tab[i].value, vallen );
 	    if (rc != 0) {
-		PMIU_printf( 1, "MPIU_Strncpy failed in PMIU_getval\n" );
+		PMI2U_printf( 1, "PMI2U_Strncpy failed in PMI2U_getval\n" );
 		return NULL;
 	    }
 	    return valstr;
@@ -289,14 +283,14 @@
     return NULL;
 }
 
-void PMIU_chgval( const char *keystr, char *valstr )
+void PMI2U_chgval( const char *keystr, char *valstr )
 {
     int i;
     
-    for ( i = 0; i < PMIU_keyval_tab_idx; i++ ) {
-	if ( strcmp( keystr, PMIU_keyval_tab[i].key ) == 0 ) {
-	    MPIU_Strncpy( PMIU_keyval_tab[i].value, valstr, MAXVALLEN - 1 );
-	    PMIU_keyval_tab[i].value[MAXVALLEN - 1] = '\0';
+    for ( i = 0; i < PMI2U_keyval_tab_idx; i++ ) {
+	if ( strcmp( keystr, PMI2U_keyval_tab[i].key ) == 0 ) {
+	    PMI2U_Strncpy( PMI2U_keyval_tab[i].value, valstr, MAXVALLEN - 1 );
+	    PMI2U_keyval_tab[i].value[MAXVALLEN - 1] = '\0';
 	}
     }
 }

Modified: mpich2/trunk/src/pmi/pmi2/simple_pmiutil.h
===================================================================
--- mpich2/trunk/src/pmi/pmi2/simple_pmiutil.h	2009-10-19 19:24:19 UTC (rev 5486)
+++ mpich2/trunk/src/pmi/pmi2/simple_pmiutil.h	2009-10-19 22:33:48 UTC (rev 5487)
@@ -6,28 +6,247 @@
 #ifndef SIMPLE_PMI_UTIL_H_INCLUDED
 #define SIMPLE_PMI_UTIL_H_INCLUDED
 
+#include "pmi2conf.h"
+
 /* maximum sizes for arrays */
-#define PMIU_MAXLINE 1024
-#define PMIU_IDSIZE    32
+#define PMI2U_MAXLINE 1024
+#define PMI2U_IDSIZE    32
 
-/* we don't have access to MPIU_Assert and friends here in the PMI code */
-#if defined(HAVE_ASSERT_H)
-#  include <assert.h>
-#  define PMIU_Assert(expr) assert(expr)
+/* prototypes for PMIU routines */
+void PMI2U_Set_rank( int PMI_rank );
+void PMI2U_SetServer( void );
+void PMI2U_printf( int print_flag, const char *fmt, ... );
+int  PMI2U_readline( int fd, char *buf, int max );
+int  PMI2U_writeline( int fd, char *buf );
+int  PMI2U_parse_keyvals( char *st );
+void PMI2U_dump_keyvals( void );
+char *PMI2U_getval( const char *keystr, char *valstr, int vallen );
+void PMI2U_chgval( const char *keystr, char *valstr );
+
+#ifdef HAVE__FUNCTION__
+#define PMI2U_FUNC __FUNCTION__
+#elif defined(HAVE_CAP__FUNC__)
+#define PMI2U_FUNC __FUNC__
+#elif defined(HAVE__FUNC__)
+#define PMI2U_FUNC __func__
 #else
-#  define PMIU_Assert(expr)
+#define PMI2U_FUNC __FILE__
 #endif
 
+/* error reporting macros */
 
-/* prototypes for PMIU routines */
-void PMIU_Set_rank( int PMI_rank );
-void PMIU_SetServer( void );
-void PMIU_printf( int print_flag, const char *fmt, ... );
-int  PMIU_readline( int fd, char *buf, int max );
-int  PMIU_writeline( int fd, char *buf );
-int  PMIU_parse_keyvals( char *st );
-void PMIU_dump_keyvals( void );
-char *PMIU_getval( const char *keystr, char *valstr, int vallen );
-void PMIU_chgval( const char *keystr, char *valstr );
+#define PMI2U_ERR_POP(err) do { pmi2_errno = err; fprintf(stderr, "ERROR: %s (%d)\n", PMI2U_FUNC, __LINE__); goto fn_fail; } while (0)
+#define PMI2U_ERR_SETANDJUMP(err, class, str) do {                              \
+        fprintf(stderr, "ERROR: "str" in %s (%d)\n", PMI2U_FUNC, __LINE__);     \
+        pmi2_errno = class;                                                      \
+        goto fn_fail;                                                           \
+    } while (0)
+#define PMI2U_ERR_SETANDJUMP1(err, class, str, str1, arg) do {                          \
+        fprintf(stderr, "ERROR: "str1" in %s (%d)\n", arg, PMI2U_FUNC, __LINE__);       \
+        pmi2_errno = class;                                                              \
+        goto fn_fail;                                                                   \
+    } while (0)
+#define PMI2U_ERR_SETANDJUMP2(err, class, str, str1, arg1, arg2) do {                           \
+        fprintf(stderr, "ERROR: "str1" in %s (%d)\n", arg1, arg2, PMI2U_FUNC, __LINE__);        \
+        pmi2_errno = class;                                                                      \
+        goto fn_fail;                                                                           \
+    } while (0)
+#define PMI2U_ERR_SETANDJUMP3(err, class, str, str1, arg1, arg2, arg3) do {                     \
+        fprintf(stderr, "ERROR: "str1" in %s (%d)\n", arg1, arg2, arg3, PMI2U_FUNC, __LINE__);  \
+        pmi2_errno = class;                                                                      \
+        goto fn_fail;                                                                           \
+    } while (0)
+#define PMI2U_ERR_SETANDJUMP4(err, class, str, str1, arg1, arg2, arg3, arg4) do {                       \
+        fprintf(stderr, "ERROR: "str1" in %s (%d)\n", arg1, arg2, arg3, arg4, PMI2U_FUNC, __LINE__);    \
+        pmi2_errno = class;                                                                              \
+        goto fn_fail;                                                                                   \
+    } while (0)
+#define PMI2U_ERR_SETANDJUMP5(err, class, str, str1, arg1, arg2, arg3, arg4, arg5) do {                         \
+        fprintf(stderr, "ERROR: "str1" in %s (%d)\n", arg1, arg2, arg3, arg4, arg5, PMI2U_FUNC, __LINE__);      \
+        pmi2_errno = class;                                                                                      \
+        goto fn_fail;                                                                                           \
+    } while (0)
+#define PMI2U_ERR_SETANDJUMP6(err, class, str, str1, arg1, arg2, arg3, arg4, arg5, arg6) do {                           \
+        fprintf(stderr, "ERROR: "str1" in %s (%d)\n", arg1, arg2, arg3, arg4, arg5, arg6, PMI2U_FUNC, __LINE__);        \
+        pmi2_errno = class;                                                                                              \
+        goto fn_fail;                                                                                                   \
+    } while (0)
 
+
+#define PMI2U_ERR_CHKANDJUMP(cond, err, class, str) do {        \
+        if (cond)                                               \
+            PMI2U_ERR_SETANDJUMP(err, class, str);              \
+    } while (0)
+#define PMI2U_ERR_CHKANDJUMP1(cond, err, class, str, str1, arg) do {    \
+        if (cond)                                                       \
+            PMI2U_ERR_SETANDJUMP1(err, class, str, str1, arg);          \
+    } while (0)
+#define PMI2U_ERR_CHKANDJUMP2(cond, err, class, str, str1, arg1, arg2) do {     \
+        if (cond)                                                               \
+            PMI2U_ERR_SETANDJUMP2(err, class, str, str1, arg1, arg2);           \
+    } while (0)
+#define PMI2U_ERR_CHKANDJUMP3(cond, err, class, str, str1, arg1, arg2, arg3) do {       \
+        if (cond)                                                                       \
+            PMI2U_ERR_SETANDJUMP3(err, class, str, str1, arg1, arg2, arg3);             \
+    } while (0)
+#define PMI2U_ERR_CHKANDJUMP4(cond, err, class, str, str1, arg1, arg2, arg3, arg4) do { \
+        if (cond)                                                                       \
+            PMI2U_ERR_SETANDJUMP4(err, class, str, str1, arg1, arg2, arg3, arg4);       \
+    } while (0)
+#define PMI2U_ERR_CHKANDJUMP5(cond, err, class, str, str1, arg1, arg2, arg3, arg4, arg5) do {   \
+        if (cond)                                                                               \
+            PMI2U_ERR_SETANDJUMP5(err, class, str, str1, arg1, arg2, arg3, arg4, arg5);         \
+    } while (0)
+#define PMI2U_ERR_CHKANDJUMP6(cond, err, class, str, str1, arg1, arg2, arg3, arg4, arg5, arg6) do {     \
+        if (cond)                                                                                       \
+            PMI2U_ERR_SETANDJUMP6(err, class, str, str1, arg1, arg2, arg3, arg4, arg5, arg6);           \
+    } while (0)
+
+#if (!defined(NDEBUG) && defined(HAVE_ERROR_CHECKING))
+#define PMI2U_AssertDecl(a_) a_
+#define PMI2U_AssertDeclValue(_a, _b) _a = _b
+#else
+/* Empty decls not allowed in C */
+#define PMI2U_AssertDecl(a_) a_ 
+#define PMI2U_AssertDeclValue(_a, _b) _a ATTRIBUTE((unused))
+#endif
+
+#ifdef HAVE_ERROR_CHECKING
+#define PMI2U_CHKMEM_SETERR(rc_, nbytes_, name_) do {                                           \
+        rc_ = PMI2_ERR_NOMEM;                                                                   \
+        fprintf(stderr, "ERROR: memory allocation of %lu bytes failed for %s in %s (%d)\n",     \
+                (size_t)nbytes_, name_, PMI2U_FUNC, __LINE__);                                  \
+    } while(0)
+#else
+#define PMI2U_CHKMEM_SETERR(rc_, nbytes_, name_) rc_ = PMI2_ERR_NOMEM
+#endif
+
+
+#if defined(HAVE_ALLOCA) && defined(USE_ALLOCA)
+#ifdef HAVE_ALLOCA_H
+#include <alloca.h>
+#endif
+/* Define decl with a dummy definition to allow us to put a semi-colon
+   after the macro without causing the declaration block to end (restriction
+   imposed by C) */
+#define PMI2U_CHKLMEM_DECL(n_) int dummy_ ATTRIBUTE((unused))
+#define PMI2U_CHKLMEM_FREEALL()
+#define PMI2U_CHKLMEM_MALLOC_ORSTMT(pointer_,type_,nbytes_,rc_,name_,stmt_) do {        \
+        pointer_ = (type_)alloca(nbytes_);                                              \
+        if (!(pointer_)) {                                                              \
+            PMI2U_CHKMEM_SETERR(rc_,nbytes_,name_);                                     \
+            stmt_;                                                                      \
+        }                                                                               \
+    } while(0)
+#else
+#define PMI2U_CHKLMEM_DECL(n_)                                  \
+    void *(pmi2u_chklmem_stk_[n_]) = {0};                       \
+    int pmi2u_chklmem_stk_sp_=0;                                \
+    PMI2U_AssertDeclValue(const int pmi2u_chklmem_stk_sz_,n_)
+
+#define PMI2U_CHKLMEM_MALLOC_ORSTMT(pointer_,type_,nbytes_,rc_,name_,stmt_) do {        \
+        pointer_ = (type_)PMI2U_Malloc(nbytes_);                                        \
+        if (pointer_) {                                                                 \
+            PMI2U_Assert(pmi2u_chklmem_stk_sp_<pmi2u_chklmem_stk_sz_);                  \
+            pmi2u_chklmem_stk_[pmi2u_chklmem_stk_sp_++] = pointer_;                     \
+        } else {                                                                        \
+            PMI2U_CHKMEM_SETERR(rc_,nbytes_,name_);                                     \
+            stmt_;                                                                      \
+        }                                                                               \
+    } while(0)
+#define PMI2U_CHKLMEM_FREEALL()                                         \
+    while (pmi2u_chklmem_stk_sp_ > 0) {                                 \
+        PMI2U_Free( pmi2u_chklmem_stk_[--pmi2u_chklmem_stk_sp_] ); }
+#endif /* HAVE_ALLOCA */
+#define PMI2U_CHKLMEM_MALLOC(pointer_,type_,nbytes_,rc_,name_) \
+    PMI2U_CHKLMEM_MALLOC_ORJUMP(pointer_,type_,nbytes_,rc_,name_)
+#define PMI2U_CHKLMEM_MALLOC_ORJUMP(pointer_,type_,nbytes_,rc_,name_) \
+    PMI2U_CHKLMEM_MALLOC_ORSTMT(pointer_,type_,nbytes_,rc_,name_,goto fn_fail)
+
+/* In some cases, we need to allocate large amounts of memory. This can
+   be a problem if alloca is used, as the available stack space may be small.
+   This is the same approach for the temporary memory as is used when alloca
+   is not available. */
+#define PMI2U_CHKLBIGMEM_DECL(n_)                                       \
+    void *(pmi2u_chklbigmem_stk_[n_]);                                  \
+    int pmi2u_chklbigmem_stk_sp_ = 0;                                   \
+    PMI2U_AssertDeclValue(const int pmi2u_chklbigmem_stk_sz_,n_)
+
+#define PMI2U_CHKLBIGMEM_MALLOC_ORSTMT(pointer_,type_,nbytes_,rc_,name_,stmt_) do {     \
+        pointer_ = (type_)PMI2U_Malloc(nbytes_);                                        \
+        if (pointer_) {                                                                 \
+            PMI2U_Assert(pmi2u_chklbigmem_stk_sp_<pmi2u_chklbigmem_stk_sz_);            \
+            pmi2u_chklbigmem_stk_[pmi2u_chklbigmem_stk_sp_++] = pointer_;               \
+        } else {                                                                        \
+            PMI2U_CHKMEM_SETERR(rc_,nbytes_,name_);                                     \
+            stmt_;                                                                      \
+        }                                                                               \
+    } while(0)
+#define PMI2U_CHKLBIGMEM_FREEALL()                                              \
+    while (pmi2u_chklbigmem_stk_sp_ > 0) {                                      \
+        PMI2U_Free( pmi2u_chklbigmem_stk_[--pmi2u_chklbigmem_stk_sp_] ); }
+
+#define PMI2U_CHKLBIGMEM_MALLOC(pointer_,type_,nbytes_,rc_,name_)       \
+    PMI2U_CHKLBIGMEM_MALLOC_ORJUMP(pointer_,type_,nbytes_,rc_,name_)
+#define PMI2U_CHKLBIGMEM_MALLOC_ORJUMP(pointer_,type_,nbytes_,rc_,name_)                \
+    PMI2U_CHKLBIGMEM_MALLOC_ORSTMT(pointer_,type_,nbytes_,rc_,name_,goto fn_fail)
+
+/* Persistent memory that we may want to recover if something goes wrong */
+#define PMI2U_CHKPMEM_DECL(n_)                                  \
+    void *(pmi2u_chkpmem_stk_[n_]) = {0};                       \
+    int pmi2u_chkpmem_stk_sp_=0;                                \
+    PMI2U_AssertDeclValue(const int pmi2u_chkpmem_stk_sz_,n_)
+#define PMI2U_CHKPMEM_MALLOC_ORSTMT(pointer_,type_,nbytes_,rc_,name_,stmt_) do {        \
+        pointer_ = (type_)PMI2U_Malloc(nbytes_);                                        \
+        if (pointer_) {                                                                 \
+            PMI2U_Assert(pmi2u_chkpmem_stk_sp_<pmi2u_chkpmem_stk_sz_);                  \
+            pmi2u_chkpmem_stk_[pmi2u_chkpmem_stk_sp_++] = pointer_;                     \
+        } else {                                                                        \
+            PMI2U_CHKMEM_SETERR(rc_,nbytes_,name_);                                     \
+            stmt_;                                                                      \
+        }                                                                               \
+    } while(0)
+#define PMI2U_CHKPMEM_REGISTER(pointer_) do {                           \
+        PMI2U_Assert(pmi2u_chkpmem_stk_sp_<pmi2u_chkpmem_stk_sz_);      \
+        pmi2u_chkpmem_stk_[pmi2u_chkpmem_stk_sp_++] = pointer_;         \
+    } while(0)
+#define PMI2U_CHKPMEM_REAP()                                            \
+    while (pmi2u_chkpmem_stk_sp_ > 0) {                                 \
+        PMI2U_Free( pmi2u_chkpmem_stk_[--pmi2u_chkpmem_stk_sp_] ); }
+#define PMI2U_CHKPMEM_COMMIT() pmi2u_chkpmem_stk_sp_ = 0
+#define PMI2U_CHKPMEM_MALLOC(pointer_,type_,nbytes_,rc_,name_)          \
+    PMI2U_CHKPMEM_MALLOC_ORJUMP(pointer_,type_,nbytes_,rc_,name_)
+#define PMI2U_CHKPMEM_MALLOC_ORJUMP(pointer_,type_,nbytes_,rc_,name_)           \
+    PMI2U_CHKPMEM_MALLOC_ORSTMT(pointer_,type_,nbytes_,rc_,name_,goto fn_fail)
+
+/* A special version for routines that only allocate one item */
+#define PMI2U_CHKPMEM_MALLOC1(pointer_,type_,nbytes_,rc_,name_,stmt_) do {      \
+        pointer_ = (type_)PMI2U_Malloc(nbytes_);                                \
+        if (!(pointer_)) {                                                      \
+            PMI2U_CHKMEM_SETERR(rc_,nbytes_,name_);                             \
+            stmt_;                                                              \
+        }                                                                       \
+    } while(0)
+
+/* Provides a easy way to use realloc safely and avoid the temptation to use
+ * realloc unsafely (direct ptr assignment).  Zero-size reallocs returning NULL
+ * are handled and are not considered an error. */
+#define PMI2U_REALLOC_OR_FREE_AND_JUMP(ptr_,size_,rc_) do {                                     \
+        void *realloc_tmp_ = PMI2U_Realloc((ptr_), (size_));                                    \
+        if ((size_) && !realloc_tmp_) {                                                         \
+            PMI2U_Free(ptr_);                                                                   \
+            PMI2U_ERR_SETANDJUMP2(rc_,PMI2U_CHKMEM_ISFATAL,                                     \
+                                  "**nomem2","**nomem2 %d %s",(size_),PMI2U_QUOTE(ptr_));       \
+        }                                                                                       \
+        (ptr_) = realloc_tmp_;                                                                  \
+    } while (0)
+/* this version does not free ptr_ */
+#define PMI2U_REALLOC_ORJUMP(ptr_,size_,rc_) do {                                               \
+        void *realloc_tmp_ = PMI2U_Realloc((ptr_), (size_));                                    \
+        if (size_)                                                                              \
+            PMI2U_ERR_CHKANDJUMP2(!realloc_tmp_,rc_,PMI2U_CHKMEM_ISFATAL,\                      \
+                                  "**nomem2","**nomem2 %d %s",(size_),PMI2U_QUOTE(ptr_));       \
+        (ptr_) = realloc_tmp_;                                                                  \
+    } while (0)
+
 #endif /*SIMPLE_PMI_UTIL_H_INCLUDED*/



More information about the mpich2-commits mailing list