[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Vectorization question

This will be my last post on this topic: please accept my apologies.

Liam Gumley <Liam.Gumley@ssec.wisc.edu> wrote in message
> I forgot FORTRAN uses 1-based indices by default. What I *meant* to say
>         subroutine vecadd1(a, na, x, nx, b)
>         integer*4 na, nx
>         real*4 a(0:na-1), b(0:nx-1)
>         integer*4 x(0:nx-1), i
>         do i = 0, nx - 1
>           a(x(i)) = a(x(i)) + b(i)
>         end do
>         end

The SGI compiler doesn't like this code for some reason. So I switched back
to the original FORTRAN source, and changed the IDL wrapper function to

x = ((long(index) > 0L) < (n_elements(a) - 1L)) + 1L

which converts the zero-based IDL indices to one-based FORTRAN indices. Then
everything works as advertised. This is a better approach anyway, because it
allows existing FORTRAN code to be used without modification.