Search code examples
gccpathfortran

I compiled a program in fortran using GCC but the executable outputs files to the user path of my system instead of where the program is located


The program is placing the files to the path Users/username/ instead of the Oil and Cells folder. Can I fix this issue with the compiling command?

I used gfortran -o Planar_Surfactant Planar_Surfactant.f while inside of the Oil and Cells folder to compile the executable.

~ % /Users/username/Documents/BMEN\ Research/Oil\ And\ Cells/Planar_Surfactant ; exit;

this is what shows up when I run the program along with some information about the base values.


Solution

  • Paths in the program are relative to the current working directory, which starts off as the directory where the program is launched, not where the program binary happens to be located.

    (This is per se not specific to Fortran.)