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
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 becausecall get_sim_time(dict)
is never called.The possible solution is to move the call above the if-block: