Reputation: 19
In a computational fluid dynamics solver I have written, I am getting a different result based on the compiler I use. When I compile this code using gfortran with the following flags:
-ffree-line-length-512 -Ofast -march=native
, I get the "correct" results. However, when I run the same code with pgfortran using the flags -fast -acc -Minfo=accel -ta=tesla:managed
, it seems like the boundaries of my domain become incorrect.
To test if this could be a compiler issue, I commented out all OpenACC directives and compiled the code using the abovementioned pgfortran and flags. I still got the same incorrect results. I then removed all flags and compiled the code only using pgfortran
with no flags. I still got the same incorrect results.
I am not sure what the issue is or even if this really is a compiler issue. However, with exactly the same code, just with different compilers I am getting considerably different results at my domain boundaries and I am not sure what to do.
Appreciate any advice and if there is any other information I can provide I would be happy to do so.
UPDATE:
I figured out what the issue was. I just want to be clear that when I was testing compiler vs. compiler I was not using any flags for either to make sure that it would not be an optimization issue or something else.
Essentially, the error came from my boundary conditions, for which I use ghost cells. In the isothermal wall boundary condition, I was computing the temperature, setting a zero gradient condition for the pressure, and then computing the density from temperature and pressure.
These boundary conditions were being set as:
T_g = 2*T_b - T_i
p_g = p_i
rho_g = gamma*p_g/T_g
where the subscripts g, b, i denote ghost, boundary, and interior cell, respectively. In a sequential manner, this produces the intended result, since p_g and T_g are set before rho_g and thus I may compute rho_g from them. I guess somehow this was not being done sequentially when running pgfortran so p_g and T_g were not set before computing density. I have no idea how this makes sense since without the -acc flag the code should just run sequentially. However, modifying the density boundary condition to be:
rho_g = gamma*p_i/T_i
fixed the issue.
Upvotes: 1
Views: 67