The function that reads in the input file. Function that reads the input file.
Function header. Note that this function is a member of the inputs class. Therefore the scope inputs:: must be used. The function is called with the name of the input file that is to be read. int inputs::input_reader(char* input_file_name) { Initialize the GetPot object ifile with the input file to be read. Return an error message if file does not exist. GetPot ifile(input_file_name); if(ifile.size() <= 1){ printf("non-existent or empty file\n"); return 0;} Read in variables pi and kb. According to GetPOt format, the name of the variable that appears in the file is enclosed within " ", a default for the value of the parameter is also entered. Read in other variables. Note that in the input file they come under the section [Solver_parameters]. Therefore while reading we use ifile("Solver_parameters/time_step",). Note that the variable dt is called time_step in the input file and hence that name is used within " ". It is possible to asssign different names in this file and the input file. Usually more descriptive names are preferred in the input file. dt = ifile("Solver_parameters/time_step", 0.); num_steps = ifile("Solver_parameters/num_steps", 0); verbose_mode = ifile("Solver_parameters/verbose_mode", 0); print_interval = ifile("Solver_parameters/print_interval", 0); mu_g = ifile("Solver_parameters/log_geometric_mean",0.); std_g = ifile("Solver_parameters/standard_dev",0.); Read in additional variables that appear in the input file in the section [Model_Parameters] |