Stacks

Rename a symbol across the repo in Fortran with Atlas in 2026

Updated 6 min read

Atlas, the terminal-native AI coding agent, renames Fortran symbols across your entire repository by leveraging the `lsp` tool for precise AST-based references, `grep` for non-code occurrences, and `edit` for mechanical changes, all verified by `fpm test (test-drive)` and formatted by `fprettify`. This ensures accurate, safe, and Fortran-idiomatic refactoring, even in complex projects with modules and coarrays.

How Atlas renames Fortran symbols accurately across the codebase

Atlas renames Fortran symbols with high precision by combining multiple strategies, ensuring no reference is missed or wrongly matched. In 2026, Atlas uses the `lsp` tool's `findReferences` to get the authoritative callsite list from the Fortran language server, which is crucial for modern Fortran constructs like modules and explicit interfaces.

Renaming a function, class, or constant in a Fortran codebase can be challenging, especially with legacy FIXED-form numerics alongside modern modules and coarrays. Atlas addresses this by first employing the `lsp` tool's `findReferences` operation. This tool leverages the language server's understanding of the Fortran Abstract Syntax Tree (AST) to identify every true declaration and usage of a symbol. This is vital for Fortran, where `USE` statements, `INTERFACE` blocks, and `INTENT` declarations define precise relationships that simple text search would miss or misinterpret. For instance, if you rename a subroutine `CALCULATE_ENERGY` defined in `src/physics_module.f90`, Atlas will accurately find all calls to it, even if they are aliased or used through an interface. After identifying these compiler-visible references, Atlas then runs `grep` for the old name. This step catches occurrences outside the type system, such as comments, documentation within `README.md` files, or configuration entries in `fpm.toml` that might reference the symbol. This hybrid approach ensures a comprehensive rename that covers both the compiler's view and human-readable contexts.

Concrete Fortran commands and files involved in a symbol rename

The renaming workflow with Atlas integrates directly with your existing Fortran toolchain, making the process feel native and familiar. Atlas interacts with `fpm.toml` for project structure, executes `fpm test (test-drive)` for verification, and applies `fprettify` for consistent formatting, ensuring your Fortran code remains pristine after 100% of changes are applied.

When you initiate a symbol rename, Atlas operates within the context of your Fortran project, typically defined by an `fpm.toml` file. For example, if you're renaming a constant `MAX_ITERATIONS` used across `src/solver.f90` and `src/utils.f90`, Atlas will first identify its declarations and uses. Once the mechanical `edit` operations are complete using `replaceAll`, Atlas proceeds to verify the changes. It does this by running your project's tests using the actual Fortran Package Manager command: `fpm test (test-drive)`. This step is critical; if any test fails, Atlas will surface the diagnostics from `gfortran`, allowing you to iterate and fix issues. After successful testing, Atlas can then run `fprettify` over the changed sources. This ensures that any formatting discrepancies introduced by the rename are automatically corrected, adhering to your project's established Fortran style guidelines. This sequence of operations,identify, modify, test, format,is executed behind permission prompts, giving you full control over each stage and ensuring that the Fortran toolchain is used correctly and safely.

Ensuring safety and review during Fortran refactoring with Atlas

Atlas prioritizes safety and transparency throughout the refactoring process, offering multiple layers of review and approval. Every Atlas tool call is permission-gated, and all proposed file edits are presented as a unified diff for your explicit approval, providing 100% control over changes to your Fortran codebase.

Safety is paramount when performing a significant refactoring like renaming a symbol across an entire Fortran repository. Atlas employs a multi-stage approval process to prevent unintended changes. First, Atlas drafts a plan in a read-only plan agent, outlining the steps it intends to take. This allows you to review the strategy before any modifications are attempted. When Atlas switches to a build agent to execute the plan, every tool call,whether it's `lsp`, `grep`, `edit`, or `bash` for `fpm test`,is permission-gated against allow, ask, or deny rules. This means you explicitly approve each action. Crucially, for every file edit, Atlas computes a unified diff and surfaces it for your approval before writing. This visual representation of changes, similar to a `git diff`, allows you to inspect every line modification in your Fortran source files, such as `src/data_types.f90` or `test/integration_test.f90`. Furthermore, Atlas snapshots file changes as git patches, so if an approved change later proves problematic, edits can be easily diffed and rolled back, providing a robust safety net for your Fortran development workflow.

