Input files are parsed a little differently from the command line. Perhaps the most important feature are the '#'-comments that allow to add text into the file without being actually parsed:
# -*- getpot -*- activate emacs 'getpot-mode' # FILE: "example.pot" # PURPOSE: some examples how to use GetPot for input file parsing. # # (C) 2001 Frank R. Schaefer # # License Terms: GNU Lesser GPL, ABSOLUTELY NO WARRANTY ##################################################################### v0 = 34.2 # [m/s^2] initial speed of point massAs can be seen in the same example, the variable assignments now allow whitespace between a left hand value v0 the assignment operator ' =' and a right hand value 34.2.
One thing is crucially different in input files: sections. In input files, the basic advantage of sections is to reduce the variable length. Imagine, you have a parameter weight occurring multiple times: for the total vehicle, for each tire, for a load in the trunk etc. Now in order give each one a unique identifier one would have to call them total_vehicle_weight, vehicle_tires_front_left_weight and so on. Here is where sections become handy:
... [vehicle] length = 2.65 # [m] initial-xyz = '100. 0.1 5.0' # [m] # coefficients of magic formula [Pajeka, et al.] [./tires/front/right] B = 3.7976 C = 1.2 E = -0.5 D = 64322.404 [./tires/front/left] B = 3.7976 C = 1.2 E = -0.5 D = 64322.404 [./tires/rear/right] B = 3.546 C = 1.135 E = -0.4 D = 59322.32 [./tires/rear/left] B = 3.546 C = 1.11 E = -0.32 D = 59322.32 [../chassis] # i.e. vehicle/chassis Roh = 1.21; # [kg/m^3] density of air S = 5.14; # [m^2] reference surface Cd = 0.45; # [1] air drag coefficient ...
In section 4 it was explained how to read out variables. The same functions work, of course, for a database build up on a parsed file. The only difference is that sections produce suffixes in front of variables and options. A database fed with a file as the above one, can be queried as follows:
... front_tire.B = ifile("vehicle/tires/front/right/B", 0.); front_tire.C = ifile("vehicle/tires/front/right/C", 0.); front_tire.D = ifile("vehicle/tires/front/right/D", 0.); front_tire.E = ifile("vehicle/tires/front/right/E", 0.); ...Note that there are two special indicators in a section label: