operation on module arguments
- From: gottoomanyaccounts@xxxxxxxxx
- Date: 21 Sep 2006 13:29:44 -0700
Hi there,
I have a question about how I can update the variables declared on a
module by simply having the USE statement only. To illustrate, for
example
file foo.f90
--------------
module foo
implicite none
real :: a, b, c
**** (anything I need here to make c=a+b)
end module foo
=========================
file main.f90
----------------
program main
use foo
implicit none
a= 1.0
b= 9.0
write(*,*) c
end program
=========================
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.
In the above example, if I don't want to change anything in the main
program, what I should write in the module foo to get the correct
result, c=10.0 ?
I apologize if this is a silly question. Thanks for any help.
.
- Follow-Ups:
- Re: operation on module arguments
- From: glen herrmannsfeldt
- Re: operation on module arguments
- From: Brooks Moses
- Re: operation on module arguments
- From: dpb
- Re: operation on module arguments
- From: Rich Townsend
- Re: operation on module arguments
- From: Richard E Maine
- Re: operation on module arguments
- Prev by Date: Re: Interface declarations
- Next by Date: Re: Non-constant expression where constant expression required.
- Previous by thread: Exponentiation operator precedence
- Next by thread: Re: operation on module arguments
- Index(es):