Instructions for calling MAPS from Fortran

Amy Yates



(These instructions assume use of g++, gcc, and g77. For questions about the C++ implementation of MAPS, check out the User's Manual at http://www.cs.wm.edu/~va/software/maps/manual.html)


In order to use MAPS and its associated classes, you will need to download the following file:

Place this in a directory of your choosing. Then type "tar zxvf maps.tgz" to create a directory called Maps with all of the necessary files. (If your version of tar doesn't support the z option, then type "gunzip maps.tgz" and then "tar xvf maps.tar".)  Once you have extracted the maps file, go into the Maps directory and type "make install" to extract and compile the netlib files. Under Solaris, you may have trouble compiling the libf2c directory. There are instructions in the file libf2c/makefile.u which should help.

Now you can make the C++ version of MAPS by typing "make maps". This makes one test executable called "maps", as described in the MAPS User's Manual. You can also make a FORTRAN version by typing "make fmaps". This will create the archive libmaps.a and give you a test executable called fmaps based on the file "MyMain.f".

If you have followed these instructions, you should now have four libraries in your directory: libBLAS.a, libf2c.a, libLAPACK.a, and libmaps.a.  If you choose to create files of your own in a different directory, simply copy these libraries over.

The user must provide two things to use the callable subroutines in FORTRAN:

You can call the FORTRAN subroutine whatever you like, but it must have the following signature: 

                         objf(x, f, n) 

                         double precision x(n), f 
                         integer n

where n is the dimension of the problem, x is the array of points to evaluate, and f is the function evaluation. The order of arguments is hardcoded in the C++, and must be maintained. An example of a subroutine that implements an objective function is given in the file MyMain.f, along with a main routine to call the wrappers. The objective function also shows how bounds can be constructed by heavily penalizing x values outside the bounds.

Next, you will write a FORTRAN routine to call the version of MAPS you are interested in. While this routine will serve as the main program, it must actually be considered a subroutine to interact with the C++ classes. It should be initiated with the line: 

subroutine mymain
where mymain is the hard-coded name for the subroutine.

Two ways of using MAPS are provided. The first subroutine, cmaps, is a more complicated implementation, which requires a lot of user input. The second version, emaps, can be called if the user prefers mostly default settings.  The file callmaps.f shows the subroutines and describes the input in detail. To sum up, the functions are as follows:

subroutine cmaps(obj, dim, maxf, maxi, delta, cor, search, trend, 
     c                            weight, lower, upper, start, seed, gfx, iter, 
     c                             aux)

subroutine emaps(obj, dim, maxf, maxi, lower, upper, start, seed, gfx, iter, aux) Either of these subroutines may be used to call MAPS. An example of the mymain subroutine is given in the distribution in the file MyMain.f. This file reads from standard input, but you can redirect the data file "example_f.dat" to run a test case by typing "fmaps < example_f.dat". This can be compared with the standalone C++ program by running "maps < example_cc.dat". (This program calls the standalone executable "myobj" to evaluate the objective function.)

To make compilation as simple as possible, copy all of the library files to the directory where you want to work. Write your objective function and your main subroutine and compile using:

g77 -Wall -c [*.f]
substituting whatever FORTRAN files you have created. This will give you object files. To compile with maps, simply type:
g++ -Wall -o name_me *.o -L./ -lmaps -lLAPACK -lBLAS -lf2c -lm
where name_me is the executable name you choose and *.o are the object files you created. Make sure the library files are listed exactly in this order when compiling.


STANDARD DISCLAIMER:
Permission to use, copy, modify, and distribute this software for any purpose without fee is hereby granted, provided that this entire notice is included in all copies of any software which is or includes a copy or modification of this software and in all copies of the supporting documentation for such software. THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED WARRANTY. IN PARTICULAR, THE AUTHOR OFFERS NO REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.