Previous: Porting TCL Up: VICAR Porting Guide Next: SUBLIB Subroutine Library

Mixing Fortran and C

This section describes how to mix code written in both Fortran and C. It covers both internal code (used only within one program), and SUBLIB subroutines that must be called from either language. Section , Portability Constraints, talks about the reasons behind some of the rules listed below.

In general, a subroutine must have a separate interface for each language. A Fortran program can only call the Fortran interface, while a C program can only call the C interface. This is because the necessary calling conventions are so different. If you are writing an internal subroutine which is used only internally to your program, you may need an interface for only one language. Also, some SUBLIB routines only make sense when called from one language. However, most subroutines will have two interfaces.