Skip to content

Commit

Permalink
Change tab to 2-spaces for prdgen scripts
Browse files Browse the repository at this point in the history
 On branch feature/gefs_v13_atmos_prep
	modified:   scripts/exgefs_atmos_prdgen.sh
	modified:   ush/gefs_prdgen.sh
	modified:   ush/gefs_prdgen_driver.sh

Refs: NOAA-EMC#95
  • Loading branch information
XianwuXue-NOAA committed Jan 9, 2023
1 parent e0c2646 commit 7523fc1
Show file tree
Hide file tree
Showing 3 changed files with 553 additions and 552 deletions.
120 changes: 60 additions & 60 deletions scripts/exgefs_atmos_prdgen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ echo "$(date -u) begin ${.sh.file}"

set -xa
if [[ ${STRICT:-NO} == "YES" ]]; then
# Turn on strict bash error checking
set -eu
# Turn on strict bash error checking
set -eu
fi

export RERUN=${RERUN:-RESTART}
Expand All @@ -16,53 +16,53 @@ echo "PRDGEN_STREAMS = $PRDGEN_STREAMS"
export overwrite=yes

if [[ $SENDCOM == "YES" && $save_pgrb2_p5 == YES ]]; then
mkdir -m 775 -p $COMOUT/$COMPONENT/pgrb2p5
mkdir -m 775 -p $COMOUT/$COMPONENT/pgrb2p5
fi
if [[ $SENDCOM == "YES" && $save_pgrb2_p25 == YES ]]; then
mkdir -m 775 -p $COMOUT/$COMPONENT/pgrb2p25
mkdir -m 775 -p $COMOUT/$COMPONENT/pgrb2p25
fi

case ${FORECAST_SEGMENT:-none} in
hr)
start_hour=0
end_hour=${fhmaxh}
;;
lr)
start_hour=$((${fhmaxh}+1))
end_hour=${fhmax}
PRDGEN_STREAMS=$PRDGEN_STREAMS_LR
;;
*)
start_hour=0
end_hour=${fhmaxh}
;;
hr)
start_hour=0
end_hour=${fhmaxh}
;;
lr)
start_hour=$((${fhmaxh}+1))
end_hour=${fhmax}
PRDGEN_STREAMS=$PRDGEN_STREAMS_LR
;;
*)
start_hour=0
end_hour=${fhmaxh}
;;
esac # $FORECAST_SEGMENT in

for stream in ${PRDGEN_STREAMS[@]}; do
# Filter out hours based on forecast segment
typeset -a hours=($(echo ${PRDGEN_HOURS[$stream]}))
echo "hours = $hours"
for i in "${!hours[@]}"; do
hour=${hours[i]}
echo "i = $i hour = $hour"
if [[ $hour -lt $start_hour || $hour -gt $end_hour ]]; then
unset 'hours[i]'
fi
done
PRDGEN_HOURS[$stream]="${hours[@]}"
unset hours

# Ensure required variables are defined
for var in PRDGEN_GRID PRDGEN_GRID_SPEC PRDGEN_HOURS PRDGEN_SUBMC PRDGEN_A_DIR PRDGEN_A_PREFIX PRDGEN_A_LIST_F00 PRDGEN_A_LIST_FHH; do
pointer="$var[$stream]"
if [[ -z ${!pointer} ]]; then
echo "FATAL ERROR in ${.sh.file}: $var not defined for $stream"
exit -1
fi
done

# Print out settings for this stream
cat <<-EOF
# Filter out hours based on forecast segment
typeset -a hours=($(echo ${PRDGEN_HOURS[$stream]}))
echo "hours = $hours"
for i in "${!hours[@]}"; do
hour=${hours[i]}
echo "i = $i hour = $hour"
if [[ $hour -lt $start_hour || $hour -gt $end_hour ]]; then
unset 'hours[i]'
fi
done
PRDGEN_HOURS[$stream]="${hours[@]}"
unset hours

