Blame confdb/aclocal_fc.m4

Packit Service c5cf8c
dnl PAC_FC_SEARCH_LIST - expands to a whitespace separated list of modern
Packit Service c5cf8c
dnl fortran compilers for use with AC_PROG_FC that is more suitable for HPC
Packit Service c5cf8c
dnl software packages
Packit Service c5cf8c
AC_DEFUN([PAC_FC_SEARCH_LIST],
Packit Service c5cf8c
         [ifort pgf90 pathf90 pathf95 xlf90 xlf95 xlf2003 gfortran f90 epcf90 f95 fort lf95 g95 ifc efc gfc])
Packit Service c5cf8c
dnl /*D
Packit Service c5cf8c
dnl PAC_PROG_FC([COMPILERS])
Packit Service c5cf8c
dnl
Packit Service c5cf8c
dnl COMPILERS is a space separated list of Fortran 77 compilers to search
Packit Service c5cf8c
dnl for.  Fortran 95 isn't strictly backwards-compatible with Fortran 77,
Packit Service c5cf8c
dnl but `f95' is worth trying.
Packit Service c5cf8c
dnl
Packit Service c5cf8c
dnl Compilers are ordered by
Packit Service c5cf8c
dnl  1. F77, F90, F95
Packit Service c5cf8c
dnl  2. Good/tested native compilers, bad/untested native compilers
Packit Service c5cf8c
dnl  3. Wrappers around f2c go last.
Packit Service c5cf8c
dnl
Packit Service c5cf8c
dnl `fort77' is a wrapper around `f2c'.
Packit Service c5cf8c
dnl It is believed that under HP-UX `fort77' is the name of the native
Packit Service c5cf8c
dnl compiler.  On some Cray systems, fort77 is a native compiler.
Packit Service c5cf8c
dnl frt is the Fujitsu F77 compiler.
Packit Service c5cf8c
dnl pgf77 and pgf90 are the Portland Group F77 and F90 compilers.
Packit Service c5cf8c
dnl xlf/xlf90/xlf95/xlf2003 are IBM (AIX) F77/F90/F95/F2003 compilers.
Packit Service c5cf8c
dnl lf95 is the Lahey-Fujitsu compiler.
Packit Service c5cf8c
dnl fl32 is the Microsoft Fortran "PowerStation" compiler.
Packit Service c5cf8c
dnl af77 is the Apogee F77 compiler for Intergraph hardware running CLIX.
Packit Service c5cf8c
dnl epcf90 is the "Edinburgh Portable Compiler" F90.
Packit Service c5cf8c
dnl fort is the Compaq Fortran 90 (now 95) compiler for Tru64 and Linux/Alpha.
Packit Service c5cf8c
dnl pathf90 is the Pathscale Fortran 90 compiler
Packit Service c5cf8c
dnl ifort is another name for the Intel f90 compiler
Packit Service c5cf8c
dnl efc - An older Intel compiler (?)
Packit Service c5cf8c
dnl ifc - An older Intel compiler
Packit Service c5cf8c
dnl fc  - A compiler on some unknown system.  This has been removed because
Packit Service c5cf8c
dnl       it may also be the name of a command for something other than
Packit Service c5cf8c
dnl       the Fortran compiler (e.g., fc=file system check!)
Packit Service c5cf8c
dnl gfortran - The GNU Fortran compiler (not the same as g95) 
Packit Service c5cf8c
dnl gfc - An alias for gfortran recommended in cygwin installations
Packit Service c5cf8c
dnl NOTE: this macro suffers from a basically intractable "expanded before it
Packit Service c5cf8c
dnl was required" problem when libtool is also used
Packit Service c5cf8c
dnl D*/
Packit Service c5cf8c
AC_DEFUN([PAC_PROG_FC],[
Packit Service c5cf8c
PAC_PUSH_FLAG([FCFLAGS])
Packit Service c5cf8c
AC_PROG_FC([m4_default([$1],[PAC_FC_SEARCH_LIST])])
Packit Service c5cf8c
PAC_POP_FLAG([FCFLAGS])
Packit Service c5cf8c
])
Packit Service c5cf8c
dnl
Packit Service c5cf8c
dnl PAC_FC_EXT checks for the default Fortran 90 program extension, f90 then f.
Packit Service c5cf8c
dnl This could be replaced by AC_FC_SRCEXT but since AC_FC_SRCEXT
Packit Service c5cf8c
dnl adds FCFLAGS_ext, which is used to modify FCFLAGS or Makefile.in.
Packit Service c5cf8c
dnl So will do this later.
Packit Service c5cf8c
dnl
Packit Service c5cf8c
AC_DEFUN([PAC_FC_EXT],[
Packit Service c5cf8c
AC_MSG_CHECKING([for extension for Fortran 90 programs])
Packit Service c5cf8c
ac_fc_srcext="f90"
Packit Service c5cf8c
AC_LANG_PUSH(Fortran)
Packit Service c5cf8c
AC_COMPILE_IFELSE([
Packit Service c5cf8c
    AC_LANG_PROGRAM()
Packit Service c5cf8c
],[
Packit Service c5cf8c
    AC_MSG_RESULT([f90])
Packit Service c5cf8c
],[
Packit Service c5cf8c
    ac_fc_srcext="f" 
Packit Service c5cf8c
    AC_COMPILE_IFELSE([
Packit Service c5cf8c
        AC_LANG_PROGRAM()
Packit Service c5cf8c
    ],[
Packit Service c5cf8c
        AC_MSG_RESULT([f])
Packit Service c5cf8c
    ],[
Packit Service c5cf8c
        AC_MSG_RESULT([unknown!])
Packit Service c5cf8c
    ])
Packit Service c5cf8c
])
Packit Service c5cf8c
AC_LANG_POP(Fortran)
Packit Service c5cf8c
])
Packit Service c5cf8c
dnl
Packit Service c5cf8c
dnl Internal routine for testing F90
Packit Service c5cf8c
dnl PAC_PROG_FC_WORKS()
Packit Service c5cf8c
dnl
Packit Service c5cf8c
AC_DEFUN([PAC_PROG_FC_WORKS],[
Packit Service c5cf8c
AC_REQUIRE([PAC_FC_EXT])
Packit Service c5cf8c
AC_LANG_PUSH(Fortran)
Packit Service c5cf8c
AC_MSG_CHECKING([whether the Fortran 90 compiler ($FC $FCFLAGS $LDFLAGS) works])
Packit Service c5cf8c
AC_LINK_IFELSE([
Packit Service c5cf8c
    AC_LANG_SOURCE([
Packit Service c5cf8c
        program conftest
Packit Service c5cf8c
        integer, dimension(10) :: n
Packit Service c5cf8c
        end
Packit Service c5cf8c
    ])
Packit Service c5cf8c
],[
Packit Service c5cf8c
    pac_cv_prog_fc_works="yes"
Packit Service c5cf8c
    AC_MSG_RESULT([$pac_cv_prog_fc_works])
Packit Service c5cf8c
    AC_MSG_CHECKING([whether the Fortran 90 compiler ($FC $FCFLAGS $LDFLAGS) is a cross-compiler])
Packit Service c5cf8c
    AC_RUN_IFELSE([],
Packit Service c5cf8c
    [pac_cv_prog_fc_cross="no"],
Packit Service c5cf8c
    [pac_cv_prog_fc_cross="yes"],
Packit Service c5cf8c
    [pac_cv_prog_fc_cross="$cross_compiling"]
Packit Service c5cf8c
    )
Packit Service c5cf8c
    AC_MSG_RESULT($pac_cv_prog_fc_cross)
Packit Service c5cf8c
],[
Packit Service c5cf8c
    pac_cv_prog_fc_works="no"
Packit Service c5cf8c
    AC_MSG_WARN([installation or configuration problem: Fortran 90 compiler cannot create executables.])
Packit Service c5cf8c
])
Packit Service c5cf8c
# The intel compiler sometimes generates these work.pc and .pcl files
Packit Service c5cf8c
rm -f work.pc work.pcl
Packit Service c5cf8c
AC_LANG_POP(Fortran)
Packit Service c5cf8c
dnl cross_compiling no longer maintained by autoconf as part of the
Packit Service c5cf8c
dnl AC_LANG changes.  If we set it here, a later AC_LANG may not 
Packit Service c5cf8c
dnl restore it (in the case where one compiler claims to be a cross compiler
Packit Service c5cf8c
dnl and another does not)
Packit Service c5cf8c
dnl cross_compiling=$pac_cv_prog_f90_cross
Packit Service c5cf8c
])
Packit Service c5cf8c
dnl/*D 
Packit Service c5cf8c
dnl PAC_PROG_FC_INT_KIND - Determine kind parameter for an integer with
Packit Service c5cf8c
dnl the specified number of bytes.
Packit Service c5cf8c
dnl
Packit Service c5cf8c
dnl Synopsis:
Packit Service c5cf8c
dnl  PAC_PROG_FC_INT_KIND(variable-to-set,number-of-bytes,[cross-size])
Packit Service c5cf8c
dnl
Packit Service c5cf8c
dnl D*/
Packit Service c5cf8c
AC_DEFUN([PAC_PROG_FC_INT_KIND],[
Packit Service c5cf8c
# Set the default
Packit Service c5cf8c
$1=-1
Packit Service c5cf8c
if test "$pac_cv_prog_fc_cross" = "yes" ; then
Packit Service c5cf8c
    AS_IF([test -z "$3"],[AC_MSG_ERROR(['$3' is empty])])
Packit Service c5cf8c
    $1="$3"
Packit Service c5cf8c
else
Packit Service c5cf8c
    AC_LANG_PUSH(Fortran)
Packit Service c5cf8c
    AC_MSG_CHECKING([for Fortran 90 integer kind for $2-byte integers])
Packit Service c5cf8c
    # Convert bytes to digits
Packit Service c5cf8c
    case $2 in 
Packit Service c5cf8c
        1) sellen=2 ;;
Packit Service c5cf8c
        2) sellen=4 ;;
Packit Service c5cf8c
        4) sellen=8 ;;
Packit Service c5cf8c
        8) sellen=16 ;;
Packit Service c5cf8c
       16) sellen=30 ;;
Packit Service c5cf8c
        *) sellen=8 ;;
Packit Service c5cf8c
    esac
Packit Service c5cf8c
    # Check for cached value
Packit Service c5cf8c
    eval testval=\$"pac_cv_prog_fc_int_kind_$sellen"
Packit Service c5cf8c
    if test -n "$testval" ; then 
Packit Service c5cf8c
        AC_MSG_RESULT([$testval (cached)])
Packit Service c5cf8c
        $1=$testval
Packit Service c5cf8c
    else
Packit Service c5cf8c
        KINDVAL="unavailable"
Packit Service c5cf8c
        eval "pac_cv_prog_fc_int_kind_$sellen"=-1
