1

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 enter image description here

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?

1
  • @casey: Updated question with code. Work array is 20,5 shape. I hope now it make sense. Commented Jul 28, 2014 at 16:33

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

ah! my stupid mistake. I read about column majoring, but didn't realize in action. Thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.