1
1

Bunches of things with respect to F90, mainly resulting from work on

Monday with Craig:
- split two f90 modules into two separate .f90 files so that
  dependencies can be satisfied properly in parallel builds (i.e.,
  mpi_kinds.f90 can be compiled and its f90 module can be generated
  before any others are compiled, because it is needed by all of the
  other f90 source files).
- rename mpi.i.h* to be mpi-f90-interfaces.h, just to be a little more
  clear and less name-confusing with mpi.h and mpif.h
- update the build process in src/mpi/f90, including printing out a
  warning that compiling mpi.f90 may take quite a while :-\
- update the wrapper compilers to add in the Right Things for
  compiling F90 MPI applications
- add a check in configure to find what flag the F90 compiler uses to
  identify where f90 module files live

This commit was SVN r5297.
Этот коммит содержится в:
Jeff Squyres 2005-04-13 11:54:36 +00:00
родитель 815664c57e
Коммит 87fce5c2a6
17 изменённых файлов: 218 добавлений и 61 удалений

Просмотреть файл

@ -35,6 +35,7 @@ sinclude(config/f77_get_fortran_handle_max.m4)
sinclude(config/f77_get_sizeof.m4)
sinclude(config/f90_check_type.m4)
sinclude(config/f90_find_module_include_flag.m4)
sinclude(config/f90_get_alignment.m4)
sinclude(config/f90_get_precision.m4)
sinclude(config/f90_get_range.m4)

Просмотреть файл

@ -29,6 +29,7 @@ EXTRA_DIST = \
f77_get_alignment.m4 \
f77_get_sizeof.m4 \
f90_check_type.m4 \
f90_find_module_include_flag.m4 \
f90_get_alignment.m4 \
f90_get_precision.m4 \
f90_get_range.m4 \

80
config/f90_find_module_include_flag.m4 Обычный файл
Просмотреть файл

@ -0,0 +1,80 @@
dnl -*- shell-script -*-
dnl
dnl Copyright (c) 2004-2005 The Trustees of Indiana University.
dnl All rights reserved.
dnl Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
dnl All rights reserved.
dnl Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
dnl University of Stuttgart. All rights reserved.
dnl Copyright (c) 2004-2005 The Regents of the University of California.
dnl All rights reserved.
dnl $COPYRIGHT$
dnl
dnl Additional copyrights may follow
dnl
dnl $HEADER$
dnl
AC_DEFUN([OMPI_F90_FIND_MODULE_INCLUDE_FLAG],[
AC_MSG_CHECKING([for FORTRAN compiler module include flag])
possible_flags="-I -p -M"
mkdir conftest.$$
cd conftest.$$
#
# Try to compile an F90 module
#
mkdir subdir
cd subdir
cat > conftest-module.f90 <<EOF
module OMPI_MOD_FLAG
type OMPI_MOD_FLAG_TYPE
integer :: i
end type OMPI_MOD_FLAG_TYPE
end module OMPI_MOD_FLAG
EOF
OMPI_LOG_COMMAND([$FC $FCFLAGS $FCFLAGS_f90 -c conftest-module.f90], ,
AC_MSG_RESULT([Whoops!])
AC_MSG_WARN([*** Cannot seem to compile an f90 module])
AC_MSG_ERROR([Cannot continue]))
cd ..
#
# Now try to compile a simple program usinng that module, iterating
# through the possible flags that the compiler might use
#
cat > conftest.f90 <<EOF
program main
use OMPI_MOD_FLAG
end program main
EOF
OMPI_FC_MODULE_FLAG=
for flag in $possible_flags; do
if test "$OMPI_FC_MODULE_FLAG" = ""; then
OMPI_LOG_COMMAND([$FC $FCFLAGS $FCFLAGS_f90 conftest.f90 $flag subdir],
[OMPI_FC_MODULE_FLAG="$flag"])
fi
done
cd ..
rm -rf conftest.$$
#
# Did we find it?
#
if test "$OMPI_FC_MODULE_FLAG" = ""; then
AC_MSG_RESULT([])
AC_MSG_WARN([*** Could not determine the f90 compiler flag to indicate where modules reside])
AC_MSG_ERROR([Cannot continue])
fi
AC_MSG_RESULT([$OMPI_FC_MODULE_FLAG])
AC_SUBST(OMPI_FC_MODULE_FLAG)])dnl