Packit Service c5cf8c
        AC_RUN_IFELSE([
Packit Service c5cf8c
            AC_LANG_SOURCE([
Packit Service c5cf8c
                program main
Packit Service c5cf8c
                integer ii
Packit Service c5cf8c
                ii = selected_int_kind($sellen)
Packit Service c5cf8c
                open(8, file="conftest1.out", form="formatted")
Packit Service c5cf8c
                write (8,*) ii
Packit Service c5cf8c
                close(8)
Packit Service c5cf8c
                stop
Packit Service c5cf8c
                end
Packit Service c5cf8c
            ])
Packit Service c5cf8c
        ],[pac_run_ok=yes],[pac_run_ok=no])
Packit Service c5cf8c
        if test "$pac_run_ok" = "yes" ; then
Packit Service c5cf8c
            if test -s conftest1.out ; then
Packit Service c5cf8c
                # Because of write, there may be a leading blank.
Packit Service c5cf8c
                KINDVAL=`cat conftest1.out | sed 's/ //g'`
Packit Service c5cf8c
                eval "pac_cv_prog_fc_int_kind_$sellen"=$KINDVAL
Packit Service c5cf8c
                $1=$KINDVAL
Packit Service c5cf8c
            fi
Packit Service c5cf8c
        fi
Packit Service c5cf8c
        AC_MSG_RESULT([$KINDVAL])
Packit Service c5cf8c
    fi # not cached
Packit Service c5cf8c
    AC_LANG_POP(Fortran)
