Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix int types when writing restart files #300

Merged
merged 1 commit into from
Nov 24, 2023
Merged
Changes from all commits
Commits
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
22 changes: 12 additions & 10 deletions xbout/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -492,21 +492,23 @@ def _split_into_restarts(ds, variables, savepath, nxpe, nype, tind, prefix, over
if isinstance(value, str):
# Write strings as byte-strings so BOUT++ can read them
value = value.encode()
elif isinstance(value, int):
value = np.intc(value)

restart_ds[v] = value

# These variables need to be altered, because they depend on the number of
# files and/or the rank of this file.
restart_ds["MXSUB"] = mxsub
restart_ds["MYSUB"] = mysub
restart_ds["NXPE"] = nxpe
restart_ds["NYPE"] = nype
restart_ds["PE_XIND"] = xproc
restart_ds["PE_YIND"] = yproc
restart_ds["hist_hi"] = hist_hi
restart_ds["PE_XIND"] = xproc
restart_ds["PE_YIND"] = yproc
restart_ds["MYPE"] = yproc * nxpe + xproc
restart_ds["MXSUB"] = np.intc(mxsub)
restart_ds["MYSUB"] = np.intc(mysub)
restart_ds["NXPE"] = np.intc(nxpe)
restart_ds["NYPE"] = np.intc(nype)
restart_ds["PE_XIND"] = np.intc(xproc)
restart_ds["PE_YIND"] = np.intc(yproc)
restart_ds["hist_hi"] = np.intc(hist_hi)
restart_ds["PE_XIND"] = np.intc(xproc)
restart_ds["PE_YIND"] = np.intc(yproc)
restart_ds["MYPE"] = np.intc(yproc * nxpe + xproc)

# tt is the simulation time where the restart happens
restart_ds["tt"] = tt
Expand Down