parially fixed bug in cpp program. Finalized griding.py