With all due respect, IMHO your plan is wrong wrong wrong.
You want to go to Morocco? Good. You're smart enough to know that Marrakech is a primary destination. Great. IMHO, the rest of your plan is a major mistake.
Forget going to Morocco by boat. You waste time, money, and you end up in the worst possible place/experience in the country - essentially Morocco's version of Tijuana.
Fly. It's dirt cheap, fast, efficient, and easy. Low-cost airlines fly directly to Marrakech and Fes from a dozen cities across western Europe, including multiple cities in Spain. Skip the ferry ports, they are not the Morocco you are looking for.
Forget Casablanca, there's nothing much to see there (one large, modern mosque - that's it).
For travel between Marrrakech and Fes, yes, take the train. The train is good, if a bit slow (it takes most of a day). Comfy, good trains (legacy of the French). If you really have 7-9 days, then I'd suggest you do Marrakech, Fes and 1 or maybe 2 other locations. Want a beach vacation from your vacation? Head to Essouaria, a lovely seaside town on the Atlantic. Longing for the stark beauty of Morocco's rough south? Rent a car in Marrakech and drive over the High Atlas Mountains, stop in Ait Benhaddou, then continue on to one of the Grand Ergs (the great sand seas) on the edge of the deep Sahara. Stop in Todra Gorge on the way/on the way back. You could, if you want, use this trip to the south as a way to connect Marrakech and Fes. You'll be doing lots of driving (much of it across what seems like bleak, utter desolation) but IME Morocco is not difficult to drive in (outside of Marrakech and Fes...driving there is pretty nerve-wracking). Don't miss Fes - it's like no place else, a real time-travel experience. With 7-9 days you could see a lot.