[ncl-talk] Divide by zero error using "pot_vort_isobaric" function

Daniel Swain danielswain2 at gmail.com
Thu Mar 10 13:27:42 MST 2016


Thanks, Kyle and Dennis!

Yes, the older version of "shea_util.ncl" seems to have been the problem. I
am no longer getting errors after using the most recent/supported version
of the function.

Thanks for the prompt response and quick fix!

Cheers,
Daniel

On Wed, Mar 9, 2016 at 9:57 PM, Dennis Shea <shea at ucar.edu> wrote:

> Kyle is correct.
>
> Basically the 6.3.0 shea_util.ncl had ''back-door' interfaces  to older
> versions pot_vort_isobaric and pot_vort_hybrid. These were used for old
> testing. Unfortunately, they were not deleted. As 'they' ...my bad!
>
> Please download:
>     http://www.cgd.ucar.edu/~shea/contributed.ncl_640
>
>
> Place these in some directory, load these files in your script. If these
> files are in the same directory as your script ...
>
> load "./contributed.ncl_640"
> ... your_script...
>
> ===
>
>
> The shea_util.ncl_640 need not be loaded. If you decide to do so,
> http://www.cgd.ucar.edu/~shea/shea_util.ncl_640
>
> load "./contributed.ncl_640"
> load "./shea_util.ncl_640"
> ... your_script ...
>
> ===
> If your script still fails, you can upload your script and data files to:
>
> ftp ftp.cgd.ucar.edu
> anonymous
> your_email
> cd incoming
> put ...
> put ...
> ...
> quit
>
> Then, after successful transfer. let me know.
>
> Cheers
> D
>
>
>
>
>
>
>
>
> On Wed, Mar 9, 2016 at 10:26 PM, Kyle Griffin <ksgriffin2 at wisc.edu> wrote:
>
>> Hi Daniel,
>>
>> OK, I finally read your email in all the detail I should have the first
>> time and found what should likely be an easy fix (this is the 3rd time I've
>> written this email - probably shouldn't reply to the list at this hour!).
>>
>> You're reading a version in from shea_util.ncl, which is an older, out of
>> date, and unsupported version of pot_vort_isobaric (anything in
>> shea_util.ncl is unsupported, technically - and note the file and line
>> numbers in your error message). The safe guards for static stability that
>> you've likely seen Dennis and I discuss in previous posts have been fully
>> implemented in the contributed.ncl version that became officially supported
>> in the 6.3.0 release. I suggest you either comment out your load of
>> shea_util.ncl (if possible) or ensure that you load contributed.ncl after
>> you load shea_util.ncl - this should ensure the older function is redefined
>> when you load contributed.ncl.
>>
>> Hope that is an easy fix and that your calculations will work now.
>>
>>
>> Kyle
>>
>> On Wed, Mar 9, 2016 at 6:57 PM Daniel Swain <danielswain2 at gmail.com>
>> wrote:
>>
>>> Hello,
>>>
>>> I'm currently attempting to use the built-in NCL function to calculate
>>> potential vorticity ("pot_vort_isobaric"). Unfortunately, I am repeatedly
>>> getting a divide by zero error:
>>>
>>> "
>>> fatal:divide: Division by 0, Can't continue
>>> fatal:Div: operator failed, can't continue
>>> fatal:["Execute.c":8575]:Execute: Error occurred at or near line 3892
>>> in file $NCARG_ROOT/lib/ncarg/nclscripts/csm/shea_util.ncl
>>> fatal:["Execute.c":8575]:Execute: Error occurred at or near line 3909
>>> in file $NCARG_ROOT/lib/ncarg/nclscripts/csm/shea_util.ncl
>>> "
>>>
>>> I have confirmed that my original units are in hPa (thus the *100 hPa->
>>> Pa conversion should be correct), and that the original latitudes were
>>> north->south (so the lat flip should also be correct). I'm assuming this
>>> occurring during the static stability calculation (as mentioned in previous
>>> ncl-talk discussions), but I'm not sure whether there has yet been a
>>> resolution.
>>>
>>> I've attempted this with data from different years, but eventually a
>>> zero division error always crops up. A short sample script is below, and
>>> representative data files have been uploaded to the FTP site with the same
>>> names as below.
>>>
>>> I'm currently using NCL version 6.3.0.
>>>
>>> Thanks very much for any advice!
>>>
>>> ~Daniel
>>>
>>> "
>>> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
>>> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
>>> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
>>> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/shea_util.ncl"
>>>
>>> begin
>>>
>>> infile1 = addfile ("air.2013.nc", "r")
>>> infile2 = addfile ("uwnd.2013.nc", "r")
>>> infile3 = addfile ("vwnd.2013.nc", "r")
>>>
>>>      U   = infile2->uwnd   ; (time,lev,lat,lon)
>>>      V   = infile3->vwnd
>>>      T   = infile1->air    ; K
>>>
>>>      lev = T&level  ; hPa
>>>      lev = lev*100 ; convert units
>>>      lev at units = "Pa"
>>>
>>>      U   = U(:,:,::-1,:)    ; reorder to South -> North
>>>      V   = V(:,:,::-1,:)
>>>      T   = T(:,:,::-1,:)
>>>
>>>      lat = T&lat
>>>      gridType  = 0          ; Gaussian grid
>>>      opt = 0
>>>      pvort = pot_vort_isobaric(lev,U,V,T,lat, gridType, opt)
>>>
>>> outfile1=addfile("pvort.2013.nc","c")
>>> outfile1->pvort = pvort
>>>
>>> end
>>>
>>> "
>>> _______________________________________________
>>> 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/20160310/e7ea0c94/attachment.html 


More information about the ncl-talk mailing list