|
| 1 | +#!/bin/bash -x |
| 2 | + |
| 3 | +if [ $# -ne 1 ]; then |
| 4 | + |
| 5 | + echo "Must specify an input argument to set runtime environment variables!" |
| 6 | + echo "argument can be any one of the following:" |
| 7 | + echo "atmanalrun atmensanalrun" |
| 8 | + echo "anal sfcanl fcst post vrfy metp" |
| 9 | + echo "eobs eupd ecen efcs epos" |
| 10 | + echo "postsnd awips gempak" |
| 11 | + exit 1 |
| 12 | + |
| 13 | +fi |
| 14 | + |
| 15 | +step=$1 |
| 16 | +PARTITION_BATCH=${PARTITION_BATCH:-"s4"} |
| 17 | + |
| 18 | +if [[ ${PARTITION_BATCH} = "s4" ]]; then |
| 19 | + export npe_node_max=32 |
| 20 | +elif [[ ${PARTITION_BATCH} = "ivy" ]]; then |
| 21 | + export npe_node_max=20 |
| 22 | +fi |
| 23 | +export launcher="srun -l --export=ALL" |
| 24 | + |
| 25 | +# Configure MPI environment |
| 26 | +export OMP_STACKSIZE=2048000 |
| 27 | +export NTHSTACK=1024000000 |
| 28 | + |
| 29 | +ulimit -s unlimited |
| 30 | +ulimit -a |
| 31 | + |
| 32 | +export job=${PBS_JOBNAME:-${step}} |
| 33 | +export jobid=${job}.${PBS_JOBID:-$$} |
| 34 | + |
| 35 | + |
| 36 | +if [[ ${step} = "prep" || ${step} = "prepbufr" ]]; then |
| 37 | + |
| 38 | + npe_node_prep=${npe_node_prep:-${npe_node_max}} |
| 39 | + nth_max=$((npe_node_max / npe_node_prep)) |
| 40 | + |
| 41 | + export POE="NO" |
| 42 | + export BACK="NO" |
| 43 | + export sys_tp="S4" |
| 44 | + export launcher_PREP="srun" |
| 45 | + |
| 46 | +elif [[ ${step} = "waveinit" || ${step} = "waveprep" || ${step} = "wavepostsbs" || ${step} = "wavepostbndpnt" || ${step} = "wavepostbndpntbll" || ${step} = "wavepostpnt" ]]; then |
| 47 | + |
| 48 | + export mpmd="--multi-prog" |
| 49 | + export CFP_MP="YES" |
| 50 | + if [[ ${step} = "waveprep" ]]; then export MP_PULSE=0 ; fi |
| 51 | + export wavempexec=${launcher} |
| 52 | + export wave_mpmd=${mpmd} |
| 53 | + |
| 54 | +elif [[ ${step} = "atmanalrun" ]]; then |
| 55 | + |
| 56 | + export CFP_MP=${CFP_MP:-"YES"} |
| 57 | + export USE_CFP=${USE_CFP:-"YES"} |
| 58 | + export APRUNCFP="${launcher} -n \$ncmd --multi-prog" |
| 59 | + |
| 60 | + npe_node_atmanalrun=${npe_node_atmanalrun:-${npe_node_max}} |
| 61 | + nth_max=$((npe_node_max / npe_node_atmanalrun)) |
| 62 | + |
| 63 | + export NTHREADS_ATMANAL=${nth_atmanalrun:-${nth_max}} |
| 64 | + [[ ${NTHREADS_ATMANAL} -gt ${nth_max} ]] && export NTHREADS_ATMANAL=${nth_max} |
| 65 | + export APRUN_ATMANAL="${launcher} -n ${npe_atmanalrun:-0}" |
| 66 | + |
| 67 | +elif [[ ${step} = "atmensanalrun" ]]; then |
| 68 | + |
| 69 | + export CFP_MP=${CFP_MP:-"YES"} |
| 70 | + export USE_CFP=${USE_CFP:-"YES"} |
| 71 | + export APRUNCFP="${launcher} -n \$ncmd --multi-prog" |
| 72 | + |
| 73 | + npe_node_atmensanalrun=${npe_node_atmensanalrun:-${npe_node_max}} |
| 74 | + nth_max=$((npe_node_max / npe_node_atmensanalrun)) |
| 75 | + |
| 76 | + export NTHREADS_ATMENSANAL=${nth_atmensanalrun:-${nth_max}} |
| 77 | + [[ ${NTHREADS_ATMENSANAL} -gt ${nth_max} ]] && export NTHREADS_ATMENSANAL=${nth_max} |
| 78 | + export APRUN_ATMENSANAL="${launcher} -n ${npe_atmensanalrun:-0}" |
| 79 | + |
| 80 | +elif [[ ${step} = "aeroanlrun" ]]; then |
| 81 | + |
| 82 | + export APRUNCFP="${launcher} -n \$ncmd --multi-prog" |
| 83 | + |
| 84 | + npe_node_aeroanlrun=${npe_node_aeroanlrun:-${npe_node_max}} |
| 85 | + nth_max=$((npe_node_max / npe_node_aeroanlrun)) |
| 86 | + |
| 87 | + export NTHREADS_AEROANL=${nth_aeroanlrun:-${nth_max}} |
| 88 | + [[ ${NTHREADS_AEROANL} -gt ${nth_max} ]] && export NTHREADS_AEROANL=${nth_max} |
| 89 | + export APRUN_AEROANL="${launcher} -n ${npe_aeroanlrun:-0}" |
| 90 | + |
| 91 | +elif [[ ${step} = "anal" || ${step} = "analcalc" ]]; then |
| 92 | + |
| 93 | + export MKL_NUM_THREADS=4 |
| 94 | + export MKL_CBWR=AUTO |
| 95 | + |
| 96 | + export CFP_MP=${CFP_MP:-"YES"} |
| 97 | + export USE_CFP=${USE_CFP:-"YES"} |
| 98 | + export APRUNCFP="${launcher} -n \$ncmd --multi-prog" |
| 99 | + |
| 100 | + npe_node_anal=${npe_node_anal:-${npe_node_max}} |
| 101 | + nth_max=$((npe_node_max / npe_node_anal)) |
| 102 | + |
| 103 | + export NTHREADS_GSI=${nth_anal:-${nth_max}} |
| 104 | + [[ ${NTHREADS_GSI} -gt ${nth_max} ]] && export NTHREADS_GSI=${nth_max} |
| 105 | + export APRUN_GSI=${launcher} |
| 106 | + |
| 107 | + export NTHREADS_CALCINC=${nth_calcinc:-1} |
| 108 | + [[ ${NTHREADS_CALCINC} -gt ${nth_max} ]] && export NTHREADS_CALCINC=${nth_max} |
| 109 | + export APRUN_CALCINC=${launcher} |
| 110 | + |
| 111 | + export NTHREADS_CYCLE=${nth_cycle:-12} |
| 112 | + [[ ${NTHREADS_CYCLE} -gt ${npe_node_max} ]] && export NTHREADS_CYCLE=${npe_node_max} |
| 113 | + npe_cycle=${ntiles:-6} |
| 114 | + export APRUN_CYCLE="${launcher} -n ${npe_cycle:-0}" |
| 115 | + |
| 116 | + |
| 117 | + export NTHREADS_GAUSFCANL=1 |
| 118 | + npe_gausfcanl=${npe_gausfcanl:-1} |
| 119 | + export APRUN_GAUSFCANL="${launcher} -n ${npe_gausfcanl:-0}" |
| 120 | + |
| 121 | +elif [[ ${step} = "sfcanl" ]]; then |
| 122 | + npe_node_sfcanl=${npe_node_sfcanl:-${npe_node_max}} |
| 123 | + nth_max=$((npe_node_max / npe_node_sfcanl)) |
| 124 | + |
| 125 | + export NTHREADS_CYCLE=${nth_sfcanl:-14} |
| 126 | + [[ ${NTHREADS_CYCLE} -gt ${npe_node_max} ]] && export NTHREADS_CYCLE=${npe_node_max} |
| 127 | + npe_sfcanl=${ntiles:-6} |
| 128 | + export APRUN_CYCLE="${launcher} -n ${npe_sfcanl:-0}" |
| 129 | + |
| 130 | +elif [[ ${step} = "gldas" ]]; then |
| 131 | + |
| 132 | + npe_node_gldas=${npe_node_gldas:-${npe_node_max}} |
| 133 | + nth_max=$((npe_node_max / npe_node_gldas)) |
| 134 | + |
| 135 | + export NTHREADS_GLDAS=${nth_gldas:-${nth_max}} |
| 136 | + [[ ${NTHREADS_GLDAS} -gt ${nth_max} ]] && export NTHREADS_GLDAS=${nth_max} |
| 137 | + export APRUN_GLDAS="${launcher} -n ${npe_gldas:-0}" |
| 138 | + |
| 139 | + export NTHREADS_GAUSSIAN=${nth_gaussian:-1} |
| 140 | + [[ ${NTHREADS_GAUSSIAN} -gt ${nth_max} ]] && export NTHREADS_GAUSSIAN=${nth_max} |
| 141 | + export APRUN_GAUSSIAN="${launcher} -n ${npe_gaussian:-0}" |
| 142 | + |
| 143 | +# Must run data processing with exactly the number of tasks as time |
| 144 | +# periods being processed. |
| 145 | + |
| 146 | + gldas_spinup_hours=${gldas_spinup_hours:-0} |
| 147 | + npe_gldas_data_proc=$((gldas_spinup_hours + 12)) |
| 148 | + export APRUN_GLDAS_DATA_PROC="${launcher} -n ${npe_gldas_data_proc} --multi-prog" |
| 149 | + |
| 150 | +elif [[ ${step} = "eobs" ]]; then |
| 151 | + |
| 152 | + export MKL_NUM_THREADS=4 |
| 153 | + export MKL_CBWR=AUTO |
| 154 | + |
| 155 | + export CFP_MP=${CFP_MP:-"YES"} |
| 156 | + export USE_CFP=${USE_CFP:-"YES"} |
| 157 | + export APRUNCFP="${launcher} -n \$ncmd --multi-prog" |
| 158 | + |
| 159 | + npe_node_eobs=${npe_node_eobs:-${npe_node_max}} |
| 160 | + nth_max=$((npe_node_max / npe_node_eobs)) |
| 161 | + |
| 162 | + export NTHREADS_GSI=${nth_eobs:-${nth_max}} |
| 163 | + [[ ${NTHREADS_GSI} -gt ${nth_max} ]] && export NTHREADS_GSI=${nth_max} |
| 164 | + export APRUN_GSI=${launcher} |
| 165 | + |
| 166 | +elif [[ ${step} = "eupd" ]]; then |
| 167 | + |
| 168 | + export CFP_MP=${CFP_MP:-"YES"} |
| 169 | + export USE_CFP=${USE_CFP:-"YES"} |
| 170 | + export APRUNCFP="${launcher} -n \$ncmd --multi-prog" |
| 171 | + |
| 172 | + npe_node_eupd=${npe_node_eupd:-${npe_node_max}} |
| 173 | + nth_max=$((npe_node_max / npe_node_eupd)) |
| 174 | + |
| 175 | + export NTHREADS_ENKF=${nth_eupd:-${nth_max}} |
| 176 | + [[ ${NTHREADS_ENKF} -gt ${nth_max} ]] && export NTHREADS_ENKF=${nth_max} |
| 177 | + export APRUN_ENKF=${launcher} |
| 178 | + |
| 179 | +elif [[ ${step} = "fcst" ]]; then |
| 180 | + |
| 181 | + #PEs and PEs/node can differ for GFS and GDAS forecasts if threading differs |
| 182 | + if [[ ${CDUMP:-gdas} == "gfs" ]]; then |
| 183 | + npe_fcst=${npe_fcst_gfs:-0} |
| 184 | + npe_node_fcst=${npe_node_fcst_gfs:-${npe_node_max}} |
| 185 | + nth_fv3=${nth_fv3_gfs:-1} |
| 186 | + fi |
| 187 | + |
| 188 | + npe_node_fcst=${npe_node_fcst:-${npe_node_max}} |
| 189 | + nth_max=$((npe_node_max / npe_node_fcst)) |
| 190 | + |
| 191 | + export NTHREADS_FV3=${nth_fv3:-${nth_max}} |
| 192 | + [[ ${NTHREADS_FV3} -gt ${nth_max} ]] && export NTHREADS_FV3=${nth_max} |
| 193 | + export cores_per_node=${npe_node_max} |
| 194 | + export APRUN_FV3="${launcher} -n ${npe_fcst:-0}" |
| 195 | + |
| 196 | + export NTHREADS_REGRID_NEMSIO=${nth_regrid_nemsio:-1} |
| 197 | + [[ ${NTHREADS_REGRID_NEMSIO} -gt ${nth_max} ]] && export NTHREADS_REGRID_NEMSIO=${nth_max} |
| 198 | + export APRUN_REGRID_NEMSIO=${launcher} |
| 199 | + |
| 200 | + export NTHREADS_REMAP=${nth_remap:-2} |
| 201 | + [[ ${NTHREADS_REMAP} -gt ${nth_max} ]] && export NTHREADS_REMAP=${nth_max} |
| 202 | + export APRUN_REMAP=${launcher} |
| 203 | + export I_MPI_DAPL_UD="enable" |
| 204 | + |
| 205 | +elif [[ ${step} = "efcs" ]]; then |
| 206 | + |
| 207 | + npe_node_efcs=${npe_node_efcs:-${npe_node_max}} |
| 208 | + nth_max=$((npe_node_max / npe_node_efcs)) |
| 209 | + |
| 210 | + export NTHREADS_FV3=${nth_efcs:-${nth_max}} |
| 211 | + [[ ${NTHREADS_FV3} -gt ${nth_max} ]] && export NTHREADS_FV3=${nth_max} |
| 212 | + export cores_per_node=${npe_node_max} |
| 213 | + export APRUN_FV3="${launcher} -n ${npe_efcs:-0}" |
| 214 | + |
| 215 | + export NTHREADS_REGRID_NEMSIO=${nth_regrid_nemsio:-1} |
| 216 | + [[ ${NTHREADS_REGRID_NEMSIO} -gt ${nth_max} ]] && export NTHREADS_REGRID_NEMSIO=${nth_max} |
| 217 | + export APRUN_REGRID_NEMSIO="${launcher} ${LEVS:-128}" |
| 218 | + |
| 219 | +elif [[ ${step} = "post" ]]; then |
| 220 | + |
| 221 | + npe_node_post=${npe_node_post:-npe_node_max} |
| 222 | + nth_max=$((npe_node_max / npe_node_post)) |
| 223 | + |
| 224 | + export NTHREADS_NP=${nth_np:-1} |
| 225 | + [[ ${NTHREADS_NP} -gt ${nth_max} ]] && export NTHREADS_NP=${nth_max} |
| 226 | + export APRUN_NP=${launcher} |
| 227 | + |
| 228 | + export NTHREADS_DWN=${nth_dwn:-1} |
| 229 | + [[ ${NTHREADS_DWN} -gt ${nth_max} ]] && export NTHREADS_DWN=${nth_max} |
| 230 | + export APRUN_DWN=${launcher} |
| 231 | + |
| 232 | +elif [[ ${step} = "ecen" ]]; then |
| 233 | + |
| 234 | + npe_node_ecen=${npe_node_ecen:-${npe_node_max}} |
| 235 | + nth_max=$((npe_node_max / npe_node_ecen)) |
| 236 | + |
| 237 | + export NTHREADS_ECEN=${nth_ecen:-${nth_max}} |
| 238 | + [[ ${NTHREADS_ECEN} -gt ${nth_max} ]] && export NTHREADS_ECEN=${nth_max} |
| 239 | + export APRUN_ECEN=${launcher} |
| 240 | + |
| 241 | + export NTHREADS_CHGRES=${nth_chgres:-12} |
| 242 | + [[ ${NTHREADS_CHGRES} -gt ${npe_node_max} ]] && export NTHREADS_CHGRES=${npe_node_max} |
| 243 | + export APRUN_CHGRES="time" |
| 244 | + |
| 245 | + export NTHREADS_CALCINC=${nth_calcinc:-1} |
| 246 | + [[ ${NTHREADS_CALCINC} -gt ${nth_max} ]] && export NTHREADS_CALCINC=${nth_max} |
| 247 | + export APRUN_CALCINC=${launcher} |
| 248 | + |
| 249 | +elif [[ ${step} = "esfc" ]]; then |
| 250 | + |
| 251 | + npe_node_esfc=${npe_node_esfc:-${npe_node_max}} |
| 252 | + nth_max=$((npe_node_max / npe_node_esfc)) |
| 253 | + |
| 254 | + export NTHREADS_ESFC=${nth_esfc:-${nth_max}} |
| 255 | + [[ ${NTHREADS_ESFC} -gt ${nth_max} ]] && export NTHREADS_ESFC=${nth_max} |
| 256 | + export APRUN_ESFC="${launcher} -n ${npe_esfc:-0}" |
| 257 | + |
| 258 | + export NTHREADS_CYCLE=${nth_cycle:-14} |
| 259 | + [[ ${NTHREADS_CYCLE} -gt ${npe_node_max} ]] && export NTHREADS_CYCLE=${npe_node_max} |
| 260 | + export APRUN_CYCLE="${launcher} -n ${npe_esfc:-0}" |
| 261 | + |
| 262 | +elif [[ ${step} = "epos" ]]; then |
| 263 | + |
| 264 | + npe_node_epos=${npe_node_epos:-${npe_node_max}} |
| 265 | + nth_max=$((npe_node_max / npe_node_epos)) |
| 266 | + |
| 267 | + export NTHREADS_EPOS=${nth_epos:-${nth_max}} |
| 268 | + [[ ${NTHREADS_EPOS} -gt ${nth_max} ]] && export NTHREADS_EPOS=${nth_max} |
| 269 | + export APRUN_EPOS=${launcher} |
| 270 | + |
| 271 | +elif [[ ${step} = "init" ]]; then |
| 272 | + |
| 273 | + export APRUN=${launcher} |
| 274 | + |
| 275 | +elif [[ ${step} = "postsnd" ]]; then |
| 276 | + |
| 277 | + npe_node_postsnd=${npe_node_postsnd:-${npe_node_max}} |
| 278 | + nth_max=$((npe_node_max / npe_node_postsnd)) |
| 279 | + |
| 280 | + export NTHREADS_POSTSND=${nth_postsnd:-1} |
| 281 | + [[ ${NTHREADS_POSTSND} -gt ${nth_max} ]] && export NTHREADS_POSTSND=${nth_max} |
| 282 | + export APRUN_POSTSND=${launcher} |
| 283 | + |
| 284 | + export NTHREADS_POSTSNDCFP=${nth_postsndcfp:-1} |
| 285 | + [[ ${NTHREADS_POSTSNDCFP} -gt ${nth_max} ]] && export NTHREADS_POSTSNDCFP=${nth_max} |
| 286 | + export APRUN_POSTSNDCFP=${launcher} |
| 287 | + |
| 288 | +elif [[ ${step} = "awips" ]]; then |
| 289 | + |
| 290 | + echo "WARNING: ${step} is not enabled on S4!" |
| 291 | + |
| 292 | +elif [[ ${step} = "gempak" ]]; then |
| 293 | + |
| 294 | + echo "WARNING: ${step} is not enabled on S4!" |
| 295 | +fi |
0 commit comments