When nesting block statements into each other, it is no longer possible to access the result value of an outer function.Consider
integer function test() result(Res)
Res = 1
This leads to error #7816: Invalid assignment to function result of external procedure.
The error occurs regardless of whether a result variable is defined or the function name is used by itself. Assignment works for one single block, but as soon as the second level starts, the result can no longer be written to.
Compiler: Visual Fortran Compiler 220.127.116.11