00001
00002
00003
00004
00005
00006
00007
00008 #include "mpioimpl.h"
00009
00010 #ifdef HAVE_WEAK_SYMBOLS
00011
00012 #if defined(HAVE_PRAGMA_WEAK)
00013 #pragma weak MPI_Info_set = PMPI_Info_set
00014 #elif defined(HAVE_PRAGMA_HP_SEC_DEF)
00015 #pragma _HP_SECONDARY_DEF PMPI_Info_set MPI_Info_set
00016 #elif defined(HAVE_PRAGMA_CRI_DUP)
00017 #pragma _CRI duplicate MPI_Info_set as PMPI_Info_set
00018
00019 #endif
00020
00021
00022 #define MPIO_BUILD_PROFILING
00023 #include "mpioprof.h"
00024 #endif
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 int MPI_Info_set(MPI_Info info, char *key, char *value)
00037 {
00038 MPI_Info prev, curr;
00039
00040 if ((info <= (MPI_Info) 0) || (info->cookie != MPIR_INFO_COOKIE)) {
00041 FPRINTF(stderr, "MPI_Info_set: Invalid info object\n");
00042 MPI_Abort(MPI_COMM_WORLD, 1);
00043 }
00044
00045 if (key <= (char *) 0) {
00046 FPRINTF(stderr, "MPI_Info_set: key is an invalid address\n");
00047 MPI_Abort(MPI_COMM_WORLD, 1);
00048 }
00049
00050 if (value <= (char *) 0) {
00051 FPRINTF(stderr, "MPI_Info_set: value is an invalid address\n");
00052 MPI_Abort(MPI_COMM_WORLD, 1);
00053 }
00054
00055 if (strlen(key) > MPI_MAX_INFO_KEY) {
00056 FPRINTF(stderr, "MPI_Info_set: key is longer than MPI_MAX_INFO_KEY\n");
00057 MPI_Abort(MPI_COMM_WORLD, 1);
00058 }
00059
00060 if (strlen(value) > MPI_MAX_INFO_VAL) {
00061 FPRINTF(stderr, "MPI_Info_set: value is longer than MPI_MAX_INFO_VAL\n");
00062 MPI_Abort(MPI_COMM_WORLD, 1);
00063 }
00064
00065 if (!strlen(key)) {
00066 FPRINTF(stderr, "MPI_Info_set: key is a null string\n");
00067 MPI_Abort(MPI_COMM_WORLD, 1);
00068 }
00069
00070 if (!strlen(value)) {
00071 FPRINTF(stderr, "MPI_Info_set: value is a null string\n");
00072 MPI_Abort(MPI_COMM_WORLD, 1);
00073 }
00074
00075 prev = info;
00076 curr = info->next;
00077
00078 while (curr) {
00079 if (!strcmp(curr->key, key)) {
00080 ADIOI_Free(curr->value);
00081 curr->value = ADIOI_Strdup(value);
00082 break;
00083 }
00084 prev = curr;
00085 curr = curr->next;
00086 }
00087
00088 if (!curr) {
00089 prev->next = (MPI_Info) ADIOI_Malloc(sizeof(struct MPIR_Info));
00090 curr = prev->next;
00091 curr->cookie = 0;
00092 curr->key = ADIOI_Strdup(key);
00093 curr->value = ADIOI_Strdup(value);
00094 curr->next = 0;
00095 }
00096
00097 return MPI_SUCCESS;
00098 }