Re: Namelist usage

From: Dick Hendrickson (dick.hendrickson_at_att.net)
Date: 12/01/04


Date: Tue, 30 Nov 2004 23:09:41 GMT


Rich Townsend wrote:

> Dear all,
>
> I've never got around to using namelists in my code, and I was wondering
> whether anybody who *does* use them -- and find them helpful -- could
> embark on a bit of advocacy in their favour. For instance, what sorts of
> tasks do namelists help you tackle? What sort of coding idioms do you
> employ with namelists?
>

Two major uses that I can think of where it works out well.
1) Debugging or status printouts during a program run.
Doing a NAMELIST output gives name=value lists (obviously)
which I think are easier to read than just value lists.
Especially during debugging where you probably don't know
what is going on anyhow.

2) Managing code which has a large set of adjustable
parameters. I used to see people do things like
       namelist /parameters/ a,b,c...
       data a /137/
       data b /42/
...
       read(input_file, parameters)
       write (history_file, parameters)

That way, the user only has to put in the values he wants
to change, everything else keeps the values from the DATA
statements. The history_file gets the complete set for
later checking or whatever.

Dick Hendrickson
> cheers,
>
> Rich
>