(ATCScript "WaterBalance.spt" (Arg "DataFileObject") (Arg "CurScenario") (Arg "DateFormat" " yyyy ") (Arg "showTotal" 0) (Unset Report) ('get rid of possible old grid) (Set DoRow (FileAsString (+ StandardsDir "DoWaterBalanceRow.spt"))) (Set GroupCounter 0) (Set CRLF (+ (Chr 13) (Chr 10))) (Set ReportString "") (If (= CurScenario "CurScenario") (Warn "CurScenario was not passed in the call to WaterBalance." "Water Balance Report") (Else (Set sampleData (DataFile DataFileObject Data Scenario CurScenario Constituent SURO)) (Set curDates (DataTser sampleData Dates)) (Set nVal (Len curDates)) (For CurLocation In (DataFile DataFileObject AttributeValues "Location") (If (Or (> (InStr CurLocation "P:") 0) (> (InStr CurLocation "I:") 0)) (If (And (= (Mod GroupCounter 2) 0) (> GroupCounter 0)) (+= ReportString (+ CRLF (Chr 12) "Water Balance Report for Scenario [" CurScenario "]" CRLF " Run Made " (Format (FileAttribute (+ InputDir CurScenario ".hbn") "date") "yyyy-mm-dd hh:mm") CRLF " " gHspfRunInfo CRLF " (Units:Inches)" ) ) ) (Increment GroupCounter) (Set Row 1) (Set col (+ nval 2)) (If (> showTotal 0) (Set col (+ nval 3))) (Grid "Report" col 21) (Increment Row) (Set lSegDescript (ArrayItem (HspfParameter (+ "PERLND:GEN-INFO:LSID:" (Mid CurLocation (+ (Instr CurLocation ":") 1)))) 1)) (Grid 1 (Increment Row) (+ "Water Balance for " lSegDescript) ) (Increment Row) (Grid 1 Row "Date ") (For col = 1 to nVal (Grid (+ col 1) Row (Format (ArrayItem curDates (- col 1)) DateFormat)) ) (Grid (+ nVal 2) Row " Aver ") (If (> showTotal 0) (Grid (+ nVal 3) Row " Sum ") ) (If (> (InStr CurLocation "P:") 0) (Increment Row) (Grid 1 (Increment Row) "Rainfall ")(Set CurConstituent SUPY) (RunScript DoRow) (Increment Row) (Grid 1 (Increment Row) "Runoff") (Grid 1 (Increment Row) " Surface ")(Set CurConstituent SURO) (RunScript DoRow) (Grid 1 (Increment Row) " Interflow ")(Set CurConstituent IFWO) (RunScript DoRow) (Grid 1 (Increment Row) " Baseflow ")(Set CurConstituent AGWO) (RunScript DoRow) (Grid 1 (Increment Row) " Total ")(Set CurConstituent PERO) (RunScript DoRow) (Increment Row) (Grid 1 (Increment Row) "Deep Groundwater")(Set CurConstituent IGWI) (RunScript DoRow) (Increment Row) (Grid 1 (Increment Row) "Evaporation") (Grid 1 (Increment Row) " Potential ")(Set CurConstituent PET) (RunScript DoRow) (Grid 1 (Increment Row) " Intercep St ")(Set CurConstituent CEPE) (RunScript DoRow) (Grid 1 (Increment Row) " Upper Zone ")(Set CurConstituent UZET) (RunScript DoRow) (Grid 1 (Increment Row) " Lower Zone ")(Set CurConstituent LZET) (RunScript DoRow) (Grid 1 (Increment Row) " Ground Water")(Set CurConstituent AGWET)(RunScript DoRow) (Grid 1 (Increment Row) " Baseflow ")(Set CurConstituent BASET)(RunScript DoRow) (Grid 1 (Increment Row) " Total ")(Set CurConstituent TAET) (RunScript DoRow) (Else (If (> (InStr CurLocation "I:") 0) (Increment Row) (Grid 1 (Increment Row) "Rainfall ")(Set CurConstituent SUPY) (RunScript DoRow) (Increment Row) (Grid 1 (Increment Row) "Runoff") (Increment Row) (Grid 1 (Increment Row) " Surface ")(Set CurConstituent SURO) (RunScript DoRow) (Increment Row) (Grid 1 (Increment Row) "Evaporation") (Grid 1 (Increment Row) " Potential ")(Set CurConstituent PET) (RunScript DoRow) (Grid 1 (Increment Row) " Actual ")(Set CurConstituent IMPEV)(RunScript DoRow) (C Warn (Grid AsText)) ) ) ) (+= ReportString (Grid AsText (Chr 9) CRLF)) ) ) ) ) (Return ReportString) (Unset DoRow) (Unset PageHeader) (Unset sampleData) (Unset GroupCounter) (Unset nVal) (Unset curDates) (Unset ReportString) (Unset lSegDescript) )