-
Notifications
You must be signed in to change notification settings - Fork 10
Description
[BUG]: GITM outputs twice at the final dt
The output subroutine is called both from main, and from finalize. This may or may not be a bug, so is worth discussing whether we want to modify this behavior or leave as-is.
Bug Information
Inside main, GITM calls write_output each dt. And then in finalize_gitm (src/finalize.f90), GITM calls output again.
When the end time of a simulation matched with the output dt, output is called twice.
Other Information
This behavior is somewhat expected, but may be worth discussing further... The reasoning behind it is to force an output file to be created if a user wishes to "cancel" a run. If one were to touch GITM.STOP, the run would be halted and the present state is output.
Couple of options here:
- Remove the call to output from finalize. This would mean that if dtOutput & the run's stop time do not align, the final states would not be output. Do not change anything else.
- Create a variable
didOutputThisDt(and/ordoForceWrite) which are used to decide if the present states have already been written. The code would then not write the files a second time. Additionally:- Change
finalizeto callwrite_output(same as main) - Add a check there to see if the file exists or not.
- Use the aforementioned variables to decide whether or not to write anything.
- Change
- Do nothing... This is not explicitly a bug, and does not affect runtime performance meaningfully. Just may not be expected behavior.
The advantage of 1 & 2 is that we de-tangle the code. The disadvantages are that it is yet another setting that can be changed (complicates things), and that it changes the behavior of the code - not necessarily bad but maybe not necessary.
My thought is to go with option 2. But this can be discussed!