3434# Authors R. W. Ford, A. R. Porter, S. Siso and N. Nobre, STFC Daresbury Lab
3535# A. B. G. Chalk, V. K. Atkinson, STFC Daresbury Lab
3636# J. Henrichs, Bureau of Meteorology
37- # Modified I. Kavcic, J. G. Wallwork, O. Brunt and L. Turner, Met Office
38- # S. Valat, Inria / Laboratoire Jean Kuntzmann
37+ # Modified I. Kavcic, J. G. Wallwork, O. Brunt and L. Turner, B. Went,
38+ # Met Office, S. Valat, Inria / Laboratoire Jean Kuntzmann
3939# M. Schreiber, Univ. Grenoble Alpes / Inria / Lab. Jean Kuntzmann
4040# J. Dendy, Met Office
4141
4242'''
4343This module provides the implementation of ParallelRegionTrans
4444
4545'''
46-
46+ import logging
47+ from collections .abc import Iterable
4748from abc import ABC , abstractmethod
4849from psyclone .psyir .transformations .transformation_error import (
4950 TransformationError )
5051from psyclone import psyGen
5152from psyclone .psyir .transformations .region_trans import RegionTrans
52- from psyclone .psyir .nodes import CodeBlock , Node , Return
53+ from psyclone .psyir .nodes import CodeBlock , Node , Return , RegionDirective
54+ from psyclone .psyir .symbols import DataSymbol
5355from psyclone .utils import transformation_documentation_wrapper
5456
5557
@@ -76,6 +78,35 @@ def __str__(self) -> str:
7678
7779 '''
7880
81+ def _check_symbol_table_vars (
82+ self , region_node : RegionDirective ,
83+ force_private : Iterable [str ] = ()) -> set [DataSymbol ]:
84+ '''
85+ Check that the symbol table of the provided region node contains the
86+ variable variables in the provided list. Return a set of DataSymbols.
87+
88+ This is intended to be used as part of privatising the variables
89+ contained in the list for the provided region in the child classes.
90+ '''
91+ explicitly_private_symbols = set ()
92+
93+ for symbol_name in force_private :
94+ sym = None
95+ try :
96+ sym = region_node .scope .symbol_table .lookup (
97+ symbol_name .lower ())
98+ except KeyError as err :
99+ # This is not an error, but we will log the missed string
100+ logger = logging .getLogger (__name__ )
101+ logger .warning (
102+ f"Error: { err } This has been provided with the "
103+ f"'{ symbol_name } ' in the 'force_private' option, "
104+ "but there is no such symbol in this scope." )
105+ if sym :
106+ explicitly_private_symbols .add (sym )
107+
108+ return explicitly_private_symbols
109+
79110 def validate (self , nodes : list [Node ], options = None , ** kwargs ):
80111 # pylint: disable=arguments-renamed
81112 '''
0 commit comments