Compilation problem using OpenMP and -mp compiler option

This is my first attempt to implement parallelization in a working program. The program structure I use follows closely that of an example shown in Section 5.1.3 of the PGI User’s Guide. I’m using PGI version 18.4 Community Edition. Here is a mock-up of my code:

function MyFunction(MyArguments) result(MyResult)
(use statements)
(declarations)

if (mytest1) then ! Line A

call OMP_Set_Num_Threads(OMP_Get_Max_Threads())
!$OMP Parallel Private(La, others) Shared(L, others)
!$OMP do
do La = 1, L

end do
!$OMP end do
!$OMP end Parallel
else if (mytest2) then !Line B

end if !Line C

end function MyFunction

Compilation of this code produces 6 errors. The first two errors are “unterminated PARALLEL directive” that point first to Line B and then to Line C. The next 3 errors are “cannot branch out of parallel/teams/task region” that point to lines beyond Line C. The final error is “unterminated block if” that points to Line A.

These errors make sense if the !$OMP end parallel statement is not recognized, but I don’t know why it is not recognized. Can someone please explain this to me? Thanks.

Hi JerryAtSFS,

I don’t see anything obvious in this mocked-up version so my guess is that there’s something else in the real code that’s causing the problem.

Can you please post or send to PGI Customer Service (trs@pgroup.com) a reproducing example?

Thanks,
Mat

FYI, Jerry sent use the code. The problem was a typo where he has “!$OPM” instead of “!$OMP”.

		 !$OMP end do
		 !$OPM End Parallel

-Mat