-
Notifications
You must be signed in to change notification settings - Fork 7
Add default CICE5 builds when using CMake #383
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
3c4c286
tidyup and testing with api-v2
anton-seaice 8c74a88
empty
anton-seaice 1cc3b88
Move cmake_args higher in class definition
anton-seaice 1195201
review comments and formating
anton-seaice 68ebf7e
Update spack_repo/access/nri/packages/cice5/package.py
anton-seaice File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
.github/build-ci/manifests/cice5/access-om2+deterministic-intel.spack.yaml.j2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,13 +7,27 @@ | |
| from spack_repo.builtin.build_systems.makefile import MakefilePackage | ||
| from spack.package import * | ||
|
|
||
| # These are the default layouts, inc 3 executables for OM2 | ||
| # alternatively, supply the 5 layout variants to produce 1 executable | ||
| OM2_LAYOUTS = [ | ||
| {"nxglob": "360", "nyglob": "300", "blckx": "15", "blcky": "300", "mxblcks": "1"}, | ||
| {"nxglob": "1440", "nyglob": "1080", "blckx": "30", "blcky": "27", "mxblcks": "4"}, | ||
| {"nxglob": "3600", "nyglob": "2700", "blckx": "40", "blcky": "30", "mxblcks": "12"}, | ||
| ] | ||
| ESM1P6_LAYOUTS = [ | ||
| {"nxglob": "360", "nyglob": "300", "blckx": "30", "blcky": "300", "mxblcks": "1"}, | ||
| ] | ||
|
|
||
|
|
||
| def _int_validator(s): | ||
| """Test a string variant is a valid integer """ | ||
| if (s.isdigit() and int(s) > 0): | ||
| return True | ||
| else: | ||
| print(f"ERROR: {s} not a valid integer") | ||
| return False | ||
| if (s != "none"): | ||
| if (s.isdigit() and int(s) > 0): | ||
| return True | ||
| else: | ||
| print(f"ERROR: {s} not a valid integer") | ||
| return False | ||
|
|
||
|
|
||
| class Cice5(CMakePackage, MakefilePackage): | ||
| """The Los Alamos sea ice model (CICE) is the result of an effort to develop | ||
|
|
@@ -32,7 +46,7 @@ class Cice5(CMakePackage, MakefilePackage): | |
| version("access-om2", branch="master") | ||
| version("access-esm1.6", branch="access-esm1.6") | ||
|
|
||
| # by default, keep existing processor layout defined in makefile | ||
| # by default, keep existing processor layout | ||
| # if nxglob, nyglob, blckx, blcky, mxblcks are supplied, then spack will switch to cmake | ||
| build_system("makefile", "cmake", default="makefile") | ||
|
|
||
|
|
@@ -113,26 +127,91 @@ class Cice5(CMakePackage, MakefilePackage): | |
| depends_on("libaccessom2+deterministic", when="+deterministic") | ||
| depends_on("libaccessom2~deterministic", when="~deterministic") | ||
|
|
||
|
|
||
| class CMakeBuilder(cmake.CMakeBuilder): | ||
|
|
||
| phases = ["set_layouts", "cmake", "build", "install"] | ||
|
|
||
| _all_layouts = [{}] # all layouts to build, | ||
| # see OM2_LAYOUTS and ESM1P6_LAYOUTS for examples | ||
| _layout = {} # current layout being setup/built/installed | ||
|
|
||
| def cmake_args(self): | ||
| """List of the arguments that must be passed to cmake. | ||
| These are set based on the values in _layout. | ||
| cmake_args is called during super().cmake() | ||
| """ | ||
| if self.spec.variants["model"].value == "access-esm1.6": | ||
| args = [self.define("CICE_DRIVER", "access")] | ||
| else: # access-om2 | ||
| args = [self.define("CICE_DRIVER", "auscom")] | ||
|
|
||
| args.extend([ | ||
| self.define("CICE_NXGLOB", self._layout['nxglob']), | ||
| self.define("CICE_NYGLOB", self._layout['nyglob']), | ||
| self.define("CICE_BLCKX", self._layout['blckx']), | ||
| self.define("CICE_BLCKY", self._layout['blcky']), | ||
| self.define("CICE_MXBLCKS", self._layout['mxblcks']), | ||
| self.define_from_variant("CICE_IO", "io_type"), | ||
| self.define_from_variant("CICE_NXGLOB", "nxglob"), | ||
| self.define_from_variant("CICE_NYGLOB", "nyglob"), | ||
| self.define_from_variant("CICE_BLCKX", "blckx"), | ||
| self.define_from_variant("CICE_BLCKY", "blcky"), | ||
| self.define_from_variant("CICE_MXBLCKS", "mxblcks"), | ||
| self.define_from_variant("CICE_DETERMINISTIC", "deterministic"), | ||
| ]) | ||
|
|
||
| return args | ||
|
|
||
| @property | ||
| def build_dirname(self) -> str: | ||
| """Directory name to use when building the package. | ||
| We modify this using _layout to ensure uniqueness with multiple builds | ||
| """ | ||
| build = ( | ||
| f"{self._layout['nxglob']}x{self._layout['nyglob']}_" | ||
| f"{self._layout['blckx']}x{self._layout['blcky']}_" | ||
| f"{self._layout['mxblcks']}" | ||
| ) | ||
| return f"{super().build_dirname}/{build}" | ||
|
|
||
| def set_layouts(self, pkg, spec, prefix): | ||
| """Layout of cice processors to use. If variants are set, use those. | ||
| Otherwise, use defaults.""" | ||
| layout_variants = OM2_LAYOUTS[0].keys() | ||
|
|
||
| # if all 5 layouts variants are available, set the layouts dict | ||
| if all([ | ||
| self.spec.variants[variant].value != 'none' | ||
| for variant in layout_variants | ||
| ]): | ||
| layouts = [{variant: self.spec.variants[variant].value | ||
| for variant in layout_variants}] | ||
| # else if no layout variants are available, use the defaults | ||
| elif all([ | ||
| self.spec.variants[variant].value == 'none' | ||
| for variant in layout_variants | ||
| ]): | ||
|
Comment on lines
+186
to
+189
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be clearer that this is a list comprehension if the square brackets are immediately at the start and end of the list comprehension. |
||
| if self.spec.variants["model"].value == "access-esm1.6": | ||
| layouts = ESM1P6_LAYOUTS | ||
| else: | ||
| layouts = OM2_LAYOUTS | ||
| else: | ||
| raise Error(f"All of {layout_variants} " | ||
| "variants must be set if any are set") | ||
|
|
||
| self._all_layouts = layouts | ||
|
|
||
| def cmake(self, pkg, spec, prefix): | ||
| for layout in self._all_layouts: | ||
| self._layout = layout | ||
| super().cmake(pkg, spec, prefix) | ||
|
|
||
| def build(self, pkg, spec, prefix): | ||
| for layout in self._all_layouts: | ||
| self._layout = layout | ||
| super().build(pkg, spec, prefix) | ||
|
|
||
| def install(self, pkg, spec, prefix): | ||
| for layout in self._all_layouts: | ||
| self._layout = layout | ||
| super().install(pkg, spec, prefix) | ||
|
|
||
|
|
||
| class MakefileBuilder(makefile.MakefileBuilder): | ||
|
|
||
|
|
@@ -217,7 +296,6 @@ def set_deps_targets(self, pkg, spec, prefix): | |
|
|
||
| self.__deps["ldflags"] = " ".join([lstr] + [self.get_linker_args(spec, d) for d in ldeps]) | ||
|
|
||
|
|
||
| def edit(self, pkg, spec, prefix): | ||
|
|
||
| srcdir = self.stage.source_path | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be clearer that this is a list comprehension if the square brackets are immediately at the start and end of the list comprehension.