I am working in Fortran. My purpose is to parallelize with OPENMP a program of this kind:
do t=1, t_fin (sequential)
a sequence of do loops (not sequential)
end do
where the cycle is sequential (temporal). I have tried to create threads at the beginning of each sequential cycle iteration, but this makes the code slower than it could be. Therefore, my question is if it possible to create the threads only once before starting the cycle. Practically:
!$OMP PARALLEL
!$OMP SECTIONS
!$OMP CRITICAL
do t=1, t_fin
sequence of OMP do
end do
!$OMP END CRITICAL
!$OMP END PARALLEL
I have tried in this way, but it works as if it were only one thread. I suppose this depends on the fact that there is an external critical section that includes the omp do. However, I would like to execute the internal omp do with more than one thread. Is there a way to obtain this?
omp parallel dodirective? Why do you usesections? Why do you youcriticalsections? You are aware of the fact that only a single thread is allowed in the critical section at a time, right? Your code doesn't make sense... - Alexander Vogt