I had a very enjoyable few days travelling by train between short stays in various Moroccan cities a few years ago. I concur the trains were reliable, comfortable, clean and cheap, and locals met on board very sociable, especially if you can speak a little French. One problem we had in Marrakesh was getting to the rail station. We had arrived by air so hadn't seen the station or it's surroundings before. On the morning of our departure to Fes I made it clear (I thought) to my taxi driver that I wanted the rail station (gare, chemin de fer, locomotive, train etc), yet he still left me outside the main long distance coach station, which is closer to the city centre, assuring me on checking again with him ( 'le train, chemin de fer') that it was the correct place. I read in a guide subsequently that taxi drivers may receive some kind of incentive from the private coach companies to drop tourists there rather than take them to the railway station. After discovering my mistake I had to find another taxi rather quickly to get us to the real station in time for our train. After visiting Fes and nearby Meknes we returned by train to Marrakesh to catch the railway bus out to Essaouira for a relaxing week by the seaside to finish our holiday, stopping for a night at Casablanca on the way to look at the Hassan II Mosque. Unfortunately I sprained my ankle stepping into a massive unseen hole in a poorly lit back street in Casablanca later that night and then succumbed to food poisoning. With my consequent badly swollen painful ankle and shall we say irregular bodily functions, I was thus unable to venture far from the lovely little riad we stayed in by the sea, but don't let that put anybody off!
I attach a couple of locomotive pictures taken at Marrakesh station. I'm afraid that was the limit of my railway photography for that holiday.
The highlight of the holiday was Fes, which is a really remarkable place as featured in the recent tv documentary. Despite the claim you easily get lost in the maze of the medina, there are gateways and 'main roads' and I soon got used to navigating around. The medina is much bigger than that of Marrakesh but quieter and less overtly commercial I found.