next up previous contents index
Next: 6.6.2 Calling FORTRAN routines Up: 6.6 Programming in FORTRAN Previous: 6.6 Programming in FORTRAN   Contents   Index


6.6.1 Calling NEMO C routines from FORTRAN

The NEMO user interface, with limited capabilities, is also available to FORTRAN programmers. First of all, the keywords, their defaults and a help string must be made available (see Section [*]). This can be done by supplying them as comments in the FORTRAN source code, as is show in the following example listed under Table [*]


Table: $NEMO/src/kernel/fortran/test.f
\begin{table}\small\verbatimlisting{testf2c.src}
\normalsize\end{table}


The documentation section between C+ and C- can be extracted with a NEMO utility, ftoc, to the appropriate C module as follows:

    % ftoc test.f test_main.c

after which the new test_main.c file merely has to be included on the commandline during compilation. To avoid having to include FORTRAN libraries explicitly on the commandline, easiest is to use the f77 command, instead of cc:

    % f77 -o test test.f test_main.c -I$NEMOINC -L$NEMOLIB -lnemo

This only works if your operating supports mixing C and FORTRAN source code on one commandline. Otherwise try:

    % cc -c test_main.c
    % f77 -o test test.f test_main.o -L$NEMOLIB -lnemo
where the NEMO library is still needed to resolve the user interface of course.

The other alternative would be:

    % f77 -c test.f
    % cc -o test test.o test_main.c -L$NEMOLIB -lnemo \
                -lF77 -lI77 -lU77 -lm
with various possible complications with the new FORTRAN 1.3+ compiler on SUN workstations. Browsing with nm(1) through UNIX library files to find undefined reference might be the only alternative left to find out where the system has hidden them. See the FORLIBS environment variable defined in NEMORC startup file.


next up previous contents index
Next: 6.6.2 Calling FORTRAN routines Up: 6.6 Programming in FORTRAN Previous: 6.6 Programming in FORTRAN   Contents   Index
(c) Peter Teuben