forked from NOAA-EMC/global-workflow
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add preamble, convert to bash, and remove env
This is the first in a wave of commits to improve and standardize the scripts within global workflow. In this commit, all scripts run during execution are converted to bash and a preamble is added to every script that is not sourced by another script. Every script executed during a forecast cycle is converted to bash. This was mostly straightforward, though there were a couple Korne-shell conventions (primarily using `typeset` to format strings) that had to be replaced with bash-compatable alternatives like `printf`. This in turn required a few modification to prevent zero-padded numbers from being treated as octals (other may have been pre-existing bugs). The preamble contains a number of feature to standardize code and improve script flow and debugging. First, it uses two variables, `$STRICT` and `$TRACE` to control the behavior of `set`. When `$STRICT` is `"YES"`, error on undefined variables (`set -u`) and exit on non-zero return (`set -e`) are turned on. When `$TRACE` is `"YES"`, command trace (`set -x`) is turned on and a useful string is set to `$PS4` that gives the name and line number of the script. Both `$STRICT` and `$TRACE` default to `"YES"`. They also set up commands, `$ERR_EXIT_ON` and `$TRACE_ON`, that will restore the setting of each in the event a script needs to temporarily turn them off. Second, the preamble sets up primative timing of scripts using Posix `date`. Third, it echos the script is beginning and at what time. Finally, it also establishes a postamble function and sets it to run as a trap of EXIT. The postamble will use the end time to calculate the run time of the script, then print that the script has ended at what time, how long has elapsed, and the exit code. By setting this up as a trap instead of just calling it at the end of the script, it ensures the postamble is called even if the script exits early because there is an error. In response to this standardization, parts of scripts that performed these preamble functions (announcing start/end, `set -x`, etc) have been deleted. For some scripts where temporarily turning off `-x` or `-e` is needed, they now use `$ERR_EXIT_ON` and `$TRACE_ON` to return to the correct state afterwards, instead of blindly turning the setting back on. Additionally, some modifications were needed to comply with `set -eu`. Mostly taking care of undefined variables, but also a couple instances where a non-zero return code had to be dealt with. If users wish to use their own preamble script instead, the default script can be overriden by setting `$PREAMBLE_SCRIPT` before the run begins. Instance where scripts would print the full list of environment variables have been removed. These can be spot added back in to debug as necessary. Alternatively, a future PR will add them back in in a standardized way. `rstprod.sh` is added to the link list from gsi_monitor.fd, as it is needed for the radmon scripts. The placeholders for AWIPS and GEMPAK in the Hera and Orion environment scripts were replaced with the correct definitions. There were also other modifications to AWIPS and GEMPAK scripts to get it working for development (AWIPS still isn't and will be fixed in the future). GSI scripts that were brought in recently had all of their backticks replaced with `$( )` as was done with all other script previously. Refs: NOAA-EMC#397
- Loading branch information
1 parent
98f4d16
commit 801e95f
Showing
240 changed files
with
2,091 additions
and
2,180 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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 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 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 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
Oops, something went wrong.