On May 10, 12:25 pm, smurray444 <email@example.com> wrote:
a simple approach:
> Hey guys,
> I'm trying to write some Fortran code to achieve a bilinear
> interpolation upon a grid of dimension 240 values (x) by 120 values
> (y) and where the data is currently at a spatial resolution of 1.5
> degrees... I want the output grid to be at a resolution of 5 minutes.
> How would I go about doing this, and what would the Fortran code look
> like to achieve this?
> Thanks for your time and help,
real,intent(in):: old(0:,0:) ! old data
integer,intent(in):: ns ! resolution factor (common for x and y)
real:: im(0:ns,2) ! interpolation matrix (common for x and y)
! prepare interpolation matrix
forall(i=0:ns) im(i,2) = real(i,kind(im))/ns
im(:,1) = 1 - im(:,2)
(untested, may contain bugs)
which you can call with ns=18 to get your fine resolution.
Note that you will get more that 9 million numbers. a simple piecewise
bilinear interpolation from a regular grid (like this) is so fast that
it is IMHO almost always better to just keep the original data and
interpolate on demand. If you insist on pre-interpolating to a fine
grid, you should at least look at more elaborate tensor product
splines that produce smoother surfaces. See, e.g. numerical recipes in
Fortran, chapter ... uhh ... three?