summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBill Wendling <wendling@ncsa.uiuc.edu>2002-05-31 18:43:22 (GMT)
committerBill Wendling <wendling@ncsa.uiuc.edu>2002-05-31 18:43:22 (GMT)
commit4a3fa29c25e2ad0acef8621e21cbd546c184e269 (patch)
treecd24ebcc6666521758c584812d8028d86b8ec6f9
parentf4d1614943e3cfcb74dfea218f8297e9f595d197 (diff)
downloadhdf5-4a3fa29c25e2ad0acef8621e21cbd546c184e269.zip
hdf5-4a3fa29c25e2ad0acef8621e21cbd546c184e269.tar.gz
hdf5-4a3fa29c25e2ad0acef8621e21cbd546c184e269.tar.bz2
[svn-r5491] Purpose:
Feature Enhancement Description: We can now set the MPI_Info object to more than one key/value pairing. By setting the HDF5_MPI_INFO environment variable to a semicolon separated list of "key=value" pairs, we can set the MPI_Info variable to them. Platforms tested: Linux
-rw-r--r--test/h5test.c97
1 files changed, 74 insertions, 23 deletions
diff --git a/test/h5test.c b/test/h5test.c
index c6382dc..1951803 100644
--- a/test/h5test.c
+++ b/test/h5test.c
@@ -586,44 +586,95 @@ h5_show_hostname(void)
#ifdef H5_HAVE_PARALLEL
/*
* Function: h5_set_info_object
- * Purpose: Process environment variables setting to set up MPI Info object.
+ * Purpose: Process environment variables setting to set up MPI Info
+ * object.
* Return: 0 if all is fine; otherwise non-zero.
* Programmer: Albert Cheng, 2002/05/21.
* Modifications:
+ * Bill Wendling, 2002/05/31
+ * Modified so that the HDF5_MPI_INFO environment variable can
+ * be a semicolon separated list of "key=value" pairings. Most
+ * of the code is to remove any whitespaces which might be
+ * surrounding the "key=value" pairs.
*/
int
h5_set_info_object(void)
{
char *envp; /* environment pointer */
- char *namep, *valp; /* name, value pointers */
int ret_value=0;
/* handle any MPI INFO hints via $HDF5_MPI_INFO */
if ((envp = getenv("HDF5_MPI_INFO")) != NULL){
- envp = HDstrdup(envp);
-
- /* create an INFO object if not created yet */
- if (h5_io_info_g==MPI_INFO_NULL)
- MPI_Info_create (&h5_io_info_g);
-
- /* parse only one setting. Need to extend it to handle multiple */
- /* settings. LATER */
- namep=envp;
- valp=HDstrchr(namep, '=');
- if (valp != NULL){
- /* change '=' to NULL, move valp down one */
- *valp++ = NULL;
- if (MPI_SUCCESS!=MPI_Info_set(h5_io_info_g, namep, valp)){
- printf("MPI_Info_set failed\n");
- ret_value = -1;
- }
+ char *next, *valp;
- }
+ valp = envp = next = HDstrdup(envp);
+
+ /* create an INFO object if not created yet */
+ if (h5_io_info_g == MPI_INFO_NULL)
+ MPI_Info_create(&h5_io_info_g);
+
+ do {
+ size_t len;
+ char *key_val, *endp, *namep;
+
+ if (*valp == ';')
+ valp++;
+
+ /* copy key/value pair into temporary buffer */
+ len = strcspn(valp, ";");
+ next = &valp[len];
+ key_val = calloc(1, len + 1);
+
+ /* increment the next pointer past the terminating semicolon */
+ if (*next == ';')
+ ++next;
+
+ namep = HDstrncpy(key_val, valp, len);
+
+ /* pass up any beginning whitespaces */
+ while (*namep && (*namep == ' ' || *namep == '\t'))
+ namep++;
+
+ /* eat up any ending white spaces */
+ endp = &namep[strlen(namep) - 1];
+
+ while (endp && (*endp == ' ' || *endp == '\t'))
+ *endp-- = '\0';
+
+ /* find the '=' */
+ valp = HDstrchr(namep, '=');
+
+ if (valp != NULL) { /* it's a valid key/value pairing */
+ char *tmp_val = valp + 1;
+
+ /* change '=' to \0, move valp down one */
+ *valp-- = '\0';
+
+ /* eat up ending whitespace on the "key" part */
+ while (*valp == ' ' || *valp == '\t')
+ *valp-- = '\0';
+
+ valp = tmp_val;
+
+ /* eat up beginning whitespace on the "value" part */
+ while (*valp == ' ' || *valp == '\t')
+ *valp++ = '\0';
+
+ /* actually set the darned thing */
+ if (MPI_SUCCESS != MPI_Info_set(h5_io_info_g, namep, valp)) {
+ printf("MPI_Info_set failed\n");
+ ret_value = -1;
+ }
+ }
+
+ valp = next;
+ HDfree(key_val);
+ } while (next && *next);
+
+ HDfree(envp);
}
- if (envp)
- HDfree(envp);
- return(ret_value);
+ return ret_value;
}