High-energy solar neutrons: 1. Production in flares