Fix logic error in subgrid location inversion.