Scheduled Downtime
On Friday 21 April 2023 @ 5pm MT, this website will be down for maintenance and expected to return online the morning of 24 April 2023 at the latest

Error modifying wrfinput_d01 using NCL

jethong

New member
Hello,

I am trying to modify the value of a certain variable of wrfinput_d01 using NCL. For example, the following code:
----------------
a=addfile("wrfinput_d01","w"),
x =a->HGT
----------------

It returns the following error message:
----------------
fatal:["NclNetCDF4.c":3073]:NclNetCDF4.c: Error in nc_def_var_chunking in file (wrfinput_d01) for writing, at line: 3073
line 3074 of NclNetCDF4.c: NetCDF: Attempt to define var properties, like deflate, after enddef.
----------------

For read only mode (a=addfile("wrfinput_d01","r")), it won't cause any error.

I searched google, and learned that it probably owning to something like data format or compression format issues, but I am not sure.

Is there any solutions to this issue ?

I appreciate any response.

Jet
 
Please follow the example below to modify tour data:

in = addfile("./met_em.d01.2017-09-12_00:00:00.nc","w")


xlat=in->XLAT


print (xlat)


new_xlat=0


in->XLAT=new_xlat


You may need to rename wrfout_d01 to wrfout_d01.nc.
 
Dear Ming,

Thank you for the reply.
The ncl ended when trying to read variable and return same error, as follows:

ncl 0> a=addfile("met_em.d01.2019-01-01_06:00:00.nc","w")
ncl 1> x=a->XLAT_U
fatal:["NclNetCDF4.c":3073]:NclNetCDF4.c: Error in nc_def_var_chunking in file (met_em.d01.2019-01-01_06:00:00.nc) for writing, at line: 3073
line 3074 of NclNetCDF4.c: NetCDF: Attempt to define var properties, like deflate, after enddef.

Jet
 
Jet,
I believe this is either a data issue or NCL version issue.
I just tried the same method to process a met-em file, and all works fine. I cannot repeat your problem.
 
Hi Dr. Chen,
I also intend to modify some value of T in wrfinput File, but the modified file cannot be used for wrf.exe. Checking the wrfinput file, the revised data has been saved in the wrfinput file, but I realised some additional information.
netcdf wrfinput_r {


dimensions:


Time = UNLIMITED ; // (1 currently)


DateStrLen = 19 ;


west_east = 400 ;


south_north = 400 ;


bottom_top = 64 ;


bottom_top_stag = 65 ;


soil_layers_stag = 4 ;


dust_erosion_dimension = 3 ;


west_east_stag = 401 ;


south_north_stag = 401 ;


DIM0010 = 5 ;


land_cat_stag = 21 ;


soil_cat_stag = 16 ;


num_ext_model_couple_dom_stag = 1 ;


ncl14 = 1 ;


ncl15 = 36 ;


ncl16 = 400 ;


ncl17 = 400 ;

Not sure if it causes the error but it is confusing why it appears after the value is modified. The method I used to modify the Netcdf file is the same as you mentioned above.
 

@MSdueon12,​

I just did a quick test and all is fine. I cannot repeat your problem. Did you follow exactly what I demonstrated above to change the variable? if so, I don't think you should have those weird variables like ncl17 etc.
 
Top