Commit 261681fa authored by Hendryk Bockelmann's avatar Hendryk Bockelmann
Browse files

add patch from Sergey Kosukhin to check for correct flags need to be used by...

add patch from Sergey Kosukhin to check for correct flags need to be used by Fortran compiler to link C code that uses OpenMP
parent b9c5ed79
This diff is collapsed.
......@@ -428,12 +428,19 @@ AC_C_INLINE
AC_C_RESTRICT
if test x"$openmp" = xtrue; then
AC_LANG_PUSH([C])
AC_OPENMP
AC_LANG_POP([C])
AC_LANG_PUSH([Fortran])
AC_OPENMP
AC_LANG_POP([Fortran])
if test x"$fortran_interface" = xtrue; then
AX_FC_C_OPENMP
if test x"$ax_cv_prog_fc_c_openmp" = xunsupported; then
AC_MSG_WARN([Fortran compiler cannot link C code that uses OpenMP])
elif test x"$ax_cv_prog_fc_c_openmp" != "xnone needed"; then
OPENMP_FC_C_LT_FLAGS=`AS_ECHO(["$OPENMP_FC_C_FLAGS"]) | sed 's%-Wl,@<:@^ @:>@* *%-XCClinker &%g'`
AC_SUBST([OPENMP_FC_C_LT_FLAGS])
fi
else
AC_LANG_PUSH([C])
AC_OPENMP
AC_LANG_POP([C])
fi
fi
......@@ -505,7 +512,7 @@ echo \
if test x"$openmp" = xtrue; then
echo \
" CFLAGS : ${OPENMP_CFLAGS}
FCFLAGS : ${OPENMP_FCFLAGS}"
FCFLAGS : ${OPENMP_FC_C_FLAGS}"
fi
echo \
......
# AX_FC_C_OPENMP
# ---------------------------------------------------------------------
# Runs AC_OPENMP for C and Fortran and checks for a linking flag for
# Fortran compiler that is required to link C code that uses OpenMP.
# The flag is set to the OPENMP_FC_C_FLAGS and cached as ax_cv_prog_fc_c_openmp.
# The result is either "none needed", "unsupported" (and OPENMP_FC_C_FLAGS is empty)
# or the actual flags (OPEN_FC_C_FLAGS is equal to the flags).
m4_define([_AX_FC_C_OPENMP],
[
program main
implicit none
interface
subroutine foo() BIND(C, NAME='foo')
end subroutine foo
end interface
call foo
end
])
AC_DEFUN([AX_FC_C_OPENMP], [
AC_REQUIRE([AC_PROG_CC])dnl
AC_REQUIRE([AC_PROG_FC])dnl
AC_LANG_PUSH([C])
AC_OPENMP
AC_LANG_POP([C])
AC_LANG_PUSH([Fortran])
AC_OPENMP
AC_LANG_POP([Fortran])
AC_CACHE_CHECK([for $FC option to link code that requires OpenMP and is compiled with $CC], [ax_cv_prog_fc_c_openmp],
[OPENMP_FC_C_FLAGS=
ax_cv_prog_fc_c_openmp=unsupported
AS_IF([test x"$ac_cv_prog_c_openmp" != xunsupported],
[AC_LANG_PUSH([C])
ax_fc_c_openmp_CFLAGS_save=$CFLAGS
CFLAGS="$OPENMP_CFLAGS $ax_fc_c_openmp_CFLAGS_save"
ac_compile="$ac_compile && cp conftest.$ac_objext conftest_foo.$ac_objext"
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
#ifndef _OPENMP
choke me
#endif
#include <omp.h>
int foo (void) { return omp_get_num_threads (); }]])],
[AC_LANG_PUSH([Fortran])
ax_fc_c_openmp_LIBS_save=$LIBS
LIBS="conftest_foo.$ac_objext $ax_fc_c_openmp_LIBS_save"
AC_LINK_IFELSE([_AX_FC_C_OPENMP],
[ax_cv_prog_fc_c_openmp='none needed'],
[ax_fc_c_openmp_FCFLAGS_save=$FCFLAGS
AS_IF([test x"$ac_cv_prog_fc_openmp" != xunsupported],
[FCFLAGS="$OPENMP_FCFLAGS $ax_fc_c_openmp_FCFLAGS_save"
AC_LINK_IFELSE([_AX_FC_C_OPENMP],
[ax_cv_prog_fc_c_openmp=$ac_cv_prog_fc_openmp],
[AS_IF([test x"$ac_cv_prog_c_openmp" != "xnone needed"],
[ax_cv_prog_fc_c_openmp=`AS_ECHO(["$OPENMP_CFLAGS"]) | sed 's%[^ ]* *%-Wl,&%g'`
FCFLAGS="$ax_cv_prog_fc_c_openmp $ax_fc_c_openmp_FCFLAGS_save"
AC_LINK_IFELSE([_AX_FC_C_OPENMP], [],
[ax_cv_prog_fc_c_openmp=unsupported])])])])
FCFLAGS=$ax_fc_c_openmp_FCFLAGS_save])
LIBS=$ax_fc_c_openmp_LIBS_save
AC_LANG_POP([Fortran])])
CFLAGS=$ax_fc_c_openmp_CFLAGS_save
AC_LANG_POP([C])])])
AS_CASE([$ax_cv_prog_fc_c_openmp],
["none needed" | unsupported], [],
[OPENMP_FC_C_FLAGS=$ax_cv_prog_fc_c_openmp])
AC_SUBST([OPENMP_FC_C_FLAGS])
])
......@@ -27,11 +27,11 @@ AC_DEFUN([AX_FC_STD2003],
*) FCFLAGS="$ax_save_FCFLAGS $ax_flag" ;;
esac
AC_LINK_IFELSE([AC_LANG_PROGRAM([],[
USE, INTRINSIC :: ISO_C_BINDING, ONLY: C_INT, C_FLOAT
TYPE, BIND(C) :: MYFTYPE
INTEGER(C_INT) :: I
REAL(C_FLOAT) :: F
END TYPE MYFTYPE
USE, INTRINSIC :: ISO_C_BINDING, ONLY: C_INT, C_FLOAT
TYPE, BIND(C) :: MYFTYPE
INTEGER(C_INT) :: I
REAL(C_FLOAT) :: F
END TYPE MYFTYPE
])],
[ax_cv_fc_std2003=$ax_flag; break])
done
......
AM_CFLAGS = $(OPENMP_CFLAGS)
AM_FCFLAGS = $(FC_MODINC).. $(OPENMP_FCFLAGS) $(FCFLAGS_f90) $(FCDEFS)
AM_FCFLAGS = $(FC_MODINC).. $(FCFLAGS_f90) $(FCDEFS)
lib_LTLIBRARIES = libsct.la
libsct_la_LIBADD = $(LTLIBPAPI) $(LTLIBHDF5)
libsct_la_LDFLAGS = -version-info @LIB_CURRENT@:@LIB_REVISION@:@LIB_AGE@
libsct_la_LDFLAGS = $(OPENMP_FC_C_LT_FLAGS) -version-info @LIB_CURRENT@:@LIB_REVISION@:@LIB_AGE@
header = $(srcdir)/sct_config.h \
$(srcdir)/sct_mach.h \
$(srcdir)/sct_collector.h \
......
AM_FCFLAGS = $(FC_MODINC). $(OPENMP_FCFLAGS) $(FCFLAGS_f90)
AM_FCFLAGS = $(FC_MODINC). $(FCFLAGS_f90)
libdir = "${exec_prefix}_nosct/lib"
includedir = "${exec_prefix}_nosct/include"
......
AM_CFLAGS = $(OPENMP_CFLAGS)
AM_CPPFLAGS = -I$(top_builddir)/src
AM_FCFLAGS = $(FC_MODINC). $(FC_MODINC)$(top_builddir)/src $(OPENMP_FCFLAGS) $(FCFLAGS_f90)
AM_FCFLAGS = $(FC_MODINC). $(FC_MODINC)$(top_builddir)/src $(FCFLAGS_f90)
if MPI
AM_FCFLAGS += $(FC_DEFINE)HAVE_MPI
endif
......
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