There are issues with naming a subroutine the same as a subroutine that is used from another module but is renamed. See the code for details.
Download all files in this gist.
To see the bug in the code, compile with gfortran-7:
make FC=gfortran-7
./prog
It should hang, and leak memory.
Try again with a newer gfortran:
make FC=gfortran-8
./prog
This should finish immediately and print
2.00000000
The issue is that even when renaming a subroutine used from a module you cannot name a subroutine, locally, with the same original name as the used subroutine. At least with a gfortran version earlier than 8.
Use gfortran-8 or greater. Or don't use name a subroutine with the same name as another even if renaming when using from the other module.
In the latter case, in lib.f90 replace
subroutine subrwith, for example,
subroutine subr_cAnd in prog.f90 replace subr with subr_c.