1 |
C $Header: /u/gcmpack/MITgcm/pkg/cal/cal_getdate.F,v 1.5 2012/04/07 22:02:11 jmc Exp $ |
2 |
C $Name: $ |
3 |
|
4 |
#include "CAL_OPTIONS.h" |
5 |
|
6 |
SUBROUTINE CAL_GETDATE( |
7 |
I myIter, |
8 |
I myTime, |
9 |
O mydate, |
10 |
I myThid ) |
11 |
|
12 |
C ================================================================== |
13 |
C SUBROUTINE cal_GetDate |
14 |
C ================================================================== |
15 |
C |
16 |
C o Determine the current date given the iteration number and/or the |
17 |
C current time of integration. |
18 |
C <- changed to be function of current time only (less ambiguous) |
19 |
C |
20 |
C started: Christian Eckert eckert@mit.edu 30-Jun-1999 |
21 |
C changed: Christian Eckert eckert@mit.edu 29-Dec-1999 |
22 |
C - restructured the original version in order to have a |
23 |
C better interface to the MITgcmUV. |
24 |
C Christian Eckert eckert@mit.edu 03-Feb-2000 |
25 |
C - Introduced new routine and function names, cal_<NAME>, |
26 |
C for verion 0.1.3. |
27 |
C |
28 |
C ================================================================== |
29 |
C SUBROUTINE cal_GetDate |
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 myIter |
40 |
_RL myTime |
41 |
INTEGER mydate(4) |
42 |
INTEGER myThid |
43 |
|
44 |
C == local variables == |
45 |
_RL secs |
46 |
INTEGER workdate(4) |
47 |
CHARACTER*(MAX_LEN_MBUF) msgBuf |
48 |
C == end of interface == |
49 |
|
50 |
IF ( myIter .EQ. -1 ) THEN |
51 |
|
52 |
C- Special case to return starDate_1 & _2 : |
53 |
mydate(1) = startdate_1 |
54 |
mydate(2) = startdate_2 |
55 |
mydate(3) = 1 |
56 |
mydate(4) = 1 |
57 |
|
58 |
ELSEIF ( cal_setStatus .LT. 3 ) THEN |
59 |
|
60 |
WRITE( msgBuf,'(2A,I10,A,F19.2)') 'CAL_GETDATE: ', |
61 |
& 'myIter=', myIter, ' , myTime=', myTime |
62 |
CALL PRINT_ERROR( msgBuf, myThid ) |
63 |
WRITE( msgBuf,'(2A,I2,A)') 'CAL_GETDATE: ', |
64 |
& 'called too early (cal_setStatus=',cal_setStatus,' )' |
65 |
CALL PRINT_ERROR( msgBuf, myThid ) |
66 |
STOP 'ABNORMAL END: S/R CAL_GETDATE' |
67 |
|
68 |
c ELSEIF ( myIter.EQ.modelIter0 .OR. myTime.EQ.modelStart ) THEN |
69 |
ELSEIF ( myTime.EQ.modelStart ) THEN |
70 |
|
71 |
C- faster to just copy modelStartDate: |
72 |
mydate(1) = modelStartDate(1) |
73 |
mydate(2) = modelStartDate(2) |
74 |
mydate(3) = modelStartDate(3) |
75 |
mydate(4) = modelStartDate(4) |
76 |
|
77 |
ELSE |
78 |
|
79 |
c if ( myTime.lt.0. ) then |
80 |
c if (myIter .ge. 0) then |
81 |
c secs = float(myIter - modelIter0)*modelStep |
82 |
c else |
83 |
c print*,' cal_GetDate: Not a valid input!' |
84 |
c STOP 'ABNORMAL END: S/R CAL_GETDATE' |
85 |
c endif |
86 |
c else |
87 |
secs = myTime - modelStart |
88 |
c endif |
89 |
|
90 |
CALL CAL_TIMEINTERVAL( secs, 'secs', workdate, myThid ) |
91 |
CALL CAL_ADDTIME( modelStartDate, workdate, mydate, myThid ) |
92 |
|
93 |
ENDIF |
94 |
|
95 |
RETURN |
96 |
END |