1 |
C $Header: /u/gcmpack/development/heimbach/ecco_env/pkg/cal/cal_toseconds.F,v 1.4 2001/02/02 16:57:23 heimbach Exp $ |
2 |
|
3 |
#include "CAL_CPPOPTIONS.h" |
4 |
|
5 |
subroutine cal_ToSeconds( |
6 |
I date, |
7 |
O timeint, |
8 |
I mythid |
9 |
& ) |
10 |
|
11 |
c ================================================================== |
12 |
c SUBROUTINE cal_ToSeconds |
13 |
c ================================================================== |
14 |
c |
15 |
c o Given a time interval as a date array return the number of |
16 |
c seconds in that time interval. |
17 |
c |
18 |
c If one wanted to use calendar dates in this routine, then |
19 |
c the date should be after the calendar's refdate and timeint |
20 |
c would be the number of seconds that have elapsed since the |
21 |
c refdate. Of course this can also be done by first calling |
22 |
c sub cal_TimePassed and the calling this routine with the |
23 |
c resulting time interval array. |
24 |
c |
25 |
c started: Christian Eckert eckert@mit.edu 30-Jun-1999 |
26 |
c |
27 |
c changed: Christian Eckert eckert@mit.edu 29-Dec-1999 |
28 |
c |
29 |
c - restructured the original version in order to have a |
30 |
c better interface to the MITgcmUV. |
31 |
c |
32 |
c Christian Eckert eckert@mit.edu 03-Feb-2000 |
33 |
c |
34 |
c - Introduced new routine and function names, cal_<NAME>, |
35 |
c for verion 0.1.3. |
36 |
c |
37 |
c ================================================================== |
38 |
c SUBROUTINE cal_ToSeconds |
39 |
c ================================================================== |
40 |
|
41 |
implicit none |
42 |
|
43 |
c == global variables == |
44 |
|
45 |
#include "cal.h" |
46 |
|
47 |
c == routine arguments == |
48 |
|
49 |
integer date(4) |
50 |
_RL timeint |
51 |
integer mythid |
52 |
|
53 |
c == local variables == |
54 |
|
55 |
integer fac |
56 |
integer ndays |
57 |
integer nsecs |
58 |
integer hhmmss |
59 |
integer check_sign_1 |
60 |
integer check_sign_2 |
61 |
integer ierr |
62 |
|
63 |
c == end of interface == |
64 |
|
65 |
check_sign_1 = sign(1,date(1)) |
66 |
check_sign_2 = sign(1,date(2)) |
67 |
if ((date(4) .eq. -1) .and. |
68 |
& (date(3) .eq. 0) .and. |
69 |
& (check_sign_1*check_sign_2 .ge. 0)) then |
70 |
if ((date(1) .lt. 0) .or. |
71 |
& (date(2) .lt. 0)) then |
72 |
ndays = -date(1) |
73 |
hhmmss = -date(2) |
74 |
fac = -1 |
75 |
else |
76 |
ndays = date(1) |
77 |
hhmmss = date(2) |
78 |
fac = 1 |
79 |
endif |
80 |
nsecs = ndays*secondsperday + |
81 |
& (hhmmss/10000)*secondsperhour + |
82 |
& mod(hhmmss/100,100)*secondsperminute + |
83 |
& mod(hhmmss,100) |
84 |
timeint = fac*nsecs |
85 |
else |
86 |
|
87 |
ierr = 1001 |
88 |
call cal_PrintError( ierr, mythid ) |
89 |
stop ' stopped in cal_ToSeconds.' |
90 |
|
91 |
endif |
92 |
|
93 |
return |
94 |
end |