-
Notifications
You must be signed in to change notification settings - Fork 23
/
getrestart.sh
executable file
·239 lines (212 loc) · 6.36 KB
/
getrestart.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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
#!/bin/tcsh -f
#
# get some restart files from HPSS or specified directory
# using the specified basename, find the file of the form basename????.????.u
# with the newest time stamp (????.????)
#
# getrestart.sh basname HPSS [uvw,h5,vor] search HPSS
# getrestart.sh basname path [uvw,h5,vor] search path
# getrestart.sh basname path [uvw,h5,vor] all search both
#
# $1 = basename of restart file.
# $2 = HPSS get file off of HPSS
# = path get file from specified path
# $3 uvw or h5 or vor. default = uvw
# $4 "all"
#
# status=0 success
# status=1 failed
#
set PSIGET = "psi get"
#set PSIGET = "echo psi get disabled: "
#set PSIVM = "psi mv"
set PSIMV = "echo psi mv disabled: "
set name = $1
set fpath = $2
set ext = w
if ($#argv >= 3 ) then
if ($3 == uvw ) then
set ext = w
else if ($3 == h5) then
set ext = h5
else if ($3 == vor) then
set ext = vor
endif
endif
set searchall = no
if ($#argv >= 4 ) then
set searchall = $4
endif
if ($searchall == all) then
#search $fpath for newest restart file
echo searching both HPSS and $fpath
set resnamels = `\ls {$fpath}/{$name}*.{$ext} | sort | tail -1`
if ($resnamels =="") then
echo {$fpath}/{$name}
echo "no restart files in $fpath"
set resnamels = aaaaaaaaaaa
endif
#search PSI
set resnamepsi = `psi ls dns/{$name}/{$name}\*.{$ext} | sort | tail -1`
if ($resnamepsi =="") then
echo "no restart files on HPSS"
set resnamepsi = aaaaaaaaaaa
endif
set resnamels = `basename $resnamels`
set resnamepsi = `basename $resnamepsi`
rm -f tempsort
echo $resnamels > tempsort
echo $resnamepsi >> tempsort
set resnamew=`sort tempsort | tail -1`
rm -f tempsort
if ($resnamew == $resnamels ) then
echo "using restart files in directory"
#fpath already set
else if ($resnamew == $resnamepsi ) then
echo "using restart files from HPSS"
set fpath = HPSS
else
echo "no restart files found"
exit 1
endif
endif
if ($fpath == HPSS) then
#search HPSS for newest restart file
set resnamew = `psi ls dns/{$name}/{$name}\*.{$ext} | sort | tail -1`
if ($resnamew =="") then
echo "Error finding restart file. Exit"
exit 1
else
echo "Using HPSS restart files: "
set nametime = `basename $resnamew .{$ext}`
if ( $ext == "w" ) then
#set resnameu = `psi ls dns/{$name}/{$nametime}\*.u | sort | tail -1`
#set resnamev = `psi ls dns/{$name}/{$nametime}\*.v | sort | tail -1`
set resnameu = dns/{$name}/{$nametime}.u
set resnamev = dns/{$name}/{$nametime}.v
echo $resnameu
echo $resnamev
endif
if ( $ext == "vor" ) then
set resnamet = dns/{$name}/{$nametime}.tracer
echo $resnamet
endif
echo $resnamew
endif
if ( $ext == "w" ) then
set resnameu2 = `basename $resnameu`
set resnamev2 = `basename $resnamev`
endif
if ( $ext == "vor" ) then
set resnamet2 = `basename $resnamet`
endif
set resnamew2 = `basename $resnamew`
# check to see if files are left over from last run:
\rm -f restart.*
if ( $ext == "w" ) then
if !(-e $resnameu2) then
$PSIGET $resnameu
endif
if !(-e $resnamev2) then
$PSIGET $resnamev
endif
if !(-e $resnamew2) then
$PSIGET $resnamew
endif
\ln -s $resnameu2 restart.u
\ln -s $resnamev2 restart.v
\ln -s $resnamew2 restart.{$ext}
if !(-e restart.u) then
echo "No restart.u file"
$PSIMV $resnameu $resnameu.bak
$PSIMV $resnamev $resnamev.bak
$PSIMV $resnamew $resnamew.bak
exit 1
endif
else if ( $ext == "h5" ) then
if !(-e $resnamew2) then
$PSIGET $resnamew
endif
\ln -s $resnamew2 restart.{$ext}
if !(-e restart.{$ext}) then
echo "No restart.{$ext} file"
$PSIMV $resnamew $resnamew.bak
exit 1
endif
else
if !(-e $resnamet2) then
$PSIGET $resnamet
endif
if !(-e $resnamew2) then
$PSIGET $resnamew
endif
\ln -s $resnamet2 restart.tracer
\ln -s $resnamew2 restart.{$ext}
if !(-e restart.tracer) then
echo "No restart.tracer file"
$PSIMV $resnamet $resnamet.bak
$PSIMV $resnamew $resnamew.bak
exit 1
endif
endif
else
#search $fpath for newest restart file
set resnamew = `ls {$fpath}/{$name}*.{$ext} | sort | tail -1`
if ($resnamew =="") then
echo {$fpath}/{$name}
echo "Error finding restart file. Exit"
exit 1
else
echo "Using directory restart files: "
set nametime = `basename $resnamew .{$ext}`
if ( $ext == "w" ) then
#set resnameu = `ls {$fpath}/{$nametime}*.u | sort | tail -1`
#set resnamev = `ls {$fpath}/{$nametime}*.v | sort | tail -1`
set resnameu = {$fpath}/{$nametime}.u
set resnamev = {$fpath}/{$nametime}.v
echo $resnameu
echo $resnamev
endif
if ( $ext == "vor" ) then
set resnamet = {$fpath}/{$nametime}.tracer
echo $resnamet
endif
echo $resnamew
endif
\rm -f restart.*
if ( $ext == "w" ) then
\ln -s $resnameu restart.u
\ln -s $resnamev restart.v
\ln -s $resnamew restart.{$ext}
if !(-e restart.{$ext}) then
echo "No restart.{$ext} file"
# move them out of the way in case this time is corrupt:
# then next run will pick up earlier backup:
mv $resnameu $resnameu.bak
mv $resnamev $resnamev.bak
mv $resnamew $resnamew.bak
exit 1
endif
else if ( $ext == "h5" ) then
\ln -s $resnamew restart.{$ext}
if !(-e restart.{$ext}) then
echo "No restart.{$ext} file"
# move them out of the way in case this time is corrupt:
# then next run will pick up earlier backup:
mv $resnamew $resnamew.bak
exit 1
endif
else
\ln -s $resnamet restart.tracer
\ln -s $resnamew restart.{$ext}
if !(-e restart.{$ext}) then
echo "No restart.{$ext} file"
# move them out of the way in case this time is corrupt:
# then next run will pick up earlier backup:
mv $resnamet $resnamet.bak
mv $resnamew $resnamew.bak
exit 1
endif
endif
endif
exit 0