A computational method for convex optimal control problems involving linear hereditary systems