Input Files

VDisp input files are parsed using the InputParser.jl module. This module is responsible for parsing input files, creating InputData instances, and reporting any possible errors in the input file format in a descriptive and helpful manner.

Note: VDisp still contains code that parses the old input file format from the original VDispl project. This code is kept in mainly for testing purposes, in which we test the new VDisp's results against that of the original program's. This also allows flexibility for any future developers or contributors to the project!

Main.InputParser.parseCurrentLineFunction
parseCurrentLine(input::Array{String}, items::Int, index::Int, delimiter::String=" ")

Given an array of String values, input, the index of a string in this array to parse, index, and the number of values expected to be parsed in this string, items, parseCurrentLine() returns an Array of values parsed from the specified line, or a NotEnoughValuesError if not enough values were found. There is also an optional argument, delimiter, which specifies the delimiter which separates each value. The default value for delimiter is a single space.

source
Main.InputParser.InputDataType
InputData()

The InputData struct contains all the variables needed to perform VDisp calculations.

There are two main ways to construct an instance of InputData:

  • Parse an input file which follows the speciication of the old VDispl file format. Details about this file format can be found in Appendix F of this publication. This functionality is not used in the modern version of VDisp, it has only been kept to allow people to parse the old input files if they want.

  • By converting values entered in the GUI into the values that populate the fields of an InputData instance. This is the way VDisp creates InputDatainstances, which are then used to make OutputDatainstances, in the createOutputDataFromGUI() function.

source
Main.InputParser.GUIDataType
GUIData()

The GUIData struct contains all the information parsed from new input file format. This information is used to populate the GUI entries, significantly speeding up the process and improving the user experience.

source
vdisp.createOutputDataFromGUIFunction
createOutputDataFromGUI()

Returns OutputData instance created from data entered by user in VDisp GUI. Data entered by user is accessed through the global Observable variables they are stored in.

source
vdisp.writeGUIDataToFileFunction
writeGUIDataToFile(path, outData)

writeGUIDataToFile() takes in a String, path, which represents a relative file path and writes the contents of writeDefaultOutput(path, outData) to file at path

source

Error Handling

As mentioned above, the InputParser.jl module is also responsible for handling any errors that might come up in input files. The following are custom defined exceptions to help in this process.

Main.InputParser.ParsingErrorType
ParsingError()

There was an error parsing old input file type to create InputData instance.

This is usually thrown when the module has already caught a specific error while parsing in another function, and given user the neccessary feedback. This error is then thrown so it can be caught and handled gracefuly by the script calling the function.

Note: Old input file type is no longer used in the modern version of VDisp. The parsing has been left in for developers who would like to test it out.

source
Main.InputParser.FoundationErrorType
FoundationError()

The foundationOption was not read as 1 or 2 in old input file type.

Note: Old input file type is no longer used in the modern version of VDisp. The parsing has been left in for developers who would like to test it out.

source
Main.InputParser.SoilNumberErrorType
SoilNumberError(line::Int)

Invalid sequence of soilLayerNumber specified in old input file type.

Ex. The soilLayerNumber of layer 12 is given before layer 11. Invalid sequence:

1  1
12 2
11 3    
16 3

Note: Old input file type is no longer used in the modern version of VDisp. The parsing has been left in for developers who would like to test it out.

source
Main.InputParser.NotEnoughValuesErrorType
NotEnoughValuesError(requiredValues::Int, givenValues::Int, line::Int)

Not enough values were given on the current line being parsed.

Note: If more values than needed are given, extra values are ignored and no error is thrown.

source
Main.InputParser.FloatConvertErrorType
FloatConvertError(line::Int32, var::String, value::String)

Value could not be converted to a Float. This happens when user enters a non-numeric value for a field that must be a floating point value.

source
Main.InputParser.IntConvertErrorType
IntConvertError(line::Int32, var::String, value::String)

Value could not be converted to an Int. This happens when user enters a non-numeric value for a field that must be an integer value.

source
Main.InputParser.BoolConvertErrorType
BoolConvertError(line::Int32, var::String, value::String)

Value could not be converted to a Bool. This happens when user enters a value that is not 0 (false) or 1(true).

source