0

I wrote the following program :

program my_pgm

    use omp_lib
    implicit none
        
    CALL OMP_set_dynamic(.FALSE.)
    CALL OMP_set_num_threads(2)
    
    !$OMP PARALLEL DEFAULT(SHARED)
    
    my_parallel_block : BLOCK

        integer :: my_idx
 
        DO my_idx = 0, 3
            WRITE(*,*) 'my_idx , thread_num, ',my_idx,omp_get_thread_num()
        END DO
    
    END BLOCK my_parallel_block
    
    !$OMP END PARALLEL
    
end program my_pgm

At compilation time (gfortran -fopenmp mypgm.f90), I got the following errors :

fortranblock.f90:19:31:

19 | END BLOCK my_parallel_block | 1 Error: Syntax error in END BLOCK statement at (1) fortranblock.f90:21:22:

21 | !$OMP END PARALLEL | 1 Error: Unexpected !$OMP END PARALLEL statement at (1) fortranblock.f90:23:3:

23 | end program my_pgm | 1 Error: Expecting END BLOCK statement at (1) f951: Error: Unexpected end of file in 'fortranblock.f90'

To avoid it, I need to remove the block name after END BLOCK: END BLOCK my_parallel_block => END BLOCK !my_parallel_block (! to comment if of course)

Is it specific to GNU Fortran compiler. And is it possible to keep this name with some compilation options or something else ?

4
  • 1
    Works for me with gfortran version 15.0.1 and 14.2. Commented Apr 3 at 15:57
  • Thanks a lot. I use version 13.3.1. I will test with your version. Commented Apr 3 at 16:04
  • 1
    When reporting such issues, always give the version you are using. Commented Apr 4 at 12:24
  • 2
    As noted, this is a bug in a particular version of the compiler. It's worth noting, though, that the workaround (removing the block name from the END BLOCK statement) makes the code invalid Fortran. You should also remove the block name from the BLOCK statement itself (which of course means you can't use the name for things you'd want to use a block name for). Commented Apr 4 at 16:13

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.