Skip to content

Decompose monolithic neo core into independent CMake sub-targets#275

Draft
krystophny wants to merge 9 commits intomainfrom
dep-audit/decompose-neo-core
Draft

Decompose monolithic neo core into independent CMake sub-targets#275
krystophny wants to merge 9 commits intomainfrom
dep-audit/decompose-neo-core

Conversation

@krystophny
Copy link
Copy Markdown
Member

Summary

  • Extract LIBNEO::util sub-target (Tier 0): libneo_kinds, math_constants, binsrc, plag_coeff, arnoldi, system_utility, etc.
  • Extract LIBNEO::nctools sub-target (Tier 0): standalone NetCDF wrapper
  • Extract LIBNEO::vmec_support sub-target (Tier 1): VMEC I/O, spline construction, data modules
  • Extract LIBNEO::coordinates sub-target (Tier 1): coordinate system framework + geqdsk_tools
  • Remove jorek_field.f90 from neo_field library, decoupling it from HDF5 (Remove jorek_field.f90 from neo_field #267)
  • Move magfie_vmec.f90 from neo core into magfie sub-target
  • Narrow species/collision_freqs deps from neo to neo_util
  • Neo aggregate now contains only poincare.f90 and links all sub-targets

Builds on the MyMPILib removal branch (#259).

Test evidence

libneo standalone

$ ninja -C build -j10
[540/540] Linking Fortran shared module _efit_to_boozer.cpython-313-darwin.so

$ ctest --test-dir build
100% tests passed, 0 tests failed out of 72

NEO-2 (on dep-audit/wave-01-remove-mympilib)

$ CODE=/Users/ert/code ninja -C build -j10
[436/436] Linking Fortran executable NEO-2-QL/neo_2_ql.x

SIMPLE (on dep-audit/decompose-neo-core, itpplasma/SIMPLE PR pending)

$ CODE=/Users/ert/code ninja -C build simple.x
[4/4] Linking Fortran executable simple.x

One pre-existing test failure (missing netcdf.h for C test), not decomposition-related.

KAMEL

$ CODE=/Users/ert/code ninja -C build -j10
[933/933] ... all targets built

MEPHIT

Pre-existing build failure on main (odeint_mod API incompatibility), not caused by this PR.

tiago

Pre-existing build failure on main (-march=native on Apple Silicon), does not use local libneo.

NEO-RT

Standalone mode, does not use libneo.

Downstream PRs

  • itpplasma/SIMPLE: branch dep-audit/decompose-neo-core (f90wrap path update)

Tier structure

Tier 0 (no libneo deps):
  util, nctools, interpolate, odeint, polylag, hdf5_tools, neo_field, contrib

Tier 1 (depends on Tier 0):
  vmec_support, coordinates

Aggregate:
  neo (poincare.f90 + links all sub-targets)

Tier 2+ (depends on aggregate):
  species, collision_freqs, transport, magfie, efit_to_boozer

Closes #267. Ref: #274, #258, #269.

The PYTHONPATH additions were a drive-by fix unrelated to removing
MyMPILib. Keep this PR focused on the MPI dependency removal only.
Move libneo_kinds, math_constants, util, binsrc, plag_coeff, arnoldi,
rusage_type, system_utility, simpson_integration, local_rusage.c into
src/util/ with own CMakeLists.txt defining the neo_util static library.

Update CMakeSources.in to remove these files and link neo_util.
Add neo_util dependency to magfie, species, collisions, transport
sub-targets that use libneo_kinds/math_constants directly.

Ref: #274
Move nctools_module.f90 into src/nctools/ with own CMakeLists.txt.
Pure NetCDF wrapper with no internal libneo dependencies (Tier 0).

Ref: #274
Create LIBNEO::vmec_support (Tier 1): VMEC I/O, spline construction,
and data modules (new_vmec_stuff_mod, vector_potentail_mod, etc.).
Depends on interpolate, nctools, util, and NetCDF.

Create LIBNEO::coordinates (Tier 1): all 13 coordinate system files.
Depends on vmec_support, interpolate, nctools, util, and NetCDF.

Move magfie_vmec.f90 and geqdsk_tools.f90 from CMakeSources.in into
the magfie sub-target (they already lived under src/magfie/).

Narrow species dependency from neo to neo_util (only needs
math_constants). Narrow collision_freqs dependency similarly.

The neo aggregate target now contains only poincare.f90 and links
all sub-targets. CMake tier structure:
  Tier 0: util, nctools, interpolate, odeint, polylag, hdf5_tools,
          neo_field, contrib
  Tier 1: vmec_support, coordinates
  Tier 2+: neo (aggregate), species, collision_freqs, transport,
           magfie

Ref: #274, #258
geqdsk_tools.f90 is a standalone EQDSK parser used by
geoflux_coordinates.f90. Placing it in magfie created a circular
dependency (coordinates -> magfie -> neo -> coordinates). Move it
to the coordinates sub-target where its consumer lives.

Add coordinates as a dependency of magfie (for the standardise_geqdsk
executable which uses geqdsk_tools transitively).

Ref: #274
gfortran on Apple Silicon resolves -march=native to apple-m3 which
it does not recognize. Use -mcpu=native on ARM targets instead,
which is the correct flag for aarch64 gfortran.
When libneo is used as a subproject via FetchContent, the NetCDF
link directories from DetectDependencies.cmake may not propagate.
Add nf-config fallback to nctools so it can find NetCDF independently.

Remove duplicate NetCDF links from vmec_support and coordinates
since they get NetCDF transitively via nctools (PUBLIC link).
@krystophny krystophny force-pushed the dep-audit/decompose-neo-core branch from e78207e to cc183b8 Compare April 9, 2026 14:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove jorek_field.f90 from neo_field

1 participant