-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
175 lines (131 loc) · 4.54 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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
########################################
#MAKEFILE for PX915 Assignment, Group A#
########################################
#Fortran compiler & flags
#Uncomment -O3 to add compiler optimisation
compiler=gfortran #-O3 #-Wall -Wextra
#set to 1 to run in serial
num_threads=1
flags=`nf-config --fflags`
ifeq ($(num_threads),1)
libraries=`nf-config --flibs` -llapack
else
libraries=`nf-config --flibs` -llapack -fopenmp
endif
main=main.f90
exe=spmsolver.out
object=input_output_netcdf.o pde.o
#Compile line
spmsolver.out: $(object)
$(compiler) $(flags) $(object) $(main) $(libraries) -o $(exe)
-rm -f *.o *.mod
chmod +x uq_code/sens_ana.sh
chmod +x uq_code/up_code.sh
#Checking if object files created
ifeq ("$(wildcard $(./pde.o))","")
@echo "Crank-Nicolson solver ready"
else
@echo "Crank-Nicolson solver failed"
endif
ifeq ("$(wildcard $(./input_output_netcdf.o))","")
@echo "Input successful"
else
@echo "Input failed"
endif
#Checking the compilation status
ifeq ("$(wildcard $(./$(exe)))","")
@echo "Compilation sucessful"
else
@echo "Compilation failed"
endif
#Rules for building object files
%.o: %.f90
$(compiler) $(flags) -c $< $(libraries) -o $@
#Serial or parallel run
.PHONY: exe
ifeq ($(num_threads),1)
exe:
@./$(exe)
@echo "Running Serial code"
else
exe:
@OMP_NUM_THREADS=$(num_threads) ./$(exe)
@echo "Running Parallel code. Number of threads = " $(num_threads)
endif
#Generate visualisation
.PHONY: visual
visual:
gnome-terminal --tab -- python3 plots.py
#Purge build and output files, give no errors if they did not previously exist
.PHONY: clean
clean:
-rm -f *.o *.mod *.nc *chp $(exe)
-rm -f uq_code/*.nc uq_code/*.csv uq_code/*.chp
-rm -r uq_code/data_store_sens
-rm -r uq_code/data_store_up
@echo "Files removed"
#Generate Doxygen documentation
.PHONY: docs
docs:
-rm docs.html docs.pdf doxy-warns.log
doxygen ./doxygen/Doxyfile
(cd ./doxygen/output/latex && make)
cp ./doxygen/output/latex/refman.pdf docs.pdf
ln -s ./doxygen/output/html/index.html docs.html
#Perform sensitivity analysis and then display the results
.PHONY: sensitive
sensitive:
(cd ./uq_code && ./sens_ana.sh False)
#Display the results from the sensitivity analysis
.PHONY: vis_sens
vis_sens:
(cd ./uq_code ; gnome-terminal --tab -- python3 visual_uq_res.py)
#Perform uncertainty propagation using random latin hypercube sampling and display the results
.PHONY: uncertain
uncertain:
(cd ./uq_code && ./up_code.sh False)
#This PHONY command executes visual_up_data.py to visualise random latin hyper cube analysis results in a new terminal.
.PHONY: vis_uncer
vis_uncer:
(cd ./uq_code ; gnome-terminal --tab -- python3 visual_up_data.py False)
#This PHONY command executes sens_ana.sh False followed by up_code.sh True to perform sensitivity analysis, from this calculate an approximate uncertainty and then perform random latin hyper cube sampling to quantify uncertainty. Then plots results.
.PHONY: sens_uncer
sens_uncer:
(cd ./uq_code && ./sens_ana.sh False)
(cd ./uq_code && ./up_code.sh True)
#This PHONY commands visualises the approximate uncertainty calculated from sensitivity analysis.
.PHONY: vis_sens_uncer
vis_sens_uncer:
(cd ./uq_code ; gnome-terminal --tab -- python3 visual_up_data.py True)
#This PHONY command calculates an approximate uncertainty using standard deviation and displays this alongside already existing data from random latin hyper cube sampling.
.PHONY: sens_uncer_sep
sens_uncer_sep:
(cp ./uq_code/data_store_up/SPM_input_ori.nc ./uq_code/)
(cd ./uq_code && python3 generate_inp_params.py True)
(cd ./uq_code ; gnome-terminal --tab -- python3 visual_up_data.py True)
#This PHONY command calculates and displays approximate uncertainty calculated from sensitivity analysis.
.PHONY: uncer_from_sens
uncer_from_sens:
(cd ./uq_code && ./sens_ana.sh True)
#This PHONY command displays approximate uncertainty calculated from sensitivity analysis.
.PHONY: vis_uncer_from_sens
vis_uncer_from_sens:
(cd ./uq_code ; gnome-terminal --tab -- python3 vis_uncer_sens.py)
#Perform benchmarking
.PHONY: benchmarking
benchmarking:
(cd ./benchmarking ; gnome-terminal --tab -- python3 benchmarking.py)
#Create a virtual environment
.PHONY: virtual
virtual:
chmod +x datafitting/compile.sh
#chmod +x compile_1.sh
sudo apt install python3.10-venv
python3 -m venv venv
#Install modules for the virtual environment
#must be done after venv is activated: source venv/bin/activate
.PHONY: mods
mods:
pip install -r requirements.txt
jupyter contrib nbextension install --user
jupyter nbextension enable codefolding/main