/// <summary> /// Read a well input file. </summary> /// <param name="filename"> name of file containing well information </param> /// <returns> status(always 0 since exception handling is now used) </returns> //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public static java.util.List<StateMod_Well> readStateModFile(String filename) throws Exception public static IList <StateMod_Well> readStateModFile(string filename) { string routine = "StateMod_Well.readStateModFile"; IList <StateMod_Well> theWellStations = new List <StateMod_Well>(); int[] format_1 = new int[] { StringUtil.TYPE_STRING, StringUtil.TYPE_STRING, StringUtil.TYPE_STRING, StringUtil.TYPE_INTEGER, StringUtil.TYPE_DOUBLE, StringUtil.TYPE_SPACE, StringUtil.TYPE_STRING, StringUtil.TYPE_SPACE, StringUtil.TYPE_DOUBLE }; int[] format_1w = new int[] { 12, 24, 12, 8, 8, 1, 12, 1, 12 }; int[] format_2 = new int[] { StringUtil.TYPE_SPACE, StringUtil.TYPE_STRING, StringUtil.TYPE_INTEGER, StringUtil.TYPE_INTEGER, StringUtil.TYPE_INTEGER, StringUtil.TYPE_DOUBLE, StringUtil.TYPE_DOUBLE, StringUtil.TYPE_INTEGER, StringUtil.TYPE_INTEGER }; int[] format_2w = new int[] { 36, 12, 8, 8, 8, 8, 8, 8, 8 }; int[] format_4 = new int[] { StringUtil.TYPE_SPACE, StringUtil.TYPE_STRING, StringUtil.TYPE_DOUBLE, StringUtil.TYPE_INTEGER }; int[] format_4w = new int[] { 36, 12, 8, 8 }; string iline = null; string s = null; IList <object> v = new List <object>(9); StreamReader @in = null; StateMod_Well aWell = null; StateMod_ReturnFlow aReturnNode = null; IList <string> effv = null; int nrtn, ndepl; Message.printStatus(1, routine, "Reading well file: " + filename); try { @in = new StreamReader(IOUtil.getPathUsingWorkingDir(filename)); while (!string.ReferenceEquals((iline = @in.ReadLine()), null)) { if (iline.StartsWith("#", StringComparison.Ordinal) || iline.Trim().Length == 0) { continue; } aWell = new StateMod_Well(); StringUtil.fixedRead(iline, format_1, format_1w, v); if (Message.isDebugOn) { Message.printDebug(50, routine, "iline: " + iline); } aWell.setID(((string)v[0]).Trim()); aWell.setName(((string)v[1]).Trim()); aWell.setCgoto(((string)v[2]).Trim()); aWell.setSwitch((int?)v[3]); aWell.setDivcapw((double?)v[4]); aWell.setCdividyw(((string)v[5]).Trim()); aWell.setPrimary((double?)v[6]); // user data iline = @in.ReadLine(); StringUtil.fixedRead(iline, format_2, format_2w, v); if (Message.isDebugOn) { Message.printDebug(50, routine, "iline: " + iline); } aWell.setIdvcow2(((string)v[0]).Trim()); aWell.setIdvcomw((int?)v[1]); // Don't set the number of return flow data get(2) or depletion data get(3) because // those will be calculated nrtn = ((int?)v[2]).Value; ndepl = ((int?)v[3]).Value; aWell.setDivefcw((double?)v[4]); aWell.setAreaw((double?)v[5]); aWell.setIrturnw((int?)v[6]); aWell.setDemsrcw((int?)v[7]); if (aWell.getDivefcw() >= 0) { // Efficiency line won't be included - set each value to the average for (int i = 0; i < 12; i++) { aWell.setDiveff(i, aWell.getDivefcw()); } } else { // 12 efficiency values iline = @in.ReadLine(); effv = StringUtil.breakStringList(iline, " ", StringUtil.DELIM_SKIP_BLANKS); for (int i = 0; i < 12; i++) { aWell.setDiveff(i, (string)effv[i]); } } // return flow data if (Message.isDebugOn) { Message.printDebug(50, routine, "Number of return flows: " + nrtn); } for (int i = 0; i < nrtn; i++) { iline = @in.ReadLine(); StringUtil.fixedRead(iline, format_4, format_4w, v); if (Message.isDebugOn) { Message.printDebug(50, routine, "Fixed read returned " + v.Count + " elements"); } aReturnNode = new StateMod_ReturnFlow(StateMod_DataSet.COMP_WELL_STATIONS); s = ((string)v[0]).Trim(); if (s.Length <= 0) { aReturnNode.setCrtnid(s); Message.printWarning(2, routine, "Return node for structure \"" + aWell.getID() + "\" is blank. "); } else { aReturnNode.setCrtnid(s); } aReturnNode.setPcttot(((double?)v[1])); aReturnNode.setIrtndl(((int?)v[2])); aWell.addReturnFlow(aReturnNode); } // depletion data for (int i = 0; i < ndepl; i++) { iline = @in.ReadLine(); StringUtil.fixedRead(iline, format_4, format_4w, v); aReturnNode = new StateMod_ReturnFlow(StateMod_DataSet.COMP_WELL_STATIONS); s = ((string)v[0]).Trim(); if (s.Length <= 0) { aReturnNode.setCrtnid(s); Message.printWarning(2, routine, "Return node for structure \"" + aWell.getID() + "\" is blank. "); } else { aReturnNode.setCrtnid(s); } aReturnNode.setPcttot(((double?)v[1])); aReturnNode.setIrtndl(((int?)v[2])); aWell.addDepletion(aReturnNode); } theWellStations.Add(aWell); } } catch (Exception e) { routine = null; format_1 = null; format_1w = null; format_2 = null; format_2w = null; format_4 = null; format_4w = null; s = null; v = null; if (@in != null) { @in.Close(); } @in = null; aWell = null; aReturnNode = null; effv = null; Message.printWarning(2, routine, e); throw e; } routine = null; format_1 = null; format_1w = null; format_2 = null; format_2w = null; format_4 = null; format_4w = null; iline = null; s = null; v = null; if (@in != null) { @in.Close(); } @in = null; aWell = null; aReturnNode = null; effv = null; return(theWellStations); }