@@ -5954,22 +5954,22 @@ def _init_scalar_properties(
59545954 self ._precision = const .SCALAR_PRECISION_MAP [
59555955 self .intrinsic_type ]
59565956
5957- def _init_field_properties (self , alg_datatype , check = True ):
5957+ def _init_field_properties (self ,
5958+ alg_datatype : Optional [str ],
5959+ check : bool = True ) -> None :
59585960 '''Set up the properties of this field using algorithm datatype
59595961 information if it is available.
59605962
5961- :param alg_datatype: the datatype of this argument as \
5962- specified in the algorithm layer or None if it is not \
5963- known.
5964- :type alg_datatype: str or NoneType
5965- :param bool check: whether to use the algorithm \
5963+ :param alg_datatype: the datatype of this argument as
5964+ specified in the algorithm layer or None if it is not known.
5965+ :param check: whether to use the algorithm
59665966 information. Optional argument that defaults to True.
59675967
5968- :raises GenerationError: if the datatype for a gh_field \
5968+ :raises GenerationError: if the datatype for a gh_field
59695969 could not be found in the algorithm layer.
5970- :raises GenerationError: if the datatype specified in the \
5970+ :raises GenerationError: if the datatype specified in the
59715971 algorithm layer is inconsistent with the kernel metadata.
5972- :raises InternalError: if the intrinsic type of the field is \
5972+ :raises InternalError: if the intrinsic type of the field is
59735973 not supported (i.e. is not real or integer).
59745974
59755975 '''
@@ -5990,20 +5990,14 @@ def _init_field_properties(self, alg_datatype, check=True):
59905990 if not check :
59915991 # Use the default as we are ignoring any algorithm info
59925992 argtype = "field"
5993- elif alg_datatype == "field_type" :
5994- argtype = "field"
5995- elif alg_datatype == "r_bl_field_type" :
5996- argtype = "r_bl_field"
5997- elif alg_datatype == "r_solver_field_type" :
5998- argtype = "r_solver_field"
5999- elif alg_datatype == "r_tran_field_type" :
6000- argtype = "r_tran_field"
60015993 else :
6002- raise GenerationError (
6003- f"The metadata for argument '{ self .name } ' in kernel "
6004- f"'{ self ._call .name } ' specifies that this is a real "
6005- f"field, however it is declared as a "
6006- f"'{ alg_datatype } ' in the algorithm code." )
5994+ argtype = const .REAL_DATA_TYPE_RMAP .get (alg_datatype , None )
5995+ if not argtype :
5996+ raise GenerationError (
5997+ f"The metadata for argument '{ self .name } ' in kernel "
5998+ f"'{ self ._call .name } ' specifies that this is a real "
5999+ f"field, however it is declared as a "
6000+ f"'{ alg_datatype } ' in the algorithm code." )
60076001
60086002 elif self .intrinsic_type == "integer" :
60096003 if check and alg_datatype != "integer_field_type" :
@@ -6023,20 +6017,21 @@ def _init_field_properties(self, alg_datatype, check=True):
60236017 self ._proxy_data_type = const .DATA_TYPE_MAP [argtype ]["proxy_type" ]
60246018 self ._module_name = const .DATA_TYPE_MAP [argtype ]["module" ]
60256019
6026- def _init_operator_properties (self , alg_datatype , check = True ):
6020+ def _init_operator_properties (self ,
6021+ alg_datatype : Optional [str ],
6022+ check : bool = True ) -> None :
60276023 '''Set up the properties of this operator using algorithm datatype
60286024 information if it is available.
60296025
6030- :param alg_datatype: the datatype of this argument as \
6031- specified in the algorithm layer or None if it is not \
6032- known.
6033- :type alg_datatype: str or NoneType
6034- :param bool check: whether to use the algorithm \
6035- information. Optional argument that defaults to True.
6036- :raises GenerationError: if the datatype for a gh_operator \
6037- could not be found in the algorithm layer (and check is \
6026+ :param alg_datatype: the datatype of this argument as specified in
6027+ the algorithm layer or None if it is not known.
6028+ :param check: whether to use the algorithm information. Optional
6029+ argument that defaults to True.
6030+
6031+ :raises GenerationError: if the datatype for a gh_operator
6032+ could not be found in the algorithm layer (and check is
60386033 True).
6039- :raises GenerationError: if the datatype specified in the \
6034+ :raises GenerationError: if the datatype specified in the
60406035 algorithm layer is inconsistent with the kernel metadata.
60416036 :raises InternalError: if this argument is not an operator.
60426037
@@ -6048,9 +6043,8 @@ def _init_operator_properties(self, alg_datatype, check=True):
60486043 # Use the default as we are ignoring any algorithm info
60496044 argtype = "operator"
60506045 elif not alg_datatype :
6051- # Raise an exception as we require algorithm
6052- # information to determine the precision of the
6053- # operator
6046+ # Raise an exception as we require algorithm information
6047+ # to determine the precision of the operator
60546048 raise GenerationError (
60556049 f"It was not possible to determine the operator type "
60566050 f"from the algorithm layer for argument '{ self .name } ' "
@@ -6061,6 +6055,10 @@ def _init_operator_properties(self, alg_datatype, check=True):
60616055 argtype = "r_solver_operator"
60626056 elif alg_datatype == "r_tran_operator_type" :
60636057 argtype = "r_tran_operator"
6058+ elif alg_datatype == "operator_real64_type" :
6059+ argtype = "r_64_operator"
6060+ elif alg_datatype == "operator_real32_type" :
6061+ argtype = "r_32_operator"
60646062 else :
60656063 raise GenerationError (
60666064 f"The metadata for argument '{ self .name } ' in kernel "
@@ -6480,17 +6478,25 @@ def _find_or_create_type(mod_name: str,
64806478 raise NotImplementedError (
64816479 f"Unsupported scalar type '{ self .intrinsic_type } '" )
64826480
6481+ const = LFRicConstants ()
64836482 kind_name = self .precision
64846483 try :
64856484 kind_symbol = symtab .lookup (kind_name )
64866485 except KeyError :
6487- mod_map = LFRicConstants ().UTILITIES_MOD_MAP
6488- const_mod = mod_map ["constants" ]["module" ]
6489- constants_container = symtab .find_or_create (
6490- const_mod , symbol_type = ContainerSymbol )
6491- kind_symbol = DataSymbol (
6492- kind_name , ScalarType .integer_type (),
6493- interface = ImportInterface (constants_container ))
6486+ if kind_name .lower () in const .INTRINSIC_KINDS :
6487+ # This is an intrinsic kind (e.g. real32) so it comes
6488+ # from the intrinsic ISO module.
6489+ cntr_sym = symtab .find_or_create (
6490+ const .FORTRAN_ISO_MOD_NAME ,
6491+ symbol_type = ContainerSymbol ,
6492+ is_intrinsic = True )
6493+ else :
6494+ mod_map = const .UTILITIES_MOD_MAP
6495+ const_mod = mod_map ["constants" ]["module" ]
6496+ cntr_sym = symtab .find_or_create (
6497+ const_mod , symbol_type = ContainerSymbol )
6498+ kind_symbol = DataSymbol (kind_name , ScalarType .integer_type (),
6499+ interface = ImportInterface (cntr_sym ))
64946500 symtab .add (kind_symbol )
64956501 dts = ScalarType (prim_type , Reference (kind_symbol ))
64966502 if self .is_scalar_array and self ._array_ndims >= 1 :
0 commit comments