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

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

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

revision 1.1 by heimbach, Mon May 14 22:07:26 2001 UTC revision 1.6 by jmc, Sun Apr 8 19:22:34 2012 UTC
# Line 1  Line 1 
1  C $Header$  C $Header$
2    C $Name$
3    
4  #include "CAL_CPPOPTIONS.h"  #include "CAL_OPTIONS.h"
5    
6        subroutine cal_ConvDate(        SUBROUTINE CAL_CONVDATE(
7       I                         date,       I                         date,
8       O                         yy, mm, dd, ss,       O                         yy, mm, dd, ss,
9       O                         lp, wd,       O                         lp, wd,
10       I                         mythid       I                         myThid )
      &                       )  
11    
12  c     ==================================================================  C     ==================================================================
13  c     SUBROUTINE cal_ConvDate  C     SUBROUTINE cal_ConvDate
14  c     ==================================================================  C     ==================================================================
15  c  C
16  c     o Decompose the first part of a date array.  C     o Decompose the first part of a date array.
17  c                C
18  c     started: Christian Eckert eckert@mit.edu  30-Jun-1999  C     started: Christian Eckert eckert@mit.edu  30-Jun-1999
19  c  C     changed: Christian Eckert eckert@mit.edu  29-Dec-1999
20  c     changed: Christian Eckert eckert@mit.edu  29-Dec-1999  C              - restructured the original version in order to have a
21  c  C                better interface to the MITgcmUV.
22  c              - restructured the original version in order to have a  C              Christian Eckert eckert@mit.edu  03-Feb-2000
23  c                better interface to the MITgcmUV.  C              - Introduced new routine and function names, cal_<NAME>,
24  c  C                for verion 0.1.3.
25  c              Christian Eckert eckert@mit.edu  03-Feb-2000  C              21-Sep-2003: fixed check_sign logic to work with
26  c  C              negative intervals (menemenlis@jpl.nasa.gov)
27  c              - Introduced new routine and function names, cal_<NAME>,  C
28  c                for verion 0.1.3.  C     ==================================================================
29  c  C     SUBROUTINE cal_ConvDate
30  c     ==================================================================  C     ==================================================================
 c     SUBROUTINE cal_ConvDate  
 c     ==================================================================  
31    
32        implicit none        IMPLICIT NONE
   
 c     == global variables ==  
33    
34    C     == global variables ==
35    #include "EEPARAMS.h"
36  #include "cal.h"  #include "cal.h"
37    
38  c     == routine arguments ==  C     == routine arguments ==
39          INTEGER date(4)
40        integer date(4)        INTEGER yy, mm, dd
41        integer mythid        INTEGER ss, lp, wd
42          INTEGER myThid
43  c     == local variables ==  
44    C     == local variables ==
45        integer yy        INTEGER fac
46        integer mm        INTEGER date_1
47        integer dd        INTEGER date_2
48        integer ss        INTEGER ierr
49        integer lp        LOGICAL wrong_sign
50        integer wd        CHARACTER*(MAX_LEN_MBUF) msgBuf
51        integer fac  C     == end of interface ==
52        integer date_1  
53        integer date_2        IF ( cal_setStatus .LT. 1 ) THEN
54        integer check_sign_1          WRITE( msgBuf,'(2A,4I9)') 'CAL_CONVDATE: ',
55        integer check_sign_2       &       'date=',date(1),date(2),date(3),date(4)
56        integer ierr          CALL PRINT_ERROR( msgBuf, myThid )
57            WRITE( msgBuf,'(2A,I2,A)') 'CAL_CONVDATE: ',
58  c     == end of interface ==       &    '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        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  c     Check the sign of the date.        if ( wrong_sign ) then
69            ierr = 901
70        check_sign_1 = sign(1,date(1))          call cal_PrintError( ierr, myThid )
71        check_sign_2 = sign(1,date(2))          stop ' stopped in cal_ConvDate.'
72          else
73        if ( check_sign_1*check_sign_2 .ge. 0 ) then          if ( date(1).lt.0 .OR. date(2).lt.0 ) then
         if (date(1) .eq. 0) then  
           date_1 = date(1)  
           if (date(2) .lt. 0) then  
             date_2 = -date(2)  
             fac    = -1  
           else  
             date_2 = date(2)  
             fac    = 1  
           endif  
         else if (date(1) .lt. 0) then  
74            date_1 = -date(1)            date_1 = -date(1)
75            date_2 = -date(2)            date_2 = -date(2)
76            fac    = -1            fac    = -1
# Line 85  c     Check the sign of the date. Line 79  c     Check the sign of the date.
79            date_2 = date(2)            date_2 = date(2)
80            fac    = 1            fac    = 1
81          endif          endif
       else  
   
         ierr = 901  
         call cal_PrintError( ierr, mythid )  
         stop ' stopped in cal_ConvDate.'  
   
82        endif        endif
83    
84  c     Decompose the entries.  C     Decompose the entries.
85        if (date(4) .ne. -1) then        if (date(4) .ne. -1) then
86          yy = date_1/10000          yy = date_1/10000
87          mm = mod(date_1/100,100)          mm = mod(date_1/100,100)
# Line 104  c     Decompose the entries. Line 92  c     Decompose the entries.
92          dd = date_1          dd = date_1
93        endif        endif
94        ss = mod(date_2,100) +        ss = mod(date_2,100) +
95       &     mod(date_2/100,100)*secondsperminute +       &     mod(date_2/100,100)*secondsPerMinute +
96       &     date_2/10000*secondsperhour       &     date_2/10000*secondsPerHour
97    
98  c     Include the sign.  C     Include the sign.
99        yy = fac*yy        yy = fac*yy
100        mm = fac*mm        mm = fac*mm
101        dd = fac*dd        dd = fac*dd
# Line 116  c     Include the sign. Line 104  c     Include the sign.
104        lp = date(3)        lp = date(3)
105        wd = date(4)        wd = date(4)
106    
107        return        RETURN
108        end        END
   

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.6

  ViewVC Help
Powered by ViewVC 1.1.22