From 931e336e795735a3694b569e8546ea513083bd6d Mon Sep 17 00:00:00 2001 From: Frank Malatino Date: Wed, 15 May 2024 11:20:07 -0400 Subject: [PATCH 1/8] Updated quantity.py to use dsl type Float where needed --- external/dace | 2 +- external/gt4py | 2 +- ndsl/quantity.py | 6 ++++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/external/dace b/external/dace index b1a7f8a6..ee5a6dfe 160000 --- a/external/dace +++ b/external/dace @@ -1 +1 @@ -Subproject commit b1a7f8a6ea76f913a0bf8b32de5bc416697218fd +Subproject commit ee5a6dfe695f329c3882105b087f3563a0c80b81 diff --git a/external/gt4py b/external/gt4py index 66f84473..2f5799eb 160000 --- a/external/gt4py +++ b/external/gt4py @@ -1 +1 @@ -Subproject commit 66f8447398762127ba51c7a335d0da7ada369219 +Subproject commit 2f5799ebcb49314f9bf40932c797f7acb85b4c67 diff --git a/ndsl/quantity.py b/ndsl/quantity.py index f998c860..6e7e25b4 100644 --- a/ndsl/quantity.py +++ b/ndsl/quantity.py @@ -6,6 +6,7 @@ import ndsl.constants as constants from ndsl.comm._boundary_utils import bound_default_slice, shift_boundary_slice_tuple +from ndsl.dsl.typing import Float from ndsl.optional_imports import cupy, dace, gt4py from ndsl.optional_imports import xarray as xr from ndsl.types import NumpyModule @@ -260,7 +261,8 @@ def _validate_quantity_property_lengths(shape, dims, origin, extent): def _is_float(dtype): """Expected floating point type for Pace""" return ( - dtype == float + dtype == Float + or dtype == float or dtype == np.float32 or dtype == np.float64 or dtype == np.float16 @@ -298,7 +300,7 @@ def __init__( """ # ToDo: [Florian 01/23] Kill the abomination. # See https://github.com/NOAA-GFDL/pace/issues/3 - from ndsl.dsl.typing import Float + # from ndsl.dsl.typing import Float if ( not allow_mismatch_float_precision From c9709141845e6e55f91b79991d05796566842f30 Mon Sep 17 00:00:00 2001 From: Frank Malatino Date: Wed, 15 May 2024 11:40:35 -0400 Subject: [PATCH 2/8] Added use of 'Float' dsl type where needed in allocator.py --- ndsl/initialization/allocator.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/ndsl/initialization/allocator.py b/ndsl/initialization/allocator.py index 5320e4c6..869086f6 100644 --- a/ndsl/initialization/allocator.py +++ b/ndsl/initialization/allocator.py @@ -3,6 +3,7 @@ import numpy as np from ndsl.constants import SPATIAL_DIMS +from ndsl.dsl.typing import Float from ndsl.initialization.sizer import GridSizer from ndsl.optional_imports import gt4py from ndsl.quantity import Quantity, QuantityHaloSpec @@ -60,7 +61,7 @@ def empty( self, dims: Sequence[str], units: str, - dtype: type = np.float64, + dtype: type = Float, allow_mismatch_float_precision: bool = False, ): return self._allocate( @@ -71,7 +72,7 @@ def zeros( self, dims: Sequence[str], units: str, - dtype: type = np.float64, + dtype: type = Float, allow_mismatch_float_precision: bool = False, ): return self._allocate( @@ -82,7 +83,7 @@ def ones( self, dims: Sequence[str], units: str, - dtype: type = np.float64, + dtype: type = Float, allow_mismatch_float_precision: bool = False, ): return self._allocate( @@ -116,7 +117,7 @@ def _allocate( allocator: Callable, dims: Sequence[str], units: str, - dtype: type = np.float64, + dtype: type = Float, allow_mismatch_float_precision: bool = False, ): origin = self.sizer.get_origin(dims) @@ -150,7 +151,7 @@ def get_quantity_halo_spec( self, dims: Sequence[str], n_halo: Optional[int] = None, - dtype: type = np.float64, + dtype: type = Float, ) -> QuantityHaloSpec: """Build memory specifications for the halo update. From 6c86f0ae8b1e8752bfb36def76156de33d9d1400 Mon Sep 17 00:00:00 2001 From: Frank Malatino Date: Thu, 16 May 2024 11:33:03 -0400 Subject: [PATCH 3/8] Updating gt4py and casting of float types to Float dsl type where needed in geometry.py and helper.py --- external/gt4py | 2 +- ndsl/grid/geometry.py | 9 +++++---- ndsl/grid/helper.py | 5 +++-- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/external/gt4py b/external/gt4py index 2f5799eb..c89bd818 160000 --- a/external/gt4py +++ b/external/gt4py @@ -1 +1 @@ -Subproject commit 2f5799ebcb49314f9bf40932c797f7acb85b4c67 +Subproject commit c89bd8189f232fcb2ee1cc96a5b4dc9ae7636491 diff --git a/ndsl/grid/geometry.py b/ndsl/grid/geometry.py index 804be0fe..74441cde 100644 --- a/ndsl/grid/geometry.py +++ b/ndsl/grid/geometry.py @@ -1,4 +1,5 @@ from ndsl.comm.partitioner import TilePartitioner +from ndsl.dsl.typing import Float from ndsl.grid.gnomonic import ( get_lonlat_vect, get_unit_vector_direction, @@ -591,7 +592,7 @@ def edge_factors( nhalo: int, tile_partitioner: TilePartitioner, rank: int, - radius: float, + radius: Float, np, ): """ @@ -704,7 +705,7 @@ def efactor_a2c_v( nhalo: int, tile_partitioner: TilePartitioner, rank: int, - radius: float, + radius: Float, np, ): """ @@ -888,7 +889,7 @@ def unit_vector_lonlat(grid, np): return unit_lon, unit_lat -def _fill_halo_corners(field, value: float, nhalo: int, tile_partitioner, rank): +def _fill_halo_corners(field, value: Float, nhalo: int, tile_partitioner, rank): """ Fills a tile halo corners (ghost cells) of a field with a set value along the first 2 axes @@ -905,7 +906,7 @@ def _fill_halo_corners(field, value: float, nhalo: int, tile_partitioner, rank): field[-nhalo:, -nhalo:] = value # NE corner -def _fill_single_halo_corner(field, value: float, nhalo: int, corner: str): +def _fill_single_halo_corner(field, value: Float, nhalo: int, corner: str): """ Fills a tile halo corner (ghost cells) of a field with a set value along the first 2 axes diff --git a/ndsl/grid/helper.py b/ndsl/grid/helper.py index fd62d771..745dce37 100644 --- a/ndsl/grid/helper.py +++ b/ndsl/grid/helper.py @@ -12,6 +12,7 @@ split_cartesian_into_storages = None import ndsl.constants as constants from ndsl.constants import Z_DIM, Z_INTERFACE_DIM +from ndsl.dsl.typing import Float from ndsl.filesystem import get_fs from ndsl.grid.generation import MetricTerms from ndsl.initialization.allocator import QuantityFactory @@ -226,13 +227,13 @@ def dp(self) -> Quantity: return self._dp_ref @property - def ptop(self) -> float: + def ptop(self) -> Float: """ top of atmosphere pressure (Pa) """ if self.bk.view[0] != 0: raise ValueError("ptop is not well-defined when top-of-atmosphere bk != 0") - return float(self.ak.view[0]) + return Float(self.ak.view[0]) @dataclasses.dataclass(frozen=True) From b168c94c796a7f2718cc9a729e36d9327d58568d Mon Sep 17 00:00:00 2001 From: Frank Malatino Date: Fri, 17 May 2024 22:25:37 -0400 Subject: [PATCH 4/8] Updating gt4py --- external/gt4py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external/gt4py b/external/gt4py index c89bd818..d49086e5 160000 --- a/external/gt4py +++ b/external/gt4py @@ -1 +1 @@ -Subproject commit c89bd8189f232fcb2ee1cc96a5b4dc9ae7636491 +Subproject commit d49086e56019964bccf08e211a1bcad0a175074b From 1a938f26c17cbc93b557539035f2802f5631516b Mon Sep 17 00:00:00 2001 From: Frank Malatino Date: Fri, 17 May 2024 22:42:24 -0400 Subject: [PATCH 5/8] Testing for pyFV3 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 7466a814..3958a501 100644 --- a/setup.py +++ b/setup.py @@ -50,6 +50,6 @@ def local_pkg(name: str, relative_path: str) -> str: packages=find_namespace_packages(include=["ndsl", "ndsl.*"]), include_package_data=True, url="https://github.com/NOAA-GFDL/NDSL", - version="2024.04.00", + version="2024.04.02", zip_safe=False, ) From b87f8132f4f9d99731dda5fc7295ae84a03ecd52 Mon Sep 17 00:00:00 2001 From: Frank Malatino Date: Mon, 20 May 2024 13:40:12 -0400 Subject: [PATCH 6/8] Updated setup.py to reflect actual version number --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 4eaf99a7..ce6fb6f3 100644 --- a/setup.py +++ b/setup.py @@ -50,6 +50,6 @@ def local_pkg(name: str, relative_path: str) -> str: packages=find_namespace_packages(include=["ndsl", "ndsl.*"]), include_package_data=True, url="https://github.com/NOAA-GFDL/NDSL", - version="2024.04.02", + version="2024.04.00", zip_safe=False, ) From 2aef448aabfb75acbc41d1a74c6e0a509d812ef1 Mon Sep 17 00:00:00 2001 From: Frank Malatino Date: Thu, 30 May 2024 16:53:05 -0400 Subject: [PATCH 7/8] Removed commented Float import in ndsl/quantity.py --- ndsl/quantity.py | 1 - 1 file changed, 1 deletion(-) diff --git a/ndsl/quantity.py b/ndsl/quantity.py index 6e7e25b4..178df991 100644 --- a/ndsl/quantity.py +++ b/ndsl/quantity.py @@ -300,7 +300,6 @@ def __init__( """ # ToDo: [Florian 01/23] Kill the abomination. # See https://github.com/NOAA-GFDL/pace/issues/3 - # from ndsl.dsl.typing import Float if ( not allow_mismatch_float_precision From 69dee7e3c2e883aafb005082e6ad52bfb17a7580 Mon Sep 17 00:00:00 2001 From: Frank Malatino Date: Fri, 31 May 2024 12:18:15 -0400 Subject: [PATCH 8/8] Removed comment in quantity regarding pace issue 3 --- ndsl/quantity.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/ndsl/quantity.py b/ndsl/quantity.py index 178df991..dc30c685 100644 --- a/ndsl/quantity.py +++ b/ndsl/quantity.py @@ -298,8 +298,6 @@ def __init__( storage attribute is disabled and will raise an exception. Will raise a TypeError if this is given with a gt4py storage type as data """ - # ToDo: [Florian 01/23] Kill the abomination. - # See https://github.com/NOAA-GFDL/pace/issues/3 if ( not allow_mismatch_float_precision