Skip to content

Why did I get an error message saying "Error unrecognised option" when I give a negative number on the command line?

Grossfield Lab edited this page Apr 22, 2020 · 1 revision

This is a common problem, and relates to our use of the BOOST program_options library to implement our command line argument processing. Basically, when you get something like

user%1  water-sides --selection 'name == "O"' dpt-new1.prmtop dpt_new.inpcrd -20 20
Error- unrecognised option '-20'

because the underlying code is foolishly trying to parse the -20 as if it were a flag to the program. This can happen any time you have a negative number as a mandatory command line argument (one without a flag in front of it).

Happily, there's an easy solution. You can tell LOOS that you're finished supplying flags by including -- between the flags and the mandatory fields, like this:

user%1  water-sides --selection 'name == "O"' -- dpt-new1.prmtop dpt_new.inpcrd -20 20

However, to do this you have to specify all of the flagged options before you get to the positional options (the mandatory ones that don't take a flag).