AD tools integration with NEOS

From Autodiff
Jump to: navigation, search


All parts are installed by neosotc in its home directory. We assume the following directory structure:

  • the solvers/scripts :
    from the mercurial repository clone with
    hg clone /mcs/mercurial/ad/neos_AD_solvers
  • tools and libraries used by the solvers in:

To differentiate tools and libraries for different OS/CPU/compiler combinations we use like
setenv INST_ARCH linux_i686_gnu
to name subdirectories, libraries etc. There are environment variable set up by as follows.

    os.environ['NEOS_OS'] = 'linux' # for now there are no other architectures in use 
    os.environ['NEOS_MACH'] = os.popen("uname -m").read().rstrip()
    os.environ['NEOS_COMP'] = 'gnu' # here one could distinguish different compilers

Like this string in the examples below all version numbers etc are given in green and may have to be changed in other installations.

Miscellaneous Shared Utilities

Under neos_AD_solvers/shared_lib are a number of source files to make a library of shared utility methods. It is created by running
in that directory, the INST_ARCH environment variable has to be set as specified above.



ADIC Adol-C user supplied
gradient in C
ADIFOR OpenAD driver for
partially separable input
user supplied
gradient in Fortran
NMTR Y Y Y Y Y only Adifor Y
BLMVM Y Y Y Y Y only Adifor Y


Sources for the solver are included in the neos_AD_solvers repository


The sources for the actual solver come from TAO/PETSc; see below.


The sources for the TRON solver are included in the neos_AD_solvers repository and are a copy of the TRON tar file given as version 1.2, except that we use the system installed BLAS instead of the ones bundled with the TRON sources. To build the TRON libraries one has to
setenv ARCH ${INST_ARCH}
and in neos_AD_solvers/TRON run


The sources for the lrambo solver can be obtained from the git repository via

git clone lrambo 

There is a NEOS specific branch called neos that has to be used in this context.

git checkout -b neos origin/neos 

The build and install follows the typical autotools approach (making a reference to Adol-C, see below, which must already be installed).

./configure --prefix=/home/neosotc/neos_AD_solvers_Extras/lrambo_${INST_ARCH} --with-adolc-base=/home/neosotc/neos_AD_solvers_Extras/adolc-${ADOLC_VER}_${INST_ARCH}
make install

Note, currently on newton there is an old Adol-C version installed in the system directories and some flawed logic in the configure needs to be patched like this

