Stacks

Trace a runtime bug from a stack trace in Fortran with Atlas in 2026

Updated 7 min read

Fortran developers in 2026 can trace runtime bugs from production stack traces directly to the responsible line and apply a fix using Atlas, the terminal-native AI coding agent, without needing a debugger attached. Atlas integrates with your existing Fortran toolchain, including `fpm` for package management and `fpm test (test-drive)` for unit testing, to streamline the debugging workflow.

How Atlas Reads Fortran Stack Traces for Bug Identification

In 2026, Atlas directly consumes Fortran stack traces, which are essentially lists of `file:line` pairs, to begin the bug identification process. The `read` tool processes each frame at its reported offset, validating it against the current file to prevent misdiagnosis from older builds, ensuring accuracy 100% of the time.

Atlas's `read` tool is specifically designed to interpret the `file:line` pairs found in a Fortran production stack trace. When you paste a stack trace, Atlas reads each frame at its reported offset. This is crucial for Fortran projects, where a single source file like `my_module.f90` might contain multiple subroutines or functions. Atlas validates these offsets against the current version of the file. If a trace originates from an older build, and the reported offset is out of range for the current file, Atlas will loudly report the discrepancy. This prevents the common pitfall of debugging against outdated code, ensuring that any subsequent analysis or proposed fix targets the correct Fortran source line. This capability is vital for maintaining the integrity of complex Fortran applications, from legacy FIXED-form numerics to modern modules and coarrays.

Pinpointing Fortran Error Sources with `grep` and `lsp`

Pinpointing the exact source of a Fortran runtime error in 2026 involves Atlas leveraging its `grep` and `lsp` tools. After reading the stack trace, Atlas first uses `grep` to locate the error message string, often revealing more context than the top frame, then employs `lsp` to find all 10 references to the failing function.

After Atlas has processed the initial Fortran stack trace frames, it employs its `grep` tool to search for the specific error message string within your codebase. This often provides more informative context than merely examining the top frame of the stack trace, helping to understand where the error message is constructed or triggered. For instance, if a Fortran program terminates with a specific error string, `grep` can quickly locate the `WRITE` statement or `STOP` condition responsible. Following this, Atlas utilizes its `lsp` (Language Server Protocol) tool to perform a `findReferences` operation on the failing Fortran function or subroutine identified in the stack trace. This allows Atlas to see all callers that can reach the problematic code with the bad input, considering Fortran's explicit interfaces and module dependencies. This comprehensive approach helps Fortran developers understand the full call chain leading to the bug, even across different modules like `my_data_module` or `calculation_subroutines.f90`.

Applying Fortran Bug Fixes and Regression Tests with Atlas

Once the Fortran bug is identified, Atlas facilitates a fix using its `edit` tool and ensures future stability by adding a regression test, a crucial step in 2026's development practices. Atlas drafts a plan, proposes code changes, and can generate new `fpm test (test-drive)` unit tests under the `test/` directory to prevent the bug from recurring silently.

With the Fortran bug's root cause identified, Atlas's `edit` tool comes into play to propose and apply a fix. Atlas operates with a read-only plan agent first, drafting a comprehensive strategy for the code modification. This plan might involve adjusting intent declarations on dummy arguments, refactoring a common block into a module, or correcting a calculation within a subroutine in `src/my_program.f90`. Crucially, Atlas also assists in adding a regression test to prevent the bug from recurring silently. It can generate a new unit test under the `test/` directory, leveraging the `fpm test (test-drive)` framework. Before any changes are written, Atlas computes a unified diff for every file edit and surfaces it for your approval. It can also run `fpm test` behind a permission prompt to validate the fix and `fprettify` over the changed sources to maintain consistent Fortran code style before you approve the final diff.

Ensuring Safe Fortran Code Changes with Atlas's Review Process

Atlas ensures the safety and integrity of Fortran code changes through a robust, multi-stage review process, a critical feature for developers in 2026. Every Atlas tool call is permission-gated, and all proposed file edits are presented as a unified diff for explicit approval, preventing unintended modifications 100% of the time.

