Blame confdb/aclocal_f77.m4

Packit 0848f5
dnl PAC_F77_SEARCH_LIST - expands to a whitespace separated list of fortran 77
Packit 0848f5
dnl compilers for use with AC_PROG_F77 that is more suitable for HPC software
Packit 0848f5
dnl packages
Packit 0848f5
AC_DEFUN([PAC_F77_SEARCH_LIST],[ifort pgf77 af77 xlf frt cf77 fort77 fl32 fort ifc efc ftn gfortran f77 g77])
Packit 0848f5
dnl PAC_PROG_F77 - reprioritize the F77 compiler search order
Packit 0848f5
dnl NOTE: this macro suffers from a basically intractable "expanded before it
Packit 0848f5
dnl was required" problem when libtool is also used
Packit 0848f5
AC_DEFUN([PAC_PROG_F77],[
Packit 0848f5
PAC_PUSH_FLAG([FFLAGS])
Packit 0848f5
AC_PROG_F77([PAC_F77_SEARCH_LIST])
Packit 0848f5
PAC_POP_FLAG([FFLAGS])
Packit 0848f5
])
Packit 0848f5
dnl
Packit 0848f5
dnl/*D
Packit 0848f5
dnl PAC_PROG_F77_NAME_MANGLE - Determine how the Fortran compiler mangles
Packit 0848f5
dnl names 
Packit 0848f5
dnl
Packit 0848f5
dnl Synopsis:
Packit 0848f5
dnl PAC_PROG_F77_NAME_MANGLE([action])
Packit 0848f5
dnl
Packit 0848f5
dnl Output Effect:
Packit 0848f5
dnl If no action is specified, one of the following names is defined:
Packit 0848f5
dnl.vb
Packit 0848f5
dnl If fortran names are mapped:
Packit 0848f5
dnl   lower -> lower                  F77_NAME_LOWER
Packit 0848f5
dnl   lower -> lower_                 F77_NAME_LOWER_USCORE
Packit 0848f5
dnl   lower -> UPPER                  F77_NAME_UPPER
Packit 0848f5
dnl   lower_lower -> lower__          F77_NAME_LOWER_2USCORE
Packit 0848f5
dnl   mixed -> mixed                  F77_NAME_MIXED
Packit 0848f5
dnl   mixed -> mixed_                 F77_NAME_MIXED_USCORE
Packit 0848f5
dnl   mixed -> UPPER@STACK_SIZE       F77_NAME_UPPER_STDCALL
Packit 0848f5
dnl.ve
Packit 0848f5
dnl If an action is specified, it is executed instead.
Packit 0848f5
dnl 
Packit 0848f5
dnl Notes:
Packit 0848f5
dnl We assume that if lower -> lower (any underscore), upper -> upper with the
Packit 0848f5
dnl same underscore behavior.  Previous versions did this by 
Packit 0848f5
dnl compiling a Fortran program and running strings -a over it.  Depending on 
Packit 0848f5
dnl strings is a bad idea, so instead we try compiling and linking with a 
Packit 0848f5
dnl C program, since that is why we are doing this anyway.  A similar approach
Packit 0848f5
dnl is used by FFTW, though without some of the cases we check (specifically, 
Packit 0848f5
dnl mixed name mangling).  STD_CALL not only specifies a particular name
Packit 0848f5
dnl mangling convention (adding the size of the calling stack into the function
Packit 0848f5
dnl name, but also the stack management convention (callee cleans the stack,
Packit 0848f5
dnl and arguments are pushed onto the stack from right to left)
Packit 0848f5
dnl
Packit 0848f5
dnl One additional problem is that some Fortran implementations include 
Packit 0848f5
dnl references to the runtime (like pgf90_compiled for the pgf90 compiler
Packit 0848f5
dnl used as the "Fortran 77" compiler).  This is not yet solved.
Packit 0848f5
dnl
Packit 0848f5
dnl D*/
Packit 0848f5
dnl
Packit 0848f5
AC_DEFUN([PAC_PROG_F77_NAME_MANGLE],[
Packit 0848f5
AC_REQUIRE([AC_F77_LIBRARY_LDFLAGS])
Packit 0848f5
AC_CACHE_CHECK([for Fortran 77 name mangling],
Packit 0848f5
pac_cv_prog_f77_name_mangle,[
Packit 0848f5
# Initialize pac_found to indicate if name mangling scheme has been found
Packit 0848f5
pac_found=no
Packit 0848f5
AC_LANG_PUSH([Fortran 77])
Packit 0848f5
AC_COMPILE_IFELSE([
Packit 0848f5
    AC_LANG_SOURCE([
Packit 0848f5
        subroutine MY_name( ii )
Packit 0848f5
        return
Packit 0848f5
        end
Packit 0848f5
    ])
Packit 0848f5
],[
Packit 0848f5
    PAC_RUNLOG([mv conftest.$OBJEXT f77conftest.$OBJEXT])
Packit 0848f5
    saved_LIBS="$LIBS"
Packit 0848f5
    dnl  FLIBS is set by AC_F77_LIBRARY_LDFLAGS
Packit 0848f5
    LIBS="f77conftest.$OBJEXT $FLIBS $LIBS"
Packit 0848f5
    AC_LANG_PUSH([C])
Packit 0848f5
    for call in "" __stdcall ; do
Packit 0848f5
        for sym in my_name_ my_name__ my_name MY_NAME MY_name MY_name_ NONE ; do
Packit 0848f5
            AC_LINK_IFELSE([
Packit 0848f5
                AC_LANG_PROGRAM([extern void ${call} ${sym}(int);],[${sym}(0);])
Packit 0848f5
            ],[
Packit 0848f5
                pac_found=yes
Packit 0848f5
                break
Packit 0848f5
            ])
Packit 0848f5
        done
Packit 0848f5
        test "$pac_found" = "yes" && break
Packit 0848f5
    done
Packit 0848f5
    AC_LANG_POP([C])
Packit 0848f5
    LIBS="$saved_LIBS"
Packit 0848f5
    rm -f f77conftest.$OBJEXT
Packit 0848f5
])
Packit 0848f5
AC_LANG_POP([Fortran 77])
Packit 0848f5
dnl
Packit 0848f5
# If we got to here and pac_cv_prog_f77_name_mangle is still NOT definable,
Packit 0848f5
# it may be that the programs have to be linked with the Fortran compiler,
Packit 0848f5
# not the C compiler.  Try reversing the language used for the test
Packit 0848f5
if test  "$pac_found" != "yes" ; then
Packit 0848f5
    AC_LANG_PUSH([C])
Packit 0848f5
    for call in "" __stdcall ; do
Packit 0848f5
        for sym in my_name_ my_name__ my_name MY_NAME MY_name MY_name_ NONE ; do
Packit 0848f5
            AC_COMPILE_IFELSE([
Packit 0848f5
                AC_LANG_SOURCE([void ${call} ${sym}(int a) {}])
Packit 0848f5
            ],[
Packit 0848f5
                PAC_RUNLOG([mv conftest.$OBJEXT cconftest.$OBJEXT])
Packit 0848f5
                saved_LIBS="$LIBS"
Packit 0848f5
                LIBS="cconftest.$OBJEXT $LIBS"
Packit 0848f5
                AC_LANG_PUSH([Fortran 77])
Packit 0848f5
                AC_LINK_IFELSE([
Packit 0848f5
                    AC_LANG_PROGRAM([],[      call my_name(0)])
Packit 0848f5
                ],[
Packit 0848f5
                    pac_found=yes
Packit 0848f5
                ]) 
Packit 0848f5
                AC_LANG_POP([Fortran 77])
Packit 0848f5
                LIBS="$saved_LIBS"
Packit 0848f5
                rm -f cconftest.$OBJEXT
Packit 0848f5
                test "$pac_found" = "yes" && break
Packit 0848f5
            ])
Packit 0848f5
        done
Packit 0848f5
        test "$pac_found" = "yes" && break
Packit 0848f5
    done
Packit 0848f5
    AC_LANG_POP([C])
Packit 0848f5
fi
Packit 0848f5
if test "$pac_found" = "yes" ; then
Packit 0848f5
    case ${sym} in
Packit 0848f5
        my_name_)
Packit 0848f5
            pac_cv_prog_f77_name_mangle="lower uscore" ;;
Packit 0848f5
        my_name__)
Packit 0848f5
            pac_cv_prog_f77_name_mangle="lower 2uscore" ;;
Packit 0848f5
        my_name)
Packit 0848f5
            pac_cv_prog_f77_name_mangle="lower" ;;
Packit 0848f5
        MY_NAME)
Packit 0848f5
            pac_cv_prog_f77_name_mangle="upper" ;;
Packit 0848f5
        MY_name)
Packit 0848f5
            pac_cv_prog_f77_name_mangle="mixed" ;;
Packit 0848f5
        MY_name_)
Packit 0848f5
            pac_cv_prog_f77_name_mangle="mixed uscore" ;;
Packit 0848f5
        *)
Packit 0848f5
            pac_cv_prog_f77_name_mangle=""
Packit 0848f5
            pac_found=no;
Packit 0848f5
            ;;
Packit 0848f5
    esac
Packit 0848f5
    if test "X$pac_cv_prog_f77_name_mangle" != "X" ; then
Packit 0848f5
        if test "$call" = "__stdcall" ; then
Packit 0848f5
            pac_cv_prog_f77_name_mangle="$pac_cv_prog_f77_name_mangle stdcall"
Packit 0848f5
        fi
Packit 0848f5
    fi
Packit 0848f5
fi
Packit 0848f5
])
Packit 0848f5
dnl Endof ac_cache_check
Packit 0848f5
case $pac_cv_prog_f77_name_mangle in
Packit 0848f5
    *stdcall)
Packit 0848f5
        F77_STDCALL="__stdcall" ;;
Packit 0848f5
    *)
Packit 0848f5
        F77_STDCALL="" ;;
Packit 0848f5
esac
Packit 0848f5
# Get the standard call definition
Packit 0848f5
# FIXME: This should use F77_STDCALL, not STDCALL (non-conforming name)
Packit 0848f5
F77_STDCALL="$call"
Packit 0848f5
AC_DEFINE_UNQUOTED(STDCALL,[$F77_STDCALL],[Define calling convention])
Packit 0848f5
Packit 0848f5
# new_name="`echo $name | tr ' ' '_' | tr [a-z] [A-Z]`"
Packit 0848f5
# We could have done the character conversion with 'tr'
Packit 0848f5
# which may not be portable, e.g. solaris's /usr/ucb/bin/tr.
Packit 0848f5
# So use a conservative approach.
Packit 0848f5
Packit 0848f5
# Replace blank with underscore
Packit 0848f5
name_scheme="`echo $pac_cv_prog_f77_name_mangle | sed 's% %_%g'`"
Packit 0848f5
# Turn lowercase into uppercase.
Packit 0848f5
name_scheme="`echo $name_scheme | sed -e 'y%abcdefghijklmnopqrstuvwxyz%ABCDEFGHIJKLMNOPQRSTUVWXYZ%'`"
Packit 0848f5
F77_NAME_MANGLE="F77_NAME_${name_scheme}"
Packit 0848f5
AC_DEFINE_UNQUOTED([$F77_NAME_MANGLE]) 
Packit 0848f5
AC_SUBST(F77_NAME_MANGLE)
Packit 0848f5
if test "X$pac_cv_prog_f77_name_mangle" = "X" ; then
Packit 0848f5
    AC_MSG_WARN([Unknown Fortran naming scheme])
Packit 0848f5
fi
Packit 0848f5
dnl
Packit 0848f5
dnl Define the macros that is needed by AC_DEFINE_UNQUOTED([$F77_NAME_MANGLE])
Packit 0848f5
AH_TEMPLATE([F77_NAME_LOWER],
Packit 0848f5
    [Fortran names are lowercase with no trailing underscore])
