[PATCH] centralised definition for surface pressure

Jan Schubert Jan.Schubert at GMX.li
Mon Jan 14 12:22:51 PST 2013


On 01/14/13 18:52, Dirk Hohndel wrote:
> Jan Schubert <Jan.Schubert at doubleSlash.de> writes:
>
>> This patch centralizes the definition for surface pressure by
>> eliminating 11 (!) occurrences of definitions for surface pressure, feel
>> free to find more :-).
>> It also removes a few occurrences of definitions for oxygen in air.
> I'm not surprised. Good idea to rationalize and centralize that.

I thought this is another good way to get an idea about the code.

> +#define O2_IN_AIR        0.20942
> +#define N2_IN_AIR        0.78084 // 0.7902 before
> +#define O2_DENSITY       1.429   // Gramm/Liter
> +#define N2_DENSITY       1.251
> +#define HE_DENSITY       0.1786
> +#define SURFACE_PRESSURE 1.01325 // mbar
> +#define AIR_PERMILLE     O2_IN_AIR * 1000
> Now this is interesting. I'm not sure this will bite us anywhere in the
> code, but if you think about it, the old definition of 209 was an int,
> but 0.20942 * 1000 is actually a float. So this could change calculations.
> So while I like the intent of making this simpler, I think I'd feel
> better if AIR_PERMILLE was defined to be 209 in stead of 0.20942 * 1000
>
> The same now happens with SURFACE_PRESSURE. Multiplying the 1.01325 with
> 1000 also creates a float, not an int.
>
> I glanced through the code - it seems harmless. It just makes me
> nervous.

Yeah, I also thought about this and beside there is indicating about
wrong types I also could not find an issue with that. So lets give it a
try? Of course it would be better to harmonize all (!) calculations by
using same units like mbar and mm and not switching between bar and mbar
or numbers and permille.

And, umgh, yes, I could start here with doing a "correct" mbar based
implemenation of the EADD calculation.

>
>> @@ -909,7 +909,8 @@ void input_plan()
>>  {
>>  	GtkWidget *planner, *content, *vbox, *hbox, *outervbox, *add_row, *deltat, *label, *surfpres;
>>  	char starttimebuf[64] = "+60:00";
>> -	char pressurebuf[64] = "1013";
>> +	char pressurebuf[64];
>> +	sprintf(pressurebuf, "%d", (int)(SURFACE_PRESSURE * 1000));
> don't like this one...

>From a technical point of view? The only reference to pressurebuf is in
here:

        gtk_entry_set_text(GTK_ENTRY(surfpres), pressurebuf);

What would be a better way to "standardize" this?

Thx,
Jan


More information about the subsurface mailing list