Caleb Yenusah
Caleb Yenusah

Reputation: 5

What does OpenMP structured-block mean in fortran?

What does openMP structured-block mean in fortran?

Using the sections construct as an example:

!$omp sections
   !$omp section 
      structured-block 
   !$omp section 
      structured-block 
   ... 
!$omp end sections

Can I have multiple commands under each section like this?

!$omp sections
  !$omp section
    command 1
    command 2
    command 3
  !$omp section
    command 4
    command 5
    command 6
  ...
!$omp end sections

Is this a correct use of the sections construct and more specifically "structured-block"?

Upvotes: 0

Views: 124

Answers (1)

Hristo Iliev
Hristo Iliev

Reputation: 74375

A "block of executable statements with a single entry at the top and a single exit at the bottom" means that you do not use goto to transfer control to a label inside the block and do not use goto to transfer control to a label outside the block.

!$omp section
  call foo()
  bar = baz
  qux = bar
!$omp section
  ...

is fine if foo() returns.

!$omp section
  bar = foo()
  if (bar == baz) then
    goto qux
  end if
!$omp section
  ...

qux: ...

is not fine.

You can have a loop inside as long as its entire body is contained in the block and you can call functions and subroutines as long as they return.

Upvotes: 1

Related Questions