From 6bbe823e729291db326d108765d3a92a99552a58 Mon Sep 17 00:00:00 2001 From: DWesl <22566757+DWesl@users.noreply.github.com> Date: Mon, 29 Jan 2024 21:15:30 -0500 Subject: [PATCH] Use seq to generate the list of times, instead of a bash for-loop (#2264) I'm running a year-long forecast, which means I get a large portion of the log file dedicated to these loops. `seq ${START} ${STEP} ${STOP}` will generate a sequence going from START to STOP by STEP, including STOP if relevant. That seems to be the purpose of these loops. It will by default separate the list with newlines, but `seq -s ' ' ${START} ${STEP} ${STOP}` will separate them with spaces instead, more closely mimicing the previous behavior. I would like this to be two lines in the log, rather than a few hundred, and this may also be faster, though probably more for reasons of fewer writes to disk than because bash isn't designed for arithmetic. --- ush/forecast_predet.sh | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/ush/forecast_predet.sh b/ush/forecast_predet.sh index 9bb565919a..ef1ca843f4 100755 --- a/ush/forecast_predet.sh +++ b/ush/forecast_predet.sh @@ -117,15 +117,10 @@ FV3_predet(){ FV3_OUTPUT_FH="" local fhr=${FHMIN} if (( FHOUT_HF > 0 && FHMAX_HF > 0 )); then - for (( fh = FHMIN; fh < FHMAX_HF; fh = fh + FHOUT_HF )); do - FV3_OUTPUT_FH="${FV3_OUTPUT_FH} ${fh}" - done + FV3_OUTPUT_FH="${FV3_OUTPUT_FH} $(seq -s ' ' "${FHMIN}" "${FHOUT_HF}" "${FHMAX_HF}")" fhr=${FHMAX_HF} fi - for (( fh = fhr; fh <= FHMAX; fh = fh + FHOUT )); do - FV3_OUTPUT_FH="${FV3_OUTPUT_FH} ${fh}" - done - + FV3_OUTPUT_FH="${FV3_OUTPUT_FH} $(seq -s ' ' "${fhr}" "${FHOUT}" "${FHMAX}")" # Model resolution specific parameters DELTIM=${DELTIM:-225}