[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Netcdf 3.3 under Digital Unix 3.2 (VAX??)



>To: address@hidden
>From: Harry Edmon <address@hidden>
>Subject: Netcdf 3.3 under Digital Unix 3.2
>Organization: .
>Keywords: 199705301715.LAA14552
>
> make of netcdf3.3 under Digital Unix 3.2 fails as follows:
>
> 11 tao% make
>
> Making `all' in directory /a/damp/usr/local/src/netcdf-3.3/src/libsrc
>
> c89 -c -O -I.  -DNDEBUG attr.c
> c89 -c -O -I.  -DNDEBUG dim.c
> c89 -c -O -I.  -DNDEBUG error.c
> c89 -c -O -I.  -DNDEBUG -DVERSION=`cat ../VERSION` libvers.c
> c89 -c -O -I.  -DNDEBUG nc.c
> c89 -c -O -I.  -DNDEBUG ncio.c
> c89 -c -O -I.  -DNDEBUG ncx.c
> /usr/lib/cmplrs/cc/cfe: Error: ncx.c, line 1221: value is outside range
> representable for type 'float'
(-3.40282347E+38F )
> )
>         ------------------^
> *** Exit 1
> Stop.
> *** Exit 1
> Stop.
> *** Exit 1
> Stop.
>
>
> - - --
> Dr. Harry Edmon                       E-MAIL: address@hidden
> (206) 543-0547                        FAX:    (206) 543-0308
> Dept of Atmospheric Sciences
> University of Washington, Box 351640, Seattle, WA 98195-1640

I presume this on on a VAX (where FLT_MAX is 1.701411733192644299e+38f),
otherwise your compiler should be able to scan the constant.

Oddly enough, gcc on our VAX doesn't catch this error.
Who knows what the comparison is actually doing!

To fix this properly, I need to think about this.
There are a couple of options:

Compare against the MIN(X_FLOAT_MAX, FLT_MAX),
Something like
#if FLT_MAX_EXP < 128 /* 128 is X_FLT_MAX_EXP */
# undef X_FLOAT_MAX
# define X_FLOAT_MAX FLT_MAX
# undef X_FLOAT_MIN
# define X_FLOAT_MIN FLT_MIN
#endif
ncx.c, line 1221, and others, become
        if((float)(*ip) > 1.701411733192644299e+38f
                || (float)(*ip) < (-1.701411733192644299e+38f))

This has the advantage of minimal code restructure.
It also preserves a sortof semantic we have, that
conversions act as if you assigned to the "closest"
type  and then "put" the assigned value.

The disadvantage is that one loses a power of two in the
domain of integers that can be converted to external float.
To implement this would be a lot more work.

You can try putting the above #if sequence at about line 47
in ncx.c and give it go.

-glenn