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

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

trunk : modif for check job status

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