Fortran Relational Database A developer has created sqr, a self-contained relational database written entirely in Fortran, using Claude Opus 4.8 to generate approximately 13,000 lines of code. The engine supports indexed, transactional, crash-safe local storage for Fortran programs without requiring external libraries or database servers. It is designed for small-to-medium workloads and has been tested across multiple compilers including gfortran, ifx, and flang. Fortran Relational Database This is a self-contained relational database written entirely in Fortran, see the README below for details. All the code has been written by Claude Opus 4.8 - about 13k lines in total including about 5.6k for the engine. My contribution has been the overall design, style, refactoring, testing requirements, clean builds, platform requirements and code reviews. It has had many reviews for which I used Codex, Antigravity, Fable 5 as well as Opus 4.8 in ultrathink mode. We even found a bug in gfortran 125866 which is being fixed. All development was done on Linux Mageia 9 . Both ‘make’ and ‘fpm’ can be used to build it and FORD documentation is included. It is known to build and run on Linux with ifx 2026.0.0, gfortran 16.1.0, flang 23.0.0git ; on Windows with mingw64 and tested with Wine in podman So where might this be useful? In keeping with the development I asked Claude: A Fortran program that needs indexed, transactional, queryable local storage — but doesn’t want to leave the language, link C/SQLite, or stand up a database server. Anywhere you’d currently reach for ad-hoc flat files, unformatted dumps, or a fragile NetCDF/CSV scheme, sqr offers indexed lookup + crash-safety instead. Abridged README.md sqr is a lightweight, embeddable relational storage engine written entirely in modern Fortran. It stores tables as fixed-record binary files in a directory, with on-disk B+tree secondary indices, a physical rollback journal for crash-safe transactions, and two interactive front-ends — a state-graph shell sqrsh and a small SQL-subset REPL sqlsh . It is deliberately scoped for the small-to-medium workloads a single program needs 10⁴–10⁶ rows , not for postgres-scale concurrency. Access is single-writer / multi-reader : an advisory lock admits one read-write connection or any number of read-only ones at a time — there is no concurrent-writer per-row / MVCC isolation. The design goal is integrity first : every mutation is write-ahead journalled and survives a crash, even at the cost of an fsync per write. DT INT 32-bit , DT REAL 64-bit , DT CHAR DT TEXT length-prefixed blob, binary-safe . b tree module is fully decoupled from sqr and is ADD COLUMN / DROP COLUMN by table rewrite, with DROP cascading to dependent db begin / db commit / db rollback , SQR LOCKED , db set readonly demotes a writer to let readers in. error stop in library code stat / errmsg arguments. db insert db, ... or db%insert ... . sqrsh , a cmdgraph state-graph shell over the engine, sqlsh , a small SQL subset a separate sql front-end layer that ifx and gfortran , builds under fpm , and use :: sqr type db t , target :: db type column t :: cols 2 character len=: , allocatable :: buf integer :: st, ti integer int32 :: rid call db open db, 'mydb', stat=st a database is a directory cols 1 %name = 'id'; cols 1 %dtype = DT INT; cols 1 %csize = 4 cols 2 %name = 'name'; cols 2 %dtype = DT CHAR; cols 2 %csize = 32 call db create table db, 'people', cols, st ti = db table index db, 'people' call row alloc buf, db%tables ti %record size call row set int buf, db%tables ti %cols 1 , 1 int32 call row set char buf, db%tables ti %cols 2 , 'Ada' call db insert db, 'people', buf, rid, st rid = new row id call db create index db, 'people', 'id', st on-disk B+-tree call db find by int db, 'people', 'id', 1 int32, rid, st call db close db, st Wrap a group of changes in an explicit transaction when you need them to commit and fail as a unit: call db begin db, st ... several inserts / updates / deletes ... call db commit db, st durable here; or db rollback db, st sqrsh shell sqrsh is a small state-graph REPL over the engine. The command set: root: open