GNU versus Intel/PGI OpenMP inconsistency

Steve Kargl sgk@troutmask.apl.washington.edu
Fri Sep 27 17:52:00 GMT 2019


On Fri, Sep 27, 2019 at 07:33:32PM +0200, Toon Moene wrote:
> On 9/27/19 6:19 PM, Dominikus Heinzeller - NOAA Affiliate via fortran wrote:
> 
> > program openmp_gnu
> > 
> >     use omp_lib
> > 
> >     implicit none
> >     integer :: X, Z
> >     integer :: i, N
> > 
> >     X = 1
> >     Z = 0
> >     N = 10
> > 
> >     associate( Y => X )
> > 
> > #ifdef __GFORTRAN__
> > !$OMP parallel do default(none) shared(N) private(i,Z)
> > #else
> > !$OMP parallel do default(none) shared(N,Y) private(i,Z)
> > #endif
> >        do i=1,N
> >           Z = Z + Y
> >        enddo
> > 
> >     end associate
> > 
> > end program openmp_gnu
> 
> I have no problem compiling this source code without the ifdef part, 
> i.e. with the single line:
> 
> !$OMP parallel do default(none) shared(N,Y) private(i,Z)
> 
> using gfortran 9.2:
> 
> toon@moene:~/src$ gfortran -v -c h.F90

You forgot the -fopenmp option.

% gfcx -c -fopenmp a.f90
a.f90:15:41:

   15 | !$OMP parallel do default(none) shared(N,Y) private(i,Z)
      |                                         1
Error: ASSOCIATE name 'y' in SHARED clause at (1)

This untested patch allows the code to compile (watch for
cut-n-paste tab corruption).

Index: gcc/fortran/openmp.c
===================================================================
--- gcc/fortran/openmp.c        (revision 276157)
+++ gcc/fortran/openmp.c        (working copy)
@@ -4360,7 +4360,8 @@ resolve_omp_clauses (gfc_code *code, gfc_omp_clauses *
                if (n->sym->attr.cray_pointee)
                  gfc_error ("Cray pointee %qs in SHARED clause at %L",
                            n->sym->name, &n->where);
-               if (n->sym->attr.associate_var)
+               if (n->sym->attr.associate_var
+                   && n->sym->assoc && !n->sym->assoc->variable)
                  gfc_error ("ASSOCIATE name %qs in SHARED clause at %L",
                             n->sym->name, &n->where);
              }


-- 
Steve



More information about the Fortran mailing list