Fortran code now loops over x and y internally