get the first argument from the command line, this is expected to be a filename
Usage: filename = get_first_arg_from_command_line()
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
character(len=255), | private | :: | arg | ||||
integer(kind=default_int), | private | :: | num_args |
function get_first_arg_from_command_line() result(filename) !! get the first argument from the command line, this is expected to be a filename !! !! Usage: filename = get_first_arg_from_command_line() !! character(len=255) :: filename character(len=255) :: arg integer(default_int) :: num_args num_args = command_argument_count() if (num_args < 1) then write (*, "(A)") "Usage: ./my_executable <filename>" stop 1 end if call get_command_argument(1, arg) filename = trim(adjustl(arg)) end function get_first_arg_from_command_line