r/fortran • • Jan 03 '19

I'm curious, what do you use Fortran for currently?

91 Upvotes

As the wide majority of programmers I talk to considers Fortran to be a dead language, I'm curious of what you are all doing with it.

I'll start by saying I learned it in University in 2009 and taught it from then on to new freshmen.

Thanks!


r/fortran • • 2d ago

From Punch Cards to the Browser: Fortran Comes to JupyterLite

Thumbnail
blog.jupyter.org
31 Upvotes

Some weeks ago I shared a post about using Fortran into JupyterLite. Here an blogpost about it.
You can now try it easily here: https://notebook.link/@anutosh491/fortran


r/fortran • • 2d ago

Update: GraphiC 2026 (Zero-Dependency Scientific Graphics) — Standalone ZIP Distribution, Native fpm Workflow, Continuous Colormaps & 4-Way Language Parity (C, Modern Fortran, Python, Java)

20 Upvotes

Hi everyone,

Following up on our earlier discussion about modernizing GraphiC (the lightweight scientific plotting engine originally developed at Oak Ridge National Laboratory and Scientific Endeavors Corp), we wanted to share a major progress update, architectural changes based on community feedback, and the release of GraphiC v7.3.0.

The core design philosophy remains unchanged: zero external dependencies (pure standard libc/libm—no Qt, OpenGL, X11, Cairo, or FreeType), sub-2ms cold-start latency, and an ultralight footprint (~655 KB static library) capable of rendering thousands of publication-grade figures per minute directly in-process from simulation codes.

Here is what's new in the latest release:

1. Simplified Standalone Distribution (No Git / Token Friction)

Based on feedback regarding external git dependencies and token management in commercial/academic environments, we have eliminated external Git dependency requirements:

  • Standalone ZIP Archives: Both the free GraphiC 2D Community Edition and GraphiC Professional are distributed as self-contained downloadable ZIP archives.
  • Local Repo Freedom: Unpack it into your workspace or project tree. Users can initialize their own internal Git repositories if desired without worrying about remote access tokens, submodules, or network firewalls on compute clusters.

2. Native Fortran Package Manager (fpm) Integration

For the computational Fortran community, integrating GraphiC into modern fpm projects is now a 2-line configuration:

toml[dependencies]
graphic = { path = "../GraphiC" }
  • Automated Mixed-Language Builds: fpm automatically compiles both the core C engine and the Modern Fortran 2003 ISO_C_BINDING module together—Fortran users do not need to run a C compiler manually or write build glue.
  • Broad Compiler Support: Out-of-the-box compatibility tested across GNU gfortran (4.8+), Intel oneAPI (ifx and ifort), LLVM flang, NVIDIA HPC SDK (nvfortran), and NAG (nagfor).
  • Instant Execution: Run included scientific examples immediately with:bashexport GPC_NONINTERACTIVE=1 fpm run --example sample fpm run --example bess3d

3. Continuous TrueColor Scientific Colormaps

Vector plots can have perceptually continuous shading due to our adoption of the SVG format. We have added 7 mathematically calibrated, continuous 256-node colormaps designed for perceptual uniformity across displays, print, and grayscale reproduction:

  • Perceptually Uniform: VIRIDIS (0), PLASMA (1), INFERNO (2), MAGMA (3).
  • Diverging & Spectral: COOLWARM (4), RAINBOW (5), and Google TURBO (6).
  • O(1)O(1)O(1) Fast Evaluation: High-throughput scalar-to-color mapping (gpc_get_color, gpc_colormap_eval) and continuous high-density scatter plotting (gpc_scatter).
  • Linear Vector Gradient Color Bars (ColorKeyGradient): Emits hardware-accelerated SVG <linearGradient> definitions with calibrated numerical tick labels and bounding frames.
  • Turbulence Showcase: Added shaded graduated color test plot rendering 7,850 experimental points shaded by density.

4. True 4-Way Language Parity (C, Fortran 2003, Python 3, Java 22 FFM)

