No, it is not possible to have an array with variable rank. From the Fortran 2008 Standard, Cl. 2.4.6 "Array":
1 An array may have up to fifteen dimensions, and any extent in any dimension. The size of an array is the total
number of elements, which is equal to the product of the extents. An array may have zero size. The shape of an
array is determined by its rank and its extent in each dimension, and is represented as a rank-one array whose
elements are the extents. All named arrays shall be declared, and the rank of a named array is specified in its
declaration. The rank of a named array, once declared, is constant; the extents may be constant or may vary
during execution.
[Emphasis mine.]
However, you could have a one-dimensional array with extent product(extent in each dimension)
, and index the elements appropriately.
You could even have multi-dimensional pointers associated with these 1D-arrays. This would take care of the indexing for you, but (as given in the citation), is limited to 15 dimensions for Standard Fortran.