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

Integrate MPAS build infrastructure with CIME #245

Merged
merged 12 commits into from
Jan 25, 2024

Conversation

kuanchihwang
Copy link
Collaborator

This PR brings integration of MPAS build infrastructure with CIME. If MPAS dynamical core is selected (determined from model grid specifications), it will be built as a part of the usual CIME build process (i.e., case.build).

The approach taken here is to reuse upstream MPAS build infrastructure as much as possible. This way, it would be easier to keep in sync with future upstream changes. However, by default, MPAS is built as a standalone executable. A supplemental Makefile is therefore needed to enable MPAS to be built as a static library, which is then linked into the host model executable.

This PR should be considered after #244.

@nusbaume nusbaume self-requested a review January 9, 2024 15:22
@nusbaume nusbaume added the enhancement New feature or request label Jan 9, 2024
@mgduda mgduda self-requested a review January 9, 2024 22:56
@nusbaume
Copy link
Collaborator

@kuanchihwang just letting you know that I'll make sure to review this PR once PR #244 has been merged (as you suggested above). Thanks!

cime_config/buildlib Outdated Show resolved Hide resolved
Variables (e.g., build options) will be read from `${CASEROOT}/Macros.make`.
MPAS will be built as a static library located at `${LIBROOT}/libmpas.a`.
Build MPAS by invoking/reusing its own build infrastructure.
This way, it would be easier to keep in sync with future upstream changes.
`cime/CIME/Tools/Makefile` explicitly queries the value of `CAM_DYCORE`.
If the value is `mpas`, it attempts to build MPAS by using old rules and fails.

There are some ways to work around this without modifying
`cime/CIME/Tools/Makefile` and breaking backward compatibility for CAM. One of
them is to rename the value to `mpasa`.
Copy link
Collaborator

@nusbaume nusbaume left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR @kuanchihwang ! However I believe many of these changes may be unnecssary as the top-level CESM Makefile in CIME already has the setup needed to build the MPAS-A dycore as a library. For example see here:

https://github.com/ESMCI/cime/blob/master/CIME/Tools/Makefile#L519

and here:

https://github.com/ESMCI/cime/blob/master/CIME/Tools/Makefile#L556

So I think in CAM-SIMA you only have to create the relevant Makefile and associated paths/linking commands (which you are doing in the PR already). Everything else can theoretically be removed, which explains my comments below.

Of course if you and @mgduda would prefer to move away from the CIME Makefile method then please let me know and I'll change my review. Thanks!

cime_config/buildlib Outdated Show resolved Hide resolved
cime_config/buildlib Outdated Show resolved Hide resolved
cime_config/buildlib Outdated Show resolved Hide resolved
cime_config/buildlib Outdated Show resolved Hide resolved
cime_config/buildlib Outdated Show resolved Hide resolved
cime_config/config_component.xml Outdated Show resolved Hide resolved
cime_config/config_component.xml Show resolved Hide resolved
cime_config/config_component.xml Outdated Show resolved Hide resolved
src/dynamics/mpas/Makefile.in.CESM Outdated Show resolved Hide resolved
src/dynamics/mpas/Makefile.in.CESM Outdated Show resolved Hide resolved
This helps keep MPAS source code in sync between `mpas_dycore_src_root` and `mpas_dycore_bld_root`.
Setup MPAS build infrastructure in a way that MPAS can be built along with CAM.
Drop dependency to `$(CASEROOT)/Macros.make`. Users are responsible to provide
all necessary build options via environment variables or command line arguments.
In this case, rely on CIME Makefile to handle this.

Print those build options for transparency.
This Makefile catches the `make` command from CIME Makefile and then executes
appropriate targets in order.
Address reviewer's suggestions.
Copy link
Collaborator

@nusbaume nusbaume left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything looks good to me now. Thanks @kuanchihwang!

Copy link
Collaborator

@mgduda mgduda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

@kuanchihwang kuanchihwang merged commit bf7302c into ESCOMP:development Jan 25, 2024
6 checks passed
@kuanchihwang kuanchihwang deleted the feature-mpas-build-infra branch January 25, 2024 17:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Tag
Development

Successfully merging this pull request may close these issues.

3 participants