link_files.sh - UK-FVCOM-Usergroup/uk-fvcom GitHub Wiki
This is a bash version of the link_grib.csh
supplied with WPS.
set -eu
alpha=({A..Z}) i1=0 i2=0 i3=0
if $# -eq 1; then
rm -f GRIBFILE.??? 2>&1 > /dev/null
for f in "$1"/*; do
ln -sf "$f" GRIBFILE.${alpha[$i3]}${alpha[$i2]}${alpha[$i1]}
let i1=i1+1
if [[ $i1 -ge 26 ]]; then
i1=0
let i2=i2+1
if [[ $i2 -ge 26 ]]; then
i2=0
let i3=i3+1
if [[ $i3 -ge 26 ]]; then
echo "RAN OUT OF GRIB FILE SUFFIXES!"
fi
fi
fi
done elif $# -gt 1; then
rm -f GRIBFILE.??? 2>&1 > /dev/null
for f in $@; do
if [[ $f != "." ]]; then
ln -sf ${f} GRIBFILE.${alpha[$i3]}${alpha[$i2]}${alpha[$i1]}
let i1=i1+1
if [[ $i1 -ge 26 ]]; then
i1=0
let i2=i2+1
if [[ $i2 -ge 26 ]]; then
i2=0
let i3=i3+1
if [[ $i3 -ge 26 ]]; then
echo "RAN OUT OF GRIB FILE SUFFIXES!"
fi
fi
fi
fi
done elif $# -eq 0; then echo " " echo " " echo " Please provide some GRIB data to link" echo " usage: $0 path_to_grib_data/grib_data_root" echo " " echo " " fi