  The discrete gradient structure and the positive definiteness of discrete
fractional integrals or derivatives are fundamental to the numerical stability
in long-time simulation of nonlinear integro-differential models. We build up a
discrete gradient structure for a class of second-order variable-step
approximations of fractional Riemann-Liouville integral and fractional Caputo
derivative. Then certain variational energy dissipation laws at discrete levels
of the corresponding variable-step Crank-Nicolson type methods are established
for time-fractional Allen-Cahn and time-fractional Klein-Gordon type models.
They are shown to be asymptotically compatible with the associated energy laws
of the classical Allen-Cahn and Klein-Gordon equations in the associated
fractional order limits.Numerical examples together with an adaptive
time-stepping procedure are provided to demonstrate the effectiveness of our
second-order methods.
