I am trying to get value from a two dimensional array, but value I have at index is not what I am getting. Here is program:
subroutine stlstp(y,n,np,ns,nt,nl,isdeg,itdeg,ildeg,nsjump,ntjump,nljump,ni,userw,rw,season,trend,work)
! implicit none
! Arg
integer n,np,ns,nt,nl,isdeg,itdeg,ildeg,nsjump,ntjump,nljump,ni
logical userw
double precision y(n),rw(n),season(n),trend(n),work(20,5)
! Var
integer i,j
do 80 j = 1,1
do 1 i = 1,n
work(i,1) = y(i)-trend(i)
1 continue
call stlss(y,n,np,ns,isdeg,nsjump,userw,rw,season)
PRINT *, 'WORK 1,2 ....',work(1,2)
PRINT *, 'WORK ....',work
call stlfts(work(1,2),n+2*np,np,work(1,3),work(1,1))
PRINT *, 'WORK...',work
printing
Based on this output, shouldn't PRINT *, 'Work1,2....'
return 193.0000
? but I am getting 0.000000
as output. Can someone please help with this? what am I missing?
Fortran uses column-major ordering for arrays, so for a shape of (20,5), the element (1,2) is the 21st element of the array. Confusing this, the print *,
will print the element in rows. The element you have circled is (2,1). Element (1,2) is the 0.000
located in the first column of row 5 of your output image.