-
Notifications
You must be signed in to change notification settings - Fork 667
non interactive ww3_from_ftp.sh #603
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
Changes from all commits
7d60a26
bda6629
0561b5b
95e8e80
934edd6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,28 +1,69 @@ | ||
| #!/bin/bash | ||
| #!/bin/bash -e | ||
| # --------------------------------------------------------------------------- # | ||
| # # | ||
| # 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" ] | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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: | ||
|
|
@@ -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 | ||
|
|
@@ -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 | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.