aboutsummaryrefslogtreecommitdiff
path: root/Source/Make.WarpX
blob: 3060ae8f0bfbd0253720a23be2810bf320586c5a (plain) (blame)
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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
AMREX_HOME ?= ../../../amrex
PICSAR_HOME ?= ../../../picsar
OPENBC_HOME ?= ../../../openbc_poisson

USE_MPI       = TRUE
USE_PARTICLES = TRUE

ifeq ($(USE_GPU),TRUE)
  USE_OMP  = FALSE
  USE_CUDA = TRUE
  USE_ACC  = TRUE
  NVCC_HOST_COMP = gcc
endif

ifeq ($(USE_RZ),TRUE)
  # DIM is set here so that it is properly set for
  # all of the included files.
  DIM = 2
endif

ifeq ($(USE_ASCENT_INSITU),TRUE)
  ASCENT_HOME ?= NOT_SET
  ifneq ($(ASCENT_HOME),NOT_SET)
    include $(ASCENT_HOME)/share/ascent/ascent_config.mk
  endif
  USE_CONDUIT = TRUE
  USE_ASCENT = TRUE
endif

include $(AMREX_HOME)/Tools/GNUMake/Make.defs

ifndef USE_PYTHON_MAIN
  USE_PYTHON_MAIN = FALSE
endif

ifeq ($(USE_PYTHON_MAIN),TRUE)
  CXXFLAGS += -fPIC
ifeq ($(USE_OMP),TRUE)
  LDFLAGS += -fopenmp
endif
  CFLAGS   += -fPIC
  FFLAGS   += -fPIC
  F90FLAGS += -fPIC
  USERSuffix := .Lib
  DEFINES += -DWARPX_USE_PY
endif

ifeq ($(DIM),3)
  DEFINES += -DWARPX_DIM_3D
else
ifeq ($(USE_RZ),TRUE)
  DEFINES += -DWARPX_DIM_RZ
else
  DEFINES += -DWARPX_DIM_2D
endif
endif

-include Make.package
include $(WARPX_HOME)/Source/Make.package
include $(WARPX_HOME)/Source/BoundaryConditions/Make.package
include $(WARPX_HOME)/Source/Diagnostics/Make.package
include $(WARPX_HOME)/Source/FieldSolver/Make.package
include $(WARPX_HOME)/Source/Filter/Make.package
include $(WARPX_HOME)/Source/FortranInterface/Make.package
include $(WARPX_HOME)/Source/Initialization/Make.package
include $(WARPX_HOME)/Source/Laser/Make.package
include $(WARPX_HOME)/Source/Parallelization/Make.package
include $(WARPX_HOME)/Source/Parser/Make.package
include $(WARPX_HOME)/Source/Particles/Make.package
include $(WARPX_HOME)/Source/Python/Make.package
include $(WARPX_HOME)/Source/Utils/Make.package
include $(WARPX_HOME)/Source/Evolve/Make.package

include $(AMREX_HOME)/Src/Base/Make.package
include $(AMREX_HOME)/Src/Particle/Make.package
include $(AMREX_HOME)/Src/Boundary/Make.package
include $(AMREX_HOME)/Src/AmrCore/Make.package

ifeq ($(USE_SENSEI_INSITU),TRUE)
  include $(AMREX_HOME)/Src/Amr/Make.package
  include $(AMREX_HOME)/Src/Extern/SENSEI/Make.package
endif

include $(PICSAR_HOME)/src/Make.package

WARPX_GIT_VERSION := $(shell cd $(WARPX_HOME); git describe --abbrev=12 --dirty --always --tags)
PICSAR_GIT_VERSION := $(shell cd $(PICSAR_HOME); git describe --abbrev=12 --dirty --always --tags)
DEFINES += -DWARPX_GIT_VERSION=\"$(WARPX_GIT_VERSION)\"
DEFINES += -DPICSAR_GIT_VERSION=\"$(PICSAR_GIT_VERSION)\"

DEFINES += -DPICSAR_NO_ASSUMED_ALIGNMENT
DEFINES += -DWARPX

ifeq ($(USE_OPENBC_POISSON),TRUE)
  include $(OPENBC_HOME)/Make.package
  DEFINES += -DFFT_FFTW -DMPIPARALLEL -DUSE_OPENBC_POISSON
endif

ifeq ($(USE_OPENPMD), TRUE)
   OPENPMD_LIB_PATH ?= NOT_SET
   ifneq ($(OPENPMD_LIB_PATH),NOT_SET)
     LIBRARY_LOCATIONS += $(OPENPMD_LIB_PATH)
   endif
   OPENPMD_INCLUDE_PATH ?= NOT_SET
   ifneq ($(OPENPMD_INCLUDE_PATH),NOT_SET)
     INCLUDE_LOCATIONS += $(OPENPMD_INCLUDE_PATH)
   endif
   DEFINES += -DWARPX_USE_OPENPMD -DopenPMD_HAVE_MPI=1
   LIBRARIES += -lopenPMD -lhdf5
endif
   

