Here is the list of variables and arrays used by the program. Note the naming scheme; variables whose names begin with “my” are private to the threads that use them. Variables whose names begin with “our” are private to the processes that use them, but public to the threads within that process. Variables are thus named from a thread’s perspective; “my” variables are ones that I use, “our” variables are ones that I and the other threads in my process use.
// All the data needed globally. Holds EVERYONE's location,
// states and other necessary counters.
struct global_t
{
// people counters
int total_number_of_people;
int total_num_initially_infected;
int total_num_infected;
// locations
int *x_locations;
int *y_locations;
// infected people's locations
int *their_infected_x_locations;
int *their_infected_y_locations;
// state
char *states;
// MPI related
int total_number_of_processes;
};
total_number_of_people
the total number of all people in the simulation; the sum of people assigned to each process. The value of this variable can be specified on the command line with the –n option.
total_num_initially_infected
the total number of people who are initially infected; the sum of initially infected people assigned to each process. The value of this variable can be specified on the command line with the –i option. This is a subset of the total number of people, so the value of this variable must be smaller or equal to the value for total_number_of_people.
total_num_infected
the total number of infected people; the sum of the number of infected people assigned to each process. This value changes throughout the course of the simulation.
x_locations
array, holds the x locations of all of the people; only used if the environment needs to be displayed; otherwise, our_x_locations is used.
y_locations
array, holds the y locations of all of the people; only used if the environment needs to be displayed; otherwise, our_y_locations is used.
their_infected_x_locations
array, used in susceptible() function to keep track of the x locations of the infected people for which each process is responsible.
their_infected_y_locations
array, used in step susceptible() function to keep track of the y locations of the infected people for which each process is responsible.
states
array, holds the states of all of the people; only used if the environment needs to be displayed; otherwise, our_states is used.
total_number_of_processes
used to keep track of how many processes are being used. If MPI is disabled, the value of this variable will be 1. If it is enabled, the value is set in init() function.
// All the data private to each node: Data being used by
// each process on a node in a cluster when using MPI.
// Each process holds data for location, states and
// other necessary counters for a subset of people.
struct our_t
{
// current day
int current_day;
// MPI related
int our_rank;
// people counters
int our_number_of_people;
int our_num_initially_infected;
// states counters
int our_num_infected;
int our_num_susceptible;
int our_num_immune;
int our_num_dead;
// our people's locations
int *our_x_locations;
int *our_y_locations;
// our infected people's locations
int *our_infected_x_locations;
int *our_infected_y_locations;
// our people's states
char *our_states;
// our people's infected time
int *our_num_days_infected;
};
our_current_day
a loop iterator representing the ID of the current day being simulated by the current process.
our_rank
used to keep track of the rank of the current process. If MPI is disabled, the value of this variable will be 0. If it is enabled, the value is set in init() function.
our_number_of_people
the number of people for which the current process is responsible. This will be a number less than or equal to the total number of people. The value is determined in find_size() function.
our_num_initially_infected
the count of initially infected people for which the current process is responsible.
our_num_infected
a count of the number of infected people for which the current process is responsible.
our_num_susceptible
a count of the number of susceptible people for which the current process is responsible.
our_num_immune
a count of the number of immune people for which the current process is responsible.
our_num_dead
a count of the number of dead people for which the current process is responsible.
our_x_locations
array, holds the x locations of all the people for which the current process is responsible.
our_y_locations
array, holds the y locations of all the people for which the current process is responsible.
our_infected_x_locations
array, holds the x locations of all the infected people for which the current process is responsible.
our_infected_y_locations
array, holds the y locations of all the infected people for which the current process is responsible.
our_states
array, holds the states of all the people for which the current process is responsible.
our_num_days_infected
array, used to keep track of the number of days each person has been infected for which the current process is responsible.
// Data being used as constant
struct const_t
{
// environment
int environment_width;
int environment_height;
// disease
int infection_radius;
int duration_of_disease;
int contagiousness_factor;
int deadliness_factor;
// time
int total_number_of_days;
int microseconds_per_day;
};
environment_width
indicates how wide the environment is; used to draw the environment and to make sure people stay within the bounds of the environment.
environment_height
indicates how high the environment is; used to draw the environment and to make sure people stay within the bounds of the environment.
infection_radius
see the Introduction Chapter above. The value of this variable can be specified on the command line with the –d option.
duration_of_disease
see the Introduction Chapter above. The value of this variable can be specified on the command line with the –T option.
contagiousness_factor
see the Introduction Chapter above. The value of this variable can be specified on the command line with the –c option.
deadliness_factor
see the Introduction Chapter above. The value of this variable can be specified on the command line with the –D option.
total_number_of_days
the total number of days over which to run the simulation.
microseconds_per_day
used to tell how many microseconds to freeze in between frames of animation. The value of this variable can be specified on the command line with the –m option.
// Stats data private to each node: Data being used by
// each process on a node in a cluster when using MPI.
// Each process holds stats data for a subset of people.
struct stats_t
{
double our_num_infections;
double our_num_infection_attempts;
double our_num_deaths;
double our_num_recovery_attempts;
};
our_num_infections
used to count the number of actual infections that take place (in which an infected person transmits the disease to a susceptible person). Only used if the showing of results is enabled (i.e., if the program is to print out final results from the simulation). Used to determine the actual contagiousness of the disease, which can be compared to the contagiousness factor by the user.
our_num_infection_attempts
used to count the number of times a susceptible person is within an infection radius of an infected person, even if the infection fails. Only used if the showing of results is enabled (i.e., if the program is to print out final results from the simulation). Used to determine the actual contagiousness of the disease, which can be compared to the contagiousness factor by the user.
our_num_deaths
used to count the number of times a person dies. Only used if the showing of results is enabled (i.e., if the program is to print out final results from the simulation). Used to determine the actual deadliness of the disease, which can be compared to the deadliness factor by the user.
our_num_recovery_attempts
used to count the number of times an infected person is able to become immune. Only used if the showing of results is enabled (i.e., if the program is to print out final results from the simulation). Used to determine the actual deadliness of the disease, which can be compared to the deadliness factor by the user.
// Data being used for the X display
struct display_t
{
#ifdef TEXT_DISPLAY
// Array of character arrays for text display
char **environment;
#endif
#ifdef X_DISPLAY
// Declare X-related variables
Display *display;
Window window;
int screen;
Atom delete_window;
GC gc;
XColor infected_color;
XColor immune_color;
XColor susceptible_color;
XColor dead_color;
Colormap colormap;
char *red;
char *green;
char *black;
char *white;
#endif
};
environment
2D array, holds an ASCII representation of the environment (see “state” under “Person” in the Introduction Chapter). This variable is used only when we are using Text Display.
display
Display, display pointer for the connection to the X server
window
Window, variable to holds the window id.
screen
Screen, variable to holds default screen
delete_window
gc
infected_color
immune_color
susceptible_color
dead_color
red
array of char, holds value #FF0000, which is the hex code for color red.
green
array of char, holds value #00FF00, which is the hex code for color green.
black
array of char, holds value #000000, which is the hex code for color black.
white
array of char, holds value #FFFFFF, which is the hex code for color white.
colormap