General

General

What are some methods to debug my own User Fortran Code?

    • FAQFAQ
      Participant

      On Linux, there is a debugger named ddd available. The following steps should be performed for debugging your own code: 1) Set current version of development debug solver as system environment variables – setenv SOLVER /otthome1/develop/Projects/CFX-11.0_SP1-build/bin/linux-amd64_debug/gnufort/solver-pvm.exe – setenv CFX_DATA_DIR ~develop/Projects/CFX-11.0_SP1-build/etc 2) Compile your own code with the option – cfx5mkext -name xxx *.F -g -Wimplicit 3) In the lib directory, e.g. linux-amd64, create a subfolder named gnufort; in that subfolder, create symbolic links of all libs that are in the above lib directory – ln -s ../libptm_injection.so . (The debugger’s standard search path for libs is in this subfolder gnufort) 4) In the cfx launch directory, let cfx5solve create a working directory starting the standard solver with option -norun: – cfx5solve -def .def -norun 5) Change to this working directory *.dir, start the debugger there: – ddd -gdb $SOLVER & The DDD console is started. Upper window: Current code that is run by the solver. Lower window: Input console 6) In the DDD input console, set a breakpoint when the libs are read by the solver: – b cfxdlrun_ Let the debug solver run up to this breakpoint: – run 7) In the header line of DDD, enter the name of the respective lib you want to debug, e.g.: – ptm_injection__ -> The source code appears in the DDD code window. There you can have the solver run single program code lines, check values of variables, set further breakpoints and thus debug your code. Right mouse click is always helpful in DDD, or just enter in the DDD input window – call help() The following naming conventions have to be obeyed when calling libs in the DDD header line: – If the name is without “_”, add a “_” at the end, e.g. routine: myroutine -> myroutine_ – If the name contains one or more “_”, add two “__” at the end, e.g. routine: my_routine -> my_routine__