[ncl-talk] ispan for floating steps

Dennis Shea shea at ucar.edu
Tue Oct 13 16:00:43 MDT 2015


I speculate possible rounding issues are the rationale for not having a
supported 'testspan'.

fortran-66 or fortran_-V used to allow a real/double 'stride' in do loops.
In some cases, the rounding errors resulted in premature loop termination
or one extra iteration.  A real/double stride was no longer allowed
starting with f77.

On Tue, Oct 13, 2015 at 2:01 PM, Mary Haley <haley at ucar.edu> wrote:

> There's an undocumented build-in function called "testspan" that may also
> do what you want.
>
> It's never been made public and it is *not* guaranteed to live forever, so
> use at your own risk.
>
> These three statements should give you the same set of values:
>
>   ilat = ispan(-360, 360,   5)   * 0.25
>
>   flat = fspan( -90,  90, 145)
>
>   lat  = testspan(  -90,  90,   1.25)
>
> The next question is probably going to be: "why isn't this public"?
>
> The answer is, "I don't remember".  I think it has something to do with
> precision accuracy that can potentially cause a problem. Here's an example
> of where you would get different values, with a slight change in precision:
>
> f1 = testspan(1,9.999999,3)   ; 1,4,7
>               f2 = testspan(1,9.9999999,3)  ; 1,4,7,10
>
> If you add a "d" to make the second argument a double, then you get better
> results:
>
> d1 = testspan(1,9.999999d,3)   ; 1,4,7
> d2 = testspan(1,9.9999999d,3)  ; 1,4,7
>
> --Mary
>
>
>
> --Mary
>
>
>
> On Tue, Oct 13, 2015 at 6:54 AM, Carl Schreck <cjschrec at ncsu.edu> wrote:
>
>> This is a feature I'd wanted too, so I wrote a simple little function to
>> do it (attached). cspan (for Carl's span, because I couldn't think of
>> anything more descriptive).
>>
>>    Carl
>>
>> On Fri, Oct 9, 2015 at 9:58 AM, Dennis Shea <shea at ucar.edu> wrote:
>>
>>> Please see 'fspan'
>>>
>>> xlow = 1e-7
>>> xhi   = 4e-05
>>> xinc = 1e-7
>>> nn   = toint((xhi-xlow)/xinc)+1
>>>
>>> x = fspan(xlow, xhi, nn)
>>>
>>> ====
>>> *you* can create your own function
>>>
>>> function myspan(xlow, xhi, xinc)
>>>
>>> that will return  the values
>>>
>>> On Fri, Oct 9, 2015 at 6:55 AM, Ahmad Farsyud <a.farsyud at gmail.com>
>>> wrote:
>>> > Hallo,
>>> >
>>> > Is there any solution to execute the following command:
>>> >
>>> > ncl 0> x= ispan (1e-7,4e-5,1e-7)
>>> > fatal:ispan: arguments must be of an integral type, can't continue
>>> > fatal:["Execute.c":8573]:Execute: Error occurred at or near line 0
>>> >
>>> > Thanks
>>> > Ahmad
>>> >
>>> > _______________________________________________
>>> > ncl-talk mailing list
>>> > ncl-talk at ucar.edu
>>> > List instructions, subscriber options, unsubscribe:
>>> > http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>> >
>>> _______________________________________________
>>> ncl-talk mailing list
>>> ncl-talk at ucar.edu
>>> List instructions, subscriber options, unsubscribe:
>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>>
>>
>>
>>
>> --
>>
>> <http://www.cicsnc.org/>
>> <http://www.researcherid.com/rid/B-8711-2011>
>> * Cyclone <http://www.cyclonecenter.org/>*Center.org
>> <http://www.cyclonecenter.org/>  *Carl J. Schreck III, PhD*
>> *Research Associate*
>> Cooperative Institute for Climate and Satellites NC (CICS-NC)
>> <http://www.cicsnc.org/> /
>> North Carolina Institute for Climate Studies (NCICS)
>> <http://www.cicsnc.org/>
>> North Carolina State University <http://ncsu.edu/>
>> NOAA National Centers for Environmental Information (NCEI)
>> <http://ncei.noaa.gov/>
>> 151 Patton Ave, Asheville, NC 28801
>> e: cjschrec at ncsu.edu
>> o: +1 828 257 3140
>> Publications
>> <http://scholar.google.com/citations?hl=en&user=th8ONEcAAAAJ&view_op=list_works&sortby=pubdate>
>> monitor.cicsnc.org/mjo
>>
>> _______________________________________________
>> ncl-talk mailing list
>> ncl-talk at ucar.edu
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
>>
>
> _______________________________________________
> 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/20151013/b808e943/attachment.html 


More information about the ncl-talk mailing list