-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathconfig.py
More file actions
executable file
·59 lines (40 loc) · 1.53 KB
/
config.py
File metadata and controls
executable file
·59 lines (40 loc) · 1.53 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
'''
Script to generate Makefile with the correct compiler
configuration for a given machine.
'''
from subprocess import *
import argparse
import sys
# Manage command-line arguments to load compiler option
parser = argparse.ArgumentParser()
parser.add_argument(
'config', metavar='CONFIG', type=str,
help='Name of config file to use (e.g., config/aire_gfortran)')
args = parser.parse_args()
# Determine locations
target_dir = "./"
config_dir = "config/"
config_path = args.config
# Load template Makefile and insert compiler configuration
makefile0 = open(config_dir+"Makefile").read()
compile_info = open(config_path).read()
makefile1 = makefile0.replace("<COMPILER_CONFIGURATION>",compile_info)
# Write the new Makefile to the main directory
open(target_dir+"Makefile","w").write(makefile1)
print( "".join(["\n\nMakefile configuration complete for configuration file: ",config_path,"\n"]) )
instructions = '''==== How to run coordinates ====\n
# Compile a test program
make clean
make coord-static # makes the static libray libcoordinates.a
# Run a test program
make test_ccsm3
./libcoordinates/bin/test_ccsm3.x
'''
print(instructions)
### Old script commands to automatically determine the config_path from host + compiler:
# Determine the current hostname
#proc = Popen("hostname",shell=True,stdout=PIPE,stderr=PIPE)
#host = proc.communicate()[0].strip().decode("utf-8")
#if host == "manager.cei.ucm.local": host = "eolo"
#if host in ["login01","login02"]: host = "pik"
#print("{}{}_{}".format(config_dir,host,compiler))