I have a very simple test setup:
PROGRAM test REAL(KIND=8), ALLOCATABLE :: lam CALL stest(lam) END PROGRAM test
SUBROUTINE stest(lam) REAL(KIND=8), ALLOCATABLE, INTENT(OUT) :: lam ALLOCATE(lam(5)) END SUBROUTINE stest
upon ifort stest.f90 test.f90 I get:
stest.f90(3): error #8196: An ALLOCATE shape must not be given for a scalar object. [LAM]
compilation aborted for stest.f90 (code 1)
Why should this work? The best practices in F90 have just this example here - see the part allocatable arrays. Further, help says:
type, [att-ls,] ALLOCATABLE [, att-ls] :: a[(d-spec)] [[coarray-spec]][, a[(d-spec)] [[coarray-spec]]...
clearly stating that (d-spec) is optional. So, why does it not work?
(Note that if you call a procedure with an allocatable dummy argument, then an explicit interface for the procedure must be accessible in the scope where the procedure is invoked (otherwise, when compiling the main program the compiler doesn't know that the dummy argument of the subroutine is allocatable and it won't know that it has to set the corresponding actual argument up in a special way). The best way to ensure an explicit interface is to put the subroutine in a module.)
The example on that Fortran90.org website is simply wrong. Inside the subroutine stest, the dummy argument lam is not declared to be an array - so it taken to be a scalar. Because it is taken to be a scalar, you cannot allocate it with bounds as if it was an array.
I expect the example was intended to be something like:
SUBROUTINE stest(lam) REAL(KIND=8), ALLOCATABLE, INTENT(OUT) :: lam(:) ! declares that lam is a rank one array -----^ ALLOCATE(lam(5)) END SUBROUTINE stest
I consider some of the "best practices" on that site to be a bit dubious.