Statement Functions and OpenMP

Hi, I don’t know if this is the right place for this question, but here goes.

Is there any standard way of using statement functions in code parallized with OpenMP?

REAL*8  :: omega,a,b,c,d,t0,expp,pp

OMEGA(A,B,C,D) = A + B * C ** (D - 1.0d0)

ZC = 0;
!$omp parallel DEFAULT(shared) private(a,b,d,pp)
!$omp do

   something = omega(a, b, c, d);
!$omp enddo
!$omp end parallel

I couldn’t seem to move the statement functions into the parallel block, and as things are it’s telling me that a,b,d,pp can’t be private.[/quote]

Hi khea_actua1,

I think this a compiler error with our 9.0 version. I have created a technical problem report (TPR#16350) and sent if off to our engineers. I was able to recreate the error here and show that it works with 8.0 but fails with the same error in 9.0.

As a work around, you could rewrite OMEGA to be an internal function instead of a statement function.

Thanks for the report,

Hi khea_actua1,

I was wrong, this in not a compiler error. Variables appearing in the rhs of statement function definitions cannot appear in PRIVATE, FIRSTPRIVATE, and LASTPRIVATE clauses. Earlier versions of pgf90 failed to detect the error.

I have closed TPR#16350.

  • Mat

So would the only solution be making these internal functions?

-what is the technical explanation that statement function variables cannot be private. As long those variables are computed inside the paralle region, I think it should be OK.
I just wrote a small example, it compiles with older version of compiler, but not with version 9.
program sf1
real :: x,y,sf,z
!$omp parallel do default(shared) private(i,j,x,y,z)
do i=1,8
do j =1,4
write(6,*)'pab x,y,z ',x,y,z
!$omp end parallel do

Is it a big or a feature in ver 9 of compiler?


Hi bpabla,

I thought it might be ok as well, until it was pointed out the OpenMP 3.0 spec specifically disallows it. From the bottom of page 91 of

• Variables that appear in namelist statements, in variable format expressions, and in Fortran
expressions for statement function definitions, may not appear in a private clause.

khea_actua1, yes, I think you should change these to internal functions.

Hope this helps,