libtime++: Date and time calculation
time_mul.f
Go to the documentation of this file.
1 c this is <time_mul.f> (extracted from ../libtime.f)
2 c automatically generated by "SPLITF.PL V1.0 SPLIT Fortran source code"
3 c----------------------------------------------------------------------
4 c
5 c Copyright 2000 by Thomas Forbriger (IfG Stuttgart)
6 c
7 c ----
8 c libtime is free software; you can redistribute it and/or modify
9 c it under the terms of the GNU General Public License as published by
10 c the Free Software Foundation; either version 2 of the License, or
11 c (at your option) any later version.
12 c
13 c This program is distributed in the hope that it will be useful,
14 c but WITHOUT ANY WARRANTY; without even the implied warranty of
15 c MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 c GNU General Public License for more details.
17 c
18 c You should have received a copy of the GNU General Public License
19 c along with this program; if not, write to the Free Software
20 c Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 c ----
22 c
23 c multiply relative time value by integer
24 c
25 c REVISIONS and CHANGES
26 c 05/08/2000 V1.0 Thomas Forbriger
27 c V2.0 call language specific fatal error handler
28 c 05/12/2007 V2.1 correction in variable declaration
29 c
30 c ============================================================================
31 cS
32  subroutine time_mul(date1, date2, n)
33 c
34 c Multiply relative time date1 by n and store result in date2.
35 c
36 c input:
37 c date1: relative time record
38 c n: integer factor
39 c output:
40 c date2: date1*n (regularized relative time value)
41 c
42 c last change: V2.00 (05/08/2000)
43 c
44  integer date1(7), date2(7), n
45 cE
46  integer quotient(7), rest(7), product(7), carry(7), i, limit(7)
47  integer help
48  data limit/-1,-1,24,60,60,1000,1000/
49 c
50  if (date1(1).ne.0) then
51  call time_util_fatal('time_mul','no absolute time allowed')
52  else
53  do i=3,7
54 c split n to avoid conflicts with integer range
55  quotient(i)=int(n/limit(i))
56  rest(i)=n-limit(i)*quotient(i)
57  help=int(rest(i)*date1(i)/limit(i))
58  carry(i)=quotient(i)*date1(i)+help
59  product(i)=rest(i)*date1(i)-help*limit(i)
60  enddo
61  product(2)=n*date1(2)
62  do i=2,6
63  date2(i)=product(i)+carry(i+1)
64  enddo
65  date2(7)=product(7)
66  date2(1)=0
67  call time_norm(date2)
68  endif
69  return
70  end
71 c
72 c ----- END OF <time_mul.f> -----
subroutine time_util_fatal(caller, text)
void time_norm(time_Ts *Pdate)
Definition: ctime_norm.c:33
void time_mul(time_Ts Date1, time_Ts *Pdate2, integer n)
Definition: ctime_mul.c:35