Debian Codegraph @

build/Makefile

raw ◀ ▶
Source reconstructed at patch state 0 of 3 — not the installed (fully patched) source.
3 Debian patches touch this file
1 ##-------------------------------------------------------------------##
2 ## Makefile for compiling SPLASH and linking with ##
3 ## required libraries ##
4 ## ##
5 ## Written by Daniel Price ##
6 ## University of Exeter, UK, 2004-2008 ##
7 ## Monash University, Australia, 2008- ##
8 ## ##
9 ## requires GNU make (on some systems this is 'gmake' instead ##
10 ## of 'make') ##
11 ## ##
12 ## see the INSTALL file for detailed installation instructions ##
13 ##-------------------------------------------------------------------##
14
15 .KEEP_STATE:
16
17 KNOWN_SYSTEM=no
18 SRCDIR=../src
19 BINDIR=../bin
20 TESTDIR=../tests
21 VPATH=$(SRCDIR) $(SRCDIR)/H5Part ../utils
22 SHELL=/bin/bash
23
24 #
25 # use SYSTEM=gfortran if no SYSTEM variable is set
26 #
27 ifndef SYSTEM
28 SYSTEM=gfortran
29 endif
30 #
31 # some default settings for unix systems
32 #
33 FC=
34 FFLAGS=
35 #
36 # change the line below if SPLASH does not find the X11 libraries
37 # (some settings of the SYSTEM variable for specific machines overwrite this)
38 #
39 # X11_LIBS= -L/usr/X11R6/lib64 -lX11
40 X11_DIR= /usr/X11/
41 X11_LIBS= -L$(X11_DIR)/lib -lX11
42 X11_CFLAGS= -I$(X11_DIR)/include
43 CAIRO_LIBS= -L$(X11_DIR)/lib -lcairo
44 CAIRO_CFLAGS= -I$(X11_DIR)/include
45
46 #--------------------------------------------------------------
47 # here we choose the backend plotting library for splash
48 # (giza is the default backend for splash v2.x, but can
49 # still be compiled with PGPLOT, just with disabled features)
50 #--------------------------------------------------------------
51 ifeq ($(BACKEND), pgplot)
52 #-- P G P L O T --
53 PLOTLIB= plotlib_pgplot.f90
54 #
55 # change the line below depending on where/how you have installed PGPLOT
56 # (some settings of the SYSTEM variable for specific machines overwrite this)
57 #
58 PGPLOTLIBS = -L$(PGPLOT_DIR) -lpgplot -lpng
59 else
60 ifeq ($(BACKEND), none)
61 PLOTLIB= plotlib_mock.f90
62 else
63 #-- C A I R O --
64 GIZA_DIR= $(PREFIX)
65 PLOTLIB= giza-fortran.F90 plotlib_giza.f90
66 PGPLOTLIBS = -L$(GIZA_DIR)/lib -lgiza $(CAIRO_LIBS)
67 CFLAGS= -fPIC -Wall -Wextra -O3 -g
68 CC = gcc
69 endif
70 endif
71 #--------------------------------------------------------------
72
73 #
74 # If you need the HDF5 libraries, edit the lines below
75 # possibly adding a -L/libpath/ and a -I/includepath/
76 #
77 ifndef HDF5ROOT
78 ifdef HDF5_ROOT
79 HDF5ROOT=$(HDF5_ROOT)
80 endif
81 ifdef HDF5_DIR
82 HDF5ROOT=$(HDF5_DIR)
83 endif
84 endif
85 HDF5LIBS = -L$(HDF5ROOT)/lib -lhdf5
86 HDF5INCLUDE = -I$(HDF5ROOT)/include
87 H5PART_LIBS = -L$(H5PART_DIR)/lib -lH5Part
88 H5PART_INCLUDE = -I$(H5PART_DIR)/include
89 ifdef FITS_DIR
90 FITSLIBS = -L$(FITS_DIR)/lib -lcfitsio
91 else
92 FITSLIBS = -lcfitsio
93 endif
94 FITSINCLUDE = -I$(FITS_DIR)/include
95 #
96 # this file contains system-dependent routines like getarg, iargc etc.
97 #
98 SYSTEMFILE= system_f2003.f90
99 #
100 # this can be used to static link the pgplot libraries if all else fails
101 #
102 STATICLIBS=
103 #
104 # set the parallel flag to 'yes' to compile with openMP directives
105 #
106 #PARALLEL=no
107 ifndef OPENMP
108 OPENMP=yes
109 endif
110 #
111 # compile in double precision by default (v3.0 onwards this is now default)
112 #
113 ifndef DOUBLEPRECISION
114 DOUBLEPRECISION=yes
115 endif
116 #
117 # the openMP flags should be set in the lines defining your system type
118 # (ie. leave line below blank)
119 OMPFLAGS=
120 #
121 # the endian flag can be used to compile the code to read BIG or LITTLE endian data
122 # some compilers also allow this to be done at runtime (e.g. g95, ifort) by setting
123 # an environment variable appropriately (e.g. G95_ENDIAN or F_UFMTENDIAN)
124 #
125 #ENDIAN=
126 #ENDIAN='BIG'
127 #ENDIAN='LITTLE'
128 #
129 # default destination for installed binaries
130 #
131 DESTDIR=
132 PREFIX=/usr/local/
133 #
134 # default C compiler
135 #
136 ifndef CC
137 CC = gcc
138 endif
139 ifndef CXX
140 CXX = g++
141 endif
142
143 # default C++ library linking
144 # (different between Mac/Linux)
145 UNAME=$(shell uname)
146 ifeq ($(UNAME), Darwin)
147 CXXLIBS= -lc++
148 else
149 CXXLIBS= -lstdc++
150 endif
151
152 #--------------------------------------------------------------
153 # the following are general settings for particular compilers
154 #
155 # set the environment variable 'SYSTEM' to one of those
156 # listed to use the appropriate settings
157 #
158 # in bash the equivalent is
159 # export SYSTEM='gfortran'
160 #
161 #--------------------------------------------------------------
162
163 ifeq ($(SYSTEM), gfortran)
164 # gfortran compiler (part of gcc 4.x.x)
165 FC= gfortran
166 FFLAGS= -O3 -fPIC
167 DBLFLAGS= -fdefault-real-8 -fdefault-double-8
168 SYSTEMFILE= system_f2003.f90
169 DEBUGFLAG= -Wall -Wextra -pedantic -g -frange-check -fcheck=all -fbacktrace \
170 -finit-real=NaN #-ffpe-trap=invalid,zero,overflow
171 OMPFLAGS= -fopenmp
172 ENDIANFLAGBIG= -fconvert=big-endian
173 ENDIANFLAGLITTLE= -fconvert=little-endian
174 KNOWN_SYSTEM=yes
175 endif
176
177 ifeq ($(SYSTEM),sunf95)
178 # sun f95 compiler on linux
179 FC= sunf95
180 FFLAGS= -fast -ftrap=%none
181 OMPFLAGS= -openmp
182 DBLFLAGS= -xtypemap=real:64,double:64
183 DEBUGFLAG= -g -C -w4 -errtags -erroff=COMMENT_1582,COMMENT_1744 -ftrap=%all
184 SYSTEMFILE= system_f2003.f90
185 ENDIANFLAGBIG= -xfilebyteorder=big16:%all
186 ENDIANFLAGLITTLE= -xfilebyteorder=little16:%all
187 KNOWN_SYSTEM=yes
188 endif
189
190 ifeq ($(SYSTEM),ifort)
191 # this is for the intel fortran compiler (version 10)
192 FC= ifort
193 FFLAGS= -O3 -nbs -fPIC
194 OMPFLAGS= -qopenmp
195 DBLFLAGS= -r8
196 DEBUGFLAG= -C -g
197 SYSTEMFILE= system_f2003.f90
198 ENDIANFLAGBIG= -convert big_endian
199 ENDIANFLAGLITTLE= -convert little_endian
200 # or use setenv F_UFMTENDIAN=big or little at runtime
201 KNOWN_SYSTEM=yes
202 CC=icc
203 CFLAGS=-Wall -O3 -fPIC
204 endif
205
206 ifeq ($(SYSTEM),ifx)
207 # this is for the intel fortran compiler (version 10)
208 FC= ifx
209 FFLAGS= -O3 -nbs -fPIC
210 OMPFLAGS= -qopenmp
211 DBLFLAGS= -r8
212 DEBUGFLAG= -C -g
213 SYSTEMFILE= system_f2003.f90
214 ENDIANFLAGBIG= -convert big_endian
215 ENDIANFLAGLITTLE= -convert little_endian
216 # or use setenv F_UFMTENDIAN=big or little at runtime
217 KNOWN_SYSTEM=yes
218 CC=icc
219 CFLAGS=-Wall -O3 -fPIC
220 endif
221
222 ifeq ($(SYSTEM),pgf90)
223 # this is for the Portland Group Fortran 90 compiler (tested with version 7.2-5)
224 FC= pgf90
225 FFLAGS= -fast -mcmodel=medium -Mbackslash -Ktrap=none
226 DBLFLAGS= -r8
227 DEBUGFLAG= -C -g -gopt -Mbounds -Mchkfpstk -Mchkptr -Mchkstk -Mcoff \
228 -Mdwarf1 -Mdwarf2 -Melf -Mpgicoff -traceback
229 OMPFLAGS= -mp
230 SYSTEMFILE= system_f2003.f90
231 ENDIANFLAGBIG= -Mbyteswapio # only works on a little-endian machine
232 ENDIANFLAGLITTLE=
233 KNOWN_SYSTEM=yes
234 endif
235
236 ifeq ($(SYSTEM),pathf95)
237 # this is for the Pathscale f95 compiler
238 FC= pathf95
239 FFLAGS= -Ofast -mcmodel=medium
240 DBLFLAGS= -r8
241 DEBUGFLAG= -C -g
242 OMPFLAGS= -openmp
243 SYSTEMFILE= system_f2003.f90
244 ENDIANFLAGBIG= -convert big_endian
245 ENDIANFLAGLITTLE= -convert little_endian
246 KNOWN_SYSTEM=yes
247 endif
248
249 #--------------------------------------------------------------
250 #
251 # the following presets are user or machine-specific
252 #
253 #--------------------------------------------------------------
254 ifeq ($(SYSTEM),cody)
255 FC= gfortran
256 FFLAGS= -O3 -Wall
257 SYSTEMFILE= system_f2003.f90
258 DBLFLAGS= -fdefault-real-8 -fdefault-double-8
259 DEBUGFLAG= -g -frange-check
260 OMPFLAGS= -fopenmp
261 ENDIANFLAGBIG= -fconvert=big-endian
262 ENDIANFLAGLITTLE= -fconvert=little-endian
263 SNFLAGS= -L$(HOME)/tree16/Objfiles/g5 -lsw
264 CFLAGS = -g -O2 -Wall -I$(HOME)/tree16/include -fbounds-check
265 CC = gcc
266 KNOWN_SYSTEM=yes
267 endif
268
269 #
270 # these are the flags used for linking
271 #
272 LDFLAGS= $(X11_LIBS) $(PGPLOTLIBS)
273 PIELDFLAGS= -pie
274
275 #
276 # this is an option to change the endian-ness at compile time
277 # (provided the appropriate flags are specified for the compiler)
278 #
279 ifeq ($(ENDIAN), BIG)
280 FFLAGS += ${ENDIANFLAGBIG}
281 endif
282
283 ifeq ($(ENDIAN), LITTLE)
284 FFLAGS += ${ENDIANFLAGLITTLE}
285 endif
286
287 # compile in parallel
288 ifeq ($(PARALLEL),yes)
289 FFLAGS += $(OMPFLAGS)
290 else
291 ifeq ($(OPENMP),yes)
292 FFLAGS += $(OMPFLAGS)
293 endif
294 endif
295
296 # compile in double precision
297 ifeq ($(DOUBLEPRECISION), yes)
298 FFLAGS += ${DBLFLAGS}
299 FPPFLAGS+=-DDP
300 endif
301
302 # add debugging flags at compile time
303 ifeq ($(DEBUG),yes)
304 FFLAGS += $(DEBUGFLAG)
305 endif
306
307 #
308 # MPI... no splash doesn't use it
309 # but sometimes you need to compile
310 # with the mpi compiler (e.g. to link
311 # correctly to MPI-HDF5 libraries)
312 # This just changes the compiler name
313 # whilst keeping the flags the same
314 # if MPI is set to "yes"
315 #
316 ifeq ($(MPI),yes)
317 FC= mpif90 -DPARALLEL_IO
318 CC=mpicc -DPARALLEL_IO
319 endif
320
321 #
322 # If PGPLOT was compiled with a different compiler to the one used here,
323 # need to link to the libraries for that compiler. We attempt to do this
324 # automatically below by looking in the PGPLOT makefile.
325 #
326 # If the relevant library is not found, may also need -L/dir/ for the directory
327 # where the corresponding library is located (e.g. -L/usr/local/gfortran/lib -lgfortran)
328 #
329 # (information about what is done here is printed via the checkpgplot target, below)
330 #
331 ifeq ($(BACKEND),pgplot)
332 ifdef PGPLOT_DIR
333
334 PGPLOT_COMP=${shell if [ -e $$PGPLOT_DIR/makefile ]; then grep 'FCOMPL=' $$PGPLOT_DIR/makefile | cut -d= -f2; else echo unknown; fi}
335
336 ifneq (X$(FC), X) # make sure it is not just accidentally blank
337 ifneq ($(PGPLOT_COMP), $(FC))
338 # g77-compiled PGPLOT
339 ifeq ($(PGPLOT_COMP), g77)
340 PGPLOTLIBS+=-lg2c
341 endif
342 # gfortran-compiled PGPLOT
343 ifeq ($(PGPLOT_COMP), gfortran)
344 PGPLOTLIBS+=-lgfortran
345 endif
346 # g95-compiled PGPLOT
347 ifeq ($(PGPLOT_COMP), g95)
348 PGPLOTLIBS+=-lg95
349 endif
350 endif
351 endif
352 endif
353 endif
354
355 ifeq ($(FC),gfortran)
356 GFORTRAN_VERSION=${shell $(FC) -dumpversion | head -1 | awk '{print $$NF}'}
357 GFORTRAN_VMAJOR:=${shell echo "$(GFORTRAN_VERSION)" | cut -f1 -d.}
358 GFORTRAN_VMINOR:=${shell echo "$(GFORTRAN_VERSION)" | cut -f2 -d.}
359 GFORTRAN_GE_4_4:=$(shell [ $(GFORTRAN_VMAJOR) -gt 4 -o \( $(GFORTRAN_VMAJOR) -eq 4 -a $(GFORTRAN_VMINOR) -ge 4 \) ] && echo true)
360 else
361 GFORTRAN_GE_4_4:=true
362 endif
363
364 # define the implicit rule to make a .o file from a .f90/.f95 file
365 # (some Make versions don't know this)
366
367 %.o : %.f90
368 $(FC) $(FFLAGS) -c $< -o $@
369 %.o : %.F90
370 $(FC) $(FPPFLAGS) $(FFLAGS) -c $< -o $@
371 %.o : %.f95
372 $(FC) $(FFLAGS) -c $< -o $@
373 %.o : %.c
374 $(CC) -c $(CFLAGS) $(INCLUDES) $< -o $@
375
376 # modules must be compiled in the correct order to check interfaces
377 # really should include all dependencies but I am lazy
378
379 READFILES= utils_json.f90 \
380 read_data_ascii.f90 read_data_sphNG.f90 read_data_ndspmhd.f90 \
381 read_data_gadget.f90 read_data_VINE.f90 read_data_sro.f90 \
382 read_data_dragon.f90 read_data_seren.f90 read_data_tipsy.f90 \
383 read_data_mhutch.f90 read_data_UCLA.f90 read_data_aly.f90 \
384 read_data_bauswein.f90 read_data_egaburov.f90 read_data_starsmasher.f90 \
385 read_data_gadget_jsb.f90 read_data_foulkes.f90 read_data_jjm.f90 \
386 read_data_jjm_multiphase.f90 read_data_mbate.f90 read_data_oilonwater.f90 \
387 read_data_rsph.f90 read_data_urban.f90 read_data_shamrock.f90 \
388 read_data_spyros.f90 read_data_vanaverbeke.f90 read_data_vtk.f90
389
390 READFILES_HDF5= hdf5_helper_utils.c read_data_gadget_hdf5_utils.c read_data_gadget_hdf5.f90 \
391 read_data_amuse_hdf5_utils.c read_data_amuse_hdf5.f90 \
392 read_data_cactus_hdf5_utils.c read_data_cactus_hdf5_futils.f90 read_data_cactus_hdf5.f90 \
393 read_data_flash_hdf5_utils.c read_data_flash_hdf5.f90
394 #read_data_falcON_hdf5_utils.cc read_data_falcON_hdf5_utils.f90 read_data_falcON_hdf5.f90 \
395
396 READFILES_FITS= write_fits.f90 read_data_fits.f90
397
398 READFILES_PBOB= read_data_pbob_utils.c read_data_pbob.f90 read_pbob.c read_particle.c
399
400 READFILES_H5PART= H5PartF.c H5PartAttribF.c H5Part.f90 H5PartAttrib.f90
401
402 RUN_CHECKS=
403
404 LDFLAGSLIB=
405
406 # link with hdf5 libraries
407 ifeq ($(HDF5),yes)
408 READFILES+=$(READFILES_HDF5)
409 CFLAGS+=$(HDF5INCLUDE)
410 LDFLAGS+=$(HDF5LIBS)
411 LDFLAGSLIB+=$(HDF5LIBS)
412 FPPFLAGS+=-DHDF5
413 RUN_CHECKS+=checkhdf5
414 endif
415
416
417 ifeq ($(FITS),yes)
418 READFILES+= $(READFILES_FITS)
419 LDFLAGS+=$(FITSLIBS)
420 LDFLAGSLIB+=$(FITSLIBS)
421 FPPFLAGS+=-DFITS
422 RUN_CHECKS+=checkfits
423 else
424 READFILES+=no_fits.f90
425 endif
426
427 ifdef PBOB_DIR
428 READFILES+=$(READFILES_PBOB)
429 VPATH+=$(PBOB_DIR)
430 RUN_CHECKS+=checkpbob
431 endif
432
433 ifdef H5PART_DIR
434 READFILES+=$(READFILES_H5PART)
435 VPATH+=$(H5PART_LIBS) $(HDF5LIBS)
436 RUN_CHECKS+=checkh5part
437 endif
438
439
440 SOURCES= $(PLOTLIB) globaldata.f90 physcon.f90 utils_vectors.f90 \
441 asciiutils.f90 byteswap.f90 \
442 labels.f90 partutils.f90 transform.f90 setpage.f90 sort.f90 \
443 prompting.f90 promptlist.f90 map_columns.f90 geometry.f90 kernels.f90 \
444 plotutils.f90 blackbody.f90 colourbar.f90 \
445 colours.f90 colourparts.f90 timing.f90 pagecolours.f90 \
446 interpolation.f90 interpolate1D.f90 interpolate2D.f90 \
447 rotate.f90 interpolate3D_projection.f90 interpolate3D_geom.f90 interpolate3D_xsec.f90 \
448 interpolate3D_proj_geom.f90 \
449 interpolate3D_opacity.f90 interpolate_vec.f90 interpolate3D.f90 \
450 units.f90 limits.f90 geomutils.f90 dataread_utils.f90 \
451 write_data_gadget.f90 write_data_phantom.f90 write_pfm.f90 write_pixmap.f90 \
452 write_griddata.f90 write_sphdata.f90 read_composition.f90 \
453 $(SYSTEMFILE) system_utils.f90 \
454 cubicsolve.f90 discplot.f90 fparser.f90 parsetext.f90 \
455 exact_fromfile.f90 exact_Cshock.f90 exact_mhdshock.f90 \
456 exact_polytrope.f90 exact_rhoh.f90 exact_rochelobe.f90 \
457 exact_sedov.f90 exact_shock.f90 exact_shock_sr.f90 exact_wave.f90 \
458 exact_toystar1D.f90 exact_toystar2D.f90 exact_function.f90 exact_planetdisc.f90\
459 exact_densityprofiles.f90 exact_dustywaves.f90 exact_torus.f90 exact_bondi.f90 \
460 exact_ringspread.f90 exact_gresho.f90 exact.f90 shapes.f90 \
461 allocate.f90 titles.f90 calc_quantities.f90 contours.f90 \
462 legends.f90 options_render.f90 options_particleplots.f90 options_xsecrotate.f90 \
463 options_limits.f90 options_page.f90 imageutils.f90 \
464 lightcurve_utils.f90 $(READFILES) lightcurve.f90 extinction.f90 \
465 read_data.F90 get_h.f90\
466 adjust_data.f90 set_options_from_dataread.f90 get_data.f90 \
467 options_data.f90 options_powerspec.f90 \
468 options_vecplot.f90 pdfs.f90 \
469 particleplot.f90 interactive.f90 \
470 convert_grid.f90 \
471 analysis.f90 convert.f90 fieldlines.f90 \
472 powerspectrums.f90 render.f90 \
473 plotstep.f90 timestepping.f90 \
474 defaults.f90 initialise.f90 menu.f90 \
475 splash.f90
476
477
478 OBJECTS1= $(SOURCES:.f90=.o) $(STATICLIBS)
479 OBJECTS2= $(OBJECTS1:.F90=.o)
480 OBJECTS3= $(OBJECTS2:.c=.o)
481 OBJECTS= $(OBJECTS3:.cc=.o)
482
483
484 #
485 # Now compile with the appropriate data read file
486 # (move yours to the top so that you can simply type "make")
487 #
488
489 all: checksystem $(RUN_CHECKS) $(OBJECTS) read_data.o
490 $(FC) $(FFLAGS) -o $(BINDIR)/splash $(OBJECTS) $(LDFLAGS) $(PIELDFLAGS)
491 @echo; echo ' SPLASH v3 successfully compiled! ';
492 @echo; echo ' "sudo make install" to copy the binary to $(DESTDIR)$(PREFIX)/bin';
493 @echo; echo ' If you do not have admin privileges, add the following to your .bashrc or equialent:';
494 @echo; echo ' export SPLASH_DIR=$$HOME/splash';
495 @echo ' export PATH=$$PATH:$$SPLASH_DIR/bin';
496 @echo; echo ' For backwards compatibility with v2.x, add the following to your .bashrc or equivalent:';
497 @echo; echo " alias asplash='splash ' # alias for ascii splash";
498 @echo " alias ssplash='splash -f phantom'";
499 @echo " alias gsplash='splash -f gadget' ";
500 @echo " alias vsplash='splash -f vine' ";
501 @echo " alias nsplash='splash -f ndspmhd' ";
502 @echo " alias rsplash='splash -f srosph' ";
503 @echo " alias dsplash='splash -f dragon' ";
504 @echo " alias srsplash='splash -f seren' ";
505 @echo " alias tsplash='splash -f tipsy' ";
506 @echo " alias msplash='splash -f mhutch' "; echo;
507
508 #---falcON HDF5 read ---
509 falcon: falcON
510
511 falcON: falcON_hdf5
512
513 falcON_hdf5: checksystem checkhdf5 $(OBJECTS) read_data_falcON_hdf5_utils.o read_data_falcON_hdf5.o
514 $(FC) $(FFLAGS) -o $(BINDIR)/fsplash $(OBJECTS) read_data_falcON_hdf5_utils.o read_data_falcON_hdf5.o $(LDFLAGS) $(PIELDFLAGS) $(CXXLIBS) $(HDF5LIBS) -lhdf5_cpp
515
516 read_data_falcON_hdf5_utils.o: read_data_falcON_hdf5_utils.cc
517 $(CXX) $(CXXFLAGS) -std=c++11 $(HDF5INCLUDE) -c $< -o $@
518
519
520
521 #---SILO read ---
522 silo: checksystem checksilo $(OBJECTS) read_data_silo_utils.o read_data_silo.o
523 $(FC) $(FFLAGS) -o $(BINDIR)/silosplash $(OBJECTS) read_data_silo_utils.o read_data_silo.o $(LDFLAGS) $(PIELDFLAGS) $(HDF5LIBS) -lsiloh5
524
525 read_data_silo_utils.o: read_data_silo_utils.c
526 $(CC) $(CFLAGS) $(HDF5INCLUDE) -c $< -o $@
527
528 #
529 # sources for the grid2pdf command-line utility
530 #
531 SRCGRID2PDF= $(SYSTEMFILE) globaldata.f90 prompting.f90 transform.f90 \
532 asciiutils.f90 write_griddata.f90 pdfs.f90 grid2pdf.f90
533 OBJGRID2PDF= ${SRCGRID2PDF:.f90=.o}
534 grid2pdf: checksystem $(OBJGRID2PDF)
535 $(FC) $(FFLAGS) -o $(BINDIR)/$@ $(OBJGRID2PDF) $(PIELDFLAGS)
536
537 #
538 #
539 #
540 liball: lib libexact libread
541
542 #
543 # libsplash: library version of splash interpolation routines
544 #
545 SRCLIB= sort.f90 asciiutils.f90 kernels.f90 timing.f90 geometry.f90 \
546 interpolation.f90 interpolate1D.f90 interpolate2D.f90 interpolate3D.f90 \
547 interpolate3D_geom.f90 interpolate3D_projection.f90 \
548 interpolate3D_proj_geom.f90 interpolate3D_opacity.f90 interpolate3D_xsec.f90 \
549 libsplash.f90 libutils.f90
550 OBJLIB1=${SRCLIB:.f90=.o}
551 OBJLIB=${OBJLIB1} libread.o
552
553 .PHONY: libsplash
554 libsplash: lib
555
556 lib: $(OBJLIB)
557 $(FC) -shared -fPIC $(FFLAGS) $(FPPFLAGS) $(DBLFLAGS) $(OBJLIB) -o libsplash.so
558
559 #
560 # libexact: exact solution library
561 #
562 SRCLIBEXACT= $(PLOTLIB) libutils.f90 geometry.f90 exact_shock.f90 \
563 exact_shock_sr.f90 exact_sedov.f90 \
564 exact_polytrope.f90 exact_toystar1D.f90 exact_toystar2D.f90 exact_gresho.f90 \
565 exact_mhdshock.f90 exact_rhoh.f90 exact_densityprofiles.f90 exact_torus.f90 \
566 exact_ringspread.f90 cubicsolve.f90 exact_dustywaves.f90 exact_rochelobe.f90 \
567 exact_Cshock.f90 exact_planetdisc.f90 exact_bondi.f90 \
568 libexact.f90
569 OBJLIBEXACT=${SRCLIBEXACT:.f90=.o}
570 OBJLIBEXACTALL=${OBJLIBEXACT:.F90=.o}
571
572 .PHONY: libexact libexact2
573 libexact:
574 ${MAKE} libexact2 BACKEND=none
575
576 libexact2: checksystem $(OBJLIBEXACTALL)
577 $(FC) -shared -fPIC $(FFLAGS) $(FPPFLAGS) $(DBLFLAGS) $(OBJLIBEXACTALL) -o libexact.so
578
579 #
580 # libread: data read library
581 #
582 SRCLIBREAD= globaldata.f90 physcon.f90 asciiutils.f90 libutils.f90 labels.f90 allocate.f90 byteswap.f90 $(SYSTEMFILE)\
583 system_utils.f90 geometry.f90 prompting.f90 fparser.f90 units.f90 timing.f90\
584 sort.f90 geomutils.f90 partutils.f90 calc_quantities.f90 dataread_utils.f90 \
585 utils_vectors.f90 lightcurve_utils.f90 read_composition.f90 $(READFILES) read_data.F90 kernels.f90 get_h.f90\
586 adjust_data.f90 limits.f90 get_data.f90 initialise.f90 read.f90 libread.f90
587
588 OBJLIBREAD=${SRCLIBREAD:.f90=.o}
589 OBJLIBREAD1=${OBJLIBREAD:.F90=.o}
590 OBJLIBREADALL=${OBJLIBREAD1:.c=.o}
591
592 .PHONY: libread
593 libread: checksystem $(OBJLIBREADALL)
594 $(FC) -shared -fPIC $(FFLAGS) $(FPPFLAGS) $(DBLFLAGS) $(OBJLIBREADALL) -o libread.so $(LDFLAGSLIB)
595
596 #
597 # splash image manipulation utilities
598 #
599 SOURCESIMLIB= asciiutils.f90 $(SYSTEMFILE) system_utils.f90 timing.f90 kernels.f90 \
600 interpolation.f90 interpolate2D.f90 interpolate3D.f90 \
601 imageutils.f90 write_fits.f90 denoise.f90
602
603 OBJECTSIMLIB = $(SOURCESIMLIB:.f90=.o)
604
605 .PHONY: denoise
606 splash-image: denoise
607
608 splash-denoise: denoise
609
610 denoise: checksystem checkfits $(OBJECTSIMLIB)
611 $(FC) $(FFLAGS) -o $(BINDIR)/$@ $(OBJECTSIMLIB) $(FITSLIBS) $(PIELDFLAGS)
612 @echo; echo ' Denoise utility successfully compiled! ';
613 @echo; echo ' Use "make install" to copy the binaries to $(DESTDIR)$(PREFIX)/bin'; echo;
614
615 #
616 # splash moments
617 #
618 SOURCESM= asciiutils.f90 $(SYSTEMFILE) system_utils.f90 timing.f90 kernels.f90 \
619 interpolate1D.f90 write_fits.f90 moments.f90 sph_moments.f90
620
621 OBJECTSM = $(SOURCESM:.f90=.o)
622
623 .PHONY: sphmoments
624 sphmoments: checksystem checkfits $(OBJECTSM)
625 $(FC) $(FFLAGS) -o $(BINDIR)/$@ $(OBJECTSM) $(FITSLIBS) $(PIELDFLAGS)
626 @echo; echo ' sphmoments utility successfully compiled! ';
627 @echo; echo ' Use "make install" to copy the binaries to $(DESTDIR)$(PREFIX)/bin'; echo;
628
629
630 checksystem:
631 ifeq ($(KNOWN_SYSTEM), yes)
632 @echo ""
633 @echo "Compiling splash for $(SYSTEM) system..........."
634 @echo ""
635 ifeq ($(ENDIAN), BIG)
636 @echo "Flags set for conversion to BIG endian"
637 endif
638 ifeq ($(ENDIAN), LITTLE)
639 @echo "Flags set for conversion to LITTLE endian"
640 endif
641 ifeq ($(PARALLEL), yes)
642 @echo "Compiling the PARALLEL code"
643 else
644 ifeq ($(OPENMP), yes)
645 @echo "Compiling the PARALLEL code"
646 else
647 @echo "Compiling the SERIAL code"
648 endif
649 endif
650 ifeq ($(FC),gfortran)
651 ifeq ($(GFORTRAN_GE_4_4),true)
652 @echo "compiling with gfortran v$(GFORTRAN_VERSION) (OK)"
653 else
654 ${error gfortran v$(GFORTRAN_VERSION) is too old to compile this version of splash: please upgrade your gfortran}
655 endif
656 endif
657 else
658 @echo ""
659 @echo " Makefile for splash by Daniel Price "
660 @echo " -- see INSTALL file for detailed instructions"
661 @echo ""
662 @echo " make: ERROR: value of SYSTEM=$(SYSTEM) not recognised..."
663 @echo " => set the environment variable SYSTEM to one listed "
664 @echo " in build/Makefile and try again"
665 @echo ""
666 @${MAKE} compilers
667 @$(MAKE) err;
668 endif
669
670 compilers:
671 @echo "I suggest one of the following, based on detected Fortran compilers..."; echo;
672 @if type -p ifx > /dev/null; then echo "make SYSTEM=ifx"; fi;
673 @if type -p ifort > /dev/null; then echo "make SYSTEM=ifort"; fi;
674 @if type -p pathf90 > /dev/null; then echo "make SYSTEM=pathf90"; fi;
675 @if type -p pgf90 > /dev/null; then echo "make SYSTEM=pgf90"; fi;
676 @if type -p xlf90_r > /dev/null; then echo "make SYSTEM=ukaff1a [uses xlf90_r]"; fi;
677 @if type -p gfortran > /dev/null; then echo "make SYSTEM=gfortran"; fi;
678 @if type -p g95 > /dev/null; then echo "make SYSTEM=g95"; fi;
679 @echo "(end of possible selections)"; echo;
680
681 checkpgplot:
682 ifneq ($(BACKEND),pgplot)
683 @# Not using PGPLOT, skip check
684 else ifeq (X${PGPLOT_DIR}, X)
685 @echo; echo "ERROR: PGPLOT_DIR should be set before compiling splash"; echo; ${MAKE} err;
686 else
687 @if [ -d $$PGPLOT_DIR ]; then echo; echo "PGPLOT_DIR=$$PGPLOT_DIR"; echo; else echo; echo "ERROR: Directory given by PGPLOT_DIR=$$PGPLOT_DIR does not exist"; echo; ${MAKE} err; fi;
688 endif
689 ifneq ($(PGPLOT_COMP),$(FC))
690 @echo; echo "*** WARNING: PGPLOT appears to have been compiled with a different Fortran"; echo " compiler (${PGPLOT_COMP}) to the one you are using to compile SPLASH (${FC}),"; echo " so may need to link to the relevant compiler libraries ***";
691 # g77-compiled PGPLOT
692 @if [ "${PGPLOT_COMP}" = "g77" ]; then echo " [Adding -lg2c to the link flags for g77-compiled PGPLOT]"; fi;
693 # gfortran-compiled PGPLOT
694 @if [ "${PGPLOT_COMP}" = "gfortran" ]; then echo " [Adding -lgfortran to the link flags for gfortran-compiled PGPLOT]"; fi;
695 # g95-compiled PGPLOT
696 @if [ "${PGPLOT_COMP}" = "g95" ]; then echo " [Adding -lg95 to the link flags for g95-compiled PGPLOT]"; fi;
697 @echo
698 # else
699 # @echo "PGPLOT was compiled with ${PGPLOT_COMP}";
700 endif
701
702 checkgiza:
703 @if [ ! -e $(GIZA_DIR)/include/giza-fortran.F90 ]; then \
704 if [ -d ../giza/ ]; then \
705 echo "*********************************************************"; \
706 echo "* *"; \
707 echo "* ERROR: Cannot find system install of giza *"; \
708 echo "* Type \"make withgiza\" to build local copy of giza *"; \
709 echo "* *"; \
710 echo "*********************************************************"; \
711 else \
712 echo "*********************************************************"; \
713 echo "* *"; \
714 echo "* ERROR: giza is not installed. Please install it. *"; \
715 echo "* *"; \
716 echo "* e.g: *"; \
717 echo "* git clone https://github.com/danieljprice/giza.git *"; \
718 echo "* make withgiza *"; \
719 echo "* *"; \
720 echo "*********************************************************"; \
721 fi; \
722 fi;
723
724 checkh5part: checkhdf5
725 ifeq (X${H5PART_DIR}, X)
726 @echo; echo "ERROR: H5PART_DIR should be set before compiling splash with h5part read/write"; echo; ${MAKE} err;
727 else
728 @if [ -d $$H5PART_DIR ]; then echo; echo "H5PART_DIR=$$H5PART_DIR"; echo; else echo; echo "ERROR: Directory given by H5PART_DIR=$$H5PART_DIR does not exist"; echo; ${MAKE} err; fi;
729 endif
730
731 checkhdf5:
732 ifeq (X${HDF5ROOT}, X)
733 @echo; echo "ERROR: HDF5ROOT should be set before compiling splash with HDF5 utilities"; echo; ${MAKE} err;
734 else
735 @if [ -d $$HDF5ROOT ]; then echo; echo "HDF5ROOT=$$HDF5ROOT"; echo; else echo; echo "ERROR: Directory given by HDF5ROOT=$$HDF5ROOT does not exist"; echo; ${MAKE} err; fi;
736 endif
737
738 checksilo: checkhdf5
739 ifeq (X${SILO_DIR}, X)
740 @echo; echo "ERROR: SILO_DIR should be set before compiling splash with SILO reader"; echo; ${MAKE} err;
741 else
742 @if [ -d $$SILO_DIR ]; then echo; echo "SILO_DIR=$$SILO_DIR"; echo; else echo; echo "ERROR: Directory given by SILO_DIR=$$SILO_DIR does not exist"; echo; ${MAKE} err; fi;
743 endif
744
745 checkfits:
746 ifeq (X${FITS_DIR}, X)
747 @echo; echo "*** WARNING: May need FITS_DIR=/usr/local to find cfitsio library **"; echo;
748 else
749 @if [ -d $$FITS_DIR ]; then echo; echo "FITS_DIR=$$FITS_DIR"; echo; else echo; echo "ERROR: Directory given by FITS_DIR=$$FITS_DIR does not exist"; echo; ${MAKE} err; fi;
750 endif
751
752 checkpbob:
753 ifeq (X${PBOB_DIR}, X)
754 @echo; echo "ERROR: PBOB_DIR should be set before compiling splash with PBOB reader"; echo; ${MAKE} err;
755 else
756 @if [ -d $$PBOB_DIR ]; then echo; echo "PBOB_DIR=$$PBOB_DIR"; echo; else echo; echo "ERROR: Directory given by PBOB_DIR=$$PBOB_DIR does not exist"; echo; ${MAKE} err; fi;
757 endif
758
759 #
760 # install option, copies any binaries compiled to /usr/local/bin/
761 # run `make' first, then `make install'. Could in principle
762 # have install compile it as well, but environment variables
763 # will not be defined if "make" is run using sudo, so better
764 # to do the two separately
765 #
766 install: destdircheck installcheck
767 @cd $(BINDIR); for x in *splash*; do if [ -e $$x ]; then echo "copying $$x -> $(DESTDIR)$(PREFIX)/bin/$$x"; cp $$x $(DESTDIR)$(PREFIX)/bin/; fi; done;
768 @cd $(BINDIR); x=denoise; if test -e $$x; then echo "copying $$x -> $(DESTDIR)$(PREFIX)/bin/$$x"; cp $$x $(DESTDIR)$(PREFIX)/bin/; fi;
769 @cd $(BINDIR); x=sphmoments; if test -e $$x; then echo "copying $$x -> $(DESTDIR)$(PREFIX)/bin/$$x"; cp $$x $(DESTDIR)$(PREFIX)/bin/; fi;
770 @echo; echo 'installation complete';
771
772 installcheck:
773 @if [ -e $(BINDIR)/splash ] || [ -e $(BINDIR)/denoise ] || [ -e $(BINDIR)/sphmoments ]; then echo; \
774 echo 'compiled binaries install to $(DESTDIR)$(PREFIX)/bin'; \
775 echo '(use "sudo make install" if Permission denied)'; \
776 echo; else echo;\
777 echo 'run "make" first, followed by "make install"'; echo;\
778 $(MAKE) err; fi
779
780 destdircheck: installcheck
781 @if test -d $(DESTDIR)$(PREFIX)/bin; then echo $(DESTDIR)$(PREFIX)/bin exists and is a directory; else \
782 echo; echo "*** ERROR in make install ***"; echo "$(DESTDIR)$(PREFIX)/bin is not a valid directory"; echo;\
783 $(MAKE) err; fi;
784
785 installclean: destdircheck
786 @for x in $(DESTDIR)$(PREFIX)/bin/?splash; do rm $$x; done;
787
788 distclean: installclean
789
790 cleanall: clean installclean
791
792 err:
793 $(error aborting);
794
795 ## other stuff
796
797 ifeq ($(BACKEND),pgplot)
798 plotlib_pgplot.o: checkpgplot
799 endif
800
801 plotlib_giza.o : giza-fortran.o
802
803 giza-fortran.o : giza-fortran.F90
804 $(FC) $(FFLAGS) -I$(GIZA_DIR)/include/ -c $(GIZA_DIR)/include/giza-fortran.F90 -o $@
805
806 .PHONY: giza gizabuild libgiza
807
808 giza-fortran.F90 : checkgiza
809 #
810 # LOCAL build of giza
811 #
812 withgiza: ../giza/lib/libgiza.a
813 $(MAKE) $(MAKECMDFLAGS) GIZA_DIR="../giza"
814
815 ../giza/lib/libgiza.a:
816 @echo "Compiling local copy of giza..."
817 cd ../giza; ./configure --prefix="$(PWD)/../giza" CC="$(CC)" CFLAGS="$(CFLAGS)" LDFLAGS="" CAIRO_LIBS="$(CAIRO_LIBS)" CAIRO_CFLAGS="$(CAIRO_CFLAGS)" X11_LIBS="$(X11_LIBS)" X11_CFLAGS="$(X11_CFLAGS)"
818 cd ../giza; $(MAKE) $(MAKECMDFLAGS) install CC="$(CC)" CFLAGS="$(CFLAGS)"
819
820 docs: doc
821
822 doc:
823 cd ../docs; make html latexpdf
824
825 htmldocs: htmldoc
826
827 htmldoc: doc cleanhtmldocs
828 cd ../docs; \
829 make html
830
831 cleanhtmldocs:
832 cd ../docs; make clean
833
834 tar:
835 tar cf splash.tar Makefile $(SOURCES) read_data*.f90
836
837 targz:
838 tar cf splash.tar Makefile $(SOURCES) read_data*.f90
839 gzip splash.tar
840
841 ## unit tests of various modules as I write them
842 .PHONY: tests
843
844 test: test1 test2 test3 test_slicer test_prompt test-parse
845
846 test1: interpolate3D_projection.o interpolate3D_xsec.o test_interpolate3D.o
847 $(FC) $(FFLAGS) $(LDFLAGS) $(PIELDFLAGS) -o $(BINDIR)/test_interpolation3D $(TESTDIR)/test_interpolate3D.o interpolate3D_projection.o interpolate3D_xsec.o
848 test2: transform.o $(TESTDIR)//test_transform.o
849 $(FC) $(FFLAGS) $(LDFLAGS) $(PIELDFLAGS) -o $(BINDIR)/test_transform $(TESTDIR)/test_transform.o transform.o
850 test3: fieldlines.o $(TESTDIR)//test_fieldlines.o
851 $(FC) $(FFLAGS) $(LDFLAGS) $(PIELDFLAGS) -o $(BINDIR)/test_fieldlines $(TESTDIR)/test_fieldlines.o fieldlines.o
852 test_slicer: interpolate3D_projection.o interpolate3D_xsec.o test_slicer3D.o
853 $(FC) $(FFLAGS) $(LDFLAGS) $(PIELDFLAGS) -o $(BINDIR)/test_slicer3D $(TESTDIR)/test_slicer3D.o interpolate3D_projection.o interpolate3D_xsec.o
854 test_prompt: prompting.o test_prompting.o
855 $(FC) $(FFLAGS) $(LDFLAGS) $(PIELDFLAGS) -o $(BINDIR)/test_prompt prompting.o test_prompting.o
856 test-parse: $(PLOTLIB) asciiutils.o fparser.o parsetext.o $(TESTDIR)/test-parsetext.o
857 $(FC) $(FFLAGS) $(PIELDFLAGS) -o $(BINDIR)/test-parse giza-fortran.o plotlib_giza.o fparser.o asciiutils.o parsetext.o $(TESTDIR)/test-parsetext.o $(LDFLAGS)
858
859
860 depends: clean
861 @echo '*********************************************************************************'
862 @echo 'Generating dependency lines using makedepf90, writing to .depends'
863 @echo '*********************************************************************************'
864 @echo " Using git to get list of tracked source files..."; \
865 SOURCE_FILES=$$(cd .. && git ls-files 'src/*.f90' 'src/*.F90' | sed 's|^src/||' | \
866 grep -v '^plotlib_pgplot\.f90$$' | grep -v '^plotlib_mock\.f90$$'); \
867 if [ "$(BACKEND)" = "pgplot" ]; then \
868 SOURCE_FILES=$$(echo $$SOURCE_FILES | sed 's|plotlib_giza\.f90||g'); \
869 fi; \
870 if ! command -v makedepf90 > /dev/null 2>&1; then \
871 echo " Error: makedepf90 not found in PATH"; \
872 echo " Please install it:"; \
873 echo " - Debian/Ubuntu: sudo apt-get install makedepf90"; \
874 echo " - Or download from: https://github.com/outpaddling/makedepf90"; \
875 exit 1; \
876 fi; \
877 echo " Generating dependencies with makedepf90 (from src directory)..."; \
878 cd ../src && makedepf90 -free $$SOURCE_FILES | sed 's/plotlib_[a-z_]*\.o/\$${PLOTLIB:.f90=.o}/g' > ../build/.depends || \
879 (echo " Error: makedepf90 failed to generate .depends file"; exit 1); \
880 if [ ! -s ../build/.depends ]; then \
881 echo " Error: .depends file is empty"; exit 1; \
882 fi; \
883 echo " Successfully created .depends with $$(grep -c '\.o ' ../build/.depends 2>/dev/null || echo 0) dependency entries"
884 @echo '*************************************************************************'
885 @echo 'Dependency file .depends created successfully'
886 @echo ' -- run "make depends" again if you alter code dependencies'
887 @echo '*************************************************************************'
888 @echo 'Removing object files...'
889 @rm -f $(SRCDIR)/*.o $(SRCDIR)/H5Part/*.o
890 #
891 #--code dependencies: MAY BE INCOMPLETE - I generate this automatically every so often
892 #
893 include .depends
894
895 cleanread:
896 rm -f read_data*.o splash.o $(BINDIR)/?splash $(BINDIR)/splash* libsplash.so libexact.so
897
898 clean:
899 rm -f *.o *.mod $(BINDIR)/?splash $(BINDIR)/splash* libsplash.so libexact.so $(BINDIR)/denoise
900 rm -f $(SRCDIR)/*.o $(SRCDIR)/H5Part/*.o
901
902 cleangiza:
903 ${MAKE} -C ../giza clean uninstall