libtime++: Date and time calculation
time_setdoy.f
Go to the documentation of this file.
1 c this is <time_setdoy.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 set doy index from given day and month index
24 c
25 c REVISIONS and CHANGES
26 c 05/08/2000 V1.0 Thomas Forbriger
27 c V2.0 call language specific warning handler
28 c 25/12/2012 V2.1 provide more details upon abort
29 c
30 c ============================================================================
31 cS
32  subroutine time_setdoy(day, month, date)
33 c
34 c Set doy in date from day and month (january first is doy 1).
35 c This routine will call time_fullyear first!
36 c
37 c This routine is senseless in combination with relative times!
38 c
39 c input:
40 c day: day index within month
41 c month: month index within year (contained in date)
42 c input/output:
43 c date: doy index in time record is changed according to given day and
44 c month index and year value in date
45 c
46 c last change: V2.10 (25/12/2012)
47 c
48  integer day, month, date(7)
49 cE
50  integer result
51  integer sel, mon
52  logical time_isleapyear
53  integer days(12,2)
54  data days/31,28,31,30,31,30,31,31,30,31,30,31,
55  & 31,29,31,30,31,30,31,31,30,31,30,31/
56 c
57  if (date(1).eq.0) then
58  call time_util_warning('time_setdoy',
59  & 'do not use this with relative times')
60  call time_util_warning('time_setdoy',
61  & 'routine skipped...')
62  else
63  call time_fullyear(date(1))
64  if (time_isleapyear(date(1))) then
65  sel=2
66  else
67  sel=1
68  endif
69  result=0
70  mon=1
71  1 if (mon.ge.month) goto 2
72  result=result+days(mon,sel)
73  mon=mon+1
74  if (mon.gt.13) then
75  call time_util_warning_report_time('time_setdoy',
76  & date)
77  call time_util_warning_n('time_setdoy',
78  & 'month value',month)
79  call time_util_fatal('time_setdoy',
80  & 'month value out of range')
81  endif
82  goto 1
83  2 continue
84  result=result+day
85  date(2)=result
86  endif
87  return
88  end
89 c
90 c ----- END OF <time_setdoy.f> -----
subroutine time_util_warning_report_time(caller, date)
subroutine time_util_fatal(caller, text)
subroutine time_util_warning(caller, text)
subroutine time_util_warning_n(caller, text, n)
void time_setdoy(timeint day, timeint month, time_Ts *Pdate)
Definition: ctime_setdoy.c:36
void time_fullyear(timeint *year)