root/ompi/mpi/c/info_get_nthkey.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. MPI_Info_get_nthkey

   1 /*
   2  * Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana
   3  *                         University Research and Technology
   4  *                         Corporation.  All rights reserved.
   5  * Copyright (c) 2004-2005 The University of Tennessee and The University
   6  *                         of Tennessee Research Foundation.  All rights
   7  *                         reserved.
   8  * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
   9  *                         University of Stuttgart.  All rights reserved.
  10  * Copyright (c) 2004-2005 The Regents of the University of California.
  11  *                         All rights reserved.
  12  * Copyright (c) 2015      Research Organization for Information Science
  13  *                         and Technology (RIST). All rights reserved.
  14  * $COPYRIGHT$
  15  *
  16  * Additional copyrights may follow
  17  *
  18  * $HEADER$
  19  */
  20 
  21 #include "ompi_config.h"
  22 
  23 #include "ompi/mpi/c/bindings.h"
  24 #include "ompi/runtime/params.h"
  25 #include "ompi/communicator/communicator.h"
  26 #include "ompi/errhandler/errhandler.h"
  27 #include "ompi/info/info.h"
  28 #include <string.h>
  29 
  30 #if OMPI_BUILD_MPI_PROFILING
  31 #if OPAL_HAVE_WEAK_SYMBOLS
  32 #pragma weak MPI_Info_get_nthkey = PMPI_Info_get_nthkey
  33 #endif
  34 #define MPI_Info_get_nthkey PMPI_Info_get_nthkey
  35 #endif
  36 
  37 static const char FUNC_NAME[] = "MPI_Info_get_nthkey";
  38 
  39 
  40 /**
  41  *   MPI_Info_get_nthkey - Get a key indexed by integer from an 'MPI_Info' obje
  42  *
  43  *   @param info info object (handle)
  44  *   @param n index of key to retrieve (integer)
  45  *   @param key character string of at least 'MPI_MAX_INFO_KEY' characters
  46  *
  47  *   @retval MPI_SUCCESS
  48  *   @retval MPI_ERR_ARG
  49  *   @retval MPI_ERR_INFO
  50  *   @retval MPI_ERR_INFO_KEY
  51  */
  52 int MPI_Info_get_nthkey(MPI_Info info, int n, char *key)
  53 {
  54     int nkeys;
  55     int err;
  56 
  57     /*
  58      * 1. Check if info is a valid handle
  59      * 2. Check if there are at least (n+1) elements
  60      * 3. If so, give the nth defined key
  61      */
  62     if (MPI_PARAM_CHECK) {
  63         OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
  64         if (NULL == info || MPI_INFO_NULL == info ||
  65             ompi_info_is_freed(info)) {
  66             return OMPI_ERRHANDLER_INVOKE (MPI_COMM_WORLD, MPI_ERR_INFO,
  67                                            FUNC_NAME);
  68         }
  69         if (0 > n) {
  70             return OMPI_ERRHANDLER_INVOKE (MPI_COMM_WORLD, MPI_ERR_ARG,
  71                                            FUNC_NAME);
  72         }
  73         if (NULL == key) {
  74             return OMPI_ERRHANDLER_INVOKE (MPI_COMM_WORLD, MPI_ERR_INFO_KEY,
  75                                            FUNC_NAME);
  76         }
  77     }
  78 
  79     OPAL_CR_ENTER_LIBRARY();
  80 
  81     /* Keys are indexed on 0, which makes the "n" parameter offset by
  82        1 from the value returned by get_nkeys().  So be sure to
  83        compare appropriately. */
  84 
  85     err = ompi_info_get_nkeys(info, &nkeys);
  86     OMPI_ERRHANDLER_CHECK(err, MPI_COMM_WORLD, err, FUNC_NAME);
  87     if (n > (nkeys - 1)) {
  88         OPAL_CR_EXIT_LIBRARY();
  89         return OMPI_ERRHANDLER_INVOKE (MPI_COMM_WORLD, MPI_ERR_INFO_KEY,
  90                                        FUNC_NAME);
  91     }
  92 
  93     /* Everything seems alright. Call the back end key copy */
  94 
  95     err = ompi_info_get_nthkey (info, n, key);
  96     OMPI_ERRHANDLER_RETURN(err, MPI_COMM_WORLD, err, FUNC_NAME);
  97 }

/* [<][>][^][v][top][bottom][index][help] */