Node:Fortran 77 Compiler, Previous:C++ Compiler, Up:Compilers and Preprocessors
AC_PROG_F77 ([compiler-search-list]) | Macro |
Determine a Fortran 77 compiler to use. If F77 is not already
set in the environment, then check for g77 and f77 , and
then some other names. Set the output variable F77 to the name
of the compiler found.
This macro may, however, be invoked with an optional first argument
which, if specified, must be a space separated list of Fortran 77
compilers to search for. This just gives the user an opportunity to
specify an alternative search list for the Fortran 77 compiler. For
example, if you didn't like the default order, then you could invoke
AC_PROG_F77(fl32 f77 fort77 xlf cf77 g77 f90 xlf90) If using |
AC_PROG_F77_C_O | Macro |
Test if the Fortran 77 compiler accepts the options -c and
-o simultaneously, and define F77_NO_MINUS_C_MINUS_O if it
does not.
|
The following macros check for Fortran 77 compiler characteristics. To
check for characteristics not listed here, use AC_TRY_COMPILE
(see Examining Syntax) or AC_TRY_RUN
(see Run Time),
making sure to first set the current language to Fortran 77
AC_LANG(Fortran 77)
(see Language Choice).
AC_F77_LIBRARY_LDFLAGS | Macro |
Determine the linker flags (e.g. -L and -l ) for the
Fortran 77 intrinsic and run-time libraries that are required to
successfully link a Fortran 77 program or shared library. The output
variable FLIBS is set to these flags.
This macro is intended to be used in those situations when it is necessary to mix, e.g. C++ and Fortran 77 source code into a single program or shared library (see Mixing Fortran 77 With C and C++). For example, if object files from a C++ and Fortran 77 compiler must be linked together, then the C++ compiler/linker must be used for linking (since special C++-ish things need to happen at link time like calling global constructors, instantiating templates, enabling exception support, etc.). However, the Fortran 77 intrinsic and run-time libraries must be linked
in as well, but the C++ compiler/linker doesn't know by default how to
add these Fortran 77 libraries. Hence, the macro
The macro |
AC_F77_DUMMY_MAIN ([action-if-found], [action-if-not-found]) | Macro |
With many compilers, the Fortran libraries detected by
AC_F77_LIBRARY_LDFLAGS provide their own main entry
function that initializes things like Fortran I/O, and which then calls
a user-provided entry function named e.g. MAIN__ to run the
user's program. The AC_F77_DUMMY_MAIN or AC_F77_MAIN
macro figures out how to deal with this interaction.
When using Fortran for purely numerical functions (no I/O, etcetera),
users often prefer to provide their own By default, action-if-found defines In order to link with Fortran routines, the user's C/C++ program should
then include the following code to define the dummy main if it is
needed:
#ifdef F77_DUMMY_MAIN # ifdef __cplusplus extern "C" # endif int F77_DUMMY_MAIN() { return 1; } #endif Note that |
AC_F77_MAIN | Macro |
As discussed above for AC_F77_DUMMY_MAIN , many Fortran libraries
allow you to provide an entry point called e.g. MAIN__ instead of
the usual main , which is then called by a main function in
the Fortran libraries that initializes things like Fortran I/O. The
AC_F77_MAIN macro detects whether it is possible to
utilize such an alternate main function, and defines F77_MAIN to
the name of the function. (If no alternate main function name is found,
F77_MAIN is simply defined to main .)
Thus, when calling Fortran routines from C that perform things like I/O,
one should use this macro and name the "main" function |
AC_F77_WRAPPERS | Macro |
Defines C macros F77_FUNC(name,NAME) and
F77_FUNC_(name,NAME) to properly mangle the names of C/C++
identifiers, and identifiers with underscores, respectively, so that
they match the name-mangling scheme used by the Fortran 77 compiler.
Fortran 77 is case-insensitive, and in order to achieve this the Fortran
77 compiler converts all identifiers into a canonical case and format.
To call a Fortran 77 subroutine from C or to write a C function that is
callable from Fortran 77, the C program must explicitly use identifiers
in the format expected by the Fortran 77 compiler. In order to do this,
one simply wraps all C identifiers in one of the macros provided by
subroutine foobar(x,y) double precision x, y y = 3.14159 * x return end You would then declare its prototype in C or C++ as:
#define FOOBAR_F77 F77_FUNC(foobar,FOOBAR) #ifdef __cplusplus extern "C" /* prevent C++ name mangling */ #endif void FOOBAR_F77(double *x, double *y); Note that we pass both the lowercase and uppercase versions of the
function name to Although Autoconf tries to be intelligent about detecting the
name-mangling scheme of the Fortran 77 compiler, there may be Fortran 77
compilers that it doesn't support yet. In this case, the above code
will generate a compile-time error, but some other behavior
(e.g. disabling Fortran-related features) can be induced by checking
whether the Now, to call that routine from a C program, we would do something like:
{ double x = 2.7183, y; FOOBAR_F77(&x, &y); } If the Fortran 77 identifier contains an underscore
(e.g. |
AC_F77_FUNC (name, [shellvar]) | Macro |
Given an identifier name, set the shell variable shellvar to
hold the mangled version name according to the rules of the
Fortran 77 linker (see also AC_F77_WRAPPERS ). shellvar is
optional; if it is not supplied, the shell variable will be simply
name. The purpose of this macro is to give the caller a way to
access the name-mangling information other than through the C
preprocessor as above; for example, to call Fortran routines from some
language other than C/C++.
|