Modernize Your Legacy Fortran Code with Astradian Technologies
At Astradian Technologies, we specialize in modernizing legacy Fortran codebases at industry leading cost and value. We accomplish this goal with two approaches: directly integrating the legacy Fortran code into C/C++ and/or Python or completely rewriting the codebase. Each approach has distinct advantages, which we will evaluate in collaboration with you during a free consultation and planning session. Regardless of the path chosen, our goal is to deliver high-performance, reliable solutions efficiently and at lower costs than the competition. Contact us today to learn more!
Our Approaches to Modernization:
Approach 1. Direct Integration with Modern Languages
Before discounting Fortran entirely, read our blog post about why you should consider keeping Fortran code!
Direct integration is often the most cost effective approach, and it allows your organization to preserve the performance advantages of existing Fortran code while enabling interoperability with modern programming environments such as Python or C/C++. This approach is generally more cost effective as it does not require the development, testing, and certification of new code. Instead, we directly integrate to the existing Fortran codebase.
This is accomplished by:
- Modular Code Organization: Ensuring the Fortran codebase is organized into clearly defined modules, each responsible for specific functionalities. This modular structure facilitates easier interfacing with other languages by isolating core computational routines, reducing complexity when creating bindings, and simplifying updates or debugging during cross-language integration.
- Binding Fortran Subroutines and Functions: Using ISO_C_BINDING and interface blocks to expose Fortran procedures so they can be called from Python, C/C++, or other languages without needing to reimplement core algorithms.
- Mapping Data Types: Translating data types between Fortran and the target language using ISO_C_BINDING derived types and standardized type correspondences (e.g., INTEGER(C_INT), REAL(C_DOUBLE)) to ensure seamless compatibility and prevent runtime errors.
- Optimizing Memory Management: Creating interfaces that handle memory efficiently during cross-language data exchanges, including proper allocation and deallocation of arrays, and managing column-major (Fortran) versus row-major (C/Python) array layouts.
This approach is well-suited for applications where peak computational efficiency is essential but additional flexibility is required for integration into modern ecosystems. With this approach, your team can better allocate resources toward implementing new features or addressing emerging challenges rather than duplicating existing functionality. Contact us today to discuss how we can get started with direct integration!
Example Use Case for Direct Integration of Fortran
A practical example of direct integration is embedding legacy Fortran code within a Python script by creating a compiled Python module. For instance, a business running weather simulations might have an established Fortran codebase optimized for solving large-scale partial differential equations. By wrapping this code as a Python module, users can leverage Python’s extensive data visualization libraries (e.g., Matplotlib) and modern machine learning frameworks (e.g., TensorFlow or PyTorch) to analyze simulation outputs or incorporate predictive modeling—without sacrificing the computational speed of the core Fortran algorithms.
This integration enables end-users to maintain the high-performance benefits of their existing Fortran routines while maximizing productivity and flexibility through Python's user-friendly interface and extensive ecosystem.
Approach 2. Complete Code Rewrites of Fortran Codebases
For projects that require it, we offer full rewrites of legacy Fortran codebases to languages like Python or C/C++. This approach allows us to tailor the codebase to the existing skill set of your team. Our expertise in high-performance scientific software development, particularly through collaborations with DoD organizations like the Air Force REsearch Laboratory, enables us to execute these rewrites efficiently while preserving the core functionality and precision of the original code. Our software development process includes stringent testing to ensure that we are developing high-quality software. Our in-house testing exceed the V&V requirements of most organizations, and we do it from the start of development. This translates to increased cost savings and less time reworking and refactoring code.
We primarily rewrite code in Python or C/C++. Each target language offers distinct advantages based on organizational goals:
Rewriting in C/C++ is best suited for performance-critical applications that require low-level hardware interaction and access to advanced libraries designed for optimized computation. Modern C++ features also enable modularity and better software design practices while preserving high efficiency.
Rewriting in Python, by contrast, supports rapid prototyping, flexibility, and ease of collaboration across teams due to Python’s readable syntax and extensive ecosystem of libraries (e.g., NumPy, SciPy). Although Python generally introduces computational overhead compared to compiled languages like C++, its versatility and user-friendliness may outweigh these trade-offs in less performance-sensitive contexts.
We can also rewrite in C/C++ and generate Python Bindings. This approch offers the benefits of C/C++ and does not impose the performance constraints of Python. However, this approach is a C/C++ rewrite and should be understood as such.
Contact us today to discuss how we can get started with a complete code rewrite!
Example Use Case for Complete Code Rewrites
An aircraft manufacturer relies on a legacy Fortran codebase to perform computational fluid dynamic (CFD) simulations for aircraft wing designs. While the Fortran implementation has been optimized for numerical precision and computational efficiency, it has become increasingly difficult to maintain due to its monolithic structure, lack of modularity, retirement of key contributors, and limited implementation of modern software development practices. To address these issues, the business meets with us, and together we decide to rewrite the codebase in C++.
Rewriting the application in C++ offers several key advantages:
GPU Acceleration: While Fortran supports GPU acceleration through libraries like CUDA Fortran, C++ generally offers broader support for GPU programming frameworks such as NVIDIA CUDA and AMD's HIP. These frameworks have robust ecosystems with extensive documentation and toolsets. They enable fine-grained control over GPU resources, making C++ the preferred choice for applications requiring large-scale parallelism or cutting-edge hardware optimization. However, not all computations are accelerated by processing on the GPU, so careful consideration must be made before employing it.
Maintainability: Modern C++ features such as smart pointers, templates, and type safety facilitate better software design practices. These features allow developers to write maintainable code that is easier to debug and extend. Additionally, transitioning to a modular architecture in C++ enables developers to isolate specific components of the code (e.g., turbulence models or boundary condition solvers), so updates and improvements can be made incrementally without affecting the entire system.
Extensibility: Rewriting in C++ establishes a solid foundation for future development by integrating with advanced software engineering practices and third-party libraries such as Eigen for linear algebra and Boost for general utilities. Additionally, leveraging modern build systems like CMake enables more robust project configuration, dependency management, and cross-platform compatibility. Tools like vcpkg further enhance extensibility by simplifying the process of managing external libraries, ensuring consistent builds across diverse development environments. These features collectively make it easier to add new functionality, adapt to emerging requirements, and integrate with other modern frameworks without requiring a complete redevelopment.
Python Bindings: Python bindings can also be added to the new C++ implementation using tools like Pybind11. This allows engineers and data scientists who are unfamiliar with C/C++ to interact with the high-performance core of the application from Python scripts. For example, they could run simulations using Python-based workflows using Matplotlib for visualization or Pandas for post-simulation data analysis. These bindings provide ease of use without sacrificing computational efficiency at the core.
Future-Proof Your Software Infrastructure
Modernizing your legacy systems doesn’t have to mean sacrificing their core strengths. At Astradian Technologies, we help you bridge the gap between the computational power of Fortran and the evolving demands of modern software platforms. Whether your goal is interoperability with new technologies or a complete transition to a different programming environment, our team delivers solutions designed to maximize value while minimizing disruption.
Do you have a legacy Fortran codebase that needs modernization? Let’s discuss how we can help you preserve performance while embracing innovation. Contact us today for a free consultation!
Contact us Today!
Our Customers