Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Index multiple non-adjacent elements of a Fortran array

Tags:

fortran

Is there a way in Fortran to access many elements of an array without using a loop?

For example given array of 100 elements

real(100) :: a

can I do something like this to access elements 1,4,7,54,81 that do not follow a regular step?

a(1,4,7,54,81)= 3.21423
like image 912
Herman Toothrot Avatar asked Mar 11 '23 04:03

Herman Toothrot


1 Answers

you could use a vector subscript: a( (/1,4,7,54,81/) )= 3.21423

like image 157
ewcz Avatar answered Mar 24 '23 07:03

ewcz