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 Jam, > I try to read the netcdf file of wrf input. > When I try to complie the program, it showed me warning message as > > nc_inq_dimlen' from incompatible pointer type That warning message is because you have declared the dimension lengths we_len, sn_len, and soil_layer_len to be of type "int", but the documentation for the nc_inq_dimlen function says the returned dimension lengths are really of type "size_t", which is the appropriate type for an integer that represents the size of something, such as a block of memory or an array index. You could get rid of the compile warnings by using the declaration size_t we_len, sn_len, soil_layer_len; instead of the current int declaration for those lengths. > When I ran the program, it could not get any function from header file of > netcdf > and it caused "segmentation error" The warnings from using an "int" rather than a "size_t" declaration for the dimension lengths could cause such a problem if you are running on a 64-bit platform, where an int is 32-bits but a size_t is 64 bits. In that case, the call to nc_inq_dimlen would be trying to stuff a 64-bit value into a 32-bit location, overwriting whatever followed that location. > This is my program, would you mind giving me suggestion what wrong with it. > > I use this command for compile it > gcc -o modify_netcdf_field modify_netcdf_field.c > -I/opt/graphics/pgi/64/6.2-3/netcdf/include > -L/opt/graphics/pgi/64/6.2-3/netcdf/lib -lnetcdf > -L/opt/pgi-7.1-1/linux86-64/7.1-1/lib/ -lpgc --Russ Russ Rew UCAR Unidata Program address@hidden http://www.unidata.ucar.edu Ticket Details =================== Ticket ID: SCL-829369 Department: Support netCDF Priority: Normal Status: Closed