Skip to content
Merged
Changes from all 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
71 changes: 61 additions & 10 deletions model/bin/ww3_from_ftp.sh
Original file line number Diff line number Diff line change
@@ -1,28 +1,69 @@
#!/bin/bash
#!/bin/bash -e
Comment thread
JessicaMeixner-NOAA marked this conversation as resolved.
# --------------------------------------------------------------------------- #
# #
# Script for downloading data from ftp #
# Created 0ct 10, 2017 #
# --------------------------------------------------------------------------- #

usage()
{
echo ''
echo ' Usage : ./ww3_from_ftp.sh [options]'
echo ''
echo ' Options : '
echo ' -h : print usage'
echo ' -i : interactive mode'
echo ' -k : keep tar files'
echo ''
}

curr_dir=`pwd`

# Set WW3 code version
ww3ver=v7.12.6

interactive='n'
keep='n'
if [ $# -eq 1 ] ; then
if [ "$1" = "-h" ] ; then
usage
exit 0
elif [ "$1" = "-i" ] ; then
interactive='y'
elif [ "$1" = "-k" ] ; then
keep='y'
else
echo '[ERROR] input argument not recognized'
usage
exit 1
fi
elif [ $# -gt 1 ] ; then
echo '[ERROR] only one input argument accepted'
usage
exit 1
fi

dir0=$(cd $(dirname $0) > /dev/null && pwd -P)
ww3dir=$(dirname $(dirname $dir0))

#Get top level directory of ww3 from user:
echo -e "\n\n This script will download data from the ftp for WAVEWATCH III "
echo -e "Enter the relative path to the main/top level directory, this would "
echo -e "be '../../' if in the model/bin directory or '.' if already in the "
echo -e "top/main directory:"
read ww3dir
if [ "$interactive" = "n" ]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is nice as it allows for previous functionality//backwards compatibility, but we're at a point where we're about to have some big changes and therefore are we willing to break this and just make this a script where you have to give it the model directory path and then you either keep things (optional, make an option) or the default is you do nothing and it doesn't keep things?

then
echo $ww3dir
else
echo -e "Enter the absolute or relative path to the main/top directory, "
echo -e "this would be '../../' if in the model/bin directory "
echo -e "or './' if already in the top/main directory:"
read ww3dir
fi

#Move to top level directory of ww3:
cd $ww3dir

#Download from ftp and uptar:
echo -e "Downloading and untaring file from ftp:"
wget https://ftp.emc.ncep.noaa.gov/static_files/public/WW3/ww3_from_ftp.${ww3ver}.tar.gz
wget --no-check-certificate https://ftp.emc.ncep.noaa.gov/static_files/public/WW3/ww3_from_ftp.${ww3ver}.tar.gz
tar -xvzf ww3_from_ftp.${ww3ver}.tar.gz

#Move regtest info from data_regtests to regtests:
Expand Down Expand Up @@ -60,8 +101,13 @@ cp -r data_regtests/ww3_ufs1.2/input/* regtests/ww3_ufs1.2/input/
cp -r data_regtests/ww3_ufs1.3/input/*nc regtests/ww3_ufs1.3/input/
#Do you want to clean up (aka delete tar file, delete the data_regtests directory)
echo -e "\n\n Do you want to delete the tar file ww3_from_ftp.${ww3ver}.tar.gz [y|n]: "
read wnew
if [ "${wnew}" = "Y" ] || [ "${wnew}" = "y" ]
if [ "$interactive" = "n" ]
then
echo $keep
else
read keep
fi
if [ "${keep}" = "N" ] || [ "${keep}" = "n" ]
then
echo -e '\n Deleting tar file ww3_from_ftp.${ww3ver}.tar.gz'
rm ww3_from_ftp.${ww3ver}.tar.gz
Expand All @@ -71,8 +117,13 @@ fi

echo -e "\n\n Files were copied from the data_regtests to the regtests folder."
echo -e "Do you want to delete the data_regtests folder? [y|n]: "
read wnew2
if [ "${wnew2}" = "Y" ] || [ "${wnew2}" = "y" ]
if [ "$interactive" = "n" ]
then
echo $keep
else
read keep
fi
if [ "${keep}" = "N" ] || [ "${keep}" = "n" ]
then
echo -e '\n Deleting the data_regtests folder'
rm -rf data_regtests
Expand Down