Skip to content

Commit

Permalink
Allow users to override the default account at setup time (#3127)
Browse files Browse the repository at this point in the history
# Description
This adds a new option to setup_expt.py, and adds a missing argument to
generate_workflows.sh, to allow users to specify which HPC account they
wish to use. It also allows users to specify the environmental variable
`HPC_ACCOUNT` at setup time to specify the account. Documentation is
updated to note the new feature.

Resolves #3124

# Type of change
- [x] Bug fix (fixes something broken)
- [x] New feature (adds functionality)

# Change characteristics
- Is this a breaking change (a change in existing functionality)? NO
- Does this change require a documentation update? YES
- Does this change require an update to any of the following submodules?
NO

# How has this been tested?
Setup experiments on Hera.

# Checklist
- [x] My code follows the style guidelines of this project
- [x] I have performed a self-review of my own code
- [x] I have commented my code, particularly in hard-to-understand areas
- [x] I have documented my code, including function, input, and output
descriptions
- [x] My changes generate no new warnings
- [ ] New and existing tests pass with my changes
- [x] This change is covered by an existing CI test or a new one has
been added
- [x] I have made corresponding changes to the system documentation if
necessary
  • Loading branch information
DavidHuber-NOAA authored Dec 2, 2024
1 parent 94f2029 commit 6b2d84e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
3 changes: 2 additions & 1 deletion docs/source/setup.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ The following command examples include variables for reference but users should

cd workflow
./setup_expt.py gfs forecast-only --idate $IDATE --edate $EDATE [--app $APP] [--start $START] [--interval $INTERVAL_GFS] [--resdetatmos $RESDETATMOS] [--resdetocean $RESDETOCEAN]
[--pslot $PSLOT] [--configdir $CONFIGDIR] [--comroot $COMROOT] [--expdir $EXPDIR]
[--pslot $PSLOT] [--configdir $CONFIGDIR] [--comroot $COMROOT] [--expdir $EXPDIR] [--account $ACCOUNT]

where:

Expand All @@ -61,6 +61,7 @@ where:
* ``$INTERVAL_GFS`` is the forecast interval in hours [default: 6]
* ``$COMROOT`` is the path to your experiment output directory. Your ``ROTDIR`` (rotating com directory) will be created using ``COMROOT`` and ``PSLOT``. [default: $HOME (but do not use default due to limited space in home directories normally, provide a path to a larger scratch space)]
* ``$EXPDIR`` is the path to your experiment directory where your configs will be placed and where you will find your workflow monitoring files (i.e. rocoto database and xml file). DO NOT include PSLOT folder at end of path, it will be built for you. [default: $HOME]
* ``$ACCOUNT`` is the HPC (i.e. slurm or PBS) account to use for the experiment. [default: $HPC_ACCOUNT; if $HPC_ACCOUNT is not set, then the default in the host file (workflow/hosts/<machine>.yaml) will be used]

Examples:

Expand Down
1 change: 1 addition & 0 deletions workflow/generate_workflows.sh
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ while [[ $# -gt 0 && "$1" != "--" ]]; do
t) _tag="_${OPTARG}" ;;
v) _verbose=true ;;
V) _very_verbose=true && _verbose=true && _verbose_flag="-v" ;;
A) _set_account=true && _hpc_account="${OPTARG}" ;;
d) _debug=true && _very_verbose=true && _verbose=true && _verbose_flag="-v" && PS4='${LINENO}: ' ;;
h) _usage && exit 0 ;;
:)
Expand Down
5 changes: 5 additions & 0 deletions workflow/setup_expt.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ def _common_args(parser):
parser.add_argument('--idate', help='starting date of experiment, initial conditions must exist!',
required=True, type=lambda dd: to_datetime(dd))
parser.add_argument('--edate', help='end date experiment', required=False, type=lambda dd: to_datetime(dd))
parser.add_argument('--account', help='HPC account to use; default is host-dependent', required=False, default=os.getenv('HPC_ACCOUNT'))
parser.add_argument('--interval', help='frequency of forecast (in hours); must be a multiple of 6', type=_validate_interval, required=False, default=6)
parser.add_argument('--icsdir', help='full path to user initial condition directory', type=str, required=False, default='')
parser.add_argument('--overwrite', help='overwrite previously created experiment (if it exists)',
Expand Down Expand Up @@ -407,6 +408,10 @@ def main(*argv):

validate_user_request(host, user_inputs)

# Update the default host account if the user supplied one
if user_inputs.account is not None:
host.info.ACCOUNT = user_inputs.account

# Determine ocean resolution if not provided
if user_inputs.resdetocean <= 0:
user_inputs.resdetocean = get_ocean_resolution(user_inputs.resdetatmos)
Expand Down

0 comments on commit 6b2d84e

Please sign in to comment.