Perhaps this will help ...
You can dimension an array using integer variables.
these variables can be passed into your function or subroutine along with the value you want to assign
As a very basic example:-
SUBROUTINE DOTHIS(NARG,MARG,VALUE)
DIMENSION MYARRAY(NARG,MARG)
DO...