Просмотреть файл

@ -601,6 +601,10 @@ if test "$OMPI_WANT_F90_BINDINGS" = "0" ; then
OMPI_SIZEOF_F90_REAL=$ac_cv_sizeof_float
OMPI_SIZEOF_F90_DBLPREC=$ac_cv_sizeof_double
else
# Look for the fortran module compiler flag
OMPI_F90_FIND_MODULE_INCLUDE_FLAG
# If we want modern Fortran support, then get supported types and sizes
OMPI_F90_CHECK_TYPE(selected_int_kind(2), OMPI_HAVE_F90_INTEGER1)

Просмотреть файл

@ -19,7 +19,7 @@ include $(top_srcdir)/config/Makefile.options
SUBDIRS = scripts
AM_FCFLAGS = -I$(top_srcdir)/include
AM_FCFLAGS = -I$(top_srcdir)/include $(OMPI_FC_MODULE_FLAG) .
# Override the default f90 rules because we have to insert
# $(FCFLAGS_f90) right before the source filename. This is necessary
@ -43,11 +43,34 @@ else
lib_LTLIBRARIES +=
endif
libmpi_f90_la_SOURCES = \
mpi.f90
#
# Force the mpi_kinds module to be generated before trying to compile
# any of the library files
#
$(libmpi_f90_la_SOURCES): mpi_kinds.o
$(nodist_libmpi_f90_la_SOURCES): mpi_kinds.o
#
# Print a warning indicating that compiling mpi.f90 can take a while
#
mpi.lo: long-warning
long-warning:
@echo "***************************************************************"
@echo "* Compiling the mpi.f90 file may take a few minutes."
@echo "* This is quite normal -- do not be alarmed if the compile"
@echo "* process seems to 'hang' at this point for several minutes."
@echo "***************************************************************"
#
# Source for the f90 library
#
libmpi_f90_la_SOURCES = mpi.f90
nodist_libmpi_f90_la_SOURCES = \
mpi.i.h \
mpi-f90-interfaces.h \
mpi_address_f90.f90 \
mpi_bcast_f90.f90 \
mpi_bsend_f90.f90 \
@ -131,7 +154,7 @@ endif
# win_wait_f.c
BUILT_SOURCES = \
mpi.i.h
mpi-f90-interfaces.h
#
# Sym link in the sources from the real MPI directory

Просмотреть файл

@ -1,7 +1,3 @@
module mpi_kinds
include "mpif.h"
!
! Copyright (c) 2004-2005 The Trustees of Indiana University.
! All rights reserved.
@ -18,49 +14,13 @@ module mpi_kinds
! $HEADER$
!
!
! kind for 4 byte integer (selected_int_kind(18) for 8 byte integer)
! (WARNING, Compiler dependent)
!
integer :: MPI_ADDRESS_KIND
parameter(MPI_ADDRESS_KIND = selected_int_kind(9))
!
! kind for int64_t equivalent, used for offsets
!
integer :: MPI_OFFSET_KIND
parameter(MPI_OFFSET_KIND = selected_int_kind(18))
!
! integer kinds
!
integer :: MPI_INTEGER1_KIND, MPI_INTEGER2_KIND, MPI_INTEGER4_KIND
integer :: MPI_INTEGER8_KIND, MPI_INTEGER16_KIND
parameter(MPI_INTEGER1_KIND = selected_int_kind(2))
parameter(MPI_INTEGER2_KIND = selected_int_kind(4))
parameter(MPI_INTEGER4_KIND = selected_int_kind(9))
parameter(MPI_INTEGER8_KIND = selected_int_kind(18))
parameter(MPI_INTEGER16_KIND = selected_int_kind(19))
!
! real kinds
!
integer :: MPI_REAL4_KIND, MPI_REAL8_KIND
integer :: MPI_REAL16_KIND, MPI_REAL32_KIND
parameter(MPI_REAL4_KIND = selected_real_kind(6))
parameter(MPI_REAL8_KIND = selected_real_kind(15))
parameter(MPI_REAL16_KIND = selected_real_kind(31))
parameter(MPI_REAL32_KIND = selected_real_kind(32))
end module mpi_kinds
module mpi
use mpi_kinds
include "mpi.i.h"
! This file is generated, and is *huge*. Its size is directly related
! to the --with-f90-max-array-dim configure parameter.
include "mpi-f90-interfaces.h"
end module mpi

