forked from EmelineBolmont/mercury-90
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmaketest.py
More file actions
66 lines (55 loc) · 2.08 KB
/
maketest.py
File metadata and controls
66 lines (55 loc) · 2.08 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
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Script that is a Makefile-like, but in python, and for fortran90
from make import *
import sys # to be able to retrieve arguments of the script
###############################################
## Beginning of the program
###############################################
filename = "test_disk.f90"
force = False # To force the compilation of every module
isOptimize = False
isProblem = False
problem_message = "Given in parameters is the name of the source code you want to compile." + "\n" + \
"The default filename is : "+filename + "\n" + \
"The script can take various arguments :" + "\n" + \
"(no spaces between the key and the values, only separated by '=')" + "\n" + \
" * force : To force the compilation of every module even those not modified" + "\n" + \
" * no_debug : will skip all debug options and use optimisation options instead" + "\n" + \
" * help : display a little help message on HOW to use various options" + "\n" + \
" * name : (default='%s')The filename of the sourcecode you want to compile" % filename + "\n" + \
"Example :" + "\n" + \
"maketest.py name=resultant_torque.f90"
# We get arguments from the script
for arg in sys.argv[1:]:
try:
(key, value) = arg.split("=")
except:
key = arg
if (key == 'help'):
isProblem = True
elif (key == 'no_debug'):
isOptimize = True
elif (key == 'force'):
force = True
elif (key == 'name'):
filename = value
else:
print("the key '"+key+"' does not match")
isProblem = True
if isProblem:
print(problem_message)
exit()
# We clean undesirable files. Indeed, we will compile everything everytime.
if force:
clean(["o", "mod"])
sourceFile.setCompilator("ifort")
sources_filename = lister("*.f90")
if isOptimize:
sourceFile.setCompilingOptions("-O3 -march=native -pipe -finit-real=nan")
# We create the binaries
make_binaries(sources_filename, [filename], debug=False, gdb=False, profiling=False)
else:
sourceFile.setCompilingOptions("")
# We create the binaries
make_binaries(sources_filename, [filename], debug=True, gdb=False, profiling=False)