13SUBROUTINE metread(lfn, MetArray, InputmetFormat, ldown_option, NetRadiationMethod, &
14 SnowUse, SMDMethod, SoilDepthMeas, SoilRocks, SoilDensity, SmCap)
21 REAL(KIND(1D0)),
DIMENSION(24) :: MetArray
25 REAL(KIND(1D0)) :: SmCap, &
30 INTEGER :: InputmetFormat, &
37 REAL(KIND(1D0)) :: avkdn, &
64 INTEGER :: iostat_var, lfn
69 IF (inputmetformat == 0)
THEN
71 READ (lfn, *, iostat=iostat_var) iy, id, it, imin, qn1_obs, avu1, avrh, &
72 temp_c, wdir, pres_kpa, precip, avkdn, snowfrac_obs, ldown_obs, fcld_obs
84 ELSEIF (inputmetformat == 10)
THEN
85 READ (lfn, *, iostat=iostat_var) iy, id, it, imin, qn1_obs, qh_obs, qe_obs, qs_obs, qf_obs, avu1, avrh, &
86 temp_c, pres_kpa, precip, avkdn, snowfrac_obs, ldown_obs, fcld_obs, &
87 wu_m3, xsmd, lai_obs, kdiff, kdir, wdir
96 IF (smdmethod == 1 .AND. xsmd /= -999)
THEN
97 xsmd = (smcap - xsmd)*soildepthmeas*soilrocks
98 ELSEIF (smdmethod == 2 .AND. xsmd /= -999)
THEN
99 xsmd = (smcap - xsmd)*soildensity*soildepthmeas*soilrocks
109 pres_hpa = pres_kpa*10.
112 dectime = id + it + imin/60.0
114 IF (iostat_var < 0)
THEN
121 CALL errorhint(27,
'Met Data: avKdn - needed for StoreDrainPrm. resistance, If present, check file not tab delimited', &
127 IF ((ldown_option == 1) .AND. (ldown_obs < 0))
THEN
128 CALL errorhint(27,
'Met Data: LWdn (ldown_obs) - impact Q* calc', ldown_obs, dectime,
notusedi)
130 ELSEIF (ldown_option == 2)
THEN
131 IF (fcld_obs == -999.0 .OR. fcld_obs < 0 .OR. fcld_obs > 1)
THEN
132 CALL errorhint(27,
'Met Data: flcd_obs - impacts LW & Q* radiation', fcld_obs, dectime,
notusedi)
136 IF (qn1_obs == -999 .AND. netradiationmethod == 0)
THEN
137 CALL errorhint(27,
'Met Data: Q* - will impact everything', qn1_obs, dectime,
notusedi)
141 CALL errorhint(27,
'Met Data: avU1 - impacts aeroydnamic resistances', avu1, dectime,
notusedi)
144 IF (temp_c < -50 .OR. temp_c > 60)
THEN
145 CALL errorhint(27,
'Met Data: Temp_C - beyond what is expected', temp_c, dectime,
notusedi)
148 IF (avrh > 100 .OR. avrh < 1)
THEN
149 CALL errorhint(27,
'Met Data: avRH - beyond what is expected', avrh, dectime,
notusedi)
152 IF (pres_kpa < 80)
THEN
153 CALL errorhint(27,
'Met Data: Pres_kPa - too low - this could be fixed in model', pres_kpa, dectime,
notusedi)
160 IF (snowfrac_obs ==
nan) snowfrac_obs = 0
162 IF (snowuse == 0 .AND. (snowfrac_obs < 0 .OR. snowfrac_obs > 1))
THEN
163 CALL errorhint(27,
'Met Data: snow not between [0 1]', snowfrac_obs, dectime,
notusedi)
166 IF (xsmd < 0 .AND. smdmethod == 1)
THEN
171 metarray(1:24) = (/iy, id, it, imin, qn1_obs, qh_obs, qe_obs, qs_obs, qf_obs, avu1, &
172 avrh, temp_c, pres_hpa, precip, avkdn, snowfrac_obs, ldown_obs, &
173 fcld_obs, wu_m3, xsmd, lai_obs, kdiff, kdir, wdir/)
195 CHARACTER(len=90),
DIMENSION(14) ::
text
208 INTEGER :: eval, i, lowerlimit, upperlimit
209 CHARACTER(len=4) :: check
215 IF (check(i:i) ==
"#")
THEN
227 WRITE (12, 120) eval,
text(1)
229 IF (eval < lowerlimit .OR. eval > upperlimit)
THEN
230 WRITE (*, *)
"Value out of range"
231 WRITE (*, *) eval,
text(1)
235 WRITE (*, 120) eval,
text(1)
236120
FORMAT(i4, 2x, a90)
246 INTEGER :: skip, lfn, i
248 READ (lfn, *, err=201, iostat=
ios_out)
253201
reall = real(skip)
276 CHARACTER(len=50) :: FileName
608 IF (
filename ==
'SUEWS_NonVeg.txt')
THEN
616 ELSEIF (
filename ==
'SUEWS_Veg.txt')
THEN
622 ELSEIF (
filename ==
'SUEWS_Water.txt')
THEN
630 ELSEIF (
filename ==
'SUEWS_Snow.txt')
THEN
636 ELSEIF (
filename ==
'SUEWS_Soil.txt')
THEN
642 ELSEIF (
filename ==
'SUEWS_Conductance.txt')
THEN
648 ELSEIF (
filename ==
'SUEWS_OHMCoefficients.txt')
THEN
651 CALL errorhint(56,
'Names or order of columns in SUEWS_OHMCoefficients.txt does not match model code.', &
655 ELSEIF (
filename ==
'SUEWS_ESTMCoefficients.txt')
THEN
658 CALL errorhint(56,
'Names or order of columns in SUEWS_ESTMCoefficients.txt does not match model code.', &
662 ELSEIF (
filename ==
'SUEWS_AnthropogenicEmission.txt')
THEN
665 CALL errorhint(56,
'Names or order of columns in SUEWS_AnthropogenicEmission.txt does not match model code.', &
669 ELSEIF (
filename ==
'SUEWS_Irrigation.txt')
THEN
674 CALL errorhint(56,
'Names or order of columns in SUEWS_Irrigation.txt does not match model code.', &
678 ELSEIF (
filename ==
'SUEWS_Profiles.txt')
THEN
681 CALL errorhint(56,
'Names or order of columns in SUEWS_Profiles.txt does not match model code.', &
685 ELSEIF (
filename ==
'SUEWS_WithinGridWaterDist.txt')
THEN
688 CALL errorhint(56,
'Names or order of columns in SUEWS_WithinGridWaterDist.txt does not match model code.', &
692 ELSEIF (
filename ==
'SUEWS_BiogenCO2.txt')
THEN
695 CALL errorhint(56,
'Names or order of columns in SUEWS_BiogenCO2.txt does not match model code.', &
700 WRITE (*, *)
'Problem in subroutine InputHeaderCheck. File header not specified in model code for ',
filename
751 INTEGER,
INTENT(IN) :: hour, min, sec
752 INTEGER :: total_sec, secperhour
753 REAL(kind(1d0)),
DIMENSION(0:23),
INTENT(IN) :: prof_24h
754 REAL(kind(1d0)) :: deltaprof
755 REAL(kind(1d0)) :: prof_currtime
757 total_sec = min*60 + sec
764 deltaprof = (prof_24h(j) - prof_24h(i))/secperhour
765 prof_currtime = prof_24h(hour) + deltaprof*total_sec
777 INTEGER,
INTENT(IN) :: hour, min, sec
778 INTEGER :: total_sec, secperhour
779 REAL(kind(1d0)),
DIMENSION(0:23),
INTENT(IN) :: prof_24h
780 REAL(kind(1d0)),
DIMENSION(0:23) :: prof_24h_mean
781 REAL(kind(1d0)) :: deltaprof
782 REAL(kind(1d0)) :: prof_currtime
784 total_sec = min*60 + sec
787 prof_24h_mean = merge(prof_24h/(sum(prof_24h)/
SIZE(prof_24h, dim=1)), 0.d0, sum(prof_24h) /= 0)
794 deltaprof = (prof_24h_mean(j) - prof_24h_mean(i))/secperhour
797 prof_currtime = prof_24h_mean(i) + deltaprof*total_sec
809 INTEGER,
INTENT(IN) :: hour, min, sec, dt
810 INTEGER :: total_sec, secperhour
811 REAL(kind(1d0)),
DIMENSION(0:23),
INTENT(IN) :: prof_24h
812 REAL(kind(1d0)),
DIMENSION(0:23) :: prof_24h_sum
813 REAL(kind(1d0)) :: deltaprof
814 REAL(kind(1d0)) :: prof_currtime
816 total_sec = min*60 + sec
819 prof_24h_sum = merge(prof_24h/(sum(prof_24h)), 0.d0, sum(prof_24h) /= 0)
825 deltaprof = (prof_24h_sum(j) - prof_24h_sum(i))/secperhour
826 prof_currtime = prof_24h_sum(hour) + deltaprof*total_sec
827 prof_currtime = prof_currtime*dt/secperhour
852 CHARACTER(len=4) :: SWWD
856 IF (swwd ==
'SWet')
THEN
863 'not found in OHM_Coefficients.txt for surface', is,
'.'
868 ELSEIF (swwd ==
'SDry')
THEN
875 'not found in OHM_Coefficients.txt for surface', is,
'.'
880 ELSEIF (swwd ==
'WWet')
THEN
887 'not found in OHM_Coefficients.txt for surface', is,
'.'
892 ELSEIF (swwd ==
'WDry')
THEN
899 'not found in OHM_Coefficients.txt for surface', is,
'.'
905 WRITE (*, *)
'Problem with CodeMatchOHM (in SUEWS_CodeMatch.f95). ', swwd,
' not recognised. Needs to be one of: ', &
906 'SWet = Summer Wet, SDry = Summer Dry, WWet = WinterWet, WDry = Winter Dry. N.B. Case sensitive. '
938 'not found in ESTM_Coefficients.txt for surface', is,
'.'
970 'not found in ESTM_Coefficients.txt for surface', is,
'.'
980 'not found in ESTM_Coefficients.txt for surface', is,
'.'
985 WRITE (*, *)
'Problem with CodeMatchESTM_Class (in SUEWS_ctrl_input.f95). ', is,
' not correct. Needs to be either ', &
986 '1 = Paved surfaced, 2 = Bldgs surfaces.'
1007 INTEGER :: SurfaceCharCodeCol
1015 WRITE (*, *)
'Program stopped! Profile code ',
surfacechar(gridiv, surfacecharcodecol),
'not found in SUEWS_Profiles.txt.'
1039 INTEGER :: codeCol, codeColSameSurf
1047 WRITE (*, *)
'Program stopped! Within-grid water distribution code ',
siteselect(rr, codecol), &
1048 'not found in SUEWS_WaterDistWithinGrid.txt.'
1055 CALL errorhint(8,
'Diagonal elements should be zero as water cannot move from one surface to the same surface.', &
1065 CALL errorhint(9,
'One of these (ToRunoff,ToSoilStore) should be zero.', &
1074 CALL errorhint(8,
'Total water distribution from each surface should add up to 1.', &
1104 WRITE (*, *)
'Program stopped! NonVeg code ',
siteselect(rr, codecol),
'not found in SUEWS_NonVeg.txt.'
1134 WRITE (*, *)
'Program stopped! Veg code ',
siteselect(rr, codecol),
'not found in SUEWS_Vegs.txt.'
1164 WRITE (*, *)
'Program stopped! Water code ',
siteselect(rr, codecol),
'not found in SUEWS_Water.txt.'
1194 WRITE (*, *)
'Program stopped! Snow code ',
siteselect(rr, codecol),
'not found in SUEWS_Snow.txt.'
1224 WRITE (*, *)
'Program stopped! Conductance code ',
siteselect(rr, codecol),
'not found in SUEWS_Conductance.txt.'
1255 WRITE (*, *)
'Program stopped! Anthropogenic code ',
siteselect(rr, codecol), &
1256 'not found in SUEWS_AnthropogenicEmission.txt.'
1257 CALL errorhint(57,
'Cannot find code in SUEWS_AnthropogenicEmission.txt', &
1287 WRITE (*, *)
'Program stopped! Irrigation code ',
siteselect(rr, codecol),
'not found in SUEWS_Irrigation.txt.'
1309 INTEGER :: SurfaceCharCodeCol
1317 WRITE (*, *)
'Program stopped! Soil code ',
surfacechar(gridiv, surfacecharcodecol),
'not found in SUEWS_Soil.txt.'
1339 INTEGER :: SurfaceCharCodeCol
1347 WRITE (*, *)
'Program stopped! Biogen code ',
surfacechar(gridiv, surfacecharcodecol),
'not found in SUEWS_BiogenCO2.txt.'
1395 INTEGER :: lunit = 100
1398 INTEGER :: iBlock, igrid
1399 INTEGER,
DIMENSION(NperTstepIn) :: seq1Nper
1400 INTEGER,
DIMENSION(nsd) :: seq1nsd
1401 INTEGER,
DIMENSION(nColumnsMetForcingData) :: MetDisaggMethod
1402 REAL(KIND(1D0)),
DIMENSION(nColumnsMetForcingData) :: MetArrayOrig
1403 REAL(KIND(1D0)),
DIMENSION(ReadLinesOrigMetData*NperTstepIn, ncolumnsMetForcingData) :: Met_tt
1404 REAL(KIND(1D0)),
DIMENSION(ReadLinesOrigMetData*NperTstepIn) :: Met_tt_kdownAdj
1405 CHARACTER(LEN=9),
DIMENSION(ncolumnsMetForcingData) :: HeaderMet
1406 CHARACTER(LEN=10*ncolumnsMetForcingData) :: HeaderMetOut
1409 REAL(KIND(1D0)),
DIMENSION(ReadLinesOrigMetData*NperTstepIn) :: dectimeFast
1410 REAL(KIND(1D0)),
DIMENSION(ReadLinesOrigMetData*NperTstepIn) :: idectime
1427 metdisaggmethod = -999
1431 seq1nsd = (/(i, i=1,
nsd, 1)/)
1436 metdisaggmethod(:) = 10
1438 metdisaggmethod(:) = 20
1440 metdisaggmethod(:) = 10
1441 metdisaggmethod(10:13) = 20
1443 CALL errorhint(2,
'Problem in SUEWS_MetDisagg: DisaggMethod value should be 1, 2, or 3', &
1451 OPEN (lunit, file=trim(
fileorigmet), status=
'old')
1453 READ (lunit, *) headermet
1492 CALL errorhint(2,
'Problem in SUEWS_MetDisagg: timestamps in met forcing file inconsistent with ResolutionFilesIn', &
1493 REAL(ResolutionFilesIn, KIND(1D0)), NotUsed, tdiff*60)
1499 CALL errorhint(3,
'Problem in SUEWS_MetDisagg: multiple years found in original met forcing file.', &
1504 IF (
diagnose == 1)
WRITE (*, *)
'Disaggregating met forcing data (', trim(
fileorigmet),
') to model time-step...'
1511 IF (metdisaggmethod(14) == 100)
THEN
1515 met_tt(:, 16) = -999
1520 ELSEIF (metdisaggmethod(14) == 101)
THEN
1522 CALL errorhint(2,
'Problem in SUEWS_MetDisagg: RainDisaggMethod requires RainAmongN', &
1523 REAL(RainAmongN, KIND(1D0)), NotUsed, RainDisaggMethod)
1525 CALL errorhint(2,
'Problem in SUEWS_MetDisagg: RainAmongN > Nper', &
1526 REAL(NperTstepIn, KIND(1D0)), NotUsed, RainAmongN)
1531 met_tt(:, 16) = -999
1537 ELSEIF (metdisaggmethod(14) == 102)
THEN
1539 CALL errorhint(2,
'Problem in SUEWS_MetDisagg: RainDisaggMethod requires MultRainAmongN', &
1540 REAL(MultRainAmongN(1), KIND(1D0)), NotUsed, RainDisaggMethod)
1542 CALL errorhint(2,
'Problem in SUEWS_MetDisagg: RainDisaggMethod requires MultRainAmongNUpperI', &
1544 ELSEIF (any(multrainamongn > npertstepin))
THEN
1545 CALL errorhint(2,
'Problem in SUEWS_MetDisagg: MultRainAmongN > Nper', real(npertstepin, kind(1d0)), notused, &
1546 maxval(multrainamongn))
1551 met_tt(:, 16) = -999
1558 WRITE (*, *)
'Disaggregation code for rain not recognised'
1560 ELSEIF (ii == 24)
THEN
1562 WRITE (*, *)
'Disaggregation of wind direction not currently implemented!'
1567 met_tt(:, ii) = -999
1577 IF (
diagnosedisagg == 1)
WRITE (*, *)
'Adjusting disaggregated kdown using zenith angle'
1578 met_tt_kdownadj(:) = met_tt(:, 15)
1585 dectimefast(:) = met_tt(:, 2) + met_tt(:, 3)/24.0 + met_tt(:, 4)/(60.0*24.0)
1592 met_tt_kdownadj(i) = 0.0
1597 met_tt_kdownadj((i - 1)*
nsd + seq1nsd) = &
1598 met_tt_kdownadj((i - 1)*
nsd + seq1nsd) &
1599 *sum(met_tt((i - 1)*
nsd + seq1nsd, 15)) &
1600 /sum(met_tt_kdownadj((i - 1)*
nsd + seq1nsd))
1603 met_tt(:, 15) = met_tt_kdownadj(:)
1613 met_tt(:, 13) = met_tt(:, 13)/10.0
1617 IF (iblock == 1)
THEN
1621 headermetout = adjustl(headermet(i))
1623 headermetout = trim(headermetout)//
' '//adjustl(headermet(i))
1628 WRITE (78,
'(a)') headermetout
1630 OPEN (78, file=trim(
filedscdmet), position=
'append')
1643303
FORMAT((i4, 1x), 3(i3, 1x), 9(f12.6, 1x), (f9.4, 1x), 10(f9.4, 1x))
1668 INTEGER :: lunit = 101
1672 INTEGER,
DIMENSION(NperESTM) :: seq1NperESTM
1673 INTEGER,
DIMENSION(nsd) :: seq1nsd
1674 INTEGER,
DIMENSION(ncolsESTMdata) :: ESTMDisaggMethod
1675 REAL(KIND(1D0)),
DIMENSION(ncolsESTMdata) :: ESTMArrayOrig
1676 REAL(KIND(1D0)),
DIMENSION(ReadLinesOrigESTMData*NperESTM, ncolsESTMdata) :: ESTM_tt
1677 CHARACTER(LEN=9),
DIMENSION(ncolsESTMdata) :: HeaderESTM
1678 CHARACTER(LEN=10*ncolsESTMdata) :: HeaderESTMOut
1681 INTEGER :: iostat_var
1695 estmdisaggmethod = -999
1698 seq1nperestm = (/(i, i=1,
nperestm, 1)/)
1699 seq1nsd = (/(i, i=1,
nsd, 1)/)
1704 estmdisaggmethod(:) = 10
1706 estmdisaggmethod(:) = 20
1708 CALL errorhint(2,
'Problem in SUEWS_ESTMDisagg: DisaggMethodESTM value should be 1 or 2', &
1716 READ (lunit, *) headerestm
1724 READ (lunit, *, iostat=iostat_var) estmarrayorig
1729 READ (lunit, *, iostat=iostat_var) estmarrayorig
1734 READ (lunit, *, iostat=iostat_var) estmarrayorig
1749 CALL errorhint(2,
'Problem in SUEWS_ESTMDisagg: timestamps in ESTM forcing file inconsistent with ResolutionFilesInESTM', &
1750 REAL(ResolutionFilesInESTM, KIND(1D0)), NotUsed, tdiff*60)
1755 WRITE (*, *)
'Disaggregating ESTM forcing data (', trim(
fileorigestm),
') to model time-step...'
1809 estm_tt(:, ii) = -999
1821 IF (iblock == 1)
THEN
1825 headerestmout = adjustl(headerestm(i))
1827 headerestmout = trim(headerestmout)//
' '//adjustl(headerestm(i))
1832 WRITE (78,
'(a)') headerestmout
1838 WRITE (78, 304) (int(estm_tt(i, ii)), ii=1, 4), estm_tt(i, 5:
ncolsestmdata)
1847304
FORMAT((i4, 1x), 3(i3, 1x), 9(f9.4, 1x))
1865 INTEGER,
INTENT(in) :: tstep, Nper, ReadLinesOrigMetDataMax
1866 REAL(KIND(1D0)),
DIMENSION(ReadLinesOrigMetData, 4),
INTENT(in) :: DateTimeForDisagg
1867 REAL(KIND(1D0)),
DIMENSION(ReadLinesOrigMetData*Nper, 4),
INTENT(out) :: DateTimeDscd
1869 REAL(KIND(1D0)),
DIMENSION(ReadLinesOrigMetData) :: dectimeOrig
1870 REAL(KIND(1D0)),
DIMENSION(Nper) :: temp_dectime
1871 INTEGER,
DIMENSION(Nper) :: temp_iy, temp_id, temp_ih, temp_im, temp_ihm
1872 INTEGER,
DIMENSION(Nper) :: ndays_iy
1875 INTEGER,
DIMENSION(Nper) :: seq1Nper
1878 seq1nper = (/(i, i=1, nper, 1)/)
1882 dectimeorig = (datetimefordisagg(:, 2) - 1) + datetimefordisagg(:, 3)/24.0 + datetimefordisagg(:, 4)/(60.0*24.0)
1884 DO i = 1, readlinesorigmetdatamax
1887 temp_dectime = dectimeorig(i) - (tstep/60.0)/(60.0*24.0)*(/(ii, ii=(nper - 1), 0, -1)/)
1888 temp_dectime = nint(temp_dectime*60*60*24)/(60*60*24*1.)
1892 temp_iy = merge(int(datetimefordisagg(i, 1)) - 1, int(datetimefordisagg(i, 1)), temp_dectime < 0)
1895 ndays_iy = daysinyear(temp_iy)
1896 temp_dectime = merge(temp_dectime + ndays_iy, temp_dectime, temp_dectime < 0)
1897 temp_id = floor(temp_dectime) + 1
1899 temp_ihm = nint((temp_dectime + 1 - temp_id/1.0)*60.0*24.0)
1900 temp_ih = (temp_ihm - mod(temp_ihm, 60))/60
1901 temp_ih = merge(temp_ih, 0, mask=(temp_ih < 24))
1902 temp_im = mod(temp_ihm, 60)
1905 datetimedscd(nper*(i - 1) + seq1nper, 1) = temp_iy
1906 datetimedscd(nper*(i - 1) + seq1nper, 2) = temp_id
1907 datetimedscd(nper*(i - 1) + seq1nper, 3) = temp_ih
1908 datetimedscd(nper*(i - 1) + seq1nper, 4) = temp_im
1916 FUNCTION disagg_lin(Slow, SlowPrev, SlowNext, DisaggType, Nper_loc, ReadLinesOrig_loc, ReadLinesOrigMax_loc, iBlock)
RESULT(Fast)
1923 INTEGER :: disaggtype
1925 INTEGER :: readlinesorig_loc, readlinesorigmax_loc
1927 REAL(kind(1d0)),
DIMENSION(ReadLinesOrig_loc*Nper_loc) :: fast
1928 REAL(kind(1d0)),
DIMENSION(ReadLinesOrig_loc) :: slow
1929 REAL(kind(1d0)) :: slowprev, slownext
1930 INTEGER,
DIMENSION(Nper_loc) :: fastrows
1931 INTEGER,
DIMENSION(FLOOR(Nper_loc/2.0)) :: firstrows10
1932 INTEGER,
DIMENSION(Nper_loc - FLOOR(Nper_loc/2.0)) :: lastrows10
1933 INTEGER,
DIMENSION(Nper_loc) :: firstrows20
1934 INTEGER,
DIMENSION(Nper_loc) :: seq1nper_loc
1935 INTEGER :: xnper_loc
1939 IF (mod(nper_loc, 2) == 0) xnper_loc = 2
1940 IF (mod(nper_loc, 2) == 1) xnper_loc = 1
1942 seq1nper_loc = (/(i, i=1, nper_loc, 1)/)
1945 IF (disaggtype == 10)
THEN
1946 fastrows = floor(nper_loc/2.0) + seq1nper_loc
1947 firstrows10 = (/(i, i=1, (fastrows(1) - 1), 1)/)
1949 (/(i, i=nper_loc*(readlinesorigmax_loc - 1 - 1) + fastrows(nper_loc) + 1, &
1950 (readlinesorigmax_loc*nper_loc), 1)/)
1951 ELSEIF (disaggtype == 20)
THEN
1952 fastrows = nper_loc + seq1nper_loc
1953 firstrows20 = (/(i, i=1, (fastrows(1) - 1), 1)/)
1959 IF (disaggtype == 10)
THEN
1960 IF (
diagnosedisagg == 1)
WRITE (*, *)
'Linearly disaggregating averaged variable'
1961 DO i = 1, (readlinesorigmax_loc - 1)
1962 fast(nper_loc*(i - 1) + fastrows) = slow(i) - &
1963 (slow(i + 1) - slow(i))/(xnper_loc*nper_loc) + &
1964 (slow(i + 1) - slow(i))/nper_loc*(/(ii, ii=1, nper_loc, 1)/)
1968 IF (iblock == 1)
THEN
1969 fast(firstrows10) = fast(fastrows(1))
1971 fast(firstrows10) = slowprev - &
1972 (slow(1) - slowprev)/(xnper_loc*nper_loc) + &
1973 (slow(1) - slowprev)/nper_loc* &
1974 (/(ii, ii=(nper_loc -
SIZE(firstrows10) + 1), nper_loc, 1)/)
1978 fast(lastrows10) = fast(nper_loc*(readlinesorigmax_loc - 1 - 1) + fastrows(nper_loc))
1980 fast(lastrows10) = slow(readlinesorigmax_loc) - &
1981 (slownext - slow(readlinesorigmax_loc))/(xnper_loc*nper_loc) + &
1982 (slownext - slow(readlinesorigmax_loc))/nper_loc* &
1983 (/(ii, ii=1,
SIZE(lastrows10), 1)/)
1985 ELSEIF (disaggtype == 20)
THEN
1986 IF (
diagnosedisagg == 1)
WRITE (*, *)
'Linearly disaggregating instantaneous variable'
1987 DO i = 1, (readlinesorigmax_loc - 1)
1988 fast(nper_loc*(i - 1) + fastrows) = (slow(i) + &
1989 (slow(i + 1) - slow(i))/nper_loc*2*(seq1nper_loc - 1) + &
1993 IF (iblock == 1)
THEN
1994 fast(firstrows20) = fast(fastrows(1))
1996 fast(firstrows20) = (slowprev + &
1997 (slow(1) - slowprev)/nper_loc*2* &
1998 ((/(ii, ii=(nper_loc -
SIZE(firstrows20) + 1), nper_loc, 1)/) - 1) + &
2012 IF (any(fast(1:readlinesorigmax_loc*nper_loc) == -999))
THEN
2013 WRITE (*, *)
'Problem: -999s (', count(fast(1:readlinesorigmax_loc*nper_loc) == -999),
') in disaggregated data.'
2021 FUNCTION disaggp_amongn(Slow, amongN, Nper_loc, ReadLinesOrig_loc, ReadLinesOrigMax_loc)
RESULT(Fast)
2035 INTEGER :: readlinesorig_loc, readlinesorigmax_loc
2036 REAL(kind(1d0)),
DIMENSION(ReadLinesOrig_loc*Nper_loc) :: fast
2037 REAL(kind(1d0)),
DIMENSION(ReadLinesOrig_loc) :: slow
2038 INTEGER,
DIMENSION(:),
ALLOCATABLE :: subintervals
2039 INTEGER,
DIMENSION(Nper_loc) :: seq1nper_loc
2043 ALLOCATE (subintervals(amongn))
2044 subintervals(:) = -999
2046 seq1nper_loc = (/(i, i=1, nper_loc, 1)/)
2048 IF (
diagnosedisagg == 1)
WRITE (*, *)
'Distributing over ', amongn,
' subintervals for variable'
2050 IF (amongn == nper_loc)
THEN
2051 subintervals(:) = seq1nper_loc
2053 IF (amongn > nper_loc) &
2054 CALL errorhint(2,
'Problem in SUEWS_MetDisagg: no. of rainy periods cannot exceed number of subintervals', &
2055 REAL(nper_loc, kind(1d0)),
notused, amongn)
2059 DO i = 1, readlinesorigmax_loc
2060 fast(nper_loc*(i - 1) + seq1nper_loc) = 0
2061 IF (slow(i) > 0)
THEN
2062 IF (amongn < nper_loc)
THEN
2063 subintervals(:) = -999
2066 fast(nper_loc*(i - 1) + subintervals) = slow(i)/amongn
2070 IF (any(fast(1:readlinesorigmax_loc*nper_loc) == -999))
THEN
2071 WRITE (*, *)
'Problem: -999s (', count(fast(1:readlinesorigmax_loc*nper_loc) == -999),
') in disaggregated data'
2079 FUNCTION disaggp_amongnmult(Slow, multupperI, multamongN, Nper_loc, ReadLinesOrig_loc, ReadLinesOrigMax_loc)
RESULT(Fast)
2091 REAL(kind(1d0)),
DIMENSION(5) :: multupperi
2092 INTEGER,
DIMENSION(5) :: multamongn
2093 INTEGER :: thisamongn
2095 INTEGER :: readlinesorig_loc, readlinesorigmax_loc
2096 REAL(kind(1d0)),
DIMENSION(ReadLinesOrig_loc*Nper_loc) :: fast
2097 REAL(kind(1d0)),
DIMENSION(ReadLinesOrig_loc) :: slow
2098 INTEGER,
DIMENSION(:),
ALLOCATABLE :: subintervals
2099 INTEGER,
DIMENSION(Nper_loc) :: seq1nper_loc
2102 seq1nper_loc = (/(i, i=1, nper_loc, 1)/)
2104 IF (
diagnosedisagg == 1)
WRITE (*, *)
'Distributing over variable subintervals depending on intensity for variable'
2108 DO i = 1, readlinesorigmax_loc
2109 fast(nper_loc*(i - 1) + seq1nper_loc) = 0
2110 IF (slow(i) > 0)
THEN
2112 IF (slow(i) <= multupperi(1))
THEN
2113 thisamongn = multamongn(1)
2114 ELSEIF (slow(i) > multupperi(1) .AND. slow(i) <= multupperi(2))
THEN
2115 thisamongn = multamongn(2)
2116 ELSEIF (slow(i) > multupperi(2) .AND. slow(i) <= multupperi(3))
THEN
2117 thisamongn = multamongn(3)
2118 ELSEIF (slow(i) > multupperi(3) .AND. slow(i) <= multupperi(4))
THEN
2119 thisamongn = multamongn(4)
2120 ELSEIF (slow(i) > multupperi(4) .AND. slow(i) <= multupperi(5))
THEN
2121 thisamongn = multamongn(5)
2122 ELSEIF (slow(i) > multupperi(5))
THEN
2123 thisamongn = multamongn(5)
2124 CALL errorhint(4,
'Precip in met forcing file exceeds maxiumum MultRainAmongNUpperI', &
2129 ALLOCATE (subintervals(thisamongn))
2130 subintervals(:) = -999
2132 IF (thisamongn > nper_loc)
CALL errorhint(2,
'Problem in SUEWS_MetDisagg: no. of rainy periods cannot exceed '// &
2133 'number of subintervals', real(nper_loc, kind(1d0)),
notused, thisamongn)
2135 IF (thisamongn == nper_loc)
THEN
2136 subintervals(:) = seq1nper_loc
2137 ELSEIF (thisamongn < nper_loc)
THEN
2140 fast(nper_loc*(i - 1) + subintervals) = slow(i)/thisamongn
2142 DEALLOCATE (subintervals)
2146 IF (any(fast(1:readlinesorigmax_loc*nper_loc) == -999))
THEN
2147 WRITE (*, *)
'Problem: -999s (', count(fast(1:readlinesorigmax_loc*nper_loc) == -999),
') in disaggregated data'
2167 REAL(kind(1d0)) :: r
2168 INTEGER,
DIMENSION(:),
ALLOCATABLE :: samples
2171 ALLOCATE (samples(n))
2176 DO WHILE (any(samples == -999))
2177 CALL random_number(r)
2178 x = int(r*outof) + 1
2181 IF (count(samples == x) == 0)
THEN
real(kind(1d0)), dimension(:, :), allocatable biogen_coeff
integer, parameter bldgsurf
real(kind(1d0)), dimension(:, :), allocatable estmcoefficients_coeff
real(kind(1d0)), dimension(:, :), allocatable snow_coeff
real(kind(1d0)), dimension(:, :), allocatable siteselect
real(kind(1d0)), dimension(:, :), allocatable anthropogenic_coeff
integer, dimension(nsurfincsnow) c_ohmcode_wwet
character(len=20), dimension(ncolumnsnonveg) headernonveg_reqd
real(kind(1d0)), dimension(:, :), allocatable wgwaterdist_coeff
integer, parameter ncolsestmdata
character(len=20), dimension(ncolumnsanthropogenic) headeranthropogenic_reqd
character(len=20), dimension(ncolumnsnonveg) headernonveg_file
character(len=20), dimension(ncolumnswgwaterdist) headerwgwaterdist_file
real(kind(1d0)), dimension(:, :), allocatable metfordisagg
character(len=20), dimension(ncolumnswater) headerwater_reqd
integer, dimension(nsurfincsnow) c_ohmcode_sdry
integer, dimension(nsurfincsnow) c_ohmcode_swet
real(kind(1d0)), dimension(:), allocatable estmfordisaggprev
character(len=20), dimension(ncolumnswater) headerwater_file
character(len=20), dimension(ncolumnssnow) headersnow_file
character(len=20), dimension(ncolumnsveg) headerveg_file
real(kind(1d0)), dimension(:), allocatable metfordisaggnext
integer, parameter ncolumnsmetforcingdata
character(len=20), dimension(ncolumnsprofiles) headerprofiles_reqd
character(len=20), dimension(ncolumnssnow) headersnow_reqd
real(kind(1d0)), dimension(:), allocatable metfordisaggprev
real(kind(1d0)), dimension(:, :), allocatable water_coeff
integer, dimension(nsurfincsnow) c_ohmcode_wdry
real(kind(1d0)), dimension(:, :), allocatable nonveg_coeff
character(len=20), dimension(ncolumnsohmcoefficients) headerohmcoefficients_reqd
real(kind(1d0)), dimension(:, :), allocatable conductance_coeff
character(len=20), dimension(ncolumnssoil) headersoil_file
real(kind(1d0)), dimension(:, :, :), allocatable metforcingdata
character(len=20), dimension(ncolumnsirrigation) headerirrigation_reqd
character(len=20), dimension(ncolumnsanthropogenic) headeranthropogenic_file
real(kind(1d0)), dimension(:, :), allocatable surfacechar
character(len=20), dimension(ncolumnsveg) headerveg_reqd
character(len=20), dimension(ncolumnsbiogen) headerbiogen_reqd
character(len=20), dimension(ncolumnsohmcoefficients) headerohmcoefficients_file
real(kind(1d0)), dimension(:, :), allocatable estmfordisagg
real(kind(1d0)), dimension(:), allocatable estmfordisaggnext
real(kind(1d0)), dimension(:, :), allocatable profiles_coeff
character(len=20), dimension(ncolumnsprofiles) headerprofiles_file
character(len=20), dimension(ncolumnsconductance) headercond_reqd
integer, dimension(nsurfincsnow) c_estmcode
real(kind(1d0)), dimension(:, :), allocatable soil_coeff
character(len=20), dimension(ncolumnsirrigation) headerirrigation_file
real(kind(1d0)), dimension(:, :), allocatable ohmcoefficients_coeff
integer, parameter pavsurf
character(len=20), dimension(ncolumnsbiogen) headerbiogen_file
real(kind(1d0)), dimension(:, :), allocatable irrigation_coeff
character(len=20), dimension(ncolumnsconductance) headercond_file
character(len=20), dimension(ncolumnsestmcoefficients) headerestmcoefficients_reqd
character(len=20), dimension(ncolumnssoil) headersoil_reqd
character(len=20), dimension(ncolumnsestmcoefficients) headerestmcoefficients_file
real(kind(1d0)), dimension(:, :), allocatable veg_coeff
real(kind(1d0)), dimension(:, :, :), allocatable estmforcingdata
character(len=20), dimension(ncolumnswgwaterdist) headerwgwaterdist_reqd
character(len=150) filedscdestm
integer netradiationmethod
integer resolutionfilesin
integer resolutionfilesinestm
real(kind(1d0)), dimension(5) multrainamongnupperi
integer, dimension(5) multrainamongn
character(len=150) filedscdmet
real(kind(1d0)) zenith_deg
integer diagnosedisaggestm
character(len=150) fileorigestm
character(len=150) fileorigmet
integer nlinesohmcoefficients
integer nlineswgwaterdist
integer nlinesestmcoefficients
integer nlinesconductance
integer readlinesorigestmdatamax
integer readlinesorigmetdata
integer readlinesorigmetdatamax
integer nlinesanthropogenic
integer readlinesorigestmdata
integer skippedlinesorigestm
integer readblocksorigmetdata
subroutine disaggregateestm(iblock)
real(kind(1d0)) function, dimension(readlinesorig_loc *nper_loc) disaggp_amongn(slow, amongn, nper_loc, readlinesorig_loc, readlinesorigmax_loc)
real(kind(1d0)) function, dimension(readlinesorig_loc *nper_loc) disaggp_amongnmult(slow, multupperi, multamongn, nper_loc, readlinesorig_loc, readlinesorigmax_loc)
subroutine disaggregatemet(iblock, igrid)
subroutine disaggregatedatetime(datetimefordisagg, tstep, nper, readlinesorigmetdatamax, datetimedscd)
integer function, dimension(:), allocatable randomsamples(n, outof)
real(kind(1d0)) function, dimension(readlinesorig_loc *nper_loc) disagg_lin(slow, slowprev, slownext, disaggtype, nper_loc, readlinesorig_loc, readlinesorigmax_loc, iblock)
subroutine narp_cal_sunposition(year, idectime, utc, locationlatitude, locationlongitude, locationaltitude, sunazimuth, sunzenith)
character(len=90), dimension(14) text
real(kind(1d0)) halftimestep
real(kind(1d0)) soildensity
real(kind(1d0)) soilrocks
real(kind(1d0)) soildepthmeas
subroutine errorhint(errh, problemfile, value, value2, valuei)