57
src/mpi/f90/mpi_kinds.f90 Обычный файл
Просмотреть файл

@ -0,0 +1,57 @@
!
! Copyright (c) 2004-2005 The Trustees of Indiana University.
! All rights reserved.
! Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
! All rights reserved.
! Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
! University of Stuttgart. All rights reserved.
! Copyright (c) 2004-2005 The Regents of the University of California.
! All rights reserved.
! $COPYRIGHT$
!
! Additional copyrights may follow
!
! $HEADER$
!
module mpi_kinds
include "mpif.h"
!
! kind for 4 byte integer (selected_int_kind(18) for 8 byte integer)
! (WARNING, Compiler dependent)
!
integer :: MPI_ADDRESS_KIND
parameter(MPI_ADDRESS_KIND = selected_int_kind(9))
!
! kind for int64_t equivalent, used for offsets
!
integer :: MPI_OFFSET_KIND
parameter(MPI_OFFSET_KIND = selected_int_kind(18))
!
! integer kinds
!
integer :: MPI_INTEGER1_KIND, MPI_INTEGER2_KIND, MPI_INTEGER4_KIND
integer :: MPI_INTEGER8_KIND, MPI_INTEGER16_KIND
parameter(MPI_INTEGER1_KIND = selected_int_kind(2))
parameter(MPI_INTEGER2_KIND = selected_int_kind(4))
parameter(MPI_INTEGER4_KIND = selected_int_kind(9))
parameter(MPI_INTEGER8_KIND = selected_int_kind(18))
parameter(MPI_INTEGER16_KIND = selected_int_kind(19))
!
! real kinds
!
integer :: MPI_REAL4_KIND, MPI_REAL8_KIND
integer :: MPI_REAL16_KIND, MPI_REAL32_KIND
parameter(MPI_REAL4_KIND = selected_real_kind(6))
parameter(MPI_REAL8_KIND = selected_real_kind(15))
parameter(MPI_REAL16_KIND = selected_real_kind(31))
parameter(MPI_REAL32_KIND = selected_real_kind(32))
end module mpi_kinds

Просмотреть файл

@ -18,7 +18,7 @@
include $(top_srcdir)/config/Makefile.options
noinst_SCRIPTS = \
mpi.i.h.sh \
mpi-f90-interfaces.h.sh \
mpi_address_f90.f90.sh \
mpi_bcast_f90.f90.sh \
mpi_bsend_f90.f90.sh \

Просмотреть файл

@ -23,7 +23,8 @@ include $(top_srcdir)/config/Makefile.options
AM_CPPFLAGS = \
-DOMPI_PREFIX="\"$(prefix)\"" \
-DOMPI_INCDIR="\"$(includedir)\"" \
-DOMPI_LIBDIR="\"$(libdir)\""
-DOMPI_LIBDIR="\"$(libdir)\"" \
-DOMPI_FC_MODULE_FLAG="\"$(OMPI_FC_MODULE_FLAG)\""
EXTRA_DIST = wrap.cc wrap_engine.cc $(pkgdata_DATA)

Просмотреть файл

@ -54,5 +54,5 @@ main(int argc, char *argv[])
return ompi_wrap_engine(argc, argv, compiler, cppflags, cflags,
ldflags, libs, OMPI_CC, WRAPPER_EXTRA_CFLAGS,
false, false);
false, false, false);
}

Просмотреть файл

@ -54,5 +54,5 @@ main(int argc, char *argv[])
return ompi_wrap_engine(argc, argv, compiler, cxxcppflags, cxxflags,
ldflags, libs, OMPI_CXX,
WRAPPER_EXTRA_CXXFLAGS, true, false);
WRAPPER_EXTRA_CXXFLAGS, true, false, false);
}

Просмотреть файл

