INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Variables in fortran & array use

Variables in fortran & array use

(OP)
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.

RE: Variables in fortran & array use

What exactly do you mean by autogenerate

RE: Variables in fortran & array use

(OP)
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

RE: Variables in fortran & array use

Quote (civil2013)

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 http://stackoverflow.com/questions/9536346/fortran...) like it would be in an interpreted language like Python or MATLAB.

RE: Variables in fortran & array use

(OP)
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

RE: Variables in fortran & array use

Sounds like you're after a data structure, ie k(1)%matrix, k(2)%matrix, ..., k(n)%matrix, to store your data

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources


Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close