I’m calling a compiled C function from Fortran 90, and am getting results that don’t seem to make sense.
The function I’m calling takes in a couple integers and arrays of integers by reference and does computations based on them.
I’m finding that the C function is treating the numbers I send it differently depending on how I fill the array.
If I assign values to the array in such a manner:
do i = 1, 20
array(i) = i + 2
enddo
I get certain results, but if I assign any of the array elements explicitly as such:
array(5:5) = (/ 7 /)
I get different results from the C routine.
The numbers are the same, and the way I’m calling the C function are the same but the results are different and often more favorable.
What is even more confusing is that it doesn’t make any difference where in my code I include the explicit assignment. Even if it is only after the C function has already been called.
The C function was compiled with pgcc to avoid any possible cross compiler issues. I’ve also tried calling the function from another C program, which works without problems.
Does pgf90 treat variables differently in memory depending on how they are assigned values in code?
-vlad