Skip to content

Commit

Permalink
Restyling.
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthewHambley committed Jul 1, 2024
1 parent b585f26 commit 48c3c72
Show file tree
Hide file tree
Showing 22 changed files with 1,209 additions and 614 deletions.
6 changes: 4 additions & 2 deletions run_configs/gcom/grab_gcom.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
if __name__ == '__main__':

# note: we can add arguments to grab_config.arg_parser here
# todo: do a real example of this in one of the configs, or at least in the docs.
# todo: do a real example of this in one of the configs, or at least in
# the docs.

with grab_config:
fcm_export(grab_config, src='fcm:gcom.xm_tr/build', revision=revision, dst_label="gcom")
fcm_export(grab_config, src='fcm:gcom.xm_tr/build',
revision=revision, dst_label="gcom")
26 changes: 20 additions & 6 deletions run_configs/jules/build_jules.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,14 @@ def __init__(self):

with BuildConfig(project_label=f'jules {revision} $compiler',
tool_box=tool_box) as state:
# grab the source. todo: use some checkouts instead of exports in these configs.
fcm_export(state, src='fcm:jules.xm_tr/src', revision=revision, dst_label='src')
fcm_export(state, src='fcm:jules.xm_tr/utils', revision=revision, dst_label='utils')
# grab the source. todo: use some checkouts instead of exports in
# these configs.
fcm_export(state, src='fcm:jules.xm_tr/src',
revision=revision,
dst_label='src')
fcm_export(state, src='fcm:jules.xm_tr/utils',
revision=revision,
dst_label='utils')

grab_pre_build(state, path='/not/a/real/folder', allow_fail=True),

Expand All @@ -61,9 +66,18 @@ def __init__(self):
# move inc files to the root for easy tool use
root_inc_files(state)

preprocess_fortran(state, common_flags=['-P', '-DMPI_DUMMY', '-DNCDF_DUMMY', '-I$output'])

analyse(state, root_symbol='jules', unreferenced_deps=['imogen_update_carb'])
preprocess_fortran(state,
common_flags=[
'-P',
'-DMPI_DUMMY',
'-DNCDF_DUMMY',
'-I$output'
]
)

analyse(state,
root_symbol='jules',
unreferenced_deps=['imogen_update_carb'])

compile_fortran(state)

Expand Down
428 changes: 271 additions & 157 deletions run_configs/lfric/atm.py

Large diffs are not rendered by default.

24 changes: 18 additions & 6 deletions run_configs/lfric/grab_lfric.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,30 @@
# these configs are interrogated by the build scripts
# todo: doesn't need two separate configs, they use the same project workspace
tool_box = ToolBox()
lfric_source_config = BuildConfig(project_label=f'lfric source {LFRIC_REVISION}',
tool_box=tool_box)
gpl_utils_source_config = BuildConfig(project_label=f'lfric source {LFRIC_REVISION}',
tool_box=tool_box)
lfric_source_config = BuildConfig(
project_label=f'lfric source {LFRIC_REVISION}',
tool_box=tool_box
)
gpl_utils_source_config = BuildConfig(
project_label=f'lfric source {LFRIC_REVISION}',
tool_box=tool_box
)


if __name__ == '__main__':

with lfric_source_config:
fcm_export(
lfric_source_config, src='fcm:lfric.xm_tr', revision=LFRIC_REVISION, dst_label='lfric')
lfric_source_config,
src='fcm:lfric.xm_tr',
revision=LFRIC_REVISION,
dst_label='lfric'
)

with gpl_utils_source_config:
fcm_export(
gpl_utils_source_config, src='fcm:lfric_gpl_utils.xm-tr', revision=LFRIC_REVISION, dst_label='gpl_utils')
gpl_utils_source_config,
src='fcm:lfric_gpl_utils.xm-tr',
revision=LFRIC_REVISION,
dst_label='gpl_utils'
)
99 changes: 72 additions & 27 deletions run_configs/lfric/gungho.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/usr/bin/env python3
# ##############################################################################
# ############################################################################
# (c) Crown copyright Met Office. All rights reserved.
# For further details please refer to the file COPYRIGHT
# which you should have received as part of this distribution
# ##############################################################################
# ############################################################################
import logging

