Wrapped the fortran code in a module. PHI is afunction now