Search code examples
debuggingidefortranphotran

How to Debug Following Fortran Program


I am trying to compile the following software so that I can step through and debug it. I am only a novice programmer and I am trying to understand how this whole makefile business works with Fortran. I know that there is a ton of literature on makefiles but I just need to insert a simple debug flag and I think if someone provided me with the answer to this question that would be the best way for me to learn.

So the program I am trying to compile, TINKER, is actually made up of several packages, located at http://dasher.wustl.edu/tinkerwiki/index.php/Main_Page. I would like to compile and debug JUST ONE specific executable, "analyze". I contacted the developer and received the following reply but I am still stuck...

Since TINKER has lots of small source code files, what we do is compile each of the small files to an object file using the "-c" flag. Then we put all of these object code files (ie, the ".o" files) into an object library. Finally, we link each of the TINKER top level programs, such as "analyze", against the object library. There is a Makefile supplied with TINKER that does this. We also supply individual scripts called "compile.make", "library.make" and "link.make" for various CPU/compiler combinations that can be run in order to perform the steps I describe above. To build a "debuggable" executable, you just need to include the appropriate debug flags (usually "-g") as part of the compile and link stages.

I am currently running OSX 10.6.8. If someone could show me which folders I cd into, what commands I enter that would be so great!

Thanks!

My follow up question (once I can figure out how to answer the above via command line will concern how to import the same procedure but using the Photran IDE - http://wiki.eclipse.org/PTP/photran/documentation/photran5#Starting_a_Project_with_a_Hand-Written_Makefile)


Solution

  • The directions are at http://dasher.wustl.edu/tinkerwiki/index.php/Main_Page#Installing_TINKER_on_your_Computer

    Maybe out of date? g77 is obsolete -- it would be better to use gfortran.

    The key steps: "The first step in building TINKER using the script files is to run the appropriate compile.make script for your operating system and compiler version. Next you must use a library.make script to create an archive of object code modules. Finally, run a link.make script to produce the complete set of TINKER executables. The executables can be renamed and moved to wherever you like by editing and running the ‘‘rename’’ script."

    So cd to the directory for the Mac -- based on "we also provide machine-specific directories with three separate shell scripts to compile the source, build an object library, and link binary executables." Then run the command scripts. Probably ./compile.make. Look around for the directories ... you can probably figure it out from the names. Or search for the file "compile.make".

    Or find someone local to you who knows more about programming.