File indexing completed on 2018-03-02 18:38:16 UTC
view on githubraw file Latest commit add29e06 on 2018-01-31 20:35:05 UTC
6d54cf9ca1 Ed H*0001 #include "CAL_OPTIONS.h"
a63ed37559 Patr*0002
3cb4ec9f6f Jean*0003 SUBROUTINE CAL_SET(
0004 I modstart, modend, modstep,
0005 I moditerini, moditerend, modintsteps,
0006 I myThid )
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047 IMPLICIT NONE
0048
0049
a63ed37559 Patr*0050
0051 #include "cal.h"
0052
3cb4ec9f6f Jean*0053
0054
0055
0056
0057
0058
0059
0060
a63ed37559 Patr*0061
0062 _RL modstart
0063 _RL modend
0064 _RL modstep
3cb4ec9f6f Jean*0065 INTEGER moditerini
0066 INTEGER moditerend
0067 INTEGER modintsteps
0068 INTEGER myThid
0069
0070
ce3a0fd2a0 Jean*0071
0072
3cb4ec9f6f Jean*0073 INTEGER i,j,k
0074 INTEGER ierr
0075 INTEGER timediff(4)
0076 INTEGER iterinitime(4)
ce3a0fd2a0 Jean*0077 INTEGER modelBaseDate(4)
a63ed37559 Patr*0078 _RL runtimesecs
0079 _RL iterinisecs
3cb4ec9f6f Jean*0080
a63ed37559 Patr*0081
ce3a0fd2a0 Jean*0082 _BEGIN_MASTER(myThid)
a63ed37559 Patr*0083
13a16b18e5 Jean*0084
0085 usingNoLeapYearCal = .FALSE.
ce3a0fd2a0 Jean*0086 usingGregorianCalendar = .FALSE.
0087 usingModelCalendar = .FALSE.
0088 usingJulianCalendar = .FALSE.
a63ed37559 Patr*0089
13a16b18e5 Jean*0090
0091 hoursPerDay = 24
0092 minutesPerHour = 60
0093 minutesPerDay = minutesPerHour*hoursPerDay
0094 secondsPerMinute = 60
0095 secondsPerHour = secondsPerMinute*minutesPerHour
0096 secondsPerDay = secondsPerMinute*minutesPerDay
a63ed37559 Patr*0097
13a16b18e5 Jean*0098
0099 IF ( theCalendar .EQ. 'gregorian') THEN
ce3a0fd2a0 Jean*0100 usingGregorianCalendar = .TRUE.
13a16b18e5 Jean*0101
0102
0103
0104 ELSE IF ( theCalendar .EQ. 'noLeapYear') THEN
0105 usingNoLeapYearCal = .TRUE.
0106 ELSE IF ( theCalendar .EQ. 'model') THEN
0107 usingModelCalendar = .TRUE.
0108
0109
0110
0111 ELSE
0112 ierr = 101
0113 CALL cal_PrintError( ierr, myThid )
0114 STOP
0115 ENDIF
0116
0117
0118
0119 IF ( usingGregorianCalendar .OR. usingNoLeapYearCal ) THEN
3cb4ec9f6f Jean*0120
0121
0122
0123
82e480d1a1 Jean*0124 refDate(1) = 15821015
0125 refDate(2) = 0
0126 refDate(3) = 1
0127 refDate(4) = 1
a63ed37559 Patr*0128
3cb4ec9f6f Jean*0129
82e480d1a1 Jean*0130 nDaysNoLeap = 365
0131 nDaysLeap = 366
0132 nMaxDayMonth = 31
a63ed37559 Patr*0133
3cb4ec9f6f Jean*0134
0135
0136
0137
0138
0139
a63ed37559 Patr*0140 k=2773
13a16b18e5 Jean*0141 DO i=1,nMonthYear
0142 j = MOD(k,2)
a63ed37559 Patr*0143 k = (k-j)/2
82e480d1a1 Jean*0144 nDayMonth(i,1) = 30+j
0145 nDayMonth(i,2) = 30+j
13a16b18e5 Jean*0146 ENDDO
82e480d1a1 Jean*0147 nDayMonth(2,1) = 28
0148 nDayMonth(2,2) = 29
a63ed37559 Patr*0149
3cb4ec9f6f Jean*0150
82e480d1a1 Jean*0151 dayOfWeek(1) = 'FRI'
0152 dayOfWeek(2) = 'SAT'
0153 dayOfWeek(3) = 'SUN'
0154 dayOfWeek(4) = 'MON'
0155 dayOfWeek(5) = 'TUE'
0156 dayOfWeek(6) = 'WED'
0157 dayOfWeek(7) = 'THU'
13a16b18e5 Jean*0158 ENDIF
a63ed37559 Patr*0159
13a16b18e5 Jean*0160 IF ( usingModelCalendar ) THEN
3cb4ec9f6f Jean*0161
ce3a0fd2a0 Jean*0162
82e480d1a1 Jean*0163 refDate(1) = 00000101
0164 refDate(2) = 0
0165 refDate(3) = 1
0166 refDate(4) = 1
a63ed37559 Patr*0167
3cb4ec9f6f Jean*0168
82e480d1a1 Jean*0169 nDaysNoLeap = 360
0170 nDaysLeap = 360
0171 nMaxDayMonth = 30
13a16b18e5 Jean*0172 DO i=1,nMonthYear
82e480d1a1 Jean*0173 nDayMonth(i,1) = 30
0174 nDayMonth(i,2) = 30
13a16b18e5 Jean*0175 ENDDO
a63ed37559 Patr*0176
3cb4ec9f6f Jean*0177
82e480d1a1 Jean*0178 dayOfWeek(1) = 'MD1'
0179 dayOfWeek(2) = 'MD2'
0180 dayOfWeek(3) = 'MD3'
0181 dayOfWeek(4) = 'MD4'
0182 dayOfWeek(5) = 'MD5'
0183 dayOfWeek(6) = 'MD6'
0184 dayOfWeek(7) = 'MD7'
a63ed37559 Patr*0185
13a16b18e5 Jean*0186 ENDIF
a63ed37559 Patr*0187
ce3a0fd2a0 Jean*0188
0189 cal_setStatus = 1
0190
0191
82e480d1a1 Jean*0192 modelStart = modstart
0193 modelEnd = modend
0194 modelStep = modstep
0195 modelIter0 = moditerini
0196 modelIterEnd = moditerend
0197 modelIntSteps = modintsteps
ce3a0fd2a0 Jean*0198
0199
0200
13a16b18e5 Jean*0201 IF ( modelStep .LE. 0. ) THEN
ce3a0fd2a0 Jean*0202 ierr = 102
13a16b18e5 Jean*0203 CALL cal_PrintError( ierr, myThid )
0204 STOP ' stopped in cal_Set.'
0205 ENDIF
0206 IF ( modelStep .LT. 1. ) THEN
ce3a0fd2a0 Jean*0207 ierr = 103
13a16b18e5 Jean*0208 CALL cal_PrintError( ierr, myThid )
0209 STOP ' stopped in cal_Set.'
0210 ENDIF
0211 IF ( ABS(modelStep - NINT(modelStep)) .GT. 0.000001 ) THEN
ce3a0fd2a0 Jean*0212 ierr = 104
13a16b18e5 Jean*0213 CALL cal_PrintError( ierr, myThid )
0214 STOP ' stopped in cal_Set.'
0215 ELSE
0216 modelStep = FLOAT(NINT(modelStep))
0217 ENDIF
ce3a0fd2a0 Jean*0218
0219
0220 cal_setStatus = 2
a63ed37559 Patr*0221
3cb4ec9f6f Jean*0222
13a16b18e5 Jean*0223 CALL cal_FullDate( startdate_1, startdate_2,
ce3a0fd2a0 Jean*0224 & modelBaseDate, myThid )
3cb4ec9f6f Jean*0225
0226
0227
82e480d1a1 Jean*0228
3cb4ec9f6f Jean*0229
82e480d1a1 Jean*0230 runtimesecs = modelIntSteps*modelStep
3cb4ec9f6f Jean*0231
0232
82e480d1a1 Jean*0233
3cb4ec9f6f Jean*0234
82e480d1a1 Jean*0235 iterinisecs = modelStart
13a16b18e5 Jean*0236 CALL cal_TimeInterval( iterinisecs, 'secs', iterinitime, myThid )
0237 CALL cal_AddTime( modelBaseDate, iterinitime, modelStartDate,
3cb4ec9f6f Jean*0238 & myThid )
a63ed37559 Patr*0239
13a16b18e5 Jean*0240 CALL cal_TimeInterval( runtimesecs, 'secs', timediff, myThid )
0241 CALL cal_AddTime( modelStartDate, timediff, modelEndDate,
3cb4ec9f6f Jean*0242 & myThid )
0243
ce3a0fd2a0 Jean*0244
0245 cal_setStatus = 3
0246
0247 _END_MASTER(myThid)
0248
0249
0250 _BARRIER
3cb4ec9f6f Jean*0251
0252 RETURN
0253 END