- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I am trying to retrieve a value from an array, using column value as index,
to select the corresponding value from a specified row, and use it in an equation.
Attached is a portion of the array.
In an attempt to do this I am trying to create another subroutine
(with the arguments as row-i and column-j) for this, and then call it in the equation,
I am going to use. In the subroutine, I tried to read the complete array into temp (i,j).
Is this the right approach, or would there be an efficient way? I also checked the documentation, but
I didn't find Fortran inbuilt functions (also tried to look for lookup function).
Any suggestions or pointers in this regard would be greatly helpful.
Thank you.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
A single array has to be all integers or all reals (or all logical or all user defined type). The data you show in the .txt file, to be one data type would imply they all be real. Thus when fetching the year, as real, you would have to use the int() function to convert it to integer prior to use.
An alternative would be to use two arrays, one as integer for the column of years, the other as real for a 3 by n array holding the H, PotE, and KinE.
If your years are always contiguous, then you only need store the start year and number of years.
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you for the suggestions, Jim.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Jim,
As suggested I created two arrays, one as integer for the column of years, the other as real for a 3 by 11 array holding the H, PotE, and KinE. Attached herewith is test program and test input. I am getting segmentation default while compiling. Can you please give me some suggestions in this regard.
Thank you in advance for your suggestions.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page