root/mpich2/branches/dev/kumudb/confdb/aclocal_f90.m4 @ 4870

Revision 4870, 23.5 KB (checked in by kumudb, 5 months ago)

Merge from trunk to kumudb r4748:r4869

Line 
1dnl
2dnl Macros for Fortran 90
3dnl
4dnl We'd like to have a PAC_LANG_FORTRAN90 that worked with AC_TRY_xxx, but
5dnl that would require too many changes to autoconf macros.
6dnl
7AC_DEFUN([PAC_LANG_FORTRAN90],
8[AC_REQUIRE([PAC_PROG_F90])
9define([AC_LANG], [FORTRAN90])dnl
10ac_ext=$pac_cv_f90_ext
11ac_compile='${F90-f90} -c $F90FLAGS conftest.$ac_ext 1>&AC_FD_CC'
12ac_link='${F90-f90} -o conftest${ac_exeext} $F90FLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&AC_FD_CC'
13dnl cross_compiling no longer maintained by autoconf as part of the
14dnl AC_LANG changes.  If we set it here, a later AC_LANG may not
15dnl restore it (in the case where one compiler claims to be a cross compiler
16dnl and another does not)
17dnl cross_compiling=$pac_cv_prog_f90_cross
18])
19dnl
20dnl This is an addition for AC_TRY_COMPILE, but for f90.  If the current
21dnl language is not f90, it does a save/restore
22AC_DEFUN([PAC_TRY_F90_COMPILE],
23[AC_REQUIRE([PAC_LANG_FORTRAN90])
24ifelse(AC_LANG, FORTRAN90,,[AC_LANG_SAVE
25PAC_LANG_FORTRAN90
26define([NEED_POP],yes)])
27cat > conftest.$ac_ext <<EOF
28      program main
29[$2]
30      end
31EOF
32if AC_TRY_EVAL(ac_compile); then
33  ifelse([$3], , :, [rm -rf conftest*
34  $3])
35else
36  echo "configure: failed program was:" >&AC_FD_CC
37  cat conftest.$ac_ext >&AC_FD_CC
38ifelse([$4], , , [  rm -rf conftest*
39  $4
40])dnl
41fi
42rm -f conftest*
43# The intel compiler sometimes generates these work.pc and .pcl files
44rm -f work.pc work.pcl
45ifelse(NEED_POP,yes,[
46undefine([NEED_POP])
47AC_LANG_RESTORE])
48])
49dnl/*D
50dnl PAC_F90_MODULE_EXT - Determine the filename extension of F90 module
51dnl
52dnl Synopsis:
53dnl PAC_F90_MODULE_EXT(action if found,action if not found)
54dnl
55dnl Variables set include:
56dnl +  pac_cv_f90_module_ext - extension for created modules
57dnl -  pac_cv_f90_module_case - case of name for created module (where the
58dnl      module name in the source file is lowercase).  One
59dnl      of unknown, lower, upper
60dnl D*/
61AC_DEFUN([PAC_F90_MODULE_EXT],
62[AC_CACHE_CHECK([for Fortran 90 module extension],
63pac_cv_f90_module_ext,[
64# aclocal_f90.m4 version
65pac_cv_f90_module_case="unknown"
66rm -f conftest*
67# Intel ifc compiler generates files by the name of work.pc and work.pcl (!)
68rm -f work.pc work.pcl
69cat >conftest.$ac_f90ext <<EOF
70        module conftest
71        integer n
72        parameter (n=1)
73        end module conftest
74EOF
75if AC_TRY_EVAL(ac_f90compile) ; then
76   dnl Look for module name
77   dnl First, try to find known names.  This avoids confusion caused by
78   dnl additional files (like <name>.stb created by some versions of pgf90)
79   for name in conftest CONFTEST ; do
80       for ext in mod MOD ; do
81           if test -s $name.$ext ; then
82               if test $name = conftest ; then
83                   pac_cv_f90_module_case=lower
84               else
85                   pac_cv_f90_module_case=upper
86               fi
87               pac_cv_f90_module_ext=$ext
88               pac_MOD=$ext
89               break
90           fi
91       done
92       if test -n "$pac_cv_f90_module_ext" ; then break ; fi
93   done
94   if test -z "$pac_MOD" ; then
95               
96       pac_MOD=`ls conftest.* 2>&1 | grep -v conftest.$ac_f90ext | grep -v conftest.o`
97       pac_MOD=`echo $pac_MOD | sed -e 's/conftest\.//g'`
98       pac_cv_f90_module_case="lower"
99       if test "X$pac_MOD" = "X" ; then
100           pac_MOD=`ls CONFTEST* 2>&1 | grep -v CONFTEST.f | grep -v CONFTEST.o`
101           pac_MOD=`echo $pac_MOD | sed -e 's/CONFTEST\.//g'`
102           if test -n "$pac_MOD" ; then
103               testname="CONFTEST"
104               pac_cv_f90_module_case="upper"
105           fi
106       fi
107       if test -z "$pac_MOD" ; then
108           pac_cv_f90_module_ext="unknown"
109       else
110           pac_cv_f90_module_ext=$pac_MOD
111       fi
112    fi
113else
114    echo "configure: failed program was:" >&AC_FD_CC
115    cat conftest.$ac_f90ext >&AC_FD_CC
116    pac_cv_f90_module_ext="unknown"
117fi
118rm -f conftest*
119# The intel compiler sometimes generates these work.pc and .pcl files
120rm -f work.pc work.pcl
121])
122if test -s work.pcl ; then
123    AC_MSG_WARN([Compiler generates auxillery files (work.pcl)!])
124fi
125AC_SUBST(F90MODEXT)
126if test "$pac_cv_f90_module_ext" = "unknown" ; then
127    ifelse($2,,:,[$2])
128else
129    ifelse($1,,F90MODEXT=$pac_MOD,[$1])
130fi
131])
132dnl
133dnl PAC_F90_MODULE_INCFLAG - Determine the compiler flags for specifying
134dnl directories that contain compiled Fortran 90 modules
135dnl
136AC_DEFUN([PAC_F90_MODULE_INCFLAG],[
137AC_CACHE_CHECK([for Fortran 90 module include flag],
138pac_cv_f90_module_incflag,[
139AC_REQUIRE([PAC_F90_MODULE_EXT])
140#
141# Note that the name of the file and the name of the module must be
142# the same (some compilers use the module, some the file name)
143rm -f work.pc work.pcl conftest.$ac_f90ext
144cat >conftest.$ac_f90ext <<EOF
145        module conftest
146        integer n
147        parameter (n=1)
148        end module conftest
149EOF
150pac_madedir="no"
151if test ! -d conftestdir ; then mkdir conftestdir ; pac_madedir="yes"; fi
152if test "$pac_cv_f90_module_case" = "upper" ; then
153    pac_module="CONFTEST.$pac_cv_f90_module_ext"
154else
155    pac_module="conftest.$pac_cv_f90_module_ext"
156fi
157if AC_TRY_EVAL(ac_f90compile) ; then
158    if test -s "$pac_module" ; then
159        mv $pac_module conftestdir
160        # Remove any temporary files, and hide the work.pc file (if
161        # the compiler generates them)
162        if test -f work.pc ; then
163            mv -f work.pc conftest.pc
164        fi
165        rm -f work.pcl
166    else
167        AC_MSG_WARN([Unable to build a simple F90 module])
168        echo "configure: failed program was:" >&AC_FD_CC
169        cat conftest.$ac_f90ext >&AC_FD_CC
170    fi
171else
172    echo "configure: failed program was:" >&AC_FD_CC
173    cat conftest.$ac_f90ext >&AC_FD_CC
174fi
175rm -f conftest.$ac_f90ext
176cat >conftest.$ac_f90ext <<EOF
177       program main
178       use conftest
179       end
180EOF
181pac_cv_f90_module_incflag="unknown"
182if ${F90-f90} -c $F90FLAGS -Iconftestdir conftest.$ac_f90ext 1>&AC_FD_CC 2>&1 && \
183        test -s conftest.o ; then
184    pac_cv_f90_module_incflag="-I"
185elif ${F90-f90} -c $F90FLAGS -Mconftestdir conftest.$ac_f90ext 1>&AC_FD_CC 2>&1 && \
186        test -s conftest.o ; then
187    pac_cv_f90_module_incflag="-M"
188elif ${F90-f90} -c $F90FLAGS -pconftestdir conftest.$ac_f90ext 1>&AC_FD_CC 2>&1 && \
189        test -s conftest.o ; then
190    pac_cv_f90_module_incflag="-p"
191elif test -s work.pc ; then
192     mv conftest.pc conftestdir/mpimod.pc
193     echo "mpimod.pc" > conftestdir/mpimod.pcl
194     echo "`pwd`/conftestdir/mpimod.pc" >> conftestdir/mpimod.pcl
195     if ${F90-f90} -c $F90FLAGS -cl,conftestdir/mpimod.pcl conftest.$ac_f90ext 1>&AC_FD_CC 2>&1 && test -s conftest.o ; then
196         pac_cv_f90_module_incflag='-cl,'
197        # Not quite right; see the comments that follow
198         AC_MSG_RESULT([-cl,filename where filename contains a list of files and directories])
199         F90_WORK_FILES_ARG="-cl,mpimod.pcl"
200         F90MODINCSPEC="-cl,<dir>/<file>mod.pcl"
201         AC_SUBST(F90_WORK_FILES_ARG)
202     else
203         # The version of the Intel compiler that I have refuses to let
204         # you put the "work catalog" list anywhere but the current directory.
205         pac_cv_f90_module_incflag="Unavailable!"
206     fi
207else
208    # Early versions of the Intel ifc compiler required a *file*
209    # containing the names of files that contained the names of the
210    #
211    # -cl,filename.pcl
212    #   filename.pcl contains
213    #     fullpathname.pc
214    # The "fullpathname.pc" is generated, I believe, when a module is
215    # compiled. 
216    # Intel compilers use a wierd system: -cl,filename.pcl .  If no file is
217    # specified, work.pcl and work.pc are created.  However, if you specify
218    # a file, it must contain a the name of a file ending in .pc .  Ugh!
219    pac_cv_f90_module_incflag="unknown"
220fi
221if test "$pac_madedir" = "yes" ; then rm -rf conftestdir ; fi
222rm -f conftest*
223# The intel compiler sometimes generates these work.pc and .pcl files
224rm -f work.pc work.pcl
225])
226AC_SUBST(F90MODINCFLAG)
227F90MODINCFLAG=$pac_cv_f90_module_incflag
228])
229AC_DEFUN([PAC_F90_MODULE],[
230PAC_F90_MODULE_EXT
231PAC_F90_MODULE_INCFLAG
232])
233AC_DEFUN([PAC_F90_EXT],[
234AC_CACHE_CHECK([whether Fortran 90 accepts f90 suffix],
235pac_cv_f90_ext_f90,[
236save_ac_f90ext=$ac_f90ext
237ac_f90ext="f90"
238PAC_TRY_F90_COMPILE(,,pac_cv_f90_ext_f90="yes",pac_cv_f90_ext_f90="no")
239ac_f90ext=$save_ac_f90ext
240])
241])
242dnl
243dnl/*D
244dnl PAC_PROG_F90_INT_KIND - Determine kind parameter for an integer with
245dnl the specified number of bytes.
246dnl
247dnl Synopsis:
248dnl  PAC_PROG_F90_INT_KIND(variable-to-set,number-of-bytes,[cross-size])
249dnl
250dnl D*/
251AC_DEFUN([PAC_PROG_F90_INT_KIND],[
252# Set the default
253$1=-1
254if test "$pac_cv_prog_f90_cross" = "yes" ; then
255    $1="$3"
256else
257if test -n "$ac_f90compile" ; then
258    AC_MSG_CHECKING([for Fortran 90 integer kind for $2-byte integers])
259    # Convert bytes to digits
260    case $2 in
261        1) sellen=2 ;;
262        2) sellen=4 ;;
263        4) sellen=8 ;;
264        8) sellen=16 ;;
265       16) sellen=30 ;;
266        *) sellen=8 ;;
267    esac
268    # Check for cached value
269    eval testval=\$"pac_cv_prog_f90_int_kind_$sellen"
270    if test -n "$testval" ; then
271        AC_MSG_RESULT([$testval (cached)])
272        $1=$testval
273    else
274        # must compute
275        rm -f conftest*
276        cat <<EOF > conftest.$ac_f90ext
277      program main
278      integer i
279      i = selected_int_kind($sellen)
280      open(8, file="conftest1.out", form="formatted")
281      write (8,*) i
282      close(8)
283      stop
284      end
285EOF
286        KINDVAL="unavailable"
287        eval "pac_cv_prog_f90_int_kind_$sellen"=-1
288        if AC_TRY_EVAL(ac_f90link) && test -s conftest ; then
289            ./conftest 1>&AC_FD_CC 2>&1
290            if test -s conftest1.out ; then
291                # Because of write, there may be a leading blank.
292                KINDVAL=`cat conftest1.out | sed 's/ //g'`
293                eval "pac_cv_prog_f90_int_kind_$sellen"=$KINDVAL
294                $1=$KINDVAL
295            fi
296        fi
297        rm -f conftest*
298        # The intel compiler sometimes generates these work.pc and .pcl files
299        rm -f work.pc work.pcl
300        AC_MSG_RESULT($KINDVAL)
301    fi # not cached
302fi # Has Fortran 90
303fi # is not cross compiling
304])dnl
305dnl
306dnl
307dnl Note: This checks for f95 before f90, since F95 is the more recent
308dnl revision of Fortran 90.  efc is the Intel Fortran 77/90/95 compiler
309dnl The compilers are:
310dnl xlf90 - IBM
311dnl pgf90 - Portland group
312dnl f90/f95 - Miscellaneous compilers, including NAG, Solaris, IRIX
313# It is believed that under HP-UX `fort77' is the name of the native
314# compiler.  On some Cray systems, fort77 is a native compiler.
315# frt is the Fujitsu F77 compiler.
316# pgf77 and pgf90 are the Portland Group F77 and F90 compilers.
317# xlf/xlf90/xlf95 are IBM (AIX) F77/F90/F95 compilers.
318# lf95 is the Lahey-Fujitsu compiler.
319# fl32 is the Microsoft Fortran "PowerStation" compiler.
320# af77 is the Apogee F77 compiler for Intergraph hardware running CLIX.
321# epcf90 is the "Edinburgh Portable Compiler" F90.
322# fort is the Compaq Fortran 90 (now 95) compiler for Tru64 and Linux/Alpha.
323# pathf90 is the Pathscale Fortran 90 compiler
324# ifort is another name for the Inten f90 compiler
325# efc - An older Intel compiler (?)
326# ifc - An older Intel compiler
327AC_DEFUN([PAC_PROG_F90],[
328if test -z "$F90" ; then
329    AC_CHECK_PROGS(F90,f90 xlf90 pgf90 ifort epcf90 f95 fort xlf95 lf95 pathf95 pathf90 g95 gfortran ifc efc)
330    test -z "$F90" && AC_MSG_WARN([no acceptable Fortran 90 compiler found in \$PATH])
331fi
332if test -n "$F90" ; then
333     PAC_PROG_F90_WORKS
334fi
335dnl Cache these so we don't need to change in and out of f90 mode
336ac_f90ext=$pac_cv_f90_ext
337ac_f90compile='${F90-f90} -c $F90FLAGS conftest.$ac_f90ext 1>&AC_FD_CC'
338ac_f90link='${F90-f90} -o conftest${ac_exeext} $F90FLAGS $LDFLAGS conftest.$ac_f90ext $LIBS 1>&AC_FD_CC'
339# Check for problems with Intel efc compiler, if the compiler works
340if test "$pac_cv_prog_f90_works" = yes ; then
341    cat > conftest.$ac_f90ext <<EOF
342        program main
343        end
344EOF
345    pac_msg=`$F90 -o conftest $F90FLAGS $LDFLAGS conftest.$ac_f90ext $LIBS 2>&1 | grep 'bfd assertion fail'`
346    if test -n "$pac_msg" ; then
347        pac_msg=`$F90 -o conftest $F90FLAGS $LDFLAGS conftest.$ac_f90ext -i_dynamic $LIBS 2>&1 | grep 'bfd assertion fail'`
348        if test -z "$pac_msg" ; then LDFLAGS="-i_dynamic" ; fi
349        # There should really be f90linker flags rather than generic ldflags.
350    fi
351fi
352])
353dnl Internal routine for testing F90
354dnl PAC_PROG_F90_WORKS()
355AC_DEFUN([PAC_PROG_F90_WORKS],
356[AC_MSG_CHECKING([for extension for Fortran 90 programs])
357pac_cv_f90_ext="f90"
358cat > conftest.$pac_cv_f90_ext <<EOF
359      program conftest
360      end
361EOF
362ac_compile='${F90-f90} -c $F90FLAGS conftest.$pac_cv_f90_ext 1>&AC_FD_CC'
363if AC_TRY_EVAL(ac_compile) ; then
364    AC_MSG_RESULT([f90])
365else
366    rm -f conftest*
367    pac_cv_f90_ext="f"
368    cat > conftest.$pac_cv_f90_ext <<EOF
369      program conftest
370      end
371EOF
372    if AC_TRY_EVAL(ac_compile) ; then
373        AC_MSG_RESULT([f])
374    else
375        AC_MSG_RESULT([unknown!])
376    fi
377fi
378AC_MSG_CHECKING([whether the Fortran 90 compiler ($F90 $F90FLAGS $LDFLAGS) works])
379AC_LANG_SAVE
380# We cannot use _LANG_FORTRAN90 here because we will usually be executing this
381# test in the context of _PROG_F90, which is a require on _LANG_FORTRAN90.
382# Instead, we insert the necessary code from _LANG_FORTRAN90 here
383dnl PAC_LANG_FORTRAN90
384dnl define(ifdef([_AC_LANG],[_AC_LANG],[AC_LANG]), [FORTRAN90])dnl
385define([AC_LANG], [FORTRAN90])dnl
386ac_ext=$pac_cv_f90_ext
387ac_compile='${F90-f90} -c $F90FLAGS conftest.$ac_ext 1>&AC_FD_CC'
388ac_link='${F90-f90} -o conftest${ac_exeext} $F90FLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&AC_FD_CC'
389dnl cross_compiling no longer maintained by autoconf as part of the
390dnl AC_LANG changes.  If we set it here, a later AC_LANG may not
391dnl restore it (in the case where one compiler claims to be a cross compiler
392dnl and another does not)
393dnl cross_compiling=$pac_cv_prog_f90_cross
394# Include a Fortran 90 construction to distinguish between Fortran 77
395# and Fortran 90 compilers.
396cat >conftest.$ac_ext <<EOF
397      program conftest
398      integer, dimension(10) :: n
399      end
400EOF
401if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeect} ; then
402    pac_cv_prog_f90_works="yes"
403    if (./conftest; exit) 2>/dev/null ; then
404        pac_cv_prog_f90_cross="no"
405    else
406        pac_cv_prog_f90_cross="yes"
407    fi
408else
409  echo "configure: failed program was:" >&AC_FD_CC
410  cat conftest.$ac_ext >&AC_FD_CC
411  pac_cv_prog_f90_works="no"
412fi
413rm -f conftest*
414# The intel compiler sometimes generates these work.pc and .pcl files
415rm -f work.pc work.pcl
416AC_LANG_RESTORE
417AC_MSG_RESULT($pac_cv_prog_f90_works)
418if test $pac_cv_prog_f90_works = no; then
419  AC_MSG_WARN([installation or configuration problem: Fortran 90 compiler cannot create executables.])
420fi
421AC_MSG_CHECKING([whether the Fortran 90 compiler ($F90 $F90FLAGS $LDFLAGS) is a cross-compiler])
422AC_MSG_RESULT($pac_cv_prog_f90_cross)
423dnl cross_compiling no longer maintained by autoconf as part of the
424dnl AC_LANG changes.  If we set it here, a later AC_LANG may not
425dnl restore it (in the case where one compiler claims to be a cross compiler
426dnl and another does not)
427dnl cross_compiling=$pac_cv_prog_f90_cross
428])
429dnl
430dnl This version uses a Fortran program to link programs.
431dnl This is necessary because some compilers provide shared libraries
432dnl that are not within the default linker paths (e.g., our installation
433dnl of the Portland Group compilers).
434dnl We assume a naming convention consistent with the Fortran 77 one.
435dnl
436AC_DEFUN([PAC_PROG_F90_CHECK_SIZEOF],[
437changequote(<<,>>)dnl
438dnl The name to #define.
439dnl If the arg value contains a variable, we need to update that
440define(<<PAC_TYPE_NAME>>, translit(sizeof_f90_$1, [a-z *], [A-Z__]))dnl
441dnl The cache variable name.
442define(<<PAC_CV_NAME>>, translit(pac_cv_f90_sizeof_$1, [ *], [__]))dnl
443changequote([,])dnl
444AC_CACHE_CHECK([for size of Fortran type $1],PAC_CV_NAME,[
445AC_REQUIRE([PAC_PROG_F77_NAME_MANGLE])
446if test "$cross_compiling" = yes ; then
447    ifelse([$2],,[AC_MSG_WARN([No value provided for size of $1 when cross-compiling])]
448,eval PAC_CV_NAME=$2)
449else
450    rm -f conftest*
451    cat <<EOF > conftestc.c
452#include <stdio.h>
453#include "confdefs.h"
454#ifdef F77_NAME_UPPER
455#define cisize_ CISIZE
456#define isize_ ISIZE
457#elif defined(F77_NAME_LOWER) || defined(F77_NAME_MIXED)
458#define cisize_ cisize
459#define isize_ isize
460#endif
461int cisize_(char *,char*);
462int cisize_(char *i1p, char *i2p)
463{
464    int isize_val=0;
465    FILE *f = fopen("conftestval", "w");
466    if (!f) return 1;
467    isize_val = (int)(i2p - i1p);
468    fprintf(f,"%d\n", isize_val );
469    fclose(f);
470    return 0;
471}
472EOF
473    pac_tmp_compile='$CC -c $CFLAGS $CPPFLAGS conftestc.c >&5'
474    if AC_TRY_EVAL(pac_tmp_compile) && test -s conftestc.o ; then
475        AC_LANG_SAVE
476        AC_LANG_FORTRAN77
477        saveLIBS=$LIBS
478        LIBS="conftestc.o $LIBS"
479        dnl TRY_RUN does not work correctly for autoconf 2.13 (the
480        dnl macro includes C-preprocessor directives that are not
481        dnl valid in Fortran.  Instead, we do this by hand
482        cat >conftest.f <<EOF
483         program main
484         $1 a(2)
485         integer irc
486         irc = cisize(a(1),a(2))
487         end
488EOF
489        rm -f conftest$ac_exeext
490        rm -f conftestval
491        if AC_TRY_EVAL(ac_link) && test -s conftest$ac_exeext ; then
492            if ./conftest$ac_exeext ; then
493                # success
494                :
495            else
496                # failure
497                :
498            fi
499        else
500            # failure
501            AC_MSG_WARN([Unable to build program to determine size of $1])
502        fi
503        AC_LANG_RESTORE
504        if test -s conftestval ; then
505            eval PAC_CV_NAME=`cat conftestval`
506        else
507            eval PAC_CV_NAME=0
508        fi
509        rm -f conftest*
510        # The intel compiler sometimes generates these work.pc and .pcl files
511        rm -f work.pc work.pcl
512        LIBS=$saveLIBS
513    else
514        AC_MSG_WARN([Unable to compile the C routine for finding the size of a $1])
515    fi
516fi # cross-compiling
517])
518AC_DEFINE_UNQUOTED(PAC_TYPE_NAME,$PAC_CV_NAME,[Define size of PAC_TYPE_NAME])
519undefine([PAC_TYPE_NAME])
520undefine([PAC_CV_NAME])
521])
522dnl
523dnl PAC_F90_AND_F77_COMPATIBLE([action-if-true],[action-if-false])
524dnl
525dnl Determine whether object files compiled with Fortran 77 can be
526dnl linked to Fortran 90 main programs.
527dnl
528dnl The test uses a name that includes an underscore unless the 3rd
529dnl argument provides another routine name.
530dnl
531AC_DEFUN([PAC_F90_AND_F77_COMPATIBLE],[
532AC_REQUIRE([PAC_PROG_F90_WORKS])
533AC_CACHE_CHECK([whether Fortran 90 works with Fortran 77],
534pac_cv_f90_and_f77,[
535pac_cv_f90_and_f77="unknown"
536rm -f conftest*
537if test -z "$ac_ext_f90" ; then ac_ext_f90=$pac_cv_f90_ext ; fi
538# Define the two language-specific steps
539link_f90='${F90-f90} -o conftest${ac_exeext} $F90FLAGS $LDFLAGS conftest1.$ac_ext_f90 conftest2.o $LIBS 1>&AC_FD_CC'
540compile_f77='${F77-f77} -c $FFLAGS conftest2.f 1>&AC_FD_CC'
541# Create test programs
542pacTestRoutine=t1_2
543# eval the assignment in case the argument is a variable.
544ifelse([$3],,,[eval pacTestRoutine=$3])
545cat > conftest1.$ac_ext_f90 <<EOF
546       program main
547       integer a
548       a = 1
549       call ${pacTestRoutine}(a)
550       end
551EOF
552cat > conftest2.f <<EOF
553       subroutine ${pacTestRoutine}(b)
554       integer b
555       b = b + 1
556       end
557EOF
558# compile the f77 program and link with the f90 program
559# The reverse may not work because the Fortran 90 environment may
560# expect to be in control (and to provide library files unknown to any other
561# environment, even Fortran 77!)
562if AC_TRY_EVAL(compile_f77) ; then
563    # Clean these files out just in case
564    rm -f work.pc work.pcl
565    if AC_TRY_EVAL(link_f90) && test -x conftest ; then
566        pac_cv_f90_and_f77="yes"
567    else
568        pac_cv_f90_and_f77="no"
569    fi
570    # Some versions of the Intel compiler produce these two files
571    rm -f work.pc work.pcl
572else
573    # If we can't compile the f77 version, then the compilers are not
574    # compatible.
575    pac_cv_f90_and_f77="no"
576fi])
577# Perform the requested action based on whether the test succeeded
578if test "$pac_cv_f90_and_f77" = yes ; then
579    ifelse($1,,:,[$1])
580else
581    ifelse($2,,:,[$2])
582fi
583])
584dnl /*D
585dnl PAC_PROG_F90_HAS_POINTER - Determine if Fortran allows pointer type
586dnl
587dnl Synopsis:
588dnl   PAC_PROG_F90_HAS_POINTER(action-if-true,action-if-false)
589dnl D*/
590AC_DEFUN([PAC_PROG_F90_HAS_POINTER],[
591AC_CACHE_CHECK([whether Fortran 90 has Cray-style pointer declaration],
592pac_cv_prog_f90_has_pointer,[
593AC_LANG_SAVE
594PAC_LANG_FORTRAN90
595AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[
596        integer M
597        pointer (MPTR,M)
598        data MPTR/0/
599])],
600    pac_cv_prog_f90_has_pointer="yes",
601    pac_cv_prog_f90_has_pointer="no")
602AC_LANG_RESTORE
603])
604if test "$pac_cv_prog_f90_has_pointer" = "yes" ; then
605    ifelse([$1],,:,[$1])
606else
607    ifelse([$2],,:,[$2])
608fi
609])
610dnl/*D
611dnl PAC_F90_CHECK_COMPILER_OPTION - Check that a F90 compiler option is
612dnl accepted without warning messages
613dnl
614dnl Synopsis:
615dnl PAC_F90_CHECK_COMPILER_OPTION(optionname,action-if-ok,action-if-fail)
616dnl
617dnl Output Effects:
618dnl
619dnl If no actions are specified, a working value is added to 'F90OPTIONS'
620dnl
621dnl Notes:
622dnl This is now careful to check that the output is different, since
623dnl some compilers are noisy.
624dnl
625dnl We are extra careful to prototype the functions in case compiler options
626dnl that complain about poor code are in effect.
627dnl
628dnl Because this is a long script, we have ensured that you can pass a
629dnl variable containing the option name as the first argument.
630dnl D*/
631AC_DEFUN([PAC_F90_CHECK_COMPILER_OPTION],[
632AC_MSG_CHECKING([whether Fortran 90 compiler accepts option $1])
633ac_result="no"
634save_F90FLAGS="$F90FLAGS"
635F90FLAGS="$1 $F90FLAGS"
636rm -f conftest.out
637cat >conftest2.$pac_cv_f90_ext <<EOF
638        subroutine try()
639        end
640EOF
641cat >conftest.$pac_cv_f90_ext <<EOF
642        program main
643        end
644EOF
645dnl It is important to use the AC_TRY_EVAL in case F90 is not a single word
646dnl but is something like "f90 -64" (where the switch has changed the
647dnl compiler)
648ac_fscompilelink='${F90-f90} $save_F90FLAGS -o conftest conftest.$pac_cv_f90_ext $LDFLAGS >conftest.bas 2>&1'
649ac_fscompilelink2='${F90-f90} $F90FLAGS -o conftest conftest.$pac_cv_f90_ext $LDFLAGS >conftest.out 2>&1'
650if AC_TRY_EVAL(ac_fscompilelink) && test -x conftest ; then
651   if AC_TRY_EVAL(ac_fscompilelink2) && test -x conftest ; then
652      if diff -b conftest.out conftest.bas >/dev/null 2>&1 ; then
653         AC_MSG_RESULT(yes)
654         AC_MSG_CHECKING([whether routines compiled with $1 can be linked with ones compiled without $1])       
655         rm -f conftest2.out
656         rm -f conftest.bas
657         ac_fscompile3='${F90-f90} -c $save_F90FLAGS conftest2.$pac_cv_f90_ext >conftest2.out 2>&1'
658         ac_fscompilelink4='${F90-f90} $F90FLAGS -o conftest conftest2.o conftest.$pac_cv_f90_ext $LDFLAGS >conftest.bas 2>&1'
659         if AC_TRY_EVAL(ac_fscompile3) && test -s conftest2.o ; then
660            if AC_TRY_EVAL(ac_fscompilelink4) && test -x conftest ; then
661               if diff -b conftest.out conftest.bas >/dev/null 2>&1 ; then
662                  ac_result="yes"
663               else
664                  echo "configure: Compiler output differed in two cases" >&AC_FD_CC
665                  diff -b conftest.out conftest.bas >&AC_FD_CC
666               fi
667            else
668               echo "configure: failed program was:" >&AC_FD_CC
669               cat conftest.$pac_cv_f90_ext >&AC_FD_CC
670            fi
671          else
672            echo "configure: failed program was:" >&AC_FD_CC
673            cat conftest2.$pac_cv_f90_ext >&AC_FD_CC
674          fi
675      else
676        # diff
677        echo "configure: Compiler output differed in two cases" >&AC_FD_CC
678        diff -b conftest.out conftest.bas >&AC_FD_CC
679      fi
680   else
681      # try_eval(fscompilelink2)
682      echo "configure: failed program was:" >&AC_FD_CC
683      cat conftest.$pac_cv_f90_ext >&AC_FD_CC
684   fi
685   if test "$ac_result" != "yes" -a -s conftest.out ; then
686        cat conftest.out >&AC_FD_CC
687   fi
688else
689    # Could not compile without the option!
690    echo "configure: Could not compile program" >&AC_FD_CC
691    cat conftest.$pac_cv_f90_ext >&AC_FD_CC
692    cat conftest.bas >&AC_FD_CC
693fi
694# Restore F90FLAGS before 2nd/3rd argument commands are executed,
695# as 2nd/3rd argument command could be modifying F90FLAGS.
696F90FLAGS="$save_F90FLAGS"
697if test "$ac_result" = "yes" ; then
698     AC_MSG_RESULT(yes)   
699     ifelse($2,,F90OPTIONS="$F90OPTIONS $1",$2)
700else
701     AC_MSG_RESULT(no)
702     $3
703fi
704rm -f conftest*
705])
Note: See TracBrowser for help on using the browser.