source: CPL/oasis3-mct/branches/OASIS3-MCT_2.0_branch/util/oasisgui/library/DATA/pluginscripts/cerfacs_formation_local.py @ 4775

Last change on this file since 4775 was 4775, checked in by aclsce, 5 years ago
  • Imported oasis3-mct from Cerfacs svn server (not suppotred anymore).

The version has been extracted from https://oasis3mct.cerfacs.fr/svn/branches/OASIS3-MCT_2.0_branch/oasis3-mct@1818

File size: 10.2 KB
Line 
1import os,XDR
2
3class cerfacs_formation_local(XDR.Plugin):
4   
5    def __init__(self,typePlugin):
6        XDR.Plugin.__init__(self, typePlugin)
7        self.login = self.getPluginParam("login")
8        self.nbprocs = self.getPluginParam("nbprocs")
9       
10        if self.login not in ["form00","form01","form02","form03","form04","form05","form06","form07","form08","form09","form10","form11"] :
11            error("Your login is not of the form 'formXX' with XX btw 01 and 11. Check your config file")
12   
13    def sendDirectory(self,directory):
14       
15        if os.path.exists(directory):
16            return 1
17        else:
18            raise Exception("Error : "+directory+" doesn't exist")
19       
20    def executeDistantCommand(self,command,execDirectory,appli,flags=[]):
21         ########
22        # INITS
23        ########
24        command_exe = command
25        supported_applis = []
26        local_directory = os.getcwd()
27        project_name = XDR.getValue("name","project","meta")
28        myhome = "/home/"+self.login
29
30       
31         #####################
32        # SECTION DEPENDING ON APPLICATIONS
33        ####################
34        supported_applis.append("tool_avsp52") 
35        supported_applis.append("avsp52") 
36        supported_applis.append("tool_avbp621") 
37        supported_applis.append("avbp621") 
38        supported_applis.append("tool_avtp2") 
39        supported_applis.append("hip_script") 
40        supported_applis.append("dummy")
41       
42        if appli not in supported_applis:
43            XDR.error("this application requires the application tag "+ appli+ ", which is not supported by the plugin cerfacs_formation_local.")
44
45        ########
46        # AVBP #
47        ########
48        if appli == "avbp621":
49            avbp_home = myhome+"/AVBP_V6.2"
50            command_exe ="mpiexec -boot -np 2 "+ avbp_home+"/HOST/FORMATION/AVBPEXEC/AVBP_V6.2.FORMATION > avbp_log.txt" 
51        if appli == "tool_avbp621":
52            hip_cur_version =  myhome+"/AVBP_V6.2/HOST/FORMATION/TOOLEXEC/hip-1.39.3-PCLINUX"
53            avbp_home = myhome+"/AVBP_V6.2"
54            avbp_scripts = os.path.join(avbp_home,"TOOLS","BIN","SCRIPTS")
55           
56            if command.startswith("-c3sm_auto_"):
57 
58                #command_exe="source "+rolex_tag+" ; "
59                command_exe=""
60
61
62                if command.startswith("-c3sm_auto_loadmesh-"):
63                    XDR.replace_pattern_in_file(os.path.join(execDirectory,"script_mesh.py"),"-c3sm_auto_meshinfo-",os.path.join(avbp_scripts,"meshinfo "))
64                    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 "))
65                    command_exe+= "/usr/bin/python ./script_mesh.py"
66           
67                if command.startswith("-c3sm_auto_track-"):
68                    command_exe += command.replace("-c3sm_auto_track-",os.path.join(avbp_scripts,"track "))
69               
70                if command.startswith("-c3sm_auto_tadia-"):
71                    command_exe += command.replace("-c3sm_auto_tadia-",os.path.join(avbp_scripts,"tadia "))
72                   
73                if command.startswith("-c3sm_auto_flame_param-"):
74                    command_exe += command.replace("-c3sm_auto_flame_param-",os.path.join(avbp_scripts,"flame_param "))
75               
76                if command == "-c3sm_auto_prepare_boundary-":
77                    print "my friend"
78                    XDR.replace_pattern_in_file(os.path.join(execDirectory,"script_boundaries.py"),"-c3sm_auto_hip-",hip_cur_version)
79                    XDR.replace_pattern_in_file(os.path.join(execDirectory,"script_boundaries.py"),"-c3sm_auto_makesolutbound-",os.path.join(avbp_scripts,"makesolutbound "))
80                    XDR.replace_pattern_in_file(os.path.join(execDirectory,"script_boundaries.py"),"-c3sm_auto_genprofile-",os.path.join(avbp_scripts,"genprofile2 "))
81                    XDR.replace_pattern_in_file(os.path.join(execDirectory,"script_boundaries.py"),"-c3sm_auto_makeinject-",os.path.join(avbp_scripts,"makeinject "))
82                    command_exe+= "/usr/bin/python ./script_boundaries.py"
83           
84                if command == "-c3sm_auto_initsol-":
85                    XDR.replace_pattern_in_file(os.path.join(execDirectory,"script_init.py"),"-c3sm_auto_solinfo-",os.path.join(avbp_scripts,"solinfo "))
86                    XDR.replace_pattern_in_file(os.path.join(execDirectory,"script_init.py"),"-c3sm_auto_add_vortex-",os.path.join(avbp_scripts,"addvortex "))
87                    XDR.replace_pattern_in_file(os.path.join(execDirectory,"script_init.py"),"-c3sm_auto_makesolution-",os.path.join(avbp_scripts,"makesolution "))
88                    XDR.replace_pattern_in_file(os.path.join(execDirectory,"script_init.py"),"-c3sm_auto_add_spec-",os.path.join(avbp_scripts,"add_spec "))
89                    XDR.replace_pattern_in_file(os.path.join(execDirectory,"script_init.py"),"-c3sm_auto_init_spec-",os.path.join(avbp_scripts,"init_spec "))
90                    XDR.replace_pattern_in_file(os.path.join(execDirectory,"script_init.py"),"-c3sm_auto_gas_out-",os.path.join(avbp_scripts,"gas_out "))
91                    XDR.replace_pattern_in_file(os.path.join(execDirectory,"script_init.py"),"-c3sm_auto_add_tpf-",os.path.join(avbp_scripts,"add_tpf "))
92                    XDR.replace_pattern_in_file(os.path.join(execDirectory,"script_init.py"),"-c3sm_auto_add_fic-",os.path.join(avbp_scripts,"add_fic "))
93                    XDR.replace_pattern_in_file(os.path.join(execDirectory,"script_init.py"),"-c3sm_auto_check_perio-",os.path.join(avbp_scripts,"check_perio "))
94                    command_exe+= "/usr/bin/python ./script_init.py"
95                   
96                if command.startswith("-c3sm_auto_xtools-"):
97                    command_exe=command.replace("-c3sm_auto_xtools-","")
98               
99
100                   
101
102        #######
103        # HIP #
104        #######
105        if appli == "hip_current":
106            hip_cur_version =  myhome+"/AVBP_V6.2/HOST/FORMATION/TOOLEXEC/hip-1.39.3-PCLINUX"
107            if command.startswith("-c3sm_auto_hip-"):
108                command_exe = command.replace("-c3sm_auto_hip-",hip_cur_version)
109            elif command == "-c3s_auto_hip_scripttxt-":
110                command_exe= hip_cur_version+" < ./script.txt"
111
112        if appli == "hip_script":
113            hip_cur_version =  myhome+"/AVBP_V6.2/HOST/FORMATION/TOOLEXEC/hip-1.39.3-PCLINUX"
114            command_exe = hip_cur_version + " < " + command
115
116           
117        ########
118        # AVSP #
119        ########
120        if appli == "avsp52":
121            command_exe = "/usr/bin/python /home/avbp_00/AVSP_FORMATION/QUIET_FORMATION/quiet3.py &> quiet.out"
122            #avsp_command = "/home/avbp_00/AVSP_FORMATION/QUIET_FORMATION/AVSP_HOME/HOST/KALI/AVSPEXEC/AVSP_V5.2.KALI"
123            from shutil import copy
124            copy("/home/avbp_00/AVSP_FORMATION/QUIET_FORMATION/AVSP_HOME/HOST/KALI/AVSPEXEC/AVSP_V5.3.KALI", execDirectory)
125            avsp_command = "mpirun -np 2 ./AVSP_V5.3.KALI"
126            XDR.replace_pattern_in_file(os.path.join(execDirectory,"user_params.py"),"-c3sm_auto_avsp_exe-",avsp_command)
127            anozzle_command = "/home/avbp_00/AVSP_FORMATION/QUIET_FORMATION/AVSP_HOME/HOST/KALI/TOOLEXEC/Anozzle_CORAIL.exe"
128            XDR.replace_pattern_in_file(os.path.join(execDirectory,"user_params.py"),"-c3sm_auto_anozzle_exe-",anozzle_command)
129        if appli == "tool_avsp52":
130            if command == "-c3sm_auto_preproc_mlpf_exec-":
131                command_exe = "/home/avbp_00/AVSP_FORMATION/QUIET_FORMATION/AVSP_HOME/HOST/KALI/TOOLEXEC/preproc_mlpf_KALI.exe"
132            if command == "-c3sm_auto_avspinitsol_exec-":
133                command_exe = "/home/avbp_00/AVSP_FORMATION/QUIET_FORMATION/AVSP_HOME/HOST/KALI/TOOLEXEC/avspinitsol_KALI.exe"
134            if command == "-c3sm_auto_zinn_exec-":
135                command_exe = "/home/avbp_00/AVSP_FORMATION/QUIET_FORMATION/AVSP_HOME/HOST/KALI/TOOLEXEC/Zinn_nozzle_KALI.exe"
136
137        ########
138        # AVTP #
139        ########
140        if appli == "tool_avtp2":
141            hip_cur_version =  "/home/rolex/HIP/1.38.1/hip-1.38.1-KALI"
142            avtp_tag =  "/home/cfd1/avtp/avtp_tag"
143            avtp_home = "/home/cfd1/avtp/AVTP_V2.X"
144            avtp_scripts = os.path.join(avtp_home,"TOOLS","BIN","SCRIPTS")
145
146            if command.startswith("-c3sm_auto"):
147
148                command_exe ="source "+avtp_tag+";"
149
150                if command.startswith("-c3sm_auto_loadmesh-"):
151                    XDR.replace_pattern_in_file(os.path.join(execDirectory,"script_mesh.py"),"-c3sm_auto_meshinfo-",os.path.join(avtp_scripts,"meshinfo "))
152                    XDR.replace_pattern_in_file(os.path.join(execDirectory,"script_mesh.py"),"-c3sm_auto_get_patch_surf-",os.path.join(avtp_scripts,"get_patch_surf "))
153                    command_exe = "/usr/bin/python ./script_mesh.py"
154
155                if command.startswith("-c3sm_auto_track-"):
156                    command_exe = command.replace("-c3sm_auto_track-",os.path.join(avtp_scripts,"track "))
157
158                if command == "-c3sm_auto_prepare_boundary-":
159                    XDR.replace_pattern_in_file(os.path.join(execDirectory,"script_boundaries.py"),"-c3sm_auto_hip-",hip_cur_version)
160                    XDR.replace_pattern_in_file(os.path.join(execDirectory,"script_boundaries.py"),"-c3sm_auto_makesolutbound-",os.path.join(avtp_scripts,"makesolutbound "))
161                    command_exe = "/usr/bin/python ./script_boundaries.py"
162
163                if command == "-c3sm_auto_initsol-":
164                    XDR.replace_pattern_in_file(os.path.join(execDirectory,"script_init.py"),"-c3sm_auto_solinfo-",os.path.join(avtp_scripts,"solinfo "))
165                    XDR.replace_pattern_in_file(os.path.join(execDirectory,"script_init.py"),"-c3sm_auto_makesolution-",os.path.join(avtp_scripts,"makesolution "))
166                    command_exe = "/usr/bin/python ./script_init.py"
167
168       
169        os.chdir(execDirectory)
170        XDR.execute(command_exe)
171        os.chdir(local_directory)
172       
173    def retrieveDirectory(self,directory):
174        # Do nothing as we are local
175        pass
176   
177    def removeDirectory(self,directory):
178        pass
179   
180    def getInfos(self):
181        self.infos['platform']="UNIX"
182        self.infos['parallelCommand'] = "mpirun -np "+XDR.getValue("nbprocs","local_unix",self.type+"_plugins","config")+" "
183        return self.infos   
Note: See TracBrowser for help on using the repository browser.