Re: Encountering problem with filedimdef

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Wed Dec 29 2010 - 10:45:47 MST

The following works fine so not sure of your issue.

    some_name = (/"a", "b", "c", "d", "e"/)
    some_size = (/ 10, 20 , 30, 40, 50/)
    ndim = dimsizes(some_name)

    dim_names = new( ndim, string )
    dim_sizes = new( ndim, integer, -1 )
    dimUnlim = new( ndim, logical )

    do id = 0, ndim-1
         dim_names(id) = some_name(id)
         dim_sizes(id) = some_size(id)
         dimUnlim(id) = False
    end do

    system("/bin/rm -f foo.nc") ; remove any pre-existing file
    ncf = addfile("foo.nc" ,"c")
    filedimdef( ncf, dim_names, dim_sizes, dimUnlim )

===
%> ncdump -h foo.nc or ncl_filedump foo.nc

netcdf foo {
dimensions:
        a = 10 ;
        b = 20 ;
        c = 30 ;
        d = 40 ;
        e = 50 ;
}
===
I note the name of your script: jra25_grib2nc_functions.ncl

I am not sure if you are aware of

http://www.ncl.ucar.edu/Document/Tools/ncl_convert2nc.shtml
http://www.ncl.ucar.edu/Document/Tools/ncl_filedump.shtml

On 12/28/10 6:00 PM, Andy Barrett wrote:
> Hi
>
> I'm getting an error that I don't understand when trying to define a
> netCDF file.
>
> "fatal:Execute: Error occurred at or near line 928 in file
> $HOME/src/NCL/grib2nc/jra25_grib2nc_functions.ncl"
>
> The problem is occuring when I try to define file dimensions using
> filedimdef.
>
> If I define dim_names, dim_sizes and dimUnlim using the following I get
> the error message above.
>
> dim_names = new( ndim, string )
> dim_sizes = new( ndim, integer, -1 )
> dimUnlim = new( ndim, logical )
> do id = 0, ndim-1
> dim_names(id) = some_name(id)
> dim_sizes(id) = some_size(id)
> dimUnlim(id) = False
> end do
> filedimdef( ncf, dim_names, dim_sizes, dimUnlim )
>
> However, if I define dim_names etc explicitely I don't get an error. E.g.
>
> dim_names = (/ "lon", "lat", "lev", "time" /)
> dim_sizes = (/ nlon , nlat , nlev , ntim /)
> dimUnlim = (/ False , False, False , True /)
> filedimdef( ncf, dim_names, dim_sizes, dimUnlim )
>
> Am I missing something or am I trying to do something that can't be done?
>
> I'd like to use the former method because I don't want to hardcode the
> number of dimensions into the code.
>
> Cheers
>
> Andy Barrett
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Wed Dec 29 10:45:52 2010

This archive was generated by hypermail 2.1.8 : Tue Jan 04 2011 - 09:16:52 MST