Separation of declaration and initiation of variables

Re: “probably should be a class,” - aka a derived type in Fortran parlance.

And there have been many illustrations of that online generally and with Fortran including at this forum, see here.

With this, a simple timing “instrumentation” becomes

   call timer%start()
   .. ! some instructions here  
   call timer%stop()
   ! the "delta seconds" are fetched via timer%t()
   print *, timer%t()

Bottom-line here: no SAVE variables needed with this. Such a “timer” type can then also be used in codes which are not the traditional sequential/serial execution ones.

1 Like