⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 aclangf90.m4

📁 MPICH是MPI的重要研究,提供了一系列的接口函数,为并行计算的实现提供了编程环境.
💻 M4
📖 第 1 页 / 共 2 页
字号:
# AC_F90_DUMMY_MAIN([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])# -----------------------------------------------------------## Detect name of dummy main routine required by the Fortran libraries,# (if any) and define F90_DUMMY_MAIN to this name (which should be# used for a dummy declaration, if it is defined).  On some systems,# linking a C program to the Fortran library does not work unless you# supply a dummy function called something like MAIN__.## Execute ACTION-IF-NOT-FOUND if no way of successfully linking a C# program with the F90 libs is found; default to exiting with an error# message.  Execute ACTION-IF-FOUND if a dummy routine name is needed# and found or if it is not needed (default to defining F90_DUMMY_MAIN# when needed).## What is technically happening is that the Fortran libraries provide# their own main() function, which usually initializes Fortran I/O and# similar stuff, and then calls MAIN__, which is the entry point of# your program.  Usually, a C program will override this with its own# main() routine, but the linker sometimes complain if you don't# provide a dummy (never-called) MAIN__ routine anyway.## Of course, programs that want to allow Fortran subroutines to do# I/O, etcetera, should call their main routine MAIN__() (or whatever)# instead of main().  A separate autoconf test (AC_F90_MAIN) checks# for the routine to use in this case (since the semantics of the test# are slightly different).  To link to e.g. purely numerical# libraries, this is normally not necessary, however, and most C/C++# programs are reluctant to turn over so much control to Fortran.  =)## The name variants we check for are (in order):#   MAIN__ (g90, MAIN__ required on some systems; IRIX, MAIN__ optional)#   MAIN_, __main (SunOS)#   MAIN _MAIN __MAIN main_ main__ _main (we follow DDD and try these too)AC_DEFUN([AC_F90_DUMMY_MAIN],[AC_REQUIRE([AC_F90_LIBRARY_LDFLAGS])dnlm4_define([_AC_LANG_PROGRAM_C_F90_HOOKS],[#ifdef F90_DUMMY_MAIN#  ifdef __cplusplus     extern "C"#  endif   int F90_DUMMY_MAIN() { return 1; }#endif])AC_CACHE_CHECK([for dummy main to link with Fortran 90 libraries],               ac_cv_f90_dummy_main,[AC_LANG_PUSH(C)dnl ac_f90_dm_save_LIBS=$LIBS LIBS="$LIBS $F90LIBS" # First, try linking without a dummy main: AC_TRY_LINK([], [],             ac_cv_f90_dummy_main=none,             ac_cv_f90_dummy_main=unknown) if test $ac_cv_f90_dummy_main = unknown; then   for ac_func in MAIN__ MAIN_ __main MAIN _MAIN __MAIN main_ main__ _main; do     AC_TRY_LINK([@%:@define F90_DUMMY_MAIN $ac_func],                 [], [ac_cv_f90_dummy_main=$ac_func; break])   done fi rm -f conftest* LIBS=$ac_f90_dm_save_LIBS AC_LANG_POP(C)dnl])F90_DUMMY_MAIN=$ac_cv_f90_dummy_mainAS_IF([test "$F90_DUMMY_MAIN" != unknown],      [m4_default([$1],[if test $F90_DUMMY_MAIN != none; then  AC_DEFINE_UNQUOTED([F90_DUMMY_MAIN], $F90_DUMMY_MAIN,                     [Define to dummy `main' function (if any) required to                      link to the Fortran 90 libraries.])fi])],      [m4_default([$2],                [AC_MSG_ERROR([Linking to Fortran libraries from C fails.])])])])# AC_F90_DUMMY_MAIN# AC_F90_MAIN# -----------# Define F90_MAIN to name of alternate main() function for use with# the Fortran libraries.  (Typically, the libraries may define their# own main() to initialize I/O, etcetera, that then call your own# routine called MAIN__ or whatever.)  See AC_F90_DUMMY_MAIN, above.# If no such alternate name is found, just define F90_MAIN to main.#AC_DEFUN([AC_F90_MAIN],[AC_REQUIRE([AC_F90_LIBRARY_LDFLAGS])dnlAC_CACHE_CHECK([for alternate main to link with Fortran 90 libraries],               ac_cv_f90_main,[AC_LANG_PUSH(C)dnl ac_f90_m_save_LIBS=$LIBS LIBS="$LIBS $F90LIBS" ac_cv_f90_main="main" # default entry point name for ac_func in MAIN__ MAIN_ __main MAIN _MAIN __MAIN main_ main__ _main; do   AC_TRY_LINK([#undef F90_DUMMY_MAIN@%:@define main $ac_func], [], [ac_cv_f90_main=$ac_func; break]) done rm -f conftest* LIBS=$ac_f90_m_save_LIBS AC_LANG_POP(C)dnl])AC_DEFINE_UNQUOTED([F90_MAIN], $ac_cv_f90_main,                   [Define to alternate name for `main' routine that is                    called from a `main' in the Fortran libraries.])])# AC_F90_MAIN# _AC_F90_NAME_MANGLING# ---------------------# Test for the name mangling scheme used by the Fortran 90 compiler.## Sets ac_cv_f90_mangling. The value contains three fields, separated# by commas:## lower case / upper case:#    case translation of the Fortan 90 symbols# underscore / no underscore:#    whether the compiler appends "_" to symbol names# extra underscore / no extra underscore:#    whether the compiler appends an extra "_" to symbol names already#    containing at least one underscore#AC_DEFUN([_AC_F90_NAME_MANGLING],[AC_REQUIRE([AC_F90_LIBRARY_LDFLAGS])dnlAC_REQUIRE([AC_F90_DUMMY_MAIN])dnlAC_CACHE_CHECK([for Fortran 90 name-mangling scheme],               ac_cv_f90_mangling,[AC_LANG_PUSH(Fortran 90)dnlAC_COMPILE_IFELSE([      subroutine foobar()      return      end      subroutine foo_bar()      return      end],[mv conftest.$ac_objext cf90_test.$ac_objext  AC_LANG_PUSH(C)dnl  ac_save_LIBS=$LIBS  LIBS="cf90_test.$ac_objext $LIBS $F90LIBS"  ac_success=no  for ac_foobar in foobar FOOBAR; do    for ac_underscore in "" "_"; do      ac_func="$ac_foobar$ac_underscore"      AC_TRY_LINK_FUNC($ac_func,         [ac_success=yes; break 2])    done  done  if test "$ac_success" = "yes"; then     case $ac_foobar in        foobar)           ac_case=lower           ac_foo_bar=foo_bar           ;;        FOOBAR)           ac_case=upper           ac_foo_bar=FOO_BAR           ;;     esac     ac_success_extra=no     for ac_extra in "" "_"; do        ac_func="$ac_foo_bar$ac_underscore$ac_extra"        AC_TRY_LINK_FUNC($ac_func,        [ac_success_extra=yes; break])     done     if test "$ac_success_extra" = "yes"; then	ac_cv_f90_mangling="$ac_case case"        if test -z "$ac_underscore"; then           ac_cv_f90_mangling="$ac_cv_f90_mangling, no underscore"	else           ac_cv_f90_mangling="$ac_cv_f90_mangling, underscore"        fi        if test -z "$ac_extra"; then           ac_cv_f90_mangling="$ac_cv_f90_mangling, no extra underscore"	else           ac_cv_f90_mangling="$ac_cv_f90_mangling, extra underscore"        fi      else	ac_cv_f90_mangling="unknown"      fi  else     ac_cv_f90_mangling="unknown"  fi  LIBS=$ac_save_LIBS  AC_LANG_POP(C)dnl  rm -f cf90_test* conftest*])AC_LANG_POP(Fortran 90)dnl])])# _AC_F90_NAME_MANGLING# The replacement is empty.AU_DEFUN([AC_F90_NAME_MANGLING], [])# AC_F90_WRAPPERS# ---------------# Defines C macros F90_FUNC(name,NAME) and F90_FUNC_(name,NAME) to# properly mangle the names of C identifiers, and C identifiers with# underscores, respectively, so that they match the name mangling# scheme used by the Fortran 90 compiler.AC_DEFUN([AC_F90_WRAPPERS],[AC_REQUIRE([_AC_F90_NAME_MANGLING])dnlAH_TEMPLATE([F90_FUNC],    [Define to a macro mangling the given C identifier (in lower and upper     case), which must not contain underscores, for linking with Fortran.])dnlAH_TEMPLATE([F90_FUNC_],    [As F90_FUNC, but for C identifiers containing underscores.])dnlcase $ac_cv_f90_mangling in  "lower case, no underscore, no extra underscore")          AC_DEFINE([F90_FUNC(name,NAME)],  [name])          AC_DEFINE([F90_FUNC_(name,NAME)], [name]) ;;  "lower case, no underscore, extra underscore")          AC_DEFINE([F90_FUNC(name,NAME)],  [name])          AC_DEFINE([F90_FUNC_(name,NAME)], [name ## _]) ;;  "lower case, underscore, no extra underscore")          AC_DEFINE([F90_FUNC(name,NAME)],  [name ## _])          AC_DEFINE([F90_FUNC_(name,NAME)], [name ## _]) ;;  "lower case, underscore, extra underscore")          AC_DEFINE([F90_FUNC(name,NAME)],  [name ## _])          AC_DEFINE([F90_FUNC_(name,NAME)], [name ## __]) ;;  "upper case, no underscore, no extra underscore")          AC_DEFINE([F90_FUNC(name,NAME)],  [NAME])          AC_DEFINE([F90_FUNC_(name,NAME)], [NAME]) ;;  "upper case, no underscore, extra underscore")          AC_DEFINE([F90_FUNC(name,NAME)],  [NAME])          AC_DEFINE([F90_FUNC_(name,NAME)], [NAME ## _]) ;;  "upper case, underscore, no extra underscore")          AC_DEFINE([F90_FUNC(name,NAME)],  [NAME ## _])          AC_DEFINE([F90_FUNC_(name,NAME)], [NAME ## _]) ;;  "upper case, underscore, extra underscore")          AC_DEFINE([F90_FUNC(name,NAME)],  [NAME ## _])          AC_DEFINE([F90_FUNC_(name,NAME)], [NAME ## __]) ;;  *)          AC_MSG_WARN([unknown Fortran 90 name-mangling scheme])          ;;esac])# AC_F90_WRAPPERS# AC_F90_FUNC(NAME, [SHELLVAR = NAME])# ------------------------------------# For a Fortran subroutine of given NAME, define a shell variable# $SHELLVAR to the Fortran-90 mangled name.  If the SHELLVAR# argument is not supplied, it defaults to NAME.AC_DEFUN([AC_F90_FUNC],[AC_REQUIRE([_AC_F90_NAME_MANGLING])dnlcase $ac_cv_f90_mangling in  upper*) ac_val="m4_toupper([$1])" ;;  lower*) ac_val="m4_tolower([$1])" ;;  *)      ac_val="unknown" ;;esaccase $ac_cv_f90_mangling in *," underscore"*) ac_val="$ac_val"_ ;; esacm4_if(m4_index([$1],[_]),-1,[],[case $ac_cv_f90_mangling in *," extra underscore"*) ac_val="$ac_val"_ ;; esac])m4_default([$2],[$1])="$ac_val"])# AC_F90_FUNC## ------------------------------------------------------------------------# Special characteristics that have no autoconf counterpart but that# we need as part of the Fortran 90 support.  To distinquish these, they# have a [PAC] prefix.#dnldnl PAC_F90_MODULE_EXT(action if found,action if not found)dnlAC_DEFUN([PAC_F90_MODULE_EXT],[AC_CACHE_CHECK([for Fortran 90 module extension],pac_cv_f90_module_ext,[pac_cv_f90_module_case="unknown"AC_LANG_PUSH(Fortran 90)cat >conftest.$ac_ext <<EOF	module conftest        integer n        parameter (n=1)        end module conftestEOFif AC_TRY_EVAL(ac_compile) ; then   dnl Look for module name   pac_MOD=`ls conftest* AS_MESSAGE_LOG_FD>&1 2>&1 | grep -v conftest.$ac_ext | grep -v conftest.o`   pac_MOD=`echo $pac_MOD | sed -e 's/conftest\.//g'`   pac_cv_f90_module_case="lower"   if test "X$pac_MOD" = "X" ; then	for file in CONFTEST* ; do	    if test "x$file" = "xCONFTEST.$ac_ext" ; then continue ; fi	    if test "x$file" = "xCONFTEST.o" ; then continue ; fi	    if test -s "$file" ; then 	        pac_MOD=$file	        break	    fi	done        pac_MOD=`echo $pac_MOD | sed -e 's/CONFTEST\.//g'`	if test -n "$pac_MOD" ; then	    testname="CONFTEST"	    pac_cv_f90_module_case="upper"	fi    fi    if test -z "$pac_MOD" ; then 	pac_cv_f90_module_ext="unknown"    else	pac_cv_f90_module_ext=$pac_MOD    fielse    echo "configure: failed program was:" >&AC_FD_CC    cat conftest.$ac_ext >&AC_FD_CC    pac_cv_f90_module_ext="unknown"fiAC_LANG_POPrm -f conftest*])AC_SUBST(F90MODEXT)if test "$pac_cv_f90_module_ext" = "unknown" ; then    ifelse($2,,:,[$2])else    ifelse($1,,F90MODEXT=$pac_MOD,[$1])fi])dnldnl PAC_F90_MODULE_INCFLAGAC_DEFUN([PAC_F90_MODULE_INCFLAG],[AC_CACHE_CHECK([for Fortran 90 module include flag],pac_cv_f90_module_incflag,[AC_REQUIRE([PAC_F90_MODULE_EXT])AC_LANG_PUSH(Fortran 90)cat >conftest.$ac_ext <<EOF	module conf        integer n        parameter (n=1)        end module confEOFpac_madedir="no"if test ! -d conf ; then mkdir conf ; pac_madedir="yes"; fiif test "$pac_cv_f90_module_case" = "upper" ; then    pac_module="CONF.$pac_cv_f90_module_ext"else    pac_module="conf.$pac_cv_f90_module_ext"fiif AC_TRY_EVAL(ac_compile) ; then    cp $pac_module confelse    echo "configure: failed program was:" >&AC_FD_CC    cat conftest.$ac_ext >&AC_FD_CCfirm -f conftest.$ac_extcat >conftest.$ac_ext <<EOF    program main    use conf    endEOFif ${F90-f90} -c $F90FLAGS -Iconf conftest.$ac_ext 1>&AC_FD_CC && \	test -s conftest.o ; then    pac_cv_f90_module_incflag="-I"elif ${F90-f90} -c $F90FLAGS -Mconf conftest.$ac_ext 1>&AC_FD_CC && \	test-s conftest.o ; then    pac_cv_f90_module_incflag="-M"elif ${F90-f90} -c $F90FLAGS -pconf conftest.$ac_ext 1>&AC_FD_CC && \	test -s conftest.o ; then    pac_cv_f90_module_incflag="-p"else    pac_cv_f90_module_incflag="unknown"fiif test "$pac_madedir" = "yes" ; then rm -rf conf ; firm -f conftest*AC_LANG_POP])AC_SUBST(F90MODINCFLAG)F90MODINCFLAG=$pac_cv_f90_module_incflag])AC_DEFUN([PAC_F90_MODULE],[PAC_F90_MODULE_EXTPAC_F90_MODULE_INCFLAG])AC_DEFUN([PAC_F90_EXT],[AC_CACHE_CHECK([whether Fortran 90 accepts f90 suffix],pac_cv_f90_ext_f90,[save_ac_f90ext=$ac_f90extac_f90ext="f90"AC_LANG_PUSH(Fortran 90)AC_TRY_COMPILE(,,pac_cv_f90_ext_f90="yes",pac_cv_f90_ext_f90="no")AC_LANG_POP])if test "$pac_cv_f90_ext_f90" = "yes" ; then    ac_f90ext=f90else    ac_f90ext=ffi])dnldnl/*D dnl PAC_PROG_F90_INT_KIND - Determine kind parameter for an integer withdnl the specified number of bytes.dnldnl Synopsis:dnl  PAC_PROG_F90_INT_KIND(variable-to-set,number-of-bytes,[cross-size])dnldnlD*/AC_DEFUN(PAC_PROG_F90_INT_KIND,[# Set the default$1=-1if test "$pac_cv_prog_f90_cross" = "yes" ; then    $1="$3"elseAC_LANG_PUSH(Fortran 90)if test -n "$ac_compile" ; then    AC_MSG_CHECKING([for Fortran 90 integer kind for $2-byte integers])    # Convert bytes to digits    case $2 in 	1) sellen=2 ;;	2) sellen=4 ;;	4) sellen=8 ;;	8) sellen=16 ;;       16) sellen=30 ;;	*) sellen=8 ;;    esac    # Check for cached value    eval testval=\$"pac_cv_prog_f90_int_kind_$sellen"    if test -n "$testval" ; then         AC_MSG_RESULT([$testval (cached)])	$1=$testval    else        # must compute        rm -f conftest*        cat <<EOF > conftest.$ac_ext      program main      integer i      i = selected_int_kind($sellen)      open(8, file="conftest1.out", form="formatted")      write (8,*) i      close(8)      stop      endEOF        KINDVAL="unavailable"        eval "pac_cv_prog_f90_int_kind_$sellen"=-1        if AC_TRY_EVAL(ac_link) && test -s conftest ; then            ./conftest >>config.log 2>&1            if test -s conftest1.out ; then	        # Because of write, there may be a leading blank.                KINDVAL=`cat conftest1.out | sed 's/ //g'` 	        eval "pac_cv_prog_f90_int_kind_$sellen"=$KINDVAL	        $1=$KINDVAL            fi        fi        rm -f conftest*	AC_MSG_RESULT($KINDVAL)    fi # not cachedfi # Has Fortran 90AC_LANG_POPfi # is not cross compiling])dnldnldnl Backwards compatibility featuresdnlAC_DEFUN([PAC_PROG_F90],[AC_PROG_F90])AC_DEFUN([PAC_LANG_FORTRAN90],[AC_LANG_PUSH(Fortran 90)])

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -