Goddard-Fortran-Ecosystem / pFlogger

A parallel Fortran logger (based on the design of the Python logger)
Other
18 stars 8 forks source link

Bug with sim_time #90

Closed mathomp4 closed 1 year ago

mathomp4 commented 1 year ago

As discovered by @tclune and myself when trying to use the "sim_time" functionality of pflogger, this code:

https://github.com/Goddard-Fortran-Ecosystem/pFlogger/blob/6011e59122e3bf08746ee3382c6c6aca5264f21e/src/Formatter.F90#L271-L280

is wrong because if you don't specify a datefmt it will crash because call get_sim_time(dict) is never called.

The possible solution is to move the call above the if-block:

      if(this%fmt_uses_simTime) then
         call get_sim_time(dict)
         if (allocated(this%datefmt)) then
            simtime = FormatString(this%datefmt, dict)
         else
            simtime = FormatString(DEFAULT_DATE_FMT, dict)
         end if

         call extra%insert('simtime', String(simtime))
      end if