Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29251 Discussions

Can't link to both CXML and MPICH-NT

Keith_R_
Novice
318 Views
I'm trying to port an MPI app to CVF 6.6B and running into
apparently insurmountable obstacles with calling conventions
because of incompatibility between the CXML and MPICH-NT libraries.

The problem arises because of MPICH-NT's handling of character arguments,
which my application uses. MPICH-NT documantation states:

The mpich dlls contain the following interfaces for Fortran:

1. MPI_INIT@4 - example symbol in the mpich dll

Uppercase externals using the standard calling convention with mixed string length parameters. This is the default for Visual Fortran. But, it doesn't allow passing strings to any of the message passing functions like MPI_SEND because strings cause the function signature to change. To use strings you must use the C calling convention.
2. MPI_INIT

Uppercase externals using the C calling convention with string length parameters at the end of the list. This is the default for the Intel Fortran compiler. You can also use this interface with Visual Fortran by adding the following compiler flags: /iface:cref /iface:nomixed_str_len_arg
3. mpi_init__

Lowercase double underscore externals using the C calling convention with string length parameters at the end of the argument list. This is the default for g77.

Option 3 is irrelevant.
Option 1 fails; CVF generates compile warnings and link
errors (no MPI_bcast@28) corresponding to the calls to MPI_Bcast with character arguments.

Option 2 succeeds, but the executable stops with an error in the first call to a LAPACK routine from CXML which has a character argument -- clearly /iface:cref /iface:nomixed_str_len_arg is incompatible with CXML.

I thought for a while that I might be able to set the calling conventions for just the MPI calls using
! !DEC$ ATTRIBUTES C, reference,nomixed_str_len_arg,alias:'_MPI_BCAST' :: MPI_Bcast

However CVF rejects this with:

cmpi.F90(685) : Error: Only a function or subroutine subprogram may have the !DEC$ ATTRIBUTES directive [NO]MIXED_STR_LEN_ARG specifier. [MPI_BCAST]

This is in apparent contradiction to the information in the manual.

My final attempt at solving this was to declare an INTERFACE block:
interface MPI_bcast
subroutine MPI_bcast_i(msg, len, type, rank, comm, error)
integer :: msg
integer :: len, type, rank, comm, error
!DEC$ ATTRIBUTES C,REFERENCE,NOMIXED_STR_LEN_ARG,ALIAS:'_MPI_BCAST' :: MPI_bcast_i
end subroutine MPI_bcast_i
subroutine MPI_bcast_str(msg, len, type, rank, comm, error)
character(len=*) :: msg
integer :: len, type, rank, comm, error
!DEC$ ATTRIBUTES C,REFERENCE,NOMIXED_STR_LEN_ARG,ALIAS:'_MPI_BCAST' :: MPI_bcast_str
end subroutine MPI_bcast_str
end interface

[other types ommitted, but you get the picture] . This approach did indeed succeed in getting a warning-free compile and link. But the executable hangs immediately at run-time. I assume therefore I still have the calling
convention wrong somehow.

Has anybody else succeeded in linking with both MPICH-NT and CXML in a code
which passes character data to MPI routines? If so I'd love to hear how you did it!

Keith Refson
0 Kudos
0 Replies
Reply