Commit 4f3a05d0 authored by Junchao Zhang's avatar Junchao Zhang
Browse files

Revise F08 binding build system



Module files are now only produced under use_mpi_f08 subdirectory.
Also, it now auto-detects cases of names and extensions of module files,
which are compiler-dependant.

Fixes #2163
Signed-off-by: Kenneth Raffenetti's avatarKen Raffenetti <raffenet@mcs.anl.gov>
parent 1e2e1328
......@@ -187,6 +187,7 @@ Makefile.am-stamp
/src/binding/fortran/use_mpi/mpi_base.mod-stamp
/src/binding/fortran/use_mpi/mpi_constants.mod-stamp
/src/binding/fortran/use_mpi/mpi_sizeofs.mod-stamp
/src/binding/fortran/use_mpi_f08/*.stamp
/src/mpe2/src/callstack/bin/bt2line
......
......@@ -2200,6 +2200,20 @@ MPIMODNAME=mpi
MPICONSTMODNAME=mpi_constants
MPISIZEOFMODNAME=mpi_sizeofs
MPIBASEMODNAME=mpi_base
# F08 binding stuff
MPI_F08_LINK_CONSTANTS_NAME=mpi_f08_link_constants
PMPI_F08_NAME=pmpi_f08
MPI_F08_CALLBACKS_NAME=mpi_f08_callbacks
MPI_C_INTERFACE_NAME=mpi_c_interface
MPI_C_INTERFACE_GLUE_NAME=mpi_c_interface_glue
MPI_F08_TYPES_NAME=mpi_f08_types
MPI_C_INTERFACE_NOBUF_NAME=mpi_c_interface_nobuf
MPI_F08_COMPILE_CONSTANTS_NAME=mpi_f08_compile_constants
MPI_F08_NAME=mpi_f08
MPI_C_INTERFACE_TYPES_NAME=mpi_c_interface_types
MPI_C_INTERFACE_CDESC_NAME=mpi_c_interface_cdesc
if test "$enable_fc" = "yes" ; then
# determine rpath and other shared library flags for FC
fc_shlib_conf=src/env/fc_shlib.conf
......@@ -2250,17 +2264,51 @@ if test "$enable_fc" = "yes" ; then
MPICONSTMODNAME=MPI_CONSTANTS
MPISIZEOFMODNAME=MPI_SIZEOFS
MPIBASEMODNAME=MPI_BASE
MPI_F08_NAME=MPI_F08
MPI_F08_LINK_CONSTANTS_NAME=MPI_F08_LINK_CONSTANTS
MPI_F08_CALLBACKS_NAME=MPI_F08_CALLBACKS
MPI_F08_TYPES_NAME=MPI_F08_TYPES
MPI_F08_COMPILE_CONSTANTS_NAME=MPI_F08_COMPILE_CONSTANTS
PMPI_F08_NAME=PMPI_F08
MPI_C_INTERFACE_NAME=MPI_C_INTERFACE
MPI_C_INTERFACE_NOBUF_NAME=MPI_C_INTERFACE_NOBUF
MPI_C_INTERFACE_GLUE_NAME=MPI_C_INTERFACE_GLUE
MPI_C_INTERFACE_TYPES_NAME=MPI_C_INTERFACE_TYPES
MPI_C_INTERFACE_CDESC_NAME=MPI_C_INTERFACE_CDESC
else
MPIMODNAME=mpi
MPICONSTMODNAME=mpi_constants
MPISIZEOFMODNAME=mpi_sizeofs
MPIBASEMODNAME=mpi_base
MPI_F08_NAME=mpi_f08
MPI_F08_LINK_CONSTANTS_NAME=mpi_f08_link_constants
MPI_F08_CALLBACKS_NAME=mpi_f08_callbacks
MPI_F08_TYPES_NAME=mpi_f08_types
MPI_F08_COMPILE_CONSTANTS_NAME=mpi_f08_compile_constants
PMPI_F08_NAME=pmpi_f08
MPI_C_INTERFACE_NAME=mpi_c_interface
MPI_C_INTERFACE_NOBUF_NAME=mpi_c_interface_nobuf
MPI_C_INTERFACE_GLUE_NAME=mpi_c_interface_glue
MPI_C_INTERFACE_TYPES_NAME=mpi_c_interface_types
MPI_C_INTERFACE_CDESC_NAME=mpi_c_interface_cdesc
fi
AC_SUBST(MPIMODNAME)
AC_SUBST(MPICONSTMODNAME)
AC_SUBST(MPISIZEOFMODNAME)
AC_SUBST(MPIBASEMODNAME)
AC_SUBST(MPI_F08_NAME)
AC_SUBST(MPI_F08_LINK_CONSTANTS_NAME)
AC_SUBST(MPI_F08_CALLBACKS_NAME)
AC_SUBST(MPI_F08_TYPES_NAME)
AC_SUBST(MPI_F08_COMPILE_CONSTANTS_NAME)
AC_SUBST(PMPI_F08_NAME)
AC_SUBST(MPI_C_INTERFACE_NAME)
AC_SUBST(MPI_C_INTERFACE_NOBUF_NAME)
AC_SUBST(MPI_C_INTERFACE_GLUE_NAME)
AC_SUBST(MPI_C_INTERFACE_TYPES_NAME)
AC_SUBST(MPI_C_INTERFACE_CDESC_NAME)
# Assume that all Fortran 90 compilers accept -I for include directories
FCINC=-I
AC_SUBST(FCINC)
......
......@@ -93,7 +93,7 @@ open($makefile_fh, ">", $makefile) || die "Error: Could not open $makefile, $!";
print $makefile_fh <<EOT;
# -*- Mode: Makefile; -*-
#
# (C) 2014 by Argonne National Laboratory.
# (C) 2015 by Argonne National Laboratory.
# See COPYRIGHT in top-level directory.
#
# AUTOGENERATED! DO NOT EDIT!
......@@ -107,9 +107,23 @@ if BUILD_F08_BINDING
EOT
print $makefile_fh "AM_FCFLAGS += \@FCINCFLAG\@src/binding/fortran/use_mpi\n\n";
# Module dependence chain
my %f08_mods = (
"mpi_c_interface" => "mpi_c_interface_cdesc",
"mpi_c_interface_cdesc" => "mpi_c_interface_nobuf",
"mpi_c_interface_nobuf" => "mpi_c_interface_glue",
"mpi_c_interface_glue" => "mpi_f08",
"mpi_f08" => "pmpi_f08",
"pmpi_f08" => "mpi_f08_link_constants",
"mpi_f08_link_constants" => "mpi_f08_callbacks",
"mpi_f08_callbacks" => "mpi_f08_compile_constants",
"mpi_f08_compile_constants" => "mpi_f08_types",
"mpi_f08_types" => "mpi_c_interface_types",
"mpi_c_interface_types" => "",
);
print $makefile_fh <<EOT;
AM_FCFLAGS += \@FCINCFLAG\@src/binding/fortran/use_mpi_f08
mpi_fc_sources += \\
src/binding/fortran/use_mpi_f08/pmpi_f08.f90 \\
......@@ -122,82 +136,67 @@ mpi_fc_sources += \\
src/binding/fortran/use_mpi_f08/mpi_c_interface_cdesc.f90 \\
src/binding/fortran/use_mpi_f08/mpi_c_interface_glue.f90 \\
src/binding/fortran/use_mpi_f08/mpi_c_interface_nobuf.f90 \\
src/binding/fortran/use_mpi_f08/mpi_c_interface_types.f90 \\
src/binding/fortran/use_mpi/pmpi_f08.\$(MOD) \\
src/binding/fortran/use_mpi/mpi_f08.\$(MOD) \\
src/binding/fortran/use_mpi/mpi_f08_callbacks.\$(MOD) \\
src/binding/fortran/use_mpi/mpi_f08_compile_constants.\$(MOD) \\
src/binding/fortran/use_mpi/mpi_f08_link_constants.\$(MOD) \\
src/binding/fortran/use_mpi/mpi_f08_types.\$(MOD)
src/binding/fortran/use_mpi_f08/mpi_c_interface_types.f90
EOT
print $makefile_fh "mpi_fc_modules += src/binding/fortran/use_mpi/mpi_f08.\$(MOD)\n\n";
my %f08_mods = (
"mpi_c_interface" => "mpi_c_interface_cdesc",
"mpi_c_interface_cdesc" => "mpi_c_interface_nobuf",
"mpi_c_interface_nobuf" => "mpi_c_interface_glue",
"mpi_c_interface_glue" => "mpi_f08",
"mpi_f08" => "pmpi_f08",
"pmpi_f08" => "mpi_f08_link_constants",
"mpi_f08_link_constants" => "mpi_f08_callbacks",
"mpi_f08_callbacks" => "mpi_f08_compile_constants",
"mpi_f08_compile_constants" => "mpi_f08_types",
"mpi_f08_types" => "mpi_c_interface_types",
"mpi_c_interface_types" => "",
);
mpi_fc_modules += src/binding/fortran/use_mpi_f08/\$(MPI_F08_NAME).\$(MOD)
print $makefile_fh "BUILT_SOURCES += ";
foreach my $x (keys %f08_mods) {
print $makefile_fh "src/binding/fortran/use_mpi/$x.\$(MOD) ";
}
print $makefile_fh "\n\n";
EOT
print $makefile_fh "CLEANFILES += ";
print $makefile_fh "f08_module_files =";
foreach my $x (keys %f08_mods) {
print $makefile_fh "src/binding/fortran/use_mpi/$x.\$(MOD) ";
my $DOLLARX = "\$(".uc($x)."_NAME)"; # Convert to $(X_NAME) for later substitution by configure
print $makefile_fh " \\\n src/binding/fortran/use_mpi_f08/$DOLLARX.\$(MOD)";
}
print $makefile_fh "\n\n";
foreach my $x (keys %f08_mods) {
print $makefile_fh "src/binding/fortran/use_mpi/$x.\$(MOD) src/binding/fortran/use_mpi_f08/$x.lo:";
if ($f08_mods{$x}) {print $makefile_fh " src/binding/fortran/use_mpi/$f08_mods{$x}.\$(MOD)";}
print $makefile_fh "\n";
print $makefile_fh "\t\$(mod_verbose)\$(FC_COMPILE_MODS) -c src/binding/fortran/use_mpi_f08/`echo \$\@ | cut -f1 -d '.' | sed -e 's+.*/++g'`.f90 -o src/binding/fortran/use_mpi_f08/`echo \$\@ | cut -f1 -d '.' | sed -e 's+.*/++g'`.lo\n\n";
}
print $makefile_fh "BUILT_SOURCES += \$(f08_module_files)\n";
print $makefile_fh "CLEANFILES += \$(f08_module_files)\n\n";
print $makefile_fh "mpi_fc_sources += \\\n";
@files = glob("$wrappers_f_dir/*.f90");
@files = glob("$wrappers_f_dir/*.f90 $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"; }
}
for (my $i=0; $i<=$#files; $i++) {
my $fname = $files[$i];
$fname =~ s/\.f90/.lo/g;
print $makefile_fh "$cur_dir/$fname: src/binding/fortran/use_mpi/mpi_f08.\$(MOD) src/binding/fortran/use_mpi/mpi_c_interface.\$(MOD)\n\n";
}
# Don't reuse FC_COMPILE_MODS since it has its own FCMODOUTFLAG directory
print $makefile_fh "F08_COMPILE_MODS = \$(LTFCCOMPILE)\n";
print $makefile_fh "F08_COMPILE_MODS += \$(FCMODOUTFLAG)src/binding/fortran/use_mpi_f08\n\n";
print $makefile_fh "mpi_fc_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"; }
}
# Generate module files using multi-ouput automake rules.
# We need to compile modules according to dependency given in %f08_mods
foreach my $x (keys %f08_mods) {
my $DOLLARX = "\$(".uc($x)."_NAME)";
print $makefile_fh "src/binding/fortran/use_mpi_f08/$x.stamp: src/binding/fortran/use_mpi_f08/$x.f90";
if ($f08_mods{$x}) { print $makefile_fh " src/binding/fortran/use_mpi_f08/$f08_mods{$x}.stamp"; }
print $makefile_fh "\n";
for (my $i=0; $i<=$#files; $i++) {
my $fname = $files[$i];
$fname =~ s/\.f90/.lo/g;
print $makefile_fh "$cur_dir/$fname: src/binding/fortran/use_mpi/mpi_f08.\$(MOD) src/binding/fortran/use_mpi/mpi_c_interface.\$(MOD)\n\n";
print $makefile_fh <<EOT;
\t\@rm -f src/binding/fortran/use_mpi_f08/$x.tmp
\t\@touch src/binding/fortran/use_mpi_f08/$x.tmp
\t\$(mod_verbose)\$(F08_COMPILE_MODS) -c src/binding/fortran/use_mpi_f08/$x.f90 -o src/binding/fortran/use_mpi_f08/$x.lo
\t\@mv src/binding/fortran/use_mpi_f08/$x.tmp src/binding/fortran/use_mpi_f08/$x.stamp
src/binding/fortran/use_mpi_f08/$DOLLARX.\$(MOD) src/binding/fortran/use_mpi_f08/$x.lo : src/binding/fortran/use_mpi_f08/$x.stamp
\t\@if test -f \$@; then :; else \\
\t trap 'rm -rf src/binding/fortran/use_mpi_f08/$x-lock src/binding/fortran/use_mpi_f08/$x.stamp' 1 2 13 15; \\
\t if mkdir src/binding/fortran/use_mpi_f08/$x-lock 2>/dev/null; then \\
\t rm -f src/binding/fortran/use_mpi_f08/$x.stamp; \\
\t \$(MAKE) \$(AM_MAKEFLAGS) src/binding/fortran/use_mpi_f08/$x.stamp; \\
\t rmdir src/binding/fortran/use_mpi_f08/$x-lock; \\
\t else \\
\t while test -d src/binding/fortran/use_mpi_f08/$x-lock; do sleep 1; done; \\
\t test -f src/binding/fortran/use_mpi_f08/$x.stamp; exit \$\$?; \\
\t fi; \\
\tfi
CLEANFILES += src/binding/fortran/use_mpi_f08/$DOLLARX.\$(MOD) \\
src/binding/fortran/use_mpi_f08/$x.lo \\
src/binding/fortran/use_mpi_f08/$x.stamp \\
src/binding/fortran/use_mpi_f08/$x.tmp
EOT
}
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";
close($makefile_fh);
# Stage 4: Call script in ./wrappers_c to generate C wrappers for subarrays
# =====================================================================
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