Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

array question

Status
Not open for further replies.

EvLer

Programmer
Aug 27, 2008
5
US
Hi,
I need to translate fortran 90 to C. I know C quite well, but fortran not really at all.... so i am learning on the fly. I came across this statement in code and not sure what exactly that means:

dUdt(0:ncx, 0:ncy, 1:neq)

it does not matter what the variables stand for, i just want to know what this is: a 3D array or what? I thought DIMENSION is used in case of a multidimensional array, so i am confused.

thanks in advance.

ps: i can provide more information if this is not sufficient.
 
Yes, it is a declaration of a 3D array. Declarations have several formats: this is just one of them. By default, the array indices start at 1; this forces two of them to start at 0.

In C, there are two ways of doing this:

1) Waste the first item if it begins with 1. In this case it would be dUdt[ncx+1][ncy+1][neq+1]
2) Recode everything to start at 0. This causes all the indices to be offset by 1 except for those which begin at 0.

Also beware of the common translation bug dUdt[x,y,z] - that just returns dUdt[z].
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top