Skip to content

Latest commit

 

History

History
29 lines (24 loc) · 1.4 KB

README.md

File metadata and controls

29 lines (24 loc) · 1.4 KB

Description

Fortran code to interpolate from regular to unstructured grid (e.g., triangle mesh) and vice versa. The former interpolation is performed with bilinear interpolation, the latter with inverse distance weighting (IDW) and the application of a k-d tree to efficiently find the nearest neighbours. For an equally spaced regular grid (esrg) – i.e., a grid with an equal spacing in the x- and y-direction – an even faster algorithm for IDW interpolation is implemented.

Usage

Create conda environment

conda create -n grid_interpolation numpy scipy matplotlib ipython gfortran meson openmp -c conda-forge

Compile Fortran code and build shared library for F2PY (tested on MacOS)

gfortran -shared -O3 -o libkd_tree.so -fPIC kd_tree.f90
gfortran -shared -O3 -o libquery_esrg.so -fPIC query_esrg.f90
cwd=$(pwd)
f2py -c --f90flags='-fopenmp' -lgomp --fcompiler=gfortran -L${cwd}/ -I${cwd}/ -lkd_tree -lquery_esrg -m interpolation interpolation.f90

Clean build

rm *.so *.mod

To do