Open weiyuan-jiang opened 1 year ago
I don't think that is quite the structure. Instead I think you have k(:,:), and weight(:,:).
And we want to encapsulate this. something like:
type VInterpolator
integer, allocatable :: k_ij(:,:)
real, allocatable :: w_ij(:,:)
contains
procedure :: interpolate
end
This issue has been automatically marked as stale because it has not had recent activity. If there are no updates within 7 days, it will be closed. You can add the "long term" tag to prevent the Stale bot from closing this issue.
In current vertical interpolation, for each level, it goes through all the levels to find out corresponding horizontal points, and then calculates the weight and does the linear interpolation. So it is roughly K*K algorithm
https://github.com/GEOS-ESM/MAPL/blob/29c9ba32a3144509d35025f6b99f20efb53de4ab/base/MAPL_VerticalMethods.F90#L604-L616
Can we improve the algorithm by saving the indices and weights ? So the interpolation would look like
OutVars(i(:), j(:), ik(:)) = inVars(i(:),j(:),ik(:))*weight((i:),j(:), ik(:) + inVars(i(:),j(:),ik(:)+1)*(1- weight((i:),j(:), ik(:))
Here
i(:), j(:), ik(:)
and weight are calculated and saved every time the pressure ( or vcoord) are updated@bena-nasa @atrayano @tclune