00001
00002
00003
00004
00005
00006
00007
00008 #include "mpio.h"
00009 #include "adio.h"
00010
00011
00012 #if defined(MPIO_BUILD_PROFILING) || defined(HAVE_WEAK_SYMBOLS)
00013 #ifdef FORTRANCAPS
00014 #define mpi_info_set_ PMPI_INFO_SET
00015 #elif defined(FORTRANDOUBLEUNDERSCORE)
00016 #define mpi_info_set_ pmpi_info_set__
00017 #elif !defined(FORTRANUNDERSCORE)
00018 #if defined(HPUX) || defined(SPPUX)
00019 #pragma _HP_SECONDARY_DEF pmpi_info_set pmpi_info_set_
00020 #endif
00021 #define mpi_info_set_ pmpi_info_set
00022 #else
00023 #if defined(HPUX) || defined(SPPUX)
00024 #pragma _HP_SECONDARY_DEF pmpi_info_set_ pmpi_info_set
00025 #endif
00026 #define mpi_info_set_ pmpi_info_set_
00027 #endif
00028
00029 #if defined(HAVE_WEAK_SYMBOLS)
00030 #if defined(HAVE_PRAGMA_WEAK)
00031 #if defined(FORTRANCAPS)
00032 #pragma weak MPI_INFO_SET = PMPI_INFO_SET
00033 #elif defined(FORTRANDOUBLEUNDERSCORE)
00034 #pragma weak mpi_info_set__ = pmpi_info_set__
00035 #elif !defined(FORTRANUNDERSCORE)
00036 #pragma weak mpi_info_set = pmpi_info_set
00037 #else
00038 #pragma weak mpi_info_set_ = pmpi_info_set_
00039 #endif
00040
00041 #elif defined(HAVE_PRAGMA_HP_SEC_DEF)
00042 #if defined(FORTRANCAPS)
00043 #pragma _HP_SECONDARY_DEF PMPI_INFO_SET MPI_INFO_SET
00044 #elif defined(FORTRANDOUBLEUNDERSCORE)
00045 #pragma _HP_SECONDARY_DEF pmpi_info_set__ mpi_info_set__
00046 #elif !defined(FORTRANUNDERSCORE)
00047 #pragma _HP_SECONDARY_DEF pmpi_info_set mpi_info_set
00048 #else
00049 #pragma _HP_SECONDARY_DEF pmpi_info_set_ mpi_info_set_
00050 #endif
00051
00052 #elif defined(HAVE_PRAGMA_CRI_DUP)
00053 #if defined(FORTRANCAPS)
00054 #pragma _CRI duplicate MPI_INFO_SET as PMPI_INFO_SET
00055 #elif defined(FORTRANDOUBLEUNDERSCORE)
00056 #pragma _CRI duplicate mpi_info_set__ as pmpi_info_set__
00057 #elif !defined(FORTRANUNDERSCORE)
00058 #pragma _CRI duplicate mpi_info_set as pmpi_info_set
00059 #else
00060 #pragma _CRI duplicate mpi_info_set_ as pmpi_info_set_
00061 #endif
00062
00063
00064 #endif
00065
00066 #include "mpioprof.h"
00067 #endif
00068
00069 #else
00070
00071 #ifdef FORTRANCAPS
00072 #define mpi_info_set_ MPI_INFO_SET
00073 #elif defined(FORTRANDOUBLEUNDERSCORE)
00074 #define mpi_info_set_ mpi_info_set__
00075 #elif !defined(FORTRANUNDERSCORE)
00076 #if defined(HPUX) || defined(SPPUX)
00077 #pragma _HP_SECONDARY_DEF mpi_info_set mpi_info_set_
00078 #endif
00079 #define mpi_info_set_ mpi_info_set
00080 #else
00081 #if defined(HPUX) || defined(SPPUX)
00082 #pragma _HP_SECONDARY_DEF mpi_info_set_ mpi_info_set
00083 #endif
00084 #endif
00085 #endif
00086
00087
00088 void mpi_info_set_(MPI_Fint *info, char *key, char *value, int *ierr,
00089 int keylen, int vallen)
00090 {
00091 MPI_Info info_c;
00092 char *newkey, *newvalue;
00093 int new_keylen, new_vallen, lead_blanks, i;
00094
00095 if (key <= (char *) 0) {
00096 FPRINTF(stderr, "MPI_Info_set: key is an invalid address\n");
00097 MPI_Abort(MPI_COMM_WORLD, 1);
00098 }
00099 if (value <= (char *) 0) {
00100 FPRINTF(stderr, "MPI_Info_set: value is an invalid address\n");
00101 MPI_Abort(MPI_COMM_WORLD, 1);
00102 }
00103
00104
00105 lead_blanks = 0;
00106 for (i=0; i<keylen; i++)
00107 if (key[i] == ' ') lead_blanks++;
00108 else break;
00109
00110 for (i=keylen-1; i>=0; i--) if (key[i] != ' ') break;
00111 if (i < 0) {
00112 FPRINTF(stderr, "MPI_Info_set: key is a blank string\n");
00113 MPI_Abort(MPI_COMM_WORLD, 1);
00114 }
00115 new_keylen = i + 1 - lead_blanks;
00116 key += lead_blanks;
00117
00118 newkey = (char *) ADIOI_Malloc((new_keylen+1)*sizeof(char));
00119 ADIOI_Strncpy(newkey, key, new_keylen);
00120 newkey[new_keylen] = '\0';
00121
00122
00123
00124 lead_blanks = 0;
00125 for (i=0; i<vallen; i++)
00126 if (value[i] == ' ') lead_blanks++;
00127 else break;
00128
00129 for (i=vallen-1; i>=0; i--) if (value[i] != ' ') break;
00130 if (i < 0) {
00131 FPRINTF(stderr, "MPI_Info_set: value is a blank string\n");
00132 MPI_Abort(MPI_COMM_WORLD, 1);
00133 }
00134 new_vallen = i + 1 - lead_blanks;
00135 value += lead_blanks;
00136
00137 newvalue = (char *) ADIOI_Malloc((new_vallen+1)*sizeof(char));
00138 ADIOI_Strncpy(newvalue, value, new_vallen);
00139 newvalue[new_vallen] = '\0';
00140
00141
00142 info_c = MPI_Info_f2c(*info);
00143 *ierr = MPI_Info_set(info_c, newkey, newvalue);
00144 ADIOI_Free(newkey);
00145 ADIOI_Free(newvalue);
00146 }