/[MITgcm]/MITgcm/pkg/cal/cal_toseconds.F
ViewVC logotype

Contents of /MITgcm/pkg/cal/cal_toseconds.F

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.8 - (show annotations) (download)
Tue Mar 16 00:11:46 2010 UTC (14 years, 1 month ago) by jmc
Branch: MAIN
CVS Tags: checkpoint62v, checkpoint62u, checkpoint62t, checkpoint62s, checkpoint62r, checkpoint62q, checkpoint62p, checkpoint62g, checkpoint62f, checkpoint62e, checkpoint62d, checkpoint62k, checkpoint62j, checkpoint62i, checkpoint62h, checkpoint62o, checkpoint62n, checkpoint62m, checkpoint62l, checkpoint62w, checkpoint62z, checkpoint62y, checkpoint62x, checkpoint63g, checkpoint63, checkpoint63l, checkpoint63h, checkpoint63i, checkpoint63j, checkpoint63k, checkpoint63d, checkpoint63e, checkpoint63f, checkpoint63a, checkpoint63b, checkpoint63c
Changes since 1.7: +3 -3 lines
avoid unbalanced quote (single or double) in commented line

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

  ViewVC Help
Powered by ViewVC 1.1.22