  Nonthermal loop-top sources in solar flares are the most prominent
observational signature that suggests energy release and particle acceleration
in the solar corona. Although several scenarios for particle acceleration have
been proposed, the origin of the loop-top sources remains unclear. Here we
present a model that combines a large-scale magnetohydrodynamic simulation of a
two-ribbon flare with a particle acceleration and transport model for
investigating electron acceleration by a fast-mode termination shock at the
looptop. Our model provides spatially resolved electron distribution that
evolves in response to the dynamic flare geometry. We find a concave-downward
magnetic structure located below the flare termination shock, induced by the
fast reconnection downflows. It acts as a magnetic trap to confine the
electrons at the looptop for an extended period of time. The electrons are
energized significantly as they cross the shock front, and eventually build up
a power-law energy spectrum extending to hundreds of keV. We suggest that this
particle acceleration and transport scenario driven by a flare termination
shock is a viable interpretation for the observed nonthermal loop-top sources.
