once an error is discovered, use copious
write(*,*) 'I got here, x = ', x
statements to see if the value of x is what you think it should be
http://www.cleanscape.net/products/fortranlint/fortran-programming_tips.html
matrix used that was not allocated
divide by zero
variable declarations in subroutines that do not match main body dimensions
Scenario: given two sets of code, "working.f90" and "desired.f90" and a compiler, pgf90. "desired.f90" has a segmentation fault.
Step 0:
pgf90 works.f90
compiles and runs, whereas
pgf90 desired.ef90
compiles, but results in segmentation fault
Step 1:
pgf90 -g desired.f90
gdb a.out
run a.out
--> see where the segfault originates
Method 1: incrementally add code from "desired.f90" to "working.f90" and compile after each addition. Eventually, a segmentation fault will occur. While incrementing, use "pgf90" (with no switches)
Method 2: incrementally comment out sections of "desired.f90" until the segmentation fault is removed
Warning (applicable to both 1,2): Just because you find a segmentation fault, don't immediately discard "working.f90" because there may be more seg faults
Reminder: "pgf90" is different from "pgf90 -g" because "-g" turns off default optimizations. Thus, "pgf90" may have segmentation faults that "pgf90 -g" does not.