Every routine in the library now features 100% signature and parameter parity across all 4 supported languages:

  • C / C++: Clean ANSI C API with unified headers (graphic.h).
  • Modern Fortran: Strict ISO_C_BINDING modules (graphic.f90, graphic_iso.f90) with type-safe interfaces and array descriptors.
  • Python 3: Both procedural and object-oriented Figure APIs with Jupyter Notebook inline display and automatic context manager cleanup (with Figure(...) as fig:).
  • Java 22+: Modern Foreign Function & Memory (FFM / Project Panama) API—direct zero-overhead off-heap calls without JNI boilerplate.

5. Smart Vector Output, Auto-Cropping & Telemetry

  • SVG Auto-Cropping (svgcrop): Automatically calculates tight vector bounding boxes with a default 0.25" publication margin, eliminating oversized 8.5"×11" white space when embedding figures into LaTeX or papers.
  • Desktop Auto-Preview (svgopen): Native OS dispatch (open on macOS, start on Windows, xdg-open on Linux) to view rendered SVG or interactive pan/zoom HTML5 plots.
  • Headless Telemetry Streaming (svgpush): Directly streams rendered SVG payloads to remote dashboards or cloud compute endpoints over HTTP/HTTPS POST—ideal for headless clusters and IoT monitoring.

6. 263-Page Reconstructed Technical Manual

We completed a major overhaul of the reference manual (available as a clean vector PDF):

  • 91-Section Table of Contents: 100% clickable internal hyperlinking in all PDF viewers.
  • 203-Function Master Index: Every routine cross-referenced with operational level, source mapping, and multi-language parity status.
  • 26 Visual Computational Recipes: Step-by-step recipes covering aerospace queuing models, orbital trajectories, 3D Bessel surfaces, contour projections, and spectral waterfall plots.
  • Publication Architecture Diagrams: High-resolution vector diagrams detailing the dual typography pipeline (Hershey stroke fonts + TrueType quadratic Bézier engine).

Quick Comparison: Community vs. Professional

Feature 2D Community Edition (Free / Open Core) Professional Edition (Commercial)
License Standalone Free Archive Commercial Single-Seat / OEM
Core 2D Plotting Full (Linear, Log, Polar, Bar, Pie, Histograms) Full (Linear, Log, Polar, Bar, Pie, Histograms)
Typography 23 Hershey Vector Fonts + TrueType Bézier Engine 23 Hershey Vector Fonts + TrueType Bézier Engine
Continuous Colormaps Viridis, Plasma, Inferno, Magma, Turbo, etc. Viridis, Plasma, Inferno, Magma, Turbo, etc.
Language Bindings C, Modern Fortran, Python 3, Java 22 FFM C, Modern Fortran, Python 3, Java 22 FFM
Build Systems fpm, CMake, GNU Make, MSVC Makefile fpm, CMake, GNU Make, MSVC Makefile
Advanced 3D & Contours — 3D Hidden-Surface Meshes, Contours, Cross-Sections
Specialized Engineering — RF Smith Charts, Ternary Phase Diagrams, Waterfall Plots

Quick Modern Fortran Example (fpm)

fortranprogram quickstart
  use graphic
  implicit none
  real, dimension(100) :: x, y
  integer :: i
  do i = 1, 100
    x(i) = (i - 1) * 0.1
    y(i) = sin(x(i)) * exp(-x(i) * 0.1)
  end do
  call gpc_bgnplot()
  call gpc_svgcrop(0.25)
  call gpc_title("Damped Harmonic Motion", "Time (s)", "Amplitude (V)")
  call gpc_graf("0 2 10", 0.0, 2.0, 10.0, "-1 0.5 1", -1.0, 0.5, 1.0)
  call gpc_color(1)      ! Blue
  call gpc_curv(x, y, 100)
  call gpc_endplot()
  call gpc_svgopen("")   ! Launches default browser to view vector SVG
end program quickstart

