add c function generator for generic grids

also, some niceties in the way this is used in the final C file that the
interpolator writes.