After adapting this answer, I wrote the following loop to simply print an array in gdb in a script called "gdb_script.gs". What am I doing wrong?
set $end=64
while ($i<$end)
print $i
print volfrac($i, :, 1)
set $i=$i+1
end
where volfrac(:,:,:) is a fortran array. I am getting the error:
gdb_script.gs:14: Error in sourced command file:
A syntax error in expression, near `<$end)'.
The other answer totally missed the point. The hint was the reported error:
gdb_script.gs:14: Error in sourced command file:
A syntax error in expression, near `<$end)'.
The hint is <$end)
, which means there is a syntax error in the while statement. By experimenting further, I am posting my results if others need it in the future:
set $ipx=0
set $end=32
while ($ipx .lt. 32)
print $ipx
print ro($ipx, 1)
set $ipx=$ipx+1
end
The key was to use the fortran syntax for comparison ($ipx .lt. 32) instead of the usual "c" syntax ($ipx < 32).