Blame confdb/aclocal_fc.m4

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