Q:

Get executable name during runtime

Using the pgf90 compiler, is it possible to get name of the executable during runtime? It would be nice to save this information in the output, together with the svn revision number (this is already implemented and done during the preprocessing).
thanks

A:

Fortran 2003 introduced GET_COMMAND_ARGUMENT. Besides getting the command argument, it allows to retrieve the command name by which the program was invoked. This is passed in argument number 0. Perhaps your compiler is recent enough to support it. The exact text of what is passed in the argument depends on the compiler. 

program cmd_name
     character :: cmd*100
     call get_command_argument(0, cmd)
     print *, "command name : " // cmd(1:len_trim(cmd))
end program

with Ifort 13.1 on Windows, this prints:
 command name : cmd_name

