CLFORTRAN – Pure Fortran Interface to OpenCL

CLFORTRAN is an open source (LGPL) Fortran module, designed to provide direct access to GPU, CPU and accelerator based computing resources available by the OpenCL standard.

While being a professional tool, CLFORTRAN aims to simplify integration of GPU resources for scientific computing in various fields of science that heavily relies on Fortran codes:

  • Climate Modeling
  • Seismic Processing
  • Particle Physics
  • CFD and other simulations



CLFORTRAN was developed as a byproduct of a PRACE project.
During the project development cycle it was recognized that current solutions are very limited when one needs to integrate GPU support into a cluster scale system with large code base (e.g. climate modeling or particle physics), combining OpenMP and MPI.

Up until today, the main approaches for utilizing the GPGPU from a Fortran application were:

  1. Write main GPU code in C/C++ and a simple interface to Fortran (both CUDA and OpenCL APIs are written in C)
  2. Writing an intermediate wrapper for OpenCL functions in C/C++ (FortranCL)
  3. Use an automated tool to transform Fortran code to C, such as with OpenACC, PGI or CAPS.

Both approaches were proven to be limited:
Writing C/C++ codes to interface the GPU, introduces a design complexity and the problem of maintaining different programming languages it the same code base, making sure that mixing C and Fortran compilers will not break functionality (also considering future updates).

On the other hand, automatic tools are eventually limited due to the functionality they offer and also by means of performance. Even if they are of choice for most users, there are occasions in real-life when the OpenCL flow has to be written directly.

Taking advantage of recent Fortran language features, CLFORTRAN is implemented in pure Fortran (no C/C++ code involved). Therefore, it allows scientists to add GPU capabilities nativeley to a familiar Fortran environment.

Providing complete access to OpenCL API, the module is standard conformant, written in simple Fortran and maintains the same functional signature as in C/C++, to allow knowledge reuse and greater flexibility.


  • Full access to OpenCL API from Fortran applications
  • Pure Fortran implementation – No need for C/C++ codes or compiler support
  • OpenCL standard conformant, up to 1.2 *
  • Open Source and free for commercial use


CLFORTRAN is licensed under LGPL v3.

Compiler Support

The following list contains compilers the module was tested and developed with. Other vendors may be supported as well, but there is no formal compatibility.

  • GNU Fortran
  • Intel Fortran
  • IBM XL Fortran

Minimum Requirements: A Fortran 2002/2003 compatible compiler.

Download / Obtain a Copy

CLFORTRAN is now hosted publicly on GitHub.


Please refer to the GitHub repository for additional resources.
We hope to add more examples soon. Contributions are welcome.