Production of deuterons and pions in a transport model of energetic heavy-ion reactions