Getting the Release

  • Official Website & Docs: https://jamesrome.com/GraphiC2026
  • Full Technical Manual: Download the 263-page GraphiC_Modern_Manual.pdf
  • Community Edition Download: Free standalone ZIP available on the site.
  • Professional Edition: Available via Lemon Squeezy with full 3D, specialized engineering modules, and more customization options.

We'd love to hear your feedback on the fpm workflow, language bindings, or any visualization bottlenecks in your current simulation pipelines!


r/fortran • • 3d ago

Why doesn't my Fortran stencil code scale past 2 threads? A short intro to roofline analysis (Jacobi / red-black Gauss-Seidel + likwid)

Thumbnail
loiseaujc.github.io
24 Upvotes

Latest post in my series on iterative solvers for the 2D Poisson equation in modern Fortran

Some context: my OpenMP Jacobi and red/black Gauss-Seidel kernels scale almost perfectly with threads on a 512² grid, but on 2048² the speed-up basically stops after 2 threads. Rather than guess, I built a roofline model of my laptop from three numbers measured with likwid-bench (peak flops, DRAM bandwidth, L3 bandwidth), and wrote it as a small parametric LP in sweeps/s.

What I found:

  • Both kernels have an arithmetic intensity of ~0.25 flop/byte, so they are memory-bound at both grid sizes. What changes is whether the working set sits in L3 or DRAM.
  • For 2048² on 8 threads, the model predicts 279 sweeps/s. Jacobi measures 272. Gauss-Seidel measures 219, and the gap is explained (plausibly, at least) by read-for-ownership traffic from the red/black stride, which brings the prediction down to 209.
  • The model is far from perfect. It drifts by up to ~50% for L3-resident Gauss-Seidel at high thread counts, and I had to hold the DRAM bandwidth flat rather than use the declining Triad curve. The post is upfront about both.
  • Bottom line: both kernels already run about as fast as the machine allows (5-7 Gflops/s vs ~483 Gflops/s peak). The remaining lever is temporal blocking, which I don't cover, or reducing the number of sweeps (SOR, next post).

I'm using likwid to the best of my understanding, so I'd really appreciate feedback from people with more experience, especially on the RFO accounting and on how to properly measure DRAM traffic with likwid-perfctr for these kernels. If you've done temporal tiling on stencils in Fortran, I'd love to hear how it went.


r/fortran • • 11d ago

Red/Black Gauss-Seidel: getting loop-carried dependencies to actually disappear (not just shrink)

Thumbnail
loiseaujc.github.io
28 Upvotes

A follow-up to my last post here on unrolling Gauss-Seidel for the 2D Poisson equation.

Short recap of where that left off: unrolling + algebraic rewriting cut the loop-carried dependency and got GS running 6x faster than the textbook lexicographic kernel, matching (and slightly beating) Jacobi in serial. Looked like a win. Then I turned on multithreading, and Jacobi pulled 5x ahead, because the unrolled GS kernel still couldn't be vectorized. The dependency chain was shorter, not gone.

This post goes back to basics: is the sequential dependency actually inherent to Gauss-Seidel, or just an artifact of how the grid points happen to be ordered? Answer: the latter. Red/black checkerboard ordering removes it almost entirely, derived not just by intuition (every red point depends only on black neighbors and vice versa) but formally, as an instance of block Gauss-Seidel on a permuted SPD system, with the usual convergence guarantees.

Results: loop-carried dependency effectively drops to nothing (confirmed via OSACA analysis of the generated assembly), SIMD vectorization comes back for free, and for the first time in this series GS actually scales with thread count right alongside Jacobi.

Also in there: walking through the compiler-generated assembly to see exactly why a kernel fails to vectorize (mnemonic-level, not just "the compiler didn't do it"), and using OSACA to quantify port pressure / critical path / LCD rather than just eyeballing it.

Link: https://loiseaujc.github.io/posts/blog-title/redblack_gauss_seidel.html


r/fortran • • 15d ago

How to loop through lines in a file

2 Upvotes

Currently, to run a Fortran file, I need to execute the line: file.exe number text in w64devkit. I need to loop through each line in a text file and run the code each time with a different input for text but same input for number. How do I automate this? Also, would it be possible to save all results to a csv file?


