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!

Fortran_Nested_Arrays?

Status
Not open for further replies.

Ahn210

Technical User
Jun 18, 2013
11
Hello,

Can anyone teach me how to declare an allocatable array with another array (TYPE) nested inside? Or suggest better way to store data below?

I wish to store data into an array like...
Automaker (i) % Month (j) % SALES(j)
Automaker (i) % Month (j) % COST(j)

ex)
Automaker (bmw) % Month(JAN) % Sales(JAN)
Automaker (bmw) % Month(JAN) % COST(JAN)
Automaker (bmw) % Month(FEB) % Sales(FEB)
Automaker (bmw) % Month(FEB) % COST(FEB)
;;
Automaker (Audi) % Month(JAN) % Sales(JAN)
Automaker (Audi) % Month(FEB) % Sales(FEB)


I used to declare

Type Month
integer sales , cost
End type

then

Type (month), dimension :)), allocatable :: Array1

for the inner array that I use.



Thank you,
 
Not really sure what you are asking. Would you ever have
Code:
automaker(bmw)%Month(JAN)%Sales(FEB)
automaker(bmw)%Month(FEB)%Sales(DEC)
If not, then why would you want Sales and Cost to be indexed?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top