File indexing completed on 2018-03-02 18:39:19 UTC
view on githubraw file Latest commit add29e06 on 2018-01-31 20:35:05 UTC
8f7d13d0c9 Jean*0001 #include "ECCO_OPTIONS.h"
5001c65f45 Patr*0002
0003
0004 subroutine cost_AveragesFlags(
0005 I myiter,
0006 I mytime,
0007 I mythid,
0008 O first,
706976e7e4 Patr*0009 O last,
5001c65f45 Patr*0010 O startofday,
0011 O startofmonth,
706976e7e4 Patr*0012 O startofyear,
5001c65f45 Patr*0013 O inday,
0014 O inmonth,
706976e7e4 Patr*0015 O inyear,
5001c65f45 Patr*0016 O endofday,
0017 O endofmonth,
706976e7e4 Patr*0018 O endofyear,
5001c65f45 Patr*0019 O sum1day,
0020 O dayrec,
0021 O sum1mon,
706976e7e4 Patr*0022 O monrec,
0023 O sum1year,
0024 O yearrec
5001c65f45 Patr*0025 & )
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044 implicit none
0045
0046
0047
0048 #include "EEPARAMS.h"
0049 #include "SIZE.h"
0050
0051 #include "cal.h"
0052
0053
0054
0055 integer myiter
0056 _RL mytime
0057 integer mythid
0058 logical first
0059 logical startofday
0060 logical startofmonth
706976e7e4 Patr*0061 logical startofyear
5001c65f45 Patr*0062 logical inday
0063 logical inmonth
706976e7e4 Patr*0064 logical inyear
5001c65f45 Patr*0065 logical last
0066 logical endofday
0067 logical endofmonth
706976e7e4 Patr*0068 logical endofyear
5001c65f45 Patr*0069 integer sum1day
0070 integer dayrec
0071 integer sum1mon
0072 integer monrec
706976e7e4 Patr*0073 integer sum1year
0074 integer yearrec
5001c65f45 Patr*0075
0076
0077
0078 integer mydate(4)
0079 integer nextdate(4)
0080 integer prevdate(4)
0081 integer timediff(4)
0082 integer datediff(4)
0083 integer targetdate(4)
0084 integer targetdate1
0085 integer targetdate2
0086 integer mydateday
0087 integer mydatemonth
706976e7e4 Patr*0088 integer mydateyear
5001c65f45 Patr*0089 integer nextdateday
0090 integer nextdatemonth
706976e7e4 Patr*0091 integer nextdateyear
5001c65f45 Patr*0092 integer prevdateday
0093 integer prevdatemonth
706976e7e4 Patr*0094 integer prevdateyear
5001c65f45 Patr*0095
0096 logical equal
0097
0098
0099
0100 logical cal_CompDates
0101 external cal_CompDates
0102
0103 integer cal_NumInts
0104 external cal_NumInts
0105
0106
0107
0108
0109 call cal_GetDate( myiter, mytime, mydate, mythid )
0110 call cal_GetDate( myiter+1, mytime+modelstep, nextdate, mythid )
0111
0112 call cal_TimeInterval( -modelstep, 'secs', timediff, mythid )
0113 call cal_AddTime( mydate, timediff, prevdate, mythid )
0114
0115
0116
0117
0118
0119
0120
0121
0122 equal = cal_CompDates(modelstartdate,mydate,mythid)
0123 if ( equal ) then
0124 first = .true.
0125 dayrec = 0
0126 monrec = 0
706976e7e4 Patr*0127 yearrec = 0
5001c65f45 Patr*0128 else
0129 first = .false.
0130 endif
0131
0132
0133 equal = cal_CompDates(modelenddate,mydate,mythid)
0134 if ( equal ) then
0135 last = .true.
0136 else
0137 last = .false.
0138 endif
0139
0140
0141 mydateday = mod(mydate(1),100)
0142 prevdateday = mod(prevdate(1),100)
0143 if ( mydateday .ne. prevdateday ) then
0144 startofday = .true.
0145 else
0146 startofday = .false.
0147 endif
0148
0149
0150 mydateday = mod(mydate(1),100)
0151 nextdateday = mod(nextdate(1),100)
0152 if ( mydateday .ne. nextdateday ) then
0153 endofday = .true.
0154 else
0155 endofday = .false.
0156 endif
0157
0158
0159
0160
0161 if ( ( mydateday .eq. prevdateday ) .and.
0162 & ( mydateday .eq. nextdateday ) ) then
0163 inday = .true.
0164 else
0165 inday = .false.
0166 endif
0167
0168
0169 if ( last .or. endofday ) then
0170 if ( mydate(1) .eq. modelstartdate(1) ) then
0171 call cal_CopyDate( modelstartdate, targetdate, mythid )
0172 dayrec = 1
0173 else
0174 targetdate(1) = mydate(1)
0175 targetdate(2) = 0
0176 targetdate(3) = mydate(3)
0177 targetdate(4) = mydate(4)
0178 call cal_TimePassed( modelstartdate, targetdate, datediff,
0179 & mythid )
0180 if ( datediff(2) .eq. 0) then
0181 dayrec = datediff(1) + 1
0182 else
0183 dayrec = datediff(1) + 2
0184 endif
0185 endif
0186 call cal_TimeInterval( modelstep, 'secs', timediff, mythid )
0187
0188 sum1day =
0189 & cal_NumInts( targetdate, mydate, timediff, mythid ) + 1
0190 else
0191 sum1day = 0
0192 endif
0193
0194
0195 mydatemonth = mod(mydate(1)/100,100)
0196 prevdatemonth = mod(prevdate(1)/100,100)
0197 if ( mydatemonth .ne. prevdatemonth ) then
0198 startofmonth = .true.
0199 else
0200 startofmonth = .false.
0201 endif
0202
0203
0204 mydatemonth = mod(mydate(1)/100,100)
0205 nextdatemonth = mod(nextdate(1)/100,100)
0206 if ( mydatemonth .ne. nextdatemonth ) then
0207 endofmonth = .true.
0208 else
0209 endofmonth = .false.
0210 endif
0211
0212
0213
0214
0215 if ( ( mydatemonth .eq. prevdatemonth ) .and.
0216 & ( mydatemonth .eq. nextdatemonth ) ) then
0217 inmonth = .true.
0218 else
0219 inmonth = .false.
0220 endif
0221
0222
0223 if ( last .or. endofmonth ) then
0224 if ( (mydate(1)/100)*100 .eq. (modelstartdate(1)/100)*100 ) then
0225 call cal_CopyDate( modelstartdate, targetdate, mythid )
0226 monrec = 1
0227 else
0228 targetdate1 = (mydate(1)/100)*100+1
0229 targetdate2 = 0
0230 call cal_FullDate( targetdate1, targetdate2, targetdate,
0231 & mythid )
0232 if ( mydate(1)/10000 .eq. modelstartdate(1)/10000 ) then
0233 monrec = mod( mydate(1)/100, 100 )
0234 & - mod( modelstartdate(1)/100, 100 ) + 1
0235 else
0236 monrec = mod( mydate(1)/100, 100 )
0237 & + nmonthyear - mod(modelstartdate(1)/100,100) + 1
0238 & + ( mydate(1)/10000 - modelstartdate(1)/10000 - 1)*
951926fb9b Jean*0239 & nmonthyear
5001c65f45 Patr*0240 endif
0241 endif
0242 call cal_TimeInterval( modelstep, 'secs', timediff, mythid )
0243
951926fb9b Jean*0244 sum1mon =
5001c65f45 Patr*0245 & cal_NumInts( targetdate, mydate, timediff, mythid ) + 1
0246 else
0247 sum1mon = 0
0248 endif
0249
706976e7e4 Patr*0250
0251 mydateyear = int(mydate(1)/10000)
0252 prevdateyear = int(prevdate(1)/10000)
0253 if ( mydateyear .ne. prevdateyear ) then
0254 startofyear = .true.
0255 else
0256 startofyear = .false.
0257 endif
0258
0259
0260 mydateyear = int(mydate(1)/10000)
0261 nextdateyear = int(nextdate(1)/10000)
0262 if ( mydateyear .ne. nextdateyear ) then
0263 endofyear = .true.
0264 else
0265 endofyear = .false.
0266 endif
0267
0268
0269
0270
0271 if ( ( mydateyear .eq. prevdateyear ) .and.
0272 & ( mydateyear .eq. nextdateyear ) ) then
0273 inyear = .true.
0274 else
0275 inyear = .false.
0276 endif
0277
0278
0279 if ( last .or. endofyear ) then
951926fb9b Jean*0280 if ( int(mydate(1)/10000) .eq.
dc3b22adb0 Patr*0281 & int(modelstartdate(1)/10000) ) then
706976e7e4 Patr*0282 call cal_CopyDate( modelstartdate, targetdate, mythid )
0283 yearrec = 1
0284 else
dc3b22adb0 Patr*0285 targetdate1 = int(mydate(1)/10000)*10000+101
706976e7e4 Patr*0286 targetdate2 = 0
0287 call cal_FullDate( targetdate1, targetdate2, targetdate,
0288 & mythid )
0289 yearrec = mydate(1)/10000 - modelstartdate(1)/10000 + 1
0290 endif
0291
0292 call cal_TimeInterval( modelstep, 'secs', timediff, mythid )
0293
951926fb9b Jean*0294 sum1year =
706976e7e4 Patr*0295 & cal_NumInts( targetdate, mydate, timediff, mythid ) + 1
0296 else
0297 sum1year = 0
0298 endif
0299
5001c65f45 Patr*0300 end