Re: pros and cons of user-defined types
- From: Paul van Delst <Paul.vanDelst@xxxxxxxx>
- Date: Wed, 17 Oct 2007 10:35:41 -0400
Bart Vandewoestyne wrote:
Hello all,
Because of an email of a collegue of mine, i started to ask
myself questions about the benefits and disadvantages of using
user-defined types.
Suppose you have the situation where you have a procedure with
lots and lots of arguments. Then i think it is good programming
style to group related arguments into user-defined types. And
for as far as I know, this 'making code more readable' is the main
benefit of replacing the large argument list by a smaller
argument list consisting of arguments of user-defined types.
My question is however: does this replacement also have a
drawback? In what way can it be disadvantageous to replace a
large argument list by something smaller consisting of
user-defined type arguments?
The only disadvantage that I could possibly think of is speed.
Whether that should be 'compilation speed' and/or 'execution speed',
I'm not quite sure...
Am I right that compilation and/or execution speed would be the only disadvantage(s) here? Or are there other possible disadvantages?
Having gone this route (using derived types for most stuff) the only disadvantage I routinely encounter is the simple make-work of writing the code to handle the derived type operations (allocate, destroy, etc) and their I/O (in my case both netcdf and "binary"). I overcame that with a tool that writes about 90% of the code and I tailor the remainder by hand.
Compilation speed is not an issue for me (but I know it is for others).
In my case, trying to measure execution speed in some meaningful sense has proven difficult enough that I don't really consider it until the application code I write ends up in the final application (radiative transfer model in a data assimilation system). Of course, I pay attention to the usual details that affect speed when designing/writing code, and I profile it also, but the maintainability and adaptability of the code is more important to me. If/when the NWP guys tell me the code is too slow, I make it faster -- and that's a lot easier to do when the source code is malleable; thanks in part to the judicious use of derived types.
cheers,
paulv
.
- Follow-Ups:
- Re: pros and cons of user-defined types
- From: ttw
- Re: pros and cons of user-defined types
- References:
- pros and cons of user-defined types
- From: Bart Vandewoestyne
- pros and cons of user-defined types
- Prev by Date: Re: Problem with log function - Intel fortran compiler under Linux
- Next by Date: Array of Array
- Previous by thread: Re: pros and cons of user-defined types
- Next by thread: Re: pros and cons of user-defined types
- Index(es):
Relevant Pages
|