resolving same generic-name functions via size of argument-Collection of common programming errors

I’d like to have a function interface that resolves which specific procedure is to be used depending on the size of an array argument. I could then, for example, have a program that handles vectors with less than or exactly N elements with one procedure and longer vectors with another one. As far as I know, Fortran only resolves using types, ranks and keywords of the arguments. Why is that? Aren’t compilers intelligent enough to differentiate between arrays of different sizes or is it intrinsically impossible to write a compiler that does that?

Is there a workaround to achieve the desired functionality? I know of course that I could write a subroutine with an if-clause to sort out which procedure to use for which array size. Wouldn’t that cost more CPU time though?