Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

The basic structure of OpenMP

Anonymous21
Beginner
389 Views
I have three questions for OpenMP

- 1st question:

!$OMP PARALLEL DO
do=1, 20
:
end do
!$OMP END PARALLEL DO

----- after making f90 codeI put into the this line "export OMP_NUM_THREADS=4"
or put into "CALL OMP_SET_NUM_THREADS(4)"in f90 code. That's it..

Is it corrected or not?


- 2ndquestion:

Is it impossibe to make parellel programmingwithout do-loop?

do nz=1,nnm
!$OMP PARALLEL DO
read(1) nn
read(1) (((x(ln(i,j,k,n,nz)),i=1,img(n,nz)),j=1,jmg(n,nz)),k=1,kmg(n,nz))
read(1) (((yl(ln(i,j,k,n,nz)),i=1,img(n,nz)),j=1,jmg(n,nz)),k=1,kmg(n,nz))
!$OMP END PARALLEL DO
end do

- 3rd question:

Before do-loop,if there is if-loop, it make error message? Is it impossible?
However, if the order of directive and if-loopis exchanged,it is OK...
Is therethe othermethod?

!$OMP PARALLEL DO
if(i>= 21) then
do i=1, 20
:
end do
end if
!$OMP END PARALLEL DO
0 Kudos
1 Reply
TimP
Honored Contributor III
389 Views
There is no use for an END PARALLEL DO combination directive. OMP DO ends automatically at the closure of the DO loop. It works only with a DO loop, not even with a FOR loop. If you have OMP DO inside OMP PARALLEL, then you need OMP END PARALLEL for Fortran, unlike C where the parallel region is set off by {} (and so is not easily distinguished from non-OMP usage).
PARALLEL WORKSHARE , parallel sections, and tasks are available for appropriate usage. It wouldn't normally make sense to put a parallel region which doesn't use OMP DO inside a DO loop. WORKSHARE is over rated by some of those who advocate it.
You might do well to consult a textbook, but there are plenty of examples and tutorials on line as well. Amazingly enough, you can believe much of what you read on this topic.
0 Kudos
Reply