Atlas is built with safety and developer control as paramount concerns for Fortran projects. Before any tool call that could modify your codebase, such as `edit` or even running `fpm test`, Atlas presents a permission prompt, allowing you to `allow`, `ask`, or `deny` the action. This ensures that you, the Fortran developer, are always in control. When Atlas proposes a fix, it first drafts a plan in a read-only plan agent, which you can review. Only after your approval does it switch to a build agent. For every file edit, Atlas computes and displays a unified diff, clearly showing what changes will be made to your Fortran source files, like `src/calculations.f90` or `fpm.toml`. You must explicitly approve this diff before Atlas writes any changes to disk. Furthermore, Atlas reads git branches, status, and diffs, and can stage and create commits on your behalf, ensuring that your Fortran project's version control remains clean and traceable. Atlas also snapshots file changes as git patches, allowing edits to be easily diffed and rolled back if needed, providing a robust safety net for your Fortran development workflow.

Step by step

  1. 01Paste the Fortran production stack trace into Atlas's terminal interface.
  2. 02Have Atlas `read` each `file:line` frame from the Fortran stack trace to understand the call path.
  3. 03If Atlas's `read` tool reports an 'Offset <n> is out of range for this file', re-read the Fortran file from the top to ensure you are working with the current build's code.
  4. 04Instruct Atlas to `grep` for the specific error message string within your Fortran codebase to find where it is constructed, often revealing more context.
  5. 05Use Atlas's `lsp` tool to `findReferences` on the failing Fortran function or subroutine to identify all callers that can reach it with the problematic input.
  6. 06Approve Atlas's proposed `edit` to fix the Fortran bug, reviewing the unified diff for accuracy and correctness.
  7. 07Direct Atlas to add a new `fpm test (test-drive)` unit test under the `test/` directory to create a regression test for the identified Fortran bug.
  8. 08Review the `fprettify`-formatted Fortran changes and approve the final diff before Atlas commits the fix.

Frequently asked questions

How does Atlas handle Fortran stack traces from different builds?
Atlas validates each `file:line` offset from a Fortran stack trace against the current version of the file. If an offset is out of range, Atlas will alert you, preventing debugging against outdated code and ensuring accuracy for your Fortran project.
Can Atlas debug legacy FIXED-form Fortran code?
Yes, Atlas is designed to work with modern Fortran, from legacy FIXED-form numerics to modules, interfaces, and coarrays. Its code indexing and search capabilities are effective across various Fortran code styles.
What Fortran tools does Atlas integrate with?
Atlas integrates deeply with the Fortran toolchain, including `fpm` for package management, `fpm test (test-drive)` for running unit tests, and `fprettify` for code formatting. It also processes `gfortran` diagnostics.
How does Atlas ensure code quality for Fortran fixes?
Atlas ensures code quality by proposing fixes as unified diffs for your approval, running `fpm test` to validate changes, and applying `fprettify` to maintain consistent Fortran code style before final approval.
Can Atlas move a Fortran `COMMON` block into a `MODULE`?
Yes, Atlas can be asked to refactor Fortran code, including moving a `COMMON` block into a `MODULE`. It leverages its AST indexing to understand code structure and propose accurate, idiomatic changes.
How does Atlas manage permissions for Fortran code modifications?
Atlas employs a permission-gated system for all tool calls that modify Fortran code. It drafts plans in a read-only agent and presents all proposed file edits as unified diffs for explicit developer approval before writing any changes.

Try Atlas in your terminal

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

Install Atlas

Related guides

Trace a Runtime Bug from a Stack Trace with Atlas in 2026

How to trace a runtime bug from a stack trace with Atlas in 2026: read each frame at its offset, grep for the error string, and use the lsp tool to find callers.

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.

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

Refactor Fortran code with Atlas in 2026. Rename functions, classes, or constants across your entire repository using fpm, fprettify, and precise AST-based tools.

Research a third-party API before integrating it in Fortran with Atlas in 2026

Fortran developers in 2026 can research third-party APIs efficiently with Atlas. Use `websearch` and `webfetch` for current docs, then integrate with confidence, verifying against `fpm` project conventions.

Onboard to an Unfamiliar Fortran Codebase in 2026 with Atlas

Quickly build a working mental model of any Fortran repository using Atlas. Leverage semantic search, `fpm` package layouts, and `fprettify` formatting for rapid understanding and safe code exploration in 2026.

Run Atlas Headless in CI for Fortran in 2026

Fortran developers in 2026 can run Atlas headless in CI pipelines to automate tasks, integrate with fpm, and get machine-readable output for robust automation.

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.

Plan a Multi-File Change in Fortran with Atlas Before Editing in 2026

Design and review complex Fortran code changes across multiple files using Atlas in 2026. Plan safely with fpm, fprettify, and gfortran integration before modifying a single line.

Browse this resource hub