1 |
C $Header: /u/gcmpack/MITgcm/pkg/cal/cal_subdates.F,v 1.2 2003/10/09 04:19:19 edhill Exp $ |
2 |
C $Name: $ |
3 |
|
4 |
#include "CAL_OPTIONS.h" |
5 |
|
6 |
SUBROUTINE CAL_SUBDATES( |
7 |
I finaldate, |
8 |
I initialdate, |
9 |
O diffdate, |
10 |
I myThid ) |
11 |
|
12 |
C ================================================================== |
13 |
C SUBROUTINE cal_SubDates |
14 |
C ================================================================== |
15 |
C |
16 |
C o Subtract two dates. In case calendar dates are given finaldate |
17 |
C must be after initialdate. |
18 |
C |
19 |
C started: Christian Eckert eckert@mit.edu 30-Jun-1999 |
20 |
C changed: Christian Eckert eckert@mit.edu 29-Dec-1999 |
21 |
C - restructured the original version in order to have a |
22 |
C better interface to the MITgcmUV. |
23 |
C Christian Eckert eckert@mit.edu 03-Feb-2000 |
24 |
C - Introduced new routine and function names, cal_<NAME>, |
25 |
C for verion 0.1.3. |
26 |
C |
27 |
C ================================================================== |
28 |
C SUBROUTINE cal_SubDates |
29 |
C ================================================================== |
30 |
|
31 |
IMPLICIT NONE |
32 |
|
33 |
C == global variables == |
34 |
#include "EEPARAMS.h" |
35 |
#include "cal.h" |
36 |
|
37 |
C == routine arguments == |
38 |
INTEGER finaldate(4) |
39 |
INTEGER initialdate(4) |
40 |
INTEGER diffdate(4) |
41 |
INTEGER myThid |
42 |
|
43 |
C == local variables == |
44 |
INTEGER workdate(4) |
45 |
INTEGER ierr |
46 |
CHARACTER*(MAX_LEN_MBUF) msgBuf |
47 |
|
48 |
C == end of interface == |
49 |
|
50 |
IF ( cal_setStatus .LT. 1 ) THEN |
51 |
WRITE( msgBuf,'(2A,4I9)') 'CAL_SUBDATES: ', 'finaldate=', |
52 |
& finaldate(1),finaldate(2),finaldate(3),finaldate(4) |
53 |
CALL PRINT_ERROR( msgBuf, myThid ) |
54 |
WRITE( msgBuf,'(2A,4I9)') 'CAL_SUBDATES: ', 'initialdate=', |
55 |
& initialdate(1),initialdate(2),initialdate(3),initialdate(4) |
56 |
CALL PRINT_ERROR( msgBuf, myThid ) |
57 |
WRITE( msgBuf,'(2A,I2,A)') 'CAL_SUBDATES: ', |
58 |
& 'called too early (cal_setStatus=',cal_setStatus,' )' |
59 |
CALL PRINT_ERROR( msgBuf, myThid ) |
60 |
STOP 'ABNORMAL END: S/R CAL_SUBDATES' |
61 |
ENDIF |
62 |
|
63 |
if ((initialdate(4) .gt. 0) .eqv. |
64 |
& ( finaldate(4) .gt. 0)) then |
65 |
|
66 |
if (initialdate(4) .eq. -1) then |
67 |
C The time interval is subtracted. |
68 |
workdate(1) = -initialdate(1) |
69 |
workdate(2) = -initialdate(2) |
70 |
workdate(3) = 0 |
71 |
workdate(4) = -1 |
72 |
call cal_AddTime( finaldate, workdate, diffdate, myThid ) |
73 |
else |
74 |
C The time interval between initial and final date is calculated. |
75 |
call cal_TimePassed( |
76 |
& initialdate, finaldate, diffdate, myThid ) |
77 |
endif |
78 |
else |
79 |
|
80 |
ierr = 801 |
81 |
call cal_PrintError( ierr, myThid ) |
82 |
stop ' stopped in cal_SubDates.' |
83 |
|
84 |
endif |
85 |
|
86 |
RETURN |
87 |
END |