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

Annotation of /MITgcm/pkg/cal/cal_convdate.F

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


Revision 1.5 - (hide annotations) (download)
Sat Apr 7 16:21:05 2012 UTC (13 years, 3 months ago) by jmc
Branch: MAIN
Changes since 1.4: +59 -57 lines
stop if called before pkg/cal parameters were set.

1 jmc 1.5 C $Header: /u/gcmpack/MITgcm/pkg/cal/cal_convdate.F,v 1.4 2003/10/09 04:19:19 edhill Exp $
2 edhill 1.4 C $Name: $
3 heimbach 1.1
4 edhill 1.4 #include "CAL_OPTIONS.h"
5 heimbach 1.1
6 jmc 1.5 SUBROUTINE CAL_CONVDATE(
7 heimbach 1.1 I date,
8     O yy, mm, dd, ss,
9     O lp, wd,
10 jmc 1.5 I myThid )
11 heimbach 1.1
12 jmc 1.5 C ==================================================================
13     C SUBROUTINE cal_ConvDate
14     C ==================================================================
15     C
16     C o Decompose the first part of a date array.
17     C
18     C started: Christian Eckert eckert@mit.edu 30-Jun-1999
19     C changed: Christian Eckert eckert@mit.edu 29-Dec-1999
20     C - restructured the original version in order to have a
21     C better interface to the MITgcmUV.
22     C Christian Eckert eckert@mit.edu 03-Feb-2000
23     C - Introduced new routine and function names, cal_<NAME>,
24     C for verion 0.1.3.
25     C 21-Sep-2003: fixed check_sign logic to work with
26     C negative intervals (menemenlis@jpl.nasa.gov)
27     C
28     C ==================================================================
29     C SUBROUTINE cal_ConvDate
30     C ==================================================================
31 heimbach 1.1
32 jmc 1.5 IMPLICIT NONE
33 heimbach 1.1
34 jmc 1.5 C == global variables ==
35     #include "EEPARAMS.h"
36 heimbach 1.1 #include "cal.h"
37    
38 jmc 1.5 C == routine arguments ==
39     INTEGER date(4)
40     INTEGER myThid
41    
42     C == local variables ==
43     INTEGER yy
44     INTEGER mm
45     INTEGER dd
46     INTEGER ss
47     INTEGER lp
48     INTEGER wd
49     INTEGER fac
50     INTEGER date_1
51     INTEGER date_2
52     INTEGER ierr
53     INTEGER check_sign
54     CHARACTER*(MAX_LEN_MBUF) msgBuf
55     C == end of interface ==
56    
57     IF ( cal_setStatus .LT. 1 ) THEN
58     WRITE( msgBuf,'(2A,4I9)') 'CAL_CONVDATE: ',
59     & 'date=',date(1),date(2),date(3),date(4)
60     CALL PRINT_ERROR( msgBuf, myThid )
61     WRITE( msgBuf,'(2A,I2,A)') 'CAL_CONVDATE: ',
62     & 'called too early (cal_setStatus=',cal_setStatus,' )'
63     CALL PRINT_ERROR( msgBuf, myThid )
64     STOP 'ABNORMAL END: S/R CAL_CONVDATE'
65     ENDIF
66 heimbach 1.1
67     fac = 1
68    
69 jmc 1.5 C Check the sign of the date.
70 heimbach 1.1
71 dimitri 1.3 check_sign = 1
72     if ( ( (date(1).lt.0) .and. date(2).gt.0 ) .or.
73     & ( (date(1).gt.0) .and. date(2).lt.0 ) )
74     & check_sign = -1
75 heimbach 1.1
76 dimitri 1.2 if ( check_sign .ge. 0 ) then
77 heimbach 1.1 if (date(1) .eq. 0) then
78     date_1 = date(1)
79     if (date(2) .lt. 0) then
80     date_2 = -date(2)
81     fac = -1
82     else
83     date_2 = date(2)
84     fac = 1
85     endif
86     else if (date(1) .lt. 0) then
87     date_1 = -date(1)
88     date_2 = -date(2)
89     fac = -1
90     else
91     date_1 = date(1)
92     date_2 = date(2)
93     fac = 1
94     endif
95     else
96    
97     ierr = 901
98 jmc 1.5 call cal_PrintError( ierr, myThid )
99 heimbach 1.1 stop ' stopped in cal_ConvDate.'
100    
101     endif
102    
103 jmc 1.5 C Decompose the entries.
104 heimbach 1.1 if (date(4) .ne. -1) then
105     yy = date_1/10000
106     mm = mod(date_1/100,100)
107     dd = mod(date_1,100)
108     else
109     yy = 0
110     mm = 0
111     dd = date_1
112     endif
113     ss = mod(date_2,100) +
114     & mod(date_2/100,100)*secondsperminute +
115     & date_2/10000*secondsperhour
116    
117 jmc 1.5 C Include the sign.
118 heimbach 1.1 yy = fac*yy
119     mm = fac*mm
120     dd = fac*dd
121     ss = fac*ss
122    
123     lp = date(3)
124     wd = date(4)
125    
126 jmc 1.5 RETURN
127     END
128 heimbach 1.1

  ViewVC Help
Powered by ViewVC 1.1.22