{"id":27029,"library":"gridtools-cpp","title":"GridTools C++","description":"A Python wrapper for the GridTools C++ library, providing high-performance stencil computations on structured grids for weather and climate applications. Current version 2.3.9, released under a BSD license. Release cadence is irregular, with minor updates every few months.","status":"active","version":"2.3.9","language":"python","source_language":"en","source_url":"https://github.com/GridTools/gridtools","tags":["high-performance-computing","stencil","grid","weather","climate","c++"],"install":[{"cmd":"pip install gridtools-cpp","lang":"bash","label":"Install from PyPI"}],"dependencies":[{"reason":"Used for array operations and data exchange","package":"numpy","optional":false},{"reason":"Required for C++ backend compilation","package":"boost","optional":true}],"imports":[{"note":"The package uses the name 'gridtools' (no underscore) for the Python module, even though the PyPI package is 'gridtools-cpp'.","wrong":"from gridtools_cpp import GridTools","symbol":"GridTools","correct":"import gridtools"}],"quickstart":{"code":"import gridtools\nimport numpy as np\n\n# Define a simple stencil: compute average of neighbors\ndef stencil(in_field, out_field):\n    # GridTools expects Fortran-layout arrays\n    in_field = np.asfortranarray(in_field)\n    out_field = np.asfortranarray(out_field)\n    \n    # Example using the gridtools library (mock)\n    # Real usage involves building a stencil object and applying it\n    out_field[1:-1, 1:-1] = (in_field[:-2, 1:-1] + in_field[2:, 1:-1] +\n                              in_field[1:-1, :-2] + in_field[1:-1, 2:]) / 4.0\n    return out_field\n\n# Create test data\nnx, ny = 10, 10\nin_field = np.random.rand(nx, ny)\nout_field = np.zeros((nx, ny))\n\nresult = stencil(in_field, out_field)\nprint(result)\n","lang":"python","description":"Basic usage of GridTools Python interface. Note that actual high-performance stencils require compiling C++ kernels via the GridTools library; this Python wrapper exposes that functionality."},"warnings":[{"fix":"Use 'import gridtools' instead.","message":"The Python package name is 'gridtools' (no underscore) despite the PyPI package being 'gridtools-cpp'. Attempting to import 'gridtools_cpp' will fail.","severity":"gotcha","affected_versions":"all"},{"fix":"Convert arrays using np.asfortranarray() before passing to GridTools functions.","message":"GridTools expects Fortran-contiguous (column-major) arrays. Passing C-contiguous arrays may result in incorrect results or performance degradation.","severity":"gotcha","affected_versions":"all"},{"fix":"Update imports to use 'gridtools' and refer to current documentation.","message":"The older version 1.x used a different API with 'gridtools_cpp' module. Many online examples still reference the old import path.","severity":"deprecated","affected_versions":"<=1.x"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Change import to 'import gridtools'.","cause":"Incorrect import name; the module is 'gridtools' not 'gridtools_cpp'.","error":"ImportError: No module named gridtools_cpp"},{"fix":"Run 'pip install gridtools-cpp' to install the package.","cause":"Package not installed or installed under different name.","error":"ModuleNotFoundError: No module named 'gridtools'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}