COMMAND_ARGUMENT_COUNT() (Fortran 2003)

Purpose

Returns the number of command line arguments for the command that invoked the program.

Class

Inquiry function

Result type and attributes

Default integer scalar

Result value

The result value is the number of command arguments, not counting the command name. If there are no command arguments, the result value is 0.

Examples

integer cmd_count
cmd_count = COMMAND_ARGUMENT_COUNT()
print*, cmd_count
end
The following is sample output generated by the above program:
$ a.out
0
$ a.out aa
1
$ a.out aa bb
2