-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup_xml.py
More file actions
executable file
·55 lines (48 loc) · 1.47 KB
/
setup_xml.py
File metadata and controls
executable file
·55 lines (48 loc) · 1.47 KB
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
#!/usr/bin/env python
#
import os, sys, stat
from xml_funcs.base import header_begin, header_entities, header_end, source, \
wflow_begin, wflow_log, wflow_cycledefs, wflow_end
from xml_funcs.tasks1 import rap, gfs
### setup_xml
def setup_xml(expdir):
# source the config cascade
source('exp.setup')
#
dcCycledef={}
dcCycledef['gfs']=os.getenv('CYCLEDEF_GFS')
dcCycledef['rap']=os.getenv('CYCLEDEF_RAP')
dcCycledef['rap_g2']=os.getenv('CYCLEDEF_RAP_G2')
fPath=f"{expdir}/link.xml"
with open(fPath, 'w') as xmlFile:
header_begin(xmlFile)
header_end(xmlFile)
wflow_begin(xmlFile)
log_fpath=f'{expdir}/logs/rrfs.@Y@m@d/@H/link.log'
wflow_log(xmlFile,log_fpath)
wflow_cycledefs(xmlFile,dcCycledef)
# assemble tasks for an experiment or setup/generate an xml file
rap(xmlFile,expdir,"rap",0,21)
rap(xmlFile,expdir,"rap_g2",22,51)
gfs(xmlFile,expdir,"gfs",0,60)
#
wflow_end(xmlFile)
fPath=f"{expdir}/run_rocoto.sh"
with open(fPath,'w') as rocotoFile:
text= \
f'''#!/usr/bin/env bash
source /etc/profile
module load rocoto
cd {expdir}
rocotorun -w link.xml -d link.db
'''
rocotoFile.write(text)
# set run_rocoto.sh to be executable
st = os.stat(fPath)
os.chmod(fPath, st.st_mode | stat.S_IEXEC)
print(f'link.xml and run_rocoto.sh has been created.')
### end of setup_xml
### run setup_xml.py from the command line
if __name__ == "__main__":
expdir = os.path.dirname(os.path.realpath(__file__))
setup_xml(expdir)