Fix #281 in the pik branch.
Fix an unreported bug in the pik branch.

3D diagnostic quantities computed on demand did not work with automatic
vertical grid extension: saving "cts" could make PISM create an output
file with the number of z levels corresponding to the old vertical
grid (before automatic extension). This lead to a crash when a properly
"vertically extended" field was saved.

This is a cherry-pick of 50776fcb9380d8ad94db89737a6f38b68ca73314.

(Includes the fix from b102325.)