DNAD, a Simple Tool for Automatic Differentiation of Fortran Codes Using Dual Numbers

2013 
Abstract DNAD (dual number automatic differentiation) is a simple, general-purpose tool to automatically differentiate Fortran codes written in modern Fortran (F90/ 95/2003) or legacy codes written in previous version of the Fortran language. It implements the forward mode of automatic differentiation using the arithmetic of dual numbers and the operator overloading feature of F90/ 95/2003. Very minimum changes of the source codes are needed to compute the first derivatives of Fortran programs. The advantages of DNAD in comparison to other existing similar computer codes are its programming simplicity, extensibility, and computational efficiency. Specifically, DNAD is more accurate and efficient than the popular complex-step approximation. Several examples are used to demonstrate its applications and advantages. Program summary Program title: DNAD Catalogue identifier: AEOS_v1_0 Program summary URL: http://cpc.cs.qub.ac.uk/summaries/AEOS_v1_0.html Program obtainable from: CPC Program Library, Queen’s University, Belfast, N. Ireland Licensing provisions: Standard CPC licence, http://cpc.cs.qub.ac.uk/licence/licence.html No. of lines in distributed program, including test data, etc.: 3922 No. of bytes in distributed program, including test data, etc.: 18 275 Distribution format: tar.gz Programming language: Fortran 90/95/2003. Computer: All computers with a modern FORTRAN compiler. Operating system: All platforms with a modern FORTRAN compiler. Classification: 4.12, 6.2. Nature of problem: Derivatives of outputs with respect to inputs of a Fortran code are often needed in physics, chemistry, and engineering. The author of the analysis code may no longer be available and the user may not have a deep knowledge of the code. Thus a simple tool is necessary to automatically differentiate the code with very minimum change to the source codes. This can be achieved using dual number arithmetic and operator overloading. Solution method: A new data type is defined with the first scalar component holding the function value and the second array component holding the first derivatives. All the basic operations and functions are overloaded with the new definitions according to dual number arithmetic. To differentiate an existing code, all real numbers should be replaced with this new data type and the input/output of the code should also be modified accordingly. Running time: For each additional independent variable, DNAD takes less time than the running time of the original analysis code. However, the actual running time depends on the compiler, the computer, and the operations involved in the code to be differentiated.
    • Correction
    • Source
    • Cite
    • Save
    • Machine Reading By IdeaReader
    13
    References
    44
    Citations
    NaN
    KQI
    []