[ncl-talk] Potential issue with version 6.4.0 of NCL

Rick Brownrigg brownrig at ucar.edu
Fri Mar 16 14:50:47 MDT 2018


Hi Tanya,

It appears the warning about floats exceeding INT_MAX are coming from the
function decimalPlaces(). That function was modifed in 2016, but I'm having
trouble determining what got modified and how/whether that introduced the
error you are seeing.  Nonetheless, the comments in the code for
decimalPlaces() suggest its perhaps considered deprecated, and that
sprintf() is what should be used instead:

http://ncl.ucar.edu/Document/Functions/Built-in/sprintf.shtml

Rick


On Fri, Mar 16, 2018 at 2:08 PM, Tanya Peevey <trpeevey at gmail.com> wrote:

> NCL-Talk,
>
> I'm running some code that works with version 6.3.0 of NCL but not with
> the 6.4.0 version. The issue happens in one or two functions: tofloat (or
> stringtofloat) and decimalPlaces. I looked online and there is no mention
> of these functions being removed or changed for the newer version of NCL.
> I'm wondering if there is a bug in the 6.4.0 version of NCL. Any assistance
> would be appreciated.
>
> Below is some text showing what happens and a snippet of the code. If
> needed I'll send more information but I'm hoping that this will be enough.
>
> The 'cost,grad,step ...' line is obtained from a file that is generated by
> a model.
> Here is the code that gets that line and then tries to get information
> from the 5th and 6th column of that line.
>
> filename2 =
> /scratch4/BMC/qosap/ptmp/Andrew.Kren/par/prCTL_2_noAMV/gsistat.gdas.
> 2016082200 <(201)%20608-2200>
>
> error occurs at first 'if statement'
>
> **CODE*:*
> ; Default background color of Main Table (not Header) is white.
> ; If num assimilated (ratio) doesn't increase (decrease) then the color is
> changed so
> ; that the user can quickly see the issue.
> default_table_fillcolor = "white"
> flag_table_fillcolor = "palegreen"
> delim1 = " "
> delim2 = "_"
>
> ; system calls to linux to get necessary data
> cost_grad = systemfunc("grep cost, " + filename2)
> print(cost_grad)
> print("Reading Cost and Gradient...")
>
> cost_value_1 =
> tostring(decimalPlaces(tofloat(str_get_field(cost_
> grad(0),5,delim1)),4,True))
> cost_value_2 =
> tostring(decimalPlaces(tofloat(str_get_field(cost_
> grad(201),5,delim1)),4,True))
>
> grad_value_1 =
> tostring(decimalPlaces(tofloat(str_get_field(cost_
> grad(0),6,delim1)),4,True))
> grad_value_2 =
> tostring(decimalPlaces(tofloat(str_get_field(cost_
> grad(201),6,delim1)),4,True))
>
> print(str_get_field(cost_grad(0),5,delim1))
> print(str_get_field(cost_grad(201),5,delim1))
> print(stringtofloat(str_get_field(cost_grad(0),5,delim1)))
> print(stringtofloat(str_get_field(cost_grad(201),5,delim1)))
> print(decimalPlaces(tofloat(str_get_field(cost_grad(0),5,delim1)),4,True))
> print(decimalPlaces(tofloat(str_get_field(cost_grad(201),
> 5,delim1)),4,True))
> print(cost_value_1)
> print(cost_value_2)
>
> dayfile_name = str_get_field(inFile1,7,"/")
> if (tofloat(cost_value_1) .lt. tofloat(cost_value_2)) then
>   cost_value_flag = flag_table_fillcolor
>
>   write_table(textfile,"a",[/"X","  ","  ","  ","  ","  ","  ","  "/], \
>              "%12s%10s%12s%10s%10s%10s%10s%10s")
> end if
> if (tofloat(grad_value_1) .lt. tofloat(grad_value_2)) then
>   grad_value_flag = flag_table_fillcolor
> end if
>
> **OUTPUT with 6.4.0*:*
>
> (0) cost,grad,step,b,step? =   1   0  1.498929611143528717E+06
>  2.048988964546030616E+02  1.211877385244983785E+00
>  0.000000000000000000E+00  good
> ......
> (201) cost,grad,step,b,step? =   2 150  1.131911262744225329E+06
> 5.6766037650629
> *47227E-02  1.791057212970216916E+00  9.879673418565034781E-01*
> good
> (0) Reading Cost and Gradient...
> warning:toint: there are 1 float(s) larger than INT_MAX, which have been
> flagged missing.
> warning:toint: there are 1 float(s) larger than INT_MAX, which have been
> flagged missing.
> (0) 1.498929611143528717E+06
> (0) 1.131911262744225329E+06
> (0) 1498930
> (0) 1131911
> warning:toint: there are 1 float(s) larger than INT_MAX, which have been
> flagged missing.
>
> Variable: unnamed (return)
> Type: float
> Total Size: 4 bytes
>             1 values
> Number of Dimensions: 1
> Dimensions and sizes: [1]
> Coordinates:
> Number Of Attributes: 1
>   _FillValue : -2.147484e+09
> (0) -2.147484e+09
>
> warning:toint: there are 1 float(s) larger than INT_MAX, which have been
> flagged missing.
>
> Variable: unnamed (return)
> Type: float
> Total Size: 4 bytes
>             1 values
> Number of Dimensions: 1
> Dimensions and sizes: [1]
> Coordinates:
> Number Of Attributes: 1
>   _FillValue : -2.147484e+09
> (0) -2.147484e+09
>
> Variable: cost_value_1
> Type: string
> Total Size: 8 bytes
>             1 values
> Number of Dimensions: 1
> Dimensions and sizes: [1]
> Coordinates:
> Number Of Attributes: 1
>   _FillValue : -2147483648 <(214)%20748-3648>.000000
> (0) -2147483648.000000
>
> Variable: cost_value_2
> Type: string
> Total Size: 8 bytes
>             1 values
> Number of Dimensions: 1
> Dimensions and sizes: [1]
> Coordinates:
> Number Of Attributes: 1
>   _FillValue : -2147483648 <(214)%20748-3648>.000000
> (0) -2147483648.000000
>
> fatal:The result of the conditional expression yields a missing value. NCL
> can not determine branch, see ismissing function
>
> fatal:["Execute.c":8640]:Execute: Error occurred at or near line 92 in
> file
> /scratch4/BMC/qosap/noscrub/VERIF_PKG/anl_monitor/gsi_
> stats/scripts/create_minimization_data.ncl
>
> **OUTPUT with 6.3.0*:*
> (0) cost,grad,step,b,step? =   1   0  1.498929611143528717E+06
>  2.048988964546030616E+02  1.211877385244983785E+00
>  0.000000000000000000E+00  good
> ......
> (201) cost,grad,step,b,step? =   2 150  1.131911262744225329E+06
> 5.676603765062947227E-02  1.791057212970216916E+00
>  9.879673418565034781E-01
>   good
> (0) Reading Cost and Gradient...
> (0) 1.498929611143528717E+06
> (0) 1.131911262744225329E+06
> (0) 1498930
> (0) 1131911
>
> Variable: unnamed (return)
> Type: float
> Total Size: 4 bytes
>             1 values
> Number of Dimensions: 1
> Dimensions and sizes: [1]
> Coordinates:
> (0) 1498930
>
> Variable: unnamed (return)
> Type: float
> Total Size: 4 bytes
>             1 values
> Number of Dimensions: 1
> Dimensions and sizes: [1]
> Coordinates:
> (0) 1131911
>
> Variable: cost_value_1
> Type: string
> Total Size: 8 bytes
>             1 values
> Number of Dimensions: 1
> Dimensions and sizes: [1]
> Coordinates:
> (0) 1498929.625000
>
> Variable: cost_value_2
> Type: string
> Total Size: 8 bytes
>             1 values
> Number of Dimensions: 1
> Dimensions and sizes: [1]
> Coordinates:
> (0) 1131911.250000
>
>
> Thank you,
> Tanya
>
>
> --
> Tanya R. Peevey, PhD
> Research Scientist I, Global Observing Systems Analysis (GOSA) Group
> NOAA ESRL Global Systems Division
> 325 Broadway, Boulder, CO 80305
> (303) 497-5847
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20180316/b1670627/attachment.html>


More information about the ncl-talk mailing list