Skip to content

Fix out-of-bounds access on zk in cvmix_kpp_compute_StokesXi (2)#114

Merged
mnlevy1981 merged 2 commits intoCVMix:masterfrom
alperaltuntas:fix_stokesmost
May 4, 2026
Merged

Fix out-of-bounds access on zk in cvmix_kpp_compute_StokesXi (2)#114
mnlevy1981 merged 2 commits intoCVMix:masterfrom
alperaltuntas:fix_stokesmost

Conversation

@alperaltuntas
Copy link
Copy Markdown
Contributor

This PR applies a fix a Fortran runtime error caused by accessing zk(kSL+1) when the KPP surface layer cell index kSL equals the number of vertical levels.

Fixes: #112

@alperaltuntas
Copy link
Copy Markdown
Contributor Author

Menitoning @mnlevy1981

@mnlevy1981 mnlevy1981 self-assigned this May 4, 2026
Copy link
Copy Markdown
Contributor

@mnlevy1981 mnlevy1981 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alperaltuntas the source mods look good, but there's some trailing white space that needs be cleaned up so the CI tests will pass:

* Check for trailing white space: 6 error(s) found
  ../src/shared/cvmix_kpp.F90:3454:     real(cvmix_r8) :: BLDepth, TauMAG, TauCG, TauDG, taux0, tauy0, Stk0 , Pinc█
  ../src/shared/cvmix_kpp.F90:3457:     integer        :: ktmp                                              ! vertical loop index███████████████████████████
  ../src/shared/cvmix_kpp.F90:3483:     delz    = zk(1) - zk(2)█
  ../src/shared/cvmix_kpp.F90:3492:       delz     = zk(ktmp) - zk(ktmp+1)██
  ../src/shared/cvmix_kpp.F90:3507:       tauEbot  = (tauxbot * delU + tauybot * delV) / delz█████████████████████████████
  ../src/shared/cvmix_kpp.F90:3540:     tauEbot  = (tauxbot * delU + tauybot * delV) / delz██
* Check length of lines: 0 error(s) found
* Check for case sensitive statements: 0 error(s) found
Fortran errors found: 6

Copy link
Copy Markdown
Contributor

@mnlevy1981 mnlevy1981 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

@mnlevy1981 mnlevy1981 merged commit fce4221 into CVMix:master May 4, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Out-of-bounds array access in cvmix_kpp_compute_StokesXi when surface layer reaches bottom cell

2 participants