Packit 0848f5
AH_TEMPLATE([F77_NAME_LOWER_USCORE],
Packit 0848f5
    [Fortran names are lowercase with one trailing underscore])
Packit 0848f5
AH_TEMPLATE([F77_NAME_LOWER_2USCORE],
Packit 0848f5
    [Fortran names are lowercase with two trailing underscores])
Packit 0848f5
AH_TEMPLATE([F77_NAME_MIXED],
Packit 0848f5
    [Fortran names preserve the original case])
Packit 0848f5
AH_TEMPLATE([F77_NAME_MIXED_USCORE],
Packit 0848f5
    [Fortran names preserve the original case with one trailing underscore])
Packit 0848f5
AH_TEMPLATE([F77_NAME_UPPER],
Packit 0848f5
    [Fortran names are uppercase])
Packit 0848f5
AH_TEMPLATE([F77_NAME_LOWER_STDCALL],
Packit 0848f5
    [Fortran names are lowercase with no trailing underscore in stdcall])
Packit 0848f5
AH_TEMPLATE([F77_NAME_LOWER_USCORE_STDCALL],
Packit 0848f5
    [Fortran names are lowercase with one trailing underscore in stdcall])
Packit 0848f5
AH_TEMPLATE([F77_NAME_LOWER_2USCORE_STDCALL],
Packit 0848f5
    [Fortran names are lowercase with two trailing underscores in stdcall])
Packit 0848f5
AH_TEMPLATE([F77_NAME_MIXED_STDCALL],
Packit 0848f5
    [Fortran names preserve the original case in stdcall])
Packit 0848f5
AH_TEMPLATE([F77_NAME_MIXED_USCORE_STDCALL],
Packit 0848f5
    [Fortran names preserve the original case with one trailing underscore in stdcall])
Packit 0848f5
AH_TEMPLATE([F77_NAME_UPPER_STDCALL],
Packit 0848f5
    [Fortran names are uppercase in stdcall])
