Insertion and wrapping of generation files

A new generation in a GDG is typically inserted after the current generation and thus becomes the new current generation.

If the sum of the increment and the current generation number is greater than 9999, wrapping (subtraction of 9999) occurs, and the new generation number will be less than the current generation number. In this case the new generation might be inserted before the current generation, becoming a previous (less current) generation in the group.

Consider the following initial group:


0: base.g0001v00 

The number before the colon, called an epoch number, is used to cause insertion to occur predictably and enforces limits on generation numbers.

Typically a new generation is inserted into the group in the position indicated by the new generation number after any wrapping has occurred, and the epoch numbers within the GDG are not changed.

In each of the following examples, the least current generation is listed first, and the most current generation is listed last. Italics indicates a new generation that has been added to the group.

Consider the example initial group shown above. If base(+1) is specified, the current generation number (0001) is incremented by 1. The group as a result will contain the new generation 0002 as shown:


0: base.g0001v00 
0: base.g0002v00

If base(+4) is then specified, the current generation number (0002) is incremented by 4. The group as a result will contain the new generation (0006) as shown:


0: base.g0001v00
0: base.g0002v00
0: base.g0006v00

If base(+9997) is then specified, the current generation number (0006) is incremented by 9997. The resulting generation number (10003) is greater than 9999 and is therefore wrapped to become 0004. In the resulting group this new generation (0004) will be inserted before the current generation (0006) as shown:


0: base.g0001v00 
0: base.g0002v00
0: base.g0004v00 
0: base.g0006v00

After this last insertion, it is not an error to open base(+9997) for input, because the reference to base(+9997) denotes the existing file base.g0004v00 and does not cause any change to the structure of the group.

Typically, the epoch number of a new generation is the same as the epoch number of the current generation. There are however two cases in which epoch numbers are adjusted, and the insertion position of the new generation is less obvious:

  • If the current generation number is greater than or equal to 9000 and the new generation number is less than 1000, wrapping will occur. But the epoch number of the new generation will increase so that the new generation can be inserted after the current generation despite the fact that the new generation has a lower generation number.
    For example, consider the following initial group:
    
    0: base.g1000v00 
    0: base.g9000v00
    

    If base(+1499) is specified, the current generation number (9000) is incremented by 1499. The resulting generation number (10499) is greater than 9999 and is therefore wrapped to become 0500. In the resulting group the new generation (0500) is given a higher epoch number and becomes the new current generation despite having the lowest generation number in the group as shown:

    
    0: base.g1000v00 
    0: base.g9000v00
    1: base.g0500v00
    
  • If the current generation number is less than 1000 and the new generation number is greater than or equal to 9000, the epoch number of the new generation is decreased unless the epoch number of the current generation was already zero. In the latter case the epoch number of the existing generations is increased so that the new generation will be inserted before all the generations despite having a higher generation number.
    For example, consider the following initial group:
    
    0: base.g0001v00 
    0: base.g0999v00
    
    If base(+8501) is specified, the current generation (0999) is incremented by 8501. The resulting generation number (9500) is less than 9999; therefore no wrapping occurs. The resulting group will contain the new generation (9500) but with epoch number 0. The epoch number of the existing generations is increased to 1. As a result the new generation becomes the least current generation in the group as shown:
    
    0: base.g9500v00
    1: base.g0001v00 
    1: base.g0999v00
    

Related concepts  
Generation data groups

Related tasks  
Using generation data groups

Related references  
Name format of generation files  
File specification