from fab.build_config import BuildConfig
Expand Down Expand Up @@ -34,7 +34,8 @@ def get_transformation_script(fpath, config):
relative_path = fpath.relative_to(base_path)
except ValueError:
pass
local_transformation_script = optimisation_path / (relative_path.with_suffix('.py'))
local_transformation_script = (optimisation_path
/ (relative_path.with_suffix('.py')))
if local_transformation_script.exists():
return local_transformation_script
global_transformation_script = optimisation_path / 'global.py'
Expand All @@ -49,18 +50,40 @@ def get_transformation_script(fpath, config):

with BuildConfig(project_label='gungho $compiler $two_stage',
tool_box=ToolBox()) as state:
grab_folder(state, src=lfric_source / 'infrastructure/source/', dst_label='')
grab_folder(state, src=lfric_source / 'components/driver/source/', dst_label='')
grab_folder(state, src=lfric_source / 'components' / 'inventory' / 'source', dst_label='')
grab_folder(state, src=lfric_source / 'components/science/source/', dst_label='')
grab_folder(state, src=lfric_source / 'components/lfric-xios/source/', dst_label='')
grab_folder(state, src=lfric_source / 'gungho/source/', dst_label='')
grab_folder(state, src=lfric_source / 'um_physics/source/', dst_label='')
grab_folder(state, src=lfric_source / 'miniapps' / 'gungho_model' / 'source', dst_label='')
grab_folder(state, src=lfric_source / 'miniapps' / 'gungho_model' / 'optimisation',
grab_folder(state,
src=lfric_source / 'infrastructure/source/',
dst_label='')
grab_folder(state,
src=lfric_source / 'components/driver/source/',
dst_label='')
grab_folder(state,
src=lfric_source / 'components' / 'inventory' / 'source',
dst_label='')
grab_folder(state,
src=lfric_source / 'components/science/source/',
dst_label='')
grab_folder(state,
src=lfric_source / 'components/lfric-xios/source/',
dst_label='')
grab_folder(state,
src=lfric_source / 'gungho/source/',
dst_label='')
grab_folder(state,
src=lfric_source / 'um_physics/source/',
dst_label='')
grab_folder(state,
src=lfric_source / 'miniapps' / 'gungho_model' / 'source',
dst_label='')
grab_folder(state,
src=lfric_source / 'miniapps' / 'gungho_model'
/ 'optimisation',
dst_label='optimisation')
grab_folder(state, src=lfric_source / 'jules/source/', dst_label='')
grab_folder(state, src=lfric_source / 'socrates/source/', dst_label='')
grab_folder(state,
src=lfric_source / 'jules/source/',
dst_label='')
grab_folder(state,
src=lfric_source / 'socrates/source/',
dst_label='')

# generate more source files in source and source/configuration
configurator(
Expand All @@ -72,15 +95,24 @@ def get_transformation_script(fpath, config):
/ 'HEAD' / 'rose-meta.conf',
)

find_source_files(state, path_filters=[Exclude('unit-test', '/test/')])
find_source_files(state,
path_filters=[
Exclude('unit-test', '/test/')
])

preprocess_fortran(
state,
common_flags=[
'-DRDEF_PRECISION=64', '-DR_SOLVER_PRECISION=64', '-DR_TRAN_PRECISION=64', '-DUSE_XIOS',
])
'-DRDEF_PRECISION=64',
'-DR_SOLVER_PRECISION=64',
'-DR_TRAN_PRECISION=64',
'-DUSE_XIOS',
]
)

preprocess_x90(state, common_flags=['-DRDEF_PRECISION=64', '-DUSE_XIOS', '-DCOUPLED'])
preprocess_x90(state, common_flags=['-DRDEF_PRECISION=64',
'-DUSE_XIOS',
'-DCOUPLED'])

