libtime++: Date and time calculation
time_compare.f
Go to the documentation of this file.
1 c this is <time_compare.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 compare two time records
24 c
25 c REVISIONS and CHANGES
26 c 05/08/2000 V1.0 Thomas Forbriger
27 c V2.0 call language specific warning wrapper
28 c
29 c ============================================================================
30 cS
31  integer function time_compare(date1, date2)
32 c
33 c Compare values of date1 and date2.
34 c Both must be absolute or both must be relative.
35 c
36 c result = 0 for date1 = date2
37 c result = -1 for date1 < date2
38 c result = 1 for date1 > date2
39 c
40 c input:
41 c date1: primary time record
42 c date2: secondary time record
43 c
44 c last change: V2.00 (05/08/2000)
45 c
46  integer date1(7), date2(7)
47 cE
48  integer result, i
49 c
50  if (((date1(1).eq.0).and.(date2(1).eq.0)).or.
51  & ((date1(1).ne.0).and.(date2(1).ne.0))) then
52  result=0
53  i=1
54  1 if (date1(i).gt.date2(i)) then
55  result=1
56  elseif (date1(i).lt.date2(i)) then
57  result=-1
58  else
59  i=i+1
60  if (i.lt.8) goto 1
61  endif
62  else
63  call time_util_warning('time_compare',
64  & 'do not mix absolute and relative times')
65  call time_util_warning('time_compare',
66  & 'routine skipped... (result=-2)')
67  result=-2
68  endif
69  time_compare=result
70  return
71  end
72 c
73 c ----- END OF <time_compare.f> -----
subroutine time_util_warning(caller, text)
integer time_compare(time_Ts Date1, time_Ts Date2)
Definition: ctime_compare.c:35