Skip to content

Commit 9e603a2

Browse files
authored
Merge pull request #103 from boutproject/fix-restart-file-creation
Fix creating restart files for BOUT++ 5
2 parents a043a2b + 8128e36 commit 9e603a2

3 files changed

Lines changed: 12 additions & 3 deletions

File tree

boutdata/data.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -695,9 +695,9 @@ def __init__(
695695
comments = []
696696
if inline_comment is not None:
697697
parent_section.inline_comments[sectionname] = inline_comment
698-
parent_section._comment_whitespace[
699-
sectionname
700-
] = comment_whitespace
698+
parent_section._comment_whitespace[sectionname] = (
699+
comment_whitespace
700+
)
701701
else:
702702
# A key=value pair
703703

boutdata/gen_surface.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""Flux surface generator for tokamak grid files
22
33
"""
4+
45
from __future__ import print_function
56

67
import numpy as np

boutdata/restart.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,14 @@ def create(
527527
# This attribute results in the correct (x,y,z) dimension labels
528528
data_slice.attributes["bout_type"] = "Field3D"
529529

530+
# The presence of `time_dimension` triggers BOUT++ to
531+
# save field with a time dimension, which breaks
532+
# subsequent restart files. `current_time_index` just
533+
# doesn't make sense for restart files
534+
for bad_attr in ["current_time_index", "time_dimension"]:
535+
if bad_attr in data.attributes:
536+
data_slice.attributes.pop(bad_attr)
537+
530538
outfile.write(var, data_slice)
531539

532540
infile.close()

0 commit comments

Comments
 (0)