--- a/
+++ b/
@@ -80,10 +80,6 @@ if test "$ADOLC" != no ; then
        #first check system without extra flags
        AC_SEARCH_LIBS([fos_forward], [adolc], 
-       if test "$have_adolc" = "yes"; then 
-               ADOLC_CFLAGS=""
-               ADOLC_LDFLAGS="-ladolc"
-       else
        #check in the ADOLC_BASE
                ADOLC_CFLAGS="-I$ADOLC_BASE/include -I$ADOLC_BASE/include/adolc"
                ADOLC_LDFLAGS="-L$ADOLC_BASE/${_lib} -ladolc -Wl,-rpath -Wl,$ADOLC_BASE/${_lib}" 
@@ -97,7 +93,6 @@ if test "$ADOLC" != no ; then
-       fi

to make sure the value specified at --with-adolc-base is actually taken for the Adol-C relevant settings.

External Tools and Libraries

Below paths may be given relativ to /home/neosotc/neos_AD_solvers_Extras


The ADIC version we use is installed under /home/derivs. The exact path is specified in under

 os.environ['ADIC'] = ...

To build the NMTR sources one needs to
setenv ADIC /home/derivs/adic-1.2.0


The ADIFOR version we use is installed at /home/derivs/ADIFOR2.0E. There is no 64-bit compiled version of the ADIFOR front-end and therefore we cannot run the Fortran solver version on a 64-bit machine. Among the libraries referenced from /home/derivs/ADIFOR2.0E.lib/lib at least libSparsLinC-Linux86.a had been compiled with g77 which was last supported in the gcc 3.4.x series but refers to symbols in libg2c. Therefore this library has to be explicitly linked.


Download a versioned tar ball via Adol-C project page or clone the SVN repository using
svn checkout adolc-svn
and in the source directory configure it as follows.
setenv ADOLC_VER svn
./configure --prefix=/home/neosotc/neos_AD_solvers_Extras/adolc-${ADOLC_VER}_${INST_ARCH}
and run
make install
The path to the installation is used in Makefiles etc by way of the environment variable ADOLC_DIR which is hard coded at os.environ['ADOLC_DIR'] = ... in

Adol-C Preprocessor

Obtain the sources with
hg clone /mcs/mercurial/ad/ADOLCpp ADOLCpp_${INST_ARCH}
set the environment for make step to point to the the Adol-C installation
setenv ADOLC_DIR /home/neosotc/neos_AD_solvers_Extras/adolc-${ADOLC_VER}_${INST_ARCH}
and in the source directory cloned as ADOLCpp_${INST_ARCH} run
which makes the preprocessor and runs a sanity test. The path to the preprocessor is hard coded as ADOLCpp_DIR = ... in


Unpack the OpenAD sources into a directory
and build the sources as described on the OpenAD webpage. The path is hard coded in as os.environ['OPENADROOT'] = ....

Solver Specific


The solver uses the BLAS and LAPACK libraries for which we reference the system installation in /usr/lib. This setting can be be changed in at

os.environ['BLAS'] = ...
os.environ['LAPACK'] = ...

The solver sources are built by going to NMTR/src. Various environment variables are needed to build the sources and their values are suggested in the respective sections on this page.



Get PETSc sources, unpack it, set the environment
setenv PETSC_VER 2.3.3-p13
setenv PETSC_DIR /home/neosotc/neos_AD_solvers_Extras/petsc-${PETSC_VER}
In the source directory configure it with
config/ --with-cc=gcc --with-fc=gfortran --download-mpich=1 --with-shared --with-fortran --with-clanguage=C++ --PETSC_ARCH=${INST_ARCH}
and run
make all
The script BLMVM/script/ sets the path as os.environ["PETSC_DIR"] = ....
The PETSc installation as configured includes its own version of mpich but in any case one needs to extend the PATH to include the mpich binaries as done with the following example in the same file.
os.environ['PATH'] = os.environ['PATH']+":"+os.environ['PETSC_DIR']+"/externalpackages/mpich2-1.0.5p4/"+os.environ['PETSC_ARCH']+"/bin"


Get TAO sources, unpack it, set the environment
setenv PETSC_DIR /home/neosotc/neos_AD_solvers_Extras/petsc-${PETSC_VER}
setenv TAO_VER 1.9
setenv TAO_DIR /home/neosotc/neos_AD_solvers_Extras/tao-${TAO_VER}
and run
make all
The script BLMVM/script/ sets the path as os.environ["TAO_DIR"] = ....

Registering a Solver and Examples

The following description only applies to solvers running at MCS neos servers. Log in with the neos user id. The solver is described (per input format) as an XML file found under ~/neos_AD_solvers/<solver>/script/<scriptName>.xml To register the solver for the test server use


Otherwise replace "test" with the proper solver category. The same applies to the examples registered for a given solver (see below). At the bottom of the XML file all machines are listed on which this solver may run.
On each of these machines the NEOS solver daemon (found in ~/neos-5/SolverTools/ must be running.
Each solver has to be associated with a top level driver file. The associations are made by entries listed under DRIVER_FILE in the NEOS server configuration file found in ~/neos-5/SolverTools/ Currently this driver file is called ~/neos-5-solvers/mcs_driver_list.
Add an entry for each solver in the DRIVER_FILE.
Register the solver by running
~/neos-5/SolverTools/ ~/neos_AD_solvers/<solver>/script/<scriptName>.xml
Examples are described in a similar fashion as the solvers by XML files found under ~/neos_AD_solvers/<solver>/script/examples/<exampleName>.xml. The examples can be registered as follows.
~/neos-5/SolverTools/ ~/neos_AD_solvers/<solver>/script/examples/<exampleName>.xml <solverPassword>