Packit Service c5cf8c
fi # is not cross compiling
Packit Service c5cf8c
])dnl
Packit Service c5cf8c
dnl
Packit Service c5cf8c
dnl ------------------------------------------------------------------------
Packit Service c5cf8c
dnl Special characteristics that have no autoconf counterpart but that
Packit Service c5cf8c
dnl we need as part of the Fortran 90 support.  To distinquish these, they
Packit Service c5cf8c
dnl have a [PAC] prefix.
Packit Service c5cf8c
dnl 
Packit Service c5cf8c
dnl At least one version of the Cray compiler needs the option -em to
Packit Service c5cf8c
dnl generate a separate module file, rather than including the module
Packit Service c5cf8c
dnl information in the object (.o) file.
Packit Service c5cf8c
dnl
Packit Service c5cf8c
dnl
Packit Service c5cf8c
dnl PAC_FC_MODULE_EXT(action if found,action if not found)
Packit Service c5cf8c
dnl
Packit Service c5cf8c
AC_DEFUN([PAC_FC_MODULE_EXT],
Packit Service c5cf8c
[AC_CACHE_CHECK([for Fortran 90 module extension],
Packit Service c5cf8c
pac_cv_fc_module_ext,[
Packit Service c5cf8c
pac_cv_fc_module_case="unknown"
Packit Service c5cf8c
AC_LANG_PUSH(Fortran)
Packit Service c5cf8c
AC_COMPILE_IFELSE([
Packit Service c5cf8c
    AC_LANG_SOURCE([
Packit Service c5cf8c
        module conftest
Packit Service c5cf8c
        integer n
Packit Service c5cf8c
        parameter (n=1)
Packit Service c5cf8c
        end module conftest
Packit Service c5cf8c
    ])
Packit Service c5cf8c
],[
Packit Service c5cf8c
    # Look for module name
Packit Service c5cf8c
    # First, try to find known names.  This avoids confusion caused by
Packit Service c5cf8c
    # additional files (like <name>.stb created by some versions of pgf90)
Packit Service c5cf8c
    # Early versions of the Intel compiler used d as the module extension;
Packit Service c5cf8c
    # we include that just to finish the test as early as possible.
Packit Service c5cf8c
    for name in conftest CONFTEST ; do
Packit Service c5cf8c
        for ext in mod MOD d ; do
Packit Service c5cf8c
            if test -s $name.$ext ; then
Packit Service c5cf8c
                if test $name = conftest ; then
Packit Service c5cf8c
                    pac_cv_fc_module_case=lower
Packit Service c5cf8c
                else
Packit Service c5cf8c
                    pac_cv_fc_module_case=upper
Packit Service c5cf8c
                fi
Packit Service c5cf8c
                pac_cv_fc_module_ext=$ext
Packit Service c5cf8c
                pac_MOD=$ext
Packit Service c5cf8c
                break
Packit Service c5cf8c
            fi
Packit Service c5cf8c
        done
Packit Service c5cf8c
        if test -n "$pac_cv_fc_module_ext" ; then break ; fi
Packit Service c5cf8c
    done
Packit Service c5cf8c
    if test -z "$pac_MOD" ; then
Packit Service c5cf8c
        # The test on .err is needed for Cray Fortran.
Packit Service c5cf8c
        pac_MOD=`ls conftest.* 2>&1 | grep -v conftest.${ac_fc_srcext} | grep -v conftest.o | grep -v conftest.err`
Packit Service c5cf8c
        pac_MOD=`echo $pac_MOD | sed -e 's/conftest\.//g'`
Packit Service c5cf8c
        pac_cv_fc_module_case="lower"
Packit Service c5cf8c
        if test "X$pac_MOD" = "X" ; then
Packit Service c5cf8c
            pac_MOD=`ls CONFTEST* 2>&1 | grep -v CONFTEST.${ac_fc_srcext} | grep -v CONFTEST.o | grep -v CONFTEST.err`
Packit Service c5cf8c
            pac_MOD=`echo $pac_MOD | sed -e 's/CONFTEST\.//g'`
Packit Service c5cf8c
            if test -n "$pac_MOD" -a -s "CONFTEST.$pac_MOD" ; then
Packit Service c5cf8c
                pac_cv_fc_module_case="upper"
Packit Service c5cf8c
            else
Packit Service c5cf8c
                # Clear because we must have gotten an error message
Packit Service c5cf8c
                pac_MOD=""
Packit Service c5cf8c
            fi
Packit Service c5cf8c
        fi
Packit Service c5cf8c
        if test -z "$pac_MOD" ; then 
Packit Service c5cf8c
            pac_cv_fc_module_ext="unknown"
Packit Service c5cf8c
        else
Packit Service c5cf8c
            pac_cv_fc_module_ext=$pac_MOD
Packit Service c5cf8c
        fi
Packit Service c5cf8c
    fi
Packit Service c5cf8c
],[
Packit Service c5cf8c
    pac_cv_fc_module_ext="unknown"
Packit Service c5cf8c
])
Packit Service c5cf8c
Packit Service c5cf8c
if test "$pac_cv_fc_module_ext" = "unknown" ; then
Packit Service c5cf8c
    # Try again, but with an -em option.  Abbreviated, because we're
Packit Service c5cf8c
    # just looking for the Cray option
Packit Service c5cf8c
    saveFCFLAGS=$FCFLAGS
Packit Service c5cf8c
    FCFLAGS="$FCFLAGS -em"
Packit Service c5cf8c
    AC_COMPILE_IFELSE([
Packit Service c5cf8c
    AC_LANG_SOURCE([
Packit Service c5cf8c
        module conftest
Packit Service c5cf8c
        integer n
Packit Service c5cf8c
        parameter (n=1)
Packit Service c5cf8c
        end module conftest
Packit Service c5cf8c
    ])
Packit Service c5cf8c
],[
Packit Service c5cf8c
    if test -s conftest.mod ; then
Packit Service c5cf8c
        pac_cv_fc_module_ext="mod"
Packit Service c5cf8c
        pac_cv_fc_module_case="lower"
Packit Service c5cf8c
    elif test -s CONFTEST.mod ; then
Packit Service c5cf8c
        pac_cv_fc_module_ext="mod"
Packit Service c5cf8c
        pac_cv_fc_module_case="upper"
Packit Service c5cf8c
    fi
Packit Service c5cf8c
],[
Packit Service c5cf8c
    :
Packit Service c5cf8c
    # do nothing - already have the unknown default value
Packit Service c5cf8c
])
Packit Service c5cf8c
    if test "$pac_cv_fc_module_ext" = "unknown" ; then
Packit Service c5cf8c
        # The additional command line option did not help - restore
Packit Service c5cf8c
        # the original flags.
Packit Service c5cf8c
        FCFLAGS=$saveFCFLAGS
Packit Service c5cf8c
    fi
Packit Service c5cf8c
fi
Packit Service c5cf8c
AC_LANG_POP(Fortran)
Packit Service c5cf8c
])
Packit Service c5cf8c
#
Packit Service c5cf8c
AC_SUBST(FCMODEXT)
Packit Service c5cf8c
if test "$pac_cv_fc_module_ext" = "unknown" ; then
Packit Service c5cf8c
    ifelse($2,,:,[$2])
Packit Service c5cf8c
else
Packit Service c5cf8c
    ifelse($1,,FCMODEXT=$pac_MOD,[$1])
Packit Service c5cf8c
fi
Packit Service c5cf8c
])
Packit Service c5cf8c
dnl
Packit Service c5cf8c
dnl
Packit Service c5cf8c
dnl PAC_FC_MODULE_INCFLAG
Packit Service c5cf8c
AC_DEFUN([PAC_FC_MODULE_INCFLAG],[
Packit Service c5cf8c
AC_REQUIRE([PAC_FC_MODULE_EXT])
Packit Service c5cf8c
AC_CACHE_CHECK([for Fortran 90 module include flag],
Packit Service c5cf8c
pac_cv_fc_module_incflag,[
Packit Service c5cf8c
AC_LANG_PUSH(Fortran)
Packit Service c5cf8c
AC_LANG_CONFTEST([
Packit Service c5cf8c
    AC_LANG_SOURCE([
Packit Service c5cf8c
        module conf
Packit Service c5cf8c
        integer n
Packit Service c5cf8c
        parameter (n=1)
Packit Service c5cf8c
        end module conf
Packit Service c5cf8c
    ])
Packit Service c5cf8c
])
Packit Service c5cf8c
pac_madedir="no"
Packit Service c5cf8c
if test ! -d conf ; then mkdir conftestdir ; pac_madedir="yes"; fi
Packit Service c5cf8c
if test "$pac_cv_fc_module_case" = "upper" ; then
Packit Service c5cf8c
    pac_module="CONF.$pac_cv_fc_module_ext"
Packit Service c5cf8c
else
Packit Service c5cf8c
    pac_module="conf.$pac_cv_fc_module_ext"
Packit Service c5cf8c
fi
Packit Service c5cf8c
AC_COMPILE_IFELSE([],[
Packit Service c5cf8c
    if test -s "$pac_module" ; then
Packit Service c5cf8c
        mv $pac_module conftestdir
Packit Service c5cf8c
        # Remove any temporary files, and hide the work.pc file
Packit Service c5cf8c
        # (if the compiler generates them)
Packit Service c5cf8c
        if test -f work.pc ; then 
Packit Service c5cf8c
            mv -f work.pc conftest.pc
Packit Service c5cf8c
        fi
Packit Service c5cf8c
        rm -f work.pcl
Packit Service c5cf8c
    else
Packit Service c5cf8c
        AC_MSG_WARN([Unable to build a simple Fortran 90 module])
Packit Service c5cf8c
        # echo "configure: failed program was:" >&AS_MESSAGE_LOG_FD
Packit Service c5cf8c
        # cat conftest.$ac_ext >&AS_MESSAGE_LOG_FD
Packit Service c5cf8c
        _AC_MSG_LOG_CONFTEST
Packit Service c5cf8c
    fi
Packit Service c5cf8c
],[])
Packit Service c5cf8c
# Remove the conftest* after AC_LANG_CONFTEST
Packit Service c5cf8c
rm -rf conftest.dSYM
Packit Service c5cf8c
rm -f conftest.$ac_ext
Packit Service c5cf8c
Packit Service c5cf8c
dnl Create the conftest here so the test isn't created everytime inside loop.
Packit Service c5cf8c
AC_LANG_CONFTEST([AC_LANG_PROGRAM([],[use conf])])
Packit Service c5cf8c
Packit Service c5cf8c
# Save the original FCFLAGS
Packit Service c5cf8c
saved_FCFLAGS="$FCFLAGS"
Packit Service c5cf8c
pac_cv_fc_module_incflag=""
Packit Service c5cf8c
for inchdr in '-I' '-M' '-p' ; do
Packit Service c5cf8c
    FCFLAGS="$saved_FCFLAGS ${inchdr}conftestdir"
Packit Service c5cf8c
    AC_COMPILE_IFELSE([],[pac_cv_fc_module_incflag="$inchdr" ; break])
Packit Service c5cf8c
done
Packit Service c5cf8c
if test "X$pac_cv_fc_module_incflag" = "X" ; then
Packit Service c5cf8c
    if test -s conftest.pc ; then
Packit Service c5cf8c
        mv conftest.pc conftestdir/mpimod.pc
Packit Service c5cf8c
        echo "mpimod.pc" > conftestdir/mpimod.pcl
Packit Service c5cf8c
        echo "`pwd`/conftestdir/mpimod.pc" >> conftestdir/mpimod.pcl
Packit Service c5cf8c
        inchdr='-cl,'
Packit Service c5cf8c
        FCFLAGS="$save_FCFLAGS ${inchdr}conftestdir"
Packit Service c5cf8c
        AC_COMPILE_IFELSE([], [pac_fcompile_ok=yes], [pac_fcompile_ok=no])
Packit Service c5cf8c
        if test "$pac_fcompile_ok" = "yes" ; then
Packit Service c5cf8c
            pac_cv_fc_module_incflag="$inchdr"
Packit Service c5cf8c
            # Not quite right; see the comments that follow
Packit Service c5cf8c
            AC_MSG_RESULT([-cl,filename where filename contains a list of files and directories])
Packit Service c5cf8c
            FC_WORK_FILES_ARG="-cl,mpimod.pcl"
Packit Service c5cf8c
            FCMODINCSPEC="-cl,<dir>/<file>mod.pcl"
Packit Service c5cf8c
        else 
Packit Service c5cf8c
            # The version of the Intel compiler that I have refuses to let
Packit Service c5cf8c
            # you put the "work catalog" list anywhere but the current directory.
Packit Service c5cf8c
            pac_cv_fc_module_incflag="Unavailable!"
Packit Service c5cf8c
        fi
Packit Service c5cf8c
    else
Packit Service c5cf8c
        # Early versions of the Intel ifc compiler required a *file*
Packit Service c5cf8c
        # containing the names of files that contained the names of the
Packit Service c5cf8c
        # 
Packit Service c5cf8c
        # -cl,filename.pcl
Packit Service c5cf8c
        #   filename.pcl contains
Packit Service c5cf8c
        #     fullpathname.pc
Packit Service c5cf8c
        # The "fullpathname.pc" is generated, I believe, when a module is 
Packit Service c5cf8c
        # compiled.  
Packit Service c5cf8c
        # Intel compilers use a wierd system: -cl,filename.pcl .  If no file is
Packit Service c5cf8c
        # specified, work.pcl and work.pc are created.  However, if you specify
Packit Service c5cf8c
        # a file, it must contain the name of a file ending in .pc .  Ugh!
Packit Service c5cf8c
        pac_cv_fc_module_incflag="unknown"
Packit Service c5cf8c
    fi
Packit Service c5cf8c
fi
Packit Service c5cf8c
# Restore the original FCFLAGS
Packit Service c5cf8c
FCFLAGS="$saved_FCFLAGS"
Packit Service c5cf8c
if test "$pac_madedir" = "yes" ; then rm -rf conftestdir ; fi
Packit Service c5cf8c
# Remove the conftest* after AC_LANG_CONFTEST
Packit Service c5cf8c
# This is needed for Mac OSX 10.5
Packit Service c5cf8c
rm -rf conftest.dSYM
Packit Service c5cf8c
rm -f conftest*
Packit Service c5cf8c
AC_LANG_POP(Fortran)
Packit Service c5cf8c
])
Packit Service c5cf8c
AC_SUBST(FC_WORK_FILES_ARG)
Packit Service c5cf8c
AC_SUBST(FCMODINCFLAG)
Packit Service c5cf8c
FCMODINCFLAG=$pac_cv_fc_module_incflag
Packit Service c5cf8c
])
Packit Service c5cf8c
dnl
Packit Service c5cf8c
dnl
Packit Service c5cf8c
dnl
Packit Service c5cf8c
AC_DEFUN([PAC_FC_MODULE],[
Packit Service c5cf8c
PAC_FC_MODULE_EXT
Packit Service c5cf8c
PAC_FC_MODULE_INCFLAG
Packit Service c5cf8c
PAC_FC_MODULE_OUTFLAG
Packit Service c5cf8c
])
Packit Service c5cf8c
dnl
Packit Service c5cf8c
dnl PAC_FC_MODULE_OUTFLAG
Packit Service c5cf8c
AC_DEFUN([PAC_FC_MODULE_OUTFLAG],[
Packit Service c5cf8c
AC_REQUIRE([PAC_FC_MODULE_EXT])
Packit Service c5cf8c
AC_CACHE_CHECK([for Fortran 90 module output directory flag],
Packit Service c5cf8c
               [pac_cv_fc_module_outflag],
Packit Service c5cf8c
[
Packit Service c5cf8c
AC_LANG_PUSH([Fortran])
Packit Service c5cf8c
AC_LANG_CONFTEST([
Packit Service c5cf8c
    AC_LANG_SOURCE([
Packit Service c5cf8c
        module conf
Packit Service c5cf8c
        integer n
Packit Service c5cf8c
        parameter (n=1)
Packit Service c5cf8c
        end module conf
Packit Service c5cf8c
    ])
Packit Service c5cf8c
])
Packit Service c5cf8c
pac_madedir="no"
Packit Service c5cf8c
if test ! -d conf ; then mkdir conftestdir ; pac_madedir="yes"; fi
Packit Service c5cf8c
if test "$pac_cv_fc_module_case" = "upper" ; then
Packit Service c5cf8c
    pac_module="CONF.$pac_cv_fc_module_ext"
Packit Service c5cf8c
else
Packit Service c5cf8c
    pac_module="conf.$pac_cv_fc_module_ext"
Packit Service c5cf8c
fi
Packit Service c5cf8c
Packit Service c5cf8c
# check base case that the compiler can create modules and that they endup in
Packit Service c5cf8c
# the current directory
Packit Service c5cf8c
AC_COMPILE_IFELSE([],[
Packit Service c5cf8c
    if test -s "$pac_module" ; then
Packit Service c5cf8c
        rm -f "$pac_module"
Packit Service c5cf8c
        # Remove any temporary files, and hide the work.pc file
Packit Service c5cf8c
        # (if the compiler generates them)
Packit Service c5cf8c
        if test -f work.pc ; then 
Packit Service c5cf8c
            mv -f work.pc conftest.pc
Packit Service c5cf8c
        fi
Packit Service c5cf8c
        rm -f work.pcl
Packit Service c5cf8c
    else
Packit Service c5cf8c
        AC_MSG_WARN([Unable to build a simple Fortran 90 module])
Packit Service c5cf8c
        # echo "configure: failed program was:" >&AS_MESSAGE_LOG_FD
Packit Service c5cf8c
        # cat conftest.$ac_ext >&AS_MESSAGE_LOG_FD
Packit Service c5cf8c
        _AC_MSG_LOG_CONFTEST
Packit Service c5cf8c
    fi
Packit Service c5cf8c
],[])
Packit Service c5cf8c
Packit Service c5cf8c
# known flags for reasonably recent versions of various f90 compilers:
Packit Service c5cf8c
#   gfortran -J${dir}
Packit Service c5cf8c
#   xlf -qmoddir=${dir}
Packit Service c5cf8c
#   pgf90 -module ${dir}
Packit Service c5cf8c
#   ifort -module ${dir}
Packit Service c5cf8c
#   nagfor -mdir ${dir}
Packit Service c5cf8c
#   ftn -J ${dir}              ## the Cray fortran compiler
Packit Service c5cf8c
#   ftn -em -J${dir}           ## the Cray fortran compiler (crayftn, in 2013)
Packit Service c5cf8c
#      For this above case, we must have added -em to FCFLAGS, since other
Packit Service c5cf8c
#      module tests do not always use the module output flag.  See
Packit Service c5cf8c
#      FC_MODULE_EXT , where this is determined.
Packit Service c5cf8c
#   f95 -YMOD_OUT_DIR=${dir}   ## the Absoft fortran compiler
Packit Service c5cf8c
#   lf95 -M ${dir}             ## the Lahey/Fujitsu fortran compiler
Packit Service c5cf8c
#   f90 -moddir=${dir}         ## the Sun f90 compiler
Packit Service c5cf8c
#   g95 -fmod=${dir}
Packit Service c5cf8c
#
Packit Service c5cf8c
# If there are any compilers still out there that are totally brain-dead and
Packit Service c5cf8c
# don't support an output directory flag, we can write a wrapper script to tell
Packit Service c5cf8c
# users to use.  Alternatively they can use an older version of MPICH.
Packit Service c5cf8c
Packit Service c5cf8c
pac_cv_fc_module_outflag=
Packit Service c5cf8c
for mod_flag in '-J' '-J ' '-qmoddir=' '-module ' '-YMOD_OUT_DIR=' '-mdir ' '-moddir=' '-fmod=' '-M '; do
Packit Service c5cf8c
    rm -f conftestdir/NONEXISTENT conftestdir/*
Packit Service c5cf8c
    PAC_PUSH_FLAG([FCFLAGS])
Packit Service c5cf8c
    FCFLAGS="$FCFLAGS ${mod_flag}conftestdir"
Packit Service c5cf8c
    AC_COMPILE_IFELSE([],[pac_build_success=yes],[pac_build_success=no])
Packit Service c5cf8c
    AS_IF([test "X$pac_build_success" = Xyes],
Packit Service c5cf8c
          [AS_IF([test -s "conftestdir/${pac_module}"],
Packit Service c5cf8c
                 [pac_cv_fc_module_outflag="$mod_flag"])])
Packit Service c5cf8c
    PAC_POP_FLAG([FCFLAGS])
Packit Service c5cf8c
    AS_IF([test "X$pac_cv_fc_module_outflag" = X],[:],[break])
Packit Service c5cf8c
done
Packit Service c5cf8c
Packit Service c5cf8c
# Remove the conftest* after AC_LANG_CONFTEST
Packit Service c5cf8c
rm -rf conftest.dSYM
Packit Service c5cf8c
rm -f conftest.$ac_ext
Packit Service c5cf8c
Packit Service c5cf8c
if test "$pac_madedir" = "yes" ; then rm -rf conftestdir ; fi
Packit Service c5cf8c
AS_UNSET([pac_madedir])
Packit Service c5cf8c
# Remove the conftest* after AC_LANG_CONFTEST
Packit Service c5cf8c
# This is needed for Mac OSX 10.5
Packit Service c5cf8c
rm -rf conftest.dSYM
Packit Service c5cf8c
rm -f conftest*
Packit Service c5cf8c
AC_LANG_POP(Fortran)
Packit Service c5cf8c
])dnl end AC_CACHE_CHECK
Packit Service c5cf8c
Packit Service c5cf8c
AC_SUBST([FCMODOUTFLAG],[$pac_cv_fc_module_outflag])
Packit Service c5cf8c
])dnl end AC_DEFUN([PAC_FC_MODULE_OUTFLAG])
Packit Service c5cf8c
dnl
Packit Service c5cf8c
dnl PAC_FC_AND_F77_COMPATIBLE([action-if-true],[action-if-false])
Packit Service c5cf8c
dnl
Packit Service c5cf8c
dnl Determine whether object files compiled with Fortran 77 can be 
Packit Service c5cf8c
dnl linked to Fortran 90 main programs.
Packit Service c5cf8c
dnl
Packit Service c5cf8c
dnl The test uses a name that includes an underscore unless the 3rd
Packit Service c5cf8c
dnl argument provides another routine name.
Packit Service c5cf8c
dnl
Packit Service c5cf8c
AC_DEFUN([PAC_FC_AND_F77_COMPATIBLE],[
Packit Service c5cf8c
AC_REQUIRE([PAC_PROG_FC_WORKS])
Packit Service c5cf8c
AC_CACHE_CHECK([whether Fortran 90 compiler works with Fortran 77 compiler],
Packit Service c5cf8c
pac_cv_fc_and_f77,[
Packit Service c5cf8c
pacTestRoutine=foo_abc
Packit Service c5cf8c
ifelse([$3],,,[eval pacTestRoutine=$3])
Packit Service c5cf8c
pac_cv_fc_and_f77="unknown"
Packit Service c5cf8c
# compile the f77 program and link with the f90 program
Packit Service c5cf8c
# The reverse may not work because the Fortran 90 environment may
Packit Service c5cf8c
# expect to be in control (and to provide library files unknown to any other
Packit Service c5cf8c
# environment, even Fortran 77!)
Packit Service c5cf8c
AC_LANG_PUSH(Fortran 77)
Packit Service c5cf8c
AC_COMPILE_IFELSE([
Packit Service c5cf8c
    AC_LANG_SOURCE([
Packit Service c5cf8c
        subroutine ${pacTestRoutine}(b)
Packit Service c5cf8c
        integer b
Packit Service c5cf8c
        b = b + 1
Packit Service c5cf8c
        end
Packit Service c5cf8c
    ])
Packit Service c5cf8c
],[
Packit Service c5cf8c
    # pac_f77compile_ok=yes
Packit Service c5cf8c
    PAC_RUNLOG([mv conftest.$OBJEXT pac_f77conftest.$OBJEXT])
Packit Service c5cf8c
    # Save original LIBS, prepend previously generated object file to LIBS
Packit Service c5cf8c
    saved_LIBS="$LIBS"
Packit Service c5cf8c
    LIBS="pac_f77conftest.$OBJEXT $LIBS"
Packit Service c5cf8c
    AC_LANG_PUSH(Fortran)
Packit Service c5cf8c
    AC_LINK_IFELSE([
Packit Service c5cf8c
        AC_LANG_SOURCE([
Packit Service c5cf8c
            program main
Packit Service c5cf8c
            integer a
Packit Service c5cf8c
            a = 1
Packit Service c5cf8c
            call ${pacTestRoutine}(a)
Packit Service c5cf8c
            end
Packit Service c5cf8c
        ])
Packit Service c5cf8c
    ],[pac_cv_fc_and_f77=yes],[pac_cv_fc_and_f77=no])
Packit Service c5cf8c
    # Some versions of the Intel compiler produce these two files
Packit Service c5cf8c
    rm -f work.pc work.pcl
Packit Service c5cf8c
    # Restore LIBS
Packit Service c5cf8c
    LIBS="$saved_LIBS"
Packit Service c5cf8c
    AC_LANG_POP(Fortran)
Packit Service c5cf8c
    # remove previously generated object file.
Packit Service c5cf8c
    rm -f pac_f77conftest.$OBJEXT
Packit Service c5cf8c
], [
Packit Service c5cf8c
    # pac_f77compile_ok=no
Packit Service c5cf8c
    pac_cv_fc_and_f77=no
Packit Service c5cf8c
])
Packit Service c5cf8c
AC_LANG_POP(Fortran 77)
Packit Service c5cf8c
# Perform the requested action based on whether the test succeeded
Packit Service c5cf8c
if test "$pac_cv_fc_and_f77" = yes ; then
Packit Service c5cf8c
    ifelse($1,,:,[$1])
Packit Service c5cf8c
else
Packit Service c5cf8c
    ifelse($2,,:,[$2])
Packit Service c5cf8c
    AC_MSG_WARN([See config.log for the failed test program and its output.])
Packit Service c5cf8c
fi
Packit Service c5cf8c
])
Packit Service c5cf8c
dnl
Packit Service c5cf8c
])
Packit Service c5cf8c
dnl
Packit Service c5cf8c
dnl
Packit Service c5cf8c
dnl /*D 
Packit Service c5cf8c
dnl PAC_PROG_FC_CRAY_POINTER - Check if Fortran supports Cray-style pointer.
Packit Service c5cf8c
dnl                            If so, set pac_cv_prog_fc_has_pointer to yes
Packit Service c5cf8c
dnl                            and find out if any extra compiler flag is
Packit Service c5cf8c
dnl                            needed and set it as CRAYPTR_FCFLAGS.
Packit Service c5cf8c
dnl                            i.e. CRAYPTR_FCFLAGS is meaningful only if
Packit Service c5cf8c
dnl                            pac_cv_prog_fc_has_pointer = yes.
Packit Service c5cf8c
dnl
Packit Service c5cf8c
dnl Synopsis:
Packit Service c5cf8c
dnl   PAC_PROG_FC_CRAY_POINTER([action-if-true],[action-if-false])
Packit Service c5cf8c
dnl D*/
Packit Service c5cf8c
AC_DEFUN([PAC_PROG_FC_CRAY_POINTER],[
Packit Service c5cf8c
AC_CACHE_CHECK([whether Fortran 90 supports Cray-style pointer],
Packit Service c5cf8c
pac_cv_prog_fc_has_pointer,[
Packit Service c5cf8c
AC_LANG_PUSH([Fortran])
Packit Service c5cf8c
AC_LANG_CONFTEST([
Packit Service c5cf8c
    AC_LANG_PROGRAM([],[
Packit Service c5cf8c
        integer M
Packit Service c5cf8c
        pointer (MPTR,M)
Packit Service c5cf8c
        data MPTR/0/
Packit Service c5cf8c
    ])
Packit Service c5cf8c
])
Packit Service c5cf8c
saved_FCFLAGS="$FCFLAGS"
Packit Service c5cf8c
pac_cv_prog_fc_has_pointer=no
Packit Service c5cf8c
CRAYPTR_FCFLAGS=""
Packit Service c5cf8c
for ptrflag in '' '-fcray-pointer' ; do
Packit Service c5cf8c
    FCFLAGS="$saved_FCFLAGS $ptrflag"
Packit Service c5cf8c
    AC_COMPILE_IFELSE([],[
Packit Service c5cf8c
        pac_cv_prog_fc_has_pointer=yes
Packit Service c5cf8c
        CRAYPTR_FCFLAGS="$ptrflag"
Packit Service c5cf8c
        break
Packit Service c5cf8c
    ])
Packit Service c5cf8c
done
Packit Service c5cf8c
dnl Restore FCFLAGS first, since user may not want to modify FCFLAGS
Packit Service c5cf8c
FCFLAGS="$saved_FCFLAGS"
Packit Service c5cf8c
dnl remove conftest after ac_lang_conftest
Packit Service c5cf8c
rm -f conftest.$ac_ext
Packit Service c5cf8c
AC_LANG_POP([Fortran])
Packit Service c5cf8c
])
Packit Service c5cf8c
if test "$pac_cv_prog_fc_has_pointer" = "yes" ; then
Packit Service c5cf8c
    AC_MSG_CHECKING([for Fortran 90 compiler flag for Cray-style pointer])
Packit Service c5cf8c
    if test "X$CRAYPTR_FCFLAGS" != "X" ; then
Packit Service c5cf8c
        AC_MSG_RESULT([$CRAYPTR_FCFLAGS])
Packit Service c5cf8c
    else
Packit Service c5cf8c
        AC_MSG_RESULT([none])
Packit Service c5cf8c
    fi
Packit Service c5cf8c
    ifelse([$1],[],[:],[$1])
Packit Service c5cf8c
else
Packit Service c5cf8c
    ifelse([$2],[],[:],[$2])
Packit Service c5cf8c
fi
Packit Service c5cf8c
])
Packit Service c5cf8c
dnl
Packit Service c5cf8c
dnl
Packit Service c5cf8c
dnl
Packit Service c5cf8c
AC_DEFUN([PAC_PROG_FC_AND_C_STDIO_LIBS],[
Packit Service c5cf8c
AC_REQUIRE([AC_HEADER_STDC])
Packit Service c5cf8c
# To simply the code in the cache_check macro, chose the routine name
Packit Service c5cf8c
# first, in case we need it
Packit Service c5cf8c
confname=conf1_
Packit Service c5cf8c
case "$pac_cv_prog_f77_name_mangle" in
Packit Service c5cf8c
    "lower underscore")       confname=conf1_  ;;
Packit Service c5cf8c
    "upper stdcall")          confname=CONF1   ;;
Packit Service c5cf8c
    upper)                    confname=CONF1   ;;
Packit Service c5cf8c
    "lower doubleunderscore") confname=conf1_  ;;
Packit Service c5cf8c
    lower)                    confname=conf1   ;;
Packit Service c5cf8c
    "mixed underscore")       confname=conf1_  ;;
