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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to create 3dimensional array

Status
Not open for further replies.

milenko76

Technical User
Mar 26, 2010
100
PT
I need this because of easy array maniplulation. I tryed like this:
program arrayc

implicit none

integer :: i
integer,dimension(57) :: a
real,dimension(57) :: b(1,1.8,63.39,472.97,801.43,3.71,35.07,15.63
&,6.15,170.03,1.96,47.99,55.85,268.35,59.79,34.29,426.48,966.75
&,150.88,794.58,7.79,18.97,499.75,90.99,506.33,766.85,3.27,374.94,
&525.45,7.62,643.81,17.54,8.27,35.05,15.36,234.07,116.79,42.94,
&59.87,1.93,67.37,19.81,62.90,342.80,30.00,208.50,1.70,3.76,
&4.88,219.32,1.88,3.50,70.81,54.88,165.17,8.76,21.45)
integer,dimension(57) ::c(0,0,0,0,0,0,0,0,0,0,1,0,1,0,1,0,0,1,0,
&1,0,0,1,0,1,1,1,0,0,0,1,0,1,0,0,0,0,0,0,1,0,0,0,1,0,1,1,1,1,1,1,
&0,0,1,0,0,1)

do i=1,57
a(i)=2
write(*,100)a(i),b(i),c(i)
100 format(i3,2x,f6.2,3x,i1)
end do
end
But get this:
arrayc.for(7): error #6204: There are too many dimensions; the maximum rank is 31.
real,dimension(57) :: b(1,1.8,63.39,472.97,801.43,3.71,35.07,15.63
----------------------------^
arrayc.for(13): error #6204: There are too many dimensions; the maximum rank is 31. [C]
integer,dimension(57) ::c(0,0,0,0,0,0,0,0,0,0,1,0,1,0,1,0,0,1,0,

 
It is a different syntax for array initialization
Code:
 real,dimension(57) :: b = (/1,1.8,63.39,472
  ...165.17,8.76,21.45/)
 
A 3 dimensional array is declared as

real:: x(max1, max2, max3)

or

real, dimension(max1, max2, max3):: x

where max1, 2 and 3 are the 3 dimensions.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top