Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get executable name during runtime

Tags:

fortran

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

like image 812
Raphael Roth Avatar asked Jul 12 '26 08:07

Raphael Roth


1 Answers

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
like image 143
Johny Bergmann Avatar answered Jul 15 '26 17:07

Johny Bergmann