-
Notifications
You must be signed in to change notification settings - Fork 383
Set SHELL explicitly in the Makefile #594
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
Set SHELL explicitly in the Makefile #594
Conversation
pwolfram
left a comment
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.
This was always one of my biggest complaints (although minor) with Ubuntu.
|
I discovered this problem (in the process of several hours of debugging) when trying out scorpio following #592 |
|
I could obviously make |
|
I'd strongly recommend we be clear about the shell used-- even mac may leave bash. There are other modern alternatives and some folks run tcsh too. Being really clear about the shell used is a good thing. |
Just to clarify, |
|
@mgduda, @mark-petersen and @matthewhoffman, if you're okay with this change, could you do a quick build and test with this Makefile when you have a chance? It should be easy to test. |
|
If |
|
@xylar I don't have access to a system running Ubuntu. Could you provide the failure message, if any, that you're seeing? I'll also check whether I have access to any systems with |
|
@mgduda, it basically isn't getting the exit code from the failed compile command. It thinks PIO1 succeeded even when it fails. "PIO1 detected" is definitely incorrect and if I actually run the command (in bash), it produces various error messages and exits 1 If I switch to and everything builds as expected. If you want to go the route of fixing the |
|
It turned out to take just a few minutes to install This creates problems when we try to pass variables to make, e.g. here in the top-level Makefile. The result is that |
|
@mgduda, that sounds like progress. Thanks for investigating! Does that still suggest that the easiest solution is |
|
@xylar I'm still experimenting a bit. Sometimes, this can lead to the realization that we're doing something fundamentally "odd", and that a different approach would solve the problem and put our code more in line with best practices. For example, maybe invoking isn't a good paradigm. On the other hand, it could be that what we're doing is reasonable, and it's simply Simply setting For what it's worth, I think the following should also be sufficient: |
|
Here's a C program to help illustrate how #include <stdio.h>
int main(int argc, char **argv)
{
int i;
for (i=1; i<argc; i++) {
printf("ARG: %s\n", argv[i]);
}
return 0;
}With, e.g., With |
|
Here's an example |
Oh, I'm fine with that solution. It didn't occur to me that the solution would be that simple. |
|
Hmm, so that raises a question for me. Typically, I define |
|
@xylar My uninformed guess would be that In the interest of placing all ideas on the table for consideration, another option might be to add at the top of the |
6b7e605 to
bf0a1d6
Compare
|
@mgduda, I like that suggestion very much. I updated the PR with that change. |
|
Tested with Ubuntu, |
|
@MiCurry, @matthewhoffman and @mark-petersen, could you try this out and review when you get a chance? The priority is to make sure nothing breaks. Secondarily, you could set |
|
@xylar I'll give it a test.
In fact, Mac OS has already switched its default shell from bash to zsh with the release of Catalina. As a zsh user, I'm not complaining! A lot of people here at |
MiCurry
left a comment
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.
I think this change only sets $SHELL for the current make process and is not passed onto sub-make commands. See: https://www.gnu.org/software/make/manual/html_node/Choosing-the-Shell.html.
If you echo $SHELL > SHELL_REPORT at various levels of the Makefile (./Makefile, ./src/Makefile, ./src/core_init_atmosphere/Makefile, etc.) you'll see the shell set in MPAS_SHELL is correctly set in the main Makefile, but is not passed down into sub-makefiles (i.e.: ./src/Makefile, ./src/core_*/Makefile).
I tried using export SHELL to pass the MPAS_SHELL onto the sub-makes, but I wasn't successful, but I was able to pass SHELL onto sub-makes by setting SHELL in the sub-make recipes calls. e.g.:
gfortran:
( $(MAKE) all \
"SHELL = $(SHELL)" \
"FC_PARALLEL = mpif90" \
"CC_PARALLEL = mpicc" \
"CXX_PARALLEL = mpicxx" \
"FC_SERIAL = gfortran" \
...Passing it this way was able to pass this all the way down to ./src/Makefile and to ./src/core_init_atmosphere/Makefile.
|
@MiCurry, thank you for looking into that. I hadn't run into any problems deeper in but that may simply be because there aren't currently shell calls in deeper Makefiles in the ocean core. @mgduda, are you okay with passing the |
MiCurry
left a comment
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.
@MiCurry, thank you for looking into that. I hadn't run into any problems deeper in but that may simply be because there aren't currently shell calls in deeper Makefiles in the ocean core.
That was my assumption. All looks good now!
mark-petersen
left a comment
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.
I tried this on grizzly with the new intel19 modules:
module load intel/19.0.4 intel-mpi/2019.4 hdf5-parallel/1.8.16 \
pnetcdf/1.11.2 netcdf-h5parallel/4.7.3 mkl/2019.0.4 scorpio/pio2/1.10.1
make ifort CORE=ocean USE_PIO2=true DEBUG=true SHELL=/bin/bash
and everything worked fine. Also tested with gnu without the SHELL on the make line, and that worked fine as well.
|
@matthewhoffman I think you can approve based on my testing, unless you want to test a different system. @mgduda any further comments? |
|
@xylar @MiCurry Rather than having to add once at the top of each I'm also fine with just modifying the top-level |
|
@mgduda, I think we would need to pass So for now I'm just removing my last commit and we'll only modify the base |
Without this, /bin/sh defaults to dash in Ubuntu, which then causes test_pio to fail.
4800121 to
c271110
Compare
|
@mgduda and @matthewhoffman, if you can review this soon, I think @mark-petersen would like to merge |
|
@xylar I'm fine with just making changes in the top-level To clarify for future reference, we would not need to pass sets the Then, in a |
mgduda
left a comment
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.
@xylar Can you update the PR description, which we'll use for the merge commit message, to explain that this PR allows the shell used by Make to be set with the MPAS_SHELL environment variable? It might be good to also explain why this is being done, including the error message that users would see in Ubuntu if the MPAS_SHELL environment variable were not set.
|
@mgduda, thanks for the explanation. It does sound like altering all the I will update the description/commit message in just a moment as you requested. Thanks for those suggestions, they certainly will make things clearer. |
mgduda
left a comment
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.
@xylar Thanks very much for the updated merge message! This looks good to me.
#3737) Update MPAS framework This PR brings in a new mpas-source submodule with updates to the mpas framework itself, plus changes to the cores supporting the framework update. Some changes are made to the atmosphere core, even though it is not used by E3SM, in order to maintain consistency with the framework. This update includes the following individual branches and PRs, many of which are additions to the makefiles for summit, or optional libraries: * az/azamat/mpas-cmake/mpas-tool-dir (MPAS-Dev/MPAS-Model#629) * init_atmosphere/kd_tree_ties (MPAS-Dev/MPAS-Model#630) * mark-petersen/framework/add_FillValue (MPAS-Dev/MPAS-Model#616) * mark-petersen/framework/add_lapack_option (MPAS-Dev/MPAS-Model#613) * amametjanov/framework/nullify-field-pointers (MPAS-Dev/MPAS-Model#578) * framework/makefile_e3sm (MPAS-Dev/MPAS-Model#603) * xylar/framework/make_shell_bash (MPAS-Dev/MPAS-Model#594) * registry/missing_value (MPAS-Dev/MPAS-Model#562) * pwolfram/updates_make_intel_stack (MPAS-Dev/MPAS-Model#592) * azamat/framework/pgi-cpr-omp-workaround (MPAS-Dev/MPAS-Model#449) * az/framework/e3sm-cmake-qnosmp-typo (MPAS-Dev/MPAS-Model#579) * xylar/compass/add_prerequisite_tag * atmosphere/fix_timekeeping_imports (MPAS-Dev/MPAS-Model#582) * xylar/fix_docs_ci (MPAS-Dev/MPAS-Model#575) * xylar/add_compass_docs (MPAS-Dev/MPAS-Model#472) * philipwjones/framework/summitmake (MPAS-Dev/MPAS-Model#536) * atmosphere/atm_core_cleanup (MPAS-Dev/MPAS-Model#548) * init_atmosphere/parse_geoindex (MPAS-Dev/MPAS-Model#459) * xylar/compass/add_copy_file (MPAS-Dev/MPAS-Model#467) * init_atmosphere/kd_tree (MPAS-Dev/MPAS-Model#438) * init_atmosphere/mpas_stack (MPAS-Dev/MPAS-Model#426) * operators/add_mpas_in_cell (MPAS-Dev/MPAS-Model#400) Fixes #3396 Fixes #3236 [BFB]
Update MPAS framework This PR brings in a new mpas-source submodule with updates to the mpas framework itself, plus changes to the cores supporting the framework update. Some changes are made to the atmosphere core, even though it is not used by E3SM, in order to maintain consistency with the framework. This update includes the following individual branches and PRs, many of which are additions to the makefiles for summit, or optional libraries: * az/azamat/mpas-cmake/mpas-tool-dir (MPAS-Dev/MPAS-Model#629) * init_atmosphere/kd_tree_ties (MPAS-Dev/MPAS-Model#630) * mark-petersen/framework/add_FillValue (MPAS-Dev/MPAS-Model#616) * mark-petersen/framework/add_lapack_option (MPAS-Dev/MPAS-Model#613) * amametjanov/framework/nullify-field-pointers (MPAS-Dev/MPAS-Model#578) * framework/makefile_e3sm (MPAS-Dev/MPAS-Model#603) * xylar/framework/make_shell_bash (MPAS-Dev/MPAS-Model#594) * registry/missing_value (MPAS-Dev/MPAS-Model#562) * pwolfram/updates_make_intel_stack (MPAS-Dev/MPAS-Model#592) * azamat/framework/pgi-cpr-omp-workaround (MPAS-Dev/MPAS-Model#449) * az/framework/e3sm-cmake-qnosmp-typo (MPAS-Dev/MPAS-Model#579) * xylar/compass/add_prerequisite_tag * atmosphere/fix_timekeeping_imports (MPAS-Dev/MPAS-Model#582) * xylar/fix_docs_ci (MPAS-Dev/MPAS-Model#575) * xylar/add_compass_docs (MPAS-Dev/MPAS-Model#472) * philipwjones/framework/summitmake (MPAS-Dev/MPAS-Model#536) * atmosphere/atm_core_cleanup (MPAS-Dev/MPAS-Model#548) * init_atmosphere/parse_geoindex (MPAS-Dev/MPAS-Model#459) * xylar/compass/add_copy_file (MPAS-Dev/MPAS-Model#467) * init_atmosphere/kd_tree (MPAS-Dev/MPAS-Model#438) * init_atmosphere/mpas_stack (MPAS-Dev/MPAS-Model#426) * operators/add_mpas_in_cell (MPAS-Dev/MPAS-Model#400) Fixes #3396 Fixes #3236 [BFB]
This merge allows the shell used by Make to be set with the
$MPAS_SHELLenvironment variable.Without this fix or if not using
MPAS_SHELL=/bin/bash,makewill use/bin/sh, which points todash(notbash) under Ubuntu. This results in the following cryptic but non-fatal error message early in the build whenUSE_PIO2=true:But the build goes on to complete successfully using PIO2.