psyclone(
state,
Expand All @@ -94,7 +126,12 @@ def get_transformation_script(fpath, config):
analyse(
state,
root_symbol='gungho_model',
ignore_mod_deps=['netcdf', 'MPI', 'yaxt', 'pfunit_mod', 'xios', 'mod_wait'],
ignore_mod_deps=['netcdf',
'MPI',
'yaxt',
'pfunit_mod',
'xios',
'mod_wait'],
)

compile_fortran(
Expand All @@ -105,11 +142,18 @@ def get_transformation_script(fpath, config):
'-g',
'-std=f2008',

'-Wall', '-Werror=conversion', '-Werror=unused-variable', '-Werror=character-truncation',
'-Werror=unused-value', '-Werror=tabs',

'-DRDEF_PRECISION=64', '-DR_SOLVER_PRECISION=64', '-DR_TRAN_PRECISION=64',
'-DUSE_XIOS', '-DUSE_MPI=YES',
'-Wall',
'-Werror=conversion',
'-Werror=unused-variable',
'-Werror=character-truncation',
'-Werror=unused-value',
'-Werror=tabs',

'-DRDEF_PRECISION=64',
'-DR_SOLVER_PRECISION=64',
'-DR_TRAN_PRECISION=64',
'-DUSE_XIOS',
'-DUSE_MPI=YES',
],
)

Expand All @@ -119,9 +163,10 @@ def get_transformation_script(fpath, config):
state,
flags=[
'-fopenmp',

'-lyaxt', '-lyaxt_c', '-lnetcdff', '-lnetcdf', '-lhdf5', # EXTERNAL_DYNAMIC_LIBRARIES
'-lxios', # EXTERNAL_STATIC_LIBRARIES
# EXTERNAL_DYNAMIC_LIBRARIES
'-lyaxt', '-lyaxt_c', '-lnetcdff', '-lnetcdf', '-lhdf5',
# EXTERNAL_STATIC_LIBRARIES
'-lxios',
'-lstdc++',
],
)
28 changes: 20 additions & 8 deletions run_configs/lfric/lfric_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import shutil
from pathlib import Path

from fab.build_config import BuildConfig
from fab.steps import step
from fab.tools import Category, Tool

Expand All @@ -23,12 +24,17 @@ def check_available(self):

# todo: is this part of psyclone? if so, put it in the psyclone step module?
@step
def configurator(config, lfric_source: Path, gpl_utils_source: Path, rose_meta_conf: Path, config_dir=None):
def configurator(config : BuIldConfig,
lfric_source: Path,
gpl_utils_source: Path,
rose_meta_conf: Path,
config_dir=None):

rose_picker_tool = gpl_utils_source / 'rose_picker/rose_picker'
gen_namelist_tool = lfric_source / 'infrastructure/build/tools/GenerateNamelist'
gen_loader_tool = lfric_source / 'infrastructure/build/tools/GenerateLoader'
gen_feigns_tool = lfric_source / 'infrastructure/build/tools/GenerateFeigns'
build_tools = lfric_source / 'infrastructure/build/tools'
gen_namelist_tool = build_tools / 'GenerateNamelist'
gen_loader_tool = build_tools / 'GenerateLoader'
gen_feigns_tool = build_tools / 'GenerateFeigns'

config_dir = config_dir or config.source_root / 'configuration'

