The parallel forage search algorithm follows the same general movement rules as in the sequential SIMPDEL model. Each day of the simulation, deer forage sequentially on each processor. Order is determined randomly each day. Each deer's daily forage search begins with an attempt to graze on the current grid location. If the cell does not contain enough available high quality forage, a search for a new grid cell position is initiated (as explained in Section 2). In order for the forage search to be performed in parallel by multiple processors, subroutine dmove was separated into the two subroutines: dmove and find_forage_cell. Subroutine dmove is invoked only by the processor on which the deer is located, however find_forage_cell may be called by all processors containing grid locations within a deer's search area. Subroutine dmove is responsible for calling find_forage_cell, waiting for message responses, and later updating the deer's position and travel distance after a new grid cell is found. Locating the new grid cell is the responsibility of find_forage_cell, which initiates the forage search among concentric squares centered at the deer's current location, and sends messages to neighboring processors if the search area expands past the current processor's boundaries. The subroutine flow of the forage search and deer growth process is discussed in [Abb95].
If either the top or bottom row of processor PN's search area is owned by another processor, PN will send a search message to the processor containing that row. If the top row of PN's search area is not located on PN, it will always be the last row on PN, and if the bottom row of PN's search area is not located on PN, it will always be the first row on PN. The search message contains the following information: the deer's grid position, maximum water depth, maximum moving distance, the class of forage being searched (FQ_HIGH or FQ_MEDIUM), and the current search radius.
Whether or not processor PN sends a search message to another processor, the local search will continue until either a 500m cell with available forage is found or the deer's maximum moving distance is reached. At this point, if a message has been sent to a neighboring processor, PN must wait for one or more message responses, referred to as location messages. A location message contains the row and column positions of the 500m grid cell with a maximum of available forage, the available forage level (or 0 if no grid cell is found), the search radius (the number of grid cells between the selected forage cell and the center of the search area), and an integer value indicating whether or not the search area expanded past a processor boundary.
As each location message is received, PN will compare the current minimum search radius with the search radius from the message buffer. As in the sequential model (explained in Section 2), the nearest grid cell with a maximum level of available forage above the threshold is chosen as the new grid cell. For example, in Figure 10, a 500m grid cell with a maximum level of available forage above the threshold has been located on each of the three processors. The maximum forage cell located on processor PN has the smallest radius and therefore will be chosen as the deer's new grid position, regardless of the amount of available forage in the selected grid cells on PN and PN. If multiple grid cells along the same concentric square perimeter have the same maximum, one will be chosen at random.
If a grid cell with available forage above the threshold is located after all message responses have been received, the deer's position is updated, as well as the positions of any fawns. If the selected grid cell is owned by processor PN, the deer's graze field is set to the value of the forage class (FQ_HIGH or FQ_MEDIUM), so that the deer will continue grazing on the same class of forage on PN. Processor PN will then send the deer structure as a message to PN. However, if the deer is a female with fawns, the deer data for the mother and fawns is first copied into an array of deer structures, and the entire array is then sent as a message to PN.
Upon receipt of the deer message from PN, PN must first determine the size of the message buffer, since a deer message may contain data for one, two, or three deer. To determine the size of the message buffer, the CMMD function CMMD_bytes_sent is used. The integer value returned by this function divided by the size (in bytes) of the deer data structure equals the number of deer structures in the message buffer. The data for each deer is then copied into a separate structure and inserted into PN's deer array. All adult deer (or independent fawns) will be placed on a queue. When the current deer has completed foraging for the day, the queue is checked. If the queue is not empty, the deer that has been waiting for the longest time will be the next to forage. The entire queue must be emptied before any deer originally residing on the processor can begin the foraging sequence. The reason for this constraint is that all deer on the deer queue have already begun the foraging sequence, but did not find enough forage on their original processors to satisfy their maximum intake. Those on the queue have been assigned new grid locations with available forage levels. In order to increase the chance that the forage level on a deer's grid cell will be the same as when it was chosen, those on the queue must forage before any other. It is still possible however, that a foraging deer could deplete the resources on a grid cell upon which a queued deer is waiting to graze, forcing the queued deer to search for a new grid cell. The intensive checking required to avoid this potential problem would be unnecessary in all but a few simulation years, and therefore has not been implemented.