Packit 0848f5
])
Packit 0848f5
dnl
Packit 0848f5
dnl/*D
Packit 0848f5
dnl PAC_PROG_F77_CHECK_SIZEOF - Determine the size in bytes of a Fortran
Packit 0848f5
dnl type
Packit 0848f5
dnl
Packit 0848f5
dnl Synopsis:
Packit 0848f5
dnl PAC_PROG_F77_CHECK_SIZEOF(type,[cross-size])
Packit 0848f5
dnl
Packit 0848f5
dnl Output Effect:
Packit 0848f5
dnl Sets SIZEOF_F77_uctype to the size if bytes of type.
Packit 0848f5
dnl If type is unknown, the size is set to 0.
Packit 0848f5
dnl If cross-compiling, the value cross-size is used (it may be a variable)
Packit 0848f5
dnl For example 'PAC_PROG_F77_CHECK_SIZEOF(real)' defines
Packit 0848f5
dnl 'SIZEOF_F77_REAL' to 4 on most systems.  The variable 
Packit 0848f5
dnl 'pac_cv_sizeof_f77_<type>' (e.g., 'pac_cv_sizeof_f77_real') is also set to
Packit 0848f5
dnl the size of the type. 
Packit 0848f5
dnl If the corresponding variable is already set, that value is used.
Packit 0848f5
dnl If the name has an '*' in it (e.g., 'integer*4'), the defined name 
Packit 0848f5
dnl replaces that with an underscore (e.g., 'SIZEOF_F77_INTEGER_4').
Packit 0848f5
dnl
Packit 0848f5
dnl Notes:
Packit 0848f5
dnl If the 'cross-size' argument is not given, 'autoconf' will issue an error
Packit 0848f5
dnl message.  You can use '0' to specify undetermined.
Packit 0848f5
dnl
Packit 0848f5
dnl D*/
Packit 0848f5
AC_DEFUN([PAC_PROG_F77_CHECK_SIZEOF],[
Packit 0848f5
AC_REQUIRE([AC_HEADER_STDC])
Packit 0848f5
AC_REQUIRE([AC_F77_LIBRARY_LDFLAGS])
Packit 0848f5
changequote(<<, >>)dnl
Packit 0848f5
dnl The name to #define.
Packit 0848f5
dnl dnl If the arg value contains a variable, we need to update that
Packit 0848f5
define(<<PAC_TYPE_NAME>>, translit(sizeof_f77_$1, [a-z *], [A-Z__]))dnl
Packit 0848f5
dnl The cache variable name.
Packit 0848f5
define(<<PAC_CV_NAME>>, translit(pac_cv_f77_sizeof_$1, [ *], [__]))dnl
Packit 0848f5
changequote([, ])dnl
Packit 0848f5
AC_CACHE_CHECK([for size of Fortran type $1],PAC_CV_NAME,[
Packit 0848f5
AC_REQUIRE([PAC_PROG_F77_NAME_MANGLE])
Packit 0848f5
AC_LANG_PUSH([Fortran 77])
Packit 0848f5
AC_COMPILE_IFELSE([
Packit 0848f5
    AC_LANG_SOURCE([
Packit 0848f5
        subroutine isize()
Packit 0848f5
        $1 i(2)
Packit 0848f5
        call cisize( i(1), i(2) )
Packit 0848f5
        end
Packit 0848f5
    ])
Packit 0848f5
],[
Packit 0848f5
    # pac_f77compile_ok=yes
Packit 0848f5
    PAC_RUNLOG([mv conftest.$OBJEXT pac_f77conftest.$OBJEXT])
Packit 0848f5
    # Save original LIBS, prepend previously generated object file to LIBS
Packit 0848f5
    saved_LIBS="$LIBS"
Packit 0848f5
    LIBS="pac_f77conftest.$OBJEXT $FLIBS $LIBS"
Packit 0848f5
    AC_LANG_PUSH([C])
Packit 0848f5
    AC_RUN_IFELSE([
Packit 0848f5
        AC_LANG_PROGRAM([
Packit 0848f5
#if defined(HAVE_STDIO_H) || defined(STDC_HEADERS)
Packit 0848f5
#include <stdio.h>
Packit 0848f5
#endif
Packit 0848f5
#ifdef F77_NAME_UPPER
Packit 0848f5
#define cisize_ CISIZE
Packit 0848f5
#define isize_ ISIZE
Packit 0848f5
#elif defined(F77_NAME_LOWER) || defined(F77_NAME_MIXED)
Packit 0848f5
#define cisize_ cisize
Packit 0848f5
#define isize_ isize
Packit 0848f5
#endif
Packit 0848f5
static int isize_val=0;
Packit 0848f5
void cisize_(char *,char*);
Packit 0848f5
void isize_(void);
Packit 0848f5
void cisize_(char *i1p, char *i2p)
Packit 0848f5
{ 
Packit 0848f5
   isize_val = (int)(i2p - i1p);
Packit 0848f5
}
Packit 0848f5
        ],[
Packit 0848f5
    FILE *f = fopen("conftestval", "w");
Packit 0848f5
    if (!f) return 1;
Packit 0848f5
    isize_();
Packit 0848f5
    fprintf(f,"%d\n", isize_val);
Packit 0848f5
        ])
Packit 0848f5
        dnl Endof ac_lang_program
Packit 0848f5
    ],[
Packit 0848f5
        eval PAC_CV_NAME=`cat conftestval`
Packit 0848f5
    ],[
Packit 0848f5
        eval PAC_CV_NAME=0
Packit 0848f5
    ],[
Packit 0848f5
        # Use -9999 as value to emit a warning message after the cache_check.
Packit 0848f5
        ifelse([$2],[],[eval PAC_CV_NAME=-9999],[eval PAC_CV_NAME=$2])
Packit 0848f5
    ])
Packit 0848f5
    dnl Endof ac_run_ifelse
Packit 0848f5
    AC_LANG_POP([C])
Packit 0848f5
    LIBS="$saved_LIBS"
Packit 0848f5
    # remove previously generated object file.
Packit 0848f5
    rm -f pac_f77conftest.$OBJEXT
Packit 0848f5
],[
Packit 0848f5
    # pac_f77compile_ok=no
Packit 0848f5
    ifelse([$2],,eval PAC_CV_NAME=0,eval PAC_CV_NAME=$2)
Packit 0848f5
])  Endof ac_compile_ifelse
Packit 0848f5
AC_LANG_POP([Fortran 77])
Packit 0848f5
])
Packit 0848f5
dnl Endof ac_cache_check
Packit 0848f5
if test "$PAC_CV_NAME" = "-9999" ; then
Packit 0848f5
     AC_MSG_WARN([No value provided for size of $1 when cross-compiling])
Packit 0848f5
fi
Packit 0848f5
AC_DEFINE_UNQUOTED(PAC_TYPE_NAME,$PAC_CV_NAME,[Define size of PAC_TYPE_NAME])
Packit 0848f5
undefine([PAC_TYPE_NAME])
Packit 0848f5
undefine([PAC_CV_NAME])
Packit 0848f5
])
Packit 0848f5
dnl
Packit 0848f5
dnl This version uses a Fortran program to link programs.
Packit 0848f5
dnl This is necessary because some compilers provide shared libraries
Packit 0848f5
dnl that are not within the default linker paths (e.g., our installation
Packit 0848f5
dnl of the Portland Group compilers)
Packit 0848f5
dnl
Packit 0848f5
AC_DEFUN([PAC_PROG_F77_CHECK_SIZEOF_EXT],[
Packit 0848f5
changequote(<<,>>)dnl
Packit 0848f5
dnl The name to #define.
Packit 0848f5
dnl If the arg value contains a variable, we need to update that
Packit 0848f5
define(<<PAC_TYPE_NAME>>, translit(sizeof_f77_$1, [a-z *], [A-Z__]))dnl
Packit 0848f5
dnl The cache variable name.
Packit 0848f5
define(<<PAC_CV_NAME>>, translit(pac_cv_f77_sizeof_$1, [ *], [__]))dnl
Packit 0848f5
changequote([,])dnl
Packit 0848f5
AC_CACHE_CHECK([for size of Fortran type $1],PAC_CV_NAME,[
Packit 0848f5
AC_REQUIRE([AC_HEADER_STDC])
Packit 0848f5
AC_REQUIRE([PAC_PROG_F77_NAME_MANGLE])
Packit 0848f5
dnl if test "$cross_compiling" = yes ; then
Packit 0848f5
dnl     ifelse([$2],[],
Packit 0848f5
dnl         [AC_MSG_WARN([No value provided for size of $1 when cross-compiling])],
Packit 0848f5
dnl         [eval PAC_CV_NAME=$2])
Packit 0848f5
dnl fi
Packit 0848f5
AC_LANG_PUSH([C])
Packit 0848f5
AC_COMPILE_IFELSE([
Packit 0848f5
    AC_LANG_SOURCE([
Packit 0848f5
#if defined(HAVE_STDIO_H) || defined(STDC_HEADERS)
Packit 0848f5
#include <stdio.h>
Packit 0848f5
#endif
Packit 0848f5
#ifdef F77_NAME_UPPER
Packit 0848f5
#define cisize_ CISIZE
Packit 0848f5
#define isize_ ISIZE
Packit 0848f5
#elif defined(F77_NAME_LOWER) || defined(F77_NAME_MIXED)
Packit 0848f5
#define cisize_ cisize
Packit 0848f5
#define isize_ isize
Packit 0848f5
#endif
Packit 0848f5
int cisize_(char *,char*);
Packit 0848f5
int cisize_(char *i1p, char *i2p) {
Packit 0848f5
    int isize_val=0;
Packit 0848f5
    FILE *f = fopen("conftestval", "w");
Packit 0848f5
    if (!f) return 1;
Packit 0848f5
    isize_val = (int)(i2p - i1p);
Packit 0848f5
    fprintf(f,"%d\n", isize_val);
Packit 0848f5
    fclose(f);
Packit 0848f5
    return 0;
Packit 0848f5
}
Packit 0848f5
    ])
Packit 0848f5
    dnl Endof ac_lang_source
Packit 0848f5
],[
Packit 0848f5
    # pac_compile_ok=yes
Packit 0848f5
    PAC_RUNLOG([mv conftest.$OBJEXT pac_conftest.$OBJEXT])
Packit 0848f5
    # Save LIBS and prepend object file to LIBS
Packit 0848f5
    saved_LIBS="$LIBS"
Packit 0848f5
    LIBS="pac_conftest.$OBJEXT $LIBS"
Packit 0848f5
    AC_LANG_PUSH([Fortran 77])
Packit 0848f5
    AC_RUN_IFELSE([
Packit 0848f5
        AC_LANG_SOURCE([
Packit 0848f5
            program main
Packit 0848f5
            $1 a(2)
Packit 0848f5
            integer irc, cisize
Packit 0848f5
            irc = cisize(a(1),a(2))
Packit 0848f5
            end
Packit 0848f5
        ])
Packit 0848f5
    ],[
Packit 0848f5
        eval PAC_CV_NAME=`cat conftestval`
Packit 0848f5
    ],[
Packit 0848f5
        eval PAC_CV_NAME=0
Packit 0848f5
    ],[
Packit 0848f5
        # Use -9999 as value to emit a warning message after the cache_check.
Packit 0848f5
        ifelse([$2],[],[eval PAC_CV_NAME=-9999],[eval PAC_CV_NAME=$2])
Packit 0848f5
    ])
Packit 0848f5
    AC_LANG_POP([Fortran 77])
Packit 0848f5
    LIBS="$saved_LIBS"
Packit 0848f5
    # remove previously generated object file.
Packit 0848f5
    rm -f pac_conftest.$OBJEXT
Packit 0848f5
],[
Packit 0848f5
    AC_MSG_WARN([Unable to compile the C routine for finding the size of a $1])
Packit 0848f5
])
Packit 0848f5
AC_LANG_POP([C])
Packit 0848f5
])
Packit 0848f5
dnl Endof ac_cache_check
Packit 0848f5
if test "$PAC_CV_NAME" = "-9999" ; then
Packit 0848f5
     AC_MSG_WARN([No value provided for size of $1 when cross-compiling])
Packit 0848f5
fi
Packit 0848f5
AC_DEFINE_UNQUOTED(PAC_TYPE_NAME,$PAC_CV_NAME,[Define size of PAC_TYPE_NAME])
Packit 0848f5
undefine([PAC_TYPE_NAME])
Packit 0848f5
undefine([PAC_CV_NAME])
Packit 0848f5
])
Packit 0848f5
dnl
Packit 0848f5
dnl/*D
Packit 0848f5
dnl PAC_PROG_F77_EXCLAIM_COMMENTS
Packit 0848f5
dnl
Packit 0848f5
dnl Synopsis:
Packit 0848f5
dnl PAC_PROG_F77_EXCLAIM_COMMENTS([action-if-true],[action-if-false])
Packit 0848f5
dnl
Packit 0848f5
dnl Notes:
Packit 0848f5
dnl Check whether '!' may be used to begin comments in Fortran.
Packit 0848f5
dnl
Packit 0848f5
dnl This macro requires a version of autoconf `after` 2.13; the 'acgeneral.m4'
Packit 0848f5
dnl file contains an error in the handling of Fortran programs in 
Packit 0848f5
dnl 'AC_TRY_COMPILE' (fixed in our local version).
Packit 0848f5
dnl
Packit 0848f5
dnl D*/
Packit 0848f5
AC_DEFUN([PAC_PROG_F77_EXCLAIM_COMMENTS],[
Packit 0848f5
AC_CACHE_CHECK([whether Fortran 77 accepts ! for comments],
Packit 0848f5
pac_cv_prog_f77_exclaim_comments,[
Packit 0848f5
AC_LANG_PUSH([Fortran 77])
Packit 0848f5
AC_COMPILE_IFELSE([
Packit 0848f5
     AC_LANG_PROGRAM([],[!        This is a comment])
Packit 0848f5
],[
Packit 0848f5
    pac_cv_prog_f77_exclaim_comments="yes"
Packit 0848f5
],[
Packit 0848f5
    pac_cv_prog_f77_exclaim_comments="no"
Packit 0848f5
])
Packit 0848f5
AC_LANG_POP([Fortran 77])
Packit 0848f5
])
Packit 0848f5
if test "$pac_cv_prog_f77_exclaim_comments" = "yes" ; then
Packit 0848f5
    ifelse([$1],[],[:],[$1])
Packit 0848f5
else
Packit 0848f5
    ifelse([$2],[],[:],[$2])
Packit 0848f5
fi
Packit 0848f5
])dnl
Packit 0848f5
dnl
Packit 0848f5
dnl/*D
Packit 0848f5
dnl PAC_F77_CHECK_COMPILER_OPTION - Check that a F77 compiler option is
Packit 0848f5
dnl accepted without warning messages
Packit 0848f5
dnl
Packit 0848f5
dnl Synopsis:
Packit 0848f5
dnl PAC_F77_CHECK_COMPILER_OPTION(optionname,action-if-ok,action-if-fail)
Packit 0848f5
dnl
Packit 0848f5
dnl Output Effects:
Packit 0848f5
dnl
Packit 0848f5
dnl If no actions are specified, a working value is added to 'FOPTIONS'
Packit 0848f5
dnl
Packit 0848f5
dnl Notes:
Packit 0848f5
dnl This is now careful to check that the output is different, since 
Packit 0848f5
dnl some compilers are noisy.
Packit 0848f5
dnl 
Packit 0848f5
dnl We are extra careful to prototype the functions in case compiler options
Packit 0848f5
dnl that complain about poor code are in effect.
Packit 0848f5
dnl
Packit 0848f5
dnl Because this is a long script, we have ensured that you can pass a 
Packit 0848f5
dnl variable containing the option name as the first argument.
Packit 0848f5
dnl D*/
Packit 0848f5
AC_DEFUN([PAC_F77_CHECK_COMPILER_OPTION],[
Packit 0848f5
AC_MSG_CHECKING([whether Fortran 77 compiler accepts option $1])
Packit 0848f5
pac_opt="$1"
Packit 0848f5
AC_LANG_PUSH([Fortran 77])
Packit 0848f5
FFLAGS_orig="$FFLAGS"
Packit 0848f5
FFLAGS_opt="$pac_opt $FFLAGS"
Packit 0848f5
pac_result="unknown"
Packit 0848f5
Packit 0848f5
AC_LANG_CONFTEST([AC_LANG_PROGRAM()])
Packit 0848f5
FFLAGS="$FFLAGS_orig"
Packit 0848f5
rm -f pac_test1.log
Packit 0848f5
PAC_LINK_IFELSE_LOG([pac_test1.log], [], [
Packit 0848f5
    FFLAGS="$FFLAGS_opt"
Packit 0848f5
    rm -f pac_test2.log
Packit 0848f5
    PAC_LINK_IFELSE_LOG([pac_test2.log], [], [
Packit 0848f5
        PAC_RUNLOG_IFELSE([diff -b pac_test1.log pac_test2.log],
Packit 0848f5
                          [pac_result=yes], [pac_result=no])
Packit 0848f5
    ],[
Packit 0848f5
        pac_result=no
Packit 0848f5
    ])
Packit 0848f5
], [
Packit 0848f5
    pac_result=no
Packit 0848f5
])
Packit 0848f5
AC_MSG_RESULT([$pac_result])
Packit 0848f5
dnl Delete the conftest created by AC_LANG_CONFTEST.
Packit 0848f5
rm -f conftest.$ac_ext
Packit 0848f5
#
Packit 0848f5
if test "$pac_result" = "yes" ; then
Packit 0848f5
    AC_MSG_CHECKING([whether routines compiled with $pac_opt can be linked with ones compiled without $pac_opt])
Packit 0848f5
    pac_result=unknown
Packit 0848f5
    FFLAGS="$FFLAGS_orig"
Packit 0848f5
    rm -f pac_test3.log
Packit 0848f5
    PAC_COMPILE_IFELSE_LOG([pac_test3.log], [
Packit 0848f5
        AC_LANG_SOURCE([
Packit 0848f5
            subroutine try()
Packit 0848f5
            end
Packit 0848f5
        ])
Packit 0848f5
    ],[
Packit 0848f5
        PAC_RUNLOG([mv conftest.$OBJEXT pac_conftest.$OBJEXT])
Packit 0848f5
        saved_LIBS="$LIBS"
Packit 0848f5
        LIBS="pac_conftest.$OBJEXT $LIBS"
Packit 0848f5
Packit 0848f5
        FFLAGS="$FFLAGS_opt"
Packit 0848f5
        rm -f pac_test4.log
Packit 0848f5
        PAC_LINK_IFELSE_LOG([pac_test4.log], [AC_LANG_PROGRAM()], [
Packit 0848f5
            PAC_RUNLOG_IFELSE([diff -b pac_test2.log pac_test4.log],
Packit 0848f5
                              [pac_result=yes], [pac_result=no])
Packit 0848f5
        ],[
Packit 0848f5
            pac_result=no
Packit 0848f5
        ])
Packit 0848f5
        LIBS="$saved_LIBS"
Packit 0848f5
        rm -f pac_conftest.$OBJEXT
Packit 0848f5
    ],[
Packit 0848f5
        pac_result=no
Packit 0848f5
    ])
Packit 0848f5
    AC_MSG_RESULT([$pac_result])
Packit 0848f5
    rm -f pac_test3.log pac_test4.log
Packit 0848f5
fi
Packit 0848f5
rm -f pac_test1.log pac_test2.log
Packit 0848f5
Packit 0848f5
dnl Restore FFLAGS before 2nd/3rd argument commands are executed,
Packit 0848f5
dnl as 2nd/3rd argument command could be modifying FFLAGS.
Packit 0848f5
FFLAGS="$FFLAGS_orig"
Packit 0848f5
if test "$pac_result" = "yes" ; then
Packit 0848f5
     ifelse([$2],[],[FOPTIONS="$FOPTIONS $1"],[$2])
Packit 0848f5
else
Packit 0848f5
     ifelse([$3],[],[:],[$3])
Packit 0848f5
fi
Packit 0848f5
AC_LANG_POP([Fortran 77])
Packit 0848f5
])
Packit 0848f5
dnl
Packit 0848f5
dnl/*D
Packit 0848f5
dnl PAC_PROG_F77_LIBRARY_DIR_FLAG - Determine the flag used to indicate
Packit 0848f5
dnl the directories to find libraries in
Packit 0848f5
dnl
Packit 0848f5
dnl Notes:
Packit 0848f5
dnl Many compilers accept '-Ldir' just like most C compilers.  
Packit 0848f5
dnl Unfortunately, some (such as some HPUX Fortran compilers) do not, 
Packit 0848f5
dnl and require instead either '-Wl,-L,dir' or something else.  This
Packit 0848f5
dnl command attempts to determine what is accepted.  The flag is 
Packit 0848f5
dnl placed into 'F77_LIBDIR_LEADER'.
Packit 0848f5
dnl
Packit 0848f5
dnl D*/
Packit 0848f5
dnl
Packit 0848f5
dnl An earlier version of this only tried the arguments without using
Packit 0848f5
dnl a library.  This failed when the HP compiler complained about the
Packit 0848f5
dnl arguments, but produced an executable anyway.
Packit 0848f5
AC_DEFUN([PAC_PROG_F77_LIBRARY_DIR_FLAG],[
Packit 0848f5
AC_CACHE_CHECK([for Fortran 77 flag for library directories],
Packit 0848f5
pac_cv_prog_f77_library_dir_flag,[
Packit 0848f5
AC_LANG_PUSH([Fortran 77])
Packit 0848f5
AC_COMPILE_IFELSE([
Packit 0848f5
    AC_LANG_SOURCE([
Packit 0848f5
        subroutine f1conf
Packit 0848f5
        end
Packit 0848f5
    ])
Packit 0848f5
],[
Packit 0848f5
    # pac_f77compile_ok=yes
Packit 0848f5
    PAC_RUNLOG([mv conftest.$OBJEXT pac_f77conftest.$OBJEXT])
Packit 0848f5
    PAC_RUNLOG([test -d conftestdir || mkdir conftestdir])
Packit 0848f5
    PAC_RUNLOG([${AR-ar} ${AR_FLAGS-cr} conftestdir/libf77conftest.a pac_f77conftest.$OBJEXT])
Packit 0848f5
    PAC_RUNLOG([${RANLIB-ranlib} conftestdir/libf77conftest.a])
Packit 0848f5
    # Save original LIBS, prepend previously generated object file to LIBS
Packit 0848f5
    saved_LIBS="$LIBS"
Packit 0848f5
    LIBS="-lf77conftest $LIBS"
Packit 0848f5
    saved_LDFLAGS="$LDFLAGS"
Packit 0848f5
    pac_cv_prog_f77_library_dir_flag="none"
Packit 0848f5
    for ldir in "-L" "-Wl,-L," ; do
Packit 0848f5
        LDFLAGS="${ldir}conftestdir $saved_LDFLAGS"
Packit 0848f5
        AC_LINK_IFELSE([
Packit 0848f5
            AC_LANG_SOURCE([
Packit 0848f5
                program main
Packit 0848f5
                call f1conf
Packit 0848f5
                end
Packit 0848f5
            ])
Packit 0848f5
        ],[pac_cv_prog_f77_library_dir_flag="$ldir";break])
Packit 0848f5
    done
Packit 0848f5
    LDFLAGS="$saved_LDFLAGS"
Packit 0848f5
    LIBS="$saved_LIBS"
Packit 0848f5
    rm -rf conftestdir
Packit 0848f5
    rm -f pac_f77conftest.$OBJEXT
Packit 0848f5
],[])
Packit 0848f5
AC_LANG_POP([Fortran 77])
Packit 0848f5
])
Packit 0848f5
dnl Endof ac_cache_check
Packit 0848f5
if test "X$pac_cv_prog_f77_library_dir_flag" != "Xnone" ; then
Packit 0848f5
    F77_LIBDIR_LEADER="$pac_cv_prog_f77_library_dir_flag"
Packit 0848f5
    AC_SUBST(F77_LIBDIR_LEADER)
Packit 0848f5
fi
Packit 0848f5
])
Packit 0848f5
dnl
Packit 0848f5
dnl/*D 
Packit 0848f5
dnl PAC_PROG_F77_HAS_INCDIR - Check whether Fortran accepts -Idir flag
Packit 0848f5
dnl
Packit 0848f5
dnl Syntax:
Packit 0848f5
dnl   PAC_PROG_F77_HAS_INCDIR(directory,action-if-true,action-if-false)
Packit 0848f5
dnl
Packit 0848f5
dnl Output Effect:
Packit 0848f5
dnl  Sets 'F77_INCDIR' to the flag used to choose the directory.  
Packit 0848f5
dnl
Packit 0848f5
dnl Notes:
Packit 0848f5
dnl This refers to the handling of the common Fortran include extension,
Packit 0848f5
dnl not to the use of '#include' with the C preprocessor.
Packit 0848f5
dnl If directory does not exist, it will be created.  In that case, the 
Packit 0848f5
dnl directory should be a direct descendant of the current directory.
Packit 0848f5
dnl
Packit 0848f5
dnl D*/
Packit 0848f5
AC_DEFUN([PAC_PROG_F77_HAS_INCDIR],[
Packit 0848f5
ifelse([$1],[],[checkdir=f77tmpdir],[checkdir=$1;checkdir_is_given=yes])
Packit 0848f5
AC_CACHE_CHECK([for include directory flag for Fortran],
Packit 0848f5
pac_cv_prog_f77_has_incdir,[
Packit 0848f5
test -d $checkdir || mkdir $checkdir
Packit 0848f5
dnl PAC_RUNLOG([echo '       call sub()' > $checkdir/conftestf.h])
Packit 0848f5
echo '       call sub()' > $checkdir/conftestf.h
Packit 0848f5
AC_LANG_PUSH([Fortran 77])
Packit 0848f5
saved_FFLAGS="$FFLAGS"
Packit 0848f5
pac_cv_prog_f77_has_incdir="none"
Packit 0848f5
# SGI wants -Wf,-I
Packit 0848f5
for idir in "-I" "-Wf,-I" ; do
Packit 0848f5
    FFLAGS="${idir} $checkdir $saved_FFLAGS"
Packit 0848f5
    AC_COMPILE_IFELSE([
Packit 0848f5
        AC_LANG_SOURCE([
Packit 0848f5
            program main
Packit 0848f5
            include 'conftestf.h'
Packit 0848f5
            end
Packit 0848f5
        ])
Packit 0848f5
    ],[pac_cv_prog_f77_has_incdir="$idir"; break])
Packit 0848f5
done
Packit 0848f5
FFLAGS="$saved_FFLAGS"
Packit 0848f5
AC_LANG_POP([Fortran 77])
Packit 0848f5
if test "$checkdir_is_given" = "yes" ; then
Packit 0848f5
    rm -f $checkdir/conftestf.h
Packit 0848f5
else
Packit 0848f5
    rm -rf $checkdir
Packit 0848f5
fi
Packit 0848f5
])
Packit 0848f5
dnl Endof ac_cache_check
Packit 0848f5
if test "X$pac_cv_prog_f77_has_incdir" != "Xnone" ; then
Packit 0848f5
    F77_INCDIR="$pac_cv_prog_f77_has_incdir"
Packit 0848f5
    AC_SUBST(F77_INCDIR)
Packit 0848f5
fi
Packit 0848f5
])
Packit 0848f5
dnl
Packit 0848f5
dnl/*D
Packit 0848f5
dnl PAC_PROG_F77_ALLOWS_UNUSED_EXTERNALS - Check whether the Fortran compiler
Packit 0848f5
dnl allows unused and undefined functions to be listed in an external 
Packit 0848f5
dnl statement
Packit 0848f5
dnl
Packit 0848f5
dnl Syntax:
Packit 0848f5
dnl   PAC_PROG_F77_ALLOWS_UNUSED_EXTERNALS(action-if-true,action-if-false)
Packit 0848f5
dnl
Packit 0848f5
dnl D*/
Packit 0848f5
AC_DEFUN([PAC_PROG_F77_ALLOWS_UNUSED_EXTERNALS],[
Packit 0848f5
AC_CACHE_CHECK([whether Fortran allows unused externals],
Packit 0848f5
pac_cv_prog_f77_allows_unused_externals,[
Packit 0848f5
AC_LANG_PUSH([Fortran 77])
Packit 0848f5
AC_LINK_IFELSE([
Packit 0848f5
    AC_LANG_SOURCE([
Packit 0848f5
        program main
Packit 0848f5
        external bar
Packit 0848f5
        end
Packit 0848f5
    ])
Packit 0848f5
],[
Packit 0848f5
    pac_cv_prog_f77_allows_unused_externals="yes"
Packit 0848f5
],[
Packit 0848f5
    pac_cv_prog_f77_allows_unused_externals="no"
Packit 0848f5
])
Packit 0848f5
AC_LANG_POP([Fortran 77])
Packit 0848f5
])
Packit 0848f5
dnl Endof ac_cache_check
Packit 0848f5
if test "X$pac_cv_prog_f77_allows_unused_externals" = "Xyes" ; then
Packit 0848f5
   ifelse([$1],[],[:],[$1])
Packit 0848f5
else
Packit 0848f5
   ifelse([$2],[],[:],[$2])
Packit 0848f5
fi
Packit 0848f5
])
Packit 0848f5
dnl PAC_PROG_F77_RUN_PROC_FROM_C( c main program, fortran routine, 
Packit 0848f5
dnl                               [action-if-works], [action-if-fails], 
Packit 0848f5
dnl                               [cross-action] )
Packit 0848f5
dnl Fortran routine MUST be named ftest unless you include code
Packit 0848f5
dnl to select the appropriate Fortran name.
Packit 0848f5
dnl 
Packit 0848f5
AC_DEFUN([PAC_PROG_F77_RUN_PROC_FROM_C],[
Packit 0848f5
AC_REQUIRE([AC_HEADER_STDC])
Packit 0848f5
AC_REQUIRE([AC_F77_LIBRARY_LDFLAGS])
Packit 0848f5
AC_LANG_PUSH([Fortran 77])
Packit 0848f5
AC_COMPILE_IFELSE([
Packit 0848f5
    AC_LANG_SOURCE([$2])
Packit 0848f5
],[
Packit 0848f5
    # pac_f77compile_ok=yes
Packit 0848f5
    PAC_RUNLOG([mv conftest.$OBJEXT pac_f77conftest.$OBJEXT])
Packit 0848f5
    # Save original LIBS, prepend previously generated object file to LIBS
Packit 0848f5
    saved_LIBS="$LIBS"
Packit 0848f5
    LIBS="pac_f77conftest.$OBJEXT $FLIBS $LIBS"
Packit 0848f5
    AC_LANG_PUSH([C])
Packit 0848f5
    AC_RUN_IFELSE([
Packit 0848f5
        AC_LANG_SOURCE([
Packit 0848f5
#if defined(HAVE_STDIO_H) || defined(STDC_HEADERS)
Packit 0848f5
#include <stdio.h>
Packit 0848f5
#endif
Packit 0848f5
#ifdef F77_NAME_UPPER
Packit 0848f5
#define ftest_ FTEST
Packit 0848f5
#elif defined(F77_NAME_LOWER) || defined(F77_NAME_MIXED)
Packit 0848f5
#define ftest_ ftest
Packit 0848f5
#endif
Packit 0848f5
$1
Packit 0848f5
        ])
Packit 0848f5
    ],[
Packit 0848f5
        ifelse([$3],[],[:],[$3])
Packit 0848f5
    ],[
Packit 0848f5
        ifelse([$4],[],[:],[$4])
Packit 0848f5
    ],[
Packit 0848f5
        ifelse([$5],[],[:],[$5])
Packit 0848f5
    ])
Packit 0848f5
    AC_LANG_POP([C])
Packit 0848f5
    LIBS="$saved_LIBS"
Packit 0848f5
    rm -f pac_f77conftest.$OBJEXT
Packit 0848f5
],[
Packit 0848f5
])
Packit 0848f5
AC_LANG_POP([Fortran 77])
Packit 0848f5
])
Packit 0848f5
dnl PAC_PROG_F77_IN_C_LIBS
Packit 0848f5
dnl
Packit 0848f5
dnl Find the essential libraries that are needed to use the C linker to 
Packit 0848f5
dnl create a program that includes a trival Fortran code.  
Packit 0848f5
dnl
Packit 0848f5
dnl For example, all pgf90 compiled objects include a reference to the
Packit 0848f5
dnl symbol pgf90_compiled, found in libpgf90 .
Packit 0848f5
dnl
Packit 0848f5
dnl There is an additional problem.  To *run* programs, we may need 
Packit 0848f5
dnl additional arguments; e.g., if shared libraries are used.  Even
Packit 0848f5
dnl with autoconf 2.52, the autoconf macro to find the library arguments
Packit 0848f5
dnl doesn't handle this, either by detecting the use of -rpath or
Packit 0848f5
dnl by trying to *run* a trivial program.  It only checks for *linking*.
Packit 0848f5
dnl 
Packit 0848f5
dnl
Packit 0848f5
AC_DEFUN([PAC_PROG_F77_IN_C_LIBS],[
Packit 0848f5
AC_REQUIRE([AC_HEADER_STDC])
Packit 0848f5
AC_REQUIRE([AC_F77_LIBRARY_LDFLAGS])
Packit 0848f5
AC_MSG_CHECKING([for which Fortran libraries are needed to link C with Fortran])
Packit 0848f5
F77_IN_C_LIBS="invalid"
Packit 0848f5
AC_LANG_PUSH([Fortran 77])
Packit 0848f5
AC_COMPILE_IFELSE([
Packit 0848f5
    AC_LANG_SOURCE([
Packit 0848f5
        subroutine ftest
Packit 0848f5
        end
Packit 0848f5
    ])
Packit 0848f5
],[
Packit 0848f5
    # pac_f77compile_ok=yes
Packit 0848f5
    PAC_RUNLOG([mv conftest.$OBJEXT pac_f77conftest.$OBJEXT])
Packit 0848f5
    # Save original LIBS, prepend previously generated object file to LIBS
Packit 0848f5
    saved_LIBS="$LIBS"
Packit 0848f5
    LIBS="pac_f77conftest.$OBJEXT $FLIBS $saved_LIBS"
Packit 0848f5
    AC_LANG_PUSH([C])
Packit 0848f5
Packit 0848f5
    # Create conftest for all link tests.
Packit 0848f5
    AC_LANG_CONFTEST([
Packit 0848f5
        AC_LANG_PROGRAM([
Packit 0848f5
#if defined(HAVE_STDIO_H) || defined(STDC_HEADERS)
Packit 0848f5
#include <stdio.h>
Packit 0848f5
#endif
Packit 0848f5
        ],[
Packit 0848f5
#ifdef F77_NAME_UPPER
Packit 0848f5
#define ftest_ FTEST
Packit 0848f5
#elif defined(F77_NAME_LOWER) || defined(F77_NAME_MIXED)
Packit 0848f5
#define ftest_ ftest
Packit 0848f5
#endif
Packit 0848f5
extern void ftest_(void);
Packit 0848f5
ftest_();
Packit 0848f5
        ])
Packit 0848f5
    ])
Packit 0848f5
Packit 0848f5
    F77_IN_C_LIBS=""
Packit 0848f5
    AC_LINK_IFELSE([],[:],[
Packit 0848f5
        flibdirs=`echo $FLIBS | tr ' ' '\012' | grep '\-L' | tr '\012' ' '`
Packit 0848f5
        fliblibs=`echo $FLIBS | tr ' ' '\012' | grep -v '\-L' | tr '\012' ' '`
Packit 0848f5
        for flibs in $fliblibs ; do
Packit 0848f5
            LIBS="pac_f77conftest.$OBJEXT $flibdirs $flibs $saved_LIBS"
Packit 0848f5
            AC_LINK_IFELSE([],[F77_IN_C_LIBS="$flibdirs $flibs"; break])
Packit 0848f5
        done
Packit 0848f5
        if test "X$F77_IN_C_LIBS" = "X" ; then
Packit 0848f5
            flibscat=""
Packit 0848f5
            for flibs in $fliblibs ; do
Packit 0848f5
                flibscat="$flibscat $flibs"
Packit 0848f5
                LIBS="pac_f77conftest.$OBJEXT $flibdirs $flibscat $saved_LIBS"
Packit 0848f5
                AC_LINK_IFELSE([],[F77_IN_C_LIBS="$flibdirs $flibscat";break])
Packit 0848f5
            done
Packit 0848f5
        fi
Packit 0848f5
    ])
Packit 0848f5
Packit 0848f5
    # remove conftest created by ac_lang_conftest
Packit 0848f5
    rm -f conftest.$ac_ext
Packit 0848f5
    AC_LANG_POP([C])
Packit 0848f5
    LIBS="$saved_LIBS"
Packit 0848f5
    rm -f pac_f77conftest.$OBJEXT
Packit 0848f5
])
Packit 0848f5
AC_LANG_POP([Fortran 77])
Packit 0848f5
if test "X$F77_IN_C_LIBS" = "X" ; then
Packit 0848f5
    AC_MSG_RESULT(none)
Packit 0848f5
else
Packit 0848f5
    AC_MSG_RESULT($F77_IN_C_LIBS)
Packit 0848f5
fi
Packit 0848f5
])
Packit 0848f5
dnl
Packit 0848f5
dnl Test to see if we should use C or Fortran to link programs whose
Packit 0848f5
dnl main program is in Fortran.  We may find that neither work because 
Packit 0848f5
dnl we need special libraries in each case.
Packit 0848f5
dnl
Packit 0848f5
AC_DEFUN([PAC_PROG_F77_LINKER_WITH_C],[
Packit 0848f5
AC_REQUIRE([AC_F77_LIBRARY_LDFLAGS])
Packit 0848f5
AC_MSG_CHECKING([for linker for Fortran main program])
Packit 0848f5
dnl Create a C program that uses multiplication and division
Packit 0848f5
dnl in case that requires special libraries
Packit 0848f5
AC_LANG_PUSH([C])
Packit 0848f5
AC_COMPILE_IFELSE([
Packit 0848f5
    AC_LANG_PROGRAM([],[long long a;])
Packit 0848f5
],[
Packit 0848f5
    AC_DEFINE(HAVE_LONG_LONG,1,[Define if long long allowed])
Packit 0848f5
])
Packit 0848f5
AC_LANG_CONFTEST([
Packit 0848f5
    AC_LANG_SOURCE([
Packit 0848f5
#ifdef HAVE_LONG_LONG
Packit 0848f5
int f(int a, long long b) { int c; c = a * ( b / 3 ) / (b-1); return c ; }
Packit 0848f5
#else
Packit 0848f5
int f(int a, long b) { int c; c = a * b / (b-1); return c ; }
Packit 0848f5
#endif
Packit 0848f5
    ])
Packit 0848f5
])
Packit 0848f5
AC_LANG_POP([C])
Packit 0848f5
Packit 0848f5
dnl Create a Fortran program for test
Packit 0848f5
AC_LANG_PUSH([Fortran 77])
Packit 0848f5
AC_LANG_CONFTEST([
Packit 0848f5
    AC_LANG_SOURCE([
Packit 0848f5
        program main
Packit 0848f5
        double precision d
Packit 0848f5
        print *, "hi"
Packit 0848f5
        end
Packit 0848f5
    ])
Packit 0848f5
])
Packit 0848f5
AC_LANG_POP([Fortran 77])
Packit 0848f5
Packit 0848f5
dnl Initialize flags
Packit 0848f5
pac_linkwithf77=no
Packit 0848f5
pac_linkwithC=no
Packit 0848f5
Packit 0848f5
dnl Use F77 as a linker to compile a Fortran main and C subprogram.
Packit 0848f5
if test "$pac_linkwithC" != "yes" ; then
Packit 0848f5
    AC_LANG_PUSH([C])
Packit 0848f5
    AC_COMPILE_IFELSE([],[
Packit 0848f5
        PAC_RUNLOG([mv conftest.$OBJEXT pac_conftest.$OBJEXT])
Packit 0848f5
        saved_LIBS="$LIBS"
Packit 0848f5
        LIBS="pac_conftest.$OBJEXT $saved_LIBS"
Packit 0848f5
        AC_LANG_PUSH([Fortran 77])
Packit 0848f5
        AC_LINK_IFELSE([],[
Packit 0848f5
            AC_MSG_RESULT([Use Fortran to link programs])
Packit 0848f5
            pac_linkwithf77=yes
Packit 0848f5
        ])
Packit 0848f5
        AC_LANG_POP([Fortran 77])
Packit 0848f5
        LIBS="$saved_LIBS"
Packit 0848f5
        rm -f pac_conftest.$OBJEXT
Packit 0848f5
    ])
Packit 0848f5
    AC_LANG_POP([C])
Packit 0848f5
fi
Packit 0848f5
Packit 0848f5
dnl Use C as a linker and FLIBS to compile a Fortran main and C subprogram.
Packit 0848f5
if test "$pac_linkwithf77" != "yes" ; then
Packit 0848f5
    AC_LANG_PUSH([Fortran 77])
Packit 0848f5
    AC_COMPILE_IFELSE([],[
Packit 0848f5
        PAC_RUNLOG([mv conftest.$OBJEXT pac_f77conftest.$OBJEXT])
Packit 0848f5
        saved_LIBS="$LIBS"
Packit 0848f5
        LIBS="pac_f77conftest.$OBJEXT $FLIBS $saved_LIBS"
Packit 0848f5
        AC_LANG_PUSH([C])
Packit 0848f5
        AC_LINK_IFELSE([],[
Packit 0848f5
            pac_linkwithC=yes
Packit 0848f5
            AC_MSG_RESULT([Use C with FLIBS to link programs])
Packit 0848f5
            F77LINKER="$CC"
Packit 0848f5
            F77_LDFLAGS="$F77_LDFLAGS $FLIBS"
Packit 0848f5
        ])
Packit 0848f5
        AC_LANG_POP([C])
Packit 0848f5
        LIBS="$saved_LIBS"
Packit 0848f5
        rm -f pac_f77conftest.$OBJEXT
Packit 0848f5
    ])
Packit 0848f5
    AC_LANG_POP([Fortran 77])
Packit 0848f5
fi
Packit 0848f5
Packit 0848f5
AC_LANG_PUSH([Fortran 77])
Packit 0848f5
rm -f conftest.$ac_ext
Packit 0848f5
AC_LANG_POP([Fortran 77])
Packit 0848f5
Packit 0848f5
AC_LANG_PUSH([C])
Packit 0848f5
rm -f conftest.$ac_ext
Packit 0848f5
AC_LANG_POP([C])
Packit 0848f5
Packit 0848f5
if test "$pac_linkwithf77" != "yes" -a "$pac_linkwithC" != "yes" ; then
Packit 0848f5
    AC_MSG_ERROR([Could not determine a way to link a Fortran test program!])
Packit 0848f5
fi
Packit 0848f5
])
Packit 0848f5
dnl
Packit 0848f5
dnl Check to see if a C program can be linked when using the libraries
Packit 0848f5
dnl needed by C programs
Packit 0848f5
dnl
Packit 0848f5
AC_DEFUN([PAC_PROG_F77_CHECK_FLIBS],[
Packit 0848f5
AC_REQUIRE([AC_F77_LIBRARY_LDFLAGS])
Packit 0848f5
AC_MSG_CHECKING([whether $CC links with FLIBS found by autoconf])
Packit 0848f5
AC_LANG_PUSH([C])
Packit 0848f5
# Create a simple C program for the tests.
Packit 0848f5
AC_LANG_CONFTEST([
Packit 0848f5
    AC_LANG_PROGRAM([],[int a;])
Packit 0848f5
])
Packit 0848f5
# Try to link a C program with all of these libraries
Packit 0848f5
saved_LIBS="$LIBS"
Packit 0848f5
LIBS="$FLIBS $saved_LIBS"
Packit 0848f5
AC_LINK_IFELSE([],[
Packit 0848f5
    AC_MSG_RESULT([yes])
Packit 0848f5
],[
Packit 0848f5
    AC_MSG_RESULT([no])
Packit 0848f5
    AC_MSG_CHECKING([for which libraries can be used])
Packit 0848f5
    pac_ldirs=""
Packit 0848f5
    pac_libs=""
Packit 0848f5
    pac_other=""
Packit 0848f5
    for name in $FLIBS ; do
Packit 0848f5
        case $name in 
Packit 0848f5
        -l*) pac_libs="$pac_libs $name"   ;;
Packit 0848f5
        -L*) pac_ldirs="$pac_ldirs $name" ;;
Packit 0848f5
          *) pac_other="$pac_other $name" ;;
Packit 0848f5
        esac
Packit 0848f5
    done
Packit 0848f5
    keep_libs=""
Packit 0848f5
    for name in $pac_libs ; do
Packit 0848f5
        LIBS="$saved_LIBS $pac_ldirs $pac_other $name"
Packit 0848f5
        AC_LINK_IFELSE([],[
Packit 0848f5
            keep_libs="$keep_libs $name"
Packit 0848f5
        ])
Packit 0848f5
    done
Packit 0848f5
    AC_MSG_RESULT($keep_libs)
Packit 0848f5
    FLIBS="$pac_ldirs $pac_other $keep_libs"
Packit 0848f5
])
Packit 0848f5
LIBS="$saved_LIBS"
Packit 0848f5
rm -f conftest.$ac_ext
Packit 0848f5
AC_LANG_PUSH([C])
Packit 0848f5
])
Packit 0848f5
dnl
Packit 0848f5
dnl Test for extra libraries needed when linking C routines that use
Packit 0848f5
dnl stdio with Fortran.  This test was created for OSX, which 
Packit 0848f5
dnl sometimes requires -lSystemStubs.  If another library is needed,
Packit 0848f5
dnl add it to F77_OTHER_LIBS
Packit 0848f5
dnl
Packit 0848f5
AC_DEFUN([PAC_PROG_F77_AND_C_STDIO_LIBS],[
Packit 0848f5
AC_REQUIRE([AC_HEADER_STDC])
Packit 0848f5
AC_REQUIRE([PAC_PROG_F77_NAME_MANGLE])
Packit 0848f5
# To simply the code in the cache_check macro, chose the routine name
Packit 0848f5
# first, in case we need it
Packit 0848f5
confname=conf1_
Packit 0848f5
case "$pac_cv_prog_f77_name_mangle" in
Packit 0848f5
    "lower underscore")       confname=conf1_ ;;
Packit 0848f5
    "upper stdcall")          confname=CONF1  ;;
