Generate an arbitrary 1D array, vector, filled with random numbers between 0 and 1. By using the MAXLOC intrinsic with a suitable mask set up an integer array, VSubs, which contains a permuted index set of vector such that Vector(VSubs(i)) > Vector(VSubs(i+1)) for all valid i.
You may find it useful to use the MAXLOC intrinsic. For example,
MAXLOC(VSubs)
returns an array containing the index of the largest element of the array VSubs, and,
MAXLOC(VSubs,MASK=VSubs.LT.VSubs(i))
returns the position of the largest element that is less than the value of VSubs(i). In both cases the result is a one element 1D array. (The array contains one element because VSub only has one dimension.)