Skip to content

Commit

Permalink
Cython interface the NCEPLIBS-ip subroutines (#170)
Browse files Browse the repository at this point in the history
* Updating tests and test data.

[skip-ci]

* Update setup.py to build for interpolation

Update setup.py to build cython-based iplib extension module for
interfacing to NCEPLIBS-ip.

* Adding iplib.h and iplib.pyx

iplib.h - C header that defines ipolates_grib2 and ipolatev_grib2
functions that map to the Fortran subroutines.

iplib.pyx - Cython source file that contains the wrapper functions
to the C-based functions.

* Update g2clib.pyx and redtoreg.pyx

Adding Cython build directives and parameters.

* Removing grib2io_interp refrences in tests.

* Update for _grib2io.py

This commit changes code syntax for interpolation from grib2io_interp's
interface to the now built-in Cython-based interpolation interface
to the NCEPLIBS-ip library.

IMPORTANT:  At this time, the logic for handling OpenMP thread count
is commented out. That functionality needs to be built into iplib.pyx.

* Adding NCEPLIBS-ip to build/test workflows.

* Update github workflows to make sure numpy<2

* Adding openmp_handler Cython ext module

This commit adds an openmp_handler Cython extension module. This
allows for the control of getting and setting the number of
OpenMP threads for interpolation.

Some minor updates to documentation.

* Update iplib

Changed syntax for points from "type* name" to "type *name".

* Update src/grib2io/templates.py.

* Update for setup.py

This commit fixes some minor issues with obtaining the OpenMP
static library.  Also added more build information to the
__config__.py that is generated.

* Update github workflows.

* No tabs in workflow yaml!

* Test static and shared lib builds on macOS.

* Try again...

* Update build_macos.yml

* Update build_macos.yml

* Update build_macos.yml

* Another try for build_macos.yml.

* Looks good!

* Update build_macos.yml

* Update docs.

[skip-ci]

* Test self-hosted runner.  This will fail, but testing workflow.

* Removing self-hosted workflow.

---------

Co-authored-by: Eric Engle <EricEngle-NOAA@users.noreply.github.com>
  • Loading branch information
EricEngle-NOAA and EricEngle-NOAA authored Feb 15, 2025
1 parent 1a0bdc7 commit d88e9e2
Show file tree
Hide file tree
Showing 70 changed files with 10,029 additions and 8,192 deletions.
13 changes: 12 additions & 1 deletion .github/workflows/build_linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- name: Install Ubuntu Dependencies
run: |
sudo apt-get update
sudo apt-get install cmake gfortran libopenjp2-7 libopenjp2-7-dev libpng16-16 libpng-dev libaec0 libaec-dev
sudo apt-get install cmake gfortran libopenjp2-7 libopenjp2-7-dev libpng16-16 libpng-dev libaec0 libaec-dev libopenblas-serial-dev
- name: Install python dependencies via pip
run: |
Expand All @@ -40,9 +40,20 @@ jobs:
cmake -DUSE_Jasper=OFF -DUSE_OpenJPEG=ON -DBUILD_PNG=ON -DBUILD_AEC=ON -DBUILD_SHARED_LIBS=ON ..
make -j2
sudo make install
- name: Install NCEPLIBS-ip
run: |
wget https://github.com/NOAA-EMC/NCEPLIBS-ip/archive/refs/tags/v5.1.0.tar.gz
tar -xzvf v5.1.0.tar.gz
cd NCEPLIBS-ip-5.1.0
mkdir build && cd build
cmake -DOPENMP=ON -DBUILD_SHARED_LIBS=ON -DBLA_VENDOR=OpenBLAS ..
make -j2
sudo make install
- name: Install grib2io and test
run: |
python --version
pip install .
python -c "import grib2io; grib2io.show_config()"
pytest ./tests/
12 changes: 7 additions & 5 deletions .github/workflows/build_macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,17 @@ on: [push, pull_request]

jobs:
build-macos:
name: Python (${{ matrix.python-version }})

name: Python (${{ matrix.python-version }}); USE_STATIC_LIBS=${{ matrix.staticlib }}
runs-on: ${{ matrix.os }}
env:
CC: gcc-12
strategy:
matrix:
os: ["macos-latest",]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]

staticlib: [ "True", "False" ]

steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
Expand All @@ -25,7 +26,7 @@ jobs:
run: |
brew install jasper libpng libaec
brew tap eengl/nceplibs
brew install nceplibs-g2c
brew install nceplibs-g2c nceplibs-ip
- name: Install python dependencies via pip
run: |
Expand All @@ -37,5 +38,6 @@ jobs:
- name: Install grib2io and test
run: |
python --version
pip install .
USE_STATIC_LIBS=${{ matrix.staticlib }} pip install .
python -c "import grib2io; grib2io.show_config()"
pytest ./tests/
3 changes: 2 additions & 1 deletion create_docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
#
# pip install pdoc
# ----------------------------------------------------------------------------------------
pdoc --docformat numpy -o 'docs' ./src/grib2io
BUILD_LIB=$(find . -name "lib*" -type d)
pdoc --docformat numpy -o 'docs' $BUILD_LIB/grib2io
5,313 changes: 2,658 additions & 2,655 deletions docs/grib2io.html

Large diffs are not rendered by default.

833 changes: 833 additions & 0 deletions docs/grib2io/g2clib.html

Large diffs are not rendered by default.

357 changes: 357 additions & 0 deletions docs/grib2io/iplib.html

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions docs/grib2io/tables.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/grib2io/tables/originating_centers.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/grib2io/tables/section0.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/grib2io/tables/section1.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/grib2io/tables/section3.html

Large diffs are not rendered by default.

40 changes: 20 additions & 20 deletions docs/grib2io/tables/section4.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/grib2io/tables/section4_discipline0.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/grib2io/tables/section4_discipline1.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/grib2io/tables/section4_discipline10.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/grib2io/tables/section4_discipline2.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/grib2io/tables/section4_discipline20.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/grib2io/tables/section4_discipline209.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/grib2io/tables/section4_discipline3.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/grib2io/tables/section4_discipline4.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/grib2io/tables/section5.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/grib2io/tables/section6.html

Large diffs are not rendered by default.

10,568 changes: 5,289 additions & 5,279 deletions docs/grib2io/templates.html

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions docs/grib2io/utils.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/grib2io/utils/arakawa_rotated_grid.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/grib2io/utils/gauss_grid.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/grib2io/utils/rotated_grid.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/search.js

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ dependencies = [
dynamic = ["version"]

[project.optional-dependencies]
interp = ["grib2io-interp >= 1.0.0"]
xarray = ["xarray"]

[project.entry-points."xarray.backends"]
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cython
dask
numpy
numpy<2
pyproj
pytest
xarray
11 changes: 10 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,23 @@
# g2c_dir = /usr/local
# g2c_incdir =
# g2c_libdir =
#
# ----------------------------------------------------------------------------------------
# Define paths for NCEPLIBS-ip Library
#
# Please set ip_dir is include and library files are within the same location.
# If not, please set ip_incdir and ip_libdir.
# ----------------------------------------------------------------------------------------
# ip_dir =
# ip_incdir =
# ip_libdir =

[static_libs]
# ----------------------------------------------------------------------------------------
# Set the following variables if static linking to g2c.
#
# IMPORTANT: You do not need to specify the static library path for g2c here.
# ----------------------------------------------------------------------------------------
#g2c_lib =
#aec_lib =
#jasper_lib =
#jpeg_lib =
Expand Down
Loading

0 comments on commit d88e9e2

Please sign in to comment.