Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
587 commits
Select commit Hold shift + click to select a range
d41ea85
Remove is not None
msimberg Feb 13, 2026
cccbe97
Simplify return
msimberg Feb 13, 2026
2b6be6d
Revert "Remove is not None"
msimberg Feb 13, 2026
b5115c2
Minor consistency renaming
msimberg Feb 13, 2026
1370754
Small cleanup in grid refinement
msimberg Feb 13, 2026
822549e
Add distributed property to GridConfig
msimberg Feb 13, 2026
d01fd13
CI for standalone_driver
nfarabullini Feb 19, 2026
f3c69ff
Merge branch 'main' into ci_for_standalone_driver
nfarabullini Feb 19, 2026
4bf1e15
edits to yamla nd toml files
nfarabullini Feb 19, 2026
de83aeb
further edits and fixes
nfarabullini Feb 19, 2026
cf19a0f
Small reordering of fields
msimberg Feb 24, 2026
54ba6b5
Add more fields to be tested in test_parallel_grid_manager.py
msimberg Feb 24, 2026
bac1faf
Change computational domain for some geometry fields
msimberg Feb 24, 2026
789a7ff
Sort geometry fields
msimberg Feb 24, 2026
b40ff92
Add more interpolation fields to parallel grid manager test
msimberg Feb 24, 2026
67e054b
Test more metrics fields
msimberg Feb 24, 2026
f864ec6
Remove unused fixture
msimberg Feb 24, 2026
0fbfb62
Fix figure reference
msimberg Feb 24, 2026
2bc143e
Merge remote-tracking branch 'origin/main' into halo_construction
msimberg Feb 24, 2026
4fb0936
Remove deleted field from test
msimberg Feb 24, 2026
203fcf9
inital conditions edits and tests
nfarabullini Feb 25, 2026
ca8d67c
Merge branch 'main' into ci_for_standalone_driver
nfarabullini Feb 25, 2026
dfdcfcb
further edits to remove serialized constants
nfarabullini Feb 25, 2026
bdde616
Merge branch 'ci_for_standalone_driver' of https://github.com/C2SM/ic…
nfarabullini Feb 25, 2026
7234c6b
Merge branch 'main' into ci_for_standalone_driver
nfarabullini Feb 25, 2026
5e5a6ef
Merge branch 'main' into ci_for_standalone_driver
nfarabullini Feb 27, 2026
7290b81
Update model/common/src/icon4py/model/common/decomposition/definition…
msimberg Feb 27, 2026
135172d
Update model/common/src/icon4py/model/common/decomposition/definition…
msimberg Feb 27, 2026
171d23f
Update model/common/src/icon4py/model/common/decomposition/halo.py
msimberg Feb 27, 2026
7fa119a
Update model/common/src/icon4py/model/common/decomposition/definition…
msimberg Feb 27, 2026
5b6ddf8
Merge remote-tracking branch 'origin/main' into distributed-tests-dac…
msimberg Feb 27, 2026
18ebc10
Merge remote-tracking branch 'origin/main' into halo_construction
msimberg Feb 27, 2026
f47e5f3
Work on failing test_parallel_grid_geometry.py fields
msimberg Feb 27, 2026
20e4a8b
Comment one more field out for now
msimberg Feb 27, 2026
46014f6
further edits
nfarabullini Mar 2, 2026
1061e37
Merge branch 'main' into ci_for_standalone_driver
nfarabullini Mar 2, 2026
02a9650
Add assertions for halo construction consistency
msimberg Mar 2, 2026
bb9ebf1
lowered tolerance in standalone driver test and ran pre-commit
nfarabullini Mar 2, 2026
5b8a448
Merge branch 'main' into ci_for_standalone_driver
nfarabullini Mar 2, 2026
cd8ef1c
update from upstream, edits to types, and ran pre-commit
nfarabullini Mar 2, 2026
63a2520
Change implementation of array_ns_from_array
msimberg Mar 2, 2026
3eea114
some edits
nfarabullini Mar 2, 2026
c1217d5
small edit
nfarabullini Mar 2, 2026
4bf3733
Merge branch 'main' into ci_for_standalone_driver
nfarabullini Mar 2, 2026
23d7c83
Fix inverse dual edge length and c_lin_e fields
msimberg Mar 2, 2026
cc30a62
small fix
nfarabullini Mar 2, 2026
6b1bb5f
small edit to fixture
nfarabullini Mar 2, 2026
930e167
commented out parametrization
nfarabullini Mar 2, 2026
e86051a
Merge branch 'main' into ci_for_standalone_driver
nfarabullini Mar 2, 2026
22338bf
removed w_1
nfarabullini Mar 3, 2026
fc982cb
small test edits
nfarabullini Mar 3, 2026
5424978
Merge branch 'ci_for_standalone_driver' of https://github.com/C2SM/ic…
nfarabullini Mar 3, 2026
3fc3dbf
edited one tolerance
nfarabullini Mar 3, 2026
55836c3
further fixes for w_1
nfarabullini Mar 3, 2026
69c8ae6
Merge branch 'main' into ci_for_standalone_driver
nfarabullini Mar 3, 2026
cfabcd3
Update diffusion.py
nfarabullini Mar 3, 2026
6cbcbad
merge with upstream
nfarabullini Mar 3, 2026
5724bc6
edits to icon4py test
nfarabullini Mar 3, 2026
961f4cd
small type hint edit
nfarabullini Mar 3, 2026
3db70c3
further edits
nfarabullini Mar 3, 2026
68e85a4
standalone driver parametrization edits
nfarabullini Mar 3, 2026
f0e14d2
Merge branch 'main' into ci_for_standalone_driver
nfarabullini Mar 3, 2026
fa07307
adjusted standalone tolerances
nfarabullini Mar 3, 2026
f415370
Merge branch 'main' into distributed-tests-dace-gpu
nfarabullini Mar 3, 2026
ad485d0
"Fix" more parallel tests
msimberg Mar 3, 2026
d2335c1
Merge branch 'main' into ci_for_standalone_driver
nfarabullini Mar 4, 2026
09e99d2
ran pre-commit
nfarabullini Mar 4, 2026
88ffb2f
Merge branch 'ci_for_standalone_driver' of https://github.com/C2SM/ic…
nfarabullini Mar 4, 2026
abcc29c
grid description fixture and tiny grid
jcanton Mar 4, 2026
8c83811
Add tests to check consistency of owner masks and domain bounds
msimberg Mar 4, 2026
20aed6e
change config of metric factory for JW
OngChia Mar 4, 2026
895b5b4
Fix vertex/edge decomposition ownership masks
msimberg Mar 4, 2026
88b83ba
Update compute bounds in factories now that ownership bug is fixed
msimberg Mar 4, 2026
44e3708
Add tests to check that halo levels are sorted
msimberg Mar 4, 2026
82466c1
Clean up test_halo.py and fix a few parameters
msimberg Mar 4, 2026
38be5e5
Add missing is_sorted helper function
msimberg Mar 4, 2026
7cac885
Remove todo
msimberg Mar 4, 2026
eda26ef
Clean up and enable more tests in test_parallel_grid_manager.py
msimberg Mar 4, 2026
a397e0a
Add specialized mask_prog_halo_c test
msimberg Mar 4, 2026
d0acad4
Merge remote-tracking branch 'origin/halo_construction' into halo_con…
msimberg Mar 4, 2026
d949e44
Merge remote-tracking branch 'origin/main' into halo_construction
msimberg Mar 4, 2026
d2d8faf
Update array_ns_from_array after merge
msimberg Mar 4, 2026
95a676f
Update tested fields in test_parallel_grid_manager.py after merge
msimberg Mar 4, 2026
47d0e63
Merge branch 'main' into distributed-tests-dace-gpu
nfarabullini Mar 4, 2026
ce21e8f
modified np strict references with broader array_ns
nfarabullini Mar 4, 2026
214fbe9
Simplify test_halo.py
msimberg Mar 4, 2026
0d33ee4
Remove empty pytest file
msimberg Mar 4, 2026
1f632ab
Disable r01b01 grid for testing for now
msimberg Mar 5, 2026
a62e6e3
Fix formatting
msimberg Mar 5, 2026
c367428
Ignore commented out code
msimberg Mar 5, 2026
1975443
Small cleanup refactoring in halo construction
msimberg Mar 5, 2026
19abd25
Update decomposition info with_dimension call to set_dimension
msimberg Mar 5, 2026
4bf0618
Merge branch 'main' into ci_for_standalone_driver
nfarabullini Mar 5, 2026
0d10792
Explicitly convert np.bool_ to bool
msimberg Mar 5, 2026
cecea11
adjusted tolerances
nfarabullini Mar 5, 2026
3013e78
Merge branch 'ci_for_standalone_driver' of https://github.com/C2SM/ic…
nfarabullini Mar 5, 2026
74938f3
Merge branch 'main' into distributed-tests-dace-gpu
nfarabullini Mar 5, 2026
f6fd95f
Remove unnecessary test
msimberg Mar 5, 2026
03fb537
replaced a few more np with array_ns
nfarabullini Mar 5, 2026
878db70
Update interpolation_fields.py
nfarabullini Mar 5, 2026
c449030
ran pre-commit
nfarabullini Mar 5, 2026
9460369
removed additional but unused return val
nfarabullini Mar 5, 2026
d96956a
edit for scipy func to flexible gpu/cpu func
nfarabullini Mar 5, 2026
c343334
Constrain xfail a bit more
msimberg Mar 5, 2026
c3606ae
Update interpolation_fields.py
nfarabullini Mar 5, 2026
890166a
replaced gt4py field operator within regular function to regular pyth…
nfarabullini Mar 5, 2026
81375ca
ran pre-commit
nfarabullini Mar 5, 2026
da60b19
Add domain sizes
msimberg Mar 5, 2026
5fb0b0e
small fix to bounds
nfarabullini Mar 6, 2026
6362e62
small fix to tuple
nfarabullini Mar 6, 2026
726fd50
fix to index
nfarabullini Mar 6, 2026
356f889
introduced array_ns instead of strict numpy computation in init_w
nfarabullini Mar 6, 2026
fd0c7f0
Remove rbf interpolation todo
msimberg Mar 6, 2026
b8fa94e
Merge remote-tracking branch 'origin/main' into halo_construction
msimberg Mar 6, 2026
b47aa03
edit from asnumpy() to ndarray
nfarabullini Mar 6, 2026
1869d03
additional edit from asnumpy() to ndarray
nfarabullini Mar 6, 2026
80f1fa9
Fix second halo level cell computation
msimberg Mar 6, 2026
e9fc3fd
Merge remote-tracking branch 'origin/main' into halo_construction
msimberg Mar 6, 2026
7b3e18a
potential fix
nfarabullini Mar 6, 2026
5305e2f
Merge branch 'main' into ci_for_standalone_driver
nfarabullini Mar 6, 2026
182a843
Increase distributed CI pipeline timelimits
msimberg Mar 6, 2026
79d65f2
Allow None for halo_levels
msimberg Mar 6, 2026
5a6cc8e
Add more tests for test_compute_domain_bounds_for_global_grid
msimberg Mar 6, 2026
8efe35c
Enable grid data download in distributed pipeline
msimberg Mar 6, 2026
be614a0
potential fix
nfarabullini Mar 6, 2026
5fc92d8
Merge branch 'ci_for_standalone_driver' of https://github.com/C2SM/ic…
nfarabullini Mar 6, 2026
b6314b6
more edits
nfarabullini Mar 8, 2026
3b95f9b
more edits
nfarabullini Mar 8, 2026
b1386d2
removed serialized exit point from internal code
nfarabullini Mar 8, 2026
50ebb90
small edit to equation to see if this works with gpu backend
nfarabullini Mar 9, 2026
6642aa2
new for loop implementaed instead of array_ns.sum
nfarabullini Mar 9, 2026
26fd7db
edits to array_ns and ran pre-commit
nfarabullini Mar 9, 2026
53a2585
edits for offset declaration potential issue
nfarabullini Mar 9, 2026
d6d9f30
small edit to change args position
nfarabullini Mar 9, 2026
56f9cef
Add xfails for wrong halo, interior, local indices with torus grid
msimberg Mar 9, 2026
c6cf66b
Check INTERIOR indices with icon4py domain decomposition
msimberg Mar 9, 2026
301c041
Update ci/distributed.yml
msimberg Mar 9, 2026
d77f5d9
Less verbose xfail
msimberg Mar 9, 2026
37b196b
Download r01b01 grid in ci
msimberg Mar 9, 2026
39703b3
Enable download again
msimberg Mar 9, 2026
c958a6e
small fix to index
nfarabullini Mar 9, 2026
6df6af6
Disable download again
msimberg Mar 9, 2026
08cc652
small edits to offset provider spec
nfarabullini Mar 9, 2026
115aec8
Explicitly set ICON4PY_TEST_DATA_PATH in github workflows
msimberg Mar 9, 2026
f204644
More explicit path
msimberg Mar 9, 2026
0279054
added cpu only marker
nfarabullini Mar 9, 2026
dc339dc
Enable grid download for grid download step
msimberg Mar 9, 2026
fd6034a
ran pre-commit
nfarabullini Mar 9, 2026
de2f7a5
edited ci time
nfarabullini Mar 10, 2026
7a8118a
removed backend customization
nfarabullini Mar 10, 2026
83de5f4
ran pre-commit
nfarabullini Mar 10, 2026
fc0a445
Remove todos
msimberg Mar 10, 2026
accedb7
Merge branch 'halo_construction' into distributed_standalone_driver
jcanton Mar 10, 2026
125e26f
remove these two
jcanton Mar 10, 2026
2e52f15
adjusted ci time and removed cp only constraint
nfarabullini Mar 10, 2026
3c7e718
increased ci time
nfarabullini Mar 10, 2026
6e900f9
Merge branch 'main' into ci_for_standalone_driver
nfarabullini Mar 10, 2026
8b5a614
increased ci time
nfarabullini Mar 10, 2026
2a71be6
Merge branch 'main' into distributed_standalone_driver
jcanton Mar 10, 2026
b36637f
Merge branch 'ci_for_standalone_driver' of https://github.com/C2SM/ic…
nfarabullini Mar 10, 2026
7b097e2
Merge branch 'ci_for_standalone_driver' into distributed_standalone_d…
jcanton Mar 10, 2026
2b9c823
Merge branch 'ci_for_standalone_driver' into distributed_standalone_d…
jcanton Mar 10, 2026
9f9765f
Merge branch 'distributed-tests-dace-gpu' into distributed_standalone…
jcanton Mar 10, 2026
cae3aba
these changes don't belong here but why not
jcanton Mar 10, 2026
b3cab13
code refactoring
nfarabullini Mar 10, 2026
71ccba5
further code refactoring
nfarabullini Mar 10, 2026
0ed42b7
Merge remote-tracking branch 'origin/main' into distributed-tests-dac…
msimberg Mar 10, 2026
fbd9775
wip
jcanton Mar 10, 2026
bf47258
move check_local_global_fields to parallel_helpers
jcanton Mar 10, 2026
e154538
small fix
nfarabullini Mar 10, 2026
e9fd355
fix type warning
jcanton Mar 10, 2026
77e0fc4
parallel standalone driver?
jcanton Mar 10, 2026
2158b61
small fix
nfarabullini Mar 10, 2026
9ab2b09
small fix
nfarabullini Mar 10, 2026
f17d6ab
ran pre-commit
nfarabullini Mar 10, 2026
82ebba2
wip2
jcanton Mar 10, 2026
dacc75d
Merge branch 'ci_for_standalone_driver' into distributed_standalone_d…
jcanton Mar 10, 2026
51eab0c
Merge branch 'distributed-tests-dace-gpu' into distributed_standalone…
jcanton Mar 10, 2026
a25e6f7
gt4py hack
jcanton Mar 11, 2026
3ee4e96
comment init_w
jcanton Mar 11, 2026
acd2217
comment tracer adv
jcanton Mar 11, 2026
79e6a41
update test
jcanton Mar 11, 2026
b564899
more verbose testing
jcanton Mar 11, 2026
9e2dbd7
no default exchange
jcanton Mar 11, 2026
3a5f51d
no single rank defaults
jcanton Mar 11, 2026
437c6c7
exchange to IC
jcanton Mar 11, 2026
1874a54
no need for dim prints
jcanton Mar 11, 2026
fd9f493
Add halo exchanges for jw initial condition
msimberg Mar 11, 2026
888c1ae
Remove unnecessary functools.partial
msimberg Mar 11, 2026
054b7ba
Add parallel jablonowski williamson initial condition test
msimberg Mar 11, 2026
f25e3e5
Slight cleanup
msimberg Mar 11, 2026
720e48f
add SingleNodeExchange warnings
jcanton Mar 11, 2026
87a23c5
remove unnecessary array_ns, we have the backend and xp from that
jcanton Mar 11, 2026
86e600b
fix typer
jcanton Mar 11, 2026
a38072b
update warning message
jcanton Mar 11, 2026
4f24d9b
forgot to remove from here
jcanton Mar 11, 2026
d1e5076
cleanup and wip on distributed serdata test
jcanton Mar 11, 2026
bab3d58
Add back assertions to local/global field checks
msimberg Mar 11, 2026
6a65619
add wip multi-rank ser_data test
jcanton Mar 11, 2026
552c118
wip2
jcanton Mar 11, 2026
f295368
I need this back
jcanton Mar 11, 2026
b4b20cb
add UV to IC test
jcanton Mar 12, 2026
45eb7f2
Fix halo exchanges for diagnostic state
msimberg Mar 16, 2026
a57d8f4
pick from #1012
jcanton Mar 18, 2026
5c15dd6
Merge branch 'main' into distributed_standalone_driver
jcanton Mar 19, 2026
db1dc99
restore some from main
jcanton Mar 19, 2026
758b96b
Try to restore exchanges to distributed standalone driver
msimberg Mar 19, 2026
5b126f7
Add missing exchange
msimberg Mar 20, 2026
3e1bb55
Comment out part of initial conditions for now
msimberg Mar 20, 2026
76a426e
Allow passing atol to check_local_global_fields
msimberg Mar 20, 2026
5107aa4
Use ghex release
msimberg Mar 20, 2026
e440a53
cupy/numpy compat
msimberg Mar 20, 2026
cfe8147
put back SingleNodeExchange defaults
jcanton Mar 20, 2026
88e97da
back to main for diffusion.py
jcanton Mar 20, 2026
81e3a1f
a couple more cleanups
jcanton Mar 20, 2026
f62de4a
put this back too
jcanton Mar 20, 2026
a4921e9
Merge branch 'main' into distributed_standalone_driver
jcanton Mar 25, 2026
29ea0b3
update uv.lock
jcanton Mar 25, 2026
9fc348b
small edit to fix init_w issue and ran pre-commit
nfarabullini Mar 25, 2026
14ec2ad
small pre-commit fix
nfarabullini Mar 26, 2026
c7216a9
added standalone driver to distributed tests
nfarabullini Mar 26, 2026
b4035ba
Merge branch 'main' into distributed_standalone_driver
jcanton Mar 26, 2026
c18877a
added standalone driver to distributed tests
nfarabullini Mar 26, 2026
ad08811
added backend to fixtures
nfarabullini Mar 26, 2026
6149ecc
re-introduced exchange for jablonowski_williamson call
nfarabullini Mar 26, 2026
a37dc32
Merge branch 'main' into distributed_standalone_driver
nfarabullini Mar 27, 2026
c7a5775
move initial condition test to its own file
jcanton Mar 30, 2026
1192fe6
Merge branch 'main' into distributed_standalone_driver
nfarabullini Mar 31, 2026
080859b
move connectivity from args to inside init_w
jcanton Mar 30, 2026
9762334
add exchange to w
jcanton Mar 31, 2026
efeabe3
print label
jcanton Mar 31, 2026
93dd64d
increased atol for vn
nfarabullini Mar 31, 2026
f8c1777
Merge branch 'main' into distributed_standalone_driver
nfarabullini Apr 1, 2026
3c841de
this log.info was moved
jcanton Apr 1, 2026
27557e6
rename for clarity
jcanton Apr 1, 2026
e0ac456
fix with_mpi logic
jcanton Apr 1, 2026
83dc957
fix logging in parallel_initial_condition test
jcanton Apr 1, 2026
990d4d1
fix bounds and vectorize and restructure
jcanton Apr 7, 2026
e639dba
add missing w exchange after diffusion and JW test
jcanton Apr 7, 2026
aba7e2f
colorful output
jcanton Apr 7, 2026
325c318
exchange all
jcanton Apr 8, 2026
46c877e
bugfix missing exchange wgtfac_e
jcanton Apr 10, 2026
68bd552
add halo_1 and _2 checks
jcanton Apr 10, 2026
0a22c0d
fix newline
jcanton Apr 10, 2026
f2f63ba
fix global reduction domains and respective tests
jcanton Apr 10, 2026
e713b64
put back in order
jcanton Apr 10, 2026
1f5e921
add todos
jcanton Apr 10, 2026
1456201
todos and optimistic tolerance
jcanton Apr 10, 2026
115e8e2
global max of max cfl number and modify logging
OngChia Apr 13, 2026
9fc9f46
global mass and clean up
OngChia Apr 13, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion ci/distributed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ build_distributed:
- ci/scripts/ci-mpi-wrapper.sh pytest -sv -k mpi_tests --with-mpi --backend=$BACKEND model/$COMPONENT --level=$LEVEL
parallel:
matrix:
- COMPONENT: [atmosphere/diffusion, atmosphere/dycore, common]
- COMPONENT: [atmosphere/diffusion, atmosphere/dycore, common, standalone_driver]
# TODO(msimberg): Enable dace_gpu when compilation doesn't take as long
# or when we can cache across CI jobs.
BACKEND: [embedded, gtfn_cpu, dace_cpu, gtfn_gpu]
Expand All @@ -113,6 +113,12 @@ build_distributed:
- if: $COMPONENT == 'atmosphere/dycore'
variables:
SLURM_TIMELIMIT: '00:15:00'
- if: $COMPONENT == 'standalone_driver'
variables:
SLURM_TIMELIMIT: '00:50:00'
- if: $COMPONENT == 'standalone_driver'
variables:
SLURM_TIMELIMIT: '00:50:00'
- when: on_success
variables:
SLURM_TIMELIMIT: '00:45:00'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"2021-06-20T12:00:10.000",
),
(definitions.Experiments.EXCLAIM_APE, "2000-01-01T00:00:02.000", "2000-01-01T00:00:02.000"),
(definitions.Experiments.JW, "2008-09-01T00:05:00.000", "2008-09-01T00:05:00.000"),
],
)
@pytest.mark.parametrize("ndyn_substeps", [2])
Expand Down Expand Up @@ -142,6 +143,12 @@ def test_parallel_diffusion(
prognostic_state=prognostic_state,
dtime=dtime,
)
if experiment == definitions.Experiments.JW:
# TODO (jcanton,ongchia): move this exchange inside
# diffusion.run with the proper DiffusionConfig equivalent to
# the fortran
# IF ( linit .OR. (iforcing /= inwp .AND. iforcing /= iaes) ) THEN
exchange.exchange(dims.CellDim, prognostic_state.w)
_log.info(f"rank={processor_props.rank}/{processor_props.comm_size}: diffusion run ")

