Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize wavepostpnt #2657

Merged
merged 16 commits into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 28 additions & 32 deletions scripts/exgfs_wave_post_pnt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ source "${USHgfs}/preamble.sh"
cp -f ${PARMgfs}/wave/wave_${NET}.buoys buoy.loc.temp
if [ "$DOBNDPNT_WAV" = YES ]; then
#only do boundary points
sed -n '/^\$.*/!p' buoy.loc.temp | grep IBP > buoy.loc || {
sed -n '/^\$.*IBP.*/!p' buoy.loc.temp > buoy.loc || {
WalterKolczynski-NOAA marked this conversation as resolved.
Show resolved Hide resolved
echo "WARNING: No boundary points found in buoy file ${PARMgfs}/wave/wave_${NET}.buoys"
echo " Ending job without doing anything."
exit 0
Expand Down Expand Up @@ -289,14 +289,14 @@ source "${USHgfs}/preamble.sh"
fi

# Create new buoy_log.ww3
cat buoy.loc | awk '{print $3}' | sed 's/'\''//g' > ibp_tags
awk '{print $3}' buoy.loc | sed 's/'\''//g' > ibp_tags
grep -F -f ibp_tags buoy_log.ww3 > buoy_log.tmp
rm -f buoy_log.dat
mv buoy_log.tmp buoy_log.dat

grep -F -f ibp_tags buoy_lst.loc > buoy_tmp1.loc
#sed '$d' buoy_tmp1.loc > buoy_tmp2.loc
buoys=$(awk '{ print $1 }' buoy_tmp1.loc)
awk '{ print $1 }' buoy_tmp1.loc > buoy_lst.txt
Nb=$(wc buoy_tmp1.loc | awk '{ print $1 }')
rm -f buoy_tmp1.loc

Expand Down Expand Up @@ -349,6 +349,8 @@ source "${USHgfs}/preamble.sh"

# 1.a.2 Loop over forecast time to generate post files
fhr=$FHMIN_WAV
# Generated sed-searchable paths
escaped_USHgfs="${USHgfs//\//\\\/}"
while [ $fhr -le $FHMAX_WAV_PNT ]; do

echo " Creating the wave point scripts at : $(date)"
Expand All @@ -365,6 +367,7 @@ source "${USHgfs}/preamble.sh"

# Create instances of directories for spec and gridded output
export SPECDATA=${DATA}/output_$YMDHMS
escaped_SPECDATA="${SPECDATA//\//\\\/}"
export BULLDATA=${DATA}/output_$YMDHMS
cp $DATA/mod_def.${waveuoutpGRD} mod_def.${waveuoutpGRD}

Expand All @@ -385,19 +388,15 @@ source "${USHgfs}/preamble.sh"
if [ "$DOSPC_WAV" = 'YES' ]
then
export dtspec=3600.
for buoy in $buoys
do
echo "${USHgfs}/wave_outp_spec.sh $buoy $ymdh spec $SPECDATA > $SPECDATA/spec_$buoy.out 2>&1" >> tmpcmdfile.$FH3
done
# Construct the wave_outp_spec (spec) command to run on each buoy in buoy_lst.txt
sed "s/^\(.*\)$/${escaped_USHgfs}\/wave_outp_spec.sh \1 ${ymdh} spec ${escaped_SPECDATA} > ${escaped_SPECDATA}\/spec_\1.out 2>&1/" buoy_lst.txt >> "tmpcmdfile.${FH3}"
fi

if [ "$DOBLL_WAV" = 'YES' ]
then
export dtspec=3600.
for buoy in $buoys
do
echo "${USHgfs}/wave_outp_spec.sh $buoy $ymdh bull $SPECDATA > $SPECDATA/bull_$buoy.out 2>&1" >> tmpcmdfile.$FH3
done
# Construct the wave_outp_spec (bull) command to run on each buoy in buoy_lst.txt
sed "s/^\(.*\)$/${escaped_USHgfs}\/wave_outp_spec.sh \1 ${ymdh} bull ${escaped_SPECDATA} > ${escaped_SPECDATA}\/bull_\1.out 2>&1/" buoy_lst.txt >> "tmpcmdfile.${FH3}"
fi

split -n l/1/10 tmpcmdfile.$FH3 > cmdfile.${FH3}.01
Expand Down Expand Up @@ -503,46 +502,43 @@ source "${USHgfs}/preamble.sh"

cd $DATA

echo "Before create cmdfile for cat bouy : $(date)"
rm -f cmdfile.bouy
touch cmdfile.bouy
chmod 744 cmdfile.bouy
echo "Before create cmdfile for cat buoy : $(date)"
rm -f cmdfile.buoy
touch cmdfile.buoy
chmod 744 cmdfile.buoy
CATOUTDIR=${DATA}/pnt_cat_out
escaped_CATOUTDIR="${CATOUTDIR//\//\\\/}"
mkdir -p ${CATOUTDIR}

if [ "$DOSPC_WAV" = 'YES' ]
then
for buoy in $buoys
do
echo "${USHgfs}/wave_outp_cat.sh $buoy $FHMAX_WAV_PNT spec > ${CATOUTDIR}/spec_cat_$buoy.out 2>&1" >> cmdfile.bouy
done
# Construct wave_outp_cat (spec) call for each buoy in buoy_lst.txt
sed "s/^\(.*\)$/${escaped_USHgfs}\/wave_outp_cat.sh \1 ${FHMAX_WAV_PNT} spec > ${escaped_CATOUTDIR}\/spec_cat_\1.out 2>&1/" buoy_lst.txt >> cmdfile.buoy
fi

if [ "$DOBLL_WAV" = 'YES' ]
then
for buoy in $buoys
do
echo "${USHgfs}/wave_outp_cat.sh $buoy $FHMAX_WAV_PNT bull > ${CATOUTDIR}/bull_cat_$buoy.out 2>&1" >> cmdfile.bouy
done
# Construct wave_outp_cat (bull) call for each buoy in buoy_lst.txt
sed "s/^\(.*\)$/${escaped_USHgfs}\/wave_outp_cat.sh \1 ${FHMAX_WAV_PNT} bull > ${escaped_CATOUTDIR}\/bull_cat_\1.out 2>&1/" buoy_lst.txt >> cmdfile.buoy
fi

if [ ${CFP_MP:-"NO"} = "YES" ]; then
nfile=0
ifile=0
iline=1
ifirst='yes'
nlines=$( wc -l cmdfile.bouy | awk '{print $1}' )
nlines=$( wc -l < cmdfile.buoy)
while [ $iline -le $nlines ]; do
line=$( sed -n ''$iline'p' cmdfile.bouy )
line=$( sed -n ''$iline'p' cmdfile.buoy )
if [ -z "$line" ]; then
break
else
if [ "$ifirst" = 'yes' ]; then
echo "#!/bin/sh" > cmdfile.bouy.$nfile
echo "$nfile cmdfile.bouy.$nfile" >> cmdmprogbouy
chmod 744 cmdfile.bouy.$nfile
echo "#!/bin/sh" > cmdfile.buoy.$nfile
echo "$nfile cmdfile.buoy.$nfile" >> cmdmprogbuoy
chmod 744 cmdfile.buoy.$nfile
fi
echo $line >> cmdfile.bouy.$nfile
echo $line >> cmdfile.buoy.$nfile
nfile=$(( nfile + 1 ))
if [ $nfile -eq $NTASKS ]; then
nfile=0
Expand All @@ -553,7 +549,7 @@ source "${USHgfs}/preamble.sh"
done
fi

wavenproc=$(wc -l cmdfile.bouy | awk '{print $1}')
wavenproc=$(wc -l < cmdfile.buoy)
wavenproc=$(echo $((${wavenproc}<${NTASKS}?${wavenproc}:${NTASKS})))

set +x
Expand All @@ -566,9 +562,9 @@ source "${USHgfs}/preamble.sh"
if [ "$wavenproc" -gt '1' ]
then
if [ ${CFP_MP:-"NO"} = "YES" ]; then
${wavempexec} -n ${wavenproc} ${wave_mpmd} cmdmprogbouy
${wavempexec} -n "${wavenproc}" "${wave_mpmd}" cmdmprogbuoy
else
${wavempexec} ${wavenproc} ${wave_mpmd} cmdfile.bouy
${wavempexec} "${wavenproc}" "${wave_mpmd}" cmdfile.buoy
fi
exit=$?
else
WalterKolczynski-NOAA marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
39 changes: 15 additions & 24 deletions ush/wave_outp_spec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -73,21 +73,7 @@ source "${USHgfs}/preamble.sh"
exit 1
else
buoy=$bloc
grep $buoy ${DATA}/buoy_log.ww3 > tmp_list.loc
while read line
do
buoy_name=$(echo $line | awk '{print $2}')
if [ $buoy = $buoy_name ]
then
point=$(echo $line | awk '{ print $1 }')
set +x
echo " Location ID/# : $buoy (${point})"
echo " Spectral output start time : $ymdh "
echo ' '
set_trace
break
fi
done < tmp_list.loc
point=$(awk "{if (\$2 == \"${buoy}\"){print \$1; exit} }" "${DATA}/buoy_log.ww3")
if [ -z "$point" ]
then
set +x
Expand All @@ -97,6 +83,11 @@ source "${USHgfs}/preamble.sh"
echo ' '
set_trace
exit 2
else
set +x
echo " Location ID/# : $buoy (${point})"
echo " Spectral output start time : $ymdh "
echo ' '
fi
fi

Expand Down Expand Up @@ -200,27 +191,27 @@ source "${USHgfs}/preamble.sh"
then
if [ "$specdir" = "bull" ]
then
cat $outfile | sed -e '9,$d' >> ${STA_DIR}/${specdir}fhr/$WAV_MOD_TAG.${ymdh}.$buoy.bull
cat $coutfile | sed -e '8,$d' >> ${STA_DIR}/c${specdir}fhr/$WAV_MOD_TAG.${ymdh}.$buoy.cbull
sed '9,$d' "${outfile}" >> "${STA_DIR}/${specdir}fhr/${WAV_MOD_TAG}.${ymdh}.${buoy}.bull"
sed '8,$d' "${coutfile}" >> "${STA_DIR}/c${specdir}fhr/${WAV_MOD_TAG}.${ymdh}.${buoy}.cbull"
else
cat $outfile >> ${STA_DIR}/${specdir}fhr/$WAV_MOD_TAG.${ymdh}.$buoy.spec
cat $outfile >> "${STA_DIR}/${specdir}fhr/${WAV_MOD_TAG}.${ymdh}.${buoy}.spec"
fi
elif [ "${ymdh}" = "${YMDHE}" ]
then
if [ "$specdir" = "bull" ]
then
cat $outfile | sed -e '1,7d' >> ${STA_DIR}/${specdir}fhr/$WAV_MOD_TAG.${ymdh}.$buoy.bull
cat $coutfile | sed -e '1,6d' >> ${STA_DIR}/c${specdir}fhr/$WAV_MOD_TAG.${ymdh}.$buoy.cbull
sed '1,7d' "${outfile}" >> "${STA_DIR}/${specdir}fhr/${WAV_MOD_TAG}.${ymdh}.${buoy}.bull"
sed '1,6d' "${coutfile}" >> "${STA_DIR}/c${specdir}fhr/${WAV_MOD_TAG}.${ymdh}.${buoy}.cbull"
else
cat $outfile | sed -n "/^${YMD} ${HMS}$/,\$p" >> ${STA_DIR}/${specdir}fhr/$WAV_MOD_TAG.${ymdh}.$buoy.spec
sed -n "/^${YMD} ${HMS}$/,\$p" "${outfile}" >> "${STA_DIR}/${specdir}fhr/${WAV_MOD_TAG}.${ymdh}.${buoy}.spec"
fi
else
if [ "$specdir" = "bull" ]
then
cat $outfile | sed -e '1,7d' | sed -e '2,$d' >> ${STA_DIR}/${specdir}fhr/$WAV_MOD_TAG.${ymdh}.$buoy.bull
cat $coutfile | sed -e '1,6d' | sed -e '2,$d' >> ${STA_DIR}/c${specdir}fhr/$WAV_MOD_TAG.${ymdh}.$buoy.cbull
sed '8q;d' "${outfile}" >> "${STA_DIR}/${specdir}fhr/${WAV_MOD_TAG}.${ymdh}.${buoy}.bull"
sed '7q;d' "${coutfile}" >> "${STA_DIR}/c${specdir}fhr/${WAV_MOD_TAG}.${ymdh}.${buoy}.cbull"
else
cat $outfile | sed -n "/^${YMD} ${HMS}$/,\$p" >> ${STA_DIR}/${specdir}fhr/$WAV_MOD_TAG.${ymdh}.$buoy.spec
sed -n "/^${YMD} ${HMS}$/,\$p" "${outfile}" >> "${STA_DIR}/${specdir}fhr/${WAV_MOD_TAG}.${ymdh}.${buoy}.spec"
fi
fi
else
Expand Down
Loading