Fortran Wiki
Command-line arguments

Fortran 95 and earlier had no standard support for obtaining command-line arguments. However, with Fortran 2003, several new standard procedures were added to help parse command-line arguments: get_command_argument, get_command, and command_argument_count.



  • FLAP a Fortran command Line Arguments Parser for poor people. A KISS pure Fortran Library for building powerful, easy-to-use, elegant command line interfaces.

  • M_CLI2 use a command prototype to define and read command-line arguments including support of response files for abbreviating command calls with many options

  • M_CLI use a command prototype to define and read command-line arguments and leverages NAMELIST so no type conversion from strings is required

  • getopt_long_module by Joe Krahn.

  • f90getopt by Mark Gates is no longer available under But Hani Andreas Ibrahim forked the module and provides an extended version in GitHub. It parses GNU- and POSIX-style CLI-options with and without arguments. Just one module and can be learned in minutes. Wiki, sample program provided.

  • kracken is an open-source library for parsing Unix-like command-line arguments. It is now provided in Github in the General-Purpose-Fortran library (GPF) with a lot more functions than CLI option parsing. It is also available on github as an fpm(1) package M_kracken, as well as an older stand-alone version at M_kracken95.

  • module options

  • CLAF90 is a f90-module for parsing command line arguments. Note the original location is no longer accessible.

  • fargParse, part of the Goddard-Fortran-Ecosystem

  • paramcard command-line parameter input made simple, by Takahiro Ueda

  • cmdff

  • command_args from arjenmarkus

  • FTN_Getopt by Reinhold Bader

  • libsim libraries from ARPA-SIMC include a general purpose library with many modules including parsing command-line arguments.

  • libSUFR by MarcvdSluys

  • get_namelist shows using NAMELIST groups to crack the command line

  • argv-fortran a better GET_COMMAND_ARGUMENT() for Fortran that returns the argument in an allocatable character string, by Jacob Williams

  • f2kcli is an implementation of the Fortran 2003 command line interface for compilers which do not support Fortran 2003.

  • Fortran code on github is a general list of Fortran code that includes packages with command-line parsers.

Wrappers around C libraries are an alternative approach. Some example candidates …