libtime++: Date and time calculation
time_read.f
Go to the documentation of this file.
1 c this is <time_read.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 read date value from string
24 c NOTICE: this routine is language specific as it call index!
25 c
26 c REVISIONS and CHANGES
27 c 05/08/2000 V2.0 Thomas Forbriger
28 c
29 c ============================================================================
30 cS
31  subroutine time_read(string,date)
32 c
33 c Reads date value from string.
34 c
35 c The timestring has to provide time information in the order
36 c
37 c year month day hours minutes seconds
38 c
39 c where seconds may be given as a floating point number. All items must be
40 c separated by non-numerical characters.
41 c
42 c input:
43 c string: character string specifying date value
44 c output:
45 c date: fully qualified and regularized time record
46 c
47 c last change: V2.00 (05/08/2000)
48 c
49  character*(*) string
50  integer date(7)
51 c
52 cE
53  integer numbers(5), i, first, last, length, index
54  double precision seconds
55 c
56  call time_clear(date)
57 c fill array with numbers
58  length=len(string)
59  first=1
60  do i=1,5
61  numbers(i)=0
62  do while ((first.lt.length).and.
63  & (index('.0123456789', string(first:first)).eq.0))
64  first=first+1
65  enddo
66  last=first
67  do while ((last.lt.length).and.
68  & (index('.0123456789', string(last:last)).gt.0))
69  last=last+1
70  enddo
71  if (index('0123456789', string(last:last)).lt.1) last=last-1
72  if ((first.le.length).and.(index('0123456789',
73  & string(first:first)).gt.0)) then
74  read(string(first:last), *) numbers(i)
75  first=last+1
76  endif
77  enddo
78 c read seconds
79  seconds=0.d0
80  do while ((first.lt.length).and.
81  & (index('.0123456789', string(first:first)).eq.0))
82  first=first+1
83  enddo
84  last=first
85  do while ((last.lt.length).and.
86  & (index('.0123456789', string(last:last)).gt.0))
87  last=last+1
88  enddo
89  read(string(first:last), *)
90  if ((first.le.length).and.(index('0123456789',
91  & string(first:first)).gt.0)) then
92  read(string(first:last), *) seconds
93  first=last+1
94  endif
95 c
96  if ((numbers(1).gt.0).or.(numbers(2).gt.0)) then
97 c absolute date
98  date(1)=numbers(1)
99  call time_fullyear(date(1))
100  call time_setdoy(numbers(3),numbers(2),date)
101  else
102 c relative date
103  date(2)=numbers(3)
104  endif
105 c hour and minute
106  do i=1,2
107  date(i+2)=numbers(i+3)
108  enddo
109 c seconds, etc.
110  date(5)=int(seconds)
111  seconds=(seconds-dble(date(5)))*1000.d0
112  date(6)=int(seconds)
113  seconds=(seconds-dble(date(6)))*1000.d0
114  date(7)=int(seconds+0.5d0)
115 c
116  call time_norm(date)
117 c
118  return
119  end
120 c
121 c ----- END OF <time_read.f> -----
void time_setdoy(timeint day, timeint month, time_Ts *Pdate)
Definition: ctime_setdoy.c:36
void time_clear(time_Ts *Pdate)
Definition: ctime_clear.c:33
void time_norm(time_Ts *Pdate)
Definition: ctime_norm.c:33
void time_fullyear(timeint *year)
int time_read(time_Ts *Date, const char *String)
Definition: ctime_read.c:37