Skip to content

Commit

Permalink
Rewrote czspline to use iso_c_binding.
Browse files Browse the repository at this point in the history
  • Loading branch information
jsachdev committed Oct 31, 2019
1 parent 53c00be commit 814d6cb
Show file tree
Hide file tree
Showing 11 changed files with 1,242 additions and 1,077 deletions.
13 changes: 6 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ SRCS := $(filter-out $(PSPDIR)/$(EXEQKS).f90, $(SRCS))
SRCS += $(EZSDIR)/ezspline_mod.f90 \
$(filter-out $(EZSDIR)/ezspline_mod.f90, $(wildcard $(EZSDIR)/*.f90))
SRCS := $(filter-out $(EZSDIR)/ezspline_test.f90, $(SRCS))
SRCS += $(CZSDIR)/czspline_pointer_types.f90 \
$(filter-out $(CZSDIR)/czspline_pointer_types.f90, $(wildcard $(CZSDIR)/*.f90))
SRCS += $(wildcard $(CZSDIR)/*.f90)
OBJS := $(SRCS:.f90=.o)


Expand All @@ -45,19 +44,19 @@ $(LIBAR): $(OBJS)
@ar r $@ $(OBJS)

$(EXELUP):
$(FC) $(LDFLAGS) $(PSPDIR)/$@.f90 -o $@ -L$(SRCDIR) -lpspline $(FLIBS)
$(FC) $(FFLAGS) $(PSPDIR)/$@.f90 -o $@ -L$(SRCDIR) -lpspline $(FLIBS)

$(EXEPSP):
$(FC) $(LDFLAGS) $(PSPDIR)/$@.f90 -o $@ -L$(SRCDIR) -lpspline $(FLIBS)
$(FC) $(FFLAGS) $(PSPDIR)/$@.f90 -o $@ -L$(SRCDIR) -lpspline $(FLIBS)

$(EXEQKS):
$(FC) $(LDFLAGS) $(EZSDIR)/$@.f90 -o $@ -L$(SRCDIR) -lpspline $(FLIBS)
$(FC) $(FFLAGS) $(EZSDIR)/$@.f90 -o $@ -L$(SRCDIR) -lpspline $(FLIBS)

$(EXEEZS):
$(FC) $(LDFLAGS) $(EZSDIR)/$@.f90 -o $@ -L$(SRCDIR) -lpspline $(FLIBS)
$(FC) $(FFLAGS) $(EZSDIR)/$@.f90 -o $@ -L$(SRCDIR) -lpspline $(FLIBS)

$(EXECZS):
$(CXX) $(CXXLDFLAGS) $(CZSDIR)/$@.cc -o $@ -L$(SRCDIR) $(CXXLIBS) -lpspline $(FLIBS)
$(CXX) $(CXXFLAGS) $(CZSDIR)/$@.cc -o $@ -L$(SRCDIR) $(CXXLIBS) -lpspline $(FLIBS)

install:
@test -d $(LIBDIR) || mkdir -p $(LIBDIR)
Expand Down
12 changes: 6 additions & 6 deletions Makefile.def
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
ifeq ($(COMPILER),ICC)
FFLAGS = -cpp -O2 -stand f08 -real-size 64 -auto-scalar $(EZCDF_FLAGS)
LDFLAGS = -cpp
DFFLAGS = -g -Wall -traceback
DFFLAGS = -g -traceback -check all -warn all
SFFLAGS = -fpic
SLDFLAGS = -shared
CXXFLAGS = -O2 -std=c++11
CXXFLAGS = -O2 -std=c++11 $(EZCDF_FLAGS)
CXXLIBS = -lifcore
CXXLDFLAGS =

else ifeq ($(COMPILER),PGC)
FFLAGS = -cpp -fast -r8 $(EZCDF_FLAGS)
LDFLAGS = -cpp -D_PGC
FFLAGS = -cpp -fast -r8 $(EZCDF_FLAGS) -D_PGC
LDFLAGS = -cpp
DFFLAGS = -g -traceback -Mbounds
SFFLAGS = -fpic
SLDFLAGS = -shared
CXXFLAGS = -O2 -mp -std=c++11
CXXFLAGS = -O2 -mp -std=c++11 $(EZCDF_FLAGS)
CXXLIBS = -lstdc++ -lgfortran
CXXLDFLAGS =

Expand All @@ -25,7 +25,7 @@ else
DFFLAGS = -Og -Wall
SFFLAGS = -fpic
SLDFLAGS = -shared
CXXFLAGS = -O2 -std=c++11
CXXFLAGS = -O2 -std=c++11 $(EZCDF_FLAGS)
CXXLIBS = -lstdc++ -lgfortran
CXXLDFLAGS =
endif
Expand Down
28 changes: 21 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,35 +1,42 @@
# pspline
PSPLINE -- a collection of Spline and Hermite interpolation tools for 1D, 2D, and 3D datasets on rectilinear grids developed as part of the TRANSP code.

![GitHub release (latest by date including pre-releases)](https://img.shields.io/github/v/release/transp/pspline?include_prereleases)

## About

PSPLINE is a collection of Spline and Hermite interpolation tools for 1D, 2D, and 3D datasets on rectilinear grids developed as part of the TRANSP code.

The spline routines give full control over boundary conditions -- the user may specify "periodic", "not a knot", 1st derivative match, 2nd derivative match, or divided difference based boundary conditions on either end of each grid dimension. Hermite routines take as input the function value and derivatives at each grid point, giving back a representation of the function between grid points. Routines are provided for creating Hermite datasets, with appropriate boundary conditions applied. The 1D spline and Hermite routines are based on standard methods; the 2D and 3D spline or Hermite interpolation functions are constructed from 1D spline or Hermite interpolation functions in a straightforward manner. The splines are continuously twice differentiable in all directions across all grid cell boundaries and over the entire grid domain; Hermite functions are continuously once differentiable in all directions over the entire grid domain. For a representation of dimensionality N, an N-dimensional spline or Hermite function requires 2\*\*N\*(nx1\*nx2\*...\*nxN) memory words. There is also an "explicit spline" representation requiring 4\*\*N\*(nx1\*nx2\*...\*nxN) memory words: much more memory but somewhat faster computationally. Spline and Hermite interpolation functions are often much faster to evaluate than other representations using e.g. Fourier series or otherwise involving transcendental functions.

This version of PSPLINE includes EZspline, a Fortran-90 interface to the spline and Hermite routines. Currently working on C-bindings for EZspline which will replace CZspline (a c-callable interface to the EZspline routines).
This version of PSPLINE includes EZspline, a Fortran-90 interface to the spline and Hermite routines. CZSPLINE, a c-callable interface to the EZspline routines, was rewritten in 10/2019 to use the Fortran instrinic iso_c_binding.


CONTACT: [email protected]
## Contact

[email protected]


1. CONTENTS:
## Contents

Makefile: GNU make should be used
Makefile.def Definitions for the Makefile

Source directories for:
pspline The original pspline F77 routines, reformatted into Fortran 90
ezspline A Fortran-90 interface to the spline and Hermite routines
czspline A C/C++ callable interface to ezpsline, using Fortran intrinsic iso_c_bindings

Test programs are included in the source directories.


2. CONFIGURATION
## Configuration

See the sample configuration used at PPPL: pppl-bashrc

If you want to use the NETCDF I/O capability with EZspline then you must have the EZCDF library installed. It is also on github: https://github.com/transp/ezcdf. See the PPPL configuration file for how to include EZCDF with PSPLINE.


3. BUILDING INSTRUCTIONS:
## Build

make -- will build libpspline.a and the test programs
make debug -- will build a debug version of libpspline.a
Expand All @@ -40,7 +47,7 @@ make clobber -- will run clean and remove the libs and test programs
The Makefile.def is set-up for compiling with the GNU, Intel, and Portland group compilers.


4. INSTALLATION:
## Install

Installation will be put in a location specified by the PREFIX environment variable. The directory './build/' will be used if not specified. Installation done with:

Expand All @@ -51,3 +58,10 @@ You can specify the PREFIX with the make command:

make PREFIX=/path/to/location install
make PREFIX=/path/to/location uninstall


## Support

This project was supported by TRANSP development at the Princeton Plasma Physics Laboratory via `U.S. Department of Energy (DE-AC02-09CH11466)`.


Loading

0 comments on commit 814d6cb

Please sign in to comment.