Skip to content
Hani Andreas Ibrahim edited this page Apr 4, 2022 · 11 revisions

Welcome to the WIKI of f90getopt

f90getopt is developed as an easy to learn and compact library in one source file for modern Fortran to parse GNU- and POSIX-style command-line options.

It is leaned on getopt()- and getopt_long() functions of C but there are differences (refer README.md for details). The f90getopt.F90 file can just be added to existing sources and deployed with them without dealing with dependencies. You can "learn" f90getopt in minutes and therefore it is even suitable for very small projects or "throw-away-code".

A little bit history

I used for parsing GNU/POSIX-style CLI options in Fortran the SNG library of the University of California before. It is compatible with even some non-standard Fortran 90 compiler CLI extentions. But after some gfortran upgrades it did not compile SNG anymore. I could not find the problem fast enough so I was looking for an alternative. I looked for an easy to learn library for modern Fortran without spending lots of time for learning its usage.

I found the tiny and nice f90getopt module from Mark Gates, licensed under GPL 2.0. It had not all features I wanted but almost all of them and some less other minor issues. I added the missing functions fixed the issues and here we are. I have to give credit to Mark Gates for his great work (Unfortunately his homepage is down for years). As I looked a little bit later, after I finished version 1.0.0 of f90getopt, SNG was updated and compatible with the latest gfortran compiler again. But lately I had some trouble to open the SNG-webpage but the version of October 2016 can be accessed via Wayback machine. SNG is still in use in my sampleSTAT 1.2.0.

Get started

Enough history. To get started I recommend the wiki-pages Get started or if you in a hurry just refer the full working and documented sample program.

If f90getopt does not fit your needs you will find more alternatives at Fortran Wiki.

Have fun.