FLAP, the Fortran command line arguments parser, has reached v2.7.0. With v2.6.0 from earlier, this release makes a FLAP program easy for other programs to call: workflow managers, Python scripts and AI agents. You describe the command line once, as before, and FLAP now answers in a form a machine can parse: what the program accepts, whether a command line is valid, and what to change when a call fails.
Everything new is opt-in. A program that uses none of it keeps its help, its errors and its exit statuses (--check is the one exception, below).
For anyone new to FLAP, here is a whole program’s session: its help, some values, a typo and an out-of-range value.
See it run: a program answering another program. It prints its JSON description, rejects a command line with --check, writes a JSON error and an exit status, and does a dry run:
The same session is on the home page, and chapter 10 of the tutorial builds it step by step.
val_type='I4P' (or R8P, logical, …), parse checks a value, its choices and its range before the program starts, whatever its source: command line, environment or configuration file. Without it, a bad value surfaces only at get, possibly hours into a run.--schema. prog cmd --schema describes a single command, so an agent need not read the whole program.--check. init(error_format='json'), or an environment variable you choose, writes each error as one line: code, message, option at fault, suggestions (“did you mean”), and a class.stop cli%exit_status() ends with 2 when the command line is wrong (fix and retry), 3 when a file or variable is wrong, and 4 when the program itself is wrong (do not retry). Status 1 stays yours.--dry-run. cli%is_dry_run(); skipping the side effects is your program’s job, and the docs say so plainly.save_provenance writes the command line and every value with its source as JSON. It contains no date, host or directory, so the same inputs give the same bytes.sensitive=.true. masks a token as *** in the manifest, the help, the description and the error messages.save_skill writes a SKILL.md (
On the skill, a measurement rather than a promise. I gave a small model the same task six times on a two-command program, three times with the generated skill and three without: 5.0 calls on average with it, 5.7 without, no failed call either way, and about the same tokens. Six runs prove nothing, but they suggest a program with a good --help already serves an agent that knows about it. The skill’s real case is an agent that has not yet heard of your program. The first version of the file did worse than none: every failed call was prog cmd --check, which is why that spelling now works. The numbers are in the guide.
FLAP itself stays pure Fortran: everything above is plain text on standard output and standard error, which any caller can read in any language. The documentation shows one such caller, a short Python script on the other side of the pipe. It is an example of a caller, not part of the library. There is no MCP server in the library either, on purpose: a well-described CLI is (generally) cheaper for an agent and has fewer moving parts. Integrating an MCP server is currently out of my scope, but it could be done in opt-in mode if someone needs it.
--n /, --n 2*5 and --n 3 abc were taken by Fortran’s list-directed read: no error, and a wrong or unassigned value.2.5 was read into an integer as 2, and an integer overflow wrapped silently. Both are now errors.set_mutually_exclusive_groups reports an undefined command instead of ignoring it.heat solver, and the get_varying and add_group, which was wrong for a positional call, along with five other statements the code contradicted.reset_parse.
The details are on the upgrade page. FLAP is pure Fortran 2018. The suite passes with gfortran 13 to 16 and with nvfortran 26.9, and FLAP builds with FoBiS, fpm, CMake or Make. It is multi-licensed: GPL v3, or BSD 2/3-Clause or MIT for closed-source and commercial use.
Feedback is welcome, especially from anyone already driving Fortran code from scripts or agents.
Kind regards,
Stefano
I’ll reword the licensing system to make it clearer.