modified main.f90 for 3d