Topic: Debugging in a folder other than where a project is built

I just downloaded and installed SF today and found it very easy to set up, build and run my main research code by moving the executable into the "working directory" where all the data files are kept. The source code is kept in a different directory as well. I do it this way because I often work with several compilers at the same time and there is a project directory for each compiler, some of which have IDEs like SF. They all reference a single, separate source code directory. It's helpful to compile new or revised code with several compilers because they all seem to flag issues that a different compiler doesn't consider troublesome. The executables built with different compilers are distinguished with appropriate add-ons to the name, and I can quickly compare results from the different builds in the working directory.

This approach works well until I wish to use the debugger. It appears that in order to use SF's debugger I would need to create the SF project in the directory where I ultimately want to run the program, so the build and module directories would need to be there too, plus the makefile and project file. Is there an alternative that would allow me to keep development in one directory and use the debugger with the executable running in a different directory?

Eric

Re: Debugging in a folder other than where a project is built

Eric,

In order to use the debugger, yes, the development environment does need to know where the executable is (or you can attach to a process, but that's not what you want here).  The "target" executable, therefore, has to be defined properly in the project; moving it around using the file manager means Simply Fortran no longer knows what you're trying to debug.

In your case, I would say the easiest alternative would be to build the executable in your compiler-specific source directory, but, in Project Options in the "Launch" category, set your Working Directory to whatever directory your data files are stored in.  When you run the executable from Simply Fortran (or start the Debugger from Simply Fortran), it will run it inside the data file directory, not the project's build directory.  That should resolve your problem.

Jeff Armstrong
Approximatrix, LLC

Re: Debugging in a folder other than where a project is built

Thanks Jeff, that worked perfectly.

Eric

Re: Debugging in a folder other than where a project is built

I should have said "almost perfectly", Jeff. The main computational program ran perfectly after I pointed the Launch function to the right directory, but this code uses the Generic Mapping Tools (GMT) to produce plots and this part does not work. Specifically, the program creates scripts that include calls to gmt, and then runs those scripts with the "call system" subroutine in Fortran to create PostScript files of the plots. All calls to gmt tools come back with "command gmt not found" when running from the SF-project directory. If I move the SF-built executable to the working directory and run it from Terminal.app it finds gmt (which is specified in the PATH variable in my .bash_profile) and produces the plots. So I am suspecting that the SF IDE, unlike the Terminal, is not aware of the path for gmt commands. Is there a way to tell it about such things?

Eric

Re: Debugging in a folder other than where a project is built

Eric,

On macOS, the .bash_profile script (and it is just a script) isn't executed by the graphical shell at login.  Changes to the path that are placed there would only be captured when a terminal is open.  However, .bash_profile is arguably deprecated on current macOS because current systems use zsh by default.  When Simply Fortran starts, it does execute .zprofile, which would be the zsh equivalent to .bash_profile.  Path changes in .zprofile should be properly picked up.  This method is how we can successfully interact with Homebrew in recent versions.

Jeff Armstrong
Approximatrix, LLC

Re: Debugging in a folder other than where a project is built

Thanks Jeff. I thought it was something like this, but my on-line searches about which login files are loaded when on a modern Mac just led to confusion. I will place the various additions to the PATH in .bash_profile into the .zprofile.

Eric