(ATCScript "LandResponseTable" (Arg "CurScenario" "CurScenario") (Arg "Constituents" (Array "NH3" "NO3" "OrganicN" "PO4" "OrganicP" "BOD" "Sed" "FColi")) (Arg "HspfTimeUnits" "yr") (Arg "HspfTimeStep" 1) (Arg "HspfnVals" (JDateDiff SDate Edate HspfTimeUnits HspfTimeStep)) (Arg aStartJdate (JDate 1992 10 1)) (Arg aEndJdate (JDate 1999 10 1)) (LoadLibrary "ATCScriptData" "ATCScriptGrid" "ATCScriptHspf" "ATCScriptFile" "ATCScriptMisc") (Unset LandResponseTable) ('grid might be left over from prev call, need a new one) (Set CRLF (+ (Chr 13) (Chr 10))) (Set Space10 " ") (Set Space20 " ") (Set lReportString "") (Set CurRow 0) (Grid "LandResponseTable" 11 10) (' Start with 11 columns and 10 rows - rows will expand as necessary, columns won't) (Grid 1 (++ CurRow) (+ "Land Response Table for Scenario [" CurScenario "]" )) (Grid 2 (++ CurRow) (+ "Run Made " (Format (FileAttribute (+ InputDir CurScenario ".hbn") "date") "yyyy-mm-dd hh:mm"))) (Grid 2 (++ CurRow) "Average Annual Rates") (Grid 2 (++ CurRow) (HspfRunInfo)) (Grid 2 (++ CurRow) (+ "Time Span: " HspfnVals " " HspfTimeUnits " from " (Format aStartJdate "mm/dd/yy") " to " (Format aEndJdate "mm/dd/yy") ) ) (+= CurRow 2) (Set NextRow (+ CurRow 1)) (Set NextRow2 (+ CurRow 2)) (Grid 1 CurRow (Format "Land Use" Space20)) (Grid 2 CurRow (Format "NH3-N" Space10)) (Grid 3 CurRow (Format "NO2+NO3-N" Space10)) (Grid 4 CurRow (Format "Organic N" Space10)) (Grid 5 CurRow (Format "Total N" Space10)) (Grid 6 CurRow (Format "PO4-P" Space10)) (Grid 7 CurRow (Format "Organic P" Space10)) (Grid 8 CurRow (Format "Total P" Space10)) (Grid 9 CurRow (Format "BOD" Space10)) (Grid 10 CurRow (Format "TSS" Space10)) (Grid 11 CurRow (Format "F.Coli" Space10)) (+= CurRow 1) (Set HspfMetSeg "") (' want landuse from any met seg) (Set LandUses (HspfLandUses)) (For lLandUseCounter = 1 to (Len LandUses) (Grid 1 (+ CurRow lLandUseCounter) (Format (ArrayItem LandUses lLandUseCounter) Space20)) ) (+= CurRow 1) (Set FirstRow CurRow) (Set lColCounter 1) (For lCurConstituent in Constituents (Set lHspfStartInterval (HspfSJDate)) (Set ltmpHspfStartInterval lHspfStartInterval) (If (= lCurConstituent "BOD") (Set lBODMultiplier 0.4) (Else (If (= lCurConstituent "OrganicN") (Set lBODMultiplier 0.069) (Else (If (= lCurConstituent "OrganicP") (Set lBODMultiplier 0.0052) ) ) ) ) ) (Set CurRow FirstRow) (++ lColCounter) (RunScript (+ StandardsDir "Constants4" lCurConstituent ".spt")) (Select PerConstituent (Case "F.Coliform-POQUAL" (Set lNumFormat "##,##0.00")) (Case Else (Set lNumFormat "#,##0.000")) ) (While (< ltmpHspfStartInterval (HspfEJDate)) (Set lHspfEndInterval (JDateAdd ltmpHspfStartInterval HspfTimeUnits HspfTimeStep HspfnVals)) (Set TotNonPointPerVal 0) (Set TotNonPointImpVal 0) (Set TotNonPointPerArea 0) (Set TotNonPointImpArea 0) (Set TotNonPointArea 0) (Set GrandTotal 0) (Set TopTotalRow CurRow) (Set MetSegCnt 0) (Set MetSegs (HspfMetSegs)) (For HspfMetSeg In MetSegs (Increment MetSegCnt) ('Reset running segment totals) (Set TotSegPerVal 0) (Set TotSegImpVal 0) (Set TotSegPerArea 0) (Set TotSegImpArea 0) (Set TotSegArea 0) (Set SegGrandTotal 0) (For LandUse in LandUses (If (= MetSegCnt 1) ('Initialize running totals by land use) (RunScript (+ "(Set " (ReplaceString LandUse " " "") "PerLandVal 0)")) (RunScript (+ "(Set " (ReplaceString LandUse " " "") "ImpLandVal 0)")) (RunScript (+ "(Set " (ReplaceString LandUse " " "") "PerLandArea 0)")) (RunScript (+ "(Set " (ReplaceString LandUse " " "") "ImpLandArea 0)")) (RunScript (+ "(Set " (ReplaceString LandUse " " "") "TotalLandArea 0)")) ) (Set PerArea (HspfArea LandUse 1)) (Set ImpArea (HspfArea LandUse 0)) (Set TotalArea (+ PerArea ImpArea)) (+= TotSegPerArea PerArea) (+= TotSegImpArea ImpArea) (+= TotSegArea PerArea ImpArea) (RunScript (+ "(+= " (ReplaceString LandUse " " "") "PerLandArea PerArea)")) (RunScript (+ "(+= " (ReplaceString LandUse " " "") "ImpLandArea ImpArea)")) (RunScript (+ "(+= " (ReplaceString LandUse " " "") "TotalLandArea PerArea ImpArea)")) (Set PerData (HspfBinData LandUse "PERLND" PerConstituent)) (If (= PerConstituent "BOD/ORGANICS-POQUAL") (Set PerData (DataTSer PerData "Math" "Mult" lBODMultiplier)) ) (Set DataSubset (DataTser PerData SubSetByDate ltmpHspfStartInterval lHspfEndInterval)) (Set PerVal (DataTser DataSubset "Attrib" HspfAggregation)) (If (= HspfAggregation "Sum") (Set PerVal (/ PerVal HspfnVals)) ) (+= TotSegPerVal (* PerVal PerArea)) (RunScript (+ "(+= " (ReplaceString LandUse " " "") "PerLandVal (* PerVal PerArea))")) (If (Not (IsNumeric PerVal)) (Set PerVal 0) ) (Set ImpData (HspfBinData LandUse "IMPLND" ImpConstituent)) (If (= PerConstituent "BOD/ORGANICS-POQUAL") (Set ImpData (DataTSer ImpData "Math" "Mult" lBODMultiplier)) ) (Set DataSubset (DataTser ImpData SubSetByDate ltmpHspfStartInterval lHspfEndInterval)) (Set ImpVal (DataTser DataSubset "Attrib" HspfAggregation)) (If (= HspfAggregation "Sum") (Set ImpVal (/ ImpVal HspfnVals)) ) (+= TotSegImpVal (* ImpVal ImpArea)) (RunScript (+ "(+= " (ReplaceString LandUse " " "") "ImpLandVal (* ImpVal ImpArea))")) (If (Not (IsNumeric ImpVal)) (Set ImpVal 0) ) (Set Total (+ (* PerArea PerVal) (* ImpArea ImpVal))) (Set Total (/ Total PerImpConv)) (+= SegGrandTotal Total) ) (+= GrandTotal SegGrandTotal) (Set Total (+ TotSegPerVal TotSegImpVal)) (+= TotNonPointPerVal TotSegPerVal) (+= TotNonPointImpVal TotSegImpVal) (+= TotNonPointPerArea TotSegPerArea) (+= TotNonPointImpArea TotSegImpArea) (+= TotNonPointArea TotSegArea) ) ('Insert totals block for non-point sources) (For LandUse in LandUses (RunScript (+ "(Set Total (+ " (ReplaceString LandUse " " "") "PerLandVal " (ReplaceString LandUse " " "") "ImpLandVal))")) (RunScript (+ "(Set tmpVal " (ReplaceString LandUse " " "") "PerLandVal)")) (If (<> tmpVal 0) (RunScript (+ "(Set " (ReplaceString LandUse " " "") "PerLandVal (/ " (ReplaceString LandUse " " "") "PerLandVal " (ReplaceString LandUse " " "") "PerLandArea))")) ) (UnSet tmpVal) (RunScript (+ "(Set tmpVal " (ReplaceString LandUse " " "") "ImpLandVal)")) (If (<> tmpVal 0) (RunScript (+ "(Set " (ReplaceString LandUse " " "") "ImpLandVal (/ " (ReplaceString LandUse " " "") "ImpLandVal " (ReplaceString LandUse " " "") "ImpLandArea))")) ) (UnSet tmpVal) (RunScript (+ "(Set tmpVal " (ReplaceString LandUse " " "") "TotalLandArea)")) (If (= tmpVal 0) (Grid lColCounter CurRow (Format 0 lNumFormat)) (Else (RunScript (+ "(Grid lColCounter CurRow (Format (/ Total " (ReplaceString LandUse " " "") "TotalLandArea) lNumFormat))")) ) ) (UnSet tmpVal) (++ CurRow) ) (Set ltmpHspfStartInterval lHspfEndInterval) ) (If (= lCurConstituent "OrganicN") (Set CurRow FirstRow) (++ lColCounter) (For LandUse in LandUses (Grid lColCounter CurRow (+ (Grid (- lColCounter 1) CurRow) (Grid (- lColCounter 2) CurRow) (Grid (- lColCounter 3) CurRow) ) ) (++ CurRow) ) ) (If (= lCurConstituent "OrganicP") (Set CurRow FirstRow) (++ lColCounter) (For LandUse in LandUses (Grid lColCounter CurRow (+ (Grid (- lColCounter 1) CurRow) (Grid (- lColCounter 2) CurRow) ) ) (++ CurRow) ) ) (Unset ltmpHspfStartInterval) (Unset CurConstituent) (Unset PerData) (Unset ImpData) (Unset RchData) (Unset DataSubset) ) (+= lReportString (Grid "AsString" "" CRLF Space10)) (Return lReportString) (Unset lReportString) (Unset LandResponseTable) )