Skip to content
Merged
Changes from 2 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
54 changes: 46 additions & 8 deletions model/bin/ww3_from_ftp.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/bash -e
Comment thread
JessicaMeixner-NOAA marked this conversation as resolved.
# --------------------------------------------------------------------------- #
# #
# Script for downloading data from ftp #
Expand All @@ -10,19 +10,47 @@ curr_dir=`pwd`
# Set WW3 code version
ww3ver=v7.12.6

interactive='n'
keep='n'
if [ $# -eq 1 ] ; then
if [ "$1" = "-i" ] ; then
interactive='y'
elif [ "$1" = "-k" ] ; then
keep='y'
else
echo '[ERROR] input argument not recognized'
echo ' use -i for interactive mode'
echo ' use -k to keep tar files'
exit 1
fi
elif [ $# -gt 1 ] ; then
echo '[ERROR] only one input argument accepted'
echo ' use -i for interactive mode'
echo ' use -k to keep tar files'
exit 1
fi

model_dir=$(cd $(dirname $(dirname $0)) > /dev/null && pwd -P)
echo $model_dir

#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:"

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.

If we're giving the path to the model directory, we should change this description or is this still the same?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

done

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 $model_dir
else
read model_dir
fi

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

#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 +88,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}" = "Y" ] || [ "${keep}" = "y" ]
then
echo -e '\n Deleting tar file ww3_from_ftp.${ww3ver}.tar.gz'
rm ww3_from_ftp.${ww3ver}.tar.gz
Expand All @@ -71,8 +104,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}" = "Y" ] || [ "${keep}" = "y" ]
then
echo -e '\n Deleting the data_regtests folder'
rm -rf data_regtests
Expand Down