r/fortran • • 18d ago

Reducing Gauss-Seidel's loop-carried dependency from 12 to 2 cycles/element with loop unrolling (OSACA analysis)

Thumbnail
loiseaujc.github.io
48 Upvotes

Author here (again). Follow-up to an earlier post where I showed a Gauss-Seidel kernel converging in half the iterations of Jacobi but running 4-5x slower per sweep, due to a loop-carried dependency from the in-place update. This post uses OSACA (open-source static code analyzer) to measure that dependency in actual CPU cycles, then applies loop unrolling with an algebraic substitution to reduce it from 12 to 2 cycles/element, bringing per-sweep performance close to Jacobi's while keeping the faster convergence.

Also ran three separate compilation experiments (no optimization, -O3 without vectorization, -O3 with vectorization) to isolate what's actually driving the speedup. Short version: it's the reduced dependency letting the scheduler overlap work, not vectorization. Neither Gauss-Seidel kernel ever gets vectorized, with or without the flag. Happy to go into the Fortran, the assembly, or the OSACA workflow itself.

u/mylarmalediction: I guess this will answer you question about ILP vs vectorization as the source of the speed-up for Jacobi.


r/fortran • • 19d ago

I wrote a calculator in 77 million lines of Fortran. It doesn't compile.

Thumbnail
github.com
19 Upvotes

I wrote a calculator in Fortran. It supports exactly three operations:

addition, subtraction, and multiplication. Input range is 0 to 5000 for

both operands.

Instead of actually calculating anything, it uses a massive SELECT CASE

table. Every possible combination of inputs is hardcoded. There is no +

in the codebase that adds anything at runtime. No - that subtracts.

No * that multiplies.

It just looks up the answer.

The result:

75,091,301 lines of Fortran

73 modules, each ~43 MB

2x the size of the Linux kernel

I tried to compile it. My machine has 32 GB of RAM. It was not enough.


r/fortran • • 20d ago

Gauss-Seidel is faster than Jacobi. Or is it?

Thumbnail
loiseaujc.github.io
71 Upvotes

Author here. Started a series working through classic iterative solvers for the 2D Poisson equation in Fortran. This is actually the second post (the first one being on Jacobi). Here, I dig into a genuinely counterintuitive result: the convergence theory for Gauss-Seidel checks out (half the iterations vs Jacobi, confirmed numerically), but the actual wall-clock time is 4-5x worse. Turns out it comes down to a single line: updating the array in place instead of into a fresh buffer and the loop-carried dependency that introduces, which stops the compiler from vectorizing the loop at all. In an upcoming post, I'll actually show how an open-source static analyzer can help you figure this out, and how simple algebra can be used to unroll the kernel and get rid of this loop-carried dependency.

Happy to talk Fortran/gfortran specifics or the discretization itself.


r/fortran • • Aug 28 '26

Fortran now runs directly in your browser through Jupyterlite

Thumbnail
video
62 Upvotes

Anutosh Bath and Ondřej Čertík brought LFortran to Jupyterlite

There is a demo here: https://notebook.link/@anutosh491/fortran

source: https://lnkd.in/p/eR49Jve6


r/fortran • • Aug 27 '26

PRIK – Generate native Python bindings from Fortran (with editable API contracts)

5 Upvotes

Hi everyone,I’ve been working on an open-source tool called PRIK (Python Runtime Interop Kit) that generates native Python bindings from Fortran (and C) source.

Basic usage:

pip install prik
python3 -m prik my_module.f90 --out my_module

This produces an importable Python extension.

The main idea is that the Python API doesn’t have to mirror the native one. PRIK generates an editable `.pyi` contract that you can modify to:

  • rename procedures
  • turn them into methods
  • hide arguments
  • return native outputs as Python values
  • support overloads and callbacks

…all without changing the original Fortran/C code.

It currently supports modules, derived types (as Python classes), NumPy arrays, strings, allocatables, pointers, optional arguments, generics, callbacks, and more.

I’ve been testing it on real libraries rather than just toy examples:

  • BLAS (155 routines)
  • LAPACK (127 double-precision routines)
  • FFTPACK
  • MINPACK (including callbacks)
  • BSPLINE-FORTRAN (modern Fortran classes)

C support exists but is less mature (tested with libm and TA-Lib). Still alpha, so the API may change. Fortran support is currently much stronger than C.

Docs: https://pynumlab.github.io/prik/

GitHub: https://github.com/PyNumLab/prik

Feedback, bug reports, or “does this work with my code?” experiments are very welcome!


r/fortran • • Aug 18 '26

I got a realtime database subscription working from modern Fortran

31 Upvotes

Not sure how useful this is beyond the amusement value, but as part of an experiment making Convex clients in 100 programming languages, I ended up with a native Fortran client that can query, mutate and hold a realtime WebSocket subscription.

A few bits I found genuinely interesting:

- Deferred-length allocatable strings make assembling JSON much less painful than I expected.

- Results come back through compiler-enforced intent(out) arguments.

- A live update is exposed as a blocking convex_live_next call, which feels oddly natural in Fortran.

- ISO_C_BINDING is only used at the transport boundary. The Convex protocol and subscription state live in Fortran, with libcurl/OpenSSL handling the network plumbing.

It is built with GNU Fortran 14.2 and the HTTP and Live paths pass the shared conformance suite. It is still an educational experiment rather than something I would recommend putting into production.

The Fortran implementation and write-up are here:

https://github.com/mikecann/the-convex-100-language-challenge/tree/main/fortran

I also made a video about the slightly ridiculous process of building all 100 clients:

https://youtu.be/l61cLu8e2tg

For transparency, I work at Convex. This is unofficial and open source, not a new supported SDK.


r/fortran • • Aug 11 '26

The Past, Present & Future of Programming Languages • Kevlin Henney • YOW!

Thumbnail
youtu.be
11 Upvotes

r/fortran • • Jul 17 '26

Translated DGGES to Go

7 Upvotes

I’ve been working on my fork of Gonum and recently translated the Netlib LAPACK reference implementation of DGGES and its supporting routines into pure Go.
For transparency, I definitely used Codex and Claude Code throughout the process, and I’m pretty sure Gemini helped with a few parts along the way as well.
This wasn’t a blind translation. The majority of the work was understanding decades-old Fortran, preserving the algorithm, adapting it to idiomatic Go, validating numerical behavior, and tracking down subtle bugs.
I know AI-generated code can be a sensitive topic in open source. My view is that these tools are just that; tools. They can dramatically speed up tedious translation work, but correctness still depends on careful review, testing, and understanding of the underlying numerical algorithms.


r/fortran • • Jul 14 '26

Differentiable Fortran with LFortran and Enzyme

Thumbnail
docs.pasteurlabs.ai
48 Upvotes

r/fortran • • Jun 11 '26

SEI CERT Fortran Coding Standard

Thumbnail cmu-sei.github.io
7 Upvotes

r/fortran • • May 28 '26

Lottery win strategy

11 Upvotes

Hello all!

I quickly wrote this in response to a news article about a girl getting a lottery win and taking what I thought was the obvious choice; $1000/wk for ever...

Does this look right?

! Program Lottery Win
! Written by Knarfnarf
! Created May 19, 2026
! Version 0.1a
! Description: Checking my thoughts about winning the lottery.
program LotteryWin
use AnsiModule
implicit none

real :: Principle, Payments, Interest, Temp, Total, Paying
integer :: Year, Week

call ClearScreen()

Print *, "Lets see if the girl who took the 1000 per week will eventually break even..."
print "(a,$)", "Please enter the Principle: "
read *, Principle
print "(a,$)", "Please enter the Payments: "
read *, Payments
print "(a,$)", "Please enter the Interest: "
read *, Interest
Interest = Interest / 100
print "(a,$)", "And how much is she going to pay herself per week? "
read *, Paying

print "(3/,a)", "Assuming start at 20 and death at 85."
print *, ""

Year = 20
Total = Principle
do while(Year .le. 85)
Week = 1
do while(Week .le. 52)
Total = Total + Payments
Total = Total - Paying
Week = Week + 1
end do
Temp = Total * Interest
Total = Total + Temp
print "(a,i3,a,f0.2,a,f0.2)", "Year ", Year, " She made $", Temp, " interest and has $", Total
Year = Year + 1
end do

end program LotteryWin

Which results in this if she takes the $1000 per week, makes 4.5% yearly and splits it $500 income per week;
Year 85 She made $448,950.72 interest and has $10,425,633.00

Or this if she takes the $1000000, makes 4.5% yearly and pays herself $500 income per week;
Year 85 She made $337,680.91 interest and has $7,841,701.00

* commas added after for legibility.


r/fortran • • May 17 '26

Fortran For C Programmers

Thumbnail flang.llvm.org
41 Upvotes

I am posting this guide, from the developers of flang, because people, often with a C or C++ background, often ask how to get started with Fortran.


r/fortran • • May 16 '26

Snoopy calendar history?

11 Upvotes

There's a famous program that creates a "Snoopy" calendar.

https://gunkies.org/wiki/Snoopy_Calendar has a copy of a version modified by T. M. Kennedy in 1984.

Does the original version exist somewhere? Do we know who wrote it? I saw someone offering a copy on Github a few years ago but I don't know if that ever actually happened.

Incidentally, despite the comments in the modified version suggesting it should work on an IV compiler, it doesn't. After fixing the syntax error in snppic with INUM(I) in the do loop (easy to just do INUMI=INUM(I) first and use INUMI, the bound is sometimes -1. It encounters the issue where DO loops in some IV compilers execute at least once (66 says the scenario is not allowed, I guess that's FORTRAN-speak for undefined? 77 says the loop occurs 0 times). Easy to change the condition above it from IF (INUM(I) .EQ. 0) GOTO 40 to IF (INUM(I) .LE. 0) GOTO 40


r/fortran • • May 13 '26

Here is some code examples for new Fortran programmers.

56 Upvotes

A request for help led me to go through my old Fortran codes. For that reason, I gathered some old programs I found in this repo: https://github.com/foxapiens/Fortran-Starter . And maybe I will continue adding code files and information about their purpose here. At least, it may be useful for beginners.


r/fortran • • May 13 '26

Help regarding where to start fortran

35 Upvotes

Hi, so I have a background in c++ and matlab in programming. I started my phd and my prof asked me to move to fortran. I want to ask how should I start and where to start in fortran. At the moment I know nothing in fortran. Can you share some sources or material for me to start. Or where do you guys started. Thank you


r/fortran • • May 10 '26

Ofort: Small C-based interpreter for a practical subset of Fortran 90/95/2003, with a command-line interface

Thumbnail
github.com
11 Upvotes

r/fortran • • Apr 29 '26

libifcoremd.dll missing

6 Upvotes

Hello, I just got a new PC at work and they installed VS2026 and the fortran compiler. I create within VS2026 a simple Hello World exe. It runs within the VS IDE but when I try and run the exe I get the message that libifcoremd.dll is missing. I have looked and cannot find the damn thing. I did find a libifcoremd.lib. Can anyone help? (I did try and download a different fortran compiler but it wont work in VS2026)


r/fortran • • Apr 22 '26

Raindrop OpenGl

4 Upvotes

My puddle looks nice but i cant make a good looking raindrop anyone got any sugestions please. Rings on water also looks nice and the wind and the stormy rain but not the raindrop that is falling down to the puddle.

This just a little programing art nothing important trying to have some fun.

Using fortran 2018 and opengl 4.1+


r/fortran • • Apr 20 '26

Extending a direct file: portable?

4 Upvotes

Is it portable to extend the length of a direct file by writing records past the current last record? In other words, if there are 3 records in the file, will WRITE(n, REC=4) successfully write the record (assuming there is room on the disk, of course)? Or will it fail? Or is the result implementation-dependent?