Re: Regridding Daymet Joined Tiles with ESMF_Regridding on NCL 6.1.0

From: Dave Allured - NOAA Affiliate <dave.allured_at_nyahnyahspammersnyahnyah>
Date: Tue Nov 20 2012 - 16:16:04 MST

Ping,

As is often the case, the very first error message is the best clue.
"NetCDF: One or more variable sizes violate format constraints" --
This frequently indicates that you are trying to write more than 2
gbytes to a Netcdf-3 file, without using the unlimited dimension.
Indeed, look at the main array size for "prcp":

1551 x 1872 x 366 days/year x 4 bytes/float = 4.3 gbytes

The simplest fix would be to just use setfileoption to write the
output file in Netcdf-4 format. You could also try to make the time
dimension unlimited with filedimdef. However, this is tricky because
of certain constraints on the order of defining and writing variables.
 So try Netcdf-4 and see how that works.

--Dave

On Mon, Nov 19, 2012 at 2:00 PM, Ping Yang <pyang@ccny.cuny.edu> wrote:
> Dear NCL,
>
> I am trying to fix the issue with the joined Daymet grid, I used to
> following script to generate a new file with the corrected coordinates:
>
> 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"
> begin
>
> Variable = "prcp"
>
>
> nx = 1551
> ny = 1872
> N = nx * ny
> ;full_coordinate.dat
> file1="full_coordinate.dat" ;the coordinate file
>
> z3 = asciiread(file1,(/N,4/),"double")
>
> lat1d=z3(:,2)
> lon1d=z3(:,3)
> dim2=(/ny,nx/)
> lat2d=onedtond(lat1d,dim2)
> lon2d=onedtond(lon1d,dim2)
> printVarSummary(lat2d)
> printVarSummary(lon2d)
> ;--find the zero value in the 2d lat and lon from the merged grid file
> ;NE_all_1980_prcp.nc
> file2="NE_all_1980_" + Variable + ".nc"
> ofile= "NE_all_1980_correct_" + Variable + ".nc"
> o = addfile(ofile, "c")
> f = addfile(file2,"r")
> lat = f->lat
> lon = f->lon
> p = f->prcp
> printVarSummary(p)
> printVarSummary(lat)
> printVarSummary(lon)
> ;--fill the zero with the generated coordinates
>
> ;If lat and lon are the same size as lat2d and lon2d, then you can use
> "where", instead of a do loop:
> lat_new = where(lat.eq.0,lat2d,lat)
> lon_new = where(lon.eq.0,lon2d,lon)
> o->prcp=f->prcp
> ;o->x=f->x
> ;o->y=f->y
> o->lat=lat_new
> o->lon=lon_new
>
> end
>
> The errors are:
> ncendef: ncid 65536: NetCDF: One or more variable sizes violate format
> constraints
> fatal:NetCDF: Operation not allowed in define mode: error attempting to
> write variable (time) to file
> (/data/ecr/yangping/DAYMET/Grid/1KM/prcp/NE_all_1980_correct_prcp.nc)
> warning:FileWriteVarVar: Could not write coordinate variable (time) to file
> (NE_all_1980_correct_prcp), continuing anyway
> ncredef: ncid 65536: NetCDF: Operation not allowed in define mode
> ncendef: ncid 65536: NetCDF: One or more variable sizes violate format
> constraints
> fatal:NetCDF: Operation not allowed in define mode: error attempting to
> write variable (y) to file
> (/data/ecr/yangping/DAYMET/Grid/1KM/prcp/NE_all_1980_correct_prcp.nc)
> warning:FileWriteVarVar: Could not write coordinate variable (y) to file
> (NE_all_1980_correct_prcp), continuing anyway
> ncredef: ncid 65536: NetCDF: Operation not allowed in define mode
> ncendef: ncid 65536: NetCDF: One or more variable sizes violate format
> constraints
> fatal:NetCDF: Operation not allowed in define mode: error attempting to
> write variable (x) to file
> (/data/ecr/yangping/DAYMET/Grid/1KM/prcp/NE_all_1980_correct_prcp.nc)
> warning:FileWriteVarVar: Could not write coordinate variable (x) to file
> (NE_all_1980_correct_prcp), continuing anyway
> warning:["Execute.c":7743]:Execute: Error occurred at or near line 48 in
> file assign_coordinate.ncl
>
> I don't understand why I can not do this? Is there a way that I can write
> back the correct coordinate to the original file(without change other
> value)?
>
> Looking forward to hearing from you.
>
> Best Regards,
>
> Ping
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Tue Nov 20 16:16:18 2012

This archive was generated by hypermail 2.1.8 : Wed Nov 21 2012 - 11:16:05 MST