Re: MODULEand USE versus Argument Passing



Dick: I like your reply to my question because it matches what my
gut suspected.

I am quite aware of special array type cases, which show some compiler
dependence, illustrated well by Arnaud Desitter's benchmarks:
http://ftp.aset.psu.edu/pub/ger/fortran/test/FortranArgPassing/results.txt

Besides this, running the (slightly modified) test case formulated by
poster Joost shows that you are correct. (Yield essentially the same
timing results across several compilers under both Windows and Linux)
for three interfaces (Module, Subroutine contained in module, and external
subroutine). My preference would be to use Modules because these
can be more self documenting as well as convenient.

I also agree with you about COMMON being messy to debug, especially
for large codes that do not use INCLUDEs for the COMMON variables and
companion declarations.

Many thanks.
Skip


On Wed, 29 Jun 2005 16:09:38 GMT, Dick Hendrickson <dick.hendrickson@xxxxxxx> wrote:

-|
-|
-|Herman D. Knoble wrote:
-|
-|> Given a Subprogram that gets called millions of times,
-|> we know that there is (CPU) overhead for subprogram linkage.
-|>
-|> My question is, independent of compilers, which is more efficient
-|> in practice:
-|>
-|> passing a list of (say 3 to 10) arguments to a subprogram's
-|> corresponding parameters,
-|> OR using a Module and companion USE statement,
-|> OR use named COMMON?
-|>
-|> Skip Knoble
-|Seriously, I think the answer is none of the above, it's
-|"whatever makes the most sense to you". If the subroutine
-|does anything significant, then the call overhead is
-|likely to be small either way, and if the subroutine is
-|small (for some definition of small ;) ), turn on inlining
-|and let the compiler figure it out.
-|
-|I once spent a fascinating week debugging someone else's
-|code (I'd never make this kind of mistake ;) ) where
-|there was a
-| COMMON blah blah I,J, blah blah
-|in the main program and a
-| COMMON blah blah J,I, blah blah
-|in the subroutine.
-|
-|Again, seriously, write it in a way that is easiest to
-|understand and don't sweat the small stuff.
-|
-|Dick Hendrickson

.



Relevant Pages

  • Re: Multiple INCLUDE Vs multiple USE
    ... Problems without explicit error meaasges and explicit code producing the ... end program master ...
    (comp.lang.fortran)
  • Re: C++ to VB conversion and preprocessor definition
    ... The #define preprocessor definition tells the compiler to effectively ... perform a search and replace on the sourcecode as it is compiling, replacing ...
    (microsoft.public.dotnet.languages.vb)
  • Re: FreeRTOS / SafeRTOS in a Medical Device
    ... delete "in blah blah blah" ... Which is why it is difficult to do validation for a GCC compiler compared to a compiler from say Byte craft where they have all the documentation from day 1 and control the process. ... if I was to take that landing gear and integrate it ... onto another plane then I would need the entire lifecycle and design data so ...
    (comp.arch.embedded)
  • Re: my first class - getting an error
    ... I'm not sure what the problem you're having interpreting the error is, but I _suspect_ you are being led astray by the "...and no extension method blah blah blah" part. ... In some cases, in a well-intentioned effort to provide you with additional guidance, the compiler introduces some concept that you may not even be aware of, completely confusing the issue. ... But the "Calculus" method exists in the "summing" class, ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Basic ASCII File Reading
    ... I have an ascii file I'm trying to read in with a header and then two ... Blah blah 2 blah blah blah blah ... it but I need to get to the correct position to start reading the ... SUBROUTINE readfile ...
    (comp.lang.fortran)