1 |
C $Header: /u/gcmpack/MITgcm/pkg/cal/cal_getdate.F,v 1.4 2012/04/07 15:53:14 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 |
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_GetDate |
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 myIter |
39 |
_RL myTime |
40 |
INTEGER mydate(4) |
41 |
INTEGER myThid |
42 |
|
43 |
C == local variables == |
44 |
_RL secs |
45 |
INTEGER workdate(4) |
46 |
CHARACTER*(MAX_LEN_MBUF) msgBuf |
47 |
C == end of interface == |
48 |
|
49 |
IF ( myIter .EQ. -1 ) THEN |
50 |
|
51 |
C- Special case to return starDate_1 & _2 : |
52 |
mydate(1) = startdate_1 |
53 |
mydate(2) = startdate_2 |
54 |
mydate(3) = 1 |
55 |
mydate(4) = 1 |
56 |
|
57 |
ELSEIF ( cal_setStatus .LT. 3 ) THEN |
58 |
|
59 |
WRITE( msgBuf,'(2A,I10,A,F19.2)') 'CAL_GETDATE: ', |
60 |
& 'myIter=', myIter, ' , myTime=', myTime |
61 |
CALL PRINT_ERROR( msgBuf, myThid ) |
62 |
WRITE( msgBuf,'(2A,I2,A)') 'CAL_GETDATE: ', |
63 |
& 'called too early (cal_setStatus=',cal_setStatus,' )' |
64 |
CALL PRINT_ERROR( msgBuf, myThid ) |
65 |
STOP 'ABNORMAL END: S/R CAL_GETDATE' |
66 |
|
67 |
ELSEIF ( myIter.EQ.modeliter0 .OR. myTime.EQ.modelstart ) THEN |
68 |
|
69 |
C- faster to just copy modelstartdate: |
70 |
mydate(1) = modelstartdate(1) |
71 |
mydate(2) = modelstartdate(2) |
72 |
mydate(3) = modelstartdate(3) |
73 |
mydate(4) = modelstartdate(4) |
74 |
|
75 |
ELSE |
76 |
|
77 |
if (myTime .lt. 0) then |
78 |
if (myIter .ge. 0) then |
79 |
secs = float(myIter - modeliter0)*modelstep |
80 |
else |
81 |
print*,' cal_GetDate: Not a valid input!' |
82 |
STOP 'ABNORMAL END: S/R CAL_GETDATE' |
83 |
endif |
84 |
else |
85 |
secs = myTime - modelstart |
86 |
endif |
87 |
|
88 |
call cal_TimeInterval( secs, 'secs', workdate, myThid ) |
89 |
call cal_AddTime( modelstartdate, workdate, mydate, myThid ) |
90 |
|
91 |
ENDIF |
92 |
|
93 |
RETURN |
94 |
END |