This archive contains answers to questions sent to Unidata support through mid-2025. Note that the archive is no longer being updated. We provide the archive for reference; many of the answers presented here remain technically correct, even if somewhat outdated. For the most up-to-date information on the use of NSF Unidata software and data services, please consult the Software Documentation first.
Hi Sujata, > I need to clarify certain things regarding the existing netCDF file. If > I want to add some new variables, then I need to define the dimensions, > attributes for that variable. If I am defining the existing dimension > with different name, then it is possible to defining other new variables > with the defined existing dimensions. But, > > 1) Suppose I want to add some new variables with the existing dimension > definition without defining the existing dimension with different name. > Then is it possible? Yes, you can just enter "define mode" using NF90_REDEF or nc_redef, define your new variables in terms of existing dimensions using NF90_DEF_VAR or nc_def_var, then leave define mode using NF90_ENDDEF or nc_enddef. At this point if the existing file is a netCDF classic format file (created with netCDF-3 libraries), the header of the file will most likely have to grow to accomodate the metadata for the new variables, which will result in all of the data being copied after the new header. This could be slow for vary large files. > I am providing an example of the header of a netCDF file as follows. > Here, LU_INDEX is defined over Time, south_north, west_east. Suppose I > want to add LU_INDEX_1 defined over Time, south_north, west_east. Then > Is it possible? Yes, as outlined above in the Fortran 90 interface or the C interface. In general, if you think you will be adding variables, dimensions, or attributes to a file, it might be a good idea to reserve extra space in the file header when the netCDF file it is first created, buy using the NF90__ENDDEF or nc__enddef interfaces. > netcdf wrfinput_d01 { > dimensions: > Time = UNLIMITED ; // (1 currently) > DateStrLen = 19 ; > west_east = 299 ; > south_north = 399 ; > bottom_top = 50 ; > bottom_top_stag = 51 ; > DIM0006 = 2600 ; > soil_layers_stag = 4 ; > variables: > float LU_INDEX(Time, south_north, west_east) ; > > Thanks > Sujata You're welcome. I hope this helps. --Russ Russ Rew UCAR Unidata Program address@hidden http://www.unidata.ucar.edu Ticket Details =================== Ticket ID: KSN-678838 Department: Support netCDF Priority: Normal Status: Closed