CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   Main CFD Forum (http://www.cfd-online.com/Forums/main/)
-   -   How to parallelize this fortran code by openmp (http://www.cfd-online.com/Forums/main/14658-how-parallelize-fortran-code-openmp.html)

ronac January 18, 2008 22:36

How to parallelize this fortran code by openmp
 
Dear all,

I have a fortran code to calculate particle motion. there are alway many big loops. Some guy suggest me to use openmp to speed it up. the following is the pseudo code. Do I do it correctly?

c$OMP PARALLEL DO DEFAULT(SHARED), PRIVATE(i,ni,c2,ks,ke)

do i=1,ni

a(i)=c1

c2=0

ks=lfirst(i)

ke=last(i)

do k=ks,ke

c2=c2+f(k)

c3=f1+f2

................

c4=f+f3

enddo

f(i)=c2+c3

enddo

It can be seen that the loop i in the code is independent, but loop k is dependent. All calculations mainly happen in loop k which is small, up to 8. The loop i is always big, up to 200,000. I only want to use openmp for loop i. Your hints would be greatly appreciated. Cheers,ronac


All times are GMT -4. The time now is 23:49.