Commit 27868581 authored by thomas.forbriger's avatar thomas.forbriger
Browse files

libtime [FIX]: fix bug in time_norm

fix bug: negative values were not normalized correctly in cases where they
were integer multiples of the limit values; this cause problems, when calling
time_compare with the result from time_sub when the result of time_sub was not
properly normalized
parent 2de65b91
......@@ -25,6 +25,8 @@ c
c REVISIONS and CHANGES
c 05/08/2000 V1.0 Thomas Forbriger
c 05/08/2000 V2.0 extracted from libtime.f
c 07/11/2017 V2.1 increase version number after bug fix in
c time_norm
c
c ============================================================================
cS
......@@ -32,11 +34,11 @@ cS
c
c returns the current version of the FORTRAN library kernel
c
c last change: V2.00 (05/08/2000)
c last change: V2.10 (07/11/2017)
c
cE
real version
parameter(version=2.00)
parameter(version=2.10)
time_libversion=version
return
end
......
......@@ -24,6 +24,12 @@ c regularize any time record (relative or absolute)
c
c REVISIONS and CHANGES
c 05/08/2000 V2.0 Thomas Forbriger
c 07/11/2017 V2.1 fix bug, negative values were not normalized
c correctly in cases where they were integer
c multiples of the limit values; this cause
c problems, when calling time_compare with the
c result from time_sub when the result of
c time_sub was not properly normalized
c
c ============================================================================
cS
......@@ -35,7 +41,7 @@ c
c input/output:
c date: date record to be regularized
c
c last change: V2.00 (05/08/2000)
c last change: V2.10 (05/08/2000)
c
integer date(7)
cE
......@@ -47,7 +53,7 @@ c
c set linear value ranges (from hours on)
do i=7,3,-1
carry=int(date(i)/limit(i))
if (date(i).lt.0) carry=carry-1
if (date(i).lt.0) carry=int((date(i)+1)/limit(i))-1
date(i)=date(i)-carry*limit(i)
date(i-1)=date(i-1)+carry
enddo
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment