FORTRAN Interface

The Callable Library can be interfaced with FORTRAN applications. You can download examples of a FORTRAN application from the ILOG web site at http://www.ilog.com/products/cplex. Choose Tech Support; then choose Callable Library Examples. The examples were compiled on a Sun Solaris operating system. Since C-to-FORTRAN interfaces vary across platforms (operating system, hardware, compilers, etc.), you may need to modify the examples for your particular system.

Whether you need intermediate "glue" routines for the interface depends on your operating system. As a first step in building such an interface, we advise you to study your system documentation about C-to-FORTRAN interfaces. In that context, this section lists a few considerations particular to ILOG CPLEX in building a FORTRAN interface.

Case-Sensitivity

As you know, FORTRAN is a case-insensitive language, whereas routines in the ILOG CPLEX Callable Library have names with mixed case. Most FORTRAN compilers have an option, such as the option -U on UNIX systems, that treats symbols in a case-sensitive way. We recommend that you use this option in any file that calls ILOG CPLEX Callable Library routines.

On some operating systems, such as DEC Alpha running Digital Unix, certain intrinsic FORTRAN functions must be in all upper case (that is, capital letters) for the compiler to accept those functions.

Underscore

On some systems, all FORTRAN external symbols are created with an underscore character (that is, _) added to the end of the symbol name. Some systems have an option to turn off this feature; for example, on DEC Alpha running Digital Unix, the option -assume nounderscore turns off the postpended underscore. If you are able to turn off those postpended underscores, you may not need other "glue" routines.

Six-Character Identifiers

FORTRAN 77 allows identifiers that are unique only up to six characters. However, in practice, most FORTRAN compilers allow you to exceed this limit. Since routines in the Callable Library have names greater than six characters, you need to verify whether your FORTRAN compiler enforces this limit or allows longer identifiers.

Call by Reference

By default, FORTRAN passes arguments by reference; that is, the address of a variable is passed to a routine, not its value. In contrast, many routines of the Callable Library require arguments passed by value. To accommodate those routines, most FORTRAN compilers have the VMS FORTRAN extension %VAL(). This operator used in calls to external functions or subroutines causes its argument to be passed by value (rather than by the default FORTRAN convention of passed by reference). For example, with that extension, you can call the routine CPXprimopt() with this FORTRAN statement:

status = CPXprimopt (%val(env), %val(lp))

Pointers

Certain ILOG CPLEX routines return a pointer to memory. In FORTRAN 77, such a pointer cannot be dereferenced; however, you can store its value in an appropriate integer type, and you can then pass it to other ILOG CPLEX routines. On most operating systems, the default integer type of four bytes is sufficient to hold pointer variables. On some systems, such as DEC Alpha, a variable of type INTEGER*8 may be needed. Consult your system documentation to determine the appropriate integer type to hold variables that are C pointers.

Strings

When you pass strings to routines of the Callable Library, they expect C strings; that is, strings terminated by an ASCII NULL character, denoted \0 in C. Consequently, when you pass a FORTRAN string, you must add a terminating NULL character; you do so by means of the FORTRAN intrinsic function CHAR(0).


Previous Page: Portability  Return to Top Next Page: C++ Interface