25743

Effect of `USE` on performance

Question:

I am currently working on a large fortran 90 code. Most of the modules have a large number of subroutines (>15). The modules USE other modules in its specification part, while their subroutines USE other modules on top of that. Here is what it looks like:

MODULE OneModule USE GlobalConstant USE GlobalVariable CONTAINS SUBROUTINE Subroutine1() [...] END SUBROUTINE Subroutine1 SUBROUTINE Subroutine2() USE Mesh [...] END SUBROUTINE Subroutine2 [Other Subroutines] END MODULE OneModule

Seeing this in every module, I was wondering if that was done for the sake of clarity or optimisation. If the module OneModule has a large number of subroutines, does it affect performance if we USE the module MESH in the specification part if only a handful of those subroutines need it?

Answer1:

I would be stunned (and writing a bug report to the compiler vendor) if the positioning of USE made any difference to execution times, given typical compiler implementation. It might make an inconsequential difference to compilation time.

Positioning in inner or outer scopes is more a question of preferred programming style intersected with program requirements for identifier accessibility.

(There is one exception, but it isn't relevant here. F2003 introduced a set of intrinsic (compiler provided) modules for IEEE floating point support. The mere presence of some of these modules can change the code that a compiler generates for anything in the scope of the USE.)

Recommend

  • Can't generate a StockID above 10
  • How to design an UML class diagramm with non object oriented parts?
  • Expanding a Region will expand children in Visual Studio
  • How pass variables by reference to a Scilab function
  • Generate stl mesh from csv
  • QML apply a texture to a Mesh
  • Most efficient way to convert a ISO Date into Unix timestamp?
  • Access floats of XMMatrix - () operator not working
  • PHP library for keeping your site Indexed by Google Bing etc
  • Camera-Offset | Project Tango
  • How to bind a single object instance in WPF?
  • Minimum Cost Flow - network optimization in R
  • Capture literal brackets inside brackets in pyparsing
  • Recursion in F# | What's happening?
  • How would you model data variables variance on common scheme? SQL
  • AWS SES Production Access setup with Meteor
  • Python importing a function with file's name contained in a variable
  • Moved coordinates of the scene when DOM element with renderer is not at the top of the screen
  • MySQL Query Tuning - Why is using a value from a variable so much slower than using a literal?
  • Fast way to alphabetically sort the contents of a file in java
  • Is there an easy way to associate an event with a ListViewItem?
  • How do you keep a running instance for Google App Engine
  • What is this strange character in chrome's resource css viewer?
  • py4j.protocol.Py4JJavaError when selecting nested column in dataframe using select statetment
  • How to repeat sections of a SQL query across UNIONs? (DRY in SQL)
  • Python 3.2.2, error(scripts to exe)
  • python mysqldb delete row
  • import scipy.sparse failed
  • For loop with if condition on multiple R functions
  • How do I retrieve the user information of a user authenticated with Apache's mod_ldap?
  • Autofac with Web API 2 - Parameter-less constructor error
  • pillow imaging ImportError
  • Authentication in Play! and RestEasy
  • Django simple Captcha “No module named fields” error
  • How do I exclude a dependency in provided scope when running in Maven test scope?
  • Is there a perl module to validate passwords stored in “{crypt}hashedpassword” “{ssha}hashedpassword
  • Meteor helpers not available in Angular template
  • Python: how to group similar lists together in a list of lists?
  • using HTMLImports.whenReady not working in chrome
  • Understanding cpu registers