NOTICE: This version of the NSF Unidata web site (archive.unidata.ucar.edu) is no longer being updated.
Current content can be found at unidata.ucar.edu.
To learn about what's going on, see About the Archive Site.
Mahakur, The easiest way is to use a Netcdf built-in feature called automatic type conversion. https://www.unidata.ucar.edu/software/netcdf/docs/data_type.html#type_conversion The library will automatically read 16-but ushort integers into default 32-bit signed integer fortran arrays. The library will perform the type conversion for you. This way, you simply declare a default integer array, then call the Netcdf read function. Since the variables are unsigned short in the file, the result in fortran will be all non-negative integers in the 16-bit unsigned range, which is 0 to 65535. use netcdf integer ncId, varId, status integer array(dim1,dim2,dim3) ... status = nf90_get_var (ncid, varid, array) if (status /= nf90_NoErr) call handle_err (status) --Dave On Thu, Oct 11, 2018 at 2:18 AM, M.Mahakur <mmahakur@xxxxxxxxxxxxxx> wrote: > Hi, > > I have few variables as "ushort data1(dim1,dim2,dim3)" which I wish to > read using fortran API as I am not good with C/C++. Can you please suggest > how do I proceed and declare in fortran code data1. I felt there I can not > use something like "unsigned (kind=2), allocatable, dimension(:,:,;) :: > data1". How do I declare/syntax for 2-bytes unsigned integer? > > With Thanks and Regards, > Mahakur > > IITM, Pune >
netcdfgroup
archives: