Skip to content
cd /languages
  • Scientific legacy
  • Programming
  • AST and symbol support

Fortran Support in Maguyva: Code Graphs for Scientific Codebases

Maguyva parses Fortran with AST, symbol, and graph support, so AI agents can trace subroutines, modules, and derived types before changing numerical code.

Why Fortran needs structure, not string matching

Fortran codebases tend to be old, large, and written by domain experts rather than software teams. Routines named SOLVE, Solve, and solve are the same routine. Modules are shared across hundreds of files, and the intrinsic library is big enough that a naive call list is mostly SQRT, SUM, and WRITE.

An agent that only greps will drown in that noise. Maguyva gives it the structure first: which program units exist, which modules they use, and which user routines call each other.

What Maguyva extracts in Fortran

Maguyva covers fixed-form and free-form source (.f, .for, .ftn, .f90, .f95, .f03, .f08). Functions and subroutines are extracted as callable symbols, and derived types are selectable as type definitions in structural search.

Symbol matching is case-insensitive, matching Fortran’s own rules. Import relationships come from use and include, with the keyword stripped so the module name is what the graph stores. Calls, reads, assignments, type references, and inheritance from extended derived types are all part of the graph.

The relationship filter removes around 165 intrinsics (I/O statements, math, array, string, type-conversion, and bit-manipulation routines), so the edges that remain point at your own code.

Example agent prompts

  • “Which subroutines call compute_flux, and which modules do they use?” (find_symbol, then dependency_search incoming)
  • “Trace how boundary conditions are applied in the solver loop.” (get_task_context)
  • “Find every program unit that uses the constants module.” (text_pattern_search for use constants, then find_symbol)

Known limits

  • Fortran has no decorators or exception handling, so those relationship types are marked not applicable.
  • Type-bound procedures share the same nodes as ordinary functions and subroutines. Use the functions preset in structural_search; the methods preset selects no Fortran nodes.
  • Calls to filtered intrinsics do not appear as graph edges. Use text_pattern_search when you need every WRITE or OPEN.

Next steps

Connect a repository with the quickstart, then check the full support matrix on the compatibility page. If Fortran sits beside C glue code, read the C guide too.

Best fit

  • > Research, engineering, and HPC teams maintaining Fortran solvers, simulations, or numerical libraries that predate the current team.
  • > Repositories that mix fixed-form `.f` files with free-form `.f90` and later modules, often beside C or Python wrappers.
  • > Agent-assisted reviews where the first job is mapping which subroutines touch a shared module before a numerical change.

Agent workflows

  • > Trace which subroutines and functions call a solver routine before changing its arguments or units.
  • > List the modules a program unit pulls in with `use` and follow them to their definitions.
  • > Find where a derived type is declared and which procedures work with it.

Engine details

  • > Fortran support covers fixed-form and free-form source: `.f`, `.for`, `.ftn`, `.f90`, `.f95`, `.f03`, and `.f08`.
  • > Functions and subroutines are callable symbols, symbol matching is case-insensitive, and `use` and `include` become import relationships.
  • > About 165 intrinsics (I/O, math, array, string, type-conversion, and bit routines) are filtered from relationships. Decorator and exception relationships are marked not applicable.

Useful MCP entry points

  • find_symbol

    Start with the subroutine, function, or module name; matching ignores case, as Fortran does.

  • dependency_search

    Use incoming traversal on a solver or shared module routine to see every caller before a numerical change.

  • get_task_context

    Use it for prompts like “trace how boundary conditions are applied in the solver loop.”