I call the nested loop loop like this:
do ir = 1,Nr do iom = iom1, iom2 xyz(1) = xo(1) + xom(iom)*r xyz(2) = xo(2) + yom(iom)*r xyz(3) = xo(3) + zom(iom)*r call FUNSUB(xyz,Nprop,PropXYZ) enddo enddo
where FUNSUB evaluates the property as follows:
id = 1 do l=0,lmax do m=-l,l id = id + 1 Prop(id) = RHO * Ylm(l,m,xl(1),xl(2),xl(3)) enddo enddo
now I'm trying to parallelize it with something like a form
!$OMP parallel do reduction(+:Prop) private(ir, l, m, j, iom, r, wrad, xyz, PropOm, PropOm1, PropXYZ)
where some other private variables visible here are left outside my sample code for brevity. I'm intentionally trying to make l and m confidential, so inside FUNSUB loops FUNSUB properties are evaluated independently. However, I find that they are shared between threads. I added some debugging options and found that id constantly goes beyond Prop and found that l also about lmax , and also m is outside of (-l,l) .
my question is: how can I make sure that l and m remain private and NOT separable from the main routine? it seems that the problem is that it is a completely different routine that contains these values โโand that somehow these private variable declarations are not portable