Fortran remains widely used in aerospace, automotive, and scientific research, where it powers critical simulation software. To build high-quality and efficient Fortran applications, a structured development approach is required.
A Structured Approach to Fortran Quality
A practical development strategy consists of two stages:
- Establish a high-quality, reliable, and maintainable codebase using modern programming practices introduced in recent Fortran standards.
- Optimize performance once correctness and code quality are ensured.
Correctness is a foundational requirement. Bugs such as uninitialized variables or implicit behaviors can lead to computational errors, crashes, or undefined behavior. Identifying and preventing these issues early reduces debugging effort and long-term maintenance cost.

Static Analysis with Codee Analyzer
The Codee Analyzer performs deep static analysis of Fortran (C/C++) code, detecting issues without executing the program. It:
- Identifies correctness issues at exact source locations
- Provides detailed explanations and links to documentation
- Generates reports
- Supports automatic code rewriting (AutoFix) for selected recommendations
Codee integrates into CI/CD pipelines and IDEs and runs entirely on the local system, ensuring code privacy.
The Open Catalog of Coding Guidelines
Codee Analyzer is driven by the Open Catalog, a curated collection of programming best practices developed in collaboration with the community.
The catalog includes tens of checks, with 32 recommendations focused on correctness. Each recommendation provides (1) description of the issue, (2) guidance for resolution and (3) before-and-after examples.
Codee identifies locations in the code where these recommendations can be applied. For each detected issue, developers can review the associated Open Catalog documentation to understand the problem and determine the appropriate resolution.
Example: Uninitialized Variables (PWR079)
Recommendation PWR079 detects uses of uninitialized variables, which may lead to undefined behavior and difficult-to-diagnose bugs.
In the WRF project, Codee Analyzer identified that the variable ttke was read before being initialized. Upon inspection, the variable was not declared due to the use of implicit variables — a common source of errors in Fortran.
AutoFix is not available for PWR079. However, Codee provides detailed diagnostics and links to the Open Catalog documentation to assist developers in manually resolving the issue.
A second example of PWR079 was observed in the Adflow project, where the variable rotationpoint was also read before initialization. In this case, the issue appeared in code generated automatically by a third-party dependency. This highlights the need to analyze not only handwritten code but also externally generated source code included in a project.
Example: Implicit SAVE Behavior (PWR072)
Recommendation PWR072 detects variables affected by implicit save behavior.
In one analyzed file, the variable itCount retained state between subroutine calls due to implicit save. Although the subroutine manually reset the variable later, this behavior could be confusing, particularly for developers unfamiliar with this aspect of Fortran.
For this recommendation, AutoFix was available. Codee suggested a rewrite command that modified the code by separating the variable declaration and initialization, thereby removing the implicit save behavior.
With a small number of commands, thousands of lines of code were analyzed and correctness issues were detected and, where possible, automatically resolved.
🎦 A recorded demonstration of these examples, including the exact commands and workflow, is available here.
Integration in Development Workflows
Codee is designed to complement compilers and IDEs.
It provides:
- Approximately 90 checkers covering correctness, modernization, security, and portability
- Multiple report types
- CI/CD and IDE integration
- Self-hosted execution to preserve code privacy
Conclusion
Fortran remains critical for numerically intensive simulation software.
Ensuring correctness through static analysis and best practices is a prerequisite for performance optimization and long-term maintainability. Codee enables systematic detection and resolution of correctness issues using configurable checks and AutoFix capabilities.
Build correct, secure, modern and fast Fortran, C and C++ scientific software
This company is capitalized by INNVIERTE, AN INVESTMENT PROGRAM OF CDTI, E.P.E
Leave a Reply