1 |
jmc |
1.3 |
C $Header: /u/gcmpack/MITgcm/pkg/cal/cal_subdates.F,v 1.2 2003/10/09 04:19:19 edhill Exp $ |
2 |
edhill |
1.2 |
C $Name: $ |
3 |
heimbach |
1.1 |
|
4 |
edhill |
1.2 |
#include "CAL_OPTIONS.h" |
5 |
heimbach |
1.1 |
|
6 |
jmc |
1.3 |
SUBROUTINE CAL_SUBDATES( |
7 |
heimbach |
1.1 |
I finaldate, |
8 |
|
|
I initialdate, |
9 |
|
|
O diffdate, |
10 |
jmc |
1.3 |
I myThid ) |
11 |
heimbach |
1.1 |
|
12 |
jmc |
1.3 |
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 |
heimbach |
1.1 |
|
31 |
jmc |
1.3 |
IMPLICIT NONE |
32 |
heimbach |
1.1 |
|
33 |
jmc |
1.3 |
C == global variables == |
34 |
|
|
#include "EEPARAMS.h" |
35 |
heimbach |
1.1 |
#include "cal.h" |
36 |
|
|
|
37 |
jmc |
1.3 |
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 |
heimbach |
1.1 |
|
63 |
|
|
if ((initialdate(4) .gt. 0) .eqv. |
64 |
|
|
& ( finaldate(4) .gt. 0)) then |
65 |
|
|
|
66 |
|
|
if (initialdate(4) .eq. -1) then |
67 |
jmc |
1.3 |
C The time interval is subtracted. |
68 |
heimbach |
1.1 |
workdate(1) = -initialdate(1) |
69 |
|
|
workdate(2) = -initialdate(2) |
70 |
|
|
workdate(3) = 0 |
71 |
|
|
workdate(4) = -1 |
72 |
jmc |
1.3 |
call cal_AddTime( finaldate, workdate, diffdate, myThid ) |
73 |
heimbach |
1.1 |
else |
74 |
jmc |
1.3 |
C The time interval between initial and final date is calculated. |
75 |
|
|
call cal_TimePassed( |
76 |
|
|
& initialdate, finaldate, diffdate, myThid ) |
77 |
heimbach |
1.1 |
endif |
78 |
|
|
else |
79 |
|
|
|
80 |
|
|
ierr = 801 |
81 |
jmc |
1.3 |
call cal_PrintError( ierr, myThid ) |
82 |
heimbach |
1.1 |
stop ' stopped in cal_SubDates.' |
83 |
|
|
|
84 |
|
|
endif |
85 |
|
|
|
86 |
jmc |
1.3 |
RETURN |
87 |
|
|
END |