2004-01-26 01:07:54 +03:00
|
|
|
/*
|
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "lam_config.h"
|
|
|
|
|
|
|
|
#include "mpi.h"
|
|
|
|
#include "mpi/interface/c/bindings.h"
|
2004-02-11 01:15:55 +03:00
|
|
|
#include "lam/lfc/lam_list.h"
|
2004-02-02 01:28:20 +03:00
|
|
|
#include "mpi/info/info.h"
|
2004-02-04 01:34:01 +03:00
|
|
|
#include <string.h>
|
2004-01-26 01:07:54 +03:00
|
|
|
|
|
|
|
#if LAM_HAVE_WEAK_SYMBOLS && LAM_PROFILING_DEFINES
|
|
|
|
#pragma weak MPI_Info_get_nthkey = PMPI_Info_get_nthkey
|
|
|
|
#endif
|
|
|
|
|
2004-02-02 01:28:20 +03:00
|
|
|
/**
|
|
|
|
* MPI_Info_get_nthkey - Get a key indexed by integer from an 'MPI_Info' obje
|
|
|
|
*
|
|
|
|
* @param info info object (handle)
|
|
|
|
* @param n index of key to retrieve (integer)
|
|
|
|
* @param key character string of at least 'MPI_MAX_INFO_KEY' characters
|
|
|
|
*
|
|
|
|
* @retval MPI_SUCCESS
|
|
|
|
* @retval MPI_ERR_ARG
|
|
|
|
*/
|
2004-01-26 01:07:54 +03:00
|
|
|
int MPI_Info_get_nthkey(MPI_Info info, int n, char *key) {
|
2004-02-04 01:34:01 +03:00
|
|
|
lam_info_entry_t *iterator;
|
|
|
|
int nkeys;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 1. Check if info is a valid handle
|
|
|
|
* 2. Check if there are atleast "n" elements
|
|
|
|
* 3. If so, give the nth defined key
|
|
|
|
*/
|
|
|
|
if (NULL == info){
|
|
|
|
printf ("Invalid MPI_Info handle passed\n");
|
|
|
|
return MPI_ERR_ARG;
|
|
|
|
}
|
|
|
|
|
|
|
|
MPI_Info_get_nkeys(info, &nkeys);
|
|
|
|
|
|
|
|
if (nkeys < n) {
|
|
|
|
printf ("Requested key does not exist\n");
|
|
|
|
return MPI_ERR_ARG;
|
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* Iterate over and over till we get to the nth key
|
|
|
|
*/
|
|
|
|
iterator = (lam_info_entry_t *)lam_list_get_first(&(info->super));
|
|
|
|
for ( ; n > 0; n--) {
|
|
|
|
iterator = (lam_info_entry_t *)
|
|
|
|
iterator->super.lam_list_next;
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* iterator is of the type lam_list_item_t. We have to
|
|
|
|
* cast it to lam_info_entry_t before we can use it to
|
|
|
|
* access the value
|
|
|
|
*/
|
|
|
|
strcpy(key, iterator->ie_key);
|
|
|
|
}
|
2004-01-26 01:07:54 +03:00
|
|
|
return MPI_SUCCESS;
|
|
|
|
}
|