Why the hell put a gun (even railgun) with range shorter than Tomahawk on a sub? Oh, and it requires surfacing. Surfaced subs are detectable by radar...
I used to be a submariner, So naturally a new railgun being applied to this weapons platform sounded fun and came quite naturally. I'm not saying its feasible, its just an entertaining thought experiment. Also, tomahawk missiles are very expensive(as opposed to the far cheaper railgun shots) and you only have a limited, small number that you can fire(as opposed to potentially hundreds of railgun shots). If you want to have a stealthy ship with long range long term firepower that can store a lot of railgun shots... well you have something to be feared. Think how many merchant ships you could sink with one submarine, and think about how much the cost of your ammunition would be compared to the value of the tonnage sunk. Honestly, it would be a weapons platform to be feared. The potential for political plausible deniability(who fired the shot!---US---> "I don't know") would be a good sell to politicians, as this would be a weapon of war they could use to gain leverage in diplomatic discussions. The submarine fleet is headed this way already with missiles (higher volume), the railgun submarine, if possible, would be a great addition to the capability of the US fleet. Also, this idea is far less crazy then the fully submersible carrier that has both been extensively designed and possibly built. lol.
@ nate
you are totally correct 
You're dismissing the heat problem for a 16 Gw gun. The gun will be hot after a shot and the submarine wil have to wait some time before stowing away the weapon less suffer from buckling problems as the heat transfer will warp the hull when exposed to the ice cold depth of the sea.
Not dismissing, just hadn't thought about heat generation. I don't know the specs on this, i'm sure its going to be a lot. I don't know much about thermodynamics aside from the basic laws, please educate me.
.
Using the external hull of the submarine would be a no no, you don't want to screw with the malleable properties of the ships metal skin via high heat. This internal compartment could be connected to the fire main system and cooled via seawater easily enough, many systems on modern submarines receive cooling this way.