I want to be able to index arrays with a single index as well as multiple indexes. For instance

real, dimension(3,3) :: arr = 0e0
arr(4) = 1.0
does not work. Conversely

real, dimension(25) :: arr = 0e0
arr(3,3) = 1.0
does not work either, i.e. Fortran does not want you to mix ranks obviously. This is to be expected, but from using MATLAB so much lately (which allows this), I was hoping to find a way to do it without being terribly inefficient.

Right now my options are to:
1) Solve for the different indices using the single index, which is inefficient
2) Reshape the higher rank array into a rank-1 array, do the operation, and then shape it back into its original shape, which is probably even more inefficient
3) Only work with rank-1 arrays, forcing me to do things like arr(N*j+i) for the indexing, and I'm also going to run into problems when I try and use the built-in amenities for higher rank arrays (transpose, etc.)

At this point I don't like any of my options, so I might just can the idea of using single indices.