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

Removed fparser stop concatenation workround after fparser update #386

Merged
merged 2 commits into from
Feb 7, 2025
Merged
Show file tree
Hide file tree
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
6 changes: 1 addition & 5 deletions run_configs/lfric/atm.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
from fab.tools import ToolBox

from grab_lfric import lfric_source_config, gpl_utils_source_config
from lfric_common import (API, configurator, fparser_workaround_stop_concatenation,
get_transformation_script)
from lfric_common import (API, configurator, get_transformation_script)

logger = logging.getLogger('fab')

Expand Down Expand Up @@ -250,9 +249,6 @@ def file_filtering(config):
api=API,
)

# todo: do we need this one in here?
fparser_workaround_stop_concatenation(state)

analyse(
state,
root_symbol='lfric_atm',
Expand Down
5 changes: 1 addition & 4 deletions run_configs/lfric/gungho.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
from fab.tools import ToolBox

from grab_lfric import lfric_source_config, gpl_utils_source_config
from lfric_common import (API, configurator, fparser_workaround_stop_concatenation,
get_transformation_script)
from lfric_common import (API, configurator, get_transformation_script)

logger = logging.getLogger('fab')

Expand Down Expand Up @@ -75,8 +74,6 @@
api=API,
)

fparser_workaround_stop_concatenation(state)

analyse(
state,
root_symbol='gungho_model',
Expand Down
32 changes: 0 additions & 32 deletions run_configs/lfric/lfric_common.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import logging
import os
import shutil
from typing import Optional
from pathlib import Path

from fab.artefacts import ArtefactSet
from fab.build_config import BuildConfig
from fab.steps import step
from fab.steps.find_source_files import find_source_files
Expand Down Expand Up @@ -84,36 +82,6 @@ def configurator(config, lfric_source: Path, gpl_utils_source: Path, rose_meta_c
find_source_files(config, source_root=config_dir)


# ============================================================================
@step
def fparser_workaround_stop_concatenation(config):
"""
fparser can't handle string concat in a stop statement. This step is
a workaround.

https://github.com/stfc/fparser/issues/330

"""
feign_path = None
for file_path in config.artefact_store[ArtefactSet.FORTRAN_BUILD_FILES]:
if file_path.name == 'feign_config_mod.f90':
feign_path = file_path
break
else:
raise RuntimeError("Could not find 'feign_config_mod.f90'.")

# rename "broken" version
broken_version = feign_path.with_suffix('.broken')
shutil.move(feign_path, broken_version)

# make fixed version
bad = "_config: '// &\n 'Unable to close temporary file'"
good = "_config: Unable to close temporary file'"

open(feign_path, 'wt').write(
open(broken_version, 'rt').read().replace(bad, good))


# ============================================================================
def get_transformation_script(fpath: Path,
config: BuildConfig) -> Optional[Path]:
Expand Down
4 changes: 1 addition & 3 deletions run_configs/lfric/mesh_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from fab.steps.psyclone import psyclone, preprocess_x90
from fab.tools import ToolBox

from lfric_common import API, configurator, fparser_workaround_stop_concatenation
from lfric_common import API, configurator
from grab_lfric import lfric_source_config, gpl_utils_source_config


Expand Down Expand Up @@ -60,8 +60,6 @@
api=API,
)

fparser_workaround_stop_concatenation(state)

analyse(
state,
root_symbol=['cubedsphere_mesh_generator', 'planar_mesh_generator', 'summarise_ugrid'],
Expand Down