utils.verify_diffusion_fields(
Expand Down
83 changes: 78 additions & 5 deletions model/common/src/icon4py/model/common/decomposition/definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@
import dataclasses
import functools
import logging
import warnings
from collections.abc import Sequence
from enum import Enum
from types import ModuleType
from typing import Any, Literal, Protocol, TypeAlias, overload, runtime_checkable
from typing import Any, ClassVar, Literal, Protocol, TypeAlias, overload, runtime_checkable

import dace # type: ignore[import-untyped]
import gt4py.next as gtx
Expand Down Expand Up @@ -160,6 +161,8 @@ class EntryType(int, Enum):
ALL = 0
OWNED = 1
HALO = 2
HALO_LEVEL_1 = 11
HALO_LEVEL_2 = 12

@utils.chainable
def set_dimension(
Expand Down Expand Up @@ -187,6 +190,14 @@ def local_index(
index = self._to_local_index(dim)
mask = self._owner_mask[dim]
return index[~mask]
case DecompositionInfo.EntryType.HALO_LEVEL_1:
index = self._to_local_index(dim)
mask = self.halo_level_mask(dim=dim, level=DecompositionFlag.FIRST_HALO_LEVEL)
return index[mask]
case DecompositionInfo.EntryType.HALO_LEVEL_2:
index = self._to_local_index(dim)
mask = self.halo_level_mask(dim=dim, level=DecompositionFlag.SECOND_HALO_LEVEL)
return index[mask]
case DecompositionInfo.EntryType.OWNED:
index = self._to_local_index(dim)
mask = self._owner_mask[dim]
Expand All @@ -212,6 +223,12 @@ def global_index(
return self._global_index[dim][self._owner_mask[dim]]
case DecompositionInfo.EntryType.HALO:
return self._global_index[dim][~self._owner_mask[dim]]
case DecompositionInfo.EntryType.HALO_LEVEL_1:
mask = self.halo_level_mask(dim=dim, level=DecompositionFlag.FIRST_HALO_LEVEL)
return self._global_index[dim][mask]
case DecompositionInfo.EntryType.HALO_LEVEL_2:
mask = self.halo_level_mask(dim=dim, level=DecompositionFlag.SECOND_HALO_LEVEL)
return self._global_index[dim][mask]
case _:
raise NotImplementedError()

Expand Down Expand Up @@ -408,12 +425,25 @@ def __str__(self) -> str:

@dataclasses.dataclass
class SingleNodeExchange(ExchangeRuntime):
_warning_emitted: ClassVar[bool] = False

@classmethod
def _warn_if_used(cls, *, stacklevel: int = 3) -> None:
if not cls._warning_emitted:
warnings.warn(
"***** SingleNodeExchange is in use; HALO EXCHANGE IS RUNNING IN SINGLE-NODE *****",
RuntimeWarning,
stacklevel=stacklevel,
)
cls._warning_emitted = True
Comment on lines +428 to +438
Copy link
Copy Markdown
Contributor Author

@jcanton jcanton Mar 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: remove before merging? or disable somehow? talk with @msimberg


def start(
self,
dim: gtx.Dimension,
*fields: gtx.Field | data_alloc.NDArray,
stream: StreamLike = DEFAULT_STREAM,
) -> ExchangeResult:
self._warn_if_used()
return SingleNodeResult()

def my_rank(self) -> int:
Expand Down Expand Up @@ -563,11 +593,19 @@ def max(
) -> state_utils.ScalarType: ...

def sum(
self, buffer: data_alloc.NDArray, array_ns: ModuleType = np
self,
buffer: data_alloc.NDArray,
lower_bound: gtx.int32,
upper_bound: gtx.int32,
array_ns: ModuleType = np,
) -> state_utils.ScalarType: ...

def mean(
self, buffer: data_alloc.NDArray, array_ns: ModuleType = np
self,
buffer: data_alloc.NDArray,
lower_bound: gtx.int32,
upper_bound: gtx.int32,
array_ns: ModuleType = np,
) -> state_utils.ScalarType: ...


Expand All @@ -578,10 +616,22 @@ def min(self, buffer: data_alloc.NDArray, array_ns: ModuleType = np) -> state_ut
def max(self, buffer: data_alloc.NDArray, array_ns: ModuleType = np) -> state_utils.ScalarType:
return array_ns.max(buffer).item()

def sum(self, buffer: data_alloc.NDArray, array_ns: ModuleType = np) -> state_utils.ScalarType:
def sum(
self,
buffer: data_alloc.NDArray,
lower_bound: gtx.int32,
upper_bound: gtx.int32,
array_ns: ModuleType = np,
) -> state_utils.ScalarType:
return array_ns.sum(buffer).item()

def mean(self, buffer: data_alloc.NDArray, array_ns: ModuleType = np) -> state_utils.ScalarType:
def mean(
self,
buffer: data_alloc.NDArray,
lower_bound: gtx.int32,
upper_bound: gtx.int32,
array_ns: ModuleType = np,
) -> state_utils.ScalarType:
return array_ns.sum(buffer).item() / buffer.size


Expand Down Expand Up @@ -673,5 +723,28 @@ class DecompositionFlag(int, Enum):
"""


class ParallelLogger(logging.Filter):
def __init__(
self,
process_properties: ProcessProperties | None = None,
print_distributed_debug_msg: bool = False,
) -> None:
super().__init__()
self._rank_info = ""
self._print_distributed_debug_msg = print_distributed_debug_msg
self._rank_id = 0
if process_properties and process_properties.comm_size > 1:
self._rank_info = f"rank={process_properties.rank}/{process_properties.comm_size} [{process_properties.comm_name}] "
self._rank_id = process_properties.rank

def filter(self, record: logging.LogRecord) -> bool:
record.rank = self._rank_info
return (
True
if self._rank_id == 0
else (self._print_distributed_debug_msg and record.levelno == logging.DEBUG)
)


single_node_default = SingleNodeExchange()
single_node_reductions = SingleNodeReductions()
Original file line number Diff line number Diff line change
Expand Up @@ -85,18 +85,6 @@ def _get_current_comm_or_comm_world(comm_id: CommId) -> mpi4py.MPI.Comm:
return MPICommProcessProperties(current_comm)


class ParallelLogger(logging.Filter):
def __init__(self, process_properties: definitions.ProcessProperties | None = None) -> None:
super().__init__()
self._rank_info = ""
if process_properties and process_properties.comm_size > 1:
self._rank_info = f"rank={process_properties.rank}/{process_properties.comm_size} [{process_properties.comm_name}] "

def filter(self, record: logging.LogRecord) -> bool:
record.rank = self._rank_info
return True


@definitions.get_processor_properties.register(definitions.MultiNodeRun)
def get_multinode_properties(
s: definitions.MultiNodeRun, comm_id: CommId = None
Expand Down Expand Up @@ -489,7 +477,15 @@ def max(self, buffer: data_alloc.NDArray, array_ns: ModuleType = np) -> state_ut
array_ns,
)

def sum(self, buffer: data_alloc.NDArray, array_ns: ModuleType = np) -> state_utils.ScalarType:
def sum(
self,
buffer: data_alloc.NDArray,
lower_bound: gtx.int32,
upper_bound: gtx.int32,
array_ns: ModuleType = np,
) -> state_utils.ScalarType:
# TODO (nfarabullini): use owned mask instead of upper lower bound, and move as "internal argument"
buffer = buffer[lower_bound:upper_bound]
if self._calc_buffer_size(buffer, array_ns) == 0:
raise ValueError("global_sum requires a non-empty buffer")
return self._reduce(
Expand All @@ -499,7 +495,15 @@ def sum(self, buffer: data_alloc.NDArray, array_ns: ModuleType = np) -> state_ut
array_ns,
)

def mean(self, buffer: data_alloc.NDArray, array_ns: ModuleType = np) -> state_utils.ScalarType:
def mean(
self,
buffer: data_alloc.NDArray,
lower_bound: gtx.int32,
upper_bound: gtx.int32,
array_ns: ModuleType = np,
) -> state_utils.ScalarType:
# TODO (nfarabullini): use owned mask instead of upper lower bound, and move as "internal argument"
buffer = buffer[lower_bound:upper_bound]
global_buffer_size = self._calc_buffer_size(buffer, array_ns)
if global_buffer_size == 0:
raise ValueError("global_mean requires a non-empty buffer")
Expand Down
18 changes: 18 additions & 0 deletions model/common/src/icon4py/model/common/grid/geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,9 @@ def __init__(
self._decomposition_info = decomposition_info
self._attrs = metadata
self._geometry_type: base.GeometryType = grid.global_properties.geometry_type
self._cell_domain = h_grid.domain(dims.CellDim)
self._edge_domain = h_grid.domain(dims.EdgeDim)
self._vertex_domain = h_grid.domain(dims.VertexDim)
self._exchange = exchange
self._global_reductions = global_reductions
log.info(
Expand Down Expand Up @@ -323,6 +325,10 @@ def _register_computed_fields(self) -> None:
deps={
"buffer": attrs.EDGE_LENGTH,
},
params={
"lower_bound": self._grid.start_index(self._edge_domain(h_grid.Zone.LOCAL)),
"upper_bound": self._grid.end_index(self._edge_domain(h_grid.Zone.LOCAL)),
},
fields=(attrs.MEAN_EDGE_LENGTH,),
)
self.register_provider(mean_edge_length_np)
Expand All @@ -336,6 +342,10 @@ def _register_computed_fields(self) -> None:
deps={
"buffer": attrs.DUAL_EDGE_LENGTH,
},
params={
"lower_bound": self._grid.start_index(self._edge_domain(h_grid.Zone.LOCAL)),
"upper_bound": self._grid.end_index(self._edge_domain(h_grid.Zone.LOCAL)),
},
fields=(attrs.MEAN_DUAL_EDGE_LENGTH,),
)
self.register_provider(mean_dual_edge_length_np)
Expand All @@ -349,6 +359,10 @@ def _register_computed_fields(self) -> None:
deps={
"buffer": attrs.CELL_AREA,
},
params={
"lower_bound": self._grid.start_index(self._cell_domain(h_grid.Zone.LOCAL)),
"upper_bound": self._grid.end_index(self._cell_domain(h_grid.Zone.LOCAL)),
},
fields=(attrs.MEAN_CELL_AREA,),
)
self.register_provider(mean_cell_area_np)
Expand All @@ -362,6 +376,10 @@ def _register_computed_fields(self) -> None:
deps={
"buffer": attrs.DUAL_AREA,
},
params={
"lower_bound": self._grid.start_index(self._vertex_domain(h_grid.Zone.LOCAL)),
"upper_bound": self._grid.end_index(self._vertex_domain(h_grid.Zone.LOCAL)),
},
fields=(attrs.MEAN_DUAL_AREA,),
)
self.register_provider(mean_dual_cell_area_np)
Expand Down
4 changes: 2 additions & 2 deletions model/common/src/icon4py/model/common/grid/grid_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ def __call__(
allocator: gtx_typing.Allocator | None,
keep_skip_values: bool,
decomposer: decomp.Decomposer = _single_node_decomposer,
run_properties=_single_process_props,
):
run_properties: decomposition.ProcessProperties = _single_process_props,
) -> None:
if not run_properties.is_single_rank() and isinstance(
decomposer, decomp.SingleNodeDecomposer
):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# ICON4Py - ICON inspired code in Python and GT4Py
#
# Copyright (c) 2022-2024, ETH Zurich and MeteoSwiss
# All rights reserved.
#
# Please, refer to the LICENSE file in the root directory.
# SPDX-License-Identifier: BSD-3-Clause

from types import ModuleType

from icon4py.model.common.utils import data_allocation as data_alloc


def compute_directional_derivative_on_cells(
cell_field: data_alloc.NDArray,
e2c: data_alloc.NDArray,
inv_dual_edge_length: data_alloc.NDArray,
lb_e: int,
ub_e: int,
num_edges: int,
array_ns: ModuleType,
) -> data_alloc.NDArray:
"""
Compute directional derivative of a cell centered variable with respect to
direction normal to triangle edge.
"""
result = array_ns.zeros((num_edges,))
result[lb_e:ub_e] = (
cell_field[e2c[lb_e:ub_e, 1]] - cell_field[e2c[lb_e:ub_e, 0]]
) * inv_dual_edge_length[lb_e:ub_e]
return result


def interpolate_edges_to_cell(
edge_field: data_alloc.NDArray,
c2e: data_alloc.NDArray,
e2c: data_alloc.NDArray,
edge_cell_length: data_alloc.NDArray,
primal_edge_length: data_alloc.NDArray,
cell_area: data_alloc.NDArray,
ub_c: int,
num_cells: int,
array_ns: ModuleType,
) -> data_alloc.NDArray:
"""
Compute interpolation of scalar fields from edge points to cell centers.
"""
e_inn_c = array_ns.zeros((num_cells, 3))
jc_indices = array_ns.arange(ub_c)[:, array_ns.newaxis]
c2e_local = c2e[:ub_c]
idx_ce = (e2c[c2e_local][:, :, 0] != jc_indices).astype(int)
e_inn_c[:ub_c] = (
edge_cell_length[c2e_local, idx_ce]
* primal_edge_length[c2e_local]
/ cell_area[:ub_c, array_ns.newaxis]
)
return array_ns.sum(edge_field[c2e] * e_inn_c, axis=1)
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,7 @@ def _register_computed_fields(self) -> None: # noqa: PLR0915 [too-many-statemen
),
},
fields={"wgtfac_e": attrs.WGTFAC_E},
do_exchange=False,
do_exchange=True,
)
self.register_provider(compute_wgtfac_e)

Expand Down
Loading