Skip to content

Commit

Permalink
Adding do-nothing tests/fortran directory.
Browse files Browse the repository at this point in the history
The `Makefile` depends on `test.f90` as the main program
that runs tests.
  • Loading branch information
dhermes committed Sep 21, 2017
1 parent da987bd commit 758bdd1
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 0 deletions.
49 changes: 49 additions & 0 deletions tests/fortran/Makefile
@@ -0,0 +1,49 @@
CURR_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
SRC_DIR := $(realpath $(CURR_DIR)/../../src/bezier)
QUADPACK_DIR := $(realpath $(SRC_DIR)/quadpack)

FC = gfortran
F77 = .f
F90 = .f90
OBJ = .o
FCFLAGS = -fPIC -O3

# NOTE: **Must** specify the order for source files.
F77_SOURCES := \
$(QUADPACK_DIR)/d1mach$(F77) \
$(QUADPACK_DIR)/dqelg$(F77) \
$(QUADPACK_DIR)/dqpsrt$(F77) \
$(QUADPACK_DIR)/dqk21$(F77) \
$(QUADPACK_DIR)/dqagse$(F77)
F90_SOURCES := \
$(SRC_DIR)/types$(F90) \
$(SRC_DIR)/helpers$(F90) \
$(SRC_DIR)/curve$(F90) \
$(SRC_DIR)/surface$(F90) \
$(SRC_DIR)/curve_intersection$(F90)
F77_OBJS := $(patsubst $(QUADPACK_DIR)/%$(F77), $(QUADPACK_DIR)/%$(OBJ), $(F77_SOURCES))
F90_OBJS := $(patsubst $(SRC_DIR)/%$(F90), $(SRC_DIR)/%$(OBJ), $(F90_SOURCES))

test: $(CURR_DIR)/test-bin
$(CURR_DIR)/test-bin

$(SRC_DIR)/%$(OBJ): $(SRC_DIR)/%$(F90)
$(FC) $(FCFLAGS) -c $< -o $@

$(QUADPACK_DIR)/%$(OBJ): $(QUADPACK_DIR)/%$(F77)
$(FC) $(FCFLAGS) -c $< -o $@

$(CURR_DIR)/test-bin: $(F77_OBJS) $(F90_OBJS) $(CURR_DIR)/test.f90
$(FC) $(FCFLAGS) \
-o $(CURR_DIR)/test-bin \
$(F77_OBJS) \
$(F90_OBJS) \
$(CURR_DIR)/test.f90

clean:
rm -f $(CURR_DIR)/*.mod
rm -f $(SRC_DIR)/*$(OBJ)
rm -f $(QUADPACK_DIR)/*$(OBJ)
rm -f $(CURR_DIR)/test-bin

.PHONY: all test clean
7 changes: 7 additions & 0 deletions tests/fortran/README.md
@@ -0,0 +1,7 @@
# Unit Tests for Fortran Surface of `libbezier`

This is so that the Fortran source can evolve without
having to have an equivalent Python function for every
piece of code.

To run the tests, simply run `make test` from this directory.
8 changes: 8 additions & 0 deletions tests/fortran/test.f90
@@ -0,0 +1,8 @@
program test

use types, only: dp
implicit none

print *, dp

end program test

0 comments on commit 758bdd1

Please sign in to comment.