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

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

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


Revision 1.6 - (show annotations) (download)
Sun Apr 8 19:22:34 2012 UTC (12 years ago) by jmc
Branch: MAIN
CVS Tags: checkpoint65z, checkpoint65x, checkpoint65y, checkpoint65r, checkpoint65s, checkpoint65p, checkpoint65q, checkpoint65v, checkpoint65w, checkpoint65t, checkpoint65u, checkpoint65j, checkpoint65k, checkpoint65h, checkpoint65i, checkpoint65n, checkpoint65l, checkpoint65m, checkpoint65b, checkpoint65c, checkpoint65a, checkpoint65f, checkpoint65g, checkpoint65d, checkpoint65e, checkpoint64, checkpoint65, checkpoint66g, checkpoint66f, checkpoint66e, checkpoint66d, checkpoint66c, checkpoint66b, checkpoint66a, checkpoint66o, checkpoint66n, checkpoint66m, checkpoint66l, checkpoint66k, checkpoint66j, checkpoint66i, checkpoint66h, checkpoint63p, checkpoint63q, checkpoint63r, checkpoint63s, checkpoint63m, checkpoint63n, checkpoint63o, checkpoint65o, checkpoint64y, checkpoint64x, checkpoint64z, checkpoint64q, checkpoint64p, checkpoint64s, checkpoint64r, checkpoint64u, checkpoint64t, checkpoint64w, checkpoint64v, checkpoint64i, checkpoint64h, checkpoint64k, checkpoint64j, checkpoint64m, checkpoint64l, checkpoint64o, checkpoint64n, checkpoint64a, checkpoint64c, checkpoint64b, checkpoint64e, checkpoint64d, checkpoint64g, checkpoint64f, HEAD
Changes since 1.5: +15 -35 lines
minor changes (change check_sign to logical wrong_sign; move output
 arguments previously in "local variables" section).

1 C $Header: /u/gcmpack/MITgcm/pkg/cal/cal_convdate.F,v 1.5 2012/04/07 16:21:05 jmc Exp $
2 C $Name: $
3
4 #include "CAL_OPTIONS.h"
5
6 SUBROUTINE CAL_CONVDATE(
7 I date,
8 O yy, mm, dd, ss,
9 O lp, wd,
10 I myThid )
11
12 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
32 IMPLICIT NONE
33
34 C == global variables ==
35 #include "EEPARAMS.h"
36 #include "cal.h"
37
38 C == routine arguments ==
39 INTEGER date(4)
40 INTEGER yy, mm, dd
41 INTEGER ss, lp, wd
42 INTEGER myThid
43
44 C == local variables ==
45 INTEGER fac
46 INTEGER date_1
47 INTEGER date_2
48 INTEGER ierr
49 LOGICAL wrong_sign
50 CHARACTER*(MAX_LEN_MBUF) msgBuf
51 C == end of interface ==
52
53 IF ( cal_setStatus .LT. 1 ) THEN
54 WRITE( msgBuf,'(2A,4I9)') 'CAL_CONVDATE: ',
55 & 'date=',date(1),date(2),date(3),date(4)
56 CALL PRINT_ERROR( msgBuf, myThid )
57 WRITE( msgBuf,'(2A,I2,A)') 'CAL_CONVDATE: ',
58 & 'called too early (cal_setStatus=',cal_setStatus,' )'
59 CALL PRINT_ERROR( msgBuf, myThid )
60 STOP 'ABNORMAL END: S/R CAL_CONVDATE'
61 ENDIF
62
63 C Check the sign of the date.
64 fac = 1
65 wrong_sign = ( (date(1).lt.0) .and. date(2).gt.0 )
66 & .OR. ( (date(1).gt.0) .and. date(2).lt.0 )
67
68 if ( wrong_sign ) then
69 ierr = 901
70 call cal_PrintError( ierr, myThid )
71 stop ' stopped in cal_ConvDate.'
72 else
73 if ( date(1).lt.0 .OR. date(2).lt.0 ) then
74 date_1 = -date(1)
75 date_2 = -date(2)
76 fac = -1
77 else
78 date_1 = date(1)
79 date_2 = date(2)
80 fac = 1
81 endif
82 endif
83
84 C Decompose the entries.
85 if (date(4) .ne. -1) then
86 yy = date_1/10000
87 mm = mod(date_1/100,100)
88 dd = mod(date_1,100)
89 else
90 yy = 0
91 mm = 0
92 dd = date_1
93 endif
94 ss = mod(date_2,100) +
95 & mod(date_2/100,100)*secondsPerMinute +
96 & date_2/10000*secondsPerHour
97
98 C Include the sign.
99 yy = fac*yy
100 mm = fac*mm
101 dd = fac*dd
102 ss = fac*ss
103
104 lp = date(3)
105 wd = date(4)
106
107 RETURN
108 END

  ViewVC Help
Powered by ViewVC 1.1.22