Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

Variables in fortran & array use 1

Status
Not open for further replies.

civil2013

Structural
Feb 27, 2005
24
Hi, I am using fortran95 for writing a code.my doubt are:
1. Whether it is possible to autogenerate a variable. Ie; for i=1, the variable should be k1, then k2 and so on...

2. I have 2d arrays k1, k2, till k10 which are of nxn size...is it possible to have an array'k' which is 10 x 1 and can store all 10 nxn matrices in this. ..
Thanks for any help on this.
 
Replies continue below

Recommended for you

What exactly do you mean by autogenerate
 
hi, to simplify, my problem looks like this - the program asks for an integer input 'n'.. when I enter 'n'=10, a variable k1 gets assigned as '1'. k2=2, k3=3, k4=4.... and so k10=10. I understand that we could define 'k' as a allocatable 1d array. but I do not want to use array here, depending on the requirement (n), the no. of variables should be automatically generated. I hope my requirement is clear.. thanks
 
civil2013 said:
but I do not want to use array here

Why? You could allocate an array of the appropriate size and store all the values in said array. I'm not sure what you're asking for is even possible in Fortran or similar compiled languages (see like it would be in an interpreted language like Python or MATLAB.
 
Seems to me that you're just asking for complications. Almost everyone else is able to use arrays and indexed variables, why are you not able to?

TTFN (ta ta for now)
I can do absolutely anything. I'm an expert! faq731-376 forum1529
 
in that case, ...is it possible to have an array'k' which is 10 x 1 and can store all 10 nxn matrices in this. ..
is it possible to store 2d arrays as elements in a 1d array
 
Sounds like you're after a data structure, ie k(1)%matrix, k(2)%matrix, ..., k(n)%matrix, to store your data
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor