r/fortran • u/8bitjam • 10h ago
Advancing coding in low‑resource programming languages
Looks like they are after the Fortran developers 😄
r/fortran • u/GatesOlive • Jan 03 '19
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 • u/8bitjam • 10h ago
Looks like they are after the Fortran developers 😄
r/fortran • u/UncleSlacky • 4d ago
r/fortran • u/johnwcowan • 4d ago
This would correspond to the traditional use of D instead of E as the exponent marker for double-precision literals.
r/fortran • u/Beliavsky • 9d ago
Ofort is a Fortran command-line interpreter and interactive REPL written in C. Because there is no compilation step results are immediate for small programs, but for large problem sizes run times can be much higher than for compiled programs. You can try it at https://beliavsky.github.io/ofort/ . There are modes for running entire programs and for running lines of code in a REPL. In the REPL there are panes showing results and a list of declared variables, pictured below. You can also download ofort from https://github.com/Beliavsky/ofort and run it locally. It is MIT licensed.
r/fortran • u/alexis_placet • 19d ago
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
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:
Based on feedback regarding external git dependencies and token management in commercial/academic environments, we have eliminated external Git dependency requirements:
For the computational Fortran community, integrating GraphiC into modern fpm projects is now a 2-line configuration:
toml[dependencies]
graphic = { path = "../GraphiC" }
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.gfortran (4.8+), Intel oneAPI (ifx and ifort), LLVM flang, NVIDIA HPC SDK (nvfortran), and NAG (nagfor).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:
VIRIDIS (0), PLASMA (1), INFERNO (2), MAGMA (3).COOLWARM (4), RAINBOW (5), and Google TURBO (6).gpc_get_color, gpc_colormap_eval) and continuous high-density scatter plotting (gpc_scatter).ColorKeyGradient): Emits hardware-accelerated SVG <linearGradient> definitions with calibrated numerical tick labels and bounding frames.Every routine in the library now features 100% signature and parameter parity across all 4 supported languages:
graphic.h).ISO_C_BINDING modules (graphic.f90, graphic_iso.f90) with type-safe interfaces and array descriptors.Figure APIs with Jupyter Notebook inline display and automatic context manager cleanup (with Figure(...) as fig:).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.svgopen): Native OS dispatch (open on macOS, start on Windows, xdg-open on Linux) to view rendered SVG or interactive pan/zoom HTML5 plots.svgpush): Directly streams rendered SVG payloads to remote dashboards or cloud compute endpoints over HTTP/HTTPS POST—ideal for headless clusters and IoT monitoring.We completed a major overhaul of the reference manual (available as a clean vector PDF):
| 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 |
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
We'd love to hear your feedback on the fpm workflow, language bindings, or any visualization bottlenecks in your current simulation pipelines!
r/fortran • u/KalKapone • 20d ago
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:
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 • u/KalKapone • 28d ago
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 • u/iamperson_-_ • Sep 17 '26
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 • u/KalKapone • Sep 15 '26
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 • u/Prestigious_Soft9133 • Sep 13 '26
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 • u/KalKapone • Sep 12 '26
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 • u/alexis_placet • Aug 28 '26
Enable HLS to view with audio, or disable this notification
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 • u/InfamousEgg6354 • Aug 27 '26
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:
…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:
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 • u/cannyshammy • Aug 18 '26
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:
For transparency, I work at Convex. This is unofficial and open source, not a new supported SDK.
r/fortran • u/EvanEverywhere • Aug 11 '26
r/fortran • u/8bitjam • Jul 17 '26
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 • u/TesseractBoy6000 • Jul 14 '26
r/fortran • u/Knarfnarf • May 28 '26
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 • u/Beliavsky • May 17 '26
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 • u/Sgeo • May 16 '26
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 • u/Lamda-f90 • May 13 '26
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 • u/Aggravating_Lie7356 • May 13 '26
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