Commit b7cd3b72 authored by Junchao Zhang's avatar Junchao Zhang
Browse files

Update the build system to include F08 binding

This includes a configure test to check if the compiler supports F08.

No review since F08 binding is experimental now.
parent 5633c4a2
......@@ -134,6 +134,7 @@ endif BUILD_F77_BINDING
mpi_sources =
mpi_f77_sources =
mpi_fc_sources =
mpi_f08_sources =
mpi_cxx_sources =
mpi_core_sources =
......@@ -179,6 +180,9 @@ lib_lib@MPIFCLIBNAME@_la_SOURCES = $(mpi_f77_sources)
if BUILD_FC_BINDING
lib_lib@MPIFCLIBNAME@_la_SOURCES += $(mpi_fc_sources)
endif BUILD_FC_BINDING
if BUILD_F08_BINDING
lib_lib@MPIFCLIBNAME@_la_SOURCES += $(mpi_f08_sources)
endif BUILD_F08_BINDING
lib_lib@MPIFCLIBNAME@_la_LDFLAGS = $(ABIVERSIONFLAGS)
lib_lib@MPIFCLIBNAME@_la_LIBADD = lib/lib@MPILIBNAME@.la
endif BUILD_F77_BINDING
......
......@@ -685,7 +685,11 @@ if [ $do_bindings = "yes" ] ; then
elif find src/binding/fortran/use_mpi -name 'buildiface' -newer 'src/binding/fortran/use_mpi/mpi_base.f90' >/dev/null 2>&1 ; then
build_f90=yes
fi
if [ ! -s src/binding/fortran/use_mpi_f08/wrappers_c/cdesc.c ] ; then
build_f08=yes
elif find src/binding/fortran/use_mpi_f08 -name 'buildiface' -newer 'src/binding/fortran/use_mpi_f08/wrappers_c/cdesc.c' >/dev/null 2>&1 ; then
build_f08=yes
fi
fi
if [ $build_f77 = "yes" ] ; then
......@@ -702,6 +706,18 @@ if [ $do_bindings = "yes" ] ; then
( cd src/binding/fortran/use_mpi && ../mpif_h/buildiface -infile=cf90t.h -deffile=cf90tdefs)
echo "done"
fi
if [ $build_f08 = "yes" ] ; then
echo_n "Building Fortran 08 interface... "
# Top-level files
( cd src/binding/fortran/use_mpi_f08 && chmod a+x ./buildiface && ./buildiface )
# Delete the old Makefile.mk
( rm -f src/binding/fortran/use_mpi_f08/wrappers_c/Makefile.mk )
# Execute once for mpi.h.in ...
( cd src/binding/fortran/use_mpi_f08/wrappers_c && chmod a+x ./buildiface && ./buildiface ../../../../include/mpi.h.in )
# ... and once for mpio.h.in
( cd src/binding/fortran/use_mpi_f08/wrappers_c && chmod a+x ./buildiface && ./buildiface ../../../../mpi/romio/include/mpio.h.in )
echo "done"
fi
if [ ! -s src/binding/cxx/mpicxx.h ] ; then
build_cxx=yes
......
......@@ -1117,3 +1117,100 @@ if test "$pac_ccompile_ok" = "yes" ; then
rm -f pac_conftest.$OBJEXT
fi
])
AC_DEFUN([PAC_FC_2008_SUPPORT],[
AC_MSG_CHECKING([for Fortran 2008 support])
AC_LANG_PUSH([C])
f08_works=yes
AC_COMPILE_IFELSE([
AC_LANG_SOURCE(
[[
#include <ISO_Fortran_binding.h>
]],
[[
int foo_c(CFI_cdesc_t * a_desc, CFI_cdesc_t * b_desc)
{
char * a_row = (char*) a_desc->base_addr;
if (a_desc->type != CFI_type_int) { return 1; }
if (a_desc->rank != 2) { return 2; }
if (a_desc->dim[1].extent != b_desc->dim[0].extent) { return 3; }
return 0;
}
]])],[mv conftest.$OBJEXT conftest1.$OBJEXT],[f08_works=no])
AC_LANG_POP([C])
AC_LANG_PUSH([Fortran])
PAC_PUSH_FLAG([LIBS])
LIBS="conftest1.$OBJEXT $LIBS"
AC_LINK_IFELSE([
AC_LANG_SOURCE([
MODULE F08TS_MODULE
IMPLICIT NONE
! Test public, private, protected
REAL, PUBLIC :: x
REAL, PRIVATE :: y
LOGICAL, PROTECTED :: z
! Test abstract
ABSTRACT INTERFACE
SUBROUTINE user_func(x, y)
INTEGER :: x(*)
REAL :: y
END SUBROUTINE
END INTERFACE
! Test TS 29113 assumed type , assumed rank and bind(C)
INTERFACE
FUNCTION FOO(A, B, C) &
BIND(C,name="foo_c") RESULT(err)
USE, intrinsic :: iso_c_binding, ONLY : c_int
TYPE(*), DIMENSION(..) :: A, B, C
INTEGER(c_int) :: err
END FUNCTION FOO
END INTERFACE
CONTAINS
! Test TS 29113 asychronous attribute and optional
SUBROUTINE test1(buf, count, ierr)
INTEGER, ASYNCHRONOUS :: buf(*)
INTEGER :: count
INTEGER, OPTIONAL :: ierr
END SUBROUTINE
! Test procedure
SUBROUTINE test2(func)
PROCEDURE(user_func) :: func
END SUBROUTINE
END MODULE
!==============================================
PROGRAM MAIN
USE :: F08TS_MODULE, ONLY : FOO
IMPLICIT NONE
INTEGER, DIMENSION(4,4) :: A, B
INTEGER, DIMENSION(2,2) :: C
INTEGER :: ERRCODE
! Test contiguous and non-contiguous array section passing
! and linkage with C code
ERRCODE = FOO(A(1:4:2, :), B(:, 2:4:2), C)
END PROGRAM
])],[],[f08_works=no])
PAC_POP_FLAG([LIBS])
AC_LANG_POP([Fortran])
if test "$f08_works" = "yes" ; then
$1
else
$2
fi
rm -f conftest1.$OBJEXT
AC_MSG_RESULT([$f08_works])
])
......@@ -413,11 +413,12 @@ dnl We enable f77 and fc if we can find compilers for them.
dnl In addition, we check whether f77 and fc can work together.
AC_ARG_ENABLE(fortran,
[ --enable-fortran=option - Control the level of Fortran support in the MPICH implementation.
yes|all - Enable all available Fortran implementations (F77, F90)
yes|all - Enable all available Fortran implementations (F77, F90, F08)
f77 - Enable Fortran 77 support
f90 - Enable Fortran 90 support
f08 - Enable Fortran 2008 support
no|none - No Fortran support
],,enable_fortran=all)
],,[enable_fortran=f77,f90])
AC_ARG_ENABLE(f77,
AC_HELP_STRING([--enable-f77],
......@@ -674,6 +675,7 @@ save_IFS="$IFS"
IFS=","
enable_f77=no
enable_fc=no
enable_f08=no
for option in $enable_fortran ; do
case "$option" in
yes|all)
......@@ -690,6 +692,9 @@ for option in $enable_fortran ; do
f90)
enable_fc=yes
;;
f08)
enable_f08=yes
;;
*)
IFS="$save_IFS"
AC_MSG_WARN([Unknown value $option for --enable-fortran])
......@@ -2167,6 +2172,7 @@ includebuild_dir=$includebuild_dir
libbuild_dir=$libbuild_dir
bashWorks=$bashWorks)
f08_works=no
if test "$enable_fc" = "yes" ; then
if test "$enable_f77" != "yes" ; then
AC_MSG_WARN([Fortran 90 requires Fortran 77])
......@@ -2174,8 +2180,15 @@ if test "$enable_fc" = "yes" ; then
else
bindingsubsystems="$bindingsubsystems src/binding/fortran/use_mpi"
bindings="$bindings f90"
if test "$enable_f08" = "yes" ; then
f08_works=yes
elif test "$enable_f08" = "auto" ; then
PAC_FC_2008_SUPPORT([f08_works=yes],[f08_works=no])
fi
fi
fi
AM_CONDITIONAL([BUILD_F08_BINDING], [test "$f08_works" = "yes"])
if test -n "$f08_works" ; then
status_f08_works=1
......
......@@ -89,24 +89,15 @@ print $makefile_fh <<EOT;
# This file is created by script $cur_dir/buildiface
# ensure that the buildiface script ends up in the release tarball
MOD = \@FCMODEXT\@
EXTRA_DIST += $cur_dir/buildiface
mpi_f08_module_sources =
mpi_c_interface_sources =
mpi_f08_wrappers_f_sources =
pmpi_f08_wrappers_f_sources =
mpi_f08_modules =
if BUILD_F08_BINDING
EOT
print $makefile_fh "AM_FCFLAGS += \@FCINCFLAG\@$cur_dir\n\n";
print $makefile_fh "mpi_f08_module_sources += \\\n";
print $makefile_fh "mpi_f08_sources += \\\n";
@files = glob("*mpi_f08*.F90");
for (my $i=0; $i<=$#files; $i++) {
print $makefile_fh "\t$cur_dir/$files[$i]";
......@@ -117,7 +108,7 @@ for (my $i=0; $i<=$#files; $i++) {
}
}
print $makefile_fh "mpi_f08_modules += \\\n";
print $makefile_fh "mpi_f08_sources += \\\n";
@files = glob("*mpi_f08*.F90");
for (my $i=0; $i<=$#files; $i++) {
my $file = $files[$i];
......@@ -129,33 +120,27 @@ for (my $i=0; $i<=$#files; $i++) {
print $makefile_fh "modinc_HEADERS = \$(mpi_f08_modules)\n\n";
print $makefile_fh "mpi_c_interface_sources += \\\n";
print $makefile_fh "mpi_f08_sources += \\\n";
@files = glob("mpi_c_interface_*.F90");
for (my $i=0; $i<=$#files; $i++) {
print $makefile_fh "\t$cur_dir/$files[$i]";
if ($i != $#files) { print $makefile_fh " \\\n"; } else { print $makefile_fh "\n\n"; }
}
print $makefile_fh "mpi_f08_wrappers_f_sources += \\\n";
print $makefile_fh "mpi_f08_sources += \\\n";
@files = glob("$wrappers_f_dir/*.F90");
for (my $i=0; $i<=$#files; $i++) {
print $makefile_fh "\t$cur_dir/$files[$i]";
if ($i != $#files) { print $makefile_fh " \\\n"; } else { print $makefile_fh "\n\n"; }
}
print $makefile_fh "pmpi_f08_wrappers_f_sources += \\\n";
print $makefile_fh "mpi_core_sources += \\\n";
@files = glob("$pmpi_dir/*.F90");
for (my $i=0; $i<=$#files; $i++) {
print $makefile_fh "\t$cur_dir/$files[$i]";
if ($i != $#files) { print $makefile_fh " \\\n"; } else { print $makefile_fh "\n\n"; }
}
print $makefile_fh "lib_lib\@MPILIBNAME\@_la_SOURCES += \\
\$(mpi_f08_module_sources) \\
\$(mpi_c_interface_sources) \\
\$(mpi_f08_wrappers_f_sources) \\
\$(pmpi_f08_wrappers_f_sources)\n\n";
print $makefile_fh "include \$(top_srcdir)/src/binding/fortran/use_mpi_f08/wrappers_c/Makefile.mk\n\n";
print $makefile_fh "endif BUILD_F08_BINDING\n";
......
......@@ -42,6 +42,7 @@ my @argbits;
my $num_dtypes;
my @dtype_bind;
my $io_header;
my $make_exists = 0;
my %inplace = ('MPI_Allgather' => 0,
'MPI_Allgatherv' => 0,
......@@ -162,8 +163,9 @@ int cdesc_create_dtype(CFI_cdesc_t *cdesc, MPI_Datatype oldtype, MPI_Datatype *n
EOT
close OUTFD;
open(MAKEFD, ">Makefile.mk") || die "Could not open Makefile.mk\n";
print MAKEFD <<EOT;
unless (-e "Makefile.mk") {
open(MAKEFD, ">Makefile.mk") || die "Could not open Makefile.mk\n";
print MAKEFD <<EOT;
## DO NOT EDIT
## This file created by buildiface
##
......@@ -172,10 +174,13 @@ print MAKEFD <<EOT;
# ensure that the buildiface script ends up in the release tarball
EXTRA_DIST += src/binding/fortran/use_mpi_f08/wrappers_c/buildiface
mpi_f08_sources =
if BUILD_F08_BINDING
mpi_f08_sources += \\
EOT
} else {
open(MAKEFD, ">>Makefile.mk") || die "Could not open Makefile.mk\n";
$make_exists = 1;
}
# if the Nth datatype does not correspond to the Nth void* buffer, set
# the correct binding here. A value of "2:4" means that the first
......
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