[MPI3 Fortran] [Mpi-comments] MPI 3.0:Fortran 2008 interface - issue with the LOGICAL kind

Bill Long longb at cray.com
Fri Mar 15 15:15:26 CDT 2013



On 3/15/13 1:19 PM, Hubert Ritzdorf wrote:
> Hi,
>
> I'm still developing MPI and I'm also implementing the mpi_f08 module.
> My concern in connection with BIND(C) are the routines which use
> character strings (for example MPI_Error_string())..
> My Intel compiler aborts the compilation for these functions with
>
> A character dummy argument with length other than 1 is not interoperable

Right. gfortran does the same.  In the interface at 349:14-19, the 
BIND(C) is not compatible with specifying a LEN for the character 
argument greater than 1.

I am not using BIND(C) in the Fortran wrapper definitions.  I'm using 
349:14-19 as printed except with the BIND(C) deleted.  In the 
corresponding interface block for the actual C function in the library, 
the declaration is a character(1)  array string(*).  Here are the texts:

Interface for C function (from 349:13)

interface  !--> MPI_Error_string

    !     int MPI_Error_string (int errorcode, char *string, int 
*resultlen);

    function MPI_Error_string_C (errorcode, string, resultlen) &
               BIND(C, name="MPI_Error_string") RESULT (res)
      import :: c_int, c_char
      integer(c_int),value,intent(in)    :: errorcode
      character(kind=c_char),intent(out) :: string(*)
      integer(c_int),intent(out)         :: resultlen
      integer(c_int)                     :: res
    end function MPI_Error_string_C
end interface


Fortran wrapper:

!--> MPI_Error_string

subroutine MPI_Error_string (errorcode, string, resultlen, ierror)
      use :: mpi_C_interfaces_nobuf, only: c_char, MPI_Error_string_C
      INTEGER,                              INTENT(IN) :: errorcode
      CHARACTER(LEN=MPI_MAX_ERROR_STRING), INTENT(OUT) :: string
      INTEGER,                             INTENT(OUT) :: resultlen
      INTEGER, OPTIONAL,                   INTENT(OUT) :: ierror
      integer(c_int) :: errorcode_c
      integer(c_int) :: resultlen_C
      integer(c_int) :: res

      errorcode_c = errorcode
      res = MPI_Error_string_C (errorcode_c, string, resultlen_c)
      resultlen = resultlen_c
      if (present(ierror)) ierror = res

end subroutine MPI_Error_string


This seems to work - at least it compiles with no errors with 2 
different compilers.

>
> I think, that this is correct (but I possibly missed some info on future changes in TSxxxxx).
> (Nick mentioned in a previous e-mail:
>   "(C) Default CHARACTER is supported only if KIND(' ') is equal to
>          C_CHAR.  However, that will almost certainly be the case."
>   I don't know whether this statement fits to the error message above.
> But almost was true also for the LOGICAL case).
> Or is this another class of routines which don't support BIND(C) ?
>
> What's about future developments in C and Fortran ?

The Fortran committee operates under the assumption that it cannot 
require (or even influence) changes in the C standard.   The list of C 
types for which interoperability is supported is fairly limited. There 
is an assumption that the C standard will not change the meanings of 
these types, but if they do, and Fortran chooses to be compatible with 
that new C standard, then the changes would be in Fortran. Fortran 2008 
specifies C99 as the C standard for purposes of the interoperability 
feature.  For the TS, everything that is not native to C (the include 
file and specified functions) all have to be supplied by the Fortran vendor.

Cheers,
Bill


> May they generate new problems for BIND(C)
> or less problems (i.e. is there a coordinated standardization effort between Fortran and C
> in order to reduce the interoperability problems) ?
>
> Hubert
>


-- 
Bill Long                                           longb at cray.com
Fortran Technical Support    &                 voice: 651-605-9024
Bioinformatics Software Development            fax:   651-605-9142
Cray Inc./Cray Plaza, Suite 210/380 Jackson St./St. Paul, MN 55101





More information about the mpiwg-fortran mailing list