This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: no warning for undeclared threadprivate variable


On Thu, Jul 14, 2011 at 08:14:49PM -0700, Andrew Benson wrote:
> Working on some OpenMP code I was surprised to find that the following doesn't 
> emit any warning or error:
> 
> module OMP_Test
> 
>   double precision :: myVar
>   !$omp threadprivate(notMyVar)
>   
> end module OMP_Test
> 
> 
> I'm compiling this using:
> 
> gfortran -c ompTest.F90 -fopenmp -Wall
> 
> with:
> 
> gcc version 4.6.0 20110530 (Red Hat 4.6.0-9) (GCC)
> 
> Reading from the OpenMP standard: " A variable can only appear in a 
> threadprivate directive in the scope in which it is declared. It must not be 
> an element of a common block or appear in an EQUIVALENCE statement." 
> 
> I would have guessed that this would make the above invalid code, since 
> "notMyVar" isn't declared in the scope of the threadprivate directive (or 
> anywhere else for that matter). Could be I'm missing the meaning of the OpenMP 
> standard of course.

Maybe.  notMyVar has the implicit type of INTEGER.  Whether this
counts as being declared according to the OpenMP standard I do not
know.  

> A warning or error would be very useful - I had a typo in a threadprivate 
> declaration which resulted in my code crashing (since the variable I'd 
> intended to be threadprivate, wasn't).

See any book on Fortran that describes the IMPLICT NONE statement.

laptop:kargl[218] cat k.f90
module OMP_Test
  implicit none
  double precision :: myVar
  !$omp threadprivate(notMyVar)
end module OMP_Test
laptop:kargl[219] gfc4x -c -fopenmp k.f90
k.f90:4.30:

  !$omp threadprivate(notMyVar)
                              1
Error: Symbol 'notmyvar' at (1) has no IMPLICIT type


-- 
Steve


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]