1 | import os,XDR |
---|
2 | import shutil |
---|
3 | import re |
---|
4 | |
---|
5 | class turbomeca_btmclx2_local(XDR.Plugin): |
---|
6 | |
---|
7 | |
---|
8 | # |
---|
9 | def __init__(self,typePlugin): |
---|
10 | """This method transfer the informations form the XML file to the present code |
---|
11 | it should essentially involve lines of type |
---|
12 | self.myparam = self.getPluginParam("mypram_in_the_xml")""" |
---|
13 | XDR.Plugin.__init__(self, typePlugin) |
---|
14 | self.nbprocs = self.getPluginParam("nbprocs") |
---|
15 | |
---|
16 | @XDR.exec_command |
---|
17 | @XDR.supported_applications(['tool_avsp52','tool_avbp621','yales2','hip_current','hip_script']) |
---|
18 | def executeDistantCommand(self,command,execDirectory,appli,flags=[]): |
---|
19 | """This method will interpret commands sent from |
---|
20 | python scripts associated to a C3Sm application |
---|
21 | |
---|
22 | Code-specific management must be done here, and only here. |
---|
23 | """ |
---|
24 | |
---|
25 | ############################################################################################################################## |
---|
26 | ############################################################################################################################## |
---|
27 | ############################################################################################################################## |
---|
28 | ######## |
---|
29 | # AVBP # |
---|
30 | ######## |
---|
31 | if appli == "tool_avbp621": |
---|
32 | hip_cur_version = "/Avbp/versions/bin/hip" |
---|
33 | avbp_home = "/Avbp/versions/AVBP_V6.2" |
---|
34 | avbp_scripts = os.path.join(avbp_home,"TOOLS","BIN","SCRIPTS") |
---|
35 | |
---|
36 | if command.startswith("-c3sm_auto_"): |
---|
37 | |
---|
38 | command_exe="" |
---|
39 | |
---|
40 | |
---|
41 | if command.startswith("-c3sm_auto_loadmesh-"): |
---|
42 | XDR.replace_pattern_in_file(os.path.join(execDirectory,"script_mesh.py"),"-c3sm_auto_meshinfo-",os.path.join(avbp_scripts,"meshinfo ")) |
---|
43 | XDR.replace_pattern_in_file(os.path.join(execDirectory,"script_mesh.py"),"-c3sm_auto_get_patch_surf-",os.path.join(avbp_scripts,"get_patch_surf ")) |
---|
44 | command_exe+= "/usr/bin/python ./script_mesh.py" |
---|
45 | |
---|
46 | if command.startswith("-c3sm_auto_track-"): |
---|
47 | command_exe += command.replace("-c3sm_auto_track-",os.path.join(avbp_scripts,"track ")) |
---|
48 | |
---|
49 | if command.startswith("-c3sm_auto_tadia-"): |
---|
50 | command_exe += command.replace("-c3sm_auto_tadia-",os.path.join(avbp_scripts,"tadia ")) |
---|
51 | |
---|
52 | if command.startswith("-c3sm_auto_flame_param-"): |
---|
53 | command_exe += command.replace("-c3sm_auto_flame_param-",os.path.join(avbp_scripts,"flame_param ")) |
---|
54 | |
---|
55 | if command == "-c3sm_auto_prepare_boundary-": |
---|
56 | print "my friend" |
---|
57 | XDR.replace_pattern_in_file(os.path.join(execDirectory,"script_boundaries.py"),"-c3sm_auto_hip-",hip_cur_version) |
---|
58 | XDR.replace_pattern_in_file(os.path.join(execDirectory,"script_boundaries.py"),"-c3sm_auto_makesolutbound-",os.path.join(avbp_scripts,"makesolutbound ")) |
---|
59 | XDR.replace_pattern_in_file(os.path.join(execDirectory,"script_boundaries.py"),"-c3sm_auto_genprofile-",os.path.join(avbp_scripts,"genprofile2 ")) |
---|
60 | XDR.replace_pattern_in_file(os.path.join(execDirectory,"script_boundaries.py"),"-c3sm_auto_makeinject-",os.path.join(avbp_scripts,"makeinject ")) |
---|
61 | command_exe+= "/usr/bin/python ./script_boundaries.py" |
---|
62 | |
---|
63 | if command == "-c3sm_auto_initsol-": |
---|
64 | XDR.replace_pattern_in_file(os.path.join(execDirectory,"script_init.py"),"-c3sm_auto_solinfo-",os.path.join(avbp_scripts,"solinfo ")) |
---|
65 | XDR.replace_pattern_in_file(os.path.join(execDirectory,"script_init.py"),"-c3sm_auto_add_vortex-",os.path.join(avbp_scripts,"addvortex ")) |
---|
66 | XDR.replace_pattern_in_file(os.path.join(execDirectory,"script_init.py"),"-c3sm_auto_makesolution-",os.path.join(avbp_scripts,"makesolution ")) |
---|
67 | XDR.replace_pattern_in_file(os.path.join(execDirectory,"script_init.py"),"-c3sm_auto_add_spec-",os.path.join(avbp_scripts,"add_spec ")) |
---|
68 | XDR.replace_pattern_in_file(os.path.join(execDirectory,"script_init.py"),"-c3sm_auto_init_spec-",os.path.join(avbp_scripts,"init_spec ")) |
---|
69 | XDR.replace_pattern_in_file(os.path.join(execDirectory,"script_init.py"),"-c3sm_auto_gas_out-",os.path.join(avbp_scripts,"gas_out ")) |
---|
70 | XDR.replace_pattern_in_file(os.path.join(execDirectory,"script_init.py"),"-c3sm_auto_ign_sphere-",os.path.join(avbp_scripts,"ignition_sphere ")) |
---|
71 | XDR.replace_pattern_in_file(os.path.join(execDirectory,"script_init.py"),"-c3sm_auto_add_tpf-",os.path.join(avbp_scripts,"add_tpf ")) |
---|
72 | XDR.replace_pattern_in_file(os.path.join(execDirectory,"script_init.py"),"-c3sm_auto_add_fic-",os.path.join(avbp_scripts,"add_fic ")) |
---|
73 | XDR.replace_pattern_in_file(os.path.join(execDirectory,"script_init.py"),"-c3sm_auto_check_perio-",os.path.join(avbp_scripts,"check_perio ")) |
---|
74 | command_exe+= "/usr/bin/python ./script_init.py" |
---|
75 | |
---|
76 | if command.startswith("-c3sm_auto_xtools-"): |
---|
77 | command_exe=command.replace("-c3sm_auto_xtools-","") |
---|
78 | |
---|
79 | ####### |
---|
80 | # HIP # |
---|
81 | ####### |
---|
82 | if appli == "hip_current": |
---|
83 | hip_cur_version = "/Avbp/versions/bin/hip" |
---|
84 | if command.startswith("-c3sm_auto_hip-"): |
---|
85 | command_exe = command.replace("-c3sm_auto_hip-",hip_cur_version) |
---|
86 | elif command == "-c3s_auto_hip_scripttxt-": |
---|
87 | command_exe= hip_cur_version+" < ./script.txt" |
---|
88 | |
---|
89 | if appli == "hip_script": |
---|
90 | command_exe = "/Avbp/versions/bin/hip < " + command |
---|
91 | |
---|
92 | ######## |
---|
93 | # AVSP # |
---|
94 | ######## |
---|
95 | if appli == "tool_avsp52": |
---|
96 | avsp_home = "/Avbp/versions/ARCHIVE_QUIET/QUIET/QUIET_TM/AVSP_HOME_2" |
---|
97 | tools_rep ="/HOST/BTMCLX2/TOOLEXEC/" |
---|
98 | if command == "-c3sm_auto_preproc_mlpf_exec-": |
---|
99 | command_exe = avsp_home+tools_rep+"preproc_mlpf_BTMCLX2.exe" |
---|
100 | if command == "-c3sm_auto_avspinitsol_exec-": |
---|
101 | command_exe = avsp_home+tools_rep+"avspinitsol_BTMCLX2.exe" |
---|
102 | if command == "-c3sm_auto_avbp2avsp_exec-": |
---|
103 | command_exe = avsp_home+tools_rep+"avbp2avsp_BTMCLX2.exe" |
---|
104 | if command == "-c3sm_auto_zinn_exec-": |
---|
105 | command_exe = avsp_home+tools_rep+"Zinn_nozzle_BTMCLX2.exe" |
---|
106 | |
---|
107 | |
---|
108 | ########## |
---|
109 | # YALES2 # |
---|
110 | ######### |
---|
111 | if appli == "yales2": |
---|
112 | |
---|
113 | script_path = XDR.getScriptDir() |
---|
114 | |
---|
115 | if command == "-c3sm_YALES2_auto_exe-": |
---|
116 | |
---|
117 | #NO JOB RUNNING ON BTMCLX2 only tools execution |
---|
118 | XDR.error("Job cann't run on BTMCLX2 (code plugin) only tools execution. Change your config.xml code plugin available are for soumi or CCRT") |
---|
119 | |
---|
120 | elif command == "-load_chemtable-": |
---|
121 | |
---|
122 | table_path=XDR.getValue("table",XDR.getValue("eos","chemistry"),"eos","chemistry") |
---|
123 | table_path=os.path.split(table_path)[0]+'/' |
---|
124 | # Replace pattern |
---|
125 | XDR.replace_pattern_in_file(os.path.join(execDirectory,"batch_chemtable"),"-table_path-",table_path) |
---|
126 | # Prepare command |
---|
127 | batch_path=os.path.join(execDirectory,'batch_chemtable') |
---|
128 | XDR.execute("chmod +x "+batch_path) |
---|
129 | command_exe = "/bin/bash ./batch_chemtable" |
---|
130 | |
---|
131 | else: |
---|
132 | XDR.error("Command unknown") |
---|
133 | |
---|
134 | |
---|
135 | ############################################################################################################################## |
---|
136 | ############################################################################################################################## |
---|
137 | ############################################################################################################################## |
---|
138 | |
---|
139 | os.chdir(execDirectory) |
---|
140 | XDR.execute(command_exe) |
---|
141 | os.chdir(self.local_directory) |
---|
142 | |
---|
143 | def retrieveDirectory(self,directory): |
---|
144 | """This method will download some directories on the ressource |
---|
145 | or do nothing if its local""" |
---|
146 | pass |
---|
147 | |
---|
148 | def removeDirectory(self,directory): |
---|
149 | """This method will remove some directories on the ressource |
---|
150 | Rarely used, kept for backward compatibility""" |
---|
151 | pass |
---|