Building the Focal Library
Prerequisites
- GNU make utility
- Fortran compiler supporting the 2008 standard (tested regularly with
gfortran
7.4.0 & 9.1.0 andifort
19.1.0 ) - An OpenCL development library (One of: Intel OpenCL SDK, NVIDIA CUDA Toolkit, AMD Radeon Software )
Build
Navigate to the repository root and run make:
$> make -j
Parallel build is fully supported by the makefile, so use of the -j
flag is recommended.
To build the example programs:
$> make examples
which will place example binaries in path/to/focal/bin/
.
To build and run the tests:
$> make -j test
Build within your own project
A non-recursive sub-makefile is included in the Focal repository root directory for inclusion within project makefiles. To use in your own makefile:
- Define the make variable
FOCAL_DIR
as the path to the Focal root directory - Include the sub-makefile into your project makefile (after the
all
recipe) - Create a dependency of your objects on
$(FOCAL_LIB_OBJS)
- Add
-I$(FOCAL_DIR)/mod/
to your Fortran compile flags - Add
-L$(FOCAL_DIR)/lib/ -lFocal -lOpenCL
to your linker flags
See linking for how to link against the Focal library. See this lattice Boltzmann code as an example.
Example:
FC ?= gfortran
FOCAL_DIR=./focal
PROGS= myProgram
OBJS= $(addsuffix .o, $(PROGS))
FFLAGS+= -I$(FOCAL_DIR)/mod/
LFLAGS+= -L$(FOCAL_DIR)/lib/ -lFocal -lOpenCL
all: $(PROGS)
include $(FOCAL_DIR)/make.include
# Objects depend on focal library
$(OBJS): $(FOCAL_LIB_OBJS)
# Recipe to link executable(s)
$(PROGS): $(OBJS)
$(FC) $^ $(LFLAGS) -o $@
# Recipe to compile objects
%.o: %.f90
$(FC) $(FFLAGS) -c $< -o $@