llnl / llnl/UEDGE

Possible typo in grid interpolation

Open
#44 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Fortran
Stars
56
Forks
22
PR merge metrics
No merged PRs in 30d

Description

There is a suspicious line in this polintp poloidal interpolation function:
https://github.com/LLNL/UEDGE/blob/master/bbb/griddubl.m#L1169

        do 30 ixo = ixos, ixof
            if(xo(ixo,iy).gt.xn(ix,iy) .or. ixo.eq.ixof) goto 25
            ixl = ixo
  20    continue
  25    continue

The 30 label is shared with an outer loop, and the 20 label is not used in this function.

The corresponding lines in the radintp radial interpolation function
https://github.com/LLNL/UEDGE/blob/master/bbb/griddubl.m#L1108
are:

            do 20 iyo = iyos, iyof
               if(yo(ix,iyo).gt.yn(ix,iy) .or. iyo.eq.iyof) goto 25
               iyl = iyo
  20        continue
  25        continue

I suspect that the radintp version is correct, and the polintp do loop should use 20 rather than 30 or be rewritten as

do ixo = ixos, ixof
   if(xo(ixo,iy).gt.xn(ix,iy) .or. ixo.eq.ixof) exit
   ixl = ixo
end do

Note: I think this bug, if it is a bug, causes extra work to be done but doesn't affect the result: The interpolation is performed for every value of ixo (rather than just one), but the last result computed has the correct value of ixl.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Inspect bbb/griddubl.m around polintp at line 1169 and compare its loop labels with radintp around line 1108. Confirm whether the shared 30 label causes repeated interpolation work, determine the intended loop behavior, and verify that the corrected version preserves the reported ixl result.

Written by the indexing model from the issue text.

Assessment

Tech stack
fortran
Domain
performance
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.