[ncl-talk] Problem writing NetCDF file

Mary Haley haley at ucar.edu
Tue Dec 8 12:14:58 MST 2015


Arun,

In the future, please include a Subject line when posting to NCL-talk. I
added one for you.

It looks like you may be hitting a NetCDF 2 GB limitation on the size of
your file. I believe in your case it's happening because one of the
variables you are trying to write is more than 2 GB into the NetCDF file.

If you enable "large file support" the problem should go away. To do this,
add this line:

setfileoption("nc","format","largefile")

before this line:

        fw = addfile("gfsout_2015113000.nc", "c")

You have some code in your script that is needlessly using up extra memory,
and could potentially make your code slower.  For example, I'm not sure why
you have these lines, but you shouldn't need them:

tc = new((/nlev,ntime,nlat,nlon/),"float")

        ua = new((/nlev,ntime,nlat,nlon/),"float")

        va = new((/nlev,ntime,nlat,nlon/),"float")

        wa = new((/nlev,ntime,nlat,nlon/),"float")

        ws = new((/nlev,ntime,nlat,nlon/),"float")

        wd = new((/nlev,ntime,nlat,nlon/),"float")

T2 = new((/ntime,nlat,nlon/),"float")

        rh2 = new((/ntime,nlat,nlon/),"float")

Also, I believe you could significantly speed up the NetCDF file creation
part by predefining your variables.

Please see this page on writing NetCDF files:

http://www.ncl.ucar.edu/Applications/o-netcdf.shtml

On this page are two ways to write NetCDF files: the inefficient but easy
way (method #1), and the efficient-but-more-coding-required-way (method #2).

You are using method #1. I suggest looking at the code for method #2.

Finally, I noticed that while you have named your dimensions "time",
"level", "lat" and "lon", you don't have any coordinate arrays attached to
your variable, and nor are you writing any type of time, level, latitude,
or longitude arrays to the file.  Please make sure you are writing your
file correctly.

​If you continue to have questions about NCL, post them to ncl-talk, but
with a subject line included.

Thanks,

--Mary
​

On Tue, Dec 8, 2015 at 5:53 AM, Arun Kumar Dwivedi <
dwivedi.arunkumar at gmail.com> wrote:

> Hello Everyone,
> I am extracting some parameters from  an nc file, do some calculations and
> writing all the parameters into a nother nc file.
> I have some error.
> Kindly help me.
> The script and the error screenshot is attached herewith.
>
> Thanks & Regards
> Arun Kumar Dwivedi,
>
>
> _______________________________________________
> 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/20151208/be3640cc/attachment.html 


More information about the ncl-talk mailing list