1

Consider the statement:

      open(unit=24,file='energy_check.out',status='unknown')

and elsewhere, in another file in the code:

       write(24,*) x

and elsewhere, in another file in the code:

       write(24,*) y

I want to watch/break every time IO is performed on unit 24. How to do this. Web search was not helpful.

wander95
  • 1,298
  • 1
  • 15
  • 22
  • Place a breakpoint on all such statements. I don't know of any other way. I don't thank gdb knows *that* much about Fortran to watch I/O units. You could set a conditional breakpoint in libgfortran, but I don't think it would be too useful. – Vladimir F Героям слава Sep 22 '17 at 20:49
  • 1
    This may help (https://stackoverflow.com/questions/8049424/how-to-stop-program-in-gdb-at-writing-to-a-particular-file-known-by-its-name) – M. Chinoune Sep 23 '17 at 11:39
  • Are all the writes to 24 of single values of the same type or does it vary? If they are single values of the same type, change to write statements to 24 to a subroutine and just set the breakpoint in the subroutine. – cup Sep 23 '17 at 14:23
  • @M.Chinoune, that will break every write including other units, many of them will be annoying because they might be in do loops. – wander95 Sep 25 '17 at 14:52
  • 0 down vote grep -n "write(24" FortFile.f where I assume the source code is FortFile.f Now you can get a better view of the lines where you have to place breakpoints. There is also an option to place that in a script and run it from gdb. Thanks! – Krassi Em Sep 25 '17 at 18:29
  • Does anyone know if there would be a pointer address associated with unit 24? I could "watch" that memory location. – wander95 Sep 25 '17 at 18:41

0 Answers0