Skip to content

Commit

Permalink
Update env files for shellcheck SC2292
Browse files Browse the repository at this point in the history
- SC2292 (style): Prefer [[ ]] over [ ] for tests in Bash/Ksh.
- Change [ ] to [[ ]] where needed in env files.

Refs NOAA-EMC#397
  • Loading branch information
KateFriedman-NOAA committed Nov 18, 2022
1 parent 5dc099d commit 9dd25de
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 78 deletions.
38 changes: 19 additions & 19 deletions env/HERA.env
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#! /usr/bin/env bash

if [ $# -ne 1 ]; then
if [[ $# -ne 1 ]]; then

echo "Must specify an input argument to set runtime environment variables!"
echo "argument can be any one of the following:"
Expand Down Expand Up @@ -49,11 +49,11 @@ if [ "${step}" = "prep" -o "${step}" = "prepbufr" ]; then
elif [ "${step}" = "waveinit" -o "${step}" = "waveprep" -o "${step}" = "wavepostsbs" -o "${step}" = "wavepostbndpnt" -o "${step}" = "wavepostbndpntbll" -o "${step}" = "wavepostpnt" ]; then

export CFP_MP="YES"
if [ "${step}" = "waveprep" ]; then export MP_PULSE=0 ; fi
if [[ "${step}" = "waveprep" ]]; then export MP_PULSE=0 ; fi
export wavempexec=${launcher}
export wave_mpmd=${mpmd_opt}

elif [ "${step}" = "atmanalrun" ]; then
elif [[ "${step}" = "atmanalrun" ]]; then

export CFP_MP=${CFP_MP:-"YES"}
export USE_CFP=${USE_CFP:-"YES"}
Expand All @@ -65,7 +65,7 @@ elif [ "${step}" = "atmanalrun" ]; then
[[ ${NTHREADS_ATMANAL} -gt ${nth_max} ]] && export NTHREADS_ATMANAL=${nth_max}
export APRUN_ATMANAL="${launcher} -n ${npe_atmanalrun}"

elif [ "${step}" = "atmensanalrun" ]; then
elif [[ "${step}" = "atmensanalrun" ]]; then

export CFP_MP=${CFP_MP:-"YES"}
export USE_CFP=${USE_CFP:-"YES"}
Expand All @@ -77,7 +77,7 @@ elif [ "${step}" = "atmensanalrun" ]; then
[[ ${NTHREADS_ATMENSANAL} -gt ${nth_max} ]] && export NTHREADS_ATMENSANAL=${nth_max}
export APRUN_ATMENSANAL="${launcher} -n ${npe_atmensanalrun}"

elif [ "${step}" = "aeroanlrun" ]; then
elif [[ "${step}" = "aeroanlrun" ]]; then

export APRUNCFP="${launcher} -n \$ncmd ${mpmd_opt}"

Expand Down Expand Up @@ -116,15 +116,15 @@ elif [ "${step}" = "anal" -o "${step}" = "analcalc" ]; then
npe_gausfcanl=${npe_gausfcanl:-1}
export APRUN_GAUSFCANL="${launcher} -n ${npe_gausfcanl}"

elif [ "${step}" = "sfcanl" ]; then
elif [[ "${step}" = "sfcanl" ]]; then
nth_max=$((${npe_node_max} / ${npe_node_sfcanl}))

export NTHREADS_CYCLE=${nth_sfcanl:-14}
[[ ${NTHREADS_CYCLE} -gt ${npe_node_max} ]] && export NTHREADS_CYCLE=${npe_node_max}
npe_sfcanl=${ntiles:-6}
export APRUN_CYCLE="${launcher} -n ${npe_sfcanl}"

elif [ "${step}" = "gldas" ]; then
elif [[ "${step}" = "gldas" ]]; then

export USE_CFP="NO"
export CFP_MP="YES"
Expand All @@ -145,7 +145,7 @@ elif [ "${step}" = "gldas" ]; then
npe_gldas_data_proc=$((${gldas_spinup_hours} + 12))
export APRUN_GLDAS_DATA_PROC="${launcher} -n ${npe_gldas_data_proc} ${mpmd_opt}"

elif [ "${step}" = "eobs" ]; then
elif [[ "${step}" = "eobs" ]]; then

export MKL_NUM_THREADS=4
export MKL_CBWR=AUTO
Expand All @@ -160,7 +160,7 @@ elif [ "${step}" = "eobs" ]; then
export USE_CFP=${USE_CFP:-"YES"}
export APRUNCFP="${launcher} -n \$ncmd ${mpmd_opt}"

elif [ "${step}" = "eupd" ]; then
elif [[ "${step}" = "eupd" ]]; then

nth_max=$((${npe_node_max} / ${npe_node_eupd}))

Expand All @@ -172,7 +172,7 @@ elif [ "${step}" = "eupd" ]; then
export USE_CFP=${USE_CFP:-"YES"}
export APRUNCFP="${launcher} -n \$ncmd ${mpmd_opt}"

elif [ "${step}" = "fcst" ]; then
elif [[ "${step}" = "fcst" ]]; then

#PEs and PEs/node can differ for GFS and GDAS forecasts if threading differs
if [[ ${CDUMP} == "gfs" ]]; then
Expand All @@ -197,7 +197,7 @@ elif [ "${step}" = "fcst" ]; then
export APRUN_REMAP="${launcher} -n ${npe_remap:-${npe_fcst}}"
export I_MPI_DAPL_UD="enable"

elif [ "${step}" = "efcs" ]; then
elif [[ "${step}" = "efcs" ]]; then

nth_max=$((${npe_node_max} / ${npe_node_efcs}))

Expand All @@ -210,7 +210,7 @@ elif [ "${step}" = "efcs" ]; then
[[ ${NTHREADS_REGRID_NEMSIO} -gt ${nth_max} ]] && export NTHREADS_REGRID_NEMSIO=${nth_max}
export APRUN_REGRID_NEMSIO="${launcher} -n ${LEVS}"

elif [ "${step}" = "post" ]; then
elif [[ "${step}" = "post" ]]; then

nth_max=$((${npe_node_max} / ${npe_node_post}))

Expand All @@ -222,7 +222,7 @@ elif [ "${step}" = "post" ]; then
[[ ${NTHREADS_DWN} -gt ${nth_max} ]] && export NTHREADS_DWN=${nth_max}
export APRUN_DWN="${launcher} -n ${npe_dwn}"

elif [ "${step}" = "ecen" ]; then
elif [[ "${step}" = "ecen" ]]; then

nth_max=$((${npe_node_max} / ${npe_node_ecen}))

Expand All @@ -238,7 +238,7 @@ elif [ "${step}" = "ecen" ]; then
[[ ${NTHREADS_CALCINC} -gt ${nth_max} ]] && export NTHREADS_CALCINC=${nth_max}
export APRUN_CALCINC="${launcher} -n ${npe_ecen}"

elif [ "${step}" = "esfc" ]; then
elif [[ "${step}" = "esfc" ]]; then

nth_max=$((${npe_node_max} / ${npe_node_esfc}))

Expand All @@ -250,19 +250,19 @@ elif [ "${step}" = "esfc" ]; then
[[ ${NTHREADS_CYCLE} -gt ${npe_node_max} ]] && export NTHREADS_CYCLE=${npe_node_max}
export APRUN_CYCLE="${launcher} -n ${npe_esfc}"

elif [ "${step}" = "epos" ]; then
elif [[ "${step}" = "epos" ]]; then

nth_max=$((${npe_node_max} / ${npe_node_epos}))

export NTHREADS_EPOS=${nth_epos:-${nth_max}}
[[ ${NTHREADS_EPOS} -gt ${nth_max} ]] && export NTHREADS_EPOS=${nth_max}
export APRUN_EPOS="${launcher} -n ${npe_epos}"

elif [ "${step}" = "init" ]; then
elif [[ "${step}" = "init" ]]; then

export APRUN="${launcher} -n ${npe_init}"

elif [ "${step}" = "postsnd" ]; then
elif [[ "${step}" = "postsnd" ]]; then

nth_max=$((${npe_node_max} / ${npe_node_postsnd}))

Expand All @@ -274,15 +274,15 @@ elif [ "${step}" = "postsnd" ]; then
[[ ${NTHREADS_POSTSNDCFP} -gt ${nth_max} ]] && export NTHREADS_POSTSNDCFP=${nth_max}
export APRUN_POSTSNDCFP="${launcher} -n ${npe_postsnd} ${mpmd_opt}"

elif [ "${step}" = "awips" ]; then
elif [[ "${step}" = "awips" ]]; then

nth_max=$((${npe_node_max} / ${npe_node_awips}))

export NTHREADS_AWIPS=${nth_awips:-2}
[[ ${NTHREADS_AWIPS} -gt ${nth_max} ]] && export NTHREADS_AWIPS=${nth_max}
export APRUN_AWIPSCFP="${launcher} -n ${npe_awips} ${mpmd_opt}"

elif [ "${step}" = "gempak" ]; then
elif [[ "${step}" = "gempak" ]]; then

nth_max=$((${npe_node_max} / ${npe_node_gempak}))

Expand Down
38 changes: 19 additions & 19 deletions env/JET.env
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/ksh -x

if [ $# -ne 1 ]; then
if [[ $# -ne 1 ]]; then

echo "Must specify an input argument to set runtime environment variables!"
echo "argument can be any one of the following:"
Expand Down Expand Up @@ -42,27 +42,27 @@ if [ "${step}" = "prep" -o "${step}" = "prepbufr" ]; then

elif [ "${step}" = "waveinit" -o "${step}" = "waveprep" -o "${step}" = "wavepostsbs" -o "${step}" = "wavepostbndpnt" -o "${step}" = "wavepostbndpntbll" -o "${step}" = "wavepostpnt" ]; then

if [ "${step}" = "waveprep" ]; then export MP_PULSE=0 ; fi
if [[ "${step}" = "waveprep" ]]; then export MP_PULSE=0 ; fi
export wavempexec=${launcher}
export wave_mpmd=${mpmd_opt}

elif [ "${step}" = "atmanalrun" ]; then
elif [[ "${step}" = "atmanalrun" ]]; then

nth_max=$((${npe_node_max} / ${npe_node_atmanalrun}))

export NTHREADS_ATMANAL=${nth_atmanalrun:-${nth_max}}
[[ ${NTHREADS_ATMANAL} -gt ${nth_max} ]] && export NTHREADS_ATMANAL=${nth_max}
export APRUN_ATMANAL="${launcher} ${npe_atmanalrun}"

elif [ "${step}" = "atmensanalrun" ]; then
elif [[ "${step}" = "atmensanalrun" ]]; then

nth_max=$((${npe_node_max} / ${npe_node_atmensanalrun}))

export NTHREADS_ATMENSANAL=${nth_atmensanalrun:-${nth_max}}
[[ ${NTHREADS_ATMENSANAL} -gt ${nth_max} ]] && export NTHREADS_ATMENSANAL=${nth_max}
export APRUN_ATMENSANAL="${launcher} ${npe_atmensanalrun}"

elif [ "${step}" = "anal" ]; then
elif [[ "${step}" = "anal" ]]; then

nth_max=$((${npe_node_max} / ${npe_node_anal}))

Expand All @@ -83,15 +83,15 @@ elif [ "${step}" = "anal" ]; then
npe_gausfcanl=${npe_gausfcanl:-1}
export APRUN_GAUSFCANL="${launcher} ${npe_gausfcanl}"

elif [ "${step}" = "sfcanl" ]; then
elif [[ "${step}" = "sfcanl" ]]; then
nth_max=$((${npe_node_max} / ${npe_node_sfcanl}))

export NTHREADS_CYCLE=${nth_sfcanl:-14}
[[ ${NTHREADS_CYCLE} -gt ${npe_node_max} ]] && export NTHREADS_CYCLE=${npe_node_max}
npe_sfcanl=${ntiles:-6}
export APRUN_CYCLE="${launcher} ${npe_sfcanl}"

elif [ "${step}" = "gldas" ]; then
elif [[ "${step}" = "gldas" ]]; then

nth_max=$((${npe_node_max} / ${npe_node_gldas}))

Expand All @@ -103,23 +103,23 @@ elif [ "${step}" = "gldas" ]; then
[[ ${NTHREADS_GAUSSIAN} -gt ${nth_max} ]] && export NTHREADS_GAUSSIAN=${nth_max}
export APRUN_GAUSSIAN="${launcher} ${npe_gaussian}"

elif [ "${step}" = "eobs" ]; then
elif [[ "${step}" = "eobs" ]]; then

nth_max=$((${npe_node_max} / ${npe_node_eobs}))

export NTHREADS_GSI=${nth_gsi:-${nth_max}}
[[ ${NTHREADS_GSI} -gt ${nth_max} ]] && export NTHREADS_GSI=${nth_max}
export APRUN_GSI="${launcher} ${npe_gsi:-${npe_eobs:-${PBS_NP}}}"

elif [ "${step}" = "eupd" ]; then
elif [[ "${step}" = "eupd" ]]; then

nth_max=$((${npe_node_max} / ${npe_node_eupd}))

export NTHREADS_ENKF=${nth_enkf:-${nth_max}}
[[ ${NTHREADS_ENKF} -gt ${nth_max} ]] && export NTHREADS_ENKF=${nth_max}
export APRUN_ENKF="${launcher} ${npe_enkf:-${npe_eupd:-${PBS_NP}}}"

elif [ "${step}" = "fcst" ]; then
elif [[ "${step}" = "fcst" ]]; then

#PEs and PEs/node can differ for GFS and GDAS forecasts if threading differs
if [[ ${CDUMP} == "gfs" ]]; then
Expand All @@ -144,7 +144,7 @@ elif [ "${step}" = "fcst" ]; then
export APRUN_REMAP="${launcher} ${npe_remap:-${npe_fcst:-${PBS_NP}}}"
export I_MPI_DAPL_UD="enable"

elif [ "${step}" = "efcs" ]; then
elif [[ "${step}" = "efcs" ]]; then

nth_max=$((${npe_node_max} / ${npe_node_efcs}))

Expand All @@ -157,7 +157,7 @@ elif [ "${step}" = "efcs" ]; then
[[ ${NTHREADS_REGRID_NEMSIO} -gt ${nth_max} ]] && export NTHREADS_REGRID_NEMSIO=${nth_max}
export APRUN_REGRID_NEMSIO="${launcher} ${LEVS}"

elif [ "${step}" = "post" ]; then
elif [[ "${step}" = "post" ]]; then

nth_max=$((${npe_node_max} / ${npe_node_post}))

Expand All @@ -169,7 +169,7 @@ elif [ "${step}" = "post" ]; then
[[ ${NTHREADS_DWN} -gt ${nth_max} ]] && export NTHREADS_DWN=${nth_max}
export APRUN_NP="${launcher}"

elif [ "${step}" = "ecen" ]; then
elif [[ "${step}" = "ecen" ]]; then

nth_max=$((${npe_node_max} / ${npe_node_ecen}))

Expand All @@ -185,7 +185,7 @@ elif [ "${step}" = "ecen" ]; then
[[ ${NTHREADS_CALCINC} -gt ${nth_max} ]] && export NTHREADS_CALCINC=${nth_max}
export APRUN_CALCINC="${launcher} ${npe_ecen:-${PBS_NP}}"

elif [ "${step}" = "esfc" ]; then
elif [[ "${step}" = "esfc" ]]; then

nth_max=$((${npe_node_max} / ${npe_node_esfc}))

Expand All @@ -198,19 +198,19 @@ elif [ "${step}" = "esfc" ]; then
export APRUN_CYCLE="${launcher} ${npe_esfc}"


elif [ "${step}" = "epos" ]; then
elif [[ "${step}" = "epos" ]]; then

nth_max=$((${npe_node_max} / ${npe_node_epos}))

export NTHREADS_EPOS=${nth_epos:-${nth_max}}
[[ ${NTHREADS_EPOS} -gt ${nth_max} ]] && export NTHREADS_EPOS=${nth_max}
export APRUN_EPOS="${launcher} ${npe_epos:-${PBS_NP}}"

elif [ "${step}" = "init" ]; then
elif [[ "${step}" = "init" ]]; then

export APRUN="${launcher}"

elif [ "${step}" = "postsnd" ]; then
elif [[ "${step}" = "postsnd" ]]; then

nth_max=$((${npe_node_max} / ${npe_node_postsnd}))

Expand All @@ -222,11 +222,11 @@ elif [ "${step}" = "postsnd" ]; then
[[ ${NTHREADS_POSTSNDCFP} -gt ${nth_max} ]] && export NTHREADS_POSTSNDCFP=${nth_max}
export APRUN_POSTSNDCFP="${launcher} ${npe_postsndcfp}"

elif [ "${step}" = "awips" ]; then
elif [[ "${step}" = "awips" ]]; then

echo "WARNING: ${step} is not enabled on ${machine}!"

elif [ "${step}" = "gempak" ]; then
elif [[ "${step}" = "gempak" ]]; then

echo "WARNING: ${step} is not enabled on ${machine}!"

Expand Down
Loading

0 comments on commit 9dd25de

Please sign in to comment.