Fortran Array Size Allocation

I am looking to take data and create new arrays that are the same shape. However, I seem to be making Fortran unhappy with this syntax:

For instance I want to create an array that is the same size as the input data:

function allocate_size(input_data)
    IMPLICIT NONE
    REAL, INTENT(in) :: input_data
    REAL, DIMENSION(SIZE(input_data, DIM=1), SIZE(input_data, DIM=2), SIZE(input_data, DIM=3), SIZE(input_data, DIM=4), &
        SIZE(input_data, DIM=5)) :: new_data
end function allocate_size

or one that is slightly different when one of those SIZE(input_data, DIM=x) would be replaced with an integer. Is this an incorrect approach?