Page 1 of 1

Wrapping particles more than once around the global longitudes

Posted: September 12th, 2025, 11:16 am
by mneish
Version: 5.4.2

In global domain, when particles are near the poles, sometimes particles can wrap around the longitude band more than once. There's already some code in adv2nt and adv3nt to handle wrapping a single time, but if the particle has wrapped more than once it fails, and the XF interpolation factor falls far outside the 0..1 range giving strange results such as negative density.

I worked around the issue by turning the "IF" statement for wrapping into a "DO WHILE"... e.g.

adv2nt.f patch:

Code: Select all

72,73c72,73
<      IF(I1.GT.NXP)THEN
<         I1=1
---
>      DO WHILE (I1.GT.NXP)
>         I1=I1-NXP
75,79c75,79
<      END IF
<      IF(I1.LT.1)THEN
<         I1=NXP
<         XF=NXP+XF
<      END IF
---
>      END DO
>      DO WHILE (I1.LT.1)
>         I1=I1+NXP
>         XF=XF+NXP
>      END DO
adv3nt.f patch:

Code: Select all

76,77c76,77
<      IF(I1.GT.NXP)THEN
<         I1=1
---
>      DO WHILE(I1.GT.NXP)
>         I1=I1-NXP
79,83c79,83
<      END IF
<      IF(I1.LT.1)THEN
<         I1=NXP
<         XF=NXP+XF
<      END IF
---
>      END DO
>      DO WHILE(I1.LT.1)
>         I1=I1+NXP
>         XF=XF+NXP
>      END DO
Thanks,
Mike