Re: moduel VS parameters
- From: Richard Edgar <rge21@xxxxxxxxxxx>
- Date: Thu, 30 Jun 2005 09:49:51 +0200
yuanliu1@xxxxxxxx wrote:
I got one code from another guy which has forty parameters for each subroutine call. I do not like it, so I make modules and then everything is passed through modules.
I assume you mean arguments, rather than parameters?
Now I have a problem. The original subroutine, which is very messy, can work independant of the other parts as long as I feed it with the right parameter. In my version of code, I have to use the module everytime. Since some information are somewhat common to many modules, it is hard to isolate them. In another words, the modules I used in one subroutine may contains more information than the subroutine needs.
I know maybe this is something about Object Oriented. But are there anyway in fortran I can do?
I believe you have just provided a very elegant description of why procedures usually take arguments, rather than receiving everything through modules/COMMON/'global variables.' Forty arguments does sound like a lot, but.....
There are times when it makes sense to pass things through MODULEs. Physical constants are a good example, since they (probably) won't change during any one run, and they would just clutter up the argument list. There are also times when I've had to use MODULEs and/or COMMON in order to keep variables in the right parallelisation scope. But these cases are the exception. As a general rule, if a procedure is supposed to take some data, do some work, and return results... that's the reason procedures take arguments.
Richard .
- Follow-Ups:
- Re: moduel VS parameters
- From: s . c . kramer
- Re: moduel VS parameters
- References:
- moduel VS parameters
- From: yuanliu1
- moduel VS parameters
- Prev by Date: Re: I have no ideas what can it be!
- Next by Date: Re: MODULEand USE versus Argument Passing
- Previous by thread: moduel VS parameters
- Next by thread: Re: moduel VS parameters
- Index(es):
Relevant Pages
|