Re: operation on module arguments
- From: "dpb" <dpbozarth@xxxxxxxx>
- Date: 21 Sep 2006 14:33:56 -0700
gottoomanyaccounts@xxxxxxxxx wrote:
Hi there,
I have a question about how I can update the variables declared on a
module by simply having the USE statement only....
The point is, I want c always to be the sum of a and b. In the main....
program, a and b may be read in from an external file, (in the example
above, they get explicitly set.) What I want is, when a and b get
changed, c is automatically updated, I don't have to call another
subgrogram to update c. All I would like to have is just the 'use foo'
statement in the main program.
As Richard points out, there's no functionality like that in Fortran so
you can't achieve the stated object w/o adding something else to the
code. But, you can certainly add the necessary code to be executed at
each point in the program where either a or b or both are modified. In
your example, if there is a READ statement that includes either, then
after that and before c is referenced elsewhere simply include the
statement
c = a + b and that will accomplish the task.
Of course, this requires that you do have to be sure to find every
place where either can be or are modified either by a direct assignment
or from an indirect use (such as a side effect of a subroutine if used
as an argument or as affected by being in COMMON or similar). And, of
course, it also means c has to be verified to not have any operations
carried out on it other than these.
One would assume that if the objective is as stated, these wouldn't be
terribly difficult constraints, but they do have to be imposed manually.
.
- Follow-Ups:
- Re: operation on module arguments
- From: gottoomanyaccounts
- Re: operation on module arguments
- References:
- operation on module arguments
- From: gottoomanyaccounts
- operation on module arguments
- Prev by Date: Re: operation on module arguments
- Next by Date: Re: operation on module arguments
- Previous by thread: Re: operation on module arguments
- Next by thread: Re: operation on module arguments
- Index(es):