-
Notifications
You must be signed in to change notification settings - Fork 6
/
makefile
137 lines (113 loc) · 4.75 KB
/
makefile
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
# ./heat alpha=8.2e-10 lenx=0.25 dx=0.01 dt=100 maxt=5580000 outi=100 savi=1000 bc0=233.15 bc1=294.261 ic="const(294.261)"
# make CXX=clang CXXFLAGS=-fopenmp LDFLAGS="-lomp -lstdc++" heat
# macOS...
# https://mac.r-project.org/openmp/
# make CXX=clang CXXFLAGS="-Xclang -fopenmp -I/Users/miller86/ideas-ecp/hello-numerical-world/omp/include" LDFLAGS="-lomp -lstdc++" heat
# make CXXFLAGS="-Xpreprocessor -fopenmp" CPPFLAGS=-DFPTYPE=0 LDFLAGS=-lomp ERRBND=1e-1 check_all
# had to copy libomp.dylib to /usr/local/lib
ERRBND ?= 1e-6
PTOOL ?= visit
RUNAME ?= heat_results
PIPEWIDTH ?= 0.1
RM = rm
# Headers
HDR = Number.h heat.h
# Source Files
SRC = heat.c utils.c args.c exact.c ftcs.c crankn.c dufrank.c
# Object Files
OBJ = $(SRC:.c=.o)
# Coverage Files
GCOV = $(SRC:.c=.c.gcov) $(SRC:.c=.gcda) $(SRC:.c=.gcno) $(HDR:.h=.h.gcov)
# Executable
EXE = heat
# Implicit rule for object files
%.o : %.c
$(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@
# Help is default target
help:
@echo "Targets:"
@echo " heat: makes the default heat application (double precision)"
@echo " heat-omp: makes default heat application with openmp threads"
@echo " heat-single: makes the heat application with single precision"
@echo " heat-double: makes the heat application with double precision"
@echo " heat-long-double: makes the heat application with long-double precision"
@echo " PTOOL=[gnuplot,matplotlib,visit] RUNAME=<run-dir-name> plot: plots results"
@echo " check: runs various tests confirming steady-state is linear"
# Linking the final heat app
heat: $(OBJ)
$(CC) -o heat $(OBJ) $(LDFLAGS) -lm
heat-omp: CC=clang
heat-omp: CFLAGS=-fopenmp
heat-omp: LDFLAGS=-lomp -lstdc++
heat-omp: $(OBJ)
heat-omp: heat
mv heat heat-omp
# All objects depend on header
$(OBJ): $(HDR)
# Convenience variable/target for half-precision
heat-half: CPPFLAGS=-DFPTYPE=0
heat-half: CFLAGS=-Wno-format
heat-half: $(OBJ)
heat-half: heat
mv heat heat-half
# Convenience variable/target for single-precision
heat-single: CPPFLAGS=-DFPTYPE=1
heat-single: $(OBJ)
heat-single: heat
mv heat heat-single
# Convenience variable/target for double-precision
# Same as default
heat-double: CPPFLAGS=-DFPTYPE=2
heat-double: $(OBJ)
heat-double: heat
mv heat heat-double
# Convenience variable/target for long-double-precision
heat-long-double: CPPFLAGS=-DFPTYPE=3
heat-long-double: $(OBJ)
heat-long-double: heat
mv heat heat-long-double
# convenient target to plot results
plot:
@test -r ./tools/run_$(PTOOL).sh || ( echo "Cannot find plotting tool \"$(PTOOL)\"" && exit 1 )
@test -d $(RUNAME) || ( echo "Cannot find results dir \"$(RUNAME)\"" && exit 1 )
@test -d $(RUNAME) && ./tools/run_$(PTOOL).sh $(RUNAME) $(PIPEWIDTH)
check_clean:
$(RM) -rf check check_impulse check_crankn check_dufrank
$(RM) -rf heat heat-omp heat-half heat-single heat-double heat-long-double
clean: check_clean
$(RM) -f $(OBJ) $(EXE) $(GCOV)
#
# Run for a long time with random initial condition
# and confirm linear stead-state upon termination
#
check/check_soln_final.curve:
./heat runame=check outi=0 maxt=10 ic="rand(0,0.2,2)"
check: heat check/check_soln_final.curve check_sin/check_sin_soln_final.curve check_impulse/check_impulse_soln_00100.curve
@echo "Time zero..."
@cat check/check_soln_00000.curve
@echo "Final result..."
@cat check/check_soln_final.curve
./python_testing/check_lss.py check/check_soln_final.curve $(ERRBND)
@echo "Sinusoidal check result..."
./python_testing/sinusoidal_solution.py check_sin/check_sin_soln_final.curve 0.01 0.00004 0.2 10 2
@echo "Impulse check result..."
@cat check_impulse/check_impulse_soln_00100.curve
./python_testing/impulse_solution.py check_impulse/check_impulse_soln_00100.curve 0.01 0.00004 0.2 1
check_impulse/check_impulse_soln_00100.curve: heat
@echo "Generating impulse check solution..."
./heat runame=check_impulse dx=0.01 dt=0.00004 alpha=0.2 lenx=1 bc1=0 ic="spikes(0,100,50)" maxt=0.04 outi=100 savi=100
check_sin/check_sin_soln_final.curve: heat
@echo "Generating sinusoidal check solution..."
./heat runame=check_sin dx=0.01 dt=0.00004 alpha=0.2 ic="sin(10,2)" outi=100 savi=100 maxt=0.004 bc1=0
check_ftcs: check
check_crankn/check_crankn_soln_final.curve:
./heat alg=crankn runame=check_crankn outi=0 maxt=10 ic="rand(0,0.2,2)"
check_crankn: heat check_crankn/check_crankn_soln_final.curve
cat check_crankn/check_crankn_soln_final.curve
./python_testing/check_lss.py check_crankn/check_crankn_soln_final.curve $(ERRBND)
check_dufrank/check_dufrank_soln_final.curve:
./heat alg=dufrank runame=check_dufrank outi=0 maxt=40 ic="rand(0,0.2,2)"
check_dufrank: heat check_dufrank/check_dufrank_soln_final.curve
cat check_dufrank/check_dufrank_soln_final.curve
./python_testing/check_lss.py check_dufrank/check_dufrank_soln_final.curve $(ERRBND)
check_all: check_ftcs check_crankn check_dufrank