Expand All @@ -37,7 +43,8 @@ def configurator(config, lfric_source: Path, gpl_utils_source: Path, rose_meta_c
env['PYTHONPATH'] += f':{rose_lfric_path}'

# "rose picker"
# creates rose-meta.json and config_namelists.txt in gungho/source/configuration
# creates rose-meta.json and config_namelists.txt in
# gungho/source/configuration
logger.info('rose_picker')
rose_picker = Script(rose_picker_tool)
rose_picker.run(additional_parameters=[str(rose_meta_conf),
Expand All @@ -56,7 +63,10 @@ def configurator(config, lfric_source: Path, gpl_utils_source: Path, rose_meta_c
# create configuration_mod.f90 in source root
logger.info('GenerateLoader')
gen_loader = Script(gen_loader_tool)
names = [name.strip() for name in open(config_dir / 'config_namelists.txt').readlines()]
names = [
name.strip()
for name in open(config_dir / 'config_namelists.txt').readlines()
]
configuration_mod_fpath = config.source_root / 'configuration_mod.f90'
gen_loader.run(additional_parameters=[configuration_mod_fpath,
*names])
Expand All @@ -70,7 +80,8 @@ def configurator(config, lfric_source: Path, gpl_utils_source: Path, rose_meta_c

# put the generated source into an artefact
# todo: we shouldn't need to do this, should we?
# it's just going to be found in the source folder with everything else.
# it's just going to be found in the source folder with everything
# else.
config._artefact_store['configurator_output'] = [
configuration_mod_fpath,
feign_config_mod_fpath
Expand All @@ -80,7 +91,8 @@ def configurator(config, lfric_source: Path, gpl_utils_source: Path, rose_meta_c
@step
def fparser_workaround_stop_concatenation(config):
"""
fparser can't handle string concat in a stop statement. This step is a workaround.
fparser can't handle string concat in a stop statement. This step is a
workaround.
https://github.com/stfc/fparser/issues/330
Expand Down
39 changes: 28 additions & 11 deletions run_configs/lfric/mesh_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,30 @@
lfric_source = lfric_source_config.source_root / 'lfric'
gpl_utils_source = gpl_utils_source_config.source_root / 'gpl_utils'

# this folder just contains previous output, for testing the overrides mechanism.
# this folder just contains previous output, for testing the overrides
# mechanism.
psyclone_overrides = Path(__file__).parent / 'mesh_tools_overrides'

with BuildConfig(project_label='mesh tools $compiler $two_stage',
tool_box=ToolBox()) as state:
grab_folder(state, src=lfric_source / 'infrastructure/source/', dst_label='')
grab_folder(state, src=lfric_source / 'mesh_tools/source/', dst_label='')
grab_folder(state, src=lfric_source / 'components/science/source/', dst_label='')
grab_folder(state, src=lfric_source / 'infrastructure/source/',
dst_label='')
grab_folder(state, src=lfric_source / 'mesh_tools/source/',
dst_label='')
grab_folder(state, src=lfric_source / 'components/science/source/',
dst_label='')

# grab the psyclone overrides folder into the source folder
grab_folder(state, src=psyclone_overrides, dst_label='mesh_tools_overrides')
grab_folder(state, src=psyclone_overrides,
dst_label='mesh_tools_overrides')

# generate more source files in source and source/configuration
configurator(
state,
lfric_source=lfric_source,
gpl_utils_source=gpl_utils_source,
rose_meta_conf=lfric_source / 'mesh_tools/rose-meta/lfric-mesh_tools/HEAD/rose-meta.conf',
rose_meta_conf=lfric_source / 'mesh_tools' / 'rose-meta'
/ 'lfric-mesh_tools' / 'HEAD' / 'rose-meta.conf',
)

find_source_files(
Expand All @@ -50,7 +56,9 @@

preprocess_fortran(state)

preprocess_x90(state, common_flags=['-DRDEF_PRECISION=64', '-DUSE_XIOS', '-DCOUPLED'])
preprocess_x90(state, common_flags=['-DRDEF_PRECISION=64',
'-DUSE_XIOS',
'-DCOUPLED'])

psyclone(
state,
Expand All @@ -63,8 +71,15 @@

analyse(
state,
root_symbol=['cubedsphere_mesh_generator', 'planar_mesh_generator', 'summarise_ugrid'],
# ignore_mod_deps=['netcdf', 'MPI', 'yaxt', 'pfunit_mod', 'xios', 'mod_wait'],
root_symbol=['cubedsphere_mesh_generator',
'planar_mesh_generator',
'summarise_ugrid'],
# ignore_mod_deps=['netcdf',
# 'MPI',
# 'yaxt',
# 'pfunit_mod',
# 'xios',
# 'mod_wait'],
)

compile_fortran(state, common_flags=['-c'])
Expand All @@ -75,8 +90,10 @@
link_exe(
state,
flags=[
'-lyaxt', '-lyaxt_c', '-lnetcdff', '-lnetcdf', '-lhdf5', # EXTERNAL_DYNAMIC_LIBRARIES
'-lxios', # EXTERNAL_STATIC_LIBRARIES
# EXTERNAL_DYNAMIC_LIBRARIES
'-lyaxt', '-lyaxt_c', '-lnetcdff', '-lnetcdf', '-lhdf5',
# EXTERNAL_STATIC_LIBRARIES
'-lxios',
'-lstdc++',
],
)
Loading

0 comments on commit 48c3c72

Please sign in to comment.