|
From: Klemens on 5 May 2008 02:48 Hi all, trying to speed up a f90 program I was thinking about the difference if I put my subroutines in a module or if I define an interface. Will there be any differences in speed for these two approaches ? Thanks for your help in advance ! Klemens
From: Richard Maine on 5 May 2008 03:00 Klemens <jokulhlaup(a)web.de> wrote: > trying to speed up a f90 program I was thinking about the difference > if I put my subroutines in a module or if I define an interface. Will > there be any differences in speed for these two approaches ? No. Except for the speed of development. Writing interface bodies is error-prone and thus likely to slow down code development. Well, ok, that is certainly an overgeneralization, as some are likely to point out. But I felt I should say more than the one-word answer "no". I can't really think of any useful elaboration on that other than that it isn't likely to be a constructive avenue to pursue. About the closest thing I can think of is the issue of copy-in/copy-out for array arguments. That doesn't have anything directly to do with using modules versus interface bodies. But it is at least vaguely related to the subject of explicit interfaces. -- Richard Maine | Good judgement comes from experience; email: last name at domain . net | experience comes from bad judgement. domain: summertriangle | -- Mark Twain
From: Klemens on 5 May 2008 03:09 Hi Richard, thanks for your quick response ! So I will not waste any time for changing from interfaces to a module. Cheers, Klemens
From: Arjen Markus on 5 May 2008 03:21 On 5 mei, 09:09, Klemens <jokulhl...(a)web.de> wrote: > Hi Richard, > > thanks for your quick response ! > So I will not waste any time for changing from interfaces to a module. > > Cheers, > > Klemens Maintaining routines in a module means that the interface is maintained in a single place only! The advantage is that changes to the interface of these routines are automatically known to the compiler. If you have interface blocks in the calling routines, there will still be a possibility for mismatches. Consider: subroutine suba( x ) real :: x ... end subroutine and: program test_suba interface subroutine suba( x, y ) real :: x, y end subroutine end interface call suba( x, y ) end program There is no "intrinsic" relationship between the implementation of the routine and the interface block. If however: module moda contains subroutine suba( x ) real :: x ... end subroutine end module and: program test_suba use moda call suba( x, y ) end program the compiler can "see" the mismatch. It is up to you, but I think modules are preferrable. Regards, Arjen
From: Klemens on 5 May 2008 03:48
Hi Arjen, thanks for your explanations ! They help to improve my knowledge of Fortran. Regards, Klemens |