Commit 4309ba57 authored by Junchao Zhang's avatar Junchao Zhang
Browse files

Enhance F08 buildiface to auto-set int kinds of c_Ain/Count/Offset



We now auto-generate mpi_c_interface_types.f90

Fixes #2196
Signed-off-by: Kenneth Raffenetti's avatarKen Raffenetti <raffenet@mcs.anl.gov>
parent de659b67
......@@ -435,6 +435,8 @@ Makefile.am-stamp
/src/binding/fortran/use_mpi_f08/pmpi_f08.f90
/src/binding/fortran/use_mpi_f08/mpi_f08_compile_constants.f90
/src/binding/fortran/use_mpi_f08/mpi_f08_compile_constants.f90.in
/src/binding/fortran/use_mpi_f08/mpi_c_interface_types.f90
/src/binding/fortran/use_mpi_f08/mpi_c_interface_types.f90.in
/src/binding/fortran/use_mpi_f08/wrappers_f/profiling/*.f90
......
......@@ -6229,6 +6229,31 @@ if test "X$f08_works" = "Xyes"; then
AC_SUBST(F08_CXX_FLOAT_COMPLEX)
AC_SUBST(F08_CXX_DOUBLE_COMPLEX)
AC_SUBST(F08_CXX_LONG_DOUBLE_COMPLEX)
AS_CASE([$MPI_AINT],
[short], [F08_C_AINT="c_short"],
[int], [F08_C_AINT="c_int"],
[long], [F08_C_AINT="c_long"],
['long long'], [F08_C_AINT="c_long_long"],
[AC_MSG_ERROR([unable to determine C MPI_AINT type in Fortran 2008])])
AS_CASE([$MPI_COUNT],
[short], [F08_C_COUNT="c_short"],
[int], [F08_C_COUNT="c_int"],
[long], [F08_C_COUNT="c_long"],
['long long'], [F08_C_COUNT="c_long_long"],
[AC_MSG_ERROR([unable to determine C MPI_COUNT type in Fortran 2008])])
AS_CASE([$MPI_OFFSET],
[short], [F08_C_OFFSET="c_short"],
[int], [F08_C_OFFSET="c_int"],
[long], [F08_C_OFFSET="c_long"],
['long long'], [F08_C_OFFSET="c_long_long"],
[AC_MSG_ERROR([unable to determine C MPI_OFFSET type in Fortran 2008])])
AC_SUBST(F08_C_AINT)
AC_SUBST(F08_C_COUNT)
AC_SUBST(F08_C_OFFSET)
fi
########################################################################
......@@ -6258,6 +6283,7 @@ AC_OUTPUT(Makefile \
src/binding/fortran/use_mpi/mpi_base.f90 \
src/binding/fortran/use_mpi/mpi_constants.f90 \
src/binding/fortran/use_mpi_f08/mpi_f08_compile_constants.f90 \
src/binding/fortran/use_mpi_f08/mpi_c_interface_types.f90 \
src/packaging/pkgconfig/mpich.pc \
src/packaging/envmods/mpich.module \
src/env/mpixxx_opts.conf \
......
......@@ -689,3 +689,72 @@ print $constants_fh "end module mpi_f08_compile_constants\n";
close($constants_fh);
&ReplaceIfDifferent("mpi_f08_compile_constants.f90.in", "mpi_f08_compile_constants.f90.in.new");
# Stage 5: Generate mpi_c_interface_types.f90.in
# =====================================================================
my $ctypes_file = "mpi_c_interface_types.f90.in.new";
my $ctypes_fh;
open($ctypes_fh, ">", $ctypes_file) || die "Error: Could not open $ctypes_file, $!";
print $ctypes_fh <<EOT;
! -*- Mode: Fortran; -*-
!
! (C) 2014 by Argonne National Laboratory.
! See COPYRIGHT in top-level directory.
!
! Module mpi_c_interface_types is a helper module used by the modules
! specifying c interfaces:
!
! mpi_c_interface_cdesc - interfaces for MPI functions with a descriptor argument
! mpi_c_interface_nobuf - interfaces for MPI functions with no choice argument
!
! MPICH C interface uses integer for handles and status type.
! It is not defined in the spec and not intended for end users.
!--------------------------------------------------------------
module mpi_c_interface_types
use, intrinsic :: iso_c_binding
implicit none
integer,parameter :: c_Fint = KIND(0)
integer,parameter :: c_Aint = \@F08_C_AINT\@
integer,parameter :: c_Count = \@F08_C_COUNT\@
integer,parameter :: c_Offset = \@F08_C_OFFSET\@
!=============================================================
! Kinds for handle types in C prototypes; should match mpi.h
!=============================================================
integer,parameter :: c_Datatype = c_int
integer,parameter :: c_Comm = c_int
integer,parameter :: c_Group = c_int
integer,parameter :: c_Win = c_int
integer,parameter :: c_Op = c_int
integer,parameter :: c_Info = c_int
integer,parameter :: c_Errhandler = c_int
integer,parameter :: c_Request = c_int
integer,parameter :: c_Message = c_int
integer,parameter :: c_File = c_intptr_t
!================================================
! C struct for STATUS values; should match mpi.h
!================================================
! MPI_Status, with name changed to c_Status for internal disambiguation
! A.1.2 p 676
type, bind(c) :: c_Status
integer(c_int) :: count_lo
integer(c_int) :: count_hi_and_cancelled
integer(c_int) :: MPI_SOURCE
integer(c_int) :: MPI_TAG
integer(c_int) :: MPI_ERROR
end type c_Status
end module mpi_c_interface_types
EOT
close($ctypes_fh);
&ReplaceIfDifferent("mpi_c_interface_types.f90.in", "mpi_c_interface_types.f90.in.new");
! -*- Mode: Fortran; -*-
!
! (C) 2014 by Argonne National Laboratory.
! See COPYRIGHT in top-level directory.
!
! mpich3 integer sizes for handles and status type
!
! Module mpi_c_interface_types is a helper module used by the modules
! specifying c interfaces:
!
! mpi_c_interface_cdesc - interfaces for MPI functions with a descriptor argument
! mpi_c_interface_nobuf - interfaces for MPI functions with no choice argument
!
! It is not defined in the spec and not intended for end users.
!--------------------------------------------------------------
module mpi_c_interface_types
!=========================
! Kinds for native C types
!=========================
use,intrinsic :: iso_c_binding, only: c_int, c_long, c_long_long, &
c_ptr, c_double, C_NULL_PTR, &
c_char, c_intptr_t , c_sizeof
implicit none
!=============================================================
! Kinds for integer types in C prototypes; should match mpi.h
!=============================================================
! C types (with MPI_ => c_ for the internal names here)
! A.1.2 p 676
!Extracted from 'grep typedef mpi.h'
!typedef int MPI_Datatype;
!typedef int MPI_Comm;
!typedef int MPI_Group;
!typedef int MPI_Win;
!typedef int MPI_Op;
!typedef int MPI_Errhandler;
!typedef int MPI_Request;
!typedef int MPI_Message;
!typedef int MPI_Info;
!typedef long MPI_Aint;
!typedef int MPI_Fint; ! replaced above with compiler-flag dependent value
!typedef long long MPI_Count;
!typedef long long MPI_Offset;
integer,parameter :: c_Fint = KIND(0)
! TODO: need to automatically set these three parameters as in mpi.h.in
integer,parameter :: c_Aint = c_long
integer,parameter :: c_Count = c_long_long
integer,parameter :: c_Offset = c_long_long
integer,parameter :: c_Datatype = c_int
integer,parameter :: c_Comm = c_int
integer,parameter :: c_Group = c_int
integer,parameter :: c_Win = c_int
integer,parameter :: c_Op = c_int
integer,parameter :: c_Info = c_int
integer,parameter :: c_Errhandler = c_int
integer,parameter :: c_Request = c_int
integer,parameter :: c_Message = c_int
integer,parameter :: c_file = c_intptr_t
!================================================
! C struct for STATUS values; should match mpi.h
!================================================
! MPI_Status, with name changed to c_Status for internal disambiguation
! A.1.2 p 676
type, bind(c) :: c_Status
integer(c_int) :: count_lo
integer(c_int) :: count_hi_and_cancelled
integer(c_int) :: MPI_SOURCE
integer(c_int) :: MPI_TAG
integer(c_int) :: MPI_ERROR
end type c_Status
end module mpi_c_interface_types
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment