NCEPLIBS-w3emc 2.12.0
Loading...
Searching...
No Matches
w3reddat.f
Go to the documentation of this file.
1
4
85 subroutine w3reddat(it,rinc,dinc)
86 real rinc(5),dinc(5)
87! parameters for number of units in a day
88! and number of milliseconds in a unit
89! and number of next smaller units in a unit, respectively
90 integer,dimension(5),parameter:: itd=(/1,24,1440,86400,86400000/),
91 & itm=itd(5)/itd
92 integer,dimension(4),parameter:: itn=itd(2:5)/itd(1:4)
93 integer,parameter:: np=16
94 integer iinc(4),jinc(5),kinc(5)
95! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
96! first reduce to the first reduced form
97 iinc=floor(rinc(1:4))
98! convert all positive fractional parts to milliseconds
99! and determine canonical milliseconds
100 jinc(5)=nint(dot_product(rinc(1:4)-iinc,real(itm(1:4)))+rinc(5))
101 kinc(5)=modulo(jinc(5),itn(4))
102! convert remainder to seconds and determine canonical seconds
103 jinc(4)=iinc(4)+(jinc(5)-kinc(5))/itn(4)
104 kinc(4)=modulo(jinc(4),itn(3))
105! convert remainder to minutes and determine canonical minutes
106 jinc(3)=iinc(3)+(jinc(4)-kinc(4))/itn(3)
107 kinc(3)=modulo(jinc(3),itn(2))
108! convert remainder to hours and determine canonical hours
109 jinc(2)=iinc(2)+(jinc(3)-kinc(3))/itn(2)
110 kinc(2)=modulo(jinc(2),itn(1))
111! convert remainder to days and compute milliseconds of the day
112 kinc(1)=iinc(1)+(jinc(2)-kinc(2))/itn(1)
113 ms=dot_product(kinc(2:5),itm(2:5))
114! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
115! next reduce to either single value canonical form
116! or to one of the two reduced forms
117 if(it.ge.1.and.it.le.5) then
118! ensure that exact multiples of 1./np are expressed exactly
119! (other fractions may have precision errors)
120 rp=(np*ms)/itm(it)+mod(np*ms,itm(it))/real(itm(it))
121 dinc=0
122 dinc(it)=real(kinc(1))*itd(it)+rp/np
123 else
124! the reduced form is done except the second reduced form is modified
125! for negative time intervals with fractional days
126 dinc=kinc
127 if(it.eq.0.and.kinc(1).lt.0.and.ms.gt.0) then
128 dinc(1)=dinc(1)+1
129 dinc(2:5)=mod(ms-itm(1),itm(1:4))/itm(2:5)
130 endif
131 endif
132! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
133 end
subroutine w3reddat(it, rinc, dinc)
This subprogram reduces an ncep relative time interval into one of seven canonical forms,...
Definition w3reddat.f:86