Is there a way to find at runtime, the absolute path of the executable?
‘getcwd’ will get you the current working directory. Though, this may or may not be where your program is located.
‘call get_command_argument(0,exename)’ will get you the name of the exe, but if you run it locally, it wont give you the full path the the exe (unless the exe is invoked with the full path).
Perhaps, we can combine the two?
:/tmp/args$ cat test.f90
character*80 :: me, mydir
integer :: scanVal
logical :: back=.true.
scanVal = scan (me, '/', back)
if (scanVal .gt. 0) then
print *, me, mydir
end program test
/tmp/args$ pgf90 test.f90 -o testargs.out
If you’re using C, then getcwd is the same but use ‘argv’ for the exe name.
I have some .so libraries together with my application in the same folder, but unfortunately the command ‘dlopen’ doesn’t work with relative path but works only if i give the full path. I don’t know why this is happening.
dlopen searches the paths included in the “LD_LIBRARY_PATH” environment variable. Try setting “LD_LIBRARY_PATH” to the path where your shared libraries are located.
Hope this helps,