@ -63,6 +63,6 @@ main(int argc, char *argv[])
return ompi_wrap_engine(argc, argv, compiler, fppflags, fflags,
ldflags, libs, OMPI_F77, WRAPPER_EXTRA_FFLAGS,
false, true);
false, false, true);
#endif
}

Просмотреть файл

@ -41,6 +41,7 @@ main(int argc, char *argv[])
ompi_sv_t fcflags;
ompi_sv_t ldflags;
ompi_sv_t libs;
string wrapper_extra_fcflags;
compiler.clear();
compiler.push_back("OMPI_MPIF90");
@ -61,8 +62,14 @@ main(int argc, char *argv[])
libs.push_back("OMPI_MPIF90_LIBS");
libs.push_back("OMPI_LIBS");
wrapper_extra_fcflags = OMPI_FC_MODULE_FLAG;
wrapper_extra_fcflags += " ";
wrapper_extra_fcflags += OMPI_LIBDIR;
wrapper_extra_fcflags += " ";
wrapper_extra_fcflags += WRAPPER_EXTRA_FCFLAGS;
return ompi_wrap_engine(argc, argv, compiler, fcflags, fcflags,
ldflags, libs, OMPI_F90, WRAPPER_EXTRA_FCFLAGS,
false, true);
ldflags, libs, OMPI_F90, wrapper_extra_fcflags,
false, true, true);
#endif
}

Просмотреть файл

@ -70,7 +70,9 @@ int ompi_wrap_engine(int argc, char *argv[],
const ompi_sv_t & libs_env_var,
const std::string & default_compiler,
const std::string & default_xflags,
bool want_cxx_libs, bool want_f77_includes);
bool want_cxx_libs,
bool want_f90_libs,
bool want_f77_includes);
///
/// Parse the command line arguments of the wrapper compiler
@ -145,7 +147,8 @@ void ompi_wrap_build_ldflags(const ompi_sv_t & env_list, ompi_sv_t & ldflags);
/// linked to the backend compiler
///
void ompi_wrap_build_libs(const ompi_sv_t & env_list,
bool want_cxx_libs, ompi_sv_t & libs);
bool want_cxx_libs, bool want_f90_libs,
ompi_sv_t & libs);
///
/// Print out a vector of strings

Просмотреть файл

@ -327,7 +327,7 @@ ompi_wrap_build_ldflags(const ompi_sv_t & env_list, ompi_sv_t & ldflags)
void
ompi_wrap_build_libs(const ompi_sv_t & env_list,
bool want_cxx_libs, ompi_sv_t & libs)
bool want_cxx_libs, bool want_f90_libs, ompi_sv_t & libs)
{
char *env;
string temp;
@ -371,6 +371,24 @@ ompi_wrap_build_libs(const ompi_sv_t & env_list,
}
}
#endif
#if OMPI_WANT_F90_BINDINGS
// The F90 bindings come next
if (want_f90_libs) {
if (
#ifdef WIN32
!ompi_wrap_check_file(libdir, "libmpi_f90.dll") &&
#endif
!ompi_wrap_check_file(libdir, "libmpi_f90.a") &&
!ompi_wrap_check_file(libdir, "libmpi_f90.so") &&
!ompi_wrap_check_file(libdir, "libmpi_f90.dylib")) {
cerr << "WARNING: " << cmd_name
<< " expected to find libmpi_f90.* in " << libdir << endl
<< "WARNING: MPI F90 support will be disabled" << endl;
} else {
libs.push_back("-lmpi_f90");
}
}
#endif
// Next comes the MPI library

Просмотреть файл

@ -50,7 +50,9 @@ ompi_wrap_engine(int argc, char *argv[],
const ompi_sv_t & libs_env_var,
const std::string & default_compiler,
const std::string & default_xflags,
bool want_cxx_libs, bool want_f77_includes)
bool want_cxx_libs,
bool want_f90_libs,
bool want_f77_includes)
{
int ret(0);
@ -95,7 +97,7 @@ ompi_wrap_engine(int argc, char *argv[],
// Build the LIBS (-l stuff and WRAPPER_EXTRA_LIBS)
ompi_wrap_build_libs(libs_env_var, want_cxx_libs, libs);
ompi_wrap_build_libs(libs_env_var, want_cxx_libs, want_f90_libs, libs);
// Now assemble the command line