-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsend_UKmet.sh
executable file
·130 lines (110 loc) · 3.02 KB
/
send_UKmet.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#!/bin/bash
#
# Purpose: send FV3 IC/LBCs to Jet
#
# /scratch/larissa.reames/make_um_icbcs/chgres_icbcs
#
scpdir=$(dirname $0) # To ensure to use the same dir as this script
#scpdir="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
destdir=/lfs3/NAGAPE/hpc-wof1/ywang/regional_fv3/ukmic
srcdir=/scratch/larissa.reames/make_um_icbcs/chgres_icbcs
eventdt=$(date -u +%Y%m%d)
function usage {
echo " "
echo " USAGE: $0 [options] DATETIME [DESTDIR]"
echo " "
echo " PURPOSE: Send FV3 IC/LBCs initialized from UKMet to Jet."
echo " NOTE: must run on Odin."
echo " "
echo " DATETIME - Case date and time in YYYYMMDD"
echo " empty for current day"
echo " DESTDIR - Work Directory on Jet"
echo " "
echo " OPTIONS:"
echo " -h Display this message"
echo " -n Show command to be run only"
echo " -v Verbose mode"
echo " "
echo " DEFAULTS:"
echo " eventdt = $eventdt"
echo " srcdir = $srcdir"
echo " destdir = $destdir"
echo " "
echo " -- By Y. Wang (2020.04.24)"
echo " "
exit $1
}
#-----------------------------------------------------------------------
#
# Default values
#
#-----------------------------------------------------------------------
show=0
verb=0
#-----------------------------------------------------------------------
#
# Handle command line arguments
#
#-----------------------------------------------------------------------
while [[ $# > 0 ]]
do
key="$1"
case $key in
-h)
usage 0
;;
-n)
show=1
;;
-v)
verb=1
;;
-*)
echo "Unknown option: $key"
exit
;;
*)
if [[ $key =~ ^[0-9]{8}$ ]]; then
eventdt="$key"
else
destdir=$key
fi
;;
esac
shift # past argument or value
done
echo "DATETIME: $eventdt"
echo "destdir = $destdir"
echo "srcdir = $srcdir"
echo " "
#-----------------------------------------------------------------------
#
# retrieve data from Jet
#
#-----------------------------------------------------------------------
tophour=36
inthour=3
eventsrc="$srcdir/$eventdt"
donefile="donefile.chgres.${eventdt}0000"
files=(gfs_ctrl.nc out.atm.tile7.nc out.sfc.tile7.nc)
for hr in $(seq 0 ${inthour} ${tophour}); do
fhr=$(printf "%03d" $hr)
files+=(gfs_bndy.tile7.${fhr}.nc)
done
files+=(${donefile})
while [[ ! -f ${eventsrc}/$donefile ]]; do
echo "Waiting for ${eventsrc}/$donefile ....."
sleep 10
done
for fn in ${files[@]}; do
echo "Sending $eventsrc/$fn ......"
if [[ $fn == "out.atm.tile7.nc" ]]; then
dfn="gfs_data.tile7.nc"
elif [[ $fn == "out.sfc.tile7.nc" ]]; then
dfn="sfc_data.tile7.nc"
else
dfn=$fn
fi
scp $eventsrc/$fn dtn:$destdir/$dfn
done
exit 0