Packit 0848f5
    "upper")                  confname=CONF1  ;;
Packit 0848f5
    "lower doubleunderscore") confname=conf1_ ;;
Packit 0848f5
    "lower")                  confname=conf1  ;;
Packit 0848f5
    "mixed underscore")       confname=conf1_ ;;
Packit 0848f5
    "mixed")                  confname=conf1  ;;
Packit 0848f5
esac
Packit 0848f5
Packit 0848f5
AC_CACHE_CHECK([for libraries to link Fortran main with C stdio routines],
Packit 0848f5
pac_cv_prog_f77_and_c_stdio_libs,[
Packit 0848f5
pac_cv_prog_f77_and_c_stdio_libs=unknown
Packit 0848f5
AC_LANG_PUSH([C])
Packit 0848f5
AC_COMPILE_IFELSE([
Packit 0848f5
    AC_LANG_SOURCE([
Packit 0848f5
#if defined(HAVE_STDIO_H) || defined(STDC_HEADERS)
Packit 0848f5
#include <stdio.h>
Packit 0848f5
#endif
Packit 0848f5
int $confname(int a) {
Packit 0848f5
    printf( "The answer is %d\n", a ); fflush(stdout); return 0;
Packit 0848f5
}
Packit 0848f5
    ])
Packit 0848f5
],[
Packit 0848f5
    PAC_RUNLOG([mv conftest.$OBJEXT pac_conftest.$OBJEXT])
Packit 0848f5
    saved_LIBS="$LIBS"
Packit 0848f5
    AC_LANG_PUSH([Fortran 77])
Packit 0848f5
    AC_LANG_CONFTEST([
Packit 0848f5
        AC_LANG_SOURCE([
Packit 0848f5
            program main
Packit 0848f5
            call conf1(0)
Packit 0848f5
            end
Packit 0848f5
        ])
Packit 0848f5
    ])
Packit 0848f5
    for extralib in "" "-lSystemStubs" ; do
Packit 0848f5
        LIBS="pac_conftest.$OBJEXT $saved_LIBS $extralib"
Packit 0848f5
        AC_LINK_IFELSE([],[
Packit 0848f5
            pac_cv_prog_f77_and_c_stdio_libs="$extralib"; break
Packit 0848f5
        ])
Packit 0848f5
    done
Packit 0848f5
    if test "X$pac_cv_prog_f77_and_c_stdio_libs" = "X" ; then
Packit 0848f5
        pac_cv_prog_f77_and_c_stdio_libs=none
Packit 0848f5
    fi
Packit 0848f5
    rm -f conftest.$ac_ext
Packit 0848f5
    AC_LANG_POP([Fortran 77])
Packit 0848f5
    LIBS="$saved_LIBS"
Packit 0848f5
    rm -f pac_conftest.$OBJEXT
Packit 0848f5
])
Packit 0848f5
AC_LANG_POP([C])
Packit 0848f5
])
Packit 0848f5
dnl Endof ac_cache_check
Packit 0848f5
if test "$pac_cv_prog_f77_and_c_stdio_libs" != "none" \
Packit 0848f5
     -a "$pac_cv_prog_f77_and_c_stdio_libs" != "unknown" ; then
