negative return value of io_wallclocktime #266
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I have written a subroutine
berry_print_progress
(line 2005 of https://github.com/qiaojunfeng/wannier90/blob/shc/src/postw90/berry.F90) to estimate calculation progress when calculating spin Hall conductivity. This subroutine callsio_wallclocktime
insrc/io.F90
.In some situations, it will print
The 2nd column is the value returned from
io_wallclocktime
.The negative value is caused by insufficient precision of
integer
inio_wallclocktime
.If using the default
kind = 4
integer insystem_clock
, thecount_max
will be2147483647
, so the return value ofsystem_clock
will wrap around about 25 days or 2.5 days depending on the compiler.Refs:
I have created a test case:
Test on machine 1:
Test on machine 2:
Test on machine 3:
So, the wrap around period of Intel compiler is 2.5 days, while that of gfortran is 25 days.
I used Intel compiler and that's why I got negative time in the calculation: the system encountered a wrap around during the calculation (note the calculation finished in a day, did not exceed 2.5 days).
In the commit, I have used use
kind = 8
integer inio_wallclocktime
. Though not totally get rid of wrap around error, this should alleviate the problem to a large extent.