Elsevier Science Home
Computer Physics Communications Program Library
Full text online from Science Direct
Programs in Physics & Physical Chemistry
CPC Home

[Licence| Download | New Version Template] adls_v2_0.tar.gz(10 Kbytes)
Manuscript Title: AUTO_DERIV: tool for automatic differentiation of a Fortran code
Authors: Stamatis Stamatiadis, Stavros C Farantos
Program title: AUTO_DERIV
Catalogue identifier: ADLS_v2_0
Distribution format: tar.gz
Journal reference: Comput. Phys. Commun. 181(2010)1818
Programming language: Fortran 95 + (optionally) TR-15580 (Floating-point exception handling).
Computer: all platforms with a Fortran 95 compiler.
Operating system: Linux, Windows, MacOS.
Keywords: Automatic Differentiation, Operator Overloading, Derivatives, Fortran 95.
Classification: 4.12, 6.2.

Does the new version supersede the previous version?: Yes

Nature of problem:
The need to calculate accurate derivatives of a multivariate function frequently arises in computational physics and chemistry. The most versatile approach to evaluate them by a computer, automatically and to machine precision, is via user-defined types and operator overloading. AUTO_DERIV is a Fortran 95 implementation of them, designed to evaluate the first and second derivatives of a function of many variables.

Solution method:
The mathematical rules for differentiation of sums, products, quotients, elementary functions in conjunction with the chain rule for compound functions are applied. The function should be expressed as one or more Fortran 77/90/95 procedures. A new type of variables is defined and the overloading mechanism of functions and operators provided by the Fortran 95 language is extensively used to implement the differentiation rules.

Reasons for new version:
The new version supports Fortran 95, handles properly the floating-point exceptions, and is faster due to internal reorganization. All discovered bugs are fixed.

Summary of revisions:
  • The code was rewritten extensively to benefit from features introduced in Fortran 95. Additionally, there was a major internal reorganization of the code, resulting in faster execution. The user interface described in the original paper was not changed. The values that the user must or should specify before compilation (essentially, the number of independent variables) were moved into ad_types module.
  • There were many minor bug fixes. One important bug was found and fixed; the code did not handle correctly the overloading of ** in a**λ when a = 0.
  • The case of division by zero and the discontinuity of the function at the requested point are indicated by standard ieee exceptions (IEEE_DIVIDE_BY_ZERO and IEEE_INVALID respectively). If the compiler does not support IEEE exceptions, a module with the appropriate name is provided, immitating the behaviour of the 'standard' module in the sense that it raises the corresponding exceptions. It is up to the compiler (through certain flags probably) to detect them.

None imposed by the program. There are certain limitations that may appear mostly due to the specific implementation chosen in the user code. They can always be overcome by recoding parts of the routines developed by the user or by modifying AUTO_DERIV according to specific instructions given in [1]. The common restrictions of available memory and the capabilities of the compiler are the same as the original version.

Additional comments:
The program has been tested using the following compilers: Intel ifort, GNU gfortran, NAGWare f95, g95.)

Running time:
The typical running time for the program depends on the compiler and the complexity of the differentiated function. A rough estimate is that AUTO_DERIV is ten times slower than the evaluation of the analytical ('by hand') function value and derivatives (if they are available).

[1] S. Stamatiadis, R. Prosmiti, S.C. Farantos, AUTO_DERIV: tool for automatic differentiation of a Fortran code. Comp. Phys. Commun 127(2000)343