A general method for calculating subsurface CO2 storage capacity