|
Prev: First day of summer?
Next: F2003 automatic deallocation
From: John on 20 Jun 2008 21:36 How do you determine if a module is in scope or not? For example, if you have four modules a,b,c,d. Suppose a uses b, b uses c, and c uses d. If a is used by the main program. Are all the modules always in scope? My thinking is a is in scope due to being used by the main program. Since a is in scope, b is in scope. Since b is in scope, d is in scope, etc. So it seems like all modules should be in scope all the time unless a module is not used at all. I'm sure I must be mistaken though. Is there any way to know for sure, e.g., compiler diagnostics? This question is motivated by the recent thread that was discussing the save attribute in the context of modules. I realized I am not sure hot to determine whether certain modules are in scope or not, so I don't know whether I need the save attribute (at the module level) or not for my module variables. John
From: robert.corbett on 20 Jun 2008 23:25 On Jun 20, 6:36 pm, John <gh14...(a)yahoo.com> wrote: > How do you determine if a module is in scope or not? > > For example, if you have four modules a,b,c,d. > > Suppose a uses b, b uses c, and c uses d. > > If a is used by the main program. Are all the modules always in scope? The Fortran 2003 standard clearly intends that if the module a is referenced in the main program, the modules referenced by a should also be considered to be referenced by the main program. The standard doesn't say that, but whoever wrote that part of the standard clearly intended it to say that. > My thinking is a is in scope due to being used by the main program. > Since a is in scope, b is in scope. Since b is in scope, d is in scope, > etc. So it seems like all modules should be in scope all the time > unless a module is not used at all. I'm sure I must be mistaken though. > Is there any way to know for sure, e.g., compiler diagnostics? > > This question is motivated by the recent thread that was discussing the > save attribute in the context of modules. I realized I am not sure hot > to determine whether certain modules are in scope or not, so I don't > know whether I need the save attribute (at the module level) or not for > my module variables. For all practical purposes, you do not need to specify the SAVE attribute for modules. Every implementation of Fortran 90 and later versions of Fortran of which I am aware treats module variables as if they have the SAVE attribute. Any implementation that does otherwise will fail to become important. Bob Corbett
|
Pages: 1 Prev: First day of summer? Next: F2003 automatic deallocation |