fre.make.create_makefile_script module
Create_makefile_script contains methods to generate the top-level Makefile used for model compilation. makefile_create is the entry point called by fre make makefile and by fre make all.
The top-level Makefile is outputted to: - for bare-metal platforms: [modelRoot]/[experiment]/[platform]-[target]/exec/Makefile - for container platforms: ./tmp/[platform]/Makefile (staged for COPY during container image build)
where
modelRoot is defined in platforms.yaml
experiment is the basename of the model YAML file (e.g. am5 from am5.yaml)
platform and target are passed via the -p / -t CLI options to fre make makefile
and fre make all.
The generated Makefile
Sets SRCROOT — path to the checked-out source code
Sets BUILDROOT — path to the directory where the executable is placed
Sets MK_TEMPLATE_PATH — path to the mkmf template file (mkTemplate from platforms.yaml); templates can be found in mkmf repository <https://github.com/NOAA-GFDL/mkmf>
Defines build and link recipes (as shown below) for each component listed under src in compile.yaml:
- [target]: [prerequisites]
[recipe]
Additional library flags are handled as below:
Bare-metal: baremetal_linkerflags from compile.yaml are added directly as -L / -l flags to the Makefile.
Container: container_addlibs from the compile yaml are resolved at build time.
For more information about the Makefile, see the fre-cli glossary: https://github.com/NOAA-GFDL/fre-cli/blob/main/docs/glossary.rst
- fre.make.create_makefile_script.makefile_create(yamlfile: str, platform: tuple[str], target: tuple[str])
Makefile_create generates the top-level Makefile for each platform/target combination.
For bare-metal platforms, the Makefile is written to [modelRoot]/[experiment]/[platform]-[target]/exec/.
For container platforms, the Makefile is staged in ./tmp/[platform]/ and is COPYed into the container image at image build time.
- Parameters:
yamlfile (str) – is the path to the model YAML file (e.g. am5.yaml). The experiment name is derived by stripping the .yaml extension.
platform (tuple[str]) – is one or more FRE platform strings as defined in platforms.yaml (e.g. ncrc5.intel23). Both bare-metal and container platforms are supported.
target (tuple[str]) – is one or more mkmf target strings (e.g. prod, debug, repro, prod-openmp). One Makefile is generated per platform/target pair.
- Raises:
ValueError – If a specified platform does not exist in platforms.yaml.
Note
Additional library dependencies are handled differently per build type:
Container build — list library names under container_addlibs in compile.yaml (e.g. container_addlibs: [‘darcy’]). A linkline.sh script, generated alongside the Makefile, locates the spack-built libraries inside the container and resolves the -L / -l flags at container image build time.
Bare-metal build — provide full linker flags under baremetal_linkerflags in compile.yaml (e.g. baremetal_linkerflags: [“-L/path/to/libs -ldarcy”]). These flags are added directly to the Makefile.