summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorAlbert Cheng <acheng@hdfgroup.org>2002-06-02 00:43:05 (GMT)
committerAlbert Cheng <acheng@hdfgroup.org>2002-06-02 00:43:05 (GMT)
commit57a68519db9075b577881e180f406d69cd50e890 (patch)
tree26a2a19b3653be80704f42afe4fc93c103318962 /test
parentb84e706de98a6541f29e6ce47dc87d895fdeacc0 (diff)
downloadhdf5-57a68519db9075b577881e180f406d69cd50e890.zip
hdf5-57a68519db9075b577881e180f406d69cd50e890.tar.gz
hdf5-57a68519db9075b577881e180f406d69cd50e890.tar.bz2
[svn-r5505] Description:
Folded in the feature Bill added to v1.5. 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: modi4, eirene, burrwhite, all PP.
Diffstat (limited to 'test')
-rw-r--r--test/h5test.c97
1 files changed, 74 insertions, 23 deletions
diff --git a/test/h5test.c b/test/h5test.c
index c4aa299..23c7bcb 100644
--- a/test/h5test.c
+++ b/test/h5test.c
@@ -664,44 +664,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;
}