ifeq ($(USE_PSATD),TRUE)
  USERSuffix := $(USERSuffix).PSATD
  DEFINES += -DWARPX_USE_PSATD
  ifeq ($(USE_CUDA),FALSE) # Running on CPU
     # Use FFTW
     LIBRARIES += -lfftw3_mpi -lfftw3 -lfftw3_threads
     FFTW_HOME ?= NOT_SET
     ifneq ($(FFTW_HOME),NOT_SET)
       VPATH_LOCATIONS += $(FFTW_HOME)/include
       INCLUDE_LOCATIONS += $(FFTW_HOME)/include
       LIBRARY_LOCATIONS += $(FFTW_HOME)/lib
     endif
     # Compile with PICSAR's Hybrid-MPI PSATD
     DEFINES += -DWARPX_USE_PSATD_HYBRID
     DEFINES += -DFFTW # PICSAR uses it
  else
    # Use cuFFT
    LIBRARIES += -lcufft
  endif
endif

ifeq ($(USE_RZ),TRUE)
  USERSuffix := $(USERSuffix).RZ
  DEFINES += -DWARPX_RZ
endif

ifeq ($(DO_ELECTROSTATIC),TRUE)
     include $(AMREX_HOME)/Src/LinearSolvers/C_to_F_MG/Make.package
     include $(AMREX_HOME)/Src/LinearSolvers/F_MG/FParallelMG.mak
     include $(AMREX_HOME)/Src/F_BaseLib/FParallelMG.mak
     DEFINES += -DWARPX_DO_ELECTROSTATIC
endif

ifeq ($(USE_HDF5),TRUE)
    HDF5_HOME ?= NOT_SET
    ifneq ($(HDF5_HOME),NOT_SET)
        VPATH_LOCATIONS += $(HDF5_HOME)/include
        INCLUDE_LOCATIONS += $(HDF5_HOME)/include
        LIBRARY_LOCATIONS += $(HDF5_HOME)/lib
    endif
    DEFINES += -DWARPX_USE_HDF5
    LIBRARIES += -lhdf5 -lz
endif     

# job_info support
CEXE_sources += AMReX_buildInfo.cpp
CEXE_headers += $(AMREX_HOME)/Tools/C_scripts/AMReX_buildInfo.H
INCLUDE_LOCATIONS += $(AMREX_HOME)/Tools/C_scripts

ifeq ($(USE_PYTHON_MAIN),TRUE)

ifeq ($(shell uname),Darwin)
  SHARED_OPTION = -dynamiclib
else
  SHARED_OPTION = -shared
endif

ifeq ($(USE_RZ),TRUE)
  PYDIM = rz
else
  PYDIM = $(DIM)d
endif

installwarpx: libwarpx$(PYDIM).so
	mv libwarpx$(PYDIM).so Python/pywarpx
	cd Python; python setup.py install --with-libwarpx $(PYDIM) $(PYINSTALLOPTIONS)

libwarpx$(PYDIM).a: $(objForExecs)
	@echo Making static library $@ ...
	$(SILENT) $(AR) -crv $@ $^
	$(SILENT) $(RM) AMReX_buildInfo.cpp
	@echo SUCCESS

libwarpx$(PYDIM).so: $(objForExecs)
	@echo Making dynamic library $@ ...
	$(SILENT) $(CXX) $(SHARED_OPTION) -fPIC -o $@ $^ $(LDFLAGS) $(libraries)
	$(SILENT) $(RM) AMReX_buildInfo.cpp
	@echo SUCCESS

clean::
	$(SILENT) $(RM) -rf build
	$(SILENT) $(RM) -f libwarpx?d.a
	$(SILENT) $(RM) -f libwarpx?d.so
	$(SILENT) $(RM) -f pywarpx/libwarpx?d.so

else

ifdef WarpxBinDir

all: $(executable) 
	$(SILENT) $(RM) AMReX_buildInfo.cpp
	@if [ ! -d $(WarpxBinDir) ]; then mkdir -p $(WarpxBinDir); fi
	$(SILENT) mv -f $(executable) $(WarpxBinDir)/
	@if [ -d $(executable).dSYM ]; then $(RM) -r $(WarpxBinDir)/$(executable).dSYM; mv -f $(executable).dSYM $(WarpxBinDir)/; fi
	@echo SUCCESS

else

all: $(executable) 
	$(SILENT) $(RM) AMReX_buildInfo.cpp
	@echo SUCCESS

endif

endif

AMReX_buildInfo.cpp: 
	$(AMREX_HOME)/Tools/C_scripts/makebuildinfo_C.py \
          --amrex_home "$(AMREX_HOME)" \
          --COMP "$(COMP)" --COMP_VERSION "$(COMP_VERSION)" \
          --CXX_comp_name "$(CXX)" --CXX_flags "$(CXXFLAGS) $(CPPFLAGS) $(includes)" \
          --F_comp_name "$(F90)" --F_flags "$(F90FLAGS)" \
          --link_flags "$(LDFLAGS)" --libraries "$(libraries)" \
          --GIT ". $(AMREX_HOME) $(PICSAR_HOME)"

include $(AMREX_HOME)/Tools/GNUMake/Make.rules

clean::
	$(SILENT) $(RM) AMReX_buildInfo.cpp