Skip to content

Commit

Permalink
pack_sim - Fix bug related to inline comment after Eclipse section ke…
Browse files Browse the repository at this point in the history
…ywords (#544)

* Fix bug with inline comment after section keyword
* Add inline comment to Reek Eclipse case
  • Loading branch information
alifbe authored Jun 1, 2023
1 parent 0c80ede commit d072f09
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
21 changes: 11 additions & 10 deletions src/subscript/pack_sim/pack_sim.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ def inspect_file(

# Remove comments if required
line_strip = _remove_comments(clear_comments, line_strip)
line_strip_no_comment = _remove_comments(True, line_strip).strip()
line = _remove_comments(clear_comments, line)

if (
Expand Down Expand Up @@ -443,43 +444,43 @@ def inspect_file(
new_data_file += line
if "--" in line:
print(line)
elif line_strip == "RUNSPEC" and fmu:
elif line_strip_no_comment == "RUNSPEC" and fmu:
section = "runspec/"
(packing_path / "include" / section).mkdir(exist_ok=True)
new_data_file += line
elif line_strip == "GRID" and fmu:
elif line_strip_no_comment == "GRID" and fmu:
section = "grid/"
(packing_path / "include" / section).mkdir(exist_ok=True)
new_data_file += line
elif line_strip == "EDIT" and fmu:
elif line_strip_no_comment == "EDIT" and fmu:
section = "edit/"
(packing_path / "include" / section).mkdir(exist_ok=True)
new_data_file += line
elif line_strip == "PROPS" and fmu:
elif line_strip_no_comment == "PROPS" and fmu:
section = "props/"
(packing_path / "include" / section).mkdir(exist_ok=True)
new_data_file += line
elif line_strip == "REGIONS" and fmu:
elif line_strip_no_comment == "REGIONS" and fmu:
section = "regions/"
(packing_path / "include" / section).mkdir(exist_ok=True)
new_data_file += line
elif line_strip == "SOLUTION" and fmu:
elif line_strip_no_comment == "SOLUTION" and fmu:
section = "solution/"
(packing_path / "include" / section).mkdir(exist_ok=True)
new_data_file += line
elif line_strip == "SUMMARY" and fmu:
elif line_strip_no_comment == "SUMMARY" and fmu:
section = "summary/"
(packing_path / "include" / section).mkdir(exist_ok=True)
new_data_file += line
elif line_strip == "SCHEDULE" and fmu:
elif line_strip_no_comment == "SCHEDULE" and fmu:
section = "schedule/"
(packing_path / "include" / section).mkdir(exist_ok=True)
new_data_file += line
elif line_strip == "OPTIMIZE" and fmu:
elif line_strip_no_comment == "OPTIMIZE" and fmu:
section = "optimize/"
(packing_path / "include" / section).mkdir(exist_ok=True)
new_data_file += line
elif line_strip.startswith("RESTART"):
elif line_strip_no_comment == "RESTART":
# This line defines a restart: raise a warning!
print(
"**********************************************************************"
Expand Down
2 changes: 1 addition & 1 deletion tests/data/reek/eclipse/model/2_R001_REEK-0.DATA
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ NORSSPEC
--GRID SECTION
-------------------------------------------------------------------------

GRID
GRID -- Grid Section

--Disable echoing of the input file
NOECHO
Expand Down

0 comments on commit d072f09

Please sign in to comment.