My Fortran program is built as a DLL, and it calls a C function that is also built as a DLL. It is all working fine. I have now started trying to parallelize a critical loop using OpenMP. The C function no longer works correctly when it is called from an OpenMP thread (it fails with an error message that is not appropriate for the arguments supplied - the same set of arguments gives no trouble in single-thread mode). This is a sketch of what I am doing:
!$omp parallel do private(a,...)
do i = 1,n
a = ...
!$omp end parallel do
Since all the arguments of fortran_sub() are private, it is my understanding that c_function() should execute happily in separate threads. Something is going wrong, however, and I have no idea what it is. I've used OpenMP in several other programs, but never calling a C function within the loop. The C compiler is MSVS 2005, the Fortran is IVF 11.