For Programmers: Free Programming Magazines  


Home > Archive > Fortran > April 2007 > HELP: "The number of subscripts is incorrect."









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author HELP: "The number of subscripts is incorrect."
Wenbin Hu

2007-04-17, 7:05 pm

I'M WRITING A SUBROUTINE TO GENERATE A INITIAL ARRAY:

SUBROUTINE MS(NX,NT)
INTEGER NX I
REAL DX
DIMENSION X(NX,1)
DO I=1,NX
X(I)=I*DX
END DO
END

THE FEEDBACK IS:
Error: The number of subscripts is incorrect. [X]

WHAT'S THE PROBLEM IN THIS PROGRAM? THANKS ALOT

WENBIN
FX

2007-04-17, 7:05 pm

> WHAT'S THE PROBLEM IN THIS PROGRAM? THANKS ALOT

The number of subscripts is incorrect.

--
FX
FX

2007-04-17, 7:05 pm

> WHAT'S THE PROBLEM IN THIS PROGRAM? THANKS ALOT

The number of subscripts is incorrect (for variable X).

--
FX

Wenbin Hu

2007-04-17, 7:05 pm

FX wrote:
>
> The number of subscripts is incorrect (for variable X).
>

So, if I wanna express X(I)=I*dX, how to set the subscripts of X?
thanks
Rich Townsend

2007-04-17, 7:05 pm

Wenbin Hu wrote:
> FX wrote:
> So, if I wanna express X(I)=I*dX, how to set the subscripts of X?
> thanks


Well, you've declared X to be a two-dimensional array. Thus, you need two
subscripts.

cheers,

Rich
e p chandler

2007-04-17, 7:05 pm

On Apr 17, 12:33 pm, Wenbin Hu <h...@ecn.purdue.edu> wrote:
> I'M WRITING A SUBROUTINE TO GENERATE A INITIAL ARRAY:
>
> SUBROUTINE MS(NX,NT)
> INTEGER NX I
> REAL DX
> DIMENSION X(NX,1)
> DO I=1,NX
> X(I)=I*DX
> END DO
> END
>
> THE FEEDBACK IS:
> Error: The number of subscripts is incorrect. [X]
>
> WHAT'S THE PROBLEM IN THIS PROGRAM? THANKS ALOT
>
> WENBIN


You are declaring a TWO dimensional array at the top. But you are
referencing a ONE dimensional array at the bottom. A ONE dimensional
array has ONE subscript.

So you need to code

DIMENSION X(NX)

In Fortran it is conventional to think of a row vector or a column
vector as one dimensional, not as a 1 row matrix or a 1 column matrix.

HTH

-- elliot

[Obviously tne next version of MIX needs an RPM instruction - "Read
Programmer's Mind"]




Beliavsky

2007-04-17, 7:05 pm

On Apr 17, 12:33 pm, Wenbin Hu <h...@ecn.purdue.edu> wrote:
> I'M WRITING A SUBROUTINE TO GENERATE A INITIAL ARRAY:
>
> SUBROUTINE MS(NX,NT)
> INTEGER NX I


I think there should be a comma between NX and I. Use IMPLICIT NONE in
all Fortran code.

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com