From 3ba8730747402b4a3d54d3a7fceab4792fb3475b Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Fri, 23 May 2014 22:51:36 +0200 Subject: [PATCH] Providers check that they are not in openMP sections. --- src/variable.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/variable.py b/src/variable.py index b4b4499..84d17bf 100644 --- a/src/variable.py +++ b/src/variable.py @@ -459,6 +459,14 @@ class Variable(object): name = self.name same_as = self.same_as + def check_openmp(): + result = [ "!$ nthreads = omp_get_num_threads()" , + "!$ if (nthreads > 1) then" , + "!$ print *, irp_here//': Error: Provider in an openMP section'" , + "!$ stop 1", + "!$ endif" ] + return result + def build_alloc(name): self = variables[name] if self.dim == []: @@ -528,14 +536,18 @@ class Variable(object): result += [ "!DEC$ ATTRIBUTES FORCEINLINE :: provide_%s"%(name) ] result += [ "subroutine provide_%s"%(name) ] result += build_use( [same_as]+self.to_provide ) + result += ["!$ use omp_lib"] result.append(" implicit none") length = len("provide_%s"%(name)) result += [\ " character*(%d) :: irp_here = 'provide_%s'"%(length,name), " integer :: irp_err ", - " logical :: irp_dimensions_OK" ] + " logical :: irp_dimensions_OK", + "!$ integer :: nthreads"] if command_line.do_openmp: result.append(" call irp_lock_%s(.True.)"%(same_as)) + else: + result += check_openmp() if command_line.do_assert or command_line.do_debug: result.append(" call irp_enter(irp_here)") result += call_provides(self.to_provide)