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.
Hello Dan, The data type is a function of the process creating the original netCDF4 files. If the variables are float in the netCDF4 files being provided, they will retain the same data type when converted to netCDF3. There is not an easy way to convert them from float to short, unfortunately. This would require writing a program to create a new variable of type short, reading the values from the variable of interest, converting them to short, and assigning them to the new variable. You could potentially side-step this by casting values to short in your application, but I can't recommend this because I don't know if this would cause other problems on your end. Regarding your final question, I don't think there is a problem with reading the converted files; the problem stems from what was once a 'short' variable is now a 'float' variable. The fact that it is also now a netCDF4 file is unrelated. I know this probably isn't as much help as you'd like, but I think the solution to this will be either to modify your application to handle the new data type of the variable, or to write a pre-processor which will convert the files being provided to you into the format you expect. Let me know if I can answer any further questions, have a great day, -Ward > We have an application that previously used netCDF3 files from NCAR. Since > they changed to netCDF4, our application fails. We started looking into > fixing the code. NCAR says the you can convert back to netCDF3 with the > nccopy command. I tried: nccopy -k classic filenetcdf4.nc filenetcdf3.nc. > It looks like I get the same errors in my code using these converted files > instead. If I dump the files with ncdump, variable that were short in netCDF3 > (original format fromNCAR) are indicated to be float in both netCDF4 and in > the converted netCDF3. - In any case, I want to know if there is a way to > convert the netCDF4 files EXACTLY back to netCDF3 files. It seems > unlikely, but is it possible that now that we have recompiled our application > with the latest version of netCDF there is a problem reading the converted > files? > > Dan MacMillan > > Ticket Details =================== Ticket ID: XEI-820003 Department: Support netCDF Priority: Normal Status: Closed