Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

Determining a running Fortran program's "residence directory" 2

Status
Not open for further replies.

Denial

Structural
Jun 3, 2003
900
0
16
AU
As my recent posts on this forum attest, I am trying to get an old Fortran program to run on a modern Windows computer.[ ] Progress is slow but steady.

However I have struck an "interesting" little problem.[ ] My program's *.EXE file will reside in a directory that will be chosen by the end user, with different users choosing to store it in different places.[ ] Users will run the program from a "Command Prompt" window, by typing its name and its residence directory.[ ] Thus they might type:
»[ ] ProgName[ ][ ] (if the program resides in the current working directory or in a directory that is on the system's "path")
»[ ] D:\MySoftware\etc\etc\ProgName[ ][ ] (an absolute address for the residence directory)
»[ ] ..\ProgName[ ][ ] (if the program resides in the directory above the current working directory)

I am looking for a way for the program to find out the full name of its residence directory.[ ] Gfortran has a subroutine GETCWD(cwd) that returns the full name of the directory the user is "sitting in", but I have been unable to find a way to obtain the program's residence directory.

Does anyone know of a way to achieve this?

 
Replies continue below

Recommended for you

Thanks, Celt83.[ ] I suspected as much after my earlier amateurish searching threw nothing up.[ ] It is unfortunate, but I can live with it.[ ] (When I distribute my program - which will be downloadable by anyone via my website - there is no way I can mandate where a random user should store the program or the data the program will be acting upon.)
 
Possibly consider a batch script that will add the directory to the users PATH with instructions on when/how to run it.

I was able to find one post on stackoverflow with a similar question to yours and the folks there didn’t have much success, Link

I'm making a thing: (It's no Kootware and it will probably break but it's alive!)
 
Status
Not open for further replies.
Back
Top