Packit 0848f5
    F77_OTHER_LIBS="$F77_OTHER_LIBS $pac_cv_prog_f77_and_c_stdio_libs"
Packit 0848f5
fi    
Packit 0848f5
])
Packit 0848f5
dnl
Packit 0848f5
dnl Check that the FLIBS determined by AC_F77_LIBRARY_LDFLAGS is valid.
Packit 0848f5
dnl That macro (at least as of autoconf 2.59) attempted to parse the output
Packit 0848f5
dnl of the compiler when asked to be verbose; in the case of the Fujitsu
Packit 0848f5
dnl frt Fortran compiler, it included files that frt looked for and then
Packit 0848f5
dnl discarded because they did not exist.
Packit 0848f5
dnl
Packit 0848f5
AC_DEFUN([PAC_PROG_F77_FLIBS_VALID],[
Packit 0848f5
AC_REQUIRE([AC_F77_LIBRARY_LDFLAGS])
Packit 0848f5
AC_MSG_CHECKING([whether $F77 accepts the FLIBS found by autoconf])
Packit 0848f5
pac_cv_f77_flibs_valid=unknown
Packit 0848f5
AC_LANG_PUSH([Fortran 77])
Packit 0848f5
AC_LANG_CONFTEST([
Packit 0848f5
    AC_LANG_SOURCE([
Packit 0848f5
        program main
Packit 0848f5
        end
Packit 0848f5
    ])
Packit 0848f5
])
Packit 0848f5
AC_LINK_IFELSE([],[
Packit 0848f5
    AC_MSG_RESULT([yes])
Packit 0848f5
],[
Packit 0848f5
    AC_MSG_RESULT([no])
Packit 0848f5
    AC_MSG_CHECKING([for valid entries in FLIBS])
Packit 0848f5
    goodFLIBS=""
Packit 0848f5
    saveFLIBS=$FLIBS
Packit 0848f5
    FLIBS=""
Packit 0848f5
    for arg in $saveFLIBS ; do
Packit 0848f5
        FLIBS="$goodFLIBS $arg"
Packit 0848f5
        AC_LINK_IFELSE([],[goodFLIBS=$FLIBS])
Packit 0848f5
    done
Packit 0848f5
    FLIBS=$goodFLIBS
Packit 0848f5
    AC_MSG_RESULT($FLIBS)
Packit 0848f5
])
Packit 0848f5
rm -f conftest.$ac_ext
Packit 0848f5
AC_LANG_POP([Fortran 77])
Packit 0848f5
])
Packit 0848f5
dnl
Packit 0848f5
dnl Check if the Fortran 77 and C objects are compatible in linking.
Packit 0848f5
dnl e.g. On some intel x86_64 Mac, Fortran compiler's default binary format
Packit 0848f5
dnl is different from C, so either -m64 or -m32 is needed in either CFLAGS
Packit 0848f5
dnl or FFLAGS.
Packit 0848f5
dnl
Packit 0848f5
AC_DEFUN([PAC_PROG_F77_OBJ_LINKS_WITH_C],[
Packit 0848f5
AC_REQUIRE([AC_F77_LIBRARY_LDFLAGS])
Packit 0848f5
AC_MSG_CHECKING([whether Fortran 77 and C objects are compatible])
Packit 0848f5
AC_LANG_PUSH([C])
Packit 0848f5
AC_LANG_CONFTEST([
Packit 0848f5
    AC_LANG_SOURCE([
Packit 0848f5
/* lower */
Packit 0848f5
void c_subpgm( int *rc );
Packit 0848f5
void c_subpgm( int *rc ) { *rc = 1; }
Packit 0848f5
Packit 0848f5
/* lower underscore */
Packit 0848f5
void c_subpgm_( int *rc );
Packit 0848f5
void c_subpgm_( int *rc ) { *rc = 2; }
Packit 0848f5
Packit 0848f5
/* upper */
Packit 0848f5
void C_SUBPGM( int *rc );
Packit 0848f5
void C_SUBPGM( int *rc ) { *rc = 3; }
Packit 0848f5
Packit 0848f5
/* lower doubleunderscore */
Packit 0848f5
void c_subpgm__( int *rc );
Packit 0848f5
void c_subpgm__( int *rc ) { *rc = 4; }
Packit 0848f5
Packit 0848f5
/* mixed */
Packit 0848f5
void C_subpgm( int *rc );
Packit 0848f5
void C_subpgm( int *rc ) { *rc = 5; }
Packit 0848f5
Packit 0848f5
/* mixed underscore */
Packit 0848f5
void C_subpgm_( int *rc );
Packit 0848f5
void C_subpgm_( int *rc ) { *rc = 6; }
Packit 0848f5
    ])
Packit 0848f5
])
Packit 0848f5
AC_LANG_POP([C])
Packit 0848f5
Packit 0848f5
AC_LANG_PUSH([Fortran 77])
Packit 0848f5
AC_LANG_CONFTEST([
Packit 0848f5
    AC_LANG_SOURCE([
Packit 0848f5
        program test
Packit 0848f5
        integer rc
Packit 0848f5
        rc = -1
Packit 0848f5
        call c_subpgm( rc )
Packit 0848f5
        write(6,*) "rc=", rc
Packit 0848f5
        end
Packit 0848f5
    ])
Packit 0848f5
])
Packit 0848f5
AC_LANG_POP([Fortran 77])
Packit 0848f5
Packit 0848f5
dnl Initialize flags
Packit 0848f5
pac_linkwithf77=no
Packit 0848f5
pac_linkwithC=no
Packit 0848f5
Packit 0848f5
dnl Use F77 as a linker to compile a Fortran main and C subprogram.
Packit 0848f5
if test "$pac_linkwithC" != "yes" ; then
Packit 0848f5
    AC_LANG_PUSH([C])
Packit 0848f5
    AC_COMPILE_IFELSE([],[
Packit 0848f5
        PAC_RUNLOG([mv conftest.$OBJEXT pac_conftest.$OBJEXT])
Packit 0848f5
        saved_LIBS="$LIBS"
Packit 0848f5
        LIBS="pac_conftest.$OBJEXT $saved_LIBS"
Packit 0848f5
        AC_LANG_PUSH([Fortran 77])
Packit 0848f5
        AC_LINK_IFELSE([],[
Packit 0848f5
            pac_linkwithf77=yes
Packit 0848f5
            AC_MSG_RESULT([yes])
Packit 0848f5
        ])
Packit 0848f5
        AC_LANG_POP([Fortran 77])
Packit 0848f5
        LIBS="$saved_LIBS"
Packit 0848f5
        if test "$pac_linkwithf77" = "yes" ; then
Packit 0848f5
            rm -f pac_conftest.$OBJEXT
Packit 0848f5
        fi
Packit 0848f5
    ])
Packit 0848f5
    AC_LANG_POP([C])
Packit 0848f5
fi
Packit 0848f5
Packit 0848f5
dnl Use C as a linker and FLIBS to compile a Fortran main and C subprogram.
Packit 0848f5
if test "$pac_linkwithf77" != "yes" ; then
Packit 0848f5
    AC_LANG_PUSH([Fortran 77])
Packit 0848f5
    AC_COMPILE_IFELSE([],[
Packit 0848f5
        PAC_RUNLOG([mv conftest.$OBJEXT pac_f77conftest.$OBJEXT])
Packit 0848f5
        saved_LIBS="$LIBS"
Packit 0848f5
        LIBS="pac_f77conftest.$OBJEXT $FLIBS $saved_LIBS"
Packit 0848f5
        AC_LANG_PUSH([C])
Packit 0848f5
        AC_LINK_IFELSE([],[
Packit 0848f5
            pac_linkwithC=yes
Packit 0848f5
            AC_MSG_RESULT([yes])
Packit 0848f5
        ])
Packit 0848f5
        AC_LANG_POP([C])
Packit 0848f5
        LIBS="$saved_LIBS"
Packit 0848f5
        if test "$pac_linkwithC" = "yes" ; then
Packit 0848f5
            rm -f pac_f77conftest.$OBJEXT
Packit 0848f5
        fi
Packit 0848f5
    ])
Packit 0848f5
    AC_LANG_POP([Fortran 77])
Packit 0848f5
fi
Packit 0848f5
Packit 0848f5
AC_LANG_PUSH([Fortran 77])
Packit 0848f5
rm -f conftest.$ac_ext
Packit 0848f5
AC_LANG_POP([Fortran 77])
Packit 0848f5
Packit 0848f5
AC_LANG_PUSH([C])
Packit 0848f5
rm -f conftest.$ac_ext
Packit 0848f5
AC_LANG_POP([C])
Packit 0848f5
Packit 0848f5
if test "$pac_linkwithf77" != "yes" -a "$pac_linkwithC" != "yes" ; then
Packit 0848f5
    AC_MSG_RESULT(no)
Packit 0848f5
    AC_CHECK_PROG(FILE, file, file, [])
Packit 0848f5
    if test "X$FILE" != "X" ; then
Packit 0848f5
        fobjtype="`${FILE} pac_f77conftest.$OBJEXT | sed -e \"s|pac_f77conftest\.$OBJEXT||g\"`"
Packit 0848f5
        cobjtype="`${FILE} pac_conftest.$OBJEXT | sed -e \"s|pac_conftest\.$OBJEXT||g\"`"
Packit 0848f5
        if test "$fobjtype" != "$cobjtype" ; then
Packit 0848f5
            AC_MSG_ERROR([****  Incompatible Fortran and C Object File Types!  ****
Packit 0848f5
F77 Object File Type produced by \"${F77} ${FFLAGS}\" is : ${fobjtype}.
Packit 0848f5
 C  Object File Type produced by \"${CC} ${CFLAGS}\" is : ${cobjtype}.])
Packit 0848f5
        fi
Packit 0848f5
    fi
Packit 0848f5
fi
Packit 0848f5
])
Packit 0848f5
dnl
Packit 0848f5
dnl /*D
Packit 0848f5
dnl PAC_F77_WORKS_WITH_CPP
Packit 0848f5
dnl
Packit 0848f5
dnl Checks if Fortran 77 compiler works with C preprocessor
Packit 0848f5
dnl
Packit 0848f5
dnl Most systems allow the Fortran compiler to process .F and .F90 files
Packit 0848f5
dnl using the C preprocessor.  However, some systems either do not
Packit 0848f5
dnl allow this or have serious bugs (OSF Fortran compilers have a bug
Packit 0848f5
dnl that generates an error message from cpp).  The following test
Packit 0848f5
dnl checks to see if .F works, and if not, whether "cpp -P -C" can be used
Packit 0848f5
dnl D*/
Packit 0848f5
AC_DEFUN([PAC_F77_WORKS_WITH_CPP],[
Packit 0848f5
AC_REQUIRE([AC_PROG_CPP])
Packit 0848f5
AC_MSG_CHECKING([whether Fortran 77 compiler processes .F files with C preprocessor])
Packit 0848f5
AC_LANG_PUSH([Fortran 77])
Packit 0848f5
saved_f77_ext=${ac_ext}
Packit 0848f5
ac_ext="F"
Packit 0848f5
saved_FFLAGS="$FFLAGS"
Packit 0848f5
FFLAGS="$FFLAGS $CPPFLAGS"
Packit 0848f5
AC_LANG_CONFTEST([
Packit 0848f5
    AC_LANG_SOURCE([
Packit 0848f5
        program main
Packit 0848f5
#define ASIZE 10
Packit 0848f5
        integer a(ASIZE)
Packit 0848f5
        end
Packit 0848f5
    ])
Packit 0848f5
])
Packit 0848f5
AC_COMPILE_IFELSE([],[
Packit 0848f5
    pac_cv_f77_accepts_F=yes
Packit 0848f5
    ifelse([$1],[],[],[$1=""])
Packit 0848f5
],[
Packit 0848f5
    pac_cv_f77_accepts_F=no
Packit 0848f5
    ifelse([$1],[],[:],[$1="false"])
Packit 0848f5
])
Packit 0848f5
# Restore Fortran 77's ac_ext but not FFLAGS
Packit 0848f5
ac_ext="$saved_f77_ext"
Packit 0848f5
Packit 0848f5
if test "$pac_cv_f77_accepts_F" != "yes" ; then
Packit 0848f5
    pac_cpp_f77="$ac_cpp -C -P conftest.F > conftest.$ac_ext"
Packit 0848f5
    PAC_RUNLOG_IFELSE([$pac_cpp_f77],[
Packit 0848f5
        if test -s conftest.${ac_ext} ; then
Packit 0848f5
            AC_COMPILE_IFELSE([],[
Packit 0848f5
                pac_cv_f77_accepts_F="no, use cpp"
Packit 0848f5
                ifelse([$1],[],[],[$1="$CPP -C -P"])
Packit 0848f5
            ],[])
Packit 0848f5
            rm -f conftest.${ac_ext}
Packit 0848f5
        fi
Packit 0848f5
    ],[])
Packit 0848f5
fi
Packit 0848f5
FFLAGS="$saved_FFLAGS"
Packit 0848f5
rm -f conftest.F
Packit 0848f5
AC_LANG_POP([Fortran 77])
Packit 0848f5
AC_MSG_RESULT([$pac_cv_f77_accepts_F])
Packit 0848f5
])
Packit 0848f5
dnl
Packit 0848f5
dnl /*D 
Packit 0848f5
dnl PAC_PROG_F77_CRAY_POINTER - Check if Fortran 77 supports Cray-style pointer.
Packit 0848f5
dnl                             If so, set pac_cv_prog_f77_has_pointer to yes
Packit 0848f5
dnl                             and find out if any extra compiler flag is
Packit 0848f5
dnl                             needed and set it as CRAYPTR_FFLAGS.
Packit 0848f5
dnl                             i.e. CRAYPTR_FFLAGS is meaningful only if
Packit 0848f5
dnl                             pac_cv_prog_f77_has_pointer = yes.
Packit 0848f5
dnl
Packit 0848f5
dnl Synopsis:
Packit 0848f5
dnl   PAC_PROG_F77_CRAY_POINTER([action-if-true],[action-if-false])
Packit 0848f5
dnl D*/
Packit 0848f5
AC_DEFUN([PAC_PROG_F77_CRAY_POINTER],[
Packit 0848f5
AC_CACHE_CHECK([whether Fortran 77 supports Cray-style pointer],
Packit 0848f5
pac_cv_prog_f77_has_pointer,[
Packit 0848f5
AC_LANG_PUSH([Fortran 77])
Packit 0848f5
AC_LANG_CONFTEST([
Packit 0848f5
    AC_LANG_PROGRAM([],[
Packit 0848f5
        integer M
Packit 0848f5
        pointer (MPTR,M)
Packit 0848f5
        data MPTR/0/
Packit 0848f5
    ])
Packit 0848f5
])
Packit 0848f5
saved_FFLAGS="$FFLAGS"
Packit 0848f5
pac_cv_prog_f77_has_pointer=no
Packit 0848f5
CRAYPTR_FFLAGS=""
Packit 0848f5
for ptrflag in '' '-fcray-pointer' ; do
Packit 0848f5
    FFLAGS="$saved_FFLAGS $ptrflag"
Packit 0848f5
    AC_COMPILE_IFELSE([], [
Packit 0848f5
        pac_cv_prog_f77_has_pointer=yes
Packit 0848f5
        CRAYPTR_FFLAGS="$ptrflag"
Packit 0848f5
        break
Packit 0848f5
    ])
Packit 0848f5
done
Packit 0848f5
dnl Restore FFLAGS first, since user may not want to modify FFLAGS
Packit 0848f5
FFLAGS="$saved_FFLAGS"
Packit 0848f5
dnl remove conftest after ac_lang_conftest
Packit 0848f5
rm -f conftest.$ac_ext
Packit 0848f5
AC_LANG_POP([Fortran 77])
Packit 0848f5
])
Packit 0848f5
if test "$pac_cv_prog_f77_has_pointer" = "yes" ; then
Packit 0848f5
    AC_MSG_CHECKING([for Fortran 77 compiler flag for Cray-style pointer])
Packit 0848f5
    if test "X$CRAYPTR_FFLAGS" != "X" ; then
Packit 0848f5
        AC_MSG_RESULT([$CRAYPTR_FFLAGS])
Packit 0848f5
    else
Packit 0848f5
        AC_MSG_RESULT([none])
Packit 0848f5
    fi
Packit 0848f5
    ifelse([$1],[],[:],[$1])
Packit 0848f5
else
Packit 0848f5
    ifelse([$2],[],[:],[$2])
Packit 0848f5
fi
Packit 0848f5
])
Packit 0848f5
dnl
Packit 0848f5
dnl
Packit 0848f5
dnl PAC_F77_INIT_WORKS_WITH_C
Packit 0848f5
dnl
Packit 0848f5
AC_DEFUN([PAC_F77_INIT_WORKS_WITH_C],[
Packit 0848f5
AC_REQUIRE([AC_HEADER_STDC])
Packit 0848f5
AC_MSG_CHECKING([whether Fortran init will work with C])
Packit 0848f5
pac_f_init_works_with_c=unknown
Packit 0848f5
AC_LANG_PUSH([Fortran 77])
Packit 0848f5
AC_COMPILE_IFELSE([
Packit 0848f5
    AC_LANG_SOURCE([
Packit 0848f5
        subroutine minit()
Packit 0848f5
        common /m1/ vc, vc2
Packit 0848f5
        character*1 vc(1,1), vc2(1)
Packit 0848f5
        common /m2/ vd
Packit 0848f5
        integer vd
Packit 0848f5
        save /m1/, /m2/
Packit 0848f5
        call minitc( vc, vc2, vd )
Packit 0848f5
        end
Packit 0848f5
    ])
Packit 0848f5
],[
Packit 0848f5
    PAC_RUNLOG([mv conftest.$OBJEXT pac_f77conftest.$OBJEXT])
Packit 0848f5
    saved_LIBS="$LIBS"
Packit 0848f5
    # This test checks if Fortran init can be done in pure C environment,
Packit 0848f5
    # i.e. no FLIBS in linking, so don't put FLIBS in LIBS below
Packit 0848f5
    dnl LIBS="pac_f77conftest.$OBJEXT $FLIBS $LIBS"
Packit 0848f5
    LIBS="pac_f77conftest.$OBJEXT $LIBS"
Packit 0848f5
    AC_LANG_PUSH([C])
Packit 0848f5
    AC_LINK_IFELSE([
Packit 0848f5
        AC_LANG_SOURCE([
Packit 0848f5
#if defined(HAVE_STDIO_H) || defined(STDC_HEADERS)
Packit 0848f5
#include <stdio.h>
Packit 0848f5
#endif
Packit 0848f5
#ifdef F77_NAME_UPPER
Packit 0848f5
#define minit_ MINIT
Packit 0848f5
#elif defined(F77_NAME_LOWER) || defined(F77_NAME_MIXED)
Packit 0848f5
#define minit_ minit
Packit 0848f5
#endif
Packit 0848f5
extern void minit_(void);
Packit 0848f5
int main( int argc, char **argv )
Packit 0848f5
{
Packit 0848f5
    minit_();
Packit 0848f5
    return 0;
Packit 0848f5
}
Packit 0848f5
char *v1 = 0;
Packit 0848f5
char *vc2 = 0;
Packit 0848f5
int  v2 = 0;
Packit 0848f5
void minitc_( char *dv1, int d, char *dv2, int d2, int dv3 );
Packit 0848f5
void minitc_( char *dv1, int d, char *dv2, int d2, int dv3 )
Packit 0848f5
{
Packit 0848f5
v1 = dv1;
Packit 0848f5
v2 = dv3;
Packit 0848f5
vc2 = dv2;
Packit 0848f5
*vc2 = ' ';
Packit 0848f5
}
Packit 0848f5
        ])
Packit 0848f5
    ],[pac_f_init_works_with_c=yes],[pac_f_init_works_with_c=no])
Packit 0848f5
    AC_LANG_POP([C])
Packit 0848f5
    LIBS="$saved_LIBS"
Packit 0848f5
    rm -f pac_f77conftest.$OBJEXT
Packit 0848f5
])
Packit 0848f5
AC_LANG_POP([Fortran 77])
Packit 0848f5
AC_MSG_RESULT([$pac_f_init_works_with_c])
Packit 0848f5
])
Packit 0848f5
dnl
Packit 0848f5
dnl PAC_F77_LOGICALS_IN_C(MPI_FINT)
Packit 0848f5
dnl
Packit 0848f5
dnl where MPI_FINT is the C type for Fortran integer.
Packit 0848f5
dnl
Packit 0848f5
dnl Use a Fortran main program.  This simplifies some steps, 
Packit 0848f5
dnl since getting all of the Fortran libraries (including shared 
Packit 0848f5
dnl libraries that are not in the default library search path) can 
Packit 0848f5
dnl be tricky.  Specifically, The PROG_F77_RUN_PROC_FROM_C failed with 
Packit 0848f5
dnl some installations of the Portland group compiler.
Packit 0848f5
dnl
Packit 0848f5
dnl We'd also like to check other values for .TRUE. and .FALSE. to see
Packit 0848f5
dnl if the compiler allows (or uses) more than one value (some DEC compilers,
Packit 0848f5
dnl for example, used the high (sign) bit to indicate true and false; the 
Packit 0848f5
dnl rest of the bits were ignored.  For now, we'll assume that there are 
Packit 0848f5
dnl unique true and false values.
Packit 0848f5
dnl
Packit 0848f5
AC_DEFUN([PAC_F77_LOGICALS_IN_C],[
Packit 0848f5
AC_REQUIRE([AC_HEADER_STDC])
Packit 0848f5
AC_REQUIRE([PAC_PROG_F77_NAME_MANGLE])
Packit 0848f5
pac_mpi_fint="$1"
Packit 0848f5
AC_MSG_CHECKING([for values of Fortran logicals])
Packit 0848f5
AC_CACHE_VAL(pac_cv_prog_f77_true_false_value,[
Packit 0848f5
pac_cv_prog_f77_true_false_value=""
Packit 0848f5
AC_LANG_PUSH([C])
Packit 0848f5
AC_COMPILE_IFELSE([
Packit 0848f5
    AC_LANG_SOURCE([
Packit 0848f5
#if defined(HAVE_STDIO_H) || defined(STDC_HEADERS)
Packit 0848f5
#include <stdio.h>
Packit 0848f5
#endif
Packit 0848f5
#if defined(HAVE_STDLIB_H) || defined(STDC_HEADERS)
Packit 0848f5
#include <stdlib.h>
Packit 0848f5
#endif
Packit 0848f5
#ifdef F77_NAME_UPPER
Packit 0848f5
#define ftest_ FTEST
Packit 0848f5
#elif defined(F77_NAME_LOWER) || defined(F77_NAME_MIXED)
Packit 0848f5
#define ftest_ ftest
Packit 0848f5
#endif
Packit 0848f5
void ftest_( $pac_mpi_fint *, $pac_mpi_fint *);
Packit 0848f5
void ftest_( $pac_mpi_fint *itrue, $pac_mpi_fint *ifalse )
Packit 0848f5
{
Packit 0848f5
  FILE *f = fopen("conftestval","w");
Packit 0848f5
  if (!f) exit(1);
Packit 0848f5
  fprintf( f, "%d %d\n", *itrue, *ifalse );
Packit 0848f5
  fclose(f);
Packit 0848f5
}
Packit 0848f5
    ])
Packit 0848f5
],[
Packit 0848f5
    PAC_RUNLOG([mv conftest.$OBJEXT pac_conftest.$OBJEXT])
Packit 0848f5
    saved_LIBS="$LIBS"
Packit 0848f5
    LIBS="pac_conftest.$OBJEXT $saved_LIBS"
Packit 0848f5
    AC_LANG_PUSH([Fortran 77])
Packit 0848f5
    AC_RUN_IFELSE([
Packit 0848f5
        AC_LANG_SOURCE([
Packit 0848f5
            program main
Packit 0848f5
            logical itrue, ifalse
Packit 0848f5
            itrue = .TRUE.
Packit 0848f5
            ifalse = .FALSE.
Packit 0848f5
            call ftest( itrue, ifalse )
Packit 0848f5
            end
Packit 0848f5
        ])
Packit 0848f5
    ],[
Packit 0848f5
        pac_cv_prog_f77_true_false_value="`cat conftestval`"
Packit 0848f5
    ],[
Packit 0848f5
        AC_MSG_WARN([Failed to build/run program to determine Fortran logical values.])
Packit 0848f5
    ],[
Packit 0848f5
        # Cross-Compiling.  Allow the user to set the values
Packit 0848f5
        if test -n "$CROSS_F77_TRUE_VALUE" -a -n "$CROSS_F77_FALSE_VALUE" ; then
Packit 0848f5
            pac_cv_prog_f77_true_false_value="$CROSS_F77_TRUE_VALUE $CROSS_F77_FALSE_VALUE"
Packit 0848f5
        else
Packit 0848f5
            AC_MSG_WARN([Either CROSS_F77_TRUE_VALUE="$CROSS_F77_TRUE_VALUE" or CROSS_F77_FALSE_VALUE="$CROSS_F77_FALSE_VALUE" is not set.])
Packit 0848f5
        fi
Packit 0848f5
    ])
Packit 0848f5
    AC_LANG_POP([Fortran 77])
Packit 0848f5
    LIBS="$saved_LIBS"
Packit 0848f5
    rm -f pac_conftest.$OBJEXT
Packit 0848f5
])
Packit 0848f5
AC_LANG_POP([C])
Packit 0848f5
])
Packit 0848f5
dnl Endof ac_cache_val
Packit 0848f5
if test "X$pac_cv_prog_f77_true_false_value" != "X" ; then
Packit 0848f5
    true_val="`echo $pac_cv_prog_f77_true_false_value | sed -e 's/ .*//g'`"
Packit 0848f5
    false_val="`echo $pac_cv_prog_f77_true_false_value | sed -e 's/.*  *//g'`"
Packit 0848f5
    if test -n "$true_val" -a -n "$false_val" ; then
Packit 0848f5
        AC_MSG_RESULT([True is $true_val and False is $false_val])
Packit 0848f5
    else
Packit 0848f5
        AC_MSG_RESULT([could not determine])
Packit 0848f5
    fi
Packit 0848f5
fi
Packit 0848f5
if test -n "$true_val" -a -n "$false_val" ; then
Packit 0848f5
    AC_DEFINE(F77_TRUE_VALUE_SET,1,[Define if we know the value of Fortran true and false])
Packit 0848f5
    AC_DEFINE_UNQUOTED(F77_TRUE_VALUE,$true_val,[The value of true in Fortran])
Packit 0848f5
    AC_DEFINE_UNQUOTED(F77_FALSE_VALUE,$false_val,[The value of false in Fortran])
Packit 0848f5
fi
Packit 0848f5
])
Packit 0848f5
dnl/*D
Packit 0848f5
dnl PAC_PROG_F77_MISMATCHED_ARGS([option],[AllOnly]) - Determine whether the 
Packit 0848f5
dnl Fortran compiler allows routines to be called with different 
Packit 0848f5
dnl argument types.  If not, attempts to determine a command-line argument 
Packit 0848f5
dnl that permits such use 
Packit 0848f5
dnl (The Fortran standard prohibits this usage)
Packit 0848f5
dnl
Packit 0848f5
dnl option is set to the compiler option to use.
Packit 0848f5
dnl if AllOnly is yes (literal, not variable with value), then only consider 
Packit 0848f5
dnl options that turn off checking
Packit 0848f5
dnl for all routines
Packit 0848f5
dnl
Packit 0848f5
dnl The NAG Fortran compiler, nagfor, is known to enforce this part of the
Packit 0848f5
dnl Fortran standard.
Packit 0848f5
dnl D*/
Packit 0848f5
AC_DEFUN([PAC_PROG_F77_MISMATCHED_ARGS],[
Packit 0848f5
AC_MSG_CHECKING([whether $F77 allows mismatched arguments])
Packit 0848f5
if test "X$pac_cv_prog_f77_mismatched_args" = X ; then
Packit 0848f5
    pac_cv_prog_f77_mismatched_args_parm=""
Packit 0848f5
    pac_cv_prog_f77_mismatched_args=no
Packit 0848f5
    AC_LANG_PUSH([Fortran 77])
Packit 0848f5
    AC_COMPILE_IFELSE([
Packit 0848f5
       AC_LANG_SOURCE([
Packit 0848f5
        program main
Packit 0848f5
        integer a
Packit 0848f5
        real b
Packit 0848f5
        character c
Packit 0848f5
        call foo1(a)
Packit 0848f5
        call foo1(b)
Packit 0848f5
        call foo1(c)
Packit 0848f5
        end
Packit 0848f5
])],[pac_cv_prog_f77_mismatched_args=yes])
Packit 0848f5
    if test "$pac_cv_prog_f77_mismatched_args" != "yes" ; then
Packit 0848f5
        # try again with -wmismatch=foo1
Packit 0848f5
        save_FFLAGS="$FFLAGS"
Packit 0848f5
	# The best solution is to turn off errors on particular routines
Packit 0848f5
	# if that isn't possible (e.g., too many of them), then
Packit 0848f5
	# just try arguments that turn off all checking
Packit 0848f5
	for flags in ifelse($2,yes,,"-wmismatch=foo1") "-mismatch" ; do
Packit 0848f5
            testok=no
Packit 0848f5
            FFLAGS="$FFLAGS $flags"
Packit 0848f5
            AC_COMPILE_IFELSE([
Packit 0848f5
            AC_LANG_SOURCE([
Packit 0848f5
        program main
Packit 0848f5
        integer a
Packit 0848f5
        real b
Packit 0848f5
        character c
Packit 0848f5
        call foo1(a)
Packit 0848f5
        call foo1(b)
Packit 0848f5
        call foo1(c)
Packit 0848f5
        end
Packit 0848f5
])],[testok=yes])
Packit 0848f5
            FFLAGS="$save_FFLAGS"
Packit 0848f5
            if test "$testok" = yes ; then break ; fi
Packit 0848f5
        done
Packit 0848f5
        if test "$testok" = yes ; then 
Packit 0848f5
	    pac_cv_prog_f77_mismatched_args_parm="$flags"
Packit 0848f5
            pac_cv_prog_f77_mismatched_args="yes, with $pac_cv_prog_f77_mismatched_args_parm"
Packit 0848f5
        fi
Packit 0848f5
    fi
Packit 0848f5
    AC_LANG_POP([Fortran 77])
Packit 0848f5
fi
Packit 0848f5
AC_MSG_RESULT($pac_cv_prog_f77_mismatched_args)
Packit 0848f5
if test "$pac_cv_prog_f77_mismatched_args" = no ; then
Packit 0848f5
    AC_MSG_ERROR([The Fortran compiler $F77 will not compile files that call 
Packit 0848f5
the same routine with arguments of different types.])
Packit 0848f5
fi
Packit 0848f5
Packit 0848f5
ifelse($1,,,[$1=$pac_cv_prog_f77_mismatched_args_parm])
Packit 0848f5
])