Step by step

  1. 01Initialize Atlas in your Fortran project directory containing an `fpm.toml` file.
  2. 02Ask Atlas to rename your Fortran symbol, for example: 'Rename `OLD_CONSTANT` to `NEW_CONSTANT` across the repo'.
  3. 03Atlas will use the `lsp` tool's `findReferences` to identify all authoritative uses of `OLD_CONSTANT` in your Fortran modules and interfaces.
  4. 04Atlas will then run `grep` for `OLD_CONSTANT` to locate occurrences in Fortran comments, strings, documentation, and `fpm.toml`.
  5. 05Atlas applies the mechanical renames using the `edit` tool with `replaceAll`, presenting a unified diff for each Fortran file for your approval.
  6. 06After edits, Atlas will run `fpm test (test-drive)` to compile and execute your Fortran unit and integration tests, surfacing any `gfortran` diagnostics.
  7. 07Upon successful testing, Atlas will run `fprettify` over the changed Fortran sources to ensure consistent code formatting, presenting another diff for approval.
  8. 08Finally, Atlas will `grep` once more for `OLD_CONSTANT` to confirm zero remaining hits and offer to stage and create a commit for the refactoring.

Frequently asked questions

How does Atlas rename Fortran symbols without breaking code?
Atlas uses the `lsp` tool's `findReferences` to get the authoritative callsite list from the Fortran language server. This leverages AST declarations to ensure only true references in Fortran modules, interfaces, and coarrays are modified, preventing compilation errors.
Can Atlas rename Fortran symbols in comments or strings?
Yes, Atlas runs `grep` for the old name to catch occurrences outside the type system. This includes strings, comments, and documentation within your Fortran source files or related project files like `fpm.toml`.
What Fortran tools does Atlas integrate with for renaming?
Atlas integrates direct with the Fortran toolchain. It uses `fpm` for package management and testing via `fpm test (test-drive)`, and `fprettify` for automatic code formatting over changed Fortran sources before you approve the diff.
How does Atlas ensure I approve changes before they are applied to my Fortran project?
Atlas drafts a plan in a read-only agent and computes a unified diff for every file edit. This diff is surfaced for your explicit approval before any changes are written to your Fortran codebase, giving you full control.
What if Atlas makes a mistake during a Fortran symbol rename?
Atlas provides robust safety features. It snapshots file changes as git patches, allowing edits to be easily diffed and rolled back. Additionally, `edit` refuses ambiguous single replacements, preventing silent corruption in your Fortran project.
Does Atlas support renaming symbols in legacy Fortran code?
Yes, Atlas is designed to work with modern Fortran, from legacy FIXED-form numerics to modules, interfaces, and coarrays. Its AST indexing capabilities ensure accurate symbol identification across various Fortran code styles and versions.
How does Atlas verify the Fortran refactoring was successful?
After applying changes, Atlas runs `fpm test (test-drive)` to execute your Fortran project's test suite. It then performs a final `grep` for the old symbol name to confirm zero remaining hits, ensuring a complete and verified refactor.

Try Atlas in your terminal

The terminal-native AI coding agent. Free core, single binary.

Install Atlas

Related guides

Rename a Symbol Across the Repo with Atlas in 2026

How to rename a symbol across a repo with Atlas in 2026: findReferences gets the true reference set, grep catches strings and docs, and edit refuses ambiguous matches.

Atlas for Fortran: fpm.toml, Explicit Interfaces, and fprettify in 2026

Atlas is a terminal-native AI coding agent for Fortran in 2026. It reads modules, explicit interfaces, and intent declarations, runs fpm test behind a prompt, and runs fprettify.

Refactor a Legacy Fortran Module with Atlas in 2026

Modernize Fortran code in 2026. Use Atlas to refactor legacy modules, move COMMON blocks, and ensure no regressions with fpm test and fprettify.

Add a Regression Test for a Fortran Bug Fix with Atlas in 2026

Fortran developers in 2026 use Atlas to add regression tests for bug fixes. Leverage fpm test (test-drive) to confirm failures and passes, ensuring robust code quality.

Audit a Fortran Repo with Parallel Subagents in 2026

Sweep your Fortran codebase for problems without context window limits. Atlas uses parallel subagents to audit fpm projects, leveraging fprettify and fpm test for comprehensive review in 2026.

Write Unit Tests for Untested Code in Fortran with Atlas in 2026

Boost your Fortran codebase in 2026 by adding robust unit tests with Atlas. Learn to use fpm test and fprettify to ensure code quality and maintainability.

Diagnose a Hanging or Long-Running Fortran Command with Atlas in 2026

Fortran developers in 2026 can use Atlas to diagnose hanging or slow fpm builds and scripts. Identify if commands are blocked on input or genuinely slow, and get them unstuck efficiently.

Migrate a deprecated API across every callsite in Fortran with Atlas in 2026

Streamline Fortran API migrations in 2026 with Atlas. Enumerate all callers, apply context-anchored patches, and validate changes with fpm test and fprettify for a complete, verified transition.

Browse this resource hub