Quantcast
Channel: Recent posts
Viewing all articles
Browse latest Browse all 415

Generic procedures with submodules

$
0
0

I've been trying to do this but can't figure out the correct syntax (It works when everything is in one module).

parent.f90:

module parent

   interface prin
       module procedure prin_i
           module procedure prin_r
   end interface prin

   interface
       module subroutine wri(c)
           integer, intent(in) :: c
           end subroutine wri

           module subroutine prin_i(i)
               integer, intent(in) :: i
           end subroutine prin_i

           module subroutine prin_r(r)
               real, intent(in) :: r
           end subroutine prin_r
   end interface

end module parent

child.f90

submodule (parent) child

contains

   module subroutine wri(c)
       integer, intent(in) :: c
           call prin(c)
   end subroutine wri

   module subroutine prin_i(i)
       integer, intent(in) :: i
           write(*,'(i0)') i
   end subroutine prin_i

   module subroutine prin_r(r)
       real, intent(in) :: r
           write(*,'(g0.6)') r
   end subroutine prin_r

end submodule child

modprob.f90:

program modprob
    use parent

        call wri(3)

end program modprob

Then

ifort /nologo parent.f90 child.f90 modprob.f90 /Femodprob.exe

gives

child.f90(7): error #6285: There is no matching specific subroutine for this generic subroutine call.   [PRIN]
           call prin(c)
----------------^
compilation aborted for child.f90 (code 1)

I've tried lots of syntax variations but can't figure this one out. Any ideas will be greatly appreciated, thanks.

 


Viewing all articles
Browse latest Browse all 415

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>