Dear all,
I recently played around with the new submodule capabilities in PSXE2016 and some questions arose.
The first one is a question of experience of other users: Do you take advantage of the procedure definition (example foo) or do you repeat the interface in the submodule (example bar)? I find it difficult to decide which one I should use.
The second is more a feature request. Staying at modules the "go to definition" works well and is really helpful. This does not work in any way with submodules (VS2015 sp1, PSXE2016 update 2, example code shows that it does not work). Please, Intel, enhance the VS2015 integration.
The third one is a question whether it makes sense to allow either 'end procedure foo' or alternatively 'end subroutine foo' within the submodule smod_test. The other way round the compiler gives an error ('end subroutine bar' vs. 'end procedure bar').
Here is the example code (4 different files):
submodule (mod_test) smod_test contains ! this version is without repeating the interface module procedure foo implicit none d = real(i*j*k,rk) return !end subroutine foo ! -> this does work too, but does it make sense? end procedure foo ! this version repeats the interface module subroutine bar(i, j, k, d) use mod_parameter implicit none integer(ik), intent(in ) :: i, j, k real(rk) , intent(out) :: d d = real(i*j*k,rk) return end subroutine bar !end procedure bar ! -> this does not work end submodule module mod_parameter use ISO_FORTRAN_ENV, only : ik => int32 use ISO_FORTRAN_ENV, only : rk => real64 implicit none private public :: ik, rk end module mod_parameter module mod_test use mod_parameter implicit none private public :: foo, bar interface module subroutine foo(i, j, k, d) implicit none integer(ik), intent(in ) :: i, j, k real(rk) , intent(out) :: d end subroutine foo module subroutine bar(i, j, k, d) use mod_parameter implicit none integer(ik), intent(in ) :: i, j, k real(rk) , intent(out) :: d end subroutine bar end interface end module mod_test program submodule_test2 use mod_parameter use mod_test implicit none integer(ik) :: i, j, k real (rk) :: d ! ---------------------------------------------- i = 2 j = 5 k = 3 call foo(i,j,k,d) write(*,'(1ES18.4)') d call bar(i,j,k,d) write(*,'(1ES18.4)') d end program submodule_test2
Any comment is highly welcome, Johannes