Originally Posted by Roowah
It's a known issue, and although there seems to be some temporary fixes to it, there really isn't a permanent solution. It was the same with my E46 as well.
The most popular way to prevent it is to run the climate control with the A/C off for a few minutes before shutting the car off. Other people have suggested spraying disinfectant into the intake vent, but I've never tried it.
This is the best way to resolve the immediate problem.
What happens is that while running the AC, moisture condenses out onto the cooling coil. (It's suppose to do that, it's how the air gets de-humidified). But if the AC is working on humid air and the coil is wet then you shut down the car, some of that moisture currently on the coil will not go down the drain and will just stay there.
Now let it sit in the heat for a while and some mold can grow. Next time you turn on the fan, A/C or heating whatever, you get that moldy gym-sock smell.
The fast way to get rid of the smell is just to kick the fan up high. I don't remember if the air from the heating core goes through the cooling coil, or if it's the other way around. If the heater is upstream, then turning on the heater would also help dry out the residual moisture.
This is a common problem down here in the south, for any kind of car. The only easy way to prevent it is to shut down the compressor (but leave the fan running), for the last 5 minutes or so you are in the car. That way the AC coil gets dried off.
I did read a DIY a while ago, about someone who had this problem often enough that he found out that the AC coil drain pan could be reached by the hump by the drivers right knee. He drilled a small hole into the drain pan and put a colored cover on the hole. When he got the smell, he unplugged it and had some deodorizer / mold-killer with a long plastic tub he could put in the hole and spray the core.