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
0003 subroutine cal_MonthsForYear(
0004 I iyear,
0005 O firstmonth,
0006 O lastmonth,
0007 O nmonths,
0008 I mythid
0009 & )
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031 implicit none
0032
0033
0034
0035 #include "cal.h"
0036
0037
0038
0039 integer iyear
0040 integer firstmonth
0041 integer lastmonth
0042 integer nmonths
0043 integer mythid
0044
0045
0046
0047 integer ierr
0048 integer numyears
0049 integer firstyear
0050 integer firstmon
0051 integer lastyear
0052 integer lastmon
0053 integer lastday
0054 integer lastsecs
0055
0056
0057
0058 integer cal_IntYears
0059 external cal_IntYears
0060
0061
0062
0063 numyears = cal_IntYears( mythid )
0064
0065 firstyear = modelstartdate(1)/10000
0066 firstmon = mod(modelstartdate(1)/100,100)
0067 lastyear = modelenddate(1)/10000
0068 lastmon = mod(modelenddate(1)/100,100)
0069 lastday = mod(modelenddate(1),100)
0070 lastsecs = modelenddate(2)/10000*secondsperhour +
0071 & mod(modelenddate(2)/100,100)*secondsperminute +
0072 & mod(modelenddate(2),100)
0073
0074 if ( numyears .eq. 1 ) then
0075
0076 if ( iyear .eq. 1 ) then
0077 if ( firstyear .eq. lastyear ) then
0078 if ( (lastday .eq. 1) .and. (lastsecs .eq. 0) ) then
0079
0080 lastmonth = lastmon - firstmon
0081 else
0082
0083 lastmonth = lastmon - firstmon + 1
0084 endif
0085 firstmonth = 1
0086 else if ( firstyear+1 .eq. lastyear ) then
0087
0088
0089 if ( ( modelenddate(2) .eq. 0) .and.
0090 & ( mod(modelenddate(1),100) .eq. 1 ) .and.
0091 & mod(modelenddate(1)/100,100) .eq. 1 ) then
0092 firstmonth = 1
0093 lastmonth = nmonthyear - firstmon + 1
0094 else
0095
0096 ierr = 2804
0097 call cal_PrintError( ierr, mythid )
0098 stop ' stopped in cal_MonthsForYear.'
0099 endif
0100 else
0101
0102 ierr = 2803
0103 call cal_PrintError( ierr, mythid )
0104 stop ' stopped in cal_MonthsForYear.'
0105 endif
0106 else
0107
0108
0109 ierr = 2802
0110 call cal_PrintError( ierr, mythid )
0111 stop ' stopped in cal_MonthsForYear.'
0112 endif
0113
0114 else if ( numyears .gt. 1 ) then
0115
0116 if ( iyear .eq. 1 ) then
0117 firstmonth = 1
0118 lastmonth = nmonthyear - firstmon + 1
0119 else if ( ( iyear .gt. 1 ) .and.
0120 & ( iyear .lt. numyears ) ) then
0121
0122 firstmonth = (nmonthyear - firstmon + 1) +
0123 & (iyear - 2)*nmonthyear + 1
0124 lastmonth = (nmonthyear - firstmon + 1) +
0125 & (iyear - 2)*nmonthyear + nmonthyear
0126 else if ( iyear .eq. numyears ) then
0127
0128 if ( lastyear .eq. (firstyear + numyears - 1) ) then
0129 if ( (lastday .eq. 1) .and. (lastsecs .eq. 0) ) then
0130
0131 lastmonth = (nmonthyear - firstmon + 1) +
0132 & (numyears - 2)*nmonthyear + lastmon - 1
0133 else
0134
0135 lastmonth = (nmonthyear - firstmon + 1) +
0136 & (numyears - 2)*nmonthyear + lastmon
0137 endif
0138 firstmonth = (nmonthyear - firstmon + 1) +
0139 & (numyears - 2)*nmonthyear + 1
0140 else if ( lastyear .eq. (firstyear + numyears) ) then
0141
0142 if ( ( modelenddate(2) .eq. 0) .and.
0143 & ( mod(modelenddate(1),100) .eq. 1 ) .and.
0144 & mod(modelenddate(1)/100,100) .eq. 1 ) then
0145 firstmonth = (nmonthyear - firstmon) +
0146 & (numyears - 2)*nmonthyear + 1
0147 lastmonth = (nmonthyear - firstmon) +
0148 & (numyears - 2)*nmonthyear + nmonthyear
0149 else
0150
0151 ierr = 2807
0152 call cal_PrintError( ierr, mythid )
0153 stop ' stopped in cal_MonthsForYear.'
0154 endif
0155 else
0156
0157 ierr = 2806
0158 call cal_PrintError( ierr, mythid )
0159 stop ' stopped in cal_MonthsForYear.'
0160 endif
0161 else
0162
0163 ierr = 2805
0164 call cal_PrintError( ierr, mythid )
0165 stop ' stopped in cal_MonthsForYear.'
0166 endif
0167
0168 else
0169
0170 ierr = 2801
0171 call cal_PrintError( ierr, mythid )
0172 stop ' stopped in cal_MonthsForYear.'
0173 endif
0174
0175
0176 nmonths = lastmonth - firstmonth + 1
0177
0178 return
0179 end
0180