I have been working with a fast multipole code in Fortran. It is a black box to me, and I have been having some strangeness when compiling it on my mac. 

I am using version 11.1 of the compiler, I've got a MacBook Pro running a 2.5 GHz Intel Core 2 Duo on Snow Leopard.

The code runs fine when I set the optimization flag to -O0, but fails when I use -O2 or -O3. What is bizarre is that the code runs fine on a Linux box, at least with the default -O2 flag.

Anyone have any ideas on what could be causing the issue? It must be something with vectorization.