source: XIOS/trunk/xios_test_suite/COMPILE/config_compile.py @ 1916

Last change on this file since 1916 was 1916, checked in by yushan, 4 years ago

trunk : change job_running criteria. Job name = XIOS_rev. Auto generate compile job scripts.

File size: 4.7 KB
Line 
1import glob
2import sys
3import subprocess
4import os
5
6def OSinfo(runthis):
7        red = lambda text: '\033[0;31m' + text + '\033[0m'
8        osstdout = subprocess.Popen(runthis, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, close_fds=True)
9        theInfo = osstdout.communicate()[0].strip()
10        if osstdout.returncode!=0:
11                print(red(runthis+" FAILED"))
12                print(theInfo)
13                sys.exit()
14
15
16def generate_compile_job_irene(revision):
17    with open("job_compile_irene.sh", "w") as f:
18        f.write("#!/bin/bash\n")
19        f.write("#=====================================\n")
20        f.write("#script generated by config_compile.py\n")
21        f.write("#=====================================\n")
22        f.write("#MSUB -r XIOS_rev"+revision+"\n")       
23        f.write("#MSUB -o client_output.out\n")
24        f.write("#MSUB -e client_error.err\n")
25        f.write("#MSUB -eo\n")
26        f.write("#MSUB -c 48\n")
27        f.write("#MSUB -n 1\n")
28        f.write("#MSUB -X\n")
29        f.write("#MSUB -x\n")
30        f.write("#MSUB -T 1800\n")
31        f.write("#MSUB -q skylake\n")
32        f.write("#MSUB -A gen0826\n")
33        f.write("#MSUB -Q test\n")
34        f.write("#MSUB -m work,scratch\n")
35        f.write("cd $BRIDGE_MSUB_PWD\n")
36        f.write("cmake .\n")
37        f.write("ctest -V\n")
38        f.write("exit\n")
39
40
41
42def generate_compile_job_jeanzay(revision): 
43    print("generating compile job for jz")
44    with open("job_compile_jeanzay.sh", "w") as f:
45        f.write("#!/bin/bash\n")
46        f.write("#=====================================\n")
47        f.write("#script generated by config_compile.py\n")
48        f.write("#=====================================\n")
49        f.write("#SBATCH --ntasks=1\n")
50        f.write("#SBATCH --cpus-per-task=40\n")
51        f.write("#SBATCH --hint=nomultithread\n")
52        f.write("#SBATCH -t 00:30:00\n")
53        f.write("#SBATCH -o output.out\n") 
54        f.write("#SBATCH -e error.err \n") 
55        f.write("#SBATCH -A psl@cpu\n")
56        f.write("#SBATCH --job-name=XIOS_rev"+revision+"\n")
57        f.write("cd ${SLURM_SUBMIT_DIR}\n")
58        f.write("cmake .\n")
59        f.write("ctest -V\n")
60        f.write("exit\n")
61
62
63def main():
64    machine=os.getenv('xios_machine_name')
65    revision=os.getenv('revision')
66
67
68    default_nb_config = 2
69    nb_config = 1
70    configs = [0]*default_nb_config
71    configs_arg = [[], []] 
72
73    f=open("compile_param_"+machine+".def", "r")
74    for line in f:
75        line = line.strip()
76        if len(line) != 0:
77            if not line.startswith("#"):
78                nb_config = nb_config * (line.count(",")+1)
79                line = line.replace(",", "")
80                line = line.replace("=", "")
81                if line.startswith("arch"):
82                    line = line.replace("arch", "")
83                    for word in line.split():
84                        configs[0] += 1
85                        configs_arg[0].append(word)
86                elif line.startswith("mode"):
87                    line = line.replace("mode", "")
88                    for word in line.split():
89                        configs[1] += 1
90                        configs_arg[1].append(word)
91    f.close()                           
92
93    f=open("CMakeLists.txt", "w")
94    f.write("#######################################\n")
95    f.write("# file generated by config_compile.py #\n")
96    f.write("#           DO NOT modify             #\n")
97    f.write("#######################################\n\n")
98    f.write("cmake_minimum_required(VERSION 2.8.12.2)\n\n")
99    f.write("project(generic_testcase)\n\n")
100    f.write("find_package(PythonInterp REQUIRED)\n\n")
101    f.write("enable_testing()\n\n")
102       
103    for i in range(len(configs_arg[0])):
104        for j in range(len(configs_arg[1])):
105            build_dir_name = configs_arg[0][i]+"_"+configs_arg[1][j]
106            g=open("build_"+revision+"_"+machine+"_"+build_dir_name+".txt", "w")
107            g.write("arch "+configs_arg[0][i]+"\n")
108            g.write("mode "+configs_arg[1][j]+"\n")
109            g.write("machine "+machine+"\n")
110            g.write("revision "+revision+"\n")
111            g.close()
112           
113            f.write("add_test( NAME "+build_dir_name+'\n')
114            f.write("          COMMAND bash -c \"source ../ARCH/arch-"+configs_arg[0][i]+".env  && cd ../.. && ./make_xios --arch_path `pwd`/xios_test_suite/ARCH --arch "+configs_arg[0][i]+" --"+configs_arg[1][j]+" --job 16 --build_dir xios_test_suite/BUILD/build_"+build_dir_name+" && echo $? >> xios_test_suite/COMPILE/build_"+revision+"_"+machine+"_"+build_dir_name+".txt\")\n\n")
115            f.write("set_tests_properties( "+build_dir_name+" PROPERTIES\n")
116            f.write("                      FAIL_REGULAR_EXPRESSION \"failed\")\n\n")
117   
118   
119    f.close()
120
121    globals()['generate_compile_job_'+machine](revision)
122
123if __name__== "__main__":
124  main()
Note: See TracBrowser for help on using the repository browser.