TRACMASS-JAX#
TRACMASS-JAX is a JAX port of TRACMASS, the
Lagrangian trajectory code for ocean and atmosphere general circulation models
(GCMs). Like the Fortran code, it computes trajectories offline from GCM
velocity fields. Each particle crosses each grid box along an analytical
solution of the velocities on the box walls. The time stepping is written in
JAX, so all particles are advanced at once with jax.vmap and the inner loop
is compiled with XLA. It runs on CPUs and on NVIDIA GPUs.
Install the package and run the synthetic double-gyre case in a few lines.
Every tracmass.toml key, and how the Fortran namelist maps onto it.
The driver, the three-layer grid split, the advection schemes and the GCM adapters.
Seeding, stopping trajectories, backward runs, subsets, adding a new GCM.
The Parquet trajectory files, their metadata, and tracmass.load.
Generated from the NumPy-style docstrings in the source.
Why a JAX port?#
TRACMASS has been used for more than three decades, in studies of the global ocean, the Baltic and Mediterranean Seas, coastal regions and the atmosphere (see About). The Fortran code loops over trajectories one at a time. TRACMASS-JAX keeps the same scheme and the same box-wall equations. It changes how the work is organised:
All particles at once. The per-particle kernel is vectorised with
jax.vmapand the sub-step loop runs insidelax.while_loop, so millions of particles share one compiled kernel, on the CPU or the GPU.Lazy GCM data. Velocity fields come from Dask-backed
xarraydatasets (Zarr, NetCDF, OPeNDAP). Nothing is read from disk until the kernel needs it, and only the part of the grid near the particles has to be read.Settings, not recompilation. Fortran TRACMASS is configured with a project folder, a
Makefileand a namelist, and is recompiled for each case. A TRACMASS-JAX run is one Python call,tracmass.run(env=...), with the options in atracmass.tomlfile (see Settings).Analysis-ready output. Trajectories go to Parquet files with the run metadata embedded, and
tracmass.loadreads them back aspandasDataFrames, optionally with longitude and latitude.
What is supported#
Fortran TRACMASS 7 |
TRACMASS-JAX |
|
|---|---|---|
Time-stepping scheme ( |
✓ |
✓ |
Time-analytical scheme ( |
✓ |
✓ |
Forward and backward trajectories |
✓ |
✓ direction from |
Zonal periodicity ( |
✓ |
✓ |
North fold ( |
✓ |
— |
Subdomains ( |
✓ |
✓ |
Seeding from boxes, masks, files |
✓ |
✓ plus lat/lon boxes, points and lists |
Repeated seeding ( |
✓ |
✓ |
Maximum trajectory time ( |
✓ |
✓ |
Kill zones ( |
✓ |
domain edges and land only |
Tracers, stream functions, diffusion |
✓ |
not yet |
GCMs |
NEMO, MOM5, ROMS, IFS, AVISO, … |
GLORYS12, ECCO2, Scripps GoG MITgcm, synthetic test cases |
The Fortran-to-JAX map lists each Fortran routine and namelist variable with its TRACMASS-JAX equivalent.
Citing#
If you use TRACMASS-JAX, please cite the TRACMASS reference paper and the software:
Döös, K., Jönsson, B., and Kjellsson, J. (2017). Evaluation of oceanic and atmospheric trajectory schemes in the TRACMASS trajectory model v6.0. Geoscientific Model Development, 10, 1733–1749. https://doi.org/10.5194/gmd-10-1733-2017
Jönsson, B., Döös, K., and Kjellsson, J. (2015). TRACMASS: Lagrangian trajectory code. Zenodo. https://doi.org/10.5281/zenodo.34157