forked from SHUD-System/SHUD
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
157 lines (129 loc) · 4.14 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
# -----------------------------------------------------------------
# Version: 1.0
# Date: Nov 2019
# Makefile for SHUD v 1.0
# -----------------------------------------------------------------
# Programmer: Lele Shu ([email protected])
# SHUD model is a heritage of Penn State Integrated Hydrologic Model (PIHM).
# -----------------------------------------------------------------
# Prerequisite:
# 1 install sundials 5.0+ via https://computation.llnl.gov/projects/sundials/sundials-software.
# 2 If parallel-computing is prefered, please install OpenMP.
# For mac:
#
brew install llvm clang
# brew install libomp
# compile flags for OpenMP:
# -Xpreprocessor -fopenmp -lomp
# Library/Include paths:
# -L/usr/local/opt/libomp/lib
# -I/usr/local/opt/libomp/include
#
# -----------------------------------------------------------------
# Configure this File:
# 1 Path of SUNDIALS_DIR. [CRITICAL]
# 2 Path of OpenMP if parallel is preffered.
# 3 Path of SRC_DIR, default is "SRC_DIR = ."
# 4 Path of BUILT_DIR, default is "BUILT_DIR = ."
# -----------------------------------------------------------------
SUNDIALS_DIR = $(HOME)/sundials
# SUNDIALS_DIR = /usr/local/sundials
SHELL = /bin/sh
BUILDDIR = .
SRC_DIR = src
LIB_SYS = /usr/local/lib/
INC_OMP = /usr/local/opt/libomp/include
LIB_OMP = /usr/local/opt/libomp/lib
LIB_SUN = ${SUNDIALS_DIR}/lib
INC_MPI = /usr/local/opt/open-mpi
TARGET_EXEC = ${BUILDDIR}/shud
TARGET_OMP = ${BUILDDIR}/shud_omp
TARGET_DEBUG = ${BUILDDIR}/shud_debug
MAIN_shud = ${SRC_DIR}/main.cpp
MAIN_OMP = ${SRC_DIR}/main.cpp
MAIN_DEBUG = ${SRC_DIR}/main.cpp
# If compile on Cluster
# CC = g++
# MPICC = mpic++
# LK_OMP = -fopenmp -lsundials_nvecopenmp
# export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${SUNDIALS_DIR}/lib
CC = /usr/bin/g++
MPICC = /usr/local/bin/mpic++
CFLAGS = -O3 -g -std=c++14
#STCFLAG = -static
SRC = ${SRC_DIR}/classes/*.cpp \
${SRC_DIR}/ModelData/*.cpp \
${SRC_DIR}/Model/*.cpp \
${SRC_DIR}/Equations/*.cpp
SRC_H = ${SRC_DIR}/classes/*.hpp \
${SRC_DIR}/ModelData/*.hpp \
${SRC_DIR}/Model/*.hpp \
${SRC_DIR}/Equations/*.hpp
INCLUDES = -I ${SUNDIALS_DIR}/include \
-I ${INC_OMP} \
-I ${SRC_DIR}/Model \
-I ${SRC_DIR}/ModelData \
-I ${SRC_DIR}/classes \
-I ${SRC_DIR}/Equations
LIBRARIES = -L ${LIB_OMP} \
-L ${LIB_SUN} \
-L ${LIB_SYS}
RPATH = '-Wl,-rpath,${LIB_SUN}'
LK_FLAGS = -lm -lsundials_cvode -lsundials_nvecserial
LK_OMP = -Xpreprocessor -fopenmp -lomp -lsundials_nvecopenmp
LK_DYLN = "LD_LIBRARY_PATH=${LIB_SUN}"
all:
make clean
make shud
@echo
check:
ls ${SUNDIALS_DIR}
ls ${SUNDIALS_DIR}/lib
./shud
@echo
help:
@(echo)
@echo "Usage:"
@(echo ' make all - make both shud and shud_omp')
@(echo ' make cvode - install SUNDIALS/CVODE to ~/sundials')
@(echo ' make shud - make shud executable')
@(echo ' make shud_omp - make shud_omp with OpenMP support')
@(echo)
@(echo ' make clean - remove all executable files')
@(echo)
cvode CVODE:
@echo '...Install SUNDIALS/CVODE for your ...'
chmod +x configure
./configure
@echo
shud SHUD: ${MAIN_shud} $(SRC) $(SRC_H)
@echo '...Compiling shud ...'
@echo $(CC) $(CFLAGS) ${STCFLAG} ${INCLUDES} ${LIBRARIES} ${RPATH} -o ${TARGET_EXEC} ${MAIN_shud} $(SRC) $(LK_FLAGS)
@echo
@echo
$(CC) $(CFLAGS) ${INCLUDES} ${STCFLAG} ${LIBRARIES} ${RPATH} -o ${TARGET_EXEC} ${MAIN_shud} $(SRC) $(LK_FLAGS)
@echo
@echo
@echo " ${TARGET_EXEC} is compiled successfully!"
@echo
shud_omp: ${MAIN_OMP} $(SRC) $(SRC_H)
@echo '...Compiling shud_OpenMP ...'
@echo $(CC) $(CFLAGS) ${STCFLAG} ${RPATH} -D_OPENMP_ON ${INCLUDES} ${LIBRARIES} -o ${TARGET_OMP} ${MAIN_OMP} $(SRC) $(LK_FLAGS) $(LK_OMP)
@echo
@echo
$(CC) $(CFLAGS) ${STCFLAG} ${RPATH} -D_OPENMP_ON ${INCLUDES} ${LIBRARIES} -o ${TARGET_OMP} ${MAIN_OMP} $(SRC) $(LK_FLAGS) $(LK_OMP)
@echo
@echo " ${TARGET_OMP} is compiled successfully!"
@echo
@echo
clean:
@echo "Cleaning ... "
@echo
@echo " rm -f *.o"
@rm -f *.o
@echo " rm -f ${TARGET_EXEC}"
@rm -f ${TARGET_EXEC}
@echo " rm -f ${TARGET_OMP}"
@rm -f ${TARGET_OMP}
@echo
@echo "Done."
@echo