To use dbx on a parallel loop, temporarily rewrite the program as follows:
Isolate the body of the loop in a file and subroutine of its own.
In the original routine, replace loop body with a call to the new subroutine.
Compile the new subroutine with -g and no parallelization options.
Compile the changed original routine with parallelization and no -g.
Example: Manually transform a loop to allow using dbx in parallel:
Original code:
demo% cat loop.f
C$PAR DOALL
DO i = 1,10
WRITE(0,*) 'Iteration ', i
END DO
END
Split into two parts: caller loop and loop body as a subroutine
demo% cat loop1.f
C$PAR DOALL
DO i = 1,10
k = i
CALL loop_body ( k )
END DO
END
demo% cat loop2.f
SUBROUTINE loop_body ( k )
WRITE(0,*) 'Iteration ', k
RETURN
END
Compile caller loop with parallelization but no debugging
demo% f77 -O3 -c -explicitpar loop1.f
Compile the subprogram with debugging but not parallelized
demo% f77 -c -g loop2.f
Link together both parts into a.out
demo% f77 loop1.o loop2.o -explicitpar
Run a.out under dbx and put breakpoint into loop body subroutine
demo% dbx a.out ¨ Various
dbx messages not shown
(dbx) stop in loop_body
(2) stop in loop_body
(dbx) run
Running: a.out
(process id 28163)
dbx stops at breakpoint
t@1 (l@1) stopped in loop_body at line 2 in file
"loop2.f"
2 write(0,*) 'Iteration ', k
Now show value of k
(dbx) print k
k = 1 ¨ Various values other than 1 are possible
(dbx)