Skip to content

Notes on Fortran

This page contains my personal notes on subjects related to Fortran which I find interesting and write down over time. It is a work in progress and subject to constant change.

Jupyter Notebooks

Some interesting things I collect over time.

  • pointerassignment.[ipynb|html] - what does => (equals greater than) mean in Fortran? .
  • implicit.[ipynb|html] - Fortran 2018 implicit none (external | type) .
  • csv.[ipynb|html] - example of using CSV files in Fortran.
  • flang-aarch64.[ipynb|html] - example of the Flang compiler (and Jupyter) running on a smartphone using Termux. The processor is the Snapdragon 617 octa-core ARMv8 Cortex-A5HTML3 64-bit.
  • fortran-assembly.[ipynb|html] - shows the assembly code generated by the gfortran compiler.
  • small-executable.[ipynb|html] - some exercises to try to better understand the creation of executables by a compiler. Some code snippets that I collect over time.
  • snippets.[ipynb|html] - some code snippets that I collect over time.

About Fortran

Fortran is one of the first programming languages and over time it has been improved and updated, and today it can be considered a modern programming language, including support for object-oriented programming (type extension and inheritance, polymorphism, dynamic type allocation, procedures linked to type), and support for parallel programming (coarray, looping , array assignment, vectorization help, etc.). It is a productive, relatively small, high-level language that is easy to learn and use, allowing programmers to focus on the program's algorithm without having to worry about too many technical details. An important feature is that it generally produces fast code, sometimes as fast as C, without the need to resort to low/medium level languages. An interesting detail is that Python/Numpy/F2PY has good integration, allowing you to use Fortran in parts that require performance, and in this way trying to combine the best of both worlds, especially when using Python's interactivity and easy prototyping features. Fortran is used in various areas of science and engineering, such as numerical prediction of climate and oceans, computational fluid dynamics, applied mathematics, statistics and finance, high-performance computing and supercomputers.

Fortran 2023

Fortran 2018

JTC1/SC22/WG5, Fortran 2018, ISO/IEC 1539:2018

Fortran 2008

Considering that F2018 is a small revision of F2008, then most of the features are the same.

Intel Fortran

Intel oneAPI Toolkits are available at no cost and do not require license files. Includes ifort Intel Fortran Compiler Classic (Full 77, 90, 95, 2003, 2008, and 2018), and ifx Intel Fortran Compiler Beta (Full 77, 90, 95, and partial 2003). ifx uses the LLVM back-end technology and is released as a Beta version for users interested in trying Intel Gen9 GPU offloading, which ifort does not support.

NVF

NVIDIA CUDA Fortran compiler and tool chain, former PGI compilers, supports F2003 and many features of F2008, CUDA, SIMD vectorization, OpenACC and OpenMP for multicore x86-64, Arm, and OpenPOWER CPUs.

F2PY

  • F2PY provide a connection between Python and F90 languages, and allows you to bring together the best of both worlds. It is not a replacement for the F90, it is just a way to take advantage of the rapidly developing features of the Python ecosystem, and in this way without having to reinvent the wheel. https://numpy.org/doc/stable/f2py/
  • Perhaps the best way to use it is in conjunction with Jupyter Notebook, as in this example (note the use of both languages): https://gist.github.com/shane5ul/79340646ba0a4487c9da50b805215369

Assembly

For debugging and optimization purposes it is important to know the "assembly" language generated by a compiler. I have some assembly notes in a separate documentation.

Videos of interest

Selected books

(click on the book picture to see more details)

Other works

  • My version of PARF (Parallel Random Forest) algorithm, MPI-enabled, compiled with Intel Fortran 2021.2 .


Last edited: 2025-01-16