Hi all,
I just started using OpenMP for my fortran codes. I have to do some calculation with arrays and want to make the code parallel. Here is a simple example. Suppose I want to calculate the interaction energy of Natom atoms which I have already grouped them in pairs: pair(1--->Npair). In a serial code I would do like following:
-----------------------------
do n=1,npair
i=atom1(n)
j=atom2(n)
energ(i)=energ(i)+some_function
energ(j)=energ(j)+some_function
end do
---------------------------
My problem when make this code parallel is to know whether to have variable energ shared or reduction? When make it reduction I get bus error. When make it shared the results are not consistent even I put the step of energy calculation in Critical block.
Please give me some hint if you can. Thanks,
Lam
