Re: moduel VS parameters



Exactly, modules shouldn't be used to pass around data used in
different parts of the program. Otherwise you'll end up with something
similar to those ghastly f77 codes, where all data is thrown in one big
common block and this data may be changed at random anywhere in the
100.000 lines of code.

If you stare long enough at those 40 arguments, you will probably find
they can be logically divided in some groups and that those groups also
appear in the argument lists of other subroutines. Now if you define a
derived type for each such group, and pass those as arguments to the
subroutine you can make the argument list a lot shorter and everything
becomes a lot more readable. You will then probably also find that a
lot of the subroutines primarily act on the contents of just one of the
groups/derived types. Those subroutines can then be bundled into one
module including the definition of this one derived type. Now you've
got yourself a more object oriented approach (if that's what you're
after): with one kind of object and all of its methods in one module.

Stephan Kramer

.



Relevant Pages

  • Re: Use and misuse of derived data types
    ... calculation, and the derived type in the calling subroutine, making ... That seems to defeat the purpose of derived types. ... potential, or spectral data, or something), you want to minimize the ... that use directly, or pass on to other subroutines, these new data ...
    (comp.lang.fortran)
  • Re: Save/restore data from a module?
    ... Brooks Moses wrote: ... I hesitate to use this solution because it will make all the variable ... a single derived type contain variables that are only related by being ... used in the same collection of subroutines. ...
    (comp.lang.fortran)
  • Re: Constant Hash problem
    ... >> You can't because perl implements constants using subroutines and ... > Perl subroutines return only lists but it converts them to hashes ... Any list can be assigned to a hash just as a hash can be assigned to a list. ...
    (perl.beginners)
  • Re: Program Fails When Parameter Fixed Constants are Changed (F77) ??
    ... Common Block /XYCRT/ Xcrt, Ycrt, n ... I would recommend fixing this before converting it to a module. ... these lists so that they agree with those that use the other list. ... the other set of subroutines. ...
    (comp.lang.fortran)
  • Re: How to insert or append new items into a perl hash ?
    ... But the answer to your question is found in perldoc perlsub and is this: subroutines only ever receive and return lists. ... but if it has a more complicated structure than that it will be lost. ... To do what you want you have to use a reference to the hash; too complicated to explain here with your level of knowledge. ...
    (comp.lang.perl.misc)