Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/PRBEM/IRBEM/llms.txt

Use this file to discover all available pages before exploring further.

IRBEM is built from Fortran source using a standard make-based workflow. The process produces a shared library (libirbem.so on Linux/macOS, libirbem.dll on Windows) that any language interface can load, plus a static archive (liboneradesp.a) for direct Fortran/C linking. The steps below cover all three major platforms.

Prerequisites

A Fortran compiler is required. IRBEM will not build without one. The officially supported compiler is gfortran, which is free and available on all platforms. Install it before proceeding.
Install gfortran from https://fortran-lang.org/learn/os_setup/install_gfortran or via your system package manager (apt, brew, etc.). Confirm the installation with:
gfortran --version
You also need git to clone the repository and make to drive the build.

Build and Install

These instructions target a 64-bit Linux system using gfortran.
1

Clone the repository

git clone https://github.com/PRBEM/IRBEM.git
cd IRBEM
2

Compile the library

Run make with the OS=linux64 and ENV=gfortran64 variables. This compiles all Fortran and C sources in the source/ directory and writes the resulting objects and library files to bin/.
make OS=linux64 ENV=gfortran64 all
To see a full list of valid OS and ENV combinations, run make all.help before the build step.
3

Install the library

The install step copies the compiled shared object and any wrapper support files to the expected locations within the IRBEM tree (including the matlab/ directory).
make OS=linux64 ENV=gfortran64 install
To install to a custom directory, append INSTALLDIR=/path/to/destination:
make OS=linux64 ENV=gfortran64 INSTALLDIR=/usr/local/irbem install
Run make install.help to see all available install-time variables.
4

Verify the build

Run the provided test suite to confirm the library was built and linked correctly:
make OS=linux64 ENV=gfortran64 test
Each test name and its pass/fail result will be printed to the terminal.
After a successful build you will find libirbem.so (shared) and liboneradesp.a (static) in the root of the IRBEM directory.

Python Wrapper

The Python wrapper (python/IRBEM/IRBEM.py) uses ctypes to call the compiled shared library. Install it after completing the platform build above.
1

Install dependencies

The Python wrapper requires numpy, scipy, and dateutil. Install them with your package manager or virtual environment tooling before proceeding.
2

Install the IRBEM Python package

Change into the python/ subdirectory of the cloned repository and install with pip:
cd python
python3 -m pip install -e .
Use pip install --user -e . instead of -e . for a user-only install that does not require root privileges. This installs the IRBEM package (containing the MagFields and Coords classes) into your active Python environment.
3

Verify the Python installation

Run the bundled test and visualization scripts to confirm the wrapper can locate and load the shared library:
python3 IRBEM/magfields_tests_and_visualization.py
python3 IRBEM/coords_tests_and_visualization.py
If you see the error "Either none or multiple .so files found in the sources folder!", the shared library (libirbem.so / libirbem.dll) is not in the expected location. Confirm the platform build completed successfully and that the .so or .dll file exists in the root of the IRBEM directory.

TS07d Optional Data Files

The Tsyganenko 2007 (TS07d / T07) magnetic field model requires a large set of external coefficient files (~8.5 GB, covering 2007–2016) that are not included in the repository.
IRBEM will compile and run without the TS07d files. Only calls that explicitly select the T07 model (kext=13) will be affected. If the tail parameter files are absent, the library returns bad-data fill values (-1e31) rather than raising a hard error.
To enable full TS07d support:
1

Set the data path environment variable

Choose a directory with at least 8.5 GB of free space and set:
export TS07_DATA_PATH=/path/to/your/ts07d_data
Add this line to your shell profile (e.g., ~/.bashrc) to make it permanent.
2

Run the setup script

From the root of the IRBEM directory, execute:
bash setup_ts07d_files.sh
This script downloads the coefficient archives (all.tgz) and tail parameter file (TAIL_PAR.zip) from the JHU APL server, then unpacks them into the correct subdirectory structure under TS07_DATA_PATH.
3

Install IRBEM normally

If you have not already done so, follow the platform build steps above. The TS07d data path is read at runtime and does not affect compilation.
If the tail parameter files are not found at runtime, the Fortran layer will print an error message. This message may not be visible when calling IRBEM from MATLAB but will not cause an unhandled exception — bad-data values are returned instead.

Cleaning the Build

To remove all compiled objects, library files, and executables from the source/ and bin/ directories without affecting installed files:
make clean

Build docs developers (and LLMs) love