Infinity and NaN in ncap2 ?

Developers
Anonymous
2010-10-17
2013-10-17
  • Anonymous - 2010-10-17

    Hello all!

    Any ideas whether there is special way to give in ncap2 values like NaN and Infinity.
    Sometimes in my anaysis I have them and whant to treat them in any way…
    For Infinity expresions like if ( a == 1./0. ) do the trick but for NaN  0.0 /0.0  sometimes doesn't work.

    Having a NaN and Inf constants in NCO could help to ahve a general approach to the problem, so whenerver the nco is compiled on a platform with IEEE floating point support one could take the benefit of constants or macros or whatever in the ncap2 language.

    This is just a suggestion, may be I have bad experience in Inf and NaN. I'll try to rewrite my old scripts to how they work now.

    Regards
    Rostislav

     
  • Charlie Zender

    Charlie Zender - 2010-10-18

    > Any ideas whether there is special way to give in ncap2 values like NaN and
    > Infinity.
    > Sometimes in my anaysis I have them and whant to treat them in any way…
    > For Infinity expresions like if ( a == 1./0. ) do the trick but for NaN  0.0
    > /0.0  sometimes doesn't work.

    This is an interesting suggestions I have not heard before.
    As I understand it, one problem with handling NaN and Infinity in ncap
    is that NCO is strongly tied to the netCDF data format. By default the
    results of computations are written immediately to disk, and so one
    needs netCDF/HDF to support these NaN/Inf representations unless one
    works with RAM variables only. So I think that even if ncap2 handled
    NaN/Inf, it would break in the netCDF layer. Is my understanding
    correct?

    > Having a NaN and Inf constants in NCO could help to ahve a general approach
    > to the problem, so whenerver the nco is compiled on a platform with
    > IEEE floating point support one could take the benefit of constants
    > or macros or whatever in the ncap2 language.

    We can assume that NCO is only used on platforms with IEEE FPS.
    And if patches were supplied that addressed the above concern,
    we would certainly accept them. It would be cool to give the
    user more control over IEEE FP signals.

    > This is just a suggestion, may be I have bad experience in Inf and
    > NaN. I'll try to rewrite my old scripts to how they work now.

    That seems more sane :)

    cz

     

Log in to post a comment.