You cannot write allocate(dset(dims(:)))
for exactly the reason the compiler gives: they have different ranks. If you were to print shape(dims)
, you would see 5
on-screen; if you were to print shape(dset)
, you would see either 0 0 0 0 0
or 5 6 7 8 9
(depends if you allocated it or not); dims
is a rank-1 array, dset
is a rank-5 array.
So pretty much the only way to allocate an allocatable is via the explicit method that you feel is inextensible.