Dear all,
I'm not sure this is the right forum to post this question since the
question deals more with OpenMP than with Fortran itself.
I am trying to ****t a program to OpenMP. The program uses some
subroutines that I wrote and some from Netlib. All programs and
subroutines are in Fortran 90 or later. The OS is Mac OS 10.5.2 and I
am using the Intel ifort compiler to with "-openmp. -reentrancy
threaded" for all programs and subroutines.
The way I was trying to parallelize the use of Netlib subroutines is
something like
do i2 = 1, N2
do i1 = 1, N1
wk(i1) = x(i1, i2)
end do
call <NetLibSubroutine>(wk, z, <other stuff>)
do i1 = 1, N1
x(i1, i2) = wk(i1)
end do
where z is an array that the subroutine uses (reads from memory) but
does not modify.
I tried placing the above snippet between OpenMP directives:
!$omp parallel do private(wk, i2, i1) shared(x, z)
<snippet>
!$omp end parallel do
At best I get NaNs at random.
I then tried making wk and z 2D arrays and changed the subroutine call
above to
call <NetLibSubroutine>(wk(1,tr), z(1,tr), <other stuff>)
where tr is the thread number. I made similar changes to the copy-in,
copy-out loops and I replicated the original array z into several
copies of wk(:,0) -one copy for each thread.
I then tried
!$omp parallel private(i1, i2, tr, istart, iend) shared(x, z, wk)
<find tr and callculate istart, iend>
do i2 = istart, iend
<snippet w/modified call>
end do
!$omp end parallel
The result is that sometimes I get an access violation, other times I
get NaNs or Infs, but most often the program hangs.
Can someone clue me on how to call external subroutines from within a
parallel construct? As I understand, the OpenMP standard states that
all variables local to subroutines and functions within a parallel
construct are private.
Thanks
Jomar


|