"Fossies" - the Fresh Open Source Software Archive

Member "openmpi-4.1.2/ompi/mca/io/romio321/romio/confdb/aclocal_fc.m4" (24 Nov 2021, 38937 Bytes) of package /linux/misc/openmpi-4.1.2.tar.bz2:


As a special service "Fossies" has tried to format the requested text file into HTML format (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 dnl PAC_FC_SEARCH_LIST - expands to a whitespace separated list of modern
    2 dnl fortran compilers for use with AC_PROG_FC that is more suitable for HPC
    3 dnl software packages
    4 AC_DEFUN([PAC_FC_SEARCH_LIST],
    5          [ifort pgf90 pathf90 pathf95 xlf90 xlf95 xlf2003 gfortran f90 epcf90 f95 fort lf95 g95 ifc efc gfc])
    6 dnl /*D
    7 dnl PAC_PROG_FC([COMPILERS])
    8 dnl
    9 dnl COMPILERS is a space separated list of Fortran 77 compilers to search
   10 dnl for.  Fortran 95 isn't strictly backwards-compatible with Fortran 77,
   11 dnl but `f95' is worth trying.
   12 dnl
   13 dnl Compilers are ordered by
   14 dnl  1. F77, F90, F95
   15 dnl  2. Good/tested native compilers, bad/untested native compilers
   16 dnl  3. Wrappers around f2c go last.
   17 dnl
   18 dnl `fort77' is a wrapper around `f2c'.
   19 dnl It is believed that under HP-UX `fort77' is the name of the native
   20 dnl compiler.  On some Cray systems, fort77 is a native compiler.
   21 dnl frt is the Fujitsu F77 compiler.
   22 dnl pgf77 and pgf90 are the Portland Group F77 and F90 compilers.
   23 dnl xlf/xlf90/xlf95/xlf2003 are IBM (AIX) F77/F90/F95/F2003 compilers.
   24 dnl lf95 is the Lahey-Fujitsu compiler.
   25 dnl fl32 is the Microsoft Fortran "PowerStation" compiler.
   26 dnl af77 is the Apogee F77 compiler for Intergraph hardware running CLIX.
   27 dnl epcf90 is the "Edinburgh Portable Compiler" F90.
   28 dnl fort is the Compaq Fortran 90 (now 95) compiler for Tru64 and Linux/Alpha.
   29 dnl pathf90 is the Pathscale Fortran 90 compiler
   30 dnl ifort is another name for the Intel f90 compiler
   31 dnl efc - An older Intel compiler (?)
   32 dnl ifc - An older Intel compiler
   33 dnl fc  - A compiler on some unknown system.  This has been removed because
   34 dnl       it may also be the name of a command for something other than
   35 dnl       the Fortran compiler (e.g., fc=file system check!)
   36 dnl gfortran - The GNU Fortran compiler (not the same as g95) 
   37 dnl gfc - An alias for gfortran recommended in cygwin installations
   38 dnl NOTE: this macro suffers from a basically intractable "expanded before it
   39 dnl was required" problem when libtool is also used
   40 dnl D*/
   41 AC_DEFUN([PAC_PROG_FC],[
   42 PAC_PUSH_FLAG([FCFLAGS])
   43 AC_PROG_FC([m4_default([$1],[PAC_FC_SEARCH_LIST])])
   44 PAC_POP_FLAG([FCFLAGS])
   45 ])
   46 dnl
   47 dnl PAC_FC_EXT checks for the default Fortran 90 program extension, f90 then f.
   48 dnl This could be replaced by AC_FC_SRCEXT but since AC_FC_SRCEXT
   49 dnl adds FCFLAGS_ext, which is used to modify FCFLAGS or Makefile.in.
   50 dnl So will do this later.
   51 dnl
   52 AC_DEFUN([PAC_FC_EXT],[
   53 AC_MSG_CHECKING([for extension for Fortran 90 programs])
   54 ac_fc_srcext="f90"
   55 AC_LANG_PUSH(Fortran)
   56 AC_COMPILE_IFELSE([
   57     AC_LANG_PROGRAM()
   58 ],[
   59     AC_MSG_RESULT([f90])
   60 ],[
   61     ac_fc_srcext="f" 
   62     AC_COMPILE_IFELSE([
   63         AC_LANG_PROGRAM()
   64     ],[
   65         AC_MSG_RESULT([f])
   66     ],[
   67         AC_MSG_RESULT([unknown!])
   68     ])
   69 ])
   70 AC_LANG_POP(Fortran)
   71 ])
   72 dnl
   73 dnl Internal routine for testing F90
   74 dnl PAC_PROG_FC_WORKS()
   75 dnl
   76 AC_DEFUN([PAC_PROG_FC_WORKS],[
   77 AC_REQUIRE([PAC_FC_EXT])
   78 AC_LANG_PUSH(Fortran)
   79 AC_MSG_CHECKING([whether the Fortran 90 compiler ($FC $FCFLAGS $LDFLAGS) works])
   80 AC_LINK_IFELSE([
   81     AC_LANG_SOURCE([
   82         program conftest
   83         integer, dimension(10) :: n
   84         end
   85     ])
   86 ],[
   87     pac_cv_prog_fc_works="yes"
   88     AC_MSG_RESULT([$pac_cv_prog_fc_works])
   89     AC_MSG_CHECKING([whether the Fortran 90 compiler ($FC $FCFLAGS $LDFLAGS) is a cross-compiler])
   90     AC_RUN_IFELSE([],
   91     [pac_cv_prog_fc_cross="no"],
   92     [pac_cv_prog_fc_cross="yes"],
   93     [pac_cv_prog_fc_cross="$cross_compiling"]
   94     )
   95     AC_MSG_RESULT($pac_cv_prog_fc_cross)
   96 ],[
   97     pac_cv_prog_fc_works="no"
   98     AC_MSG_WARN([installation or configuration problem: Fortran 90 compiler cannot create executables.])
   99 ])
  100 # The intel compiler sometimes generates these work.pc and .pcl files
  101 rm -f work.pc work.pcl
  102 AC_LANG_POP(Fortran)
  103 dnl cross_compiling no longer maintained by autoconf as part of the
  104 dnl AC_LANG changes.  If we set it here, a later AC_LANG may not 
  105 dnl restore it (in the case where one compiler claims to be a cross compiler
  106 dnl and another does not)
  107 dnl cross_compiling=$pac_cv_prog_f90_cross
  108 ])
  109 dnl/*D 
  110 dnl PAC_PROG_FC_INT_KIND - Determine kind parameter for an integer with
  111 dnl the specified number of bytes.
  112 dnl
  113 dnl Synopsis:
  114 dnl  PAC_PROG_FC_INT_KIND(variable-to-set,number-of-bytes,[cross-size])
  115 dnl
  116 dnl D*/
  117 AC_DEFUN([PAC_PROG_FC_INT_KIND],[
  118 # Set the default
  119 $1=-1
  120 if test "$pac_cv_prog_fc_cross" = "yes" ; then
  121     AS_IF([test -z "$3"],[AC_MSG_ERROR(['$3' is empty])])
  122     $1="$3"
  123 else
  124     AC_LANG_PUSH(Fortran)
  125     AC_MSG_CHECKING([for Fortran 90 integer kind for $2-byte integers])
  126     # Convert bytes to digits
  127     case $2 in 
  128         1) sellen=2 ;;
  129         2) sellen=4 ;;
  130         4) sellen=8 ;;
  131         8) sellen=16 ;;
  132        16) sellen=30 ;;
  133         *) sellen=8 ;;
  134     esac
  135     # Check for cached value
  136     eval testval=\$"pac_cv_prog_fc_int_kind_$sellen"
  137     if test -n "$testval" ; then 
  138         AC_MSG_RESULT([$testval (cached)])
  139         $1=$testval
  140     else
  141         KINDVAL="unavailable"
  142         eval "pac_cv_prog_fc_int_kind_$sellen"=-1
  143         AC_RUN_IFELSE([
  144             AC_LANG_SOURCE([
  145                 program main
  146                 integer ii
  147                 ii = selected_int_kind($sellen)
  148                 open(8, file="conftest1.out", form="formatted")
  149                 write (8,*) ii
  150                 close(8)
  151                 stop
  152                 end
  153             ])
  154         ],[pac_run_ok=yes],[pac_run_ok=no])
  155         if test "$pac_run_ok" = "yes" ; then
  156             if test -s conftest1.out ; then
  157                 # Because of write, there may be a leading blank.
  158                 KINDVAL=`cat conftest1.out | sed 's/ //g'`
  159                 eval "pac_cv_prog_fc_int_kind_$sellen"=$KINDVAL
  160                 $1=$KINDVAL
  161             fi
  162         fi
  163         AC_MSG_RESULT([$KINDVAL])
  164     fi # not cached
  165     AC_LANG_POP(Fortran)
  166 fi # is not cross compiling
  167 ])dnl
  168 dnl
  169 dnl ------------------------------------------------------------------------
  170 dnl Special characteristics that have no autoconf counterpart but that
  171 dnl we need as part of the Fortran 90 support.  To distinquish these, they
  172 dnl have a [PAC] prefix.
  173 dnl 
  174 dnl At least one version of the Cray compiler needs the option -em to
  175 dnl generate a separate module file, rather than including the module
  176 dnl information in the object (.o) file.
  177 dnl
  178 dnl
  179 dnl PAC_FC_MODULE_EXT(action if found,action if not found)
  180 dnl
  181 AC_DEFUN([PAC_FC_MODULE_EXT],
  182 [AC_CACHE_CHECK([for Fortran 90 module extension],
  183 pac_cv_fc_module_ext,[
  184 pac_cv_fc_module_case="unknown"
  185 AC_LANG_PUSH(Fortran)
  186 AC_COMPILE_IFELSE([
  187     AC_LANG_SOURCE([
  188         module conftest
  189         integer n
  190         parameter (n=1)
  191         end module conftest
  192     ])
  193 ],[
  194     # Look for module name
  195     # First, try to find known names.  This avoids confusion caused by
  196     # additional files (like <name>.stb created by some versions of pgf90)
  197     # Early versions of the Intel compiler used d as the module extension;
  198     # we include that just to finish the test as early as possible.
  199     for name in conftest CONFTEST ; do
  200         for ext in mod MOD d ; do
  201             if test -s $name.$ext ; then
  202                 if test $name = conftest ; then
  203                     pac_cv_fc_module_case=lower
  204                 else
  205                     pac_cv_fc_module_case=upper
  206                 fi
  207                 pac_cv_fc_module_ext=$ext
  208                 pac_MOD=$ext
  209                 break
  210             fi
  211         done
  212         if test -n "$pac_cv_fc_module_ext" ; then break ; fi
  213     done
  214     if test -z "$pac_MOD" ; then
  215         # The test on .err is needed for Cray Fortran.
  216         pac_MOD=`ls conftest.* 2>&1 | grep -v conftest.${ac_fc_srcext} | grep -v conftest.o | grep -v conftest.err`
  217         pac_MOD=`echo $pac_MOD | sed -e 's/conftest\.//g'`
  218         pac_cv_fc_module_case="lower"
  219         if test "X$pac_MOD" = "X" ; then
  220             pac_MOD=`ls CONFTEST* 2>&1 | grep -v CONFTEST.${ac_fc_srcext} | grep -v CONFTEST.o | grep -v CONFTEST.err`
  221             pac_MOD=`echo $pac_MOD | sed -e 's/CONFTEST\.//g'`
  222             if test -n "$pac_MOD" -a -s "CONFTEST.$pac_MOD" ; then
  223                 pac_cv_fc_module_case="upper"
  224             else
  225                 # Clear because we must have gotten an error message
  226                 pac_MOD=""
  227             fi
  228         fi
  229         if test -z "$pac_MOD" ; then 
  230             pac_cv_fc_module_ext="unknown"
  231         else
  232             pac_cv_fc_module_ext=$pac_MOD
  233         fi
  234     fi
  235 ],[
  236     pac_cv_fc_module_ext="unknown"
  237 ])
  238 
  239 if test "$pac_cv_fc_module_ext" = "unknown" ; then
  240     # Try again, but with an -em option.  Abbreviated, because we're
  241     # just looking for the Cray option
  242     saveFCFLAGS=$FCFLAGS
  243     FCFLAGS="$FCFLAGS -em"
  244     AC_COMPILE_IFELSE([
  245     AC_LANG_SOURCE([
  246         module conftest
  247         integer n
  248         parameter (n=1)
  249         end module conftest
  250     ])
  251 ],[
  252     if test -s conftest.mod ; then
  253         pac_cv_fc_module_ext="mod"
  254         pac_cv_fc_module_case="lower"
  255     elif test -s CONFTEST.mod ; then
  256         pac_cv_fc_module_ext="mod"
  257         pac_cv_fc_module_case="upper"
  258     fi
  259 ],[
  260     :
  261     # do nothing - already have the unknown default value
  262 ])
  263     if test "$pac_cv_fc_module_ext" = "unknown" ; then
  264         # The additional command line option did not help - restore
  265         # the original flags.
  266         FCFLAGS=$saveFCFLAGS
  267     fi
  268 fi
  269 AC_LANG_POP(Fortran)
  270 ])
  271 #
  272 AC_SUBST(FCMODEXT)
  273 if test "$pac_cv_fc_module_ext" = "unknown" ; then
  274     ifelse($2,,:,[$2])
  275 else
  276     ifelse($1,,FCMODEXT=$pac_MOD,[$1])
  277 fi
  278 ])
  279 dnl
  280 dnl
  281 dnl PAC_FC_MODULE_INCFLAG
  282 AC_DEFUN([PAC_FC_MODULE_INCFLAG],[
  283 AC_REQUIRE([PAC_FC_MODULE_EXT])
  284 AC_CACHE_CHECK([for Fortran 90 module include flag],
  285 pac_cv_fc_module_incflag,[
  286 AC_LANG_PUSH(Fortran)
  287 AC_LANG_CONFTEST([
  288     AC_LANG_SOURCE([
  289         module conf
  290         integer n
  291         parameter (n=1)
  292         end module conf
  293     ])
  294 ])
  295 pac_madedir="no"
  296 if test ! -d conf ; then mkdir conftestdir ; pac_madedir="yes"; fi
  297 if test "$pac_cv_fc_module_case" = "upper" ; then
  298     pac_module="CONF.$pac_cv_fc_module_ext"
  299 else
  300     pac_module="conf.$pac_cv_fc_module_ext"
  301 fi
  302 AC_COMPILE_IFELSE([],[
  303     if test -s "$pac_module" ; then
  304         mv $pac_module conftestdir
  305         # Remove any temporary files, and hide the work.pc file
  306         # (if the compiler generates them)
  307         if test -f work.pc ; then 
  308             mv -f work.pc conftest.pc
  309         fi
  310         rm -f work.pcl
  311     else
  312         AC_MSG_WARN([Unable to build a simple Fortran 90 module])
  313         # echo "configure: failed program was:" >&AS_MESSAGE_LOG_FD
  314         # cat conftest.$ac_ext >&AS_MESSAGE_LOG_FD
  315         _AC_MSG_LOG_CONFTEST
  316     fi
  317 ],[])
  318 # Remove the conftest* after AC_LANG_CONFTEST
  319 rm -rf conftest.dSYM
  320 rm -f conftest.$ac_ext
  321 
  322 dnl Create the conftest here so the test isn't created everytime inside loop.
  323 AC_LANG_CONFTEST([AC_LANG_PROGRAM([],[use conf])])
  324 
  325 # Save the original FCFLAGS
  326 saved_FCFLAGS="$FCFLAGS"
  327 pac_cv_fc_module_incflag=""
  328 for inchdr in '-I' '-M' '-p' ; do
  329     FCFLAGS="$saved_FCFLAGS ${inchdr}conftestdir"
  330     AC_COMPILE_IFELSE([],[pac_cv_fc_module_incflag="$inchdr" ; break])
  331 done
  332 if test "X$pac_cv_fc_module_incflag" = "X" ; then
  333     if test -s conftest.pc ; then
  334         mv conftest.pc conftestdir/mpimod.pc
  335         echo "mpimod.pc" > conftestdir/mpimod.pcl
  336         echo "`pwd`/conftestdir/mpimod.pc" >> conftestdir/mpimod.pcl
  337         inchdr='-cl,'
  338         FCFLAGS="$save_FCFLAGS ${inchdr}conftestdir"
  339         AC_COMPILE_IFELSE([], [pac_fcompile_ok=yes], [pac_fcompile_ok=no])
  340         if test "$pac_fcompile_ok" = "yes" ; then
  341             pac_cv_fc_module_incflag="$inchdr"
  342             # Not quite right; see the comments that follow
  343             AC_MSG_RESULT([-cl,filename where filename contains a list of files and directories])
  344             FC_WORK_FILES_ARG="-cl,mpimod.pcl"
  345             FCMODINCSPEC="-cl,<dir>/<file>mod.pcl"
  346         else 
  347             # The version of the Intel compiler that I have refuses to let
  348             # you put the "work catalog" list anywhere but the current directory.
  349             pac_cv_fc_module_incflag="Unavailable!"
  350         fi
  351     else
  352         # Early versions of the Intel ifc compiler required a *file*
  353         # containing the names of files that contained the names of the
  354         # 
  355         # -cl,filename.pcl
  356         #   filename.pcl contains
  357         #     fullpathname.pc
  358         # The "fullpathname.pc" is generated, I believe, when a module is 
  359         # compiled.  
  360         # Intel compilers use a wierd system: -cl,filename.pcl .  If no file is
  361         # specified, work.pcl and work.pc are created.  However, if you specify
  362         # a file, it must contain the name of a file ending in .pc .  Ugh!
  363         pac_cv_fc_module_incflag="unknown"
  364     fi
  365 fi
  366 # Restore the original FCFLAGS
  367 FCFLAGS="$saved_FCFLAGS"
  368 if test "$pac_madedir" = "yes" ; then rm -rf conftestdir ; fi
  369 # Remove the conftest* after AC_LANG_CONFTEST
  370 # This is needed for Mac OSX 10.5
  371 rm -rf conftest.dSYM
  372 rm -f conftest*
  373 AC_LANG_POP(Fortran)
  374 ])
  375 AC_SUBST(FC_WORK_FILES_ARG)
  376 AC_SUBST(FCMODINCFLAG)
  377 FCMODINCFLAG=$pac_cv_fc_module_incflag
  378 ])
  379 dnl
  380 dnl
  381 dnl
  382 AC_DEFUN([PAC_FC_MODULE],[
  383 PAC_FC_MODULE_EXT
  384 PAC_FC_MODULE_INCFLAG
  385 PAC_FC_MODULE_OUTFLAG
  386 ])
  387 dnl
  388 dnl PAC_FC_MODULE_OUTFLAG
  389 AC_DEFUN([PAC_FC_MODULE_OUTFLAG],[
  390 AC_REQUIRE([PAC_FC_MODULE_EXT])
  391 AC_CACHE_CHECK([for Fortran 90 module output directory flag],
  392                [pac_cv_fc_module_outflag],
  393 [
  394 AC_LANG_PUSH([Fortran])
  395 AC_LANG_CONFTEST([
  396     AC_LANG_SOURCE([
  397         module conf
  398         integer n
  399         parameter (n=1)
  400         end module conf
  401     ])
  402 ])
  403 pac_madedir="no"
  404 if test ! -d conf ; then mkdir conftestdir ; pac_madedir="yes"; fi
  405 if test "$pac_cv_fc_module_case" = "upper" ; then
  406     pac_module="CONF.$pac_cv_fc_module_ext"
  407 else
  408     pac_module="conf.$pac_cv_fc_module_ext"
  409 fi
  410 
  411 # check base case that the compiler can create modules and that they endup in
  412 # the current directory
  413 AC_COMPILE_IFELSE([],[
  414     if test -s "$pac_module" ; then
  415         rm -f "$pac_module"
  416         # Remove any temporary files, and hide the work.pc file
  417         # (if the compiler generates them)
  418         if test -f work.pc ; then 
  419             mv -f work.pc conftest.pc
  420         fi
  421         rm -f work.pcl
  422     else
  423         AC_MSG_WARN([Unable to build a simple Fortran 90 module])
  424         # echo "configure: failed program was:" >&AS_MESSAGE_LOG_FD
  425         # cat conftest.$ac_ext >&AS_MESSAGE_LOG_FD
  426         _AC_MSG_LOG_CONFTEST
  427     fi
  428 ],[])
  429 
  430 # known flags for reasonably recent versions of various f90 compilers:
  431 #   gfortran -J${dir}
  432 #   xlf -qmoddir=${dir}
  433 #   pgf90 -module ${dir}
  434 #   ifort -module ${dir}
  435 #   nagfor -mdir ${dir}
  436 #   ftn -J ${dir}              ## the Cray fortran compiler
  437 #   ftn -em -J${dir}           ## the Cray fortran compiler (crayftn, in 2013)
  438 #      For this above case, we must have added -em to FCFLAGS, since other
  439 #      module tests do not always use the module output flag.  See
  440 #      FC_MODULE_EXT , where this is determined.
  441 #   f95 -YMOD_OUT_DIR=${dir}   ## the Absoft fortran compiler
  442 #   lf95 -M ${dir}             ## the Lahey/Fujitsu fortran compiler
  443 #   f90 -moddir=${dir}         ## the Sun f90 compiler
  444 #   g95 -fmod=${dir}
  445 #
  446 # If there are any compilers still out there that are totally brain-dead and
  447 # don't support an output directory flag, we can write a wrapper script to tell
  448 # users to use.  Alternatively they can use an older version of MPICH.
  449 
  450 pac_cv_fc_module_outflag=
  451 for mod_flag in '-J' '-J ' '-qmoddir=' '-module ' '-YMOD_OUT_DIR=' '-mdir ' '-moddir=' '-fmod=' '-M '; do
  452     rm -f conftestdir/NONEXISTENT conftestdir/*
  453     PAC_PUSH_FLAG([FCFLAGS])
  454     FCFLAGS="$FCFLAGS ${mod_flag}conftestdir"
  455     AC_COMPILE_IFELSE([],[pac_build_success=yes],[pac_build_success=no])
  456     AS_IF([test "X$pac_build_success" = Xyes],
  457           [AS_IF([test -s "conftestdir/${pac_module}"],
  458                  [pac_cv_fc_module_outflag="$mod_flag"])])
  459     PAC_POP_FLAG([FCFLAGS])
  460     AS_IF([test "X$pac_cv_fc_module_outflag" = X],[:],[break])
  461 done
  462 
  463 # Remove the conftest* after AC_LANG_CONFTEST
  464 rm -rf conftest.dSYM
  465 rm -f conftest.$ac_ext
  466 
  467 if test "$pac_madedir" = "yes" ; then rm -rf conftestdir ; fi
  468 AS_UNSET([pac_madedir])
  469 # Remove the conftest* after AC_LANG_CONFTEST
  470 # This is needed for Mac OSX 10.5
  471 rm -rf conftest.dSYM
  472 rm -f conftest*
  473 AC_LANG_POP(Fortran)
  474 ])dnl end AC_CACHE_CHECK
  475 
  476 AC_SUBST([FCMODOUTFLAG],[$pac_cv_fc_module_outflag])
  477 ])dnl end AC_DEFUN([PAC_FC_MODULE_OUTFLAG])
  478 dnl
  479 dnl PAC_FC_AND_F77_COMPATIBLE([action-if-true],[action-if-false])
  480 dnl
  481 dnl Determine whether object files compiled with Fortran 77 can be 
  482 dnl linked to Fortran 90 main programs.
  483 dnl
  484 dnl The test uses a name that includes an underscore unless the 3rd
  485 dnl argument provides another routine name.
  486 dnl
  487 AC_DEFUN([PAC_FC_AND_F77_COMPATIBLE],[
  488 AC_REQUIRE([PAC_PROG_FC_WORKS])
  489 AC_CACHE_CHECK([whether Fortran 90 compiler works with Fortran 77 compiler],
  490 pac_cv_fc_and_f77,[
  491 pacTestRoutine=foo_abc
  492 ifelse([$3],,,[eval pacTestRoutine=$3])
  493 pac_cv_fc_and_f77="unknown"
  494 # compile the f77 program and link with the f90 program
  495 # The reverse may not work because the Fortran 90 environment may
  496 # expect to be in control (and to provide library files unknown to any other
  497 # environment, even Fortran 77!)
  498 AC_LANG_PUSH(Fortran 77)
  499 AC_COMPILE_IFELSE([
  500     AC_LANG_SOURCE([
  501         subroutine ${pacTestRoutine}(b)
  502         integer b
  503         b = b + 1
  504         end
  505     ])
  506 ],[
  507     # pac_f77compile_ok=yes
  508     PAC_RUNLOG([mv conftest.$OBJEXT pac_f77conftest.$OBJEXT])
  509     # Save original LIBS, prepend previously generated object file to LIBS
  510     saved_LIBS="$LIBS"
  511     LIBS="pac_f77conftest.$OBJEXT $LIBS"
  512     AC_LANG_PUSH(Fortran)
  513     AC_LINK_IFELSE([
  514         AC_LANG_SOURCE([
  515             program main
  516             integer a
  517             a = 1
  518             call ${pacTestRoutine}(a)
  519             end
  520         ])
  521     ],[pac_cv_fc_and_f77=yes],[pac_cv_fc_and_f77=no])
  522     # Some versions of the Intel compiler produce these two files
  523     rm -f work.pc work.pcl
  524     # Restore LIBS
  525     LIBS="$saved_LIBS"
  526     AC_LANG_POP(Fortran)
  527     # remove previously generated object file.
  528     rm -f pac_f77conftest.$OBJEXT
  529 ], [
  530     # pac_f77compile_ok=no
  531     pac_cv_fc_and_f77=no
  532 ])
  533 AC_LANG_POP(Fortran 77)
  534 # Perform the requested action based on whether the test succeeded
  535 if test "$pac_cv_fc_and_f77" = yes ; then
  536     ifelse($1,,:,[$1])
  537 else
  538     ifelse($2,,:,[$2])
  539     AC_MSG_WARN([See config.log for the failed test program and its output.])
  540 fi
  541 ])
  542 dnl
  543 ])
  544 dnl
  545 dnl
  546 dnl /*D 
  547 dnl PAC_PROG_FC_CRAY_POINTER - Check if Fortran supports Cray-style pointer.
  548 dnl                            If so, set pac_cv_prog_fc_has_pointer to yes
  549 dnl                            and find out if any extra compiler flag is
  550 dnl                            needed and set it as CRAYPTR_FCFLAGS.
  551 dnl                            i.e. CRAYPTR_FCFLAGS is meaningful only if
  552 dnl                            pac_cv_prog_fc_has_pointer = yes.
  553 dnl
  554 dnl Synopsis:
  555 dnl   PAC_PROG_FC_CRAY_POINTER([action-if-true],[action-if-false])
  556 dnl D*/
  557 AC_DEFUN([PAC_PROG_FC_CRAY_POINTER],[
  558 AC_CACHE_CHECK([whether Fortran 90 supports Cray-style pointer],
  559 pac_cv_prog_fc_has_pointer,[
  560 AC_LANG_PUSH([Fortran])
  561 AC_LANG_CONFTEST([
  562     AC_LANG_PROGRAM([],[
  563         integer M
  564         pointer (MPTR,M)
  565         data MPTR/0/
  566     ])
  567 ])
  568 saved_FCFLAGS="$FCFLAGS"
  569 pac_cv_prog_fc_has_pointer=no
  570 CRAYPTR_FCFLAGS=""
  571 for ptrflag in '' '-fcray-pointer' ; do
  572     FCFLAGS="$saved_FCFLAGS $ptrflag"
  573     AC_COMPILE_IFELSE([],[
  574         pac_cv_prog_fc_has_pointer=yes
  575         CRAYPTR_FCFLAGS="$ptrflag"
  576         break
  577     ])
  578 done
  579 dnl Restore FCFLAGS first, since user may not want to modify FCFLAGS
  580 FCFLAGS="$saved_FCFLAGS"
  581 dnl remove conftest after ac_lang_conftest
  582 rm -f conftest.$ac_ext
  583 AC_LANG_POP([Fortran])
  584 ])
  585 if test "$pac_cv_prog_fc_has_pointer" = "yes" ; then
  586     AC_MSG_CHECKING([for Fortran 90 compiler flag for Cray-style pointer])
  587     if test "X$CRAYPTR_FCFLAGS" != "X" ; then
  588         AC_MSG_RESULT([$CRAYPTR_FCFLAGS])
  589     else
  590         AC_MSG_RESULT([none])
  591     fi
  592     ifelse([$1],[],[:],[$1])
  593 else
  594     ifelse([$2],[],[:],[$2])
  595 fi
  596 ])
  597 dnl
  598 dnl
  599 dnl
  600 AC_DEFUN([PAC_PROG_FC_AND_C_STDIO_LIBS],[
  601 AC_REQUIRE([AC_HEADER_STDC])
  602 # To simply the code in the cache_check macro, chose the routine name
  603 # first, in case we need it
  604 confname=conf1_
  605 case "$pac_cv_prog_f77_name_mangle" in
  606     "lower underscore")       confname=conf1_  ;;
  607     "upper stdcall")          confname=CONF1   ;;
  608     upper)                    confname=CONF1   ;;
  609     "lower doubleunderscore") confname=conf1_  ;;
  610     lower)                    confname=conf1   ;;
  611     "mixed underscore")       confname=conf1_  ;;
  612     mixed)                    confname=conf1   ;;
  613 esac
  614 
  615 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,[
  616 pac_cv_prog_fc_and_c_stdio_libs=unknown
  617 
  618 AC_LANG_PUSH(C)
  619 AC_COMPILE_IFELSE([
  620     AC_LANG_SOURCE([
  621 #if defined(HAVE_STDIO_H) || defined(STDC_HEADERS)
  622 #include <stdio.h>
  623 #endif
  624 int $confname( int a )
  625 { printf( "The answer is %d\n", a ); fflush(stdout); return 0; }
  626     ])
  627 ],[
  628     pac_compile_ok=yes
  629     PAC_RUNLOG([mv conftest.$OBJEXT pac_conftest.$OBJEXT])
  630     # Save LIBS and prepend object file to LIBS
  631     saved_LIBS="$LIBS"
  632     LIBS="pac_conftest.$OBJEXT $LIBS"
  633     AC_LANG_PUSH(Fortran)
  634     AC_LINK_IFELSE([
  635         AC_LANG_PROGRAM([],[call conf1(0)])
  636     ],[
  637         pac_cv_prog_fc_and_c_stdio_libs=none
  638     ],[
  639         # Try again with -lSystemStubs
  640         LIBS="$LIBS -lSystemStubs"
  641         AC_LINK_IFELSE([],[
  642             pac_cv_prog_fc_and_c_stdio_libs="-lSystemStubs"
  643         ],[])
  644     ])
  645     LIBS="$saved_LIBS"
  646     AC_LANG_POP(Fortran)
  647     rm -f pac_conftest.$OBJEXT
  648 ])
  649 AC_LANG_POP(C)
  650 dnl
  651 if test "$pac_cv_prog_fc_and_c_stdio_libs" != none -a \
  652         "$pac_cv_prog_fc_and_c_stdio_libs" != unknown ; then
  653     FC_OTHER_LIBS="$FC_OTHER_LIBS $pac_cv_prog_fc_and_c_stdio_libs"    
  654 fi
  655 ])
  656 dnl
  657 ])
  658 dnl
  659 dnl/*D
  660 dnl PAC_FC_CHECK_COMPILER_OPTION - Check that a FC compiler option is
  661 dnl accepted without warning messages
  662 dnl
  663 dnl Synopsis:
  664 dnl PAC_FC_CHECK_COMPILER_OPTION(optionname,action-if-ok,action-if-fail)
  665 dnl
  666 dnl Output Effects:
  667 dnl
  668 dnl If no actions are specified, a working value is added to 'FCOPTIONS'
  669 dnl
  670 dnl Notes:
  671 dnl This is now careful to check that the output is different, since 
  672 dnl some compilers are noisy.
  673 dnl 
  674 dnl We are extra careful to prototype the functions in case compiler options
  675 dnl that complain about poor code are in effect.
  676 dnl
  677 dnl Because this is a long script, we have ensured that you can pass a 
  678 dnl variable containing the option name as the first argument.
  679 dnl D*/
  680 AC_DEFUN([PAC_FC_CHECK_COMPILER_OPTION],[
  681 AC_MSG_CHECKING([whether Fortran 90 compiler accepts option $1])
  682 pac_opt="$1"
  683 AC_LANG_PUSH(Fortran)
  684 FCFLAGS_orig="$FCFLAGS"
  685 FCFLAGS_opt="$pac_opt $FCFLAGS"
  686 pac_result="unknown"
  687 
  688 AC_LANG_CONFTEST([AC_LANG_PROGRAM()])
  689 FCFLAGS="$FCFLAGS_orig"
  690 rm -f pac_test1.log
  691 PAC_LINK_IFELSE_LOG([pac_test1.log], [], [
  692     FCFLAGS="$FCFLAGS_opt"
  693     rm -f pac_test2.log
  694     PAC_LINK_IFELSE_LOG([pac_test2.log], [], [
  695         PAC_RUNLOG_IFELSE([diff -b pac_test1.log pac_test2.log],
  696                           [pac_result=yes], [pac_result=no])
  697     ],[
  698         pac_result=no
  699     ])
  700 ], [
  701     pac_result=no
  702 ])
  703 AC_MSG_RESULT([$pac_result])
  704 dnl Delete the conftest created by AC_LANG_CONFTEST.
  705 rm -f conftest.$ac_ext
  706 #
  707 if test "$pac_result" = "yes" ; then
  708     AC_MSG_CHECKING([whether routines compiled with $pac_opt can be linked with ones compiled without $pac_opt])
  709     pac_result=unknown
  710     FCFLAGS="$FCFLAGS_orig"
  711     rm -f pac_test3.log
  712     PAC_COMPILE_IFELSE_LOG([pac_test3.log], [
  713         AC_LANG_SOURCE([
  714             subroutine try()
  715             end
  716         ])
  717     ],[
  718         PAC_RUNLOG([mv conftest.$OBJEXT pac_conftest.$OBJEXT])
  719         saved_LIBS="$LIBS"
  720         LIBS="pac_conftest.$OBJEXT $LIBS"
  721 
  722         FCFLAGS="$FCFLAGS_opt"
  723         rm -f pac_test4.log
  724         PAC_LINK_IFELSE_LOG([pac_test4.log], [AC_LANG_PROGRAM()], [
  725             PAC_RUNLOG_IFELSE([diff -b pac_test2.log pac_test4.log],
  726                               [pac_result=yes], [pac_result=no])
  727         ],[
  728             pac_result=no
  729         ])
  730         LIBS="$saved_LIBS"
  731         rm -f pac_conftest.$OBJEXT
  732     ],[
  733         pac_result=no
  734     ])
  735     AC_MSG_RESULT([$pac_result])
  736     rm -f pac_test3.log pac_test4.log
  737 fi
  738 rm -f pac_test1.log pac_test2.log
  739 
  740 dnl Restore FCFLAGS before 2nd/3rd argument commands are executed,
  741 dnl as 2nd/3rd argument command could be modifying FCFLAGS.
  742 FCFLAGS="$FCFLAGS_orig"
  743 if test "$pac_result" = "yes" ; then
  744      ifelse([$2],[],[FCOPTIONS="$FCOPTIONS $1"],[$2])
  745 else
  746      ifelse([$3],[],[:],[$3])
  747 fi
  748 AC_LANG_POP(Fortran)
  749 ])
  750 dnl /*D
  751 dnl PAC_FC_WORKS_WITH_CPP
  752 dnl
  753 dnl Checks if Fortran 90 compiler works with C preprocessor
  754 dnl
  755 dnl Most systems allow the Fortran compiler to process .F and .F90 files
  756 dnl using the C preprocessor.  However, some systems either do not
  757 dnl allow this or have serious bugs (OSF Fortran compilers have a bug
  758 dnl that generates an error message from cpp).  The following test
  759 dnl checks to see if .F works, and if not, whether "cpp -P -C" can be used
  760 dnl D*/
  761 AC_DEFUN([PAC_FC_WORKS_WITH_CPP],[
  762 AC_REQUIRE([AC_PROG_CPP])
  763 AC_MSG_CHECKING([whether Fortran 90 compiler processes .F90 files with C preprocessor])
  764 AC_LANG_PUSH([Fortran])
  765 saved_fc_ext=${ac_ext}
  766 ac_ext="F90"
  767 saved_FCFLAGS="$FCFLAGS"
  768 FCFLAGS="$FCFLAGS $CPPFLAGS"
  769 AC_LANG_CONFTEST([
  770     AC_LANG_SOURCE([
  771         program main
  772 #define ASIZE 10
  773         integer a(ASIZE)
  774         end
  775     ])
  776 ])
  777 AC_COMPILE_IFELSE([],[
  778     pac_cv_fc_accepts_F90=yes
  779     ifelse([$1],[],[],[$1=""])
  780 ],[
  781     pac_cv_fc_accepts_F90=no
  782     ifelse([$1],[],[:],[$1="false"])
  783 ])
  784 # Restore Fortran's ac_ext but not FCFLAGS
  785 ac_ext="$saved_fc_ext"
  786 
  787 if test "$pac_cv_fc_accepts_F90" != "yes" ; then
  788     pac_cpp_fc="$ac_cpp -C -P conftest.F90 > conftest.$ac_ext"
  789     PAC_RUNLOG_IFELSE([$pac_cpp_fc],[
  790         if test -s conftest.${ac_ext} ; then
  791             AC_COMPILE_IFELSE([],[
  792                 pac_cv_fc_accepts_F90="no, use cpp"
  793                 ifelse([$1],[],[],[$1="$CPP -C -P"])
  794             ],[])
  795             rm -f conftest.${ac_ext}
  796         fi
  797     ],[])
  798 fi
  799 FCFLAGS="$saved_FCFLAGS"
  800 rm -f conftest.F90
  801 AC_LANG_POP([Fortran])
  802 AC_MSG_RESULT([$pac_cv_fc_accepts_F90])
  803 ])
  804 dnl
  805 dnl PAC_FC_VENDOR:
  806 dnl Try to get a version string for the F90 compiler.  We may
  807 dnl need this to find likely command-line arguments for accessing
  808 dnl shared libraries
  809 dnl
  810 AC_DEFUN([PAC_FC_VENDOR],[
  811 AC_MSG_CHECKING([for Fortran 90 compiler vendor])
  812 # This is complicated by some compilers (such as the Intel 8.1 ifort)
  813 # that return a non-zero status even when they accept the -V option
  814 # (a zero status is returned only if there is a file).
  815 pac_cv_fc_vendor="unknown"
  816 for arg in --version -V -v ; do
  817     rm -f conftest.txt
  818     PAC_RUNLOG([$FC $arg </dev/null >conftest.txt 2>&1])
  819     # Ignore the return code, because some compilers set the
  820     # return code to zero on invalid arguments and some to 
  821     # non-zero on success (with no files to compile)
  822     if test -f conftest.txt ; then
  823         if grep 'Portland Group' conftest.txt >/dev/null 2>&1 ; then
  824             pac_cv_fc_vendor=pgi
  825         elif grep 'Sun Workshop' conftest.txt >/dev/null 2>&1 ; then
  826             pac_cv_fc_vendor=sun
  827 	elif grep 'Sun Fortran 9' conftest.txt >/dev/null 2>&1 ; then 
  828 	    pac_cv_fc_vendor=sun
  829         elif grep 'Absoft' conftest.txt >/dev/null 2>&1 ; then
  830             pac_cv_fc_vendor=absoft
  831         elif grep 'G95' conftest.txt >/dev/null 2>&1 ; then
  832             pac_cv_fc_vendor=gnu
  833         elif grep 'GNU Fortran' conftest.txt >/dev/null 2>&1 ; then
  834             # This is gfortran
  835             pac_cv_fc_vendor=gnu
  836         elif grep Intel conftest.txt >/dev/null 2>&1 ; then
  837             pac_cv_fc_vendor=intel
  838         fi
  839     fi
  840     if test "$pac_cv_fc_vendor" != "unknown" ; then break ; fi
  841 done
  842 if test "$pac_cv_fc_vendor" = "unknown" ; then
  843     # Try to use the compiler name
  844     if test "$FC" = "ifort" -o "$FC" = "ifc" ; then
  845         pac_cv_fc_vendor=intel
  846     elif test "$FC" = "pgf90" ; then
  847         pac_cv_fc_vendor=pgi
  848     elif test "$FC" = "xlf90" -o "$FC" = "xlf90_r" ; then
  849         pac_cv_fc_vendor=ibm
  850     elif test "$FC" = "xlf95" -o "$FC" = "xlf95_r" ; then
  851         pac_cv_fc_vendor=ibm
  852     fi
  853 fi
  854 AC_MSG_RESULT([$pac_cv_fc_vendor])
  855 rm -f conftest.txt
  856 # End of checking for F90 compiler vendor
  857 ])
  858 dnl
  859 dnl PAC_F77_IS_FC([ACTION_IF_TRUE],[ACTION_IF_FALSE])
  860 dnl Check if F77 is a Fortran 90 compiler.
  861 dnl
  862 AC_DEFUN([PAC_F77_IS_FC],[
  863 AC_MSG_CHECKING([whether $F77 is a Fortran 90 compiler])
  864 AC_LANG_PUSH([Fortran 77])
  865 saved_ac_ext=$ac_ext
  866 ac_ext="f90"
  867 AC_LINK_IFELSE([
  868     AC_LANG_SOURCE([
  869         program main
  870         integer, dimension(10) :: n
  871         integer k
  872         print *,  range(k)
  873         end
  874     ])
  875 ],[
  876     pac_cv_prog_f77_is_fc=yes
  877     ifelse([$1],[],[],[$1])
  878 ],[
  879     pac_cv_prog_f77_is_fc=no
  880     ifelse([$2],[],[],[$2])
  881 ])
  882 AC_MSG_RESULT([$pac_cv_prog_f77_is_fc])
  883 AC_LANG_POP([Fortran 77])
  884 ])
  885 dnl
  886 dnl PAC_FC_FLOAT_MODEL(float_type, [variable-set-if-successful-test])
  887 dnl variable-set-if-successful-test is optional variable.
  888 dnl
  889 dnl This is a runtime test.
  890 dnl
  891 AC_DEFUN([PAC_FC_FLOAT_MODEL],[
  892 type="$1"
  893 AC_MSG_CHECKING([for precision and range of $type])
  894 AC_LANG_PUSH([Fortran])
  895 rm -f pac_fconftest.out
  896 AC_RUN_IFELSE([
  897     AC_LANG_SOURCE([
  898         program main
  899         $type aa
  900         open(8, file="pac_fconftest.out", form="formatted")
  901         write(8,*) precision(aa), ",", range(aa)
  902         close(8)
  903         end
  904     ])
  905 ],[
  906     if test -s pac_fconftest.out ; then
  907         pac_fc_num_model="`sed -e 's/  */ /g' pac_fconftest.out`"
  908         AC_MSG_RESULT([$pac_fc_num_model])
  909         ifelse([$2],[],[],[$2=$pac_fc_num_model])
  910     else
  911         AC_MSG_RESULT([Error])
  912         AC_MSG_WARN([No output from test program!])
  913     fi
  914     rm -f pac_fconftest.out
  915 ],[
  916     AC_MSG_RESULT([Error])
  917     AC_MSG_WARN([Failed to run program to determine the precision and range of $type])
  918 ])
  919 AC_LANG_POP([Fortran])
  920 ])
  921 dnl
  922 dnl PAC_FC_SIMPLE_NUMBER_MODEL(message, Fortran-type, Fortran-write,
  923 dnl                            [variable-set-if-successful-test],
  924 dnl                            [cross-value])
  925 dnl
  926 dnl message        : message of what test-fc-code is checking
  927 dnl Fortran-type   : Fortran90 type's data model to be examined.
  928 dnl Fortran-write  : Fortran90 type's write statement used with write(N,*).
  929 dnl variable-set-if-successful-test :
  930 dnl                  The optional variable to be set if the codelet:
  931 dnl                  "Fortran-type" + "write(N,*) Fortran-write"
  932 dnl                  is successful in returning the simple data model.
  933 dnl cross-value    : value to be used for above variable when
  934 dnl                  cross_compiling=yes
  935 dnl
  936 dnl This is a runtime test.
  937 dnl
  938 AC_DEFUN([PAC_FC_SIMPLE_NUMBER_MODEL],[
  939 pac_msg="$1"
  940 AC_MSG_CHECKING([for $pac_msg])
  941 AC_LANG_PUSH([Fortran])
  942 rm -f pac_fconftest.out
  943 AC_RUN_IFELSE([
  944     AC_LANG_SOURCE([
  945         program main
  946         $2
  947         open(8, file="pac_fconftest.out", form="formatted")
  948         write(8,*) $3
  949         close(8)
  950         end
  951     ])
  952 ],[
  953     if test -s pac_fconftest.out ; then
  954         pac_fc_num_model="`sed -e 's/  */ /g' pac_fconftest.out`"
  955         AC_MSG_RESULT([$pac_fc_num_model])
  956         ifelse([$4],[],[],[$4=$pac_fc_num_model])
  957     else
  958         AC_MSG_RESULT([Error])
  959         AC_MSG_WARN([No output from test program!])
  960     fi
  961     rm -f pac_fconftest.out
  962 ],[
  963     AC_MSG_RESULT([Error])
  964     AC_MSG_WARN([Failed to run program to determine $pac_msg])
  965 ],[
  966     AC_MSG_RESULT([$5])
  967     ifelse([$4],[],[],[$4=$5])
  968 ])
  969 AC_LANG_POP([Fortran])
  970 ])
  971 dnl
  972 dnl PAC_FC_AVAIL_INTEGER_MODELS([INTEGER-MODELS-FLAG],[CROSS-VARIABLE])
  973 dnl
  974 dnl INTEGER-MODELS-FLAG : an optional variable to be set if provided.
  975 dnl                       If it isn't provided, PAC_FC_ALL_INTEGER_MODELS
  976 dnl                       will be set.
  977 dnl CROSS-VALUE         : value will be used to set INTEGER-MODELS-FLAG
  978 dnl                       or PAC_FC_ALL_INTEGER_MODELS if cross_compiling=yes.
  979 dnl
  980 dnl This is a runtime test.
  981 dnl
  982 AC_DEFUN([PAC_FC_AVAIL_INTEGER_MODELS],[
  983 AC_MSG_CHECKING([for available integer kinds])
  984 AC_LANG_PUSH([Fortran])
  985 rm -f pac_fconftest.out
  986 AC_RUN_IFELSE([
  987     AC_LANG_SOURCE([
  988         program main
  989         integer r, lastkind
  990         lastkind=selected_int_kind(1)
  991         open(8, file="pac_fconftest.out", form="formatted")
  992         do r=2,30
  993              k = selected_int_kind(r)
  994              if (k .ne. lastkind) then
  995                   write(8,*) r-1, ",", lastkind
  996                   lastkind = k
  997              endif
  998              if (k .le. 0) then
  999                  exit
 1000              endif
 1001         enddo
 1002         if (k.ne.lastkind) then
 1003             write(8,*) 31, ",", k
 1004         endif
 1005         close(8)
 1006         end
 1007     ])
 1008 ],[
 1009     if test -s pac_fconftest.out ; then
 1010         pac_flag="`sed -e 's/  */ /g' pac_fconftest.out | tr '\012' ','`"
 1011         AC_MSG_RESULT([$pac_flag])
 1012         pac_validKinds="`sed -e 's/  */ /g' pac_fconftest.out | tr '\012' ':'`"
 1013         ifelse([$1],[],[PAC_FC_ALL_INTEGER_MODELS=$pac_flag],[$1=$pac_flag])
 1014     else
 1015         AC_MSG_RESULT([Error])
 1016         AC_MSG_WARN([No output from test program!])
 1017     fi
 1018     rm -f pac_fconftest.out
 1019 ],[
 1020     AC_MSG_RESULT([Error])
 1021     AC_MSG_WARN([Failed to run program to determine available integer models])
 1022 ],[
 1023     dnl Even when cross_compiling=yes,
 1024     dnl pac_validKinds needs to be set for PAC_FC_INTEGER_MODEL_MAP()
 1025     pac_validKinds="`echo \"$2\" | tr ',' ':'`"
 1026     AC_MSG_RESULT([$2])
 1027     ifelse([$1],[],[PAC_FC_ALL_INTEGER_MODELS=$2],[$1=$2])
 1028 ])
 1029 AC_LANG_POP([Fortran])
 1030 ])
 1031 dnl
 1032 dnl PAC_FC_INTEGER_MODEL_MAP([INTEGER-MODEL-MAP-FLAG],[CROSS-VALUE]))
 1033 dnl
 1034 dnl INTEGER-MODEL-MAP-FLAG : an optional variable to be set if provided.
 1035 dnl                          If it isn't provided, PAC_FC_INTEGER_MODEL_MAP
 1036 dnl                          will be set.
 1037 dnl CROSS-VALUE            : value will be used to set INTEGER-MODEL-MAP-FLAG
 1038 dnl                          or PAC_FC_INTEGER_MODEL_MAP if cross_compiling=yes.
 1039 dnl
 1040 dnl This test requires $pac_validKinds set by PAC_FC_ALL_INTEGER_MODELS().
 1041 dnl
 1042 dnl This is a runtime test.
 1043 dnl
 1044 dnl Compile the C subroutine as pac_conftest.o and Link it with a Fortran main.
 1045 AC_DEFUN([PAC_FC_INTEGER_MODEL_MAP],[
 1046 AC_REQUIRE([PAC_FC_AVAIL_INTEGER_MODELS])
 1047 AC_MSG_CHECKING([for available integer ranges])
 1048 AC_LANG_PUSH([C])
 1049 AC_COMPILE_IFELSE([
 1050     AC_LANG_SOURCE([
 1051 #ifdef F77_NAME_UPPER
 1052 #define cisize_ CISIZE
 1053 #define isize_ ISIZE
 1054 #elif defined(F77_NAME_LOWER) || defined(F77_NAME_MIXED)
 1055 #define cisize_ cisize
 1056 #define isize_ isize
 1057 #endif
 1058 int cisize_(char *,char*);
 1059 int cisize_(char *i1p, char *i2p)
 1060 {
 1061     int isize_val=0;
 1062     isize_val = (int)(i2p - i1p);
 1063     return isize_val;
 1064 }
 1065     ])
 1066 ],[
 1067     PAC_RUNLOG([mv conftest.$OBJEXT pac_conftest.$OBJEXT])
 1068     pac_ccompile_ok=yes
 1069 ],[
 1070     pac_ccompile_ok=no
 1071 ])
 1072 AC_LANG_POP([C])
 1073 dnl
 1074 if test "$pac_ccompile_ok" = "yes" ; then
 1075     saved_LIBS="$LIBS"
 1076     LIBS="pac_conftest.$OBJEXT $LIBS"
 1077     saved_IFS=$IFS
 1078     IFS=:
 1079     AC_LANG_PUSH([Fortran])
 1080     pac_flag=""
 1081     for rangekind in $pac_validKinds ; do
 1082         kind="`echo $rangekind | sed -e 's/.*,//'`"
 1083         range="`echo $rangekind | sed -e 's/,.*//'`"
 1084         AC_LANG_CONFTEST([
 1085             AC_LANG_SOURCE([
 1086                 program main
 1087                 integer (kind=$kind) a(2)
 1088                 integer cisize
 1089                 open(8, file="pac_fconftest.out", form="formatted")
 1090                 write(8,*) $range, ",", $kind, ",", cisize( a(1), a(2) )
 1091                 close(8)
 1092                 end
 1093             ])
 1094         ])
 1095         IFS=$saved_IFS
 1096         rm -f pac_fconftest.out
 1097         AC_RUN_IFELSE([],[
 1098             if test -s pac_fconftest.out ; then
 1099                 sizes="`sed -e 's/  */ /g' pac_fconftest.out`"
 1100                 pac_flag="$pac_flag { $sizes },"
 1101             else
 1102                 AC_MSG_WARN([No output from test program!])
 1103             fi
 1104             rm -f pac_fconftest.out
 1105         ],[
 1106             AC_MSG_WARN([Fortran program fails to build or run!])
 1107         ],[
 1108             pac_flag="$2"
 1109         ])
 1110         IFS=:
 1111     done
 1112     IFS=$saved_IFS
 1113     AC_MSG_RESULT([$pac_flag])
 1114     ifelse([$1],[],[PAC_FC_INTEGER_MODEL_MAP=$pac_flag],[$1=$pac_flag])
 1115     AC_LANG_POP([Fortran])
 1116     LIBS="$saved_LIBS"
 1117     rm -f pac_conftest.$OBJEXT
 1118 fi
 1119 ])
 1120 
 1121 
 1122 AC_DEFUN([PAC_FC_2008_SUPPORT],[
 1123 AC_MSG_CHECKING([for Fortran 2008 support])
 1124 
 1125 AC_LANG_PUSH([C])
 1126 f08_works=yes
 1127 AC_COMPILE_IFELSE([
 1128 	AC_LANG_SOURCE(
 1129 [[
 1130 #include <ISO_Fortran_binding.h>
 1131 
 1132 int foo_c(CFI_cdesc_t * a_desc, CFI_cdesc_t * b_desc)
 1133 {
 1134 	char * a_row = (char*) a_desc->base_addr;
 1135 	if (a_desc->type != CFI_type_int) { return 1; }
 1136 	if (a_desc->rank != 2) { return 2; }
 1137 	if (a_desc->dim[1].extent != b_desc->dim[0].extent) { return 3; }
 1138 	return 0;
 1139 }
 1140 ]])],[mv conftest.$OBJEXT conftest1.$OBJEXT],[f08_works=no])
 1141 AC_LANG_POP([C])
 1142 
 1143 AC_LANG_PUSH([Fortran])
 1144 PAC_PUSH_FLAG([LIBS])
 1145 LIBS="conftest1.$OBJEXT $LIBS"
 1146 AC_LINK_IFELSE([
 1147     AC_LANG_SOURCE([
 1148 MODULE F08TS_MODULE
 1149 IMPLICIT NONE
 1150 
 1151 ! Test public, private, protected
 1152 REAL, PUBLIC       :: x
 1153 REAL, PRIVATE      :: y
 1154 LOGICAL, PROTECTED :: z
 1155 
 1156 ! Test abstract
 1157 ABSTRACT INTERFACE
 1158     SUBROUTINE user_func(x, y)
 1159         INTEGER  :: x(*)
 1160         REAL     :: y
 1161     END SUBROUTINE
 1162 END INTERFACE
 1163 
 1164 ! Test TS 29113 assumed type , assumed rank and bind(C)
 1165 INTERFACE
 1166     FUNCTION FOO(A, B, C) &
 1167         BIND(C,name="foo_c") RESULT(err)
 1168         USE, intrinsic :: iso_c_binding, ONLY : c_int
 1169         TYPE(*), DIMENSION(..) :: A, B, C
 1170         INTEGER(c_int) :: err
 1171     END FUNCTION FOO
 1172 END INTERFACE
 1173 
 1174 ! Test assumed-rank + asynchronous
 1175 INTERFACE TEST_ASSUMED_RANK_ASYNC
 1176     SUBROUTINE TEST_ASSUMED_RANK_ASYNC_IMPL(BUF)
 1177         IMPLICIT NONE
 1178         TYPE(*), DIMENSION(..), ASYNCHRONOUS :: BUF
 1179     END SUBROUTINE TEST_ASSUMED_RANK_ASYNC_IMPL
 1180 END INTERFACE TEST_ASSUMED_RANK_ASYNC
 1181 
 1182 CONTAINS
 1183 
 1184 ! Test TS 29113 asychronous attribute and optional
 1185 SUBROUTINE test1(buf, count, ierr)
 1186     INTEGER, ASYNCHRONOUS :: buf(*)
 1187     INTEGER               :: count
 1188     INTEGER, OPTIONAL     :: ierr
 1189 END SUBROUTINE
 1190 
 1191 ! Test procedure type and non-bind(c) x in C_FUNCLOC(x)
 1192 SUBROUTINE test2(func)
 1193     USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_FUNLOC, C_FUNPTR
 1194     PROCEDURE(user_func)  :: func
 1195     TYPE(C_FUNPTR) :: errhandler_fn
 1196     errhandler_fn = C_FUNLOC(func)
 1197 END SUBROUTINE
 1198 
 1199 ! Test intrinsic storage_size
 1200 SUBROUTINE test3(x, size)
 1201     CHARACTER, DIMENSION(..) :: x
 1202     INTEGER, INTENT(OUT) :: size
 1203     size = storage_size(x)/8
 1204 END SUBROUTINE test3
 1205 
 1206 END MODULE
 1207 
 1208 !==============================================
 1209 PROGRAM MAIN
 1210 USE :: F08TS_MODULE, ONLY : FOO, TEST_ASSUMED_RANK_ASYNC
 1211 IMPLICIT NONE
 1212 
 1213 INTEGER, DIMENSION(4,4) :: A, B
 1214 INTEGER, DIMENSION(2,2) :: C
 1215 INTEGER                 :: ERRCODE
 1216 INTEGER, DIMENSION(10), ASYNCHRONOUS :: IAR
 1217 
 1218 ! Test contiguous and non-contiguous array section passing
 1219 ! and linkage with C code
 1220 ERRCODE = FOO(A(1:4:2, :), B(:, 2:4:2), C)
 1221 CALL TEST_ASSUMED_RANK_ASYNC(IAR(2:7))
 1222 
 1223 END PROGRAM
 1224     ])],[],[f08_works=no])
 1225 PAC_POP_FLAG([LIBS])
 1226 AC_LANG_POP([Fortran])
 1227 
 1228 if test "$f08_works" = "yes" ; then
 1229    $1
 1230 else
 1231    $2
 1232 fi
 1233 rm -f conftest1.$OBJEXT F08TS_MODULE.* f08ts_module.*
 1234 AC_MSG_RESULT([$f08_works])
 1235 ])