  Let M be an even dimensional compact Riemannian manifold with boundary and
let D be a Dirac operator acting on the sections of the Clifford module E over
M. We impose certain local elliptic boundary conditions for D obtaining a
selfadjoint extension D_F of D. For a smooth U(n)--valued function g:M -> U(n)
we establish a formula for the spectral flow along the straight line between
D_F and g^{-1} D_F g. This spectral flow is motivated by index theory: in odd
dimensions it gives the natural pairing between the K--homology class of the
operator and the K--theory class of g.
  In our situation, with dim M having the "wrong" parity, the answer can be
expressed in terms of the natural spectral flow pairing on the odd--dimensional
boundary.
  Our result generalizes a recent paper by M. Prokhorova in which the
two-dimensional case is treated. Furthermore, our paper may be seen as an
odd-dimensional analogue of a paper by D. Freed. As an application we obtain a
new proof of the cobordism invariance of the spectral flow.
