Skip to content

Commit

Permalink
fix(keystring records): fixed problem with keystring records containi…
Browse files Browse the repository at this point in the history
…ng multiple keywords (#1266)
  • Loading branch information
spaulins-usgs committed Oct 16, 2021
1 parent fc09435 commit 0d21b92
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 16 deletions.
42 changes: 28 additions & 14 deletions flopy/mf6/data/mfdatalist.py
Original file line number Diff line number Diff line change
Expand Up @@ -1045,26 +1045,38 @@ def _get_file_entry_record(
ks_structs = [keystr_struct]
ks_struct_index = 0
max_index = len(ks_structs) - 1
for data_index in range(
index, data_complete_len
):
data_index = index
while data_index != data_complete_len:
if data_line[data_index] is not None:
try:
k_data_item = ks_structs[
ks_struct_index
]
text_line.append(
to_string(
data_line[data_index],
k_data_item.type,
self._simulation_data,
self._data_dimensions,
k_data_item.is_cellid,
k_data_item.possible_cellid,
k_data_item,
self._simulation_data.verify_data,
if (
k_data_item.type
== DatumType.keyword
):
if (
data_line[data_index]
is not None
):
text_line.append(
k_data_item.display_name
)
else:
text_line.append(
to_string(
data_line[data_index],
k_data_item.type,
self._simulation_data,
self._data_dimensions,
k_data_item.is_cellid,
k_data_item.possible_cellid,
k_data_item,
self._simulation_data.verify_data,
)
)
)
data_index += 1
except Exception as ex:
message = (
"An error occurred "
Expand Down Expand Up @@ -1105,6 +1117,8 @@ def _get_file_entry_record(
# increment until last record
# entry then repeat last entry
ks_struct_index += 1
else:
data_index += 1
index = data_index
elif data_val is not None and (
not isinstance(data_val, float)
Expand Down
12 changes: 10 additions & 2 deletions flopy/mf6/data/mffileaccess.py
Original file line number Diff line number Diff line change
Expand Up @@ -1733,7 +1733,9 @@ def load_list_line(
data_item_ks, MFDataStructure
):
dis = data_item_ks.data_item_structures
for ks_data_item in dis:
for idx, ks_data_item in enumerate(
dis
):
if (
ks_data_item.type
!= DatumType.keyword
Expand All @@ -1758,6 +1760,12 @@ def load_list_line(
data_line,
zero_based=zero_based,
)
elif (
idx > 0
and ks_data_item.type
== DatumType.keyword
):
data_index += 1
while data_index < arr_line_len:
try:
# append remaining data
Expand All @@ -1777,7 +1785,7 @@ def load_list_line(
repeat_count,
current_key,
data_line,
zero_base=zero_based,
zero_based=zero_based,
)
except MFDataException:
break
Expand Down

0 comments on commit 0d21b92

Please sign in to comment.