Skip to content

Commit

Permalink
Merge pull request #103 from boutproject/fix-restart-file-creation
Browse files Browse the repository at this point in the history
Fix creating restart files for BOUT++ 5
  • Loading branch information
bendudson committed Feb 16, 2024
2 parents a043a2b + 8128e36 commit 9e603a2
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
6 changes: 3 additions & 3 deletions boutdata/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -695,9 +695,9 @@ def __init__(
comments = []
if inline_comment is not None:
parent_section.inline_comments[sectionname] = inline_comment
parent_section._comment_whitespace[
sectionname
] = comment_whitespace
parent_section._comment_whitespace[sectionname] = (
comment_whitespace
)
else:
# A key=value pair

Expand Down
1 change: 1 addition & 0 deletions boutdata/gen_surface.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Flux surface generator for tokamak grid files
"""

from __future__ import print_function

import numpy as np
Expand Down
8 changes: 8 additions & 0 deletions boutdata/restart.py
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,14 @@ def create(
# This attribute results in the correct (x,y,z) dimension labels
data_slice.attributes["bout_type"] = "Field3D"

# The presence of `time_dimension` triggers BOUT++ to
# save field with a time dimension, which breaks
# subsequent restart files. `current_time_index` just
# doesn't make sense for restart files
for bad_attr in ["current_time_index", "time_dimension"]:
if bad_attr in data.attributes:
data_slice.attributes.pop(bad_attr)

outfile.write(var, data_slice)

infile.close()
Expand Down

0 comments on commit 9e603a2

Please sign in to comment.