Geoscience Reference
In-Depth Information
of arbitrary Fortran constructs. A Fortran program template can be translated into
a regular Fortran program guided by values for the parameters. The Parametric
Fortran compiler is written in Haskell ( Peyton Jones 2003 ), and the parameter values
are represented as Haskell values so they can be used by the Parametric Fortran
compiler directly. Parametric Fortran is particularly useful in scientific computing.
The applications include defining generic functions, removing duplicated code, and
automatic differentiation. Parametric Fortran thus has broader and more general
uses than previous tools in the likes of TAMC ( Giering and Kaminski 1998 ),
TAPENADE ( Hascoet and Pascual 2004 ) or ADIFOR ( Bischof et al. 1992 ),
developed just for the purpose of automatic differentiation. The differentiation is
based on the chain rule, with special treatment for non-differentiable functions.
15.3.3
How PFC Works for TL and Adjoint Generation
The Parametric Fortran compiler is publicly available from http://web.engr.
oregonstate.edu/ erwig/pf/ . It is a command line program in which the
differentiation operation has been parameterized by “Diff”. Assuming it has been
installed on a user's computer, it can be used to generate tangent linear and adjoint
of Fortran subroutines or programs in the following manner:
1. The user creates a parameter text file, say “param file”, in the format:
Diff D TL [var1, var2, var3
]
where var1, var2, var3 ..., form a list of all active variables and all
variables that depend or operate on active variables (including temporary
variables), “TL” will indicate to the compiler that the tangent linear model
is being created, and “Diff” is the differentiation parameter for Parametric
Fortran.
2. For a subroutine “test.f” to be differentiated the user also creates a file
“test.pf” that contains the subroutine in the form
f Diff:
Subroutine test(var1,var2...)
Body of subroutine
end
g
3. Finally, the compiler is invoked by typing the following from the command
line: pfc -p param file test.pf test TL.f
The output of the compiler will be the tangent linearized subroutine
“test TL.f”.
4. The procedure for generating the adjoint is the same except that in steps
1 and 3 “TL” is replaced with “AD”.
:::
 
Search WWH ::




Custom Search