Skip to content

Commit d1f42b7

Browse files
committed
Moving swarms 'procCount' cache.
This was an attribute of the hdf5 file, now it's a dataset. Due to issue #749.
1 parent 591ca29 commit d1f42b7

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

src/underworld/swarm/_swarm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ def load( self, filename, collective=False, try_optimise=True ):
359359
size = dset.shape[0] # number of particles in h5 file
360360

361361
if try_optimise:
362-
procCount = h5f.attrs.get('proc_offset')
362+
procCount = h5_get_dataset(h5f, 'proc_offset')
363363
if procCount is not None and nProcs == len(procCount):
364364
for p_i in range(rank):
365365
offset += procCount[p_i]

src/underworld/swarm/_swarmvariable.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,8 @@ def save( self, filename, collective=False, swarmHandle=None, units=None, **kwar
491491
h5f["swarm"] = h5py.ExternalLink(sFilename, "./")
492492

493493
# also write proc offsets - used for loading from checkpoint
494-
h5f.attrs["proc_offset"] = procCount
494+
pdata = h5_require_dataset(h5f, "proc_offset", shape=(len(procCount),), dtype=np.int64)
495+
pdata[:] = procCount
495496
h5f.attrs["units"] = str(units)
496497

497498
for kwarg, val in kwargs.items():

0 commit comments

Comments
 (0)