Next: Special Features
Up: Interfacing your NLP to
Previous: The C Interface
Contents
The Fortran interface is essentially a wrapper of the C interface
discussed in Section 3.4. The way to hook up IPOPT in a Fortran program is very similar to how it is done for the C
interface, and the functions of the Fortran interface correspond
one-to-one to the those of the C and C++ interface, including their
arguments. You can find an implementation of the example problem
(4)-(7) in $IPOPTDIR/Ipopt/examples/hs071_f.
The only special things to consider are:
- The return value of the function IPCREATE is of an INTEGER type that must be large enough to capture a pointer
on the particular machine. This means, that you have to declare
the ``handle'' for the IpoptProblem as INTEGER*8 if your
program is compiled in 64-bit mode. All other INTEGER-type
variables must be of the regular type.
- For the call of IPSOLVE (which is the function that is to
be called to run IPOPT), all arrays, including those for the dual
variables, must be given (in contrast to the C interface). The
return value IERR of this function indicates the outcome of
the optimization (see the include file IpReturnCodes.inc in
the IPOPT include directory).
- The return IERR value of the remaining functions has to be
set to zero, unless there was a problem during execution of the
function call.
- The callback functions (EV_* in the example) include the
arguments IDAT and DAT, which are INTEGER and DOUBLE PRECISION arrays that are passed unmodified between the
main program calling IPSOLVE and the evaluation subroutines
EV_* (similarly to UserDataPtr arguments in the C
interface). These arrays can be used to pass ``private'' data
between the main program and the user-provided Fortran subroutines.
The last argument of the EV_* subroutines, IERR, is to
be set to 0 by the user on return, unless there was a problem
during the evaluation of the optimization problem
function/derivative for the given point X (then it should
return a non-zero value).
Next: Special Features
Up: Interfacing your NLP to
Previous: The C Interface
Contents
Andreas Waechter
2008-04-25