Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

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

Status
Not open for further replies.

Denial

Structural
Joined
Jun 3, 2003
Messages
932
Location
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?

 
You would need to add the programs install directory to the users system path variable.

This is an operating system hurdle and less so a hurdle for your specific program.

I'm making a thing: (It's no Kootware and it will probably break but it's alive!)
 
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!)
 
About a week ago I posted this query on the Fortran group of the Eng-Tips site.[ ] A contributor there, Mikrom, provided me with a solution.[ ] This involves using a C routine that he developed and linking it in with the Fortran of the main program.[ ] See
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top