forked from lmadaus/cm1_dart
-
Notifications
You must be signed in to change notification settings - Fork 1
/
autorun_ensemble.py
executable file
·77 lines (61 loc) · 2.61 KB
/
autorun_ensemble.py
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
#!/usr/bin/env python
from __future__ import print_function, division
import os, sys, getopt
from ens_dart_param import *
from datetime import datetime,timedelta
import time
os.chdir(dir_dom)
#gfs_dir = '/glade/p/work/lmadaus/rtfiles'
def main():
# Make a list of all model times
starttime = 0
endtime = exp_length
deltatime = int(cycle_len)
opts,args =getopt.getopt(sys.argv[1:],'d:')
for o,a in opts:
if o == '-d':
curtime = int(a)
all_timelist = []
run_timelist = []
while curtime < endtime:
curtime += deltatime
run_timelist.append(curtime)
curtime = starttime
while curtime <= endtime:
all_timelist.append(curtime)
curtime += deltatime
#print timelist
# Find out which are assimilation times
if assim_start < 0:
assim_times = []
else:
assim_times = all_timelist[assim_start::assim_interval]
print("Assim times correct?", assim_times)
#raw_input()
#print "Run_datelist", run_datelist
# Turn on the control lock
if not os.path.exists('%s/AUTO_RUN_IN_PROGRESS' % dir_dom):
os.system('touch %s/AUTO_RUN_IN_PROGRESS' % dir_dom)
else:
print("Found file 'AUTO_RUN_IN_PROGRESS' in main dir.")
print("Don't want to start a duplicate auto run.")
print("Exiting.")
exit(1)
for time in run_timelist:
print("Auto-running in silent mode building to time", time, "min")
os.system('./check_ensemble_status.py -d {:d} -s'.format(time))
# Master control lock -- check to see if this file exists
# If it doesn't exist, exit the program
if not os.path.exists('{:s}/AUTO_RUN_IN_PROGRESS'.format(dir_dom)):
print("File 'AUTO_RUN_IN_PROGRESS' is not present in main dir. Exiting.")
exit(0)
if time in assim_times:
#os.chdir('%s/wrfdart' % dir_wrf_dom)
os.system('./submit_filter.py -d {:d} -m {:d}'.format(time,mpi_numprocs_filter))
#os.chdir(dir_wrf_dom)
# Run WPS to get new BCs
#run_wps_sequence(date,deltatime)
# Submit the new ensemble
os.system('./submit_all.py -d {:d}'.format(time))
if __name__ == '__main__':
main()