GP GRID code ported from MLOSS GPgrid toolkit v0.1