There is quite a bit going on before you do anything involving floats. Am I right in assuming that this is the code you're having trouble with?
phi.data = float(phi_data)*scale;
What is the value of phi_data? What float value are you expecting to derive from it?