Specifying command line arguments via the PROGRAM statement

Yes, as a minimum I was inquiring about adding arguments to the PROGRAM() directive that define a special namelist that is read from the command line, but allowing in particular for strings to be detectable as such as the compiler could easily know the type of the parameter.

I have used exactly the method you describe, dating back to before this:

and that is dated 2009, as well as on the Fortran Wiki, this forum, and a couple of github sites, so no argument there :slight_smile:

But the command line and NAMELIST are basically used to define a simple table, typically consisting of at least

NAME VALUE TYPE DEFAULT

often supplemented with a DESCRIPTION, CONSTRAINTS ON VALUES, and so on.

So whether you say "cmd 10,20,“title” (CDC NOS) “A=10 B=20 TITLE=“title” cmd” (bash), “cmd -a 10 -b 20 --title ‘title’” (getopts_long) or “cmd /A=10 /B=20 /TITLE=‘title’” you are in most common cases just defining that table. I think it would be great and reasonable to impliment that using existing NAMELIST rules as you describe; but think it is plausible to define filters to convert those other formats too;
and am wondering what the general interest is. I use a non-public preprocessor to do that now using that syntax except you use $PROGRAM instead of PROGRAM, so I like the preprocessor approach, but as a second choice dependent very much on a standard preprocessor being defined; but would prefer it being part of the Fortran specification.

I generate hundreds of frequently small programs so having a simple accessible way of providing command line options (even using TUI and GUI interfaces) is particularly appealing to me, but I know many cases where someone is working on a single program for whom that may not be nearly so much a glaring hole in the Fortran language (and many other languages as well). I think it would be nice for Fortran to provide such a simple but useful interface as part of the language.