From bc92d868942236f0c45bd603dd91c42606f91bb3 Mon Sep 17 00:00:00 2001 From: Edoardo Paone Date: Mon, 12 Feb 2024 14:18:21 +0100 Subject: [PATCH 1/6] Fix for 0d fields (field slice with full indexing) --- .../tests/stencil_tests/test_face_val_ppm_stencil_01.py | 2 +- .../tests/stencil_tests/test_face_val_ppm_stencil_02.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/model/atmosphere/advection/tests/stencil_tests/test_face_val_ppm_stencil_01.py b/model/atmosphere/advection/tests/stencil_tests/test_face_val_ppm_stencil_01.py index b5ceb9b413..222a53e035 100644 --- a/model/atmosphere/advection/tests/stencil_tests/test_face_val_ppm_stencil_01.py +++ b/model/atmosphere/advection/tests/stencil_tests/test_face_val_ppm_stencil_01.py @@ -73,6 +73,6 @@ def input_data(self, grid): p_cc = random_field(grid, CellDim, KDim, extend={KDim: 1}) p_cellhgt_mc_now = random_field(grid, CellDim, KDim, extend={KDim: 1}) k = as_field((KDim,), np.arange(0, _shape(grid, KDim, extend={KDim: 1})[0], dtype=int32)) - elev = k[-2] + elev = k[-2].as_scalar() return dict(p_cc=p_cc, p_cellhgt_mc_now=p_cellhgt_mc_now, k=k, elev=elev, z_slope=z_slope) diff --git a/model/atmosphere/advection/tests/stencil_tests/test_face_val_ppm_stencil_02.py b/model/atmosphere/advection/tests/stencil_tests/test_face_val_ppm_stencil_02.py index bfa201e5e3..b9f27fb7fe 100644 --- a/model/atmosphere/advection/tests/stencil_tests/test_face_val_ppm_stencil_02.py +++ b/model/atmosphere/advection/tests/stencil_tests/test_face_val_ppm_stencil_02.py @@ -60,7 +60,7 @@ def input_data(self, grid): k = as_field((KDim,), np.arange(0, _shape(grid, KDim)[0], dtype=int32)) slev = int32(1) slevp1 = slev + int32(1) - elev = k[-3] + elev = int32(k[-3].as_scalar()) elevp1 = elev + int32(1) return dict( From d7ea3c37d9f071597f4157863fa1f53c6f17f488 Mon Sep 17 00:00:00 2001 From: Edoardo Paone Date: Mon, 12 Feb 2024 14:26:37 +0100 Subject: [PATCH 2/6] Update gt4py stable revision in spack build --- spack/gt4py-stable/spack.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spack/gt4py-stable/spack.yaml b/spack/gt4py-stable/spack.yaml index eb4d6940f1..9d44fb08e4 100644 --- a/spack/gt4py-stable/spack.yaml +++ b/spack/gt4py-stable/spack.yaml @@ -1,10 +1,10 @@ spack: specs: - - py-icon4py@main%gcc@9.3.0 ^py-gt4py@1.0.1.7%gcc@9.3.0 + - py-icon4py@main%gcc@9.3.0 ^py-gt4py@1.0.3.1%gcc@9.3.0 view: false concretizer: unify: true develop: py-icon4py: - spec: py-icon4py@main%gcc@9.3.0 ^py-gt4py@1.0.1.7%gcc@9.3.0 + spec: py-icon4py@main%gcc@9.3.0 ^py-gt4py@1.0.3.1%gcc@9.3.0 path: ../../ From f13f29dbcf8f4404c4c62520b9c60df8afed4f89 Mon Sep 17 00:00:00 2001 From: Edoardo Paone Date: Mon, 12 Feb 2024 14:30:03 +0100 Subject: [PATCH 3/6] Revert "Update gt4py stable revision in spack build" This reverts commit d7ea3c37d9f071597f4157863fa1f53c6f17f488. --- spack/gt4py-stable/spack.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spack/gt4py-stable/spack.yaml b/spack/gt4py-stable/spack.yaml index 9d44fb08e4..eb4d6940f1 100644 --- a/spack/gt4py-stable/spack.yaml +++ b/spack/gt4py-stable/spack.yaml @@ -1,10 +1,10 @@ spack: specs: - - py-icon4py@main%gcc@9.3.0 ^py-gt4py@1.0.3.1%gcc@9.3.0 + - py-icon4py@main%gcc@9.3.0 ^py-gt4py@1.0.1.7%gcc@9.3.0 view: false concretizer: unify: true develop: py-icon4py: - spec: py-icon4py@main%gcc@9.3.0 ^py-gt4py@1.0.3.1%gcc@9.3.0 + spec: py-icon4py@main%gcc@9.3.0 ^py-gt4py@1.0.1.7%gcc@9.3.0 path: ../../ From f19555341d72b5345832dafaf25e5742a3dd2c5c Mon Sep 17 00:00:00 2001 From: Edoardo Paone Date: Mon, 12 Feb 2024 15:14:09 +0100 Subject: [PATCH 4/6] Add backwards compatibility check for 0d field --- .../tests/stencil_tests/test_face_val_ppm_stencil_01.py | 6 +++++- .../tests/stencil_tests/test_face_val_ppm_stencil_02.py | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/model/atmosphere/advection/tests/stencil_tests/test_face_val_ppm_stencil_01.py b/model/atmosphere/advection/tests/stencil_tests/test_face_val_ppm_stencil_01.py index 222a53e035..24a1a2e793 100644 --- a/model/atmosphere/advection/tests/stencil_tests/test_face_val_ppm_stencil_01.py +++ b/model/atmosphere/advection/tests/stencil_tests/test_face_val_ppm_stencil_01.py @@ -73,6 +73,10 @@ def input_data(self, grid): p_cc = random_field(grid, CellDim, KDim, extend={KDim: 1}) p_cellhgt_mc_now = random_field(grid, CellDim, KDim, extend={KDim: 1}) k = as_field((KDim,), np.arange(0, _shape(grid, KDim, extend={KDim: 1})[0], dtype=int32)) - elev = k[-2].as_scalar() + elev = k[-2] + if hasattr( + elev, "as_scalar" + ): # for backwards compatibility, use `as_scalar` unconditionally once minimum gt4py is >= 1.0.4 + elev = elev.as_scalar() return dict(p_cc=p_cc, p_cellhgt_mc_now=p_cellhgt_mc_now, k=k, elev=elev, z_slope=z_slope) diff --git a/model/atmosphere/advection/tests/stencil_tests/test_face_val_ppm_stencil_02.py b/model/atmosphere/advection/tests/stencil_tests/test_face_val_ppm_stencil_02.py index b9f27fb7fe..2b24120886 100644 --- a/model/atmosphere/advection/tests/stencil_tests/test_face_val_ppm_stencil_02.py +++ b/model/atmosphere/advection/tests/stencil_tests/test_face_val_ppm_stencil_02.py @@ -60,7 +60,11 @@ def input_data(self, grid): k = as_field((KDim,), np.arange(0, _shape(grid, KDim)[0], dtype=int32)) slev = int32(1) slevp1 = slev + int32(1) - elev = int32(k[-3].as_scalar()) + elev = k[-3] + if hasattr( + elev, "as_scalar" + ): # for backwards compatibility, use `as_scalar` unconditionally once minimum gt4py is >= 1.0.4 + elev = elev.as_scalar() elevp1 = elev + int32(1) return dict( From 3af6d1469d061a283f4a0a3910e24a1d68eec263 Mon Sep 17 00:00:00 2001 From: Edoardo Paone Date: Tue, 13 Feb 2024 08:45:59 +0100 Subject: [PATCH 5/6] Fix syntax error Expected argument 'elevp1' to be of type 'int32', got 'int64'. --- .../tests/stencil_tests/test_face_val_ppm_stencil_02.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/model/atmosphere/advection/tests/stencil_tests/test_face_val_ppm_stencil_02.py b/model/atmosphere/advection/tests/stencil_tests/test_face_val_ppm_stencil_02.py index 2b24120886..ad2e1fdf75 100644 --- a/model/atmosphere/advection/tests/stencil_tests/test_face_val_ppm_stencil_02.py +++ b/model/atmosphere/advection/tests/stencil_tests/test_face_val_ppm_stencil_02.py @@ -64,7 +64,7 @@ def input_data(self, grid): if hasattr( elev, "as_scalar" ): # for backwards compatibility, use `as_scalar` unconditionally once minimum gt4py is >= 1.0.4 - elev = elev.as_scalar() + elev = int32(elev.as_scalar()) elevp1 = elev + int32(1) return dict( From f530e139ece9901104164876fe2b235d03f6134a Mon Sep 17 00:00:00 2001 From: Edoardo Paone Date: Wed, 14 Feb 2024 15:04:30 +0100 Subject: [PATCH 6/6] Bump gt4py stable version --- .../tests/stencil_tests/test_face_val_ppm_stencil_01.py | 6 +----- .../tests/stencil_tests/test_face_val_ppm_stencil_02.py | 6 +----- spack/gt4py-stable/spack.yaml | 4 ++-- 3 files changed, 4 insertions(+), 12 deletions(-) diff --git a/model/atmosphere/advection/tests/stencil_tests/test_face_val_ppm_stencil_01.py b/model/atmosphere/advection/tests/stencil_tests/test_face_val_ppm_stencil_01.py index 24a1a2e793..222a53e035 100644 --- a/model/atmosphere/advection/tests/stencil_tests/test_face_val_ppm_stencil_01.py +++ b/model/atmosphere/advection/tests/stencil_tests/test_face_val_ppm_stencil_01.py @@ -73,10 +73,6 @@ def input_data(self, grid): p_cc = random_field(grid, CellDim, KDim, extend={KDim: 1}) p_cellhgt_mc_now = random_field(grid, CellDim, KDim, extend={KDim: 1}) k = as_field((KDim,), np.arange(0, _shape(grid, KDim, extend={KDim: 1})[0], dtype=int32)) - elev = k[-2] - if hasattr( - elev, "as_scalar" - ): # for backwards compatibility, use `as_scalar` unconditionally once minimum gt4py is >= 1.0.4 - elev = elev.as_scalar() + elev = k[-2].as_scalar() return dict(p_cc=p_cc, p_cellhgt_mc_now=p_cellhgt_mc_now, k=k, elev=elev, z_slope=z_slope) diff --git a/model/atmosphere/advection/tests/stencil_tests/test_face_val_ppm_stencil_02.py b/model/atmosphere/advection/tests/stencil_tests/test_face_val_ppm_stencil_02.py index ad2e1fdf75..b9f27fb7fe 100644 --- a/model/atmosphere/advection/tests/stencil_tests/test_face_val_ppm_stencil_02.py +++ b/model/atmosphere/advection/tests/stencil_tests/test_face_val_ppm_stencil_02.py @@ -60,11 +60,7 @@ def input_data(self, grid): k = as_field((KDim,), np.arange(0, _shape(grid, KDim)[0], dtype=int32)) slev = int32(1) slevp1 = slev + int32(1) - elev = k[-3] - if hasattr( - elev, "as_scalar" - ): # for backwards compatibility, use `as_scalar` unconditionally once minimum gt4py is >= 1.0.4 - elev = int32(elev.as_scalar()) + elev = int32(k[-3].as_scalar()) elevp1 = elev + int32(1) return dict( diff --git a/spack/gt4py-stable/spack.yaml b/spack/gt4py-stable/spack.yaml index eb4d6940f1..9d44fb08e4 100644 --- a/spack/gt4py-stable/spack.yaml +++ b/spack/gt4py-stable/spack.yaml @@ -1,10 +1,10 @@ spack: specs: - - py-icon4py@main%gcc@9.3.0 ^py-gt4py@1.0.1.7%gcc@9.3.0 + - py-icon4py@main%gcc@9.3.0 ^py-gt4py@1.0.3.1%gcc@9.3.0 view: false concretizer: unify: true develop: py-icon4py: - spec: py-icon4py@main%gcc@9.3.0 ^py-gt4py@1.0.1.7%gcc@9.3.0 + spec: py-icon4py@main%gcc@9.3.0 ^py-gt4py@1.0.3.1%gcc@9.3.0 path: ../../