Packit Service c5cf8c
    mixed)                    confname=conf1   ;;
Packit Service c5cf8c
esac
Packit Service c5cf8c
Packit Service c5cf8c
AC_CACHE_CHECK([what libraries are needed to link Fortran90 programs with C routines that use stdio],pac_cv_prog_fc_and_c_stdio_libs,[
Packit Service c5cf8c
pac_cv_prog_fc_and_c_stdio_libs=unknown
Packit Service c5cf8c
Packit Service c5cf8c
AC_LANG_PUSH(C)
Packit Service c5cf8c
AC_COMPILE_IFELSE([
Packit Service c5cf8c
    AC_LANG_SOURCE([
Packit Service c5cf8c
#if defined(HAVE_STDIO_H) || defined(STDC_HEADERS)
Packit Service c5cf8c
#include <stdio.h>
Packit Service c5cf8c
#endif
Packit Service c5cf8c
int $confname( int a )
Packit Service c5cf8c
{ printf( "The answer is %d\n", a ); fflush(stdout); return 0; }
Packit Service c5cf8c
    ])
Packit Service c5cf8c
],[
Packit Service c5cf8c
    pac_compile_ok=yes
Packit Service c5cf8c
    PAC_RUNLOG([mv conftest.$OBJEXT pac_conftest.$OBJEXT])
Packit Service c5cf8c
    # Save LIBS and prepend object file to LIBS
Packit Service c5cf8c
    saved_LIBS="$LIBS"
Packit Service c5cf8c
    LIBS="pac_conftest.$OBJEXT $LIBS"
Packit Service c5cf8c
    AC_LANG_PUSH(Fortran)
Packit Service c5cf8c
    AC_LINK_IFELSE([
Packit Service c5cf8c
        AC_LANG_PROGRAM([],[call conf1(0)])
Packit Service c5cf8c
    ],[
Packit Service c5cf8c
        pac_cv_prog_fc_and_c_stdio_libs=none
Packit Service c5cf8c
    ],[
Packit Service c5cf8c
        # Try again with -lSystemStubs
Packit Service c5cf8c
        LIBS="$LIBS -lSystemStubs"
Packit Service c5cf8c
        AC_LINK_IFELSE([],[
Packit Service c5cf8c
            pac_cv_prog_fc_and_c_stdio_libs="-lSystemStubs"
Packit Service c5cf8c
        ],[])
Packit Service c5cf8c
    ])
Packit Service c5cf8c
    LIBS="$saved_LIBS"
Packit Service c5cf8c
    AC_LANG_POP(Fortran)
Packit Service c5cf8c
    rm -f pac_conftest.$OBJEXT
Packit Service c5cf8c
])
Packit Service c5cf8c
AC_LANG_POP(C)
Packit Service c5cf8c
dnl
Packit Service c5cf8c
if test "$pac_cv_prog_fc_and_c_stdio_libs" != none -a \
Packit Service c5cf8c
        "$pac_cv_prog_fc_and_c_stdio_libs" != unknown ; then
Packit Service c5cf8c
    FC_OTHER_LIBS="$FC_OTHER_LIBS $pac_cv_prog_fc_and_c_stdio_libs"    
Packit Service c5cf8c
fi
Packit Service c5cf8c
])
Packit Service c5cf8c
dnl
Packit Service c5cf8c
])
Packit Service c5cf8c
dnl
Packit Service c5cf8c
dnl/*D
Packit Service c5cf8c
dnl PAC_FC_CHECK_COMPILER_OPTION - Check that a FC compiler option is
Packit Service c5cf8c
dnl accepted without warning messages
Packit Service c5cf8c
dnl
Packit Service c5cf8c
dnl Synopsis:
Packit Service c5cf8c
dnl PAC_FC_CHECK_COMPILER_OPTION(optionname,action-if-ok,action-if-fail)
Packit Service c5cf8c
dnl
Packit Service c5cf8c
dnl Output Effects:
Packit Service c5cf8c
dnl
Packit Service c5cf8c
dnl If no actions are specified, a working value is added to 'FCOPTIONS'
Packit Service c5cf8c
dnl
Packit Service c5cf8c
dnl Notes:
Packit Service c5cf8c
dnl This is now careful to check that the output is different, since 
Packit Service c5cf8c
dnl some compilers are noisy.
Packit Service c5cf8c
dnl 
Packit Service c5cf8c
dnl We are extra careful to prototype the functions in case compiler options
Packit Service c5cf8c
dnl that complain about poor code are in effect.
Packit Service c5cf8c
dnl
Packit Service c5cf8c
dnl Because this is a long script, we have ensured that you can pass a 
Packit Service c5cf8c
dnl variable containing the option name as the first argument.
Packit Service c5cf8c
dnl D*/
Packit Service c5cf8c
AC_DEFUN([PAC_FC_CHECK_COMPILER_OPTION],[
Packit Service c5cf8c
AC_MSG_CHECKING([whether Fortran 90 compiler accepts option $1])
Packit Service c5cf8c
pac_opt="$1"
Packit Service c5cf8c
AC_LANG_PUSH(Fortran)
Packit Service c5cf8c
FCFLAGS_orig="$FCFLAGS"
Packit Service c5cf8c
FCFLAGS_opt="$pac_opt $FCFLAGS"
Packit Service c5cf8c
pac_result="unknown"
Packit Service c5cf8c
Packit Service c5cf8c
AC_LANG_CONFTEST([AC_LANG_PROGRAM()])
Packit Service c5cf8c
FCFLAGS="$FCFLAGS_orig"
Packit Service c5cf8c
rm -f pac_test1.log
Packit Service c5cf8c
PAC_LINK_IFELSE_LOG([pac_test1.log], [], [
Packit Service c5cf8c
    FCFLAGS="$FCFLAGS_opt"
Packit Service c5cf8c
    rm -f pac_test2.log
Packit Service c5cf8c
    PAC_LINK_IFELSE_LOG([pac_test2.log], [], [
Packit Service c5cf8c
        PAC_RUNLOG_IFELSE([diff -b pac_test1.log pac_test2.log],
Packit Service c5cf8c
                          [pac_result=yes], [pac_result=no])
Packit Service c5cf8c
    ],[
Packit Service c5cf8c
        pac_result=no
Packit Service c5cf8c
    ])
Packit Service c5cf8c
], [
Packit Service c5cf8c
    pac_result=no
Packit Service c5cf8c
])
Packit Service c5cf8c
AC_MSG_RESULT([$pac_result])
Packit Service c5cf8c
dnl Delete the conftest created by AC_LANG_CONFTEST.
Packit Service c5cf8c
rm -f conftest.$ac_ext
Packit Service c5cf8c
#
Packit Service c5cf8c
if test "$pac_result" = "yes" ; then
Packit Service c5cf8c
    AC_MSG_CHECKING([whether routines compiled with $pac_opt can be linked with ones compiled without $pac_opt])
Packit Service c5cf8c
    pac_result=unknown
Packit Service c5cf8c
    FCFLAGS="$FCFLAGS_orig"
Packit Service c5cf8c
    rm -f pac_test3.log
Packit Service c5cf8c
    PAC_COMPILE_IFELSE_LOG([pac_test3.log], [
Packit Service c5cf8c
        AC_LANG_SOURCE([
Packit Service c5cf8c
            subroutine try()
Packit Service c5cf8c
            end
Packit Service c5cf8c
        ])
Packit Service c5cf8c
    ],[
Packit Service c5cf8c
        PAC_RUNLOG([mv conftest.$OBJEXT pac_conftest.$OBJEXT])
Packit Service c5cf8c
        saved_LIBS="$LIBS"
Packit Service c5cf8c
        LIBS="pac_conftest.$OBJEXT $LIBS"
Packit Service c5cf8c
Packit Service c5cf8c
        FCFLAGS="$FCFLAGS_opt"
Packit Service c5cf8c
        rm -f pac_test4.log
Packit Service c5cf8c
        PAC_LINK_IFELSE_LOG([pac_test4.log], [AC_LANG_PROGRAM()], [
Packit Service c5cf8c
            PAC_RUNLOG_IFELSE([diff -b pac_test2.log pac_test4.log],
Packit Service c5cf8c
                              [pac_result=yes], [pac_result=no])
Packit Service c5cf8c
        ],[
Packit Service c5cf8c
            pac_result=no
Packit Service c5cf8c
        ])
Packit Service c5cf8c
        LIBS="$saved_LIBS"
Packit Service c5cf8c
        rm -f pac_conftest.$OBJEXT
Packit Service c5cf8c
    ],[
Packit Service c5cf8c
        pac_result=no
Packit Service c5cf8c
    ])
Packit Service c5cf8c
    AC_MSG_RESULT([$pac_result])
Packit Service c5cf8c
    rm -f pac_test3.log pac_test4.log
Packit Service c5cf8c
fi
Packit Service c5cf8c
rm -f pac_test1.log pac_test2.log
Packit Service c5cf8c
Packit Service c5cf8c
dnl Restore FCFLAGS before 2nd/3rd argument commands are executed,
Packit Service c5cf8c
dnl as 2nd/3rd argument command could be modifying FCFLAGS.
Packit Service c5cf8c
FCFLAGS="$FCFLAGS_orig"
Packit Service c5cf8c
if test "$pac_result" = "yes" ; then
Packit Service c5cf8c
     ifelse([$2],[],[FCOPTIONS="$FCOPTIONS $1"],[$2])
Packit Service c5cf8c
else
Packit Service c5cf8c
     ifelse([$3],[],[:],[$3])
Packit Service c5cf8c
fi
Packit Service c5cf8c
AC_LANG_POP(Fortran)
Packit Service c5cf8c
])
Packit Service c5cf8c
dnl /*D
Packit Service c5cf8c
dnl PAC_FC_WORKS_WITH_CPP
Packit Service c5cf8c
dnl
Packit Service c5cf8c
dnl Checks if Fortran 90 compiler works with C preprocessor
Packit Service c5cf8c
dnl
Packit Service c5cf8c
dnl Most systems allow the Fortran compiler to process .F and .F90 files
Packit Service c5cf8c
dnl using the C preprocessor.  However, some systems either do not
Packit Service c5cf8c
dnl allow this or have serious bugs (OSF Fortran compilers have a bug
Packit Service c5cf8c
dnl that generates an error message from cpp).  The following test
Packit Service c5cf8c
dnl checks to see if .F works, and if not, whether "cpp -P -C" can be used
Packit Service c5cf8c
dnl D*/
Packit Service c5cf8c
AC_DEFUN([PAC_FC_WORKS_WITH_CPP],[
Packit Service c5cf8c
AC_REQUIRE([AC_PROG_CPP])
Packit Service c5cf8c
AC_MSG_CHECKING([whether Fortran 90 compiler processes .F90 files with C preprocessor])
Packit Service c5cf8c
AC_LANG_PUSH([Fortran])
Packit Service c5cf8c
saved_fc_ext=${ac_ext}
Packit Service c5cf8c
ac_ext="F90"
Packit Service c5cf8c
saved_FCFLAGS="$FCFLAGS"
Packit Service c5cf8c
FCFLAGS="$FCFLAGS $CPPFLAGS"
Packit Service c5cf8c
AC_LANG_CONFTEST([
Packit Service c5cf8c
    AC_LANG_SOURCE([
Packit Service c5cf8c
        program main
Packit Service c5cf8c
#define ASIZE 10
Packit Service c5cf8c
        integer a(ASIZE)
Packit Service c5cf8c
        end
Packit Service c5cf8c
    ])
Packit Service c5cf8c
])
Packit Service c5cf8c
AC_COMPILE_IFELSE([],[
Packit Service c5cf8c
    pac_cv_fc_accepts_F90=yes
Packit Service c5cf8c
    ifelse([$1],[],[],[$1=""])
Packit Service c5cf8c
],[
Packit Service c5cf8c
    pac_cv_fc_accepts_F90=no
Packit Service c5cf8c
    ifelse([$1],[],[:],[$1="false"])
Packit Service c5cf8c
])
Packit Service c5cf8c
# Restore Fortran's ac_ext but not FCFLAGS
Packit Service c5cf8c
ac_ext="$saved_fc_ext"
Packit Service c5cf8c
Packit Service c5cf8c
if test "$pac_cv_fc_accepts_F90" != "yes" ; then
Packit Service c5cf8c
    pac_cpp_fc="$ac_cpp -C -P conftest.F90 > conftest.$ac_ext"
Packit Service c5cf8c
    PAC_RUNLOG_IFELSE([$pac_cpp_fc],[
Packit Service c5cf8c
        if test -s conftest.${ac_ext} ; then
Packit Service c5cf8c
            AC_COMPILE_IFELSE([],[
Packit Service c5cf8c
                pac_cv_fc_accepts_F90="no, use cpp"
Packit Service c5cf8c
                ifelse([$1],[],[],[$1="$CPP -C -P"])
Packit Service c5cf8c
            ],[])
Packit Service c5cf8c
            rm -f conftest.${ac_ext}
Packit Service c5cf8c
        fi
Packit Service c5cf8c
    ],[])
Packit Service c5cf8c
fi
Packit Service c5cf8c
FCFLAGS="$saved_FCFLAGS"
Packit Service c5cf8c
rm -f conftest.F90
Packit Service c5cf8c
AC_LANG_POP([Fortran])
Packit Service c5cf8c
AC_MSG_RESULT([$pac_cv_fc_accepts_F90])
Packit Service c5cf8c
])
Packit Service c5cf8c
dnl
Packit Service c5cf8c
dnl PAC_FC_VENDOR:
Packit Service c5cf8c
dnl Try to get a version string for the F90 compiler.  We may
Packit Service c5cf8c
dnl need this to find likely command-line arguments for accessing
Packit Service c5cf8c
dnl shared libraries
Packit Service c5cf8c
dnl
Packit Service c5cf8c
AC_DEFUN([PAC_FC_VENDOR],[
Packit Service c5cf8c
AC_MSG_CHECKING([for Fortran 90 compiler vendor])
Packit Service c5cf8c
# This is complicated by some compilers (such as the Intel 8.1 ifort)
Packit Service c5cf8c
# that return a non-zero status even when they accept the -V option
Packit Service c5cf8c
# (a zero status is returned only if there is a file).
Packit Service c5cf8c
pac_cv_fc_vendor="unknown"
Packit Service c5cf8c
for arg in --version -V -v ; do
Packit Service c5cf8c
    rm -f conftest.txt
Packit Service c5cf8c
    PAC_RUNLOG([$FC $arg </dev/null >conftest.txt 2>&1])
Packit Service c5cf8c
    # Ignore the return code, because some compilers set the
Packit Service c5cf8c
    # return code to zero on invalid arguments and some to 
Packit Service c5cf8c
    # non-zero on success (with no files to compile)
Packit Service c5cf8c
    if test -f conftest.txt ; then
Packit Service c5cf8c
        if grep 'Portland Group' conftest.txt >/dev/null 2>&1 ; then
Packit Service c5cf8c
            pac_cv_fc_vendor=pgi
Packit Service c5cf8c
        elif grep 'Sun Workshop' conftest.txt >/dev/null 2>&1 ; then
Packit Service c5cf8c
            pac_cv_fc_vendor=sun
Packit Service c5cf8c
	elif grep 'Sun Fortran 9' conftest.txt >/dev/null 2>&1 ; then 
Packit Service c5cf8c
	    pac_cv_fc_vendor=sun
Packit Service c5cf8c
        elif grep 'Absoft' conftest.txt >/dev/null 2>&1 ; then
Packit Service c5cf8c
            pac_cv_fc_vendor=absoft
Packit Service c5cf8c
        elif grep 'G95' conftest.txt >/dev/null 2>&1 ; then
Packit Service c5cf8c
            pac_cv_fc_vendor=gnu
Packit Service c5cf8c
        elif grep 'GNU Fortran' conftest.txt >/dev/null 2>&1 ; then
Packit Service c5cf8c
            # This is gfortran
Packit Service c5cf8c
            pac_cv_fc_vendor=gnu
Packit Service c5cf8c
        elif grep Intel conftest.txt >/dev/null 2>&1 ; then
Packit Service c5cf8c
            pac_cv_fc_vendor=intel
Packit Service c5cf8c
        fi
Packit Service c5cf8c
    fi
Packit Service c5cf8c
    if test "$pac_cv_fc_vendor" != "unknown" ; then break ; fi
Packit Service c5cf8c
done
Packit Service c5cf8c
if test "$pac_cv_fc_vendor" = "unknown" ; then
Packit Service c5cf8c
    # Try to use the compiler name
Packit Service c5cf8c
    if test "$FC" = "ifort" -o "$FC" = "ifc" ; then
Packit Service c5cf8c
        pac_cv_fc_vendor=intel
Packit Service c5cf8c
    elif test "$FC" = "pgf90" ; then
Packit Service c5cf8c
        pac_cv_fc_vendor=pgi
Packit Service c5cf8c
    elif test "$FC" = "xlf90" -o "$FC" = "xlf90_r" ; then
Packit Service c5cf8c
        pac_cv_fc_vendor=ibm
Packit Service c5cf8c
    elif test "$FC" = "xlf95" -o "$FC" = "xlf95_r" ; then
Packit Service c5cf8c
        pac_cv_fc_vendor=ibm
Packit Service c5cf8c
    fi
Packit Service c5cf8c
fi
Packit Service c5cf8c
AC_MSG_RESULT([$pac_cv_fc_vendor])
Packit Service c5cf8c
rm -f conftest.txt
Packit Service c5cf8c
# End of checking for F90 compiler vendor
Packit Service c5cf8c
])
Packit Service c5cf8c
dnl
Packit Service c5cf8c
dnl PAC_F77_IS_FC([ACTION_IF_TRUE],[ACTION_IF_FALSE])
Packit Service c5cf8c
dnl Check if F77 is a Fortran 90 compiler.
Packit Service c5cf8c
dnl
Packit Service c5cf8c
AC_DEFUN([PAC_F77_IS_FC],[
Packit Service c5cf8c
AC_MSG_CHECKING([whether $F77 is a Fortran 90 compiler])
Packit Service c5cf8c
AC_LANG_PUSH([Fortran 77])
Packit Service c5cf8c
saved_ac_ext=$ac_ext
Packit Service c5cf8c
ac_ext="f90"
Packit Service c5cf8c
AC_LINK_IFELSE([
Packit Service c5cf8c
    AC_LANG_SOURCE([
Packit Service c5cf8c
        program main
Packit Service c5cf8c
        integer, dimension(10) :: n
Packit Service c5cf8c
        integer k
Packit Service c5cf8c
        print *,  range(k)
Packit Service c5cf8c
        end
Packit Service c5cf8c
    ])
Packit Service c5cf8c
],[
Packit Service c5cf8c
    pac_cv_prog_f77_is_fc=yes
Packit Service c5cf8c
    ifelse([$1],[],[],[$1])
Packit Service c5cf8c
],[
Packit Service c5cf8c
    pac_cv_prog_f77_is_fc=no
Packit Service c5cf8c
    ifelse([$2],[],[],[$2])
Packit Service c5cf8c
])
Packit Service c5cf8c
AC_MSG_RESULT([$pac_cv_prog_f77_is_fc])
Packit Service c5cf8c
AC_LANG_POP([Fortran 77])
Packit Service c5cf8c
])
Packit Service c5cf8c
dnl
Packit Service c5cf8c
dnl PAC_FC_FLOAT_MODEL(float_type, [variable-set-if-successful-test])
Packit Service c5cf8c
dnl variable-set-if-successful-test is optional variable.
Packit Service c5cf8c
dnl
Packit Service c5cf8c
dnl This is a runtime test.
Packit Service c5cf8c
dnl
Packit Service c5cf8c
AC_DEFUN([PAC_FC_FLOAT_MODEL],[
Packit Service c5cf8c
type="$1"
Packit Service c5cf8c
AC_MSG_CHECKING([for precision and range of $type])
Packit Service c5cf8c
AC_LANG_PUSH([Fortran])
Packit Service c5cf8c
rm -f pac_fconftest.out
Packit Service c5cf8c
AC_RUN_IFELSE([
Packit Service c5cf8c
    AC_LANG_SOURCE([
Packit Service c5cf8c
        program main
Packit Service c5cf8c
        $type aa
Packit Service c5cf8c
        open(8, file="pac_fconftest.out", form="formatted")
Packit Service c5cf8c
        write(8,*) precision(aa), ",", range(aa)
Packit Service c5cf8c
        close(8)
Packit Service c5cf8c
        end
Packit Service c5cf8c
    ])
Packit Service c5cf8c
],[
Packit Service c5cf8c
    if test -s pac_fconftest.out ; then
Packit Service c5cf8c
        pac_fc_num_model="`sed -e 's/  */ /g' pac_fconftest.out`"
Packit Service c5cf8c
        AC_MSG_RESULT([$pac_fc_num_model])
Packit Service c5cf8c
        ifelse([$2],[],[],[$2=$pac_fc_num_model])
Packit Service c5cf8c
    else
Packit Service c5cf8c
        AC_MSG_RESULT([Error])
Packit Service c5cf8c
        AC_MSG_WARN([No output from test program!])
Packit Service c5cf8c
    fi
Packit Service c5cf8c
    rm -f pac_fconftest.out
Packit Service c5cf8c
],[
Packit Service c5cf8c
    AC_MSG_RESULT([Error])
Packit Service c5cf8c
    AC_MSG_WARN([Failed to run program to determine the precision and range of $type])
Packit Service c5cf8c
])
Packit Service c5cf8c
AC_LANG_POP([Fortran])
Packit Service c5cf8c
])
Packit Service c5cf8c
dnl
Packit Service c5cf8c
dnl PAC_FC_SIMPLE_NUMBER_MODEL(message, Fortran-type, Fortran-write,
Packit Service c5cf8c
dnl                            [variable-set-if-successful-test],
Packit Service c5cf8c
dnl                            [cross-value])
Packit Service c5cf8c
dnl
Packit Service c5cf8c
dnl message        : message of what test-fc-code is checking
Packit Service c5cf8c
dnl Fortran-type   : Fortran90 type's data model to be examined.
Packit Service c5cf8c
dnl Fortran-write  : Fortran90 type's write statement used with write(N,*).
Packit Service c5cf8c
dnl variable-set-if-successful-test :
Packit Service c5cf8c
dnl                  The optional variable to be set if the codelet:
Packit Service c5cf8c
dnl                  "Fortran-type" + "write(N,*) Fortran-write"
Packit Service c5cf8c
dnl                  is successful in returning the simple data model.
Packit Service c5cf8c
dnl cross-value    : value to be used for above variable when
Packit Service c5cf8c
dnl                  cross_compiling=yes
Packit Service c5cf8c
dnl
Packit Service c5cf8c
dnl This is a runtime test.
Packit Service c5cf8c
dnl
Packit Service c5cf8c
AC_DEFUN([PAC_FC_SIMPLE_NUMBER_MODEL],[
Packit Service c5cf8c
pac_msg="$1"
Packit Service c5cf8c
AC_MSG_CHECKING([for $pac_msg])
Packit Service c5cf8c
AC_LANG_PUSH([Fortran])
Packit Service c5cf8c
rm -f pac_fconftest.out
Packit Service c5cf8c
AC_RUN_IFELSE([
Packit Service c5cf8c
    AC_LANG_SOURCE([
Packit Service c5cf8c
        program main
Packit Service c5cf8c
        $2
Packit Service c5cf8c
        open(8, file="pac_fconftest.out", form="formatted")
Packit Service c5cf8c
        write(8,*) $3
Packit Service c5cf8c
        close(8)
Packit Service c5cf8c
        end
Packit Service c5cf8c
    ])
Packit Service c5cf8c
],[
Packit Service c5cf8c
    if test -s pac_fconftest.out ; then
Packit Service c5cf8c
        pac_fc_num_model="`sed -e 's/  */ /g' pac_fconftest.out`"
Packit Service c5cf8c
        AC_MSG_RESULT([$pac_fc_num_model])
Packit Service c5cf8c
        ifelse([$4],[],[],[$4=$pac_fc_num_model])
Packit Service c5cf8c
    else
Packit Service c5cf8c
        AC_MSG_RESULT([Error])
Packit Service c5cf8c
        AC_MSG_WARN([No output from test program!])
Packit Service c5cf8c
    fi
Packit Service c5cf8c
    rm -f pac_fconftest.out
Packit Service c5cf8c
],[
Packit Service c5cf8c
    AC_MSG_RESULT([Error])
Packit Service c5cf8c
    AC_MSG_WARN([Failed to run program to determine $pac_msg])
Packit Service c5cf8c
],[
Packit Service c5cf8c
    AC_MSG_RESULT([$5])
Packit Service c5cf8c
    ifelse([$4],[],[],[$4=$5])
Packit Service c5cf8c
])
Packit Service c5cf8c
AC_LANG_POP([Fortran])
Packit Service c5cf8c
])
Packit Service c5cf8c
dnl
Packit Service c5cf8c
dnl PAC_FC_AVAIL_INTEGER_MODELS([INTEGER-MODELS-FLAG],[CROSS-VARIABLE])
Packit Service c5cf8c
dnl
Packit Service c5cf8c
dnl INTEGER-MODELS-FLAG : an optional variable to be set if provided.
Packit Service c5cf8c
dnl                       If it isn't provided, PAC_FC_ALL_INTEGER_MODELS
Packit Service c5cf8c
dnl                       will be set.
Packit Service c5cf8c
dnl CROSS-VALUE         : value will be used to set INTEGER-MODELS-FLAG
Packit Service c5cf8c
dnl                       or PAC_FC_ALL_INTEGER_MODELS if cross_compiling=yes.
Packit Service c5cf8c
dnl
Packit Service c5cf8c
dnl This is a runtime test.
Packit Service c5cf8c
dnl
Packit Service c5cf8c
AC_DEFUN([PAC_FC_AVAIL_INTEGER_MODELS],[
Packit Service c5cf8c
AC_MSG_CHECKING([for available integer kinds])
Packit Service c5cf8c
AC_LANG_PUSH([Fortran])
Packit Service c5cf8c
rm -f pac_fconftest.out
Packit Service c5cf8c
AC_RUN_IFELSE([
Packit Service c5cf8c
    AC_LANG_SOURCE([
Packit Service c5cf8c
        program main
Packit Service c5cf8c
        integer r, lastkind
Packit Service c5cf8c
        lastkind=selected_int_kind(1)
Packit Service c5cf8c
        open(8, file="pac_fconftest.out", form="formatted")
Packit Service c5cf8c
        do r=2,30
Packit Service c5cf8c
             k = selected_int_kind(r)
Packit Service c5cf8c
             if (k .ne. lastkind) then
Packit Service c5cf8c
                  write(8,*) r-1, ",", lastkind
Packit Service c5cf8c
                  lastkind = k
Packit Service c5cf8c
             endif
Packit Service c5cf8c
             if (k .le. 0) then
Packit Service c5cf8c
                 exit
Packit Service c5cf8c
             endif
Packit Service c5cf8c
        enddo
Packit Service c5cf8c
        if (k.ne.lastkind) then
Packit Service c5cf8c
            write(8,*) 31, ",", k
Packit Service c5cf8c
        endif
Packit Service c5cf8c
        close(8)
Packit Service c5cf8c
        end
Packit Service c5cf8c
    ])
Packit Service c5cf8c
],[
Packit Service c5cf8c
    if test -s pac_fconftest.out ; then
Packit Service c5cf8c
        pac_flag="`sed -e 's/  */ /g' pac_fconftest.out | tr '\012' ','`"
Packit Service c5cf8c
        AC_MSG_RESULT([$pac_flag])
Packit Service c5cf8c
        pac_validKinds="`sed -e 's/  */ /g' pac_fconftest.out | tr '\012' ':'`"
Packit Service c5cf8c
        ifelse([$1],[],[PAC_FC_ALL_INTEGER_MODELS=$pac_flag],[$1=$pac_flag])
Packit Service c5cf8c
    else
Packit Service c5cf8c
        AC_MSG_RESULT([Error])
Packit Service c5cf8c
        AC_MSG_WARN([No output from test program!])
Packit Service c5cf8c
    fi
Packit Service c5cf8c
    rm -f pac_fconftest.out
Packit Service c5cf8c
],[
Packit Service c5cf8c
    AC_MSG_RESULT([Error])
Packit Service c5cf8c
    AC_MSG_WARN([Failed to run program to determine available integer models])
Packit Service c5cf8c
],[
Packit Service c5cf8c
    dnl Even when cross_compiling=yes,
Packit Service c5cf8c
    dnl pac_validKinds needs to be set for PAC_FC_INTEGER_MODEL_MAP()
Packit Service c5cf8c
    pac_validKinds="`echo \"$2\" | tr ',' ':'`"
Packit Service c5cf8c
    AC_MSG_RESULT([$2])
Packit Service c5cf8c
    ifelse([$1],[],[PAC_FC_ALL_INTEGER_MODELS=$2],[$1=$2])
Packit Service c5cf8c
])
Packit Service c5cf8c
AC_LANG_POP([Fortran])
Packit Service c5cf8c
])
Packit Service c5cf8c
dnl
Packit Service c5cf8c
dnl PAC_FC_INTEGER_MODEL_MAP([INTEGER-MODEL-MAP-FLAG],[CROSS-VALUE]))
Packit Service c5cf8c
dnl
Packit Service c5cf8c
dnl INTEGER-MODEL-MAP-FLAG : an optional variable to be set if provided.
Packit Service c5cf8c
dnl                          If it isn't provided, PAC_FC_INTEGER_MODEL_MAP
Packit Service c5cf8c
dnl                          will be set.
Packit Service c5cf8c
dnl CROSS-VALUE            : value will be used to set INTEGER-MODEL-MAP-FLAG
Packit Service c5cf8c
dnl                          or PAC_FC_INTEGER_MODEL_MAP if cross_compiling=yes.
Packit Service c5cf8c
dnl
Packit Service c5cf8c
dnl This test requires $pac_validKinds set by PAC_FC_ALL_INTEGER_MODELS().
Packit Service c5cf8c
dnl
Packit Service c5cf8c
dnl This is a runtime test.
Packit Service c5cf8c
dnl
Packit Service c5cf8c
dnl Compile the C subroutine as pac_conftest.o and Link it with a Fortran main.
Packit Service c5cf8c
AC_DEFUN([PAC_FC_INTEGER_MODEL_MAP],[
Packit Service c5cf8c
AC_REQUIRE([PAC_FC_AVAIL_INTEGER_MODELS])
Packit Service c5cf8c
AC_MSG_CHECKING([for available integer ranges])
Packit Service c5cf8c
AC_LANG_PUSH([C])
Packit Service c5cf8c
AC_COMPILE_IFELSE([
Packit Service c5cf8c
    AC_LANG_SOURCE([
Packit Service c5cf8c
#ifdef F77_NAME_UPPER
Packit Service c5cf8c
#define cisize_ CISIZE
Packit Service c5cf8c
#define isize_ ISIZE
Packit Service c5cf8c
#elif defined(F77_NAME_LOWER) || defined(F77_NAME_MIXED)
Packit Service c5cf8c
#define cisize_ cisize
Packit Service c5cf8c
#define isize_ isize
Packit Service c5cf8c
#endif
Packit Service c5cf8c
int cisize_(char *,char*);
Packit Service c5cf8c
int cisize_(char *i1p, char *i2p)
Packit Service c5cf8c
{
Packit Service c5cf8c
    int isize_val=0;
Packit Service c5cf8c
    isize_val = (int)(i2p - i1p);
Packit Service c5cf8c
    return isize_val;
Packit Service c5cf8c
}
Packit Service c5cf8c
    ])
Packit Service c5cf8c
],[
Packit Service c5cf8c
    PAC_RUNLOG([mv conftest.$OBJEXT pac_conftest.$OBJEXT])
Packit Service c5cf8c
    pac_ccompile_ok=yes
Packit Service c5cf8c
],[
Packit Service c5cf8c
    pac_ccompile_ok=no
Packit Service c5cf8c
])
Packit Service c5cf8c
AC_LANG_POP([C])
Packit Service c5cf8c
dnl
Packit Service c5cf8c
if test "$pac_ccompile_ok" = "yes" ; then
Packit Service c5cf8c
    saved_LIBS="$LIBS"
Packit Service c5cf8c
    LIBS="pac_conftest.$OBJEXT $LIBS"
Packit Service c5cf8c
    saved_IFS=$IFS
Packit Service c5cf8c
    IFS=:
Packit Service c5cf8c
    AC_LANG_PUSH([Fortran])
Packit Service c5cf8c
    pac_flag=""
Packit Service c5cf8c
    for rangekind in $pac_validKinds ; do
Packit Service c5cf8c
        kind="`echo $rangekind | sed -e 's/.*,//'`"
Packit Service c5cf8c
        range="`echo $rangekind | sed -e 's/,.*//'`"
Packit Service c5cf8c
        AC_LANG_CONFTEST([
Packit Service c5cf8c
            AC_LANG_SOURCE([
Packit Service c5cf8c
                program main
Packit Service c5cf8c
                integer (kind=$kind) a(2)
Packit Service c5cf8c
                integer cisize
Packit Service c5cf8c
                open(8, file="pac_fconftest.out", form="formatted")
Packit Service c5cf8c
                write(8,*) $range, ",", $kind, ",", cisize( a(1), a(2) )
Packit Service c5cf8c
                close(8)
Packit Service c5cf8c
                end
Packit Service c5cf8c
            ])
Packit Service c5cf8c
        ])
Packit Service c5cf8c
        IFS=$saved_IFS
Packit Service c5cf8c
        rm -f pac_fconftest.out
Packit Service c5cf8c
        AC_RUN_IFELSE([],[
Packit Service c5cf8c
            if test -s pac_fconftest.out ; then
Packit Service c5cf8c
                sizes="`sed -e 's/  */ /g' pac_fconftest.out`"
Packit Service c5cf8c
                pac_flag="$pac_flag { $sizes },"
Packit Service c5cf8c
            else
Packit Service c5cf8c
                AC_MSG_WARN([No output from test program!])
Packit Service c5cf8c
            fi
Packit Service c5cf8c
            rm -f pac_fconftest.out
Packit Service c5cf8c
        ],[
Packit Service c5cf8c
            AC_MSG_WARN([Fortran program fails to build or run!])
Packit Service c5cf8c
        ],[
Packit Service c5cf8c
            pac_flag="$2"
Packit Service c5cf8c
        ])
Packit Service c5cf8c
        IFS=:
Packit Service c5cf8c
    done
Packit Service c5cf8c
    IFS=$saved_IFS
Packit Service c5cf8c
    AC_MSG_RESULT([$pac_flag])
Packit Service c5cf8c
    ifelse([$1],[],[PAC_FC_INTEGER_MODEL_MAP=$pac_flag],[$1=$pac_flag])
Packit Service c5cf8c
    AC_LANG_POP([Fortran])
Packit Service c5cf8c
    LIBS="$saved_LIBS"
Packit Service c5cf8c
    rm -f pac_conftest.$OBJEXT
Packit Service c5cf8c
fi
Packit Service c5cf8c
])
Packit Service c5cf8c
Packit Service c5cf8c
Packit Service c5cf8c
AC_DEFUN([PAC_FC_2008_SUPPORT],[
Packit Service c5cf8c
AC_MSG_CHECKING([for Fortran 2008 support])
Packit Service c5cf8c
Packit Service c5cf8c
AC_LANG_PUSH([C])
Packit Service c5cf8c
f08_works=yes
Packit Service c5cf8c
AC_COMPILE_IFELSE([
Packit Service c5cf8c
	AC_LANG_SOURCE(
Packit Service c5cf8c
[[
Packit Service c5cf8c
#include <ISO_Fortran_binding.h>
Packit Service c5cf8c
Packit Service c5cf8c
int foo_c(CFI_cdesc_t * a_desc, CFI_cdesc_t * b_desc)
Packit Service c5cf8c
{
Packit Service c5cf8c
	char * a_row = (char*) a_desc->base_addr;
Packit Service c5cf8c
	if (a_desc->type != CFI_type_int) { return 1; }
Packit Service c5cf8c
	if (a_desc->rank != 2) { return 2; }
Packit Service c5cf8c
	if (a_desc->dim[1].extent != b_desc->dim[0].extent) { return 3; }
Packit Service c5cf8c
	return 0;
Packit Service c5cf8c
}
Packit Service c5cf8c
Packit Service c5cf8c
void test_assumed_rank_async_impl_c(CFI_cdesc_t * a_desc)
Packit Service c5cf8c
{
Packit Service c5cf8c
	return;
Packit Service c5cf8c
}
Packit Service c5cf8c
]])],[mv conftest.$OBJEXT conftest1.$OBJEXT],[f08_works=no])
Packit Service c5cf8c
AC_LANG_POP([C])
Packit Service c5cf8c
Packit Service c5cf8c
AC_LANG_PUSH([Fortran])
Packit Service c5cf8c
PAC_PUSH_FLAG([LIBS])
Packit Service c5cf8c
LIBS="conftest1.$OBJEXT $LIBS"
Packit Service c5cf8c
AC_LINK_IFELSE([
Packit Service c5cf8c
    AC_LANG_SOURCE([
Packit Service c5cf8c
MODULE F08TS_MODULE
Packit Service c5cf8c
IMPLICIT NONE
Packit Service c5cf8c
Packit Service c5cf8c
! Test public, private, protected
Packit Service c5cf8c
REAL, PUBLIC       :: x
Packit Service c5cf8c
REAL, PRIVATE      :: y
Packit Service c5cf8c
LOGICAL, PROTECTED :: z
Packit Service c5cf8c
Packit Service c5cf8c
! Test abstract
Packit Service c5cf8c
ABSTRACT INTERFACE
Packit Service c5cf8c
    SUBROUTINE user_func(x, y)
Packit Service c5cf8c
        INTEGER  :: x(*)
Packit Service c5cf8c
        REAL     :: y
Packit Service c5cf8c
    END SUBROUTINE
Packit Service c5cf8c
END INTERFACE
Packit Service c5cf8c
Packit Service c5cf8c
! Test TS 29113 assumed type , assumed rank and bind(C)
Packit Service c5cf8c
INTERFACE
Packit Service c5cf8c
    FUNCTION FOO(A, B, C) &
Packit Service c5cf8c
        BIND(C,name="foo_c") RESULT(err)
Packit Service c5cf8c
        USE, intrinsic :: iso_c_binding, ONLY : c_int
Packit Service c5cf8c
        TYPE(*), DIMENSION(..) :: A, B, C
Packit Service c5cf8c
        INTEGER(c_int) :: err
Packit Service c5cf8c
    END FUNCTION FOO
Packit Service c5cf8c
END INTERFACE
Packit Service c5cf8c
Packit Service c5cf8c
Packit Service c5cf8c
! Test assumed-rank + asynchronous
Packit Service c5cf8c
INTERFACE TEST_ASSUMED_RANK_ASYNC
Packit Service c5cf8c
    SUBROUTINE TEST_ASSUMED_RANK_ASYNC_IMPL(BUF) &
Packit Service c5cf8c
        BIND(C,name="test_assumed_rank_async_impl_c")
Packit Service c5cf8c
        IMPLICIT NONE
Packit Service c5cf8c
        TYPE(*), DIMENSION(..), ASYNCHRONOUS :: BUF
Packit Service c5cf8c
    END SUBROUTINE TEST_ASSUMED_RANK_ASYNC_IMPL
Packit Service c5cf8c
END INTERFACE TEST_ASSUMED_RANK_ASYNC
Packit Service c5cf8c
Packit Service c5cf8c
CONTAINS
Packit Service c5cf8c
Packit Service c5cf8c
! Test TS 29113 asychronous attribute and optional
Packit Service c5cf8c
SUBROUTINE test1(buf, count, ierr)
Packit Service c5cf8c
    INTEGER, ASYNCHRONOUS :: buf(*)
Packit Service c5cf8c
    INTEGER               :: count
Packit Service c5cf8c
    INTEGER, OPTIONAL     :: ierr
Packit Service c5cf8c
END SUBROUTINE
Packit Service c5cf8c
Packit Service c5cf8c
! Test procedure type and non-bind(c) x in C_FUNCLOC(x)
Packit Service c5cf8c
SUBROUTINE test2(func)
Packit Service c5cf8c
    USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_FUNLOC, C_FUNPTR
Packit Service c5cf8c
    PROCEDURE(user_func)  :: func
Packit Service c5cf8c
    TYPE(C_FUNPTR) :: errhandler_fn
Packit Service c5cf8c
    errhandler_fn = C_FUNLOC(func)
Packit Service c5cf8c
END SUBROUTINE
Packit Service c5cf8c
Packit Service c5cf8c
! Test intrinsic storage_size
Packit Service c5cf8c
SUBROUTINE test3(x, size)
Packit Service c5cf8c
    CHARACTER, DIMENSION(..) :: x
Packit Service c5cf8c
    INTEGER, INTENT(OUT) :: size
Packit Service c5cf8c
    size = storage_size(x)/8
Packit Service c5cf8c
END SUBROUTINE test3
Packit Service c5cf8c
Packit Service c5cf8c
END MODULE
Packit Service c5cf8c
Packit Service c5cf8c
!==============================================
Packit Service c5cf8c
PROGRAM MAIN
Packit Service c5cf8c
USE :: F08TS_MODULE, ONLY : FOO, TEST_ASSUMED_RANK_ASYNC
Packit Service c5cf8c
IMPLICIT NONE
Packit Service c5cf8c
Packit Service c5cf8c
INTEGER, DIMENSION(4,4) :: A, B
Packit Service c5cf8c
INTEGER, DIMENSION(2,2) :: C
Packit Service c5cf8c
INTEGER                 :: ERRCODE
Packit Service c5cf8c
INTEGER, DIMENSION(10), ASYNCHRONOUS :: IAR
Packit Service c5cf8c
Packit Service c5cf8c
! Test contiguous and non-contiguous array section passing
Packit Service c5cf8c
! and linkage with C code
Packit Service c5cf8c
ERRCODE = FOO(A(1:4:2, :), B(:, 2:4:2), C)
Packit Service c5cf8c
CALL TEST_ASSUMED_RANK_ASYNC(IAR(2:7))
Packit Service c5cf8c
Packit Service c5cf8c
END PROGRAM
Packit Service c5cf8c
    ])],[],[f08_works=no])
Packit Service c5cf8c
PAC_POP_FLAG([LIBS])
Packit Service c5cf8c
AC_LANG_POP([Fortran])
Packit Service c5cf8c
Packit Service c5cf8c
if test "$f08_works" = "yes" ; then
Packit Service c5cf8c
   $1
Packit Service c5cf8c
else
Packit Service c5cf8c
   $2
Packit Service c5cf8c
fi
Packit Service c5cf8c
rm -f conftest1.$OBJEXT F08TS_MODULE.* f08ts_module.*
Packit Service c5cf8c
AC_MSG_RESULT([$f08_works])
Packit Service c5cf8c
])