Code for dealing with PV inversion in terrain-following coordinates