-
Notifications
You must be signed in to change notification settings - Fork 132
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
tests: run 'cice.run' with '-nomodules' #724
tests: run 'cice.run' with '-nomodules' #724
Conversation
Some compiler environments (namely newer version of Intel's oneAPI toolkit) prevent users form sourcing their initialization script twice, at least by default. The CICE test infrastructure currently does this, because env.$machine_$env is sourced by cice.test and then again by cice.run (which is ran from cice.test). Sourcing the env file in 'cice.run', when ran from 'cice.test', is thus unnecessary. Most env files already support the '-nomodules' flag, which is used by 'cice.setup' when only machine variables are needed, and not a full compiling environment. Leverage this flag by calling 'cice.run' with '-nomodules' in 'cice.test'. As a byprodcut, this should make tests run slightly faster since the environment setup is done only once. Closes: CICE-Consortium#695
How does passing -nomodules to cice.run do anything without a modification to the cice.run script? I don't think cice.run uses or checks for arguments. |
The arguments are passed-through to |
That's an interesting feature. So $1, unless reset, just retains it's "last" value. When env.machine_env is sourced, if nothing it passed into it, it doesn't reset the $1, $2, $3 arguments? That seems a little dicey. What if you pass an argument into cice.run that's used in cice.run. Then pass nothing into env.machine_env and it picks up on the $1 in cice.run, which might be completely useless or incorrect? I would have expected the local $n to default to unset by default unless an argument is explicitly set in the execution. Do we really want to leverage/rely on this feature? |
So I checked the Bash documentation (https://www.gnu.org/savannah-checkouts/gnu/bash/manual/bash.html#Bourne-Shell-Builtins) which says:
So for Bash it's a documented behaviour. But we use csh. Here is what
So it is not specified what happens to existing positional arguments, but I understand it to mean that they are implicitely passed. Note that the original
So I think we can safely use that feature. |
Good to know this feature is likely to be robust. I guess another question is do we really want to leverage this feature. It seems to lack transparency and may cause confusion later on. I would almost prefer if cice.run had an explicit check if -nomodules was passed and if so, that it would be passed to "source env.machine_env" explicitly. Thoughts? |
It depends if we want to drop support for the original I would not be opposed to that as along as all shebangs are changed to |
OK, so one question is whether we are even allowed to pass arguments with csh. What we're doing now should not work. Our scripts are #!/bin/csh but we pass arguments into them. It's working only because it's either using tcsh under the covers or because the implementation of csh under the covers allows it. Or maybe the argument is ignored and we can't tell. How much risk is there to requiring tcsh in terms of portability? Since the current "csh" seems to be working OK, should we fix this? A separate question still seems to be whether we want to explicitly or implicitly pass the arguments down the calling tree. I do think I prefer explicit. That would mean adding something like the following to cice.run
or similar. Thoughts on both issues? |
Passing arguments to scripts does work in csh, it's passing additional arguments to the # this works in csh and tcsh
source some_file
# this only works in tcsh
source some_file -some_argument |
So all our scripts are basically setup as csh, but may be running tcsh under the covers. The -nomodules option is mainly useful to speed up running large test suites. I don't think most users do that. Let me circle back again. Is this to help performance? What does "Some compiler environments (namely newer version of Intel's oneAPI toolkit) prevent users form sourcing their initialization script twice, at least by default" mean? Is there a failure or problem resetting the env with Intel oneAPI? |
It means that the Intel initialization script detects it is being sourced a second time, and aborts, yes. You can force it to do it with a special flag though. But since I opened this PR, our CS departement has added additional methods to load the compiler, so these changes are not needed for me anymore. So we can drop it if you prefer. |
Thanks @phil-blain. At this point, if the feature is not needed, I guess I prefer we just close this PR. I think there is a bigger issue about scripting language and overall implementation. @phil-blain, do you think we should switch to bash or some other language/tool? Is it time to review the current scripts and do some refactoring? Maybe we need a new issue where we can accumulate additional script ideas and then find a time to update? This could include a variety of things including #674, for instance. |
I'm ambivalent about switching tools / languages. It might be quite an involved process... |
I'll close this PR. |
PR checklist
title
me
no code changes, no test suite ran. I tested this works as intended.
Some compiler environments (namely newer version of Intel's oneAPI
toolkit) prevent users form sourcing their initialization script twice,
at least by default.
The CICE test infrastructure currently does this, because
env.$machine_$env is sourced by cice.test and then again by cice.run
(which is ran from cice.test). Sourcing the env file in 'cice.run', when
ran from 'cice.test', is thus unnecessary.
Most env files already support the '-nomodules' flag, which is used by
'cice.setup' when only machine variables are needed, and not a full
compiling environment. Leverage this flag by calling 'cice.run' with
'-nomodules' in 'cice.test'. As a byprodcut, this should make tests run
slightly faster since the environment setup is done only once.