Draft Writeup of June 11, 2000
LOADING AMPL SHARED LIBRARIES
When AMPL starts to run, it looks for two shared or dynamic link libraries, ampltabl.dll and amplfunc.dll, from which it tries to import functions and table handlers. We describe here the rules that AMPL follows in looking for each of these libraries. We then introduce new load, unload, and reload commands that can be used to explicitly change the available imported functions and table handlers during an AMPL session.
The ampl/solvers/funclink directory in netlib provides examples and makefiles for creating suitable shared libraries and linking them to solvers under various systems. For a further introduction, see the README file in the funclink directory.
Loading rules for ampltabl.dll
The ampltabl.dll library is intended for installation-standard or vendor-provided table handlers and (less commonly) imported functions. Thus AMPL uses your system's standard search rules to look for ampltabl.dll.
On most systems, the default search rules can be modified by the installation and can be affected by how AMPL was linked. On many systems, the search rules for ampltabl.dll can also be affected by the setting of an environment variable that specifies a list of directories, separated by semicolons on Microsoft systems and by colons on most other systems. Except where noted otherwise, the current directory is generally excluded unless it appears in the directory list in relevant environment variable.
Below is a summary of the library search rules for ampltabl.dll on some popular systems.
Loading rules for amplfunc.dll
The amplfunc.dll library is intended for functions and (less commonly) special table handers that you yourself provide. Thus AMPL looks for amplfunc.dll only in the invocation directory -- the directory (or folder) in which AMPL starts to run.
AMPL's -i command-line option and AMPLFUNC environment variable provide ways to change the name "amplfunc.dll" to something else and to determine the directory in which it is sought. Invoking AMPL from the command line with
ampl -i-tells AMPL not to look for amplfunc.dll at all;
ampl -i dirnametells AMPL to look in directory dirname for amplfunc.dll;
ampl -i filenametells AMPL initially to import functions and table handlers from file filename rather than amplfunc.dll; and
ampl -i?tells AMPL to summarize the current -i command-line options. If no -i command-line option appears but environment variable AMPLFUNC is set to a nonempty value, AMPL behaves as though it had been invoked by
ampl -i "$AMPLFUNC"AMPL also accepts other command-line options and reads files specified on its command line. File names must appear after command-line options; where -i appears among them does not matter. (For a summary of other currently available command-line options, invoke ampl -?.)
Explicit library loading and unloading
The load, unload, and reload commands permit changing the available imported functions and table handlers during an AMPL session. These commands have the forms
load [ libname [, libname . . . ] ];in which libname is the name of a library file (in one of the usual forms for filenames, possibly a full pathname). Naturally, load causes the contents of any specified libraries to be loaded and made available to AMPL, while unload causes the contents of specified libraries to be unloaded and hence to become unavailable to AMPL thereafter. The reload command first unloads its arguments, then loads them. This can change the order of loaded libraries and affect the visibility of imported functions: if a function appears in more than one library, the one in the first library loaded is used.
With no libname arguments, "load;" loads all the libraries currently in $AMPLFUNC; "unload;" unloads all currently loaded libraries, and "reload;" reloads them, which might be useful if some have been recompiled. On the other hand, the "reset;" command does not cause libraries to be unloaded or reloaded.
When libnames are mentioned in the load and unload commands, option AMPLFUNC is modified to reflect the full pathnames of the currently loaded libraries. Several automatically updated system sets provide further information about the currently loaded libraries:
Names that appear in _AVAILFUNCS must be declared before they can appear in declarations or commands. With the help of _AVAILFUNC2 you can see which library is currently supplying an available imported function._LIBS currently loaded libraries _AVAILFUNCS currently available imported functions _AVAILFUNC2 (available function, library) pairs _SFUNCS imported functions that "solve;" currently uses
Comments or questions?
Write to email@example.com or use our comment form.
LAST MODIFIED 2 OCTOBER 2002 BY 4er.