  We investigate the geometric structure of adjoint systems associated with
evolutionary partial differential equations at the fully continuous,
semi-discrete, and fully discrete levels and the relations between these
levels. We show that the adjoint system associated with an evolutionary partial
differential equation has an infinite-dimensional Hamiltonian structure, which
is useful for connecting the fully continuous, semi-discrete, and fully
discrete levels. We subsequently address the question of
discretize-then-optimize versus optimize-then-discrete for both
semi-discretization and time integration, by characterizing the commutativity
of discretize-then-optimize methods versus optimize-then-discretize methods
uniquely in terms of an adjoint-variational quadratic conservation law. For
Galerkin semi-discretizations and one-step time integration methods in
particular, we explicitly construct these commuting methods by using
structure-preserving discretization techniques.
