Adjusted loop-bounds in module_bl_gwdo.F to prevent illegal index operation.
Opened this issue · 0 comments
cponder commented
We were seeing a segfault in the module_bl_gwdo.F
code when we compiled it with OpenACC directives to run on the GPU.
Likely because the GPU was enforcing array-boundaries more aggressively than the original CPU compilation would.
The problem showed up here in the transition from MPAS-A 6.x to 7.x where the loop-boundary changed but the indexing did not:
569 do k = kts+1,kpblmax-1 | do k = kpblmin,kpblmax 539
570 do i = its,ite do i = its,ite 540
571 if (k .lt. kbl(i)) then if (k .lt. kbl(i)) then 541
572 rdelks = (prsl(i,k)-prsl(i,k+1)) * delks1(i) rdelks = (prsl(i,k)-prsl(i,k+1)) * delks1(i) 542
573 bnv2(i,1) = bnv2(i,1) + bnv2(i,k) * rdelks bnv2(i,1) = bnv2(i,1) + bnv2(i,k) * rdelks 543
574 usqj(i,1) = usqj(i,1) + usqj(i,k) * rdelks usqj(i,1) = usqj(i,1) + usqj(i,k) * rdelks 544
575 endif endif 545
576 enddo enddo 546
577 enddo enddo
MIchael Duda recommended this fix
133 if(present(p_top) .and. present(znu) .and. present(znw)) then
134 do k = kts,kte
135 if (znu(k).gt.0.6) kpblmax = k + 1
136 enddo
137 else
138 kpblmax = kte | kpblmax = kte-1
139 endif
which we applied to the develop-openacc
branch (pull-request #922), and intend to merge into the develop
branch to be in the 8.0 release.
You may want to merge this separately into the 7.x branch in order for the code to be more correct.