A Dynamic and Thermodynamic Foundation for Modeling the Moist Atmosphere with Parameterized Microphysics.