# Ensure required variables are defined
for var in PRDGEN_GRID PRDGEN_GRID_SPEC PRDGEN_HOURS PRDGEN_SUBMC PRDGEN_A_DIR PRDGEN_A_PREFIX PRDGEN_A_LIST_F00 PRDGEN_A_LIST_FHH; do
pointer="$var[$stream]"
if [[ -z ${!pointer} ]]; then
echo "FATAL ERROR in ${.sh.file}: $var not defined for $stream"
exit -1
fi
done

# Print out settings for this stream
cat <<-EOF
Settings for prgden stream $stream:
Grid: ${PRDGEN_GRID[$stream]}
Grid Spec: ${PRDGEN_GRID_SPEC[$stream]}
Expand All @@ -73,7 +73,7 @@ for stream in ${PRDGEN_STREAMS[@]}; do
A Parmlist f00: ${PRDGEN_A_LIST_F00[$stream]}
A Parmlist fhh: ${PRDGEN_A_LIST_FHH[$stream]}
B Dir: ${PRDGEN_B_DIR[$stream]:-""}
B Prefix: ${PRDGEN_B_PREFIX[$stream]:-""}
B Prefix: ${PRDGEN_B_PREFIX[$stream]:-""}
B Parmlist f00: ${PRDGEN_B_LIST_F00[$stream]:-""}
B Parmlist fhh: ${PRDGEN_B_LIST_FHH[$stream]:-""}
Do Anaylsis: ${PRDGEN_DO_ANALYSIS[$stream]:-"NO (default)"}
Expand All @@ -86,21 +86,21 @@ done
#################################
rm -f prdgen.cmdfile
for stream in ${PRDGEN_STREAMS[@]}; do
if [[ $SENDCOM == "YES" ]]; then
mkdir -m 775 -p $COMOUT/$COMPONENT/${PRDGEN_A_DIR[${stream}]}
if [[ ! -z ${PRDGEN_B_DIR[$stream]} ]]; then
mkdir -m 775 -p $COMOUT/$COMPONENT/${PRDGEN_B_DIR[${stream}]}
fi
fi

subdata=${DATA}/${stream}
if [ ! -d ${subdata} ]; then
mkdir -p ${subdata};
fi
infile=${subdata}/${stream}.in
outfile=${subdata}/${stream}.out

cat > ${infile} <<-EOF
if [[ $SENDCOM == "YES" ]]; then
mkdir -m 775 -p $COMOUT/$COMPONENT/${PRDGEN_A_DIR[${stream}]}
if [[ ! -z ${PRDGEN_B_DIR[$stream]} ]]; then
mkdir -m 775 -p $COMOUT/$COMPONENT/${PRDGEN_B_DIR[${stream}]}
fi
fi

subdata=${DATA}/${stream}
if [ ! -d ${subdata} ]; then
mkdir -p ${subdata};
fi
infile=${subdata}/${stream}.in
outfile=${subdata}/${stream}.out

cat > ${infile} <<-EOF
jobgrid="${PRDGEN_GRID[$stream]}"
grid_spec="${PRDGEN_GRID_SPEC[$stream]}"
hours="${PRDGEN_HOURS[$stream]}"
Expand All @@ -116,7 +116,7 @@ for stream in ${PRDGEN_STREAMS[@]}; do
do_analysis="${PRDGEN_DO_ANALYSIS[$stream]:-NO}"
EOF

echo "$HOMEgefs/ush/gefs_prdgen_driver.sh $stream $subdata \"$infile\" 2>&1 >${outfile}" >> prdgen.cmdfile
echo "$HOMEgefs/ush/gefs_prdgen_driver.sh $stream $subdata \"$infile\" 2>&1 >${outfile}" >> prdgen.cmdfile

done

Expand All @@ -134,8 +134,8 @@ $APRUN_MPMD
export err=$?

if [[ $err != 0 ]]; then
echo "FATAL ERROR in ${.sh.file}: One or more prdgen streams in $MP_CMDFILE failed!"
exit $err
echo "FATAL ERROR in ${.sh.file}: One or more prdgen streams in $MP_CMDFILE failed!"
exit $err
fi
#############################################################

Expand Down
Loading

0 comments on commit 7523fc1

Please sign in to comment.