Let's say I have an array of dimensions declared like this:
integer, dimension(5) :: dims
dims = (/ 5, 6, 7, 8, 9 /)
How can I most simply use this array to allocate another array, using the elements of dims
to specify the size of the respective dimensions? Say the second array is declared like this:
real, dimension(:,:,:,:,:), allocatable :: dset
Why can't I do the following?
allocate (dset(dims(:)))
I get Error: Rank mismatch in array reference
when I attempt to compile.
I realize that I can do this:
allocate (dset(dims(1), dims(2), dims(3), dims(4), dims(5)))
But I'm looking for something more easily extensible.