-
Notifications
You must be signed in to change notification settings - Fork 902
f08: do not BIND(C) to subroutines with LOGICAL parameters #1327
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
f08: do not BIND(C) to subroutines with LOGICAL parameters #1327
Conversation
Thanks Paul Romano for reporting this issue.
This kinda sucks; does it mean that mpi_f08 is busted in 1.10.2? If so, how did it make past testing? :-( |
@jsquyres can you have a look at this ? i simply removed that being said, i am not convinced this is very clean ... yes, f08 is busted ... |
@jsquyres the issue also occurs when using gcc 5.2.0 and using the it is currently not possible to build use-mpi-f08 with the diff --git a/ompi/mpi/fortran/use-mpi-f08/Makefile.am b/ompi/mpi/fortran/use-mpi-f08/Makefile.am
index b5ec769..daaafb0 100644
--- a/ompi/mpi/fortran/use-mpi-f08/Makefile.am
+++ b/ompi/mpi/fortran/use-mpi-f08/Makefile.am
@@ -27,7 +27,7 @@ AM_FCFLAGS = -I$(top_builddir)/ompi/include \
-I$(top_srcdir)/ompi/include \
$(OMPI_FC_MODULE_FLAG)$(top_builddir)/ompi/$(OMPI_FORTRAN_USEMPI_DIR) \
$(OMPI_FC_MODULE_FLAG). \
- -I$(top_srcdir) $(FCFLAGS_f90)
+ -I$(top_srcdir) $(FCFLAGS_f90) -std=f2008
MOSTLYCLEANFILES = *.mod
at this stage, my best bet is to update the mtt trivial test suite, and use makes sense ? |
Adding @paulromano. |
@ggouaillardet Please add "Fixes #1323" in the commit message. |
@ggouaillardet If you remind the BIND(C) to bind these mpi_f08 interfaces to Fortran functions, don't we then have to provide implementations of these interfaces? Put differently: since, for example, the |
if we do that, the mpif08 library will define a mpi_comm_null_copy_fn symbol (modulo the compiler mangling). will this be an issue since this symbol is also defined in an other MPI library ? |
@ggouaillardet Gah -- I missed your above comment (#1327 (comment)) where you said the same thing that I just did. So, yes, without BIND(C), it works -- kinda by accident. Technically, it's a hack -- the MPI_COMM_NULL_COPY_FN, for example, takes different types between mpif.h/mpi and mpi_f08 (int vs. Type(MPI_Comm) handle). But in reality, they're both the same size under the covers (i.e., a single INTEGER). So... it should work out. But it's sketchy. And even if it works today, I don't know if we want to rely on that hack. There's therefore 2 problems here:
I think that we can implement this the Right way by using an INTERFACE block to make the compiler names be the MPI-mandated names (e.g., MPI_COMM_NULL_COPY_FN), but make the back-end symbol be something else (e.g., ompi_comm_null_copy_fn_f08). I see that there's an extraneous INTERFACE / END INTERFACE in attr-fn-f08-callback-interfaces.h -- that will likely need to be removed / replaced with individual INTERFACE blocks and names. The problem then becomes how to maintain the ABI for the v1.10.x series. Perhaps the hack described above (i.e., just remove BIND(C)'s and let the compiler, linker, and God sort it all out). Since the v1.10.x series has a limited life left in it, that might be Good Enough (although we should put a good comment in the v1.10 fix such that Future Gilles and Future Jeff can remember why we did this, and what the pitfalls are). And then on master / v2.x, we fix this properly (with INTERFACE blocks). How does that sound? |
will it work when mpi_comm_null_copy_fn is passed as a parameter of mpi_comm_create_keyval ? if yes, then that sounds good to me. |
Yes. I.e., the name that mpi_f08 exports to the Fortran application will be MPI_COMM_NULL_COPY_FN, but the symbol used under the covers will be ompi_comm_null_copy_fn_f08. If an application has both mpif.h/mpi module and mpi_f08 module usage, then there should be 2 different symbols for old-style-MPI_COMM_NULL_COPY_FN (and friends) and new-style-MPI_COMM_NULL_COPY_FN. So there should be no problem. |
@jsquyres module callback
ABSTRACT INTERFACE
SUBROUTINE cb(v)
INTEGER :: v
END SUBROUTINE cb
END INTERFACE
end module callback
module f90
contains
subroutine xxx(v)
use callback
implicit none
INTEGER :: v
v = 90
end subroutine xxx
end module f90
module f08
interface xxx
subroutine xxx_f08(v)
INTEGER :: v
end subroutine xxx_f08
end interface xxx
end module f08
subroutine xxx_f08(v)
INTEGER :: v
v = 2008
end subroutine xxx_f08
subroutine bar(p)
use callback
implicit none
integer :: v
procedure(cb) :: p
call p(v)
write (*,*) v
end subroutine bar
subroutine test_f90
use callback
use f90
implicit none
integer :: v
call xxx(v)
write (*,*) 'test_f90 returns ', v
call bar(xxx)
end subroutine test_f90
subroutine test_f08
use callback
use f08
implicit none
integer :: v
call xxx(v)
write (*,*) 'test_f08 returns ', v
!call bar(xxx)
end subroutine test_f08
program test
implicit none
call test_f90
call test_f08
end program test in with fortran 5.3, it compiles and works, but if i uncomment the call to
to me, that makes some kind of sense. the only option i know, so the symbol for there might be an other way, but i am not aware of it any thoughts ? and by the way, is there a way to tell Fortran that |
Ok, this is a pickle, then. 👍 |
f08: do not BIND(C) to subroutines with LOGICAL parameters
Actually, it looks like MPI-3.1 addresses this issue directly -- see MPI-3.1 p270 5-19:
@ggouaillardet Do you want to take a whack at this? |
i will have a look at this |
coll/hcoll: Fixes predifined types mapping
Thanks Paul Romano for reporting this issue.