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 Rachel, > I am having a lot of trouble reading netcdf variables with the data type > BYTE. For example, I am trying to read flag values where each byte is > given a specific reason for being flagged. I understand that variable data > should be an 8 bit number of zeros and ones, but the Fortran 90 compiler > and system I use apparently only reads in signed integers from -128 to 127. > > Are there some netcdf commands I could use to convert this to something I > can understand? Try transforming the values with something like if(ival < 0) ival = ival + 256 That transforms the range of signed integers between -128 to 127 into the unsigned integers 0 to 255 in a way that preserves the bits for bit flags. NetCDF-4 explicitly supports unsigned bytes with the type nf90_ubyte, but the above trick may let you deal with signed bytes as if they were unsigned. --Russ Russ Rew UCAR Unidata Program address@hidden http://www.unidata.ucar.edu Ticket Details =================== Ticket ID: QCI-275305 Department: Support netCDF Priority: Normal Status: Closed