lint_rules.sc
Functions
|
|
|
Classes
|
|
SC1: horizontal indexing rule. |
|
SC2: horizontal looping rule. |
|
SC3: function calls from inside KPROMA loops |
|
SC4: no horizontal indirection |
|
SC4: no horizontal indirection |
|
SC5 (potential rule): no horizontal reduction across vector loop |
|
SC6 (potential rule): no horizontal index array accessing with an offset |
- class SC1v1Rule
Bases:
GenericRule
SC1: horizontal indexing rule.
Version 1: really simple/basic implementation
checking for innermost (0th index) of arrays
- docs = {'title': 'SC1: horizontal indexing rule.Variables referring to horizontal indices should be named consistently!'}
dict
with description of the ruleTypically, this should include
"id"
and"title"
. Allows for Python’s format specification mini-language in"title"
to fill values using data fromconfig
, with the field name corresponding to the config key.
- config = {'horizontal_index': 0, 'horizontal_shape': ['klon', 'nproma', 'kproma'], 'horizontal_var': ['jl']}
Dict of configuration keys and their default values
These values can be overriden externally in the linter config file and are passed automatically to the
check()
routine.
- classmethod check_subroutine(subroutine, rule_report, config)
Perform rule checks on subroutine level
Must be implemented by a rule if applicable.
- class SC2v1Rule
Bases:
GenericRule
SC2: horizontal looping rule.
- docs = {'title': 'SC2: horizontal looping rule.All loops over the innermost, horizontal array dimension should be explicit!'}
dict
with description of the ruleTypically, this should include
"id"
and"title"
. Allows for Python’s format specification mini-language in"title"
to fill values using data fromconfig
, with the field name corresponding to the config key.
- config = {'horizontal_index': 0, 'horizontal_shape': ['klon', 'nproma', 'kproma'], 'horizontal_var': ['jl']}
Dict of configuration keys and their default values
These values can be overriden externally in the linter config file and are passed automatically to the
check()
routine.
- class FindNodesDepth(match, greedy=False)
Bases:
FindNodes
- visit_Node(o, **kwargs)
Add the node to the returned list if it matches the criteria and visit all children.
- classmethod innermost_loops(loops)
- classmethod check_subroutine(subroutine, rule_report, config)
Perform rule checks on subroutine level
Must be implemented by a rule if applicable.
- class SC3v1Rule
Bases:
GenericRule
SC3: function calls from inside KPROMA loops
- docs = {'title': 'SC3: function calls from inside `KPROMA` loops.Inside tight horizontal loops of type DO `JL=KIDIA,KFDIA`, calls should be restricted to intrinsics!'}
dict
with description of the ruleTypically, this should include
"id"
and"title"
. Allows for Python’s format specification mini-language in"title"
to fill values using data fromconfig
, with the field name corresponding to the config key.
- config = {'horizontal_index': 0, 'horizontal_shape': ['klon', 'nproma', 'kproma'], 'horizontal_var': ['jl']}
Dict of configuration keys and their default values
These values can be overriden externally in the linter config file and are passed automatically to the
check()
routine.
- classmethod check_subroutine(subroutine, rule_report, config)
Perform rule checks on subroutine level
Must be implemented by a rule if applicable.
- class SC4v1Rule
Bases:
GenericRule
SC4: no horizontal indirection
- TODO: what to cover regarding indirect array accesses?
“direct” indirect access: arr1(arr2(…),…)
“indirect” indirect access: j = arr2(…), arr1(j, …)
“indirect, indirect” indirect access: k = arr2(…), j=k, arr1(j, …)
…
- docs = {'title': 'SC4: no horizontal indirection.Where relevant (Single Column), indirect addressing on the innermost, horizontal array index shall not be used!'}
dict
with description of the ruleTypically, this should include
"id"
and"title"
. Allows for Python’s format specification mini-language in"title"
to fill values using data fromconfig
, with the field name corresponding to the config key.
- config = {'horizontal_index': 0, 'horizontal_shape': ['klon', 'nproma', 'kproma'], 'horizontal_var': ['jl']}
Dict of configuration keys and their default values
These values can be overriden externally in the linter config file and are passed automatically to the
check()
routine.
- classmethod check_subroutine(subroutine, rule_report, config)
Perform rule checks on subroutine level
Must be implemented by a rule if applicable.
- class SC4v2Rule
Bases:
GenericRule
SC4: no horizontal indirection
- TODO: what to cover regarding indirect array accesses?
“direct” indirect access: arr1(arr2(…),…)
“indirect” indirect access: j = arr2(…), arr1(j, …)
“indirect, indirect” indirect access: k = arr2(…), j=k, arr1(j, …)
…
- docs = {'title': 'SC4: no horizontal indirection.Where relevant (Single Column), indirect addressing on the innermost, horizontal array index shall not be used!'}
dict
with description of the ruleTypically, this should include
"id"
and"title"
. Allows for Python’s format specification mini-language in"title"
to fill values using data fromconfig
, with the field name corresponding to the config key.
- config = {'horizontal_index': 0, 'horizontal_shape': ['klon', 'nproma', 'kproma'], 'horizontal_var': ['jl']}
Dict of configuration keys and their default values
These values can be overriden externally in the linter config file and are passed automatically to the
check()
routine.
- class FindValues(match, lhs=None, greedy=False)
Bases:
FindNodes
- visit_Node(o, **kwargs)
Add the node to the returned list if it matches the criteria and visit all children.
- classmethod check_subroutine(subroutine, rule_report, config)
Perform rule checks on subroutine level
Must be implemented by a rule if applicable.
- class SC5v1potentialRule
Bases:
GenericRule
SC5 (potential rule): no horizontal reduction across vector loop
- docs = {'title': 'SC5 (potential rule): no horizontal reduction across vector loop.No reduction operations (reducing the elements of an array into a single value) across the vector loop/horizontal index `JL`!'}
dict
with description of the ruleTypically, this should include
"id"
and"title"
. Allows for Python’s format specification mini-language in"title"
to fill values using data fromconfig
, with the field name corresponding to the config key.
- config = {'horizontal_index': 0, 'horizontal_shape': ['klon', 'nproma', 'kproma'], 'horizontal_var': ['jl']}
Dict of configuration keys and their default values
These values can be overriden externally in the linter config file and are passed automatically to the
check()
routine.
- reduction_functions = ['all', 'any', 'count', 'maxval', 'minval', 'product', 'sum']
- classmethod check_subroutine(subroutine, rule_report, config)
Perform rule checks on subroutine level
Must be implemented by a rule if applicable.
- class SC6v1potentialRule
Bases:
GenericRule
SC6 (potential rule): no horizontal index array accessing with an offset
- docs = {'title': 'SC6 (potential rule): no horizontal index array accessing with an offset.Arrays accessed in the horizontal dimension via the horizontal index `JL` shall only be accessed via the horizontal index, thus without any offset like e.g. `JL + n` (with `n` as an arbitrary integer).!'}
dict
with description of the ruleTypically, this should include
"id"
and"title"
. Allows for Python’s format specification mini-language in"title"
to fill values using data fromconfig
, with the field name corresponding to the config key.
- config = {'horizontal_index': 0, 'horizontal_shape': ['klon', 'nproma', 'kproma'], 'horizontal_var': ['jl']}
Dict of configuration keys and their default values
These values can be overriden externally in the linter config file and are passed automatically to the
check()
routine.
- classmethod check_subroutine(subroutine, rule_report, config)
Perform rule checks on subroutine level
Must be implemented by a rule if applicable.