This file documents the changes we made to adolc-1.10.1 in order to combine it
with revolve.

a) All the files which we needed from adolc were concatenated into two files,
adolc.h and adolc.cpp and then heavily modified. Anything that was C was made
into C++. Some global variables were renamed by appending two underscores in
order to avoid name clashes. When I made a change to something, I usually
placed my initials, 'EGK', in a comment nearby. The files that make up adolc.h
(in this order) are:

common.h
taputil.h
adouble.h
avector.h

The files that make up adolc.cpp (in this order) are:

malloc.h
taputil_p.h
tayutil_p.h
oplate.h
adalloc.h
taputil.c
tayutil.c
adouble.cpp
avector.cpp
taputilc.cpp
adalloc.c
malloc.c
fo_rev.c


b) Disabled writing to disk as a result of insufficient memory. This was
achieved by commenting out some lines of several functions. Thus if the
tracing runs out of memory, the program will probably crash and you will
either need to modify the buffer size in the file usrparms.h or restructure
the objective function to have smaller timesteps. The reason I disabled
writing to disk is because I never had any use for it so checking for buffer
overflow at every operation seemed overkill.

c) Immediate reverse following a tracing is always assumed. Hence we commented
out the line 'if (revalso)' which appears many times in the files adouble.cpp
and avector.cpp

d) Whenever possible functions and global variables were made static.

e) By combining all the files into a single one we could exploit the
compiler's inter-procedural optimization capabilities (hopefully). Therefore
some of the really small functions in the file taputil.c or tayutil.c were
explicitely declared inline, though a good compiler shouldn't need the hint.

In addition many of the arithmetic operations in the file adouble.h were made
*partially* inline. In the current version of adolc almost none of these
functions are inline. This is problematic for checkpointing since when we are
doing a forward sweep without tracing turned on then we would prefer to avoid
all these function calls. However to make these functions *entirely* inline
would probably result in too much code bloat (though I haven't verified this
experimentally). Therefore I rewrote some of these functions in such a way
that only the parts of these functions that are called when tracing is off are
inlined. The parts that are needed when tracing is turned on are in a
separatly compiled function which is not inlined.  For example, this is how I
rewrote the function badouble::operator+=

inline badouble& badouble::operator += ( double coval ) 
{ if (trace_flag) 
  { 
     return operator_plus_equal(coval);
  } 

   store[location] += coval;
   return *this; 

}

Thus we first check if tracing is being performed and if not we simply modify
the 'store' array and return. Since this function is small, the compiler
shouldn't have trouble inlining it. If we are tracing then we call
'operator_plus_equal', which is a new function I've added to the badouble
class which handles all the tracing. The 'operator_plus_equal' function, which
is non-inlined and seperately compiled is:

badouble& badouble::operator_plus_equal ( double coval ) 
{// if (trace_flag)
  { // old: write_d_same_arg(eq_plus_d,location,coval);
    put_op(eq_plus_d);
    put_locint(location); // = res
    put_val(coval);       // = coval

    ++vs_ptr;
    //if (revalso) 
      write_scaylor(store[location]);
  }

  store[location] += coval;
  return *this; 
} 

Notice that I've commented out the line 'if (trace_flag)' since we already
checked for this. Also, as mentioned above, I commented out 'if (revalso)'
since we always assume an immediate reverse sweep.

Note: I haven't rewrote all the arithmetic functions this way, just the ones I
used most often.

f) malloc. In the functions start_trace and taylor_begin, malloc is called to
allocated memory for the various buffers. Since these two functions are called
at every time step, constantly freeing and allocating memory is
wastefull. Therefore I modified these functions to only call malloc once. I
did this by introducing a global bool variable called 'first_time' which is
initially true and then set to false after the first allocation. If for some
reason you need to reallocate memory again, then I suppose you can reset
first_time back to true (the variable has external linkage).



