Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix wrong math in dynamic_vector allocation. #125

Merged

Commits on Aug 18, 2015

  1. Fix wrong math in dynamic_vector allocation.

    There were two problems with this expression. First, the order of
    operations was wrong (missing parentheses). Second, the size of a
    strided subsection of an array is the size over the stride rounded up,
    rather than down, as in typical integer division.
    
    This bug showed up in unit tests with some compiler flag modifications,
    but the affected code is not exercised in CESM (or probably anywhere
    else, other than unit tests). The reason that unit tests did not catch
    this issue earlier is that the bug has no effect under Fortran 2003
    automatic allocation rules. If the array is too small, automatic
    re-allocation prevents a segfault. If the array is too big, this is not
    a problem, since the vector type is deliberately designed to reserve
    extra space.
    
    However, we currently use some compilers without Fortran 2003 allocation
    rules enabled. This seems true of PGI and Cray in particular. On these
    compilers, it seems to be worth fixing the issue in case the strided
    access feature of the dynamic vector is used in the future.
    
    Testing:
    
        Unit tested only (this code is not currently exercised).
        Status: bit for bit
    quantheory committed Aug 18, 2015
    Configuration menu
    Copy the full SHA
    8562aab View commit details
    Browse the repository at this point in the history