Re: MODULEand USE versus Argument Passing



I don't think you can see this independent of the architecture, the
compilers, the kind of arguments and so on and so forth. Just a simple
benchmark shows that in that specific case, passing 10 arguments is
actually faster (ia32, ifort):

output:
Module 0.285956000000000
Arguments 0.250962000000000

code:
MODULE M1
INTEGER :: a,b,c,d,e,f,g,h,i,j
CONTAINS
SUBROUTINE S1()
a=a*b*c*d*e*f*g*h*i*j
END SUBROUTINE S1
SUBROUTINE S2(a,b,c,d,e,f,g,h,i,j)
INTEGER :: a,b,c,d,e,f,g,h,i,j
a=a*b*c*d*e*f*g*h*i*j
END SUBROUTINE S2
END MODULE M1

USE M1
INTEGER :: k
REAL*8 :: t1,t2,t3,t4
a=0 ; b=0 ; c=0 ; d=0 ; e=0 ; f=0;
g=0 ; h=0 ; i=0 ; j=0
CALL CPU_TIME(T1)
DO k=1,10000000
CALL S1()
ENDDO
CALL CPU_TIME(T2)
write(6,*) "Module ",T2-T1
CALL CPU_TIME(T1)
DO k=1,10000000
CALL S2(a,b,c,d,e,f,g,h,i,j)
ENDDO
CALL CPU_TIME(T2)
write(6,*) "Arguments ",T2-T1
END

Cheers,

Joost

.



Relevant Pages

  • Re: Problem converting external routine to internal
    ... subroutine into free form. ... compilers don't find any mismatches when I move it from ... I don't remember whether IMPLICIT NONE requires things like ... do indexes in the main program and a surprising host association ...
    (comp.lang.fortran)
  • Re: Problem converting external routine to internal
    ... I'm adapting the guts to construct a Fortran-90 gridded model ... The behavior is repeatable across compilers (at least "sunf95", ... What could cause the act of moving an IMPLICIT NONE subroutine ... my qname at domain dot com ...
    (comp.lang.fortran)
  • Re: Reading an image array.
    ... subroutine to display the image. ... common /cm1/nx, ny ...
    (comp.lang.fortran)
  • Re: Weired thing
    ... double precision me,He0,alpha1,Eps1,Psat,Psatp,Psatpp ... end subroutine invswitch ...
    (comp.lang.fortran)
  • Re: aliased intent(in out) arguments
    ... the code is not standard-conforming. ... What is non-conforming is for the subroutine in question to then modify ... One could also easily write a case where array elements were being ... Compilers *MAY* catch errors like this. ...
    (comp.lang.fortran)