- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Suppose you have an integer array iTime(4,4,5) which is initially filled as follows (where nSeason = 5):
do iSeason = 1,nSeason read(5,*) (iTime(1,J,iSeason), iTime(2,J,iSeason), J = 1,4) enddo
Now supposed that you set the J=2 elements of this array upstream of this read loop and only wish to read in 3 pairs of integers. In this way, you'd like to control distribution of the read integer values by setting the the J-index as 1, 3-4. I hope my description is clear.
I've never tried to do this before. Is there an easy way to do this? Is there any way to do this?
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
integer, parameter :: the_ones_i_want(3) = [ 1, 3, 4 ] do iSeason = 1,nSeason read(5,*) ( iTime(1,the_ones_i_want(J),iSeason), & iTime(2,the_ones_i_want(J),iSeason), & J = 1,size(the_ones_i_want) ) enddo
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hmmm ...
Stunning.
I'll give that a shot. Thanks so much, Ian.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Just posting back to say that I transposed your code suggestion and incorporated it into my system. It worked like top.
Sweet.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
TommyCee,
FYI,
The operation you are performing is a scatter operation. If the collection of input data are in a sequential array as opposed to read file, then you can use:
OutArray(the_ones_I_want) = InArray ! or InArray(1:nItems), or InArray(1:size(the_ones_I_want))
Where you use the array "the_ones_I_want" as the index positions in OutArray
You can use the same trick on the other side of = for a gather operation.
Jim Dempsey

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