@@ -244,20 +244,36 @@ AC_DEFUN([OMPI_SETUP_MPI_FORTRAN],[
244
244
245
245
# How big should MPI_STATUS_SIZE be? (i.e., the size of
246
246
# MPI_STATUS, expressed in units of Fortran INTEGERs). The C
247
- # equivalent of MPI_Status contains 4 C ints and a size_t.
247
+ # MPI_Status struct contains 4 C ints and a size_t.
248
248
OMPI_FORTRAN_STATUS_SIZE= 0
249
- AC_MSG_CHECKING([for the value of MPI_STATUS_SIZE])
249
+
250
+ # Calculate how many C int's can fit in sizeof(MPI_Status). Yes,
251
+ # I do mean C ints -- not Fortran INTEGERS. The reason is because
252
+ # an mpif.h MPI_Status is an array of INTEGERS. But these
253
+ # sizeof(INTEGER) may be larger than sizeof(int). Hence,
254
+ # MPI_Status_ctof() basically does this:
255
+ #
256
+ # MPI_Fint *f_status = ...;
257
+ # int *s = (int*) &c_status;
258
+ # for i=0..sizeof(MPI_Status)/sizeof(int)
259
+ # f_status[i] = c_status[i];
260
+ #
261
+ # Meaning: we have to have as many Fortran INTEGERs in the array
262
+ # as int's will fit in a C MPI_Status (vs. just having a Fortran
263
+ # array of INTEGERs that has enough bytes to hold a C MPI_Status).
250
264
bytes= ` expr 4 \* $ac_cv_sizeof_int + $ac_cv_sizeof_size_t `
251
- num_integers= ` expr $bytes / $ac_cv_sizeof_int `
252
- sanity= ` expr $num_integers \* $ac_cv_sizeof_int `
265
+ AC_MSG_NOTICE([C MPI_Status is $bytes bytes long])
266
+ AC_MSG_CHECKING([for the value of MPI_STATUS_SIZE])
267
+ num_ints= ` expr $bytes / $ac_cv_sizeof_int `
268
+ sanity= ` expr $num_ints \* $ac_cv_sizeof_int `
253
269
AS_IF([test " $sanity " != " $bytes " ],
254
270
[AC_MSG_RESULT([unknown! ])
255
271
AC_MSG_WARN([WARNING: Size of C int: $ac_cv_sizeof_int ])
256
272
AC_MSG_WARN([WARNING: Size of C size_t: $ac_cv_sizeof_size_t ])
257
273
AC_MSG_WARN([WARNING: Size of Fortran INTEGER: $OMPI_SIZEOF_FORTRAN_INTEGER ])
258
274
AC_MSG_WARN([Could not make this work out evenly...! ])
259
275
AC_MSG_ERROR([Cannot continue])])
260
- OMPI_FORTRAN_STATUS_SIZE= $num_integers
276
+ OMPI_FORTRAN_STATUS_SIZE= $num_ints
261
277
AC_MSG_RESULT([$OMPI_FORTRAN_STATUS_SIZE Fortran INTEGERs])
262
278
AC_SUBST(OMPI_FORTRAN_